'Use RealityKit ARView on macOS

I'm trying to use an ARView in a macOS-only project. I can load a scene (tested with a Reality file from Reality Composer), and it renders fine.

But how do I control the camera with the mouse?

An example of this is Reality Composer, Reality Converter, and previewing a Reality file in Xcode where you can drag anywhere on the view and the camera pans, rotates, etc. In SceneKit the equivalent is allowsCameraControl

  • There's no cameraMode on the macOS ARView, probably because it only supports nonAR anyway.

  • I tried adding a PerspectiveCamera hoping it would unlock interactivity, but no luck.

I guess I could just implement all the gestures myself, but that's a lot of work, and Apple seems to be using a standard way to interact with the scene with a mouse - and also a standard grid, which I'd love to use, too.

I'm using macOS 12 beta 1, but it shouldn't make a big difference since ARView requires macOS 10.15



Solution 1:[1]

Neither in macOS nor in iOS, RealityKit has a property similar to SceneKit's .allowsCameraControl. However, using this code as a starting point, you can create your own camera control in RealityKit.

This post can also be helpful for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1