Collection

RealityKit sample architecture

Source-backed, high-level architecture notes for Apple sample-code pages grouped in the RealityKit folder.

  • Catalog module labels: RealityKit, realitykit
  • Coverage: 36 / 36 sample pages documented
  • Source policy: archive hashes and extracted-tree references are verified locally before analysis

Samples

Sample Platforms High-level architecture Documented patterns
Altering RealityKit Rendering with Shader Functions iOS, iPadOS PopApp presents a SwiftUI wrapper whose coordinator configures an ARView; custom RealityKit material functions keep surface and geometry effects in Metal while Swift owns UI actions and scene setup. SwiftUI scene composition, UI–RealityKit bridge, Session owner boundary, Custom material shader boundary
Animating entity rotation with a system visionOS RotationApp loads the scene in ContentView; RotationComponent stores per-entity speed and RotationSystem queries those components to update transforms each frame. SwiftUI scene composition, UI–RealityKit bridge, Entity-component-system, Component-system update loop
Bringing your SceneKit projects to RealityKit iOS, iPadOS, Mac Catalyst, macOS, tvOS, visionOS PyroPandaRealityKitApp and AppModel coordinate the migrated game while feature packages split controller input, character movement, agents, attacks, and other behavior into RealityKit components and systems. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Delegate callback adapter, Feature-package ECS migration
Building an immersive experience with RealityKit iOS, iPadOS, Mac Catalyst The UIKit GameViewController owns the AR experience, GameManager coordinates gameplay, and custom components, InputSystem, and MetalRenderer create the underwater simulation and postprocessing path. UIKit lifecycle composition, UI–RealityKit bridge, Session owner boundary, Protocol capability boundary, Delegate callback adapter, Underwater postprocess pipeline
Building an object reconstruction app macOS ObjectCaptureReconstructionApp presents ContentView, which owns AppDataModel; the views collect input/output choices while the model creates a photogrammetry session, submits requests, and translates asynchronous outputs into reconstruction progress. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Session owner boundary, Async update consumer, Photogrammetry request pipeline
Combining 2D and 3D views in an immersive app visionOS MultiDimensionalImmersiveContentApp presents RainbowView, which owns RainbowModel; SwiftUI, UIKit/CALayer, and RealityKit views render coordinated 2D arcs and 3D content in one immersive composition. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Authored-content boundary, Cross-framework view composition
Composing interactive 3D content with RealityKit and Reality Composer Pro visionOS RealityKitAnimationApp owns AppModel; ImmersiveView loads authored content and registered components/systems turn Reality Composer Pro entities into interactive runtime behavior. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Authored-content boundary, Authored component-system bridge
Configuring Collision in RealityKit iOS, iPadOS, Mac Catalyst AppDelegate installs ViewController, which owns the ARView, creates custom entities, and assigns collision groups, masks, and event subscriptions that decide which pairs interact. UIKit lifecycle composition, UI–RealityKit bridge, Delegate callback adapter, Collision filter matrix
Construct an immersive environment for visionOS visionOS MeadowApp is a compact SwiftUI scene shell; ImmersiveView loads the authored meadow from RealityKitContent, leaving environment composition in Reality Composer Pro assets. SwiftUI scene composition, UI–RealityKit bridge, Authored-content boundary, Authored-scene boundary
Controlling Entity Collisions in RealityKit iOS, iPadOS The UIKit app keeps collision setup in ViewController; custom entity types define shapes and filters, and subscriptions respond only to collision pairs allowed by those masks. UIKit lifecycle composition, UI–RealityKit bridge, Delegate callback adapter, Collision filter matrix
Creating a game with scene understanding iOS, iPadOS, Mac Catalyst The shared BugBreakAR implementation is viewed through its scene-understanding path: GameViewController configures AR reconstruction, and GameManager maps classified real-world surfaces into collision-aware gameplay. UIKit lifecycle composition, UI–RealityKit bridge, Session owner boundary, Protocol capability boundary, Delegate callback adapter, Scene-understanding adapter
Creating a photogrammetry command-line app macOS Top-level main.swift defines HelloPhotogrammetry, parses command options, creates a PhotogrammetrySession, submits one request, and consumes the session’s asynchronous output stream. Session owner boundary, Async update consumer, Async session-output consumer
Creating a Spaceship game iOS, iPadOS, Mac Catalyst, visionOS SpaceshipApp owns shared AppModel; view models coordinate hangar and immersive phases while RealityKit components and systems handle ships, asteroids, hand control, lighting, and spatial-audio simulation. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Session owner boundary, Game-state plus ECS split
Creating a spatial drawing app with RealityKit visionOS RealityKitDrawingApp owns window/space mode, DrawingDocument owns stroke state, AnchorEntityInputProvider supplies tracked input, and brush generators plus RealityKit systems update low-level meshes and textures. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Protocol capability boundary, Document-input-render pipeline
Creating an App for Face-Painting in AR iOS, iPadOS, Mac Catalyst FacePainting presents SwiftUI ContentView; FacePaintingView adapts an imperative AR face-tracking view and PencilKit canvas, then maps the drawing into the face entity’s material. SwiftUI scene composition, UI–RealityKit bridge, Delegate callback adapter, ARView–PencilKit adapter
Displaying low-latency connected video visionOS LowLatencyCameraStreamingApp owns AppModel; CameraCoordinator separates device/capture lifecycle from LowLatencyRenderer, which transfers camera frames through a shared Metal texture into RealityKit content. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Session owner boundary, Async update consumer, Capture-to-shared-texture pipeline
Docking a video player in an immersive scene visionOS DockingApp owns scene state while AVPlayerViewModel owns player and docking transitions; AVPlayerView maps that stable owner into windowed and immersive RealityKit presentation. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Delegate callback adapter, Authored-content boundary, Player view-model lifecycle
Generating interactive geometry with RealityKit macOS, visionOS GeneratingInteractiveGeometrySampleApp presents a height-map view; a compute component carries dispatch state and ComputeSystem runs Metal work that updates interactive RealityKit geometry. SwiftUI scene composition, UI–RealityKit bridge, Entity-component-system, Protocol capability boundary, Compute component-system pipeline
Implementing special rendering effects with RealityKit postprocessing iOS, iPadOS, Mac Catalyst AppDelegate hosts a SwiftUI-backed RealityKit view; its coordinator owns ARView setup and installs postprocess callbacks that route frames through Metal, Core Image, or Metal Performance Shaders effects. UIKit lifecycle composition, UI–RealityKit bridge, Session owner boundary, Delegate callback adapter, Postprocess strategy boundary
Integrating virtual objects with your environment visionOS TinyTreasureTroveApp owns AppModel; ImmersiveView loads authored content and GameObjectComponent/GameObjectSystem coordinate virtual objects with the reconstructed environment. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Authored-content boundary, Environment-aware ECS
Manipulating models with RealityKit visionOS ModelManipulatorApp owns AppModel for loaded entities and selection; views forward gestures while ClippingController and a sync component/system isolate clipping-volume behavior from UI state. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Async update consumer, Clipping-state adapter
Mixing spatial music visionOS MixingSpatialMusicApp owns AppModel; the immersive scene creates spatial emitters while mixer/settings views mutate source levels and visual models reflect the same audio-scene state. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Async update consumer, Scene-backed audio mixer
Presenting an artist’s scene visionOS ArtistWorkflowExampleApp owns a small AppModel; ImmersiveView loads the artist-authored Reality Composer Pro scene and keeps Swift focused on presentation lifecycle rather than rebuilding content. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Authored-content boundary, Authored-scene boundary
Presenting images in RealityKit visionOS SpatialPhotosSampleApp owns AppModel; ImagePresentationView turns the selected image and presentation mode into RealityKit entities while ornaments expose lightweight controls. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Delegate callback adapter, Presentation-model adapter
Rendering a windowed game in stereo visionOS The app shell selects a stereo rendering path; HeadPositionProvider supplies view state, dedicated renderer types own Metal frame work, and RealityKit deferred-lighting components/systems integrate the game scene into a windowed stereo surface. SwiftUI scene composition, UI–RealityKit bridge, Entity-component-system, Session owner boundary, Protocol capability boundary, Pluggable stereo renderer
Rendering stereoscopic video with RealityKit visionOS RealityKitPlaybackApp owns PlayerModel; the model drives AVFoundation decode and sample-buffer rendering while ContentView binds the resulting stereoscopic frames to RealityKit presentation. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Async update consumer, Sample-buffer video bridge
Responding to gestures on an entity visionOS GestureResponseApp loads content in ContentView; collision/input-target configuration makes entities gesture targets and ActiveComponent records the small piece of entity state changed by the gesture. SwiftUI scene composition, UI–RealityKit bridge, Component-gated gesture state
Scanning objects using Object Capture iOS, iPadOS, Mac Catalyst GuidedCaptureSampleApp injects the singleton AppDataModel; feature views drive onboarding and capture while the model owns ObjectCaptureSession state and CaptureFolderManager owns session-folder lifecycle. SwiftUI scene composition, Observable state owner, Session owner boundary, Async update consumer, Protocol capability boundary, Capture-session state machine
Simulating particles in your visionOS app visionOS ParticleEmitterApp presents MainView; views create and tune particle-emitter entities while reusable gesture components and GeneralGoalSystem keep entity interaction outside the SwiftUI hierarchy. SwiftUI scene composition, UI–RealityKit bridge, Entity-component-system, Entity-scoped particle configuration
Simulating physics joints in your RealityKit app iOS, iPadOS, Mac Catalyst, macOS, visionOS RealityKitPhysicsJointApp presents MainView, which directly constructs entities, physics bodies, and joints inside RealityView; the compact sample intentionally has no separate model layer. SwiftUI scene composition, UI–RealityKit bridge, Direct joint composition
Simulating physics with collisions in your visionOS app visionOS PhysicsBodiesApp presents MainView; gesture state lives in components and SphereAttractionSystem applies repeated physics behavior to matching entities while RealityKit resolves collisions. SwiftUI scene composition, UI–RealityKit bridge, Entity-component-system, Physics component-system loop
Tracking a handheld accessory as a virtual sculpting tool visionOS SpatialSculptingApp owns the document scene; SculptingToolModel maps ARKit accessory updates into tool pose and haptics, while compute and sculpting systems modify the volume document’s low-level resources. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Protocol capability boundary, Tracked-input compute pipeline
Transforming entities between RealityKit coordinate spaces visionOS CoordSpaceTransformApp owns AppModel; volumetric and immersive views share entities and demonstrate explicit transform conversion between SwiftUI, RealityKit scene, and local coordinate spaces. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Explicit coordinate conversion
Transforming RealityKit entities using gestures visionOS EntityGestureApp loads content in ContentView; GestureComponent stores per-entity interaction configuration and gesture modifiers translate drag, rotate, and scale input into entity transforms. SwiftUI scene composition, UI–RealityKit bridge, Authored-content boundary, Entity gesture component
Using object capture assets in RealityKit iOS, iPadOS, Mac Catalyst ObjectCaptureSampleApp presents ContentView; the shared GameManager owns the chess scene and rules, while piece components and AnimationSystem drive Object Capture-derived entities and SwiftUI overlays forward user intent. SwiftUI scene composition, UI–RealityKit bridge, Observable state owner, Entity-component-system, Session owner boundary, Game manager plus ECS
WWDC21 Challenge: Framework Freestyle iOS, iPadOS AppDelegate installs ViewController, which directly owns the ARView, entity setup, audio, and recording/game actions; the small UIKit sample has no separate application-state layer. UIKit lifecycle composition, UI–RealityKit bridge, Delegate callback adapter, Direct ARView composition

Cross-sample signals

Recurring documented patterns

Pattern label Sample documents
UI–RealityKit bridge 34
SwiftUI scene composition 29
Observable state owner 18
Entity-component-system 13
Session owner boundary 11
Delegate callback adapter 10
Protocol capability boundary 7
Async update consumer 7
Authored-content boundary 7
UIKit lifecycle composition 6
Collision filter matrix 2
Authored-scene boundary 2

Type-role naming evidence

Counts below are declaration-name suffixes, not inferred patterns.

Role suffix Distinct declarations across samples
View 142
Component 89
System 42
App 28
Delegate 24
Model 20
Controller 14
Generator 7
Renderer 6
Coordinator 4
Manager 4
Player 4
Provider 4
Handler 3
Loader 3
ViewModel 3
Document 2
Scene 2
Session 1
Processor 1

Swift access-control evidence

These are declaration occurrences in scanned Swift source, including implicit internal declarations.

Access level Occurrences
implicit internal 8389
private 1235
public 726
fileprivate 67
private(set) 67
internal 51
open 3

References

Generated from the verified local catalog and completed Markdown documents.