Home

Awesome

visionOS Cubes Sample

Cubes provides a simple illustration of several features of visionOS apps written using SwiftUI and RealityKit. It was written using Xcode 15.4 and has been tested on visionOS 1.2, both within the simulator and deployed to a device.

The app displays three cubes that can be rotated individually when looking at them using a drag gesture while pinching your thumb and finger together. Within the simulator, you simply use the mouse to perform the drag gesture. As the cubes are rotated, observe the ground shadows on the plane below the cubes. There are two buttons on the toolbar illustrating the use of ornaments in visionOS, the first button allows you to reset the cubes to their original position. The second button applies gravity to the cubes so you can observe the physics that result from collisions. When the collisions occur, you'll also hear those collisions.

While this is an exceptionally simple example of using SwiftUI and RealityKit on visionOS, it illustrates the following:

The video below shows the Cubes sample running on an Apple Vision Pro with visionOS 1.2.

https://github.com/dougholland/Cubes/assets/11968218/4a16462b-39fd-4af1-a13a-c915fe5a00b2