visionOS Code Samples
Hello World
Windows, Spaces and Volumes
World in visionOS: It represents the infinite 3D space users interact with in a visionOS app.
Key characteristics:
Immersive: Users can feel like they're entirely within the virtual space.
Persistent: The world can hold both 2D and 3D content, allowing for a mix of interfaces.
Shared (optional): Apps can enable multiple users to interact with the same world simultaneously.
Content types in the world:
2D and 3D content: You can integrate both for a diverse user experience.
Windows: Familiar window systems can be used within the world for displaying information or controls.
Immersive content: Virtual objects can be placed in the user's environment or users can be transported to a virtual one.
Designing for the world:
Accessibility: Prioritize accessibility to ensure everyone can enjoy your visionOS app.
Privacy: Minimize sensitive data usage and be transparent about what information you collect.
In essence, "World" is the foundation of the user experience in visionOS. It provides the canvas for building immersive and interactive spatial computing applications.
Destination Video
Leverage 3D video and Spatial Audio to deliver an immersive experience.
Destination Video is a multi-platform video playback app designed for visionOS, iOS, and tvOS. It offers a familiar media browsing experience while leveraging unique features of visionOS to create a more immersive way to watch videos.
Key features:
Provides a familiar video browsing and playback experience across supported platforms.
visionOS enhancements: When used within visionOS, Destination Video offers:
Progressive immersion: Users can adjust their level of immersion by turning the Digital Crown on their device.
Automatic immersive space: When navigating to a video's details, the app transitions users into an immersive space surrounding the video player. This space disappears when returning to the library.
Overall, Destination Video demonstrates how existing apps can be adapted for visionOS by leveraging its platform-specific features to deliver a more engaging user experience, particularly through its immersive capabilities.
Happy Beam
Leverage a Full Space to create a fun game using ARKit.
Happy Beam is a sample application built for visionOS that showcases using hand tracking and spatial features to create a fun and interactive game experience.
Gameplay:
Players participate in a FaceTime call where they can see each other's virtual environment.
Grumpy clouds appear in the shared space.
Players use hand gestures to form a heart shape, which projects a beam of light.
Aiming the beam at the clouds "cheers them up," making them happy and scoring points for the players.
Technical highlights:
ARKit hand tracking: The app utilizes ARKit's 3D hand tracking capabilities to recognize the heart-shaped hand gesture.
Shared experience: Players in the FaceTime call can interact with the virtual elements in the same world, creating a collaborative game experience.
Scene management: Happy Beam utilizes visionOS concepts like scenes and windows to display the game elements.
Overall, Happy Beam serves as a practical example for developers to learn how to build interactive multiplayer games using visionOS features like ARKit hand tracking and shared experiences.
Diorama
Design scenes for your visionOS app using Reality Composer Pro.
Purpose: The Diorama app showcases how to create an interactive, virtual topographical trail map within a visionOS environment.
Functionality:
Users can explore two different trail maps (Yosemite and Catalina Island).
Tapping on points of interest reveals detailed information about them.
Smooth transitions occur when switching between the two trail maps.
Technical aspects:
The app leverages custom components to:
Identify which map elements are points of interest.
Control the flocking behavior of virtual birds within the scene.
Manage the visibility of map elements specific to each trail.
It utilizes RealityKit (Apple's framework for creating 3D content) for building and manipulating the 3D elements of the trail maps.
Key takeaway: The Diorama sample serves as a learning resource for developers interested in building interactive and visually appealing 3D experiences within the visionOS platform.
Swift Splash
Use RealityKit to create an interactive ride in visionOS.
Swift Splash (Every Complex Example of visionOS)
Swift Splash is an example project that demonstrates building an interactive virtual experience using RealityKit and Reality Composer Pro on visionOS.
Functionality: Users can build a virtual water slide by assembling modular pieces and then run a virtual goldfish through it.
Technical Breakdown:
Development tools: Xcode, Swift
Framework: RealityKit (for 3D interactions)
Additional considerations: SwiftUI (interface), Reality Composer Pro (creating 3D content)
Key concepts:
Pre-built entity hierarchies (slide pieces)
Shader Graph materials (changing object appearance)
Custom components (identifying and configuring entities)
Material references (avoiding duplicate materials)
Parallelized asset loading (improving loading speed)
ModelSortGroupComponent (specifying sorting order for transparent entities)
ConnectableComponent (identifying connectable track pieces)
ConnectableStateComponent (storing state information for track pieces)
User Interaction:
SwiftUI windows (adding/deleting pieces)
visionOS gestures (tap, double-tap, drag, rotate) for manipulating slide pieces
Overall, Swift Splash showcases techniques for building interactive 3D experiences on visionOS using RealityKit and Reality Composer Pro.