Bringing your SceneKit projects to RealityKit
At a glance
| Item | Summary |
|---|---|
| Purpose | Adapt a platformer game for RealityKit’s powerful ECS and modularity. |
| App architecture | A Swift sample bundle with entry-bearing project variants Pyro Panda RealityKit, Pyro Panda SceneKit, each leading to RealityKit APIs. |
| Main patterns | View-controller organization, Delegate or data-source callbacks, Binding-based state propagation |
| Project style | 79 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
| Execution model | Source-visible boundaries: Task, await suspension point, @MainActor, Task closure isolated to MainActor, Sendable or @Sendable; none alone proves a background thread. |
| State/event model | Source-visible mechanisms: NotificationCenter, SwiftUI state property wrapper, @Observable. |
| Key frameworks/packages | RealityKit, SwiftUI, Foundation, CharacterMovement, GameController; these are source dependencies, not architecture labels. |
Project structure
Source bundle/
├── Pyro Panda RealityKit/
│ ├── Pyro Panda RealityKit/
│ │ ├── PyroPandaRealityKitApp.swift
│ │ └── Components/
│ │ └── HeroComponent.swift
│ └── Packages/
│ ├── AgentComponent/
│ │ └── Sources/
│ │ └── AgentComponent/
│ │ └── AgentComponent.swift
│ ├── WorldCamera/
│ │ └── Sources/
│ │ └── WorldCamera/
│ │ ├── WorldCameraComponent.swift
│ │ ├── FollowComponent.swift
│ │ └── WorldCameraSystem.swift
│ ├── CharacterMovement/
│ │ └── Sources/
│ │ └── CharacterMovement/
│ │ └── CharacterMovementComponent.swift
│ └── ControllerInput/
│ └── Sources/
│ └── HapticUtility/
│ └── HapticUtility.swift
└── Pyro Panda SceneKit/
└── Swift/
├── Shared/
│ └── GameController.swift
├── iOS/
│ └── AppDelegate.swift
├── macOS/
│ └── AppDelegate.swift
└── tvOS/
└── AppDelegate.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 22 project/configuration file(s) and 86 source declaration(s).
Overall architecture
flowchart LR
Bundle["Sample bundle"]
V1["Pyro Panda RealityKit"]
V2["Pyro Panda SceneKit"]
Boundary["RealityKit APIs"]
Bundle --> V1
V1 --> Boundary
Bundle --> V2
V2 --> Boundary
Reference code
Pyro Panda RealityKit/Pyro Panda RealityKit/PyroPandaRealityKitApp.swift:12 — architecture anchor
@main
struct PyroPandaRealityKitApp: App {
// ...
@State private var appModel = AppModel()
// ...
}Interpretation
The branches represent separate entry-bearing project variants in the downloaded bundle, not runtime calls between those variants. Each branch is intentionally collapsed at the documented framework boundary; the detailed target-local flow remains in the cited files. Ownership is claimed only where the next section cites a stored property or assignment.
Ownership and state
classDiagram
AgentComponent o-- AgentType : agentType
AgentComponent o-- AgentState : state
AgentComponent o-- PositionConstraints : positionConstraints
AgentComponent *-- Dictionary : stateWeights
Ownership evidence
Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:24 — stored dependency or nearest verified ownership anchor
public struct AgentComponent: Component {
// ...
public let agentType: AgentType?
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
AgentComponent |
AgentType (agentType) |
stores or receives | Initialized by the owner; the binding is immutable |
AgentComponent |
AgentState (state) |
stores or receives | App/module collaborators |
AgentComponent |
PositionConstraints (positionConstraints) |
stores or receives | App/module collaborators |
AgentComponent |
Dictionary (stateWeights) |
owns value state | App/module collaborators |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Concurrency, scheduling, and thread safety
Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.
| Concern | Source mechanism | Verified placement or handoff | Evidence |
|---|---|---|---|
| Task creation | Task |
The source creates an unstructured task; surrounding context determines inherited actor isolation. | Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:117 |
| Suspension boundary | await suspension point |
The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. | Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:117 |
| Main isolation | @MainActor |
The cited annotation marks its attached declaration or closure as main-actor isolated. | Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentSystem.swift:11 |
| Main isolation | Task closure isolated to MainActor |
The cited operation explicitly enters a main-actor-isolated region. | Pyro Panda RealityKit/Packages/CharacterMovement/Sources/CharacterMovement/CharacterMovementComponent.swift:47 |
| Transfer contract | Sendable or @Sendable |
The source declares a sendability boundary; this alone does not synchronize mutable state. | Pyro Panda RealityKit/Packages/ControllerInput/Sources/ControllerInput/ControllerInputSystem.swift:14 |
@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.
Reference code
Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:117 — representative execution boundary
Task { await AgentSystem.registerSystem() }State propagation, frameworks, and dependencies
Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.
| Category | Mechanism or module | Verified role | Evidence |
|---|---|---|---|
| State propagation | NotificationCenter |
NotificationCenter distributes named process-local events. | Pyro Panda RealityKit/Packages/ControllerInput/Sources/ControllerInput/ControllerInputSystem.swift:20 |
| State propagation | SwiftUI state property wrapper |
A SwiftUI property wrapper supplies or observes UI state. | Pyro Panda RealityKit/Packages/ThumbStickView/Sources/ThumbStickView/ThumbStickView.swift:46 |
| State propagation | @Observable |
Observation macro publishes source-visible changes. | Pyro Panda RealityKit/Pyro Panda RealityKit/AppModel.swift:14 |
| Source import | RealityKit |
The cited file imports this module; runtime use and architectural role are not inferred. | Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:9 |
| Source import | SwiftUI |
The cited file imports this module; runtime use and architectural role are not inferred. | Pyro Panda RealityKit/Packages/CharacterMovement/Sources/CharacterMovement/CharacterMovementComponent.swift:10 |
| Source import | Foundation |
The cited file imports this module; runtime use and architectural role are not inferred. | Pyro Panda RealityKit/Packages/CharacterMovement/Sources/CharacterMovement/CharacterMovementComponent.swift:8 |
| Source import | CharacterMovement |
The cited file imports this module; runtime use and architectural role are not inferred. | Pyro Panda RealityKit/Pyro Panda RealityKit/Audio/PyroPandaView+Audio.swift:9 |
| Source import | GameController |
The cited file imports this module; runtime use and architectural role are not inferred. | Pyro Panda RealityKit/Packages/ControllerInput/Sources/ControllerInput/ControllerInputReceiver.swift:10 |
receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.
Class and protocol design
Pyro Panda SceneKit/Swift/Shared/UI/Menu.swift:10 — representative type boundary
protocol MenuDelegate: NSObjectProtocol {
func fStopChanged(_ value: CGFloat)
func focusDistanceChanged(_ value: CGFloat)
func debugMenuSelectCameraAtIndex(_ index: Int)
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
PyroPandaRealityKitApp |
Application entry and top-level composition | App |
AppDelegate |
Receives callback-driven events | UIResponder, UIApplicationDelegate |
AppDelegate |
Receives callback-driven events | NSObject, NSApplicationDelegate |
AppDelegate |
Receives callback-driven events | UIResponder, UIApplicationDelegate |
MenuDelegate |
Defines a capability or collaboration contract | NSObjectProtocol |
ButtonOverlayDelegate |
Defines a capability or collaboration contract | NSObjectProtocol |
PadOverlayDelegate |
Defines a capability or collaboration contract | NSObjectProtocol |
AgentComponent |
Stores entity-component data or behavior | Component |
WorldCameraComponent |
Stores entity-component data or behavior | Component |
GameController |
View lifecycle, callbacks, and feature coordination | NSObject, ExtraProtocols |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
agentType (Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:24) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
state (Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:33) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
clamp (Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:51) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
positionConstraints (Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:62) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
Reference code
Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift:24 — representative boundary
public struct AgentComponent: Component {
// ...
public let agentType: AgentType?
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | PyroPandaRealityKitApp |
The source’s App suffix makes this role explicit. |
| Stores entity-component data or behavior | AgentComponent, AttackComponent, BaseComponent, CharacterMovementComponent |
The source’s Component suffix makes this role explicit. |
| View lifecycle, callbacks, and feature coordination | GameController, WASDController |
The source’s Controller suffix makes this role explicit. |
| Receives callback-driven events | AppDelegate, ButtonOverlayDelegate, MenuDelegate, PadOverlayDelegate |
The source’s Delegate suffix makes this role explicit. |
| Handles callbacks or feature events | CameraLockActionHandler, CameraOrientActionHandler, HeroAttackActionHandler |
The source’s Handler suffix makes this role explicit. |
| Feature data or observable state | AppModel |
The source’s Model suffix makes this role explicit. |
| Runs entity-component-system update logic | AgentSystem, CharacterMovementSystem, ControllerInputSystem, FollowSystem |
The source’s System suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| View-controller organization | Pyro Panda SceneKit/Swift/Shared/GameController.swift:49 |
A controller is the verified coordination boundary; this is MVC-style only where a separate model is present. |
| Delegate or data-source callbacks | Pyro Panda SceneKit/Swift/iOS/AppDelegate.swift:11 |
Callback protocols invert event delivery back into the sample’s owner. |
| Binding-based state propagation | Pyro Panda RealityKit/Packages/ThumbStickView/Sources/ThumbStickView/ThumbStickView.swift:46 |
A binding exposes controlled read/write access while the upstream owner remains authoritative. |
Naming conventions
- Types: App: PyroPandaRealityKitApp; Component: AgentComponent, AttackComponent, BaseComponent, CharacterMovementComponent, CharacterStateComponent; Controller: GameController, WASDController; Delegate: AppDelegate, ButtonOverlayDelegate, MenuDelegate, PadOverlayDelegate; Handler: CameraLockActionHandler, CameraOrientActionHandler, HeroAttackActionHandler; Model: AppModel; System: AgentSystem, CharacterMovementSystem, ControllerInputSystem, FollowSystem, MoveBetweenSystem; View: CollectedItemsView, CongratulationsView, ContentView, ImmersiveView, PyroPandaView.
- Protocols:
MenuDelegate,ButtonOverlayDelegate,PadOverlayDelegate. - Methods:
clamp,cameraAxisOrientation,updateWith,setupGameController,setupCharacter,setupPhysics,setupCollisions,setupFollowCamera. - Files:
Pyro Panda RealityKit/Pyro Panda RealityKit/PyroPandaRealityKitApp.swift,Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift,Pyro Panda RealityKit/Packages/WorldCamera/Sources/WorldCamera/WorldCameraComponent.swift,Pyro Panda SceneKit/Swift/Shared/GameController.swift,Pyro Panda RealityKit/Packages/CharacterMovement/Sources/CharacterMovement/CharacterMovementComponent.swift,Pyro Panda RealityKit/Packages/ControllerInput/Sources/HapticUtility/HapticUtility.swift.
Architecture takeaways
PyroPandaRealityKitAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches RealityKit, SwiftUI, CharacterMovement, GameController through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
Pyro Panda RealityKit/Pyro Panda RealityKit/PyroPandaRealityKitApp.swift |
Cited implementation, PyroPandaRealityKitApp |
Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentComponent.swift |
Cited implementation, Task, await suspension point, RealityKit, AgentComponent, AgentType, AgentState, ConstraintValue, PositionConstraints |
Pyro Panda SceneKit/Swift/Shared/UI/Menu.swift |
MenuDelegate, Menu |
Pyro Panda SceneKit/Swift/Shared/GameController.swift |
GameController, Bitmask, ParticleKind, AudioSourceKind |
Pyro Panda SceneKit/Swift/iOS/AppDelegate.swift |
Cited implementation, AppDelegate |
Pyro Panda RealityKit/Packages/ThumbStickView/Sources/ThumbStickView/ThumbStickView.swift |
Cited implementation, SwiftUI state property wrapper, ThumbStickView |
Pyro Panda RealityKit/Packages/AgentComponent/Sources/AgentComponent/AgentSystem.swift |
@MainActor, AgentSystem |
Pyro Panda RealityKit/Packages/CharacterMovement/Sources/CharacterMovement/CharacterMovementComponent.swift |
Task closure isolated to MainActor, SwiftUI, Foundation, CharacterMovementComponent, CharacterMovementSystem |
Pyro Panda RealityKit/Packages/ControllerInput/Sources/ControllerInput/ControllerInputSystem.swift |
Sendable or @Sendable, NotificationCenter, ControllerInputSystem |
Pyro Panda RealityKit/Pyro Panda RealityKit/AppModel.swift |
@Observable, AppModel, ImmersiveSpaceState |
Pyro Panda RealityKit/Pyro Panda RealityKit/Audio/PyroPandaView+Audio.swift |
CharacterMovement, Feature implementation |
Pyro Panda RealityKit/Packages/ControllerInput/Sources/ControllerInput/ControllerInputReceiver.swift |
GameController, ControllerInputReceiver |
Pyro Panda RealityKit/Packages/WorldCamera/Sources/WorldCamera/WorldCameraComponent.swift |
WorldCameraComponent, CameraFollowMode, CameraMovementStyle, CameraBounds |
Pyro Panda RealityKit/Packages/ControllerInput/Sources/HapticUtility/HapticUtility.swift |
HapticUtility, func |
Pyro Panda RealityKit/Packages/WorldCamera/Sources/WorldCamera/FollowComponent.swift |
FollowComponent, FollowSystem |
Pyro Panda RealityKit/Packages/WorldCamera/Sources/WorldCamera/WorldCameraSystem.swift |
WorldCameraRootComponent, WorldCameraSystem |