Reset matrixWorldInverse

Summary of what I’m doing:

  • I have built an augmented reality scene with image tracking
  • I am image tracking a simple three plane to the image target and this plane is used as a portal
  • The plane lives in the main scene and canvas and the default camera is the user’s phone camera
  • I have built another three scene with it’s own perspective camera and have used react createPortal to inject in into the main scene
  • I am using webglmultisample render target to grab the virtual scene’s camera feed and map it to the main scene’s plane as a texture.
  • In my render loop I am copying the default camera’s matrixWorldInverse to the virtual scene’s camera’s matrixWorldInverse so that the user camera movement affects the virtual scene’s camera movement and mirrors it so that it looks as if you are viewing into the portal

My Problem:

  • On app start it seems as though the default camera’s (user’s phone camera) matrixWorld is initialized whichever way the user is holding the phone (which may be not facing the image target) at app start. Which creates this issue for example: If I start the app facing 90deg to right of the image target and then turn 90deg and try to view the portal plane all contents of the portal will be shifted 90deg.

I am looking for a way to say "Ok default cam’s matrix4, initialize your starting point at this phase of the application (a phase where the user is instructed to point their phone at the image Target) and use that as your starting reference so that when the virtual scene is copying your inverse, it reflects correctly.