Diorama
Overview
Diorama is a demonstration of the capabilities of Reality Composer Pro for visionOS app development. With Reality Composer Pro, developers can compose, edit, and preview RealityKit content seamlessly. This tool allows the creation of scenes containing hierarchies of virtual objects known as entities, which can be efficiently loaded and displayed in visionOS apps.
Feature
Scene Design
Entity Composition: Compose entity hierarchies effortlessly within Reality Composer Pro.
Component Configuration: Add and configure components, including custom ones, to enhance the functionality of entities.
Visual Design
Shader Graph Integration: Design the visual appearance of entities using Shader Graph, providing control over surface details and shape.
Dynamic Materials: Create animated and dynamic materials that respond to the app's state or user input.
Diorama App
Diorama showcases the following features:
Interactive Topographical Trail Map: Display an interactive virtual trail map similar to real-world dioramas found at national park trailheads.
Points of Interest: Tap on specific locations to reveal detailed information.
Smooth Transition: Seamlessly switch between two trail maps: Yosemite and Catalina Island.
Getting Started
Requirements
Download: visionOS 1.0+
Development Environment: Xcode 15.0+
Asset Import
To build scenes for your app, import assets into Reality Composer Pro. Diorama's project includes custom assets, such as a diorama table, trail map, birds, clouds, sounds, and images. You can import assets by dragging them into the project browser, using the File menu, or copying them into the .rkassets bundle in your Swift package.
Note: RealityKit compiles assets into a binary format for faster loading in visionOS.
Scene Creation
Multiple Scenes: Reality Composer Pro supports multiple scenes in a project, each stored as a .usda file.
Entity Organization: Use scenes to build complete RealityKit scenes or store reusable entity hierarchies for dynamic scene composition at runtime.
Entity Management
Asset Inclusion: Add entities to scenes by dragging assets from the project browser to the hierarchy view or 3D view.
Component System: Utilize the Entity Component System (ECS) to store data and implement entity behavior. Add and configure components, including custom ones.
Point of Interest
Transforms: Use transforms to mark locations in the scene or organize entity hierarchies.
PointOfInterestComponent: Diorama uses custom components, such as PointOfInterestComponent, to identify points of interest on the map.
Runtime Implementation
Floating View for Points of Interest
Diorama adds a PointOfInterestComponent to a transform for displaying details about interesting places.
Query for entities with a PointOfInterestComponent to create SwiftUI views for each point of interest.
Custom Materials with Shader Graph
Shader Graph Material
Diorama utilizes Shader Graph for dynamic materials that morph the map and draw elevation lines.
Input parameters allow runtime adjustments, providing a smooth transition between different map states.
Update Material at Runtime
Adjust the Progress parameter to switch between different topographical maps.
Handle slider manipulation to update Shader Graph material parameters.
Conclusion
Diorama exemplifies the powerful features of Reality Composer Pro for visionOS app development. Explore its capabilities and leverage RealityKit to create immersive and visually stunning experiences. For more information, refer to the official documentation.
Note: Ensure your development environment meets the specified requirements before using Diorama as a reference for your visionOS app development.