In particular, one tutorial I followed had me grabbing the ARSCNView as sceneView and then printing sceneView.pointOfView.transform. This showed me what I expect: when the session is begun, the 4x4 matrix is very close to identity.
However, when using the ARCamera associated with each ARFrame, as in this code snippet:
Code Block extension ViewController: ARSessionDelegate { func session(_ session: ARSession, didUpdate frame: ARFrame) { print(frame.camera.transform.transpose) } }
I instead get a camera matrix that looks like (note the transpose is on purpose as I am more familiar with the row-major layout):
Code Block [0 1 0 0] [-1 0 0 0] [0 0 1 0] [0 0 0 1]
I've tried explicitly adding the ARWorldAlignment property to .gravity and .gravityAndHeading, but neither produces the expected identity matrix when the session is run.
I also added the .showWorldOrigin debug option, which shows the world axes as I would expect: +X to the right of my phone, +Y up, and -Z down the view axis.
What am I missing here? Can someone please clarify the coordinate systems of the transforms that ARFrame is returning and how they differ from those of ARSCNView?
At the end of the day, I am looking to log the camera pose (rotation and translation) during the session, and I would expect the initial position to have identity rotation and the camera center to be at the origin. How do I achieve that?