Instruction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

You’ll can pick up the app you’ve been building from the previous lesson, or you can download the starter and start to fill out the second tab with a Volume view. Before you dig into that, look at some key concepts and tools.

While Windows provide a spatial experience for relatively flat 2D content, Volumes provide more depth on the z-axis and move toward and away from the viewer. The new RealityView, a special SwiftUI View, adds the capability to display, add gestures, and functionality to 3D elements asynchronously in your view. The content is then presented in your app’s 3D space as a RealityViewContent content type.

A RealityView conforms to RealityViewContentProtocol, which includes make and update closures. The async make closure loads the content when the view is created, and the update closure deals with changes in the view’s state. You can also use the optional attachments closure to implement ViewBuilder attachment views to a scene.

You may recall that you had a Model3D view in the starter app. It’s a simpler SwiftUI view for asynchronously loading a model with a .usdz or .reality file. During loading, SwiftUI displays a spinner until it becomes a ResolvedModel3D. Model3D isn’t as robust as RealityView. RealityView also supports optional anchors for attaching your models, useful for plane tracking, hand tracking, and image tracking.

Pro Tip: If you’re familiar with SceneKit’s ARSCNView, you might find RealityView similar.

Universal Scene Description

A zipped Universal Scene Description or, more commonly, USDz, is often referred to in discussions of visionOS and Reality Composer Pro. The file format was initially developed by Pixar and maintained by Pixar, Apple, AudioDesk, and Nvidia.

Reality Composer Pro

If you select the Scene.usda or the Package.realitycomposerpro Swift Package file in Xcode 15, you’ll see a button on the top right that says Open in Reality Composer Pro. Tap that button to launch the Reality Composer Pro app and open the file.

Reality Composer Pro Window
Leulezb Julzejuc Gze Cuspok

Reality Composer Pro Inspector
Giolirs Suxxahal Dwo Eflnallen

Adding a Scene to the App

Back in Xcode, you can add Scenes or elements in the hierarchy inside a RealityView using the make: closure with loadEntity(), or load a scene by referencing the realityKitContentBundle. You can also simply load a model from the main Bundle or the realityKitContentBundle with Model3D. A RealityView is a more robust way to add 3D content.

See forum comments
Download course materials from Github
Previous: Introduction Next: Demo