This will review how to use a handful APIs to use Windows, Volumes, and Full Space
Volumes
- This is used to emphasize 3D content. You get a fixed scaled container, which maintains the same size regardless of distance.
- You just use .windowStyle(.volumetric) to get started…. It’s that simple
3D views and layout
- Model3D API is used to load usdz objects and more. It is similar to asyncImage
- There is a a phase to landing a Model3D,
- These include .empty, .failure, .success
- You should use .scaleToFit() modifier so that the model can it within the volume
- By default alignment is back flush – so you want to use a .frame(depth: , alignment) modifier
- And than use .overlay to attach Labels
- Using a TimelineView you can add .animation to the 3D View so it has motion
RealityView
- For more complex scenes or experiences you should use RealityView instead of Model3D
- Using Entity/Component system – check out “Build Spatial Experience with RealityKit” and “Enhance your spatial computing app with RealityKit”
- Adding Attachments allow you to provide annotations relative to entities. You need to use any washable value for the .tag assigned to attachments
- .look(at: ) allow you to position and orient items
3D gestures
- To interact with these entities you need to configure them for input, this is achieved by adding both InputTargetComponent and CollisionComponent so that you can add spatial tap gestures
- There is also a .targetedToEntity so that gestures will fail if they are not on the specific entity. Use .onEnded to retrieve the coordinates of the gesture.
- You can add a Model3D as an attachment to a RealityView entity , don’t forget to add a .tag
- You can combine gestures in a Gesture Modifier to provide more functionality