I am writing in Swift and trying to obtain the RealityKit camera's rotation. I've successfully gotten the position using:
xsettings.xcam = arView.session.currentFrame?.camera.transform.columns.3.x ?? 0);
xsettings.ycam = arView.session.currentFrame?.camera.transform.columns.3.y ?? 0);
xsettings.zcam = arView.session.currentFrame?.camera.transform.columns.3.z ?? 0);
this works excellently, but I haven't found a rotation solution that seems to work as well. Currently I am doing this:
xsettings.xcamrot = arView.session.currentFrame?.camera.eulerAngles[0] ?? 0;
xsettings.ycamrot = arView.session.currentFrame?.camera.eulerAngles[1] ?? 0;
xsettings.zcamrot = arView.session.currentFrame?.camera.eulerAngles[2] ?? 0;
but it doesn't seem to work correctly, there is a lot of weirdness on the roll (eulerAngles[2]) and just some inconsistency overall, at least compared to the positioning which is excellent. Just curious if there is a better way to access the camera's rotation?