visionOS: An Introduction

Nov 21 2023 · Swift 5.9, visionOS 1.0 beta, Xcode 15

Lesson 02: Volumes & RealityView

Demo

Episode complete

Play next episode

Next

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can start with the app in the Starter folder or continue the build from lesson one.

import RealityKit
import RealityKitContent
RealityView { content in
  if let scene = try? await Entity(named: "Scene", in: realityKitContentBundle) {
    content.add(scene)
  }
}
NavigationSplitView {
  Text("Volume Tab")
    .font(.largeTitle)
    .foregroundColor(.orange)
} detail: {
  VolumeView()
}
.tabItem {
  Image(systemName: "cube")
  Text("Volume")
}

scene.availableAnimations.forEach { animation in
  scene.playAnimation(animation.repeat(), transitionDuration: 3, startsPaused: false)
}
@State var runAnimation = false
VStack {
  Button("Start") {
    runAnimation.toggle()
  }
  //..
}
} update: { content in
    if let scene = content.entities.first {

    }
}
if runAnimation {
  scene.playAnimation(animation.repeat(), transitionDuration: 3, startsPaused: false)
} else {
  scene.stopAllAnimations()
}
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion