Interacting with virtual content blended with passthrough
At a glance
| Item | Summary |
|---|---|
| Purpose | Present a mixed immersion style space to draw content in a person’s surroundings, and choose how upper limbs appear with respect to rendered content. |
| App architecture | A C/Objective-C header, Metal, Swift sample with the source-visible chain Compositor_Services_InteractionApp → InteractionView → AppModel → Renderer → CompositorServices APIs. |
| Main patterns | Protocol-oriented abstraction, Actor-isolated state |
| Project style | 12 scanned source file(s) across C/Objective-C header, Metal, Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
└── Compositor-Services-Interaction/
├── Compositor_Services_InteractionApp.swift
├── Renderer.swift
├── TintRenderer.swift
├── AppModel.swift
├── InteractionView.swift
├── PathCollection.swift
├── ImmersiveInteractionScene.swift
├── Bridging-Header.h
├── PathProperties.h
├── ShaderTypes.h
├── Shaders.metal
└── Uniforms.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: C/Objective-C header, Metal, Swift.
- The verified tree contains 4 project/configuration file(s) and 20 source declaration(s).
Overall architecture
flowchart LR
N1["Compositor_Services_InteractionApp"]
N2["InteractionView"]
N3["AppModel"]
N4["Renderer"]
N5["CompositorServices APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
N4 --> N5
Reference code
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:26 — architecture anchor
@main
struct InteractionApp: App {
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Compositor Services.
Ownership and state
classDiagram
InteractionApp *-- AppModel : appModel
RendererActor *-- RendererActor : shared
Renderer o-- AppModel : appModel
Renderer o-- PathCollection : pathCollection
Ownership evidence
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:29 — stored dependency or nearest verified ownership anchor
@main
struct InteractionApp: App {
// ...
@State private var appModel = AppModel()
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
InteractionApp |
AppModel (appModel) |
owns wrapper-managed state | Owning lexical scope |
RendererActor |
RendererActor (shared) |
creates and retains | App/module collaborators |
Renderer |
AppModel (appModel) |
stores or receives | Initialized by the owner; the binding is immutable |
Renderer |
PathCollection (pathCollection) |
stores or receives | Initialized by the owner; the binding is immutable |
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.
Class and protocol design
Compositor-Services-Interaction/PathCollection.swift:16 — representative type boundary
private protocol Path {
var id: PathID { get }
var buffer: MTLBuffer { get }
var vertexCount: Int { get }
var parameters: PathProperties { get set }
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
InteractionApp |
Application entry and top-level composition | App |
Renderer |
Owns drawing, GPU, or presentation processing | Concrete collaborators/imported frameworks |
TintRenderer |
Owns drawing, GPU, or presentation processing | Concrete collaborators/imported frameworks |
TintDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
DrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
AppModel |
Feature data or observable state | Concrete collaborators/imported frameworks |
InteractionView |
User-interface presentation and input forwarding | View |
PathCollectionDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
PathDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
ImmersiveInteractionScene |
Scene lifecycle or scene-level composition | Scene |
The source explicitly defines local protocol relationships: CompletePath → Path, ActivePath → Path.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
isFirstLaunch (Compositor-Services-Interaction/AppModel.swift:14) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
showImmersiveSpace (Compositor-Services-Interaction/AppModel.swift:15) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
immersiveSpaceIsShown (Compositor-Services-Interaction/AppModel.swift:16) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
immersionStyle (Compositor-Services-Interaction/AppModel.swift:17) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
Reference code
Compositor-Services-Interaction/AppModel.swift:14 — representative boundary
@Observable
public class AppModel {
// ...
public var isFirstLaunch = true
// ...
}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 | InteractionApp |
The source’s App suffix makes this role explicit. |
| Represents or runs a user/system command | DrawCommand, PathCollectionDrawCommand, PathDrawCommand, TintDrawCommand |
The source’s Command suffix makes this role explicit. |
| Feature data or observable state | AppModel |
The source’s Model suffix makes this role explicit. |
| Owns drawing, GPU, or presentation processing | Renderer, TintRenderer |
The source’s Renderer suffix makes this role explicit. |
| Scene lifecycle or scene-level composition | ImmersiveInteractionScene |
The source’s Scene suffix makes this role explicit. |
| User-interface presentation and input forwarding | InteractionView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Protocol-oriented abstraction | Compositor-Services-Interaction/PathCollection.swift:28 |
A local protocol and concrete conformance create an explicit capability boundary. |
| Actor-isolated state | Compositor-Services-Interaction/Renderer.swift:34 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: InteractionApp; Command: DrawCommand, PathCollectionDrawCommand, PathDrawCommand, TintDrawCommand; Model: AppModel; Renderer: Renderer, TintRenderer; Scene: ImmersiveInteractionScene; View: InteractionView.
- Protocols:
Path. - Methods:
makeConfiguration,defaultRenderPipelineDescriptor,memorylessTexture,getMultisampleRenderTarget,renderLoop,renderPassDescriptor,renderFrame,buildMetalVertexDescriptor. - Files:
Compositor-Services-Interaction/Renderer.swift,Compositor-Services-Interaction/TintRenderer.swift,Compositor-Services-Interaction/AppModel.swift,Compositor-Services-Interaction/InteractionView.swift,Compositor-Services-Interaction/PathCollection.swift,Compositor-Services-Interaction/ImmersiveInteractionScene.swift.
Architecture takeaways
Compositor_Services_InteractionAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches CompositorServices, SwiftUI, simd, MetalKit 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.
- Local protocol relationships provide an explicit substitution boundary.
Source map
| Source file | Relevant symbols |
|---|---|
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift |
ContentStageConfiguration, InteractionApp |
Compositor-Services-Interaction/Renderer.swift |
RendererActor, Renderer |
Compositor-Services-Interaction/TintRenderer.swift |
TintRenderer, func, TintDrawCommand, DrawCommand |
Compositor-Services-Interaction/AppModel.swift |
AppModel |
Compositor-Services-Interaction/InteractionView.swift |
VisibilityState, IStyle, InteractionView |
Compositor-Services-Interaction/PathCollection.swift |
Path, CompletePath, ActivePath, Storage, PathCollection, Error, func, PathCollectionDrawCommand, PathDrawCommand |
Compositor-Services-Interaction/ImmersiveInteractionScene.swift |
ImmersiveInteractionScene |
Compositor-Services-Interaction/Bridging-Header.h |
Feature implementation |
Compositor-Services-Interaction/PathProperties.h |
Feature implementation |
Compositor-Services-Interaction/ShaderTypes.h |
Feature implementation |