简体   繁体   中英

How can I get the current rotation of the ARKit camera?

I'm trying to retrieve the current orientation of the ARKit camera. In portrait mode, I'm using session.currentFrame.camera.eulerAngles[1] which appears to work, however as soon as I switch to landscape, the angle is off. Any way I can work around this?

I'm not actually changing to landscape or portrait mode, it's always in portrait mode, but landscape mode in this context refers to simply holding the phone differently.

Transform the position of your camera with the following code.

var translation = matrix_identity_float4x4
translation.columns.3.z = -0.1 // Translate 10 cm in front of the camera
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)

Translating the camera would help you getting rotation property for the camera. Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM