Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Latest commit

 

History

History
62 lines (40 loc) · 1.84 KB

10113.md

File metadata and controls

62 lines (40 loc) · 1.84 KB
contributors
coughski

Introduction

There are 3 ways to display content in visionOS:

  • Window: 2D content
  • Volume: bounded 3D experiences
  • Full Space: display of unbounded 3D content

This talk focuses on Volumes.

Volumes

  • Can use without any windows
  • Provides a fixed scale container
  • Unlike windows, maintains the same size at any distance
  • Horizontally aligned, and support viewing from any angle
  • Doesn't take over the entire space
  • Use .windowStyle(.volumetric) modifier on a WindowGroup

3D views and layout

Model3D

  • A RealityKit view to load simple 3D scenes asynchronously
  • Similar to AsyncImage, you can use placeholders during loading
  • Use .resizable modifier with model, similar to Image
  • Default alignment is against back plane. Otherwise, use .frame(depth:alignment:) with .front alignment
  • Can use .glassBackgroundEffect() to make text labels readable in visionOS

RealityView

Use for more involved 3D scenes

Can use RealityKit's Entity-Component system for advanced rendering

RealityView attachments

  • Pair tagged (.tag) SwiftUI views with Entity inside RealityView
  • Useful for adding annotations or editing affordances
  • These live views can respond to state changes, run animations, and handle gestures

3D gestures

  • Existing gestures supported in 3D
  • Hands, eyes, trackpad mechanics supported

Add InputTargetComponent to RealityKit Entity to receive input

CollisionComponent is used to define shape of entity's interactive region

Can use SpatialTapGesture to allow user to interact with entity

.targetedToEntity modifier ties gestures to specific entities

Convert from SwiftUI local space to scene's coordinate space

Instead of loading another model using RealityKit, you can add a Model3D as an attachment

RotateGesture3D is another new gesture you can use