Setting ARKit Orientation via Swift

Viewed 2009

I am developing an ARKit app with OpenGL, so working directly with ARKit and not using SceneKit.

By default, ARKit is set to landscape orientation, but I have been unable to track down any documentation or examples to rotate to portrait. SceneKit example works in portrait but the Metal example only works in landscape.

Is it possible to change the ARKit tracking orientation?

3 Answers

sorry on objective-c.

find and rewrite this

uniforms->viewMatrix = [frame.camera viewMatrixForOrientation:UIInterfaceOrientationLandscapeRight];
uniforms->projectionMatrix = [frame.camera projectionMatrixForOrientation:UIInterfaceOrientationLandscapeRight viewportSize:_viewportSize zNear:0.001 zFar:1000];

to

uniforms->viewMatrix = [frame.camera viewMatrixForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
uniforms->projectionMatrix = [frame.camera projectionMatrixForOrientation:[[UIApplication sharedApplication] statusBarOrientation] viewportSize:_viewportSize zNear:0.001 zFar:1000];

and

CGAffineTransform displayToCameraTransform = CGAffineTransformInvert([frame displayTransformForOrientation:UIInterfaceOrientationLandscapeRight viewportSize:_viewportSize]);

to

CGAffineTransform displayToCameraTransform = CGAffineTransformInvert([frame displayTransformForOrientation:[[UIApplication sharedApplication] statusBarOrientation] viewportSize:_viewportSize]);
Related