SPOILER: Don’t read on if you haven’t seen Thor: Ragnarok and plan to.

THAT moment when everyone in the cinema lost it? Yes, that was Matt Damon.

As far as celebrity cameos go, Damon’s in Thor: Ragnarok was kind of perfect. A blink-and-you’ll-miss-it bit, Damon was the fake Loki in the theatre play the real Loki staged on Asgard when Thor returns to confront his devious little brother.

And in case you missed it, that was Chris Hemsworth’s brother Luke playing fake Thor and Sam Neill playing fake Odin.

There are so many layers of meta-references.

How about another? This wasn’t the first time Damon has played a character named Loki. His avenging angel in Kevin Smith’s Dogma (1999) was also named Loki.

But that reference wasn’t intentional.

“I had no idea,” Thor: Ragnarok director Taika Waititi told news.com.au. “I’d completely forgotten about [about Damon’s Dogma Loki]. Matt and Chris know each other and we really wanted someone good and someone who’s funny.

“That was one of my favourite moments, getting him to do it.

“I thought if I was Loki and I was ruling Asgard, I would write a play about myself and force everyone to go and see it — change the details of the play and get a huge celebrity to play myself.”

Damon’s cameo didn’t even happen until Thor: Ragnarok had moved into post-production, according to executive producer Brad Winderbaum.

“We had shot the rest of the scene on the Gold Coast [in Australia] and we were getting a few little pieces here and there in post and additional photography [in New York] to fill some scenes and make things clearer.

“One day, Chris said to Taika, ‘you know, Matt is in New York, he’ll come down’. So we shot it on a lark and as soon as screened it in front of an audience, they just lost their minds.”

Thor: Ragnarok is in cinemas now.

For geek-outs about movies and TV, follow @wenleima on Twitter.