Diploma in Apple Development 🍎👩🏻💻: Coding Two: Lecture 2: Build great apps for visionOS with RealityKit workshop.
Back to slide index.
👋🏻 Hi!
First, don't forget to confirm your attendance using the Seats Mobile app!
Second, I'm going to start every lecture with a meditation from the fantastic
Sitting Still Like a Frog book, all read by Myla Kabat-Zinn. If you don't want to participate that's completely fine.
This session is going to be a duplication of the workshop that I attended at Apple Battersea in November 2024: "Build great apps for visionOS with RealityKit".
Before we go through that code, let's start with revising our understanding of RealityKit with the following three articles:
Let's get on with the workshop! It's split between Xcode and Reality Composer Pro, so make sure you have got both installed. They should come together. While you are doing that, I'm going to AirDrop all the files to someone - please keep passing it around to others to make this process faster! Inside the zip file should contain 10 further zip files.
Each of the zips correspond to a task, and each task is broken down further. The nine tasks are:
Assembling the scene in Reality Composer Pro
Displaying your Scene in SwiftUI
Applying materials to the scene
Controlling the train's speed
Adding steam to the train
Adding light to the train
If we run out of time (likely), please complete as homework! Remember - you can always look at the zip file of the task ahead in order to work out to do if you get stuck!
1. Assembling the scene in Reality Composer Pro:
Start with realitykit-sampleapp-start.zip
Open and explore Reality Composer Pro
Create a new scene and import the model
2. Displaying your Scene in SwiftUI:
Add the TrainVolumeView SwiftUI View file
Instantiate a RealityView with a placeholder
Adjust the volumetric window size (1.5m cube)
Reposition the model on the surface of the window (y: -0.65m)
3. Applying materials to the scene:
Create a new ShaderGraphMaterial
Promote the uniform nodes
Creates instances of your material
Create your own water material
4. Building the Settings UI:
Create the TrainSettingsView UI
Add an ornament to the volume to open the view
5. Controlling the train's speed:
Create a var to store the AnimationPlaybackController
Get and play the baked animation in the RealityView
Update animation speed slider
6. Adding steam to the train:
Create a new Scene for the particle system
Edit the emitter and particles to your liking
Parent the particle to the Locomotive
7. Adding light to the train:
Adding a spotlight to a new Scene
Configure the spotlight with the correct intensity
Activate the shadow component
Parent the new scene to the Locomotive
Make the light toggle in App Model
8. Adding the whistle audio:
Add an Audio Library component to the Root and add the SFX file
Add a Spatial audio component to the Root
9. Stopping at the station:
Add a trainAtStation boolean in the events