A component that renders a USD stage as RealityKit entities.
Attach a `USDStageComponent` to an entity to render USD content as child
entities. The component supports two modes of operation:
- **Manual mode**: Created with ``init(allowsHitTesting:)``. You control
when rendering occurs by calling ``render(_:to:at:)``.
- **Automatic mode**: Created with ``init(_:timeCode:allowsHitTesting:)``.
The component manages rendering internally and updates when the
stage or time code changes.
Creates a USDStageComponent in manual mode.
In manual mode, you control when rendering occurs by calling
``render(_:to:at:)``.
- Parameter allowsHitTesting: Whether to generate collision shapes for hit testing. Defaults to `true`.
get · iOS 27.0+
allowsHitTesting
TypeScript
get allowsHitTesting(): boolean
Swift declaration
let allowsHitTesting: Bool
Whether the rendered entities support hit testing.
Set at initialization and cannot be changed afterwards.
get · iOS 27.0+
rendersAutomatically
TypeScript
get rendersAutomatically(): boolean
Swift declaration
let rendersAutomatically: Bool
Whether the component renders automatically in response to stage
or time code changes. `false` indicates manual mode, in which
rendering must be triggered explicitly via ``render(_:to:at:)``.
Waits for automatic rendering to complete.
If the entity does not have a `USDStageComponent` attached, or if the
attached component is in manual mode, the result is `.failed`.
- Parameter entity: The entity with a `USDStageComponent`.
- Returns: The result of the render operation.
get · iOS 27.0+
stage
TypeScript
get stage(): (_USDKit_USDStage) | null
Swift declaration
var stage: USDStage? { get }
The stage currently being rendered by this component, or `nil` if
the component is in manual mode and no render has been performed yet.
nonisolated(nonsending) static func render(_ stage: USDStage, to entity: Entity, at timeCode: USDStage.TimeCode = .default) async -> USDStageComponent.RenderResult
Renders a USD stage to an entity in manual mode.
If the entity does not have a `USDStageComponent` attached, or if the
attached component is in automatic mode, the result is `.failed`.
- Parameters:
- stage: The USD stage to render.
- entity: The entity to render into.
- timeCode: The time code to render at.
- Returns: The result of the render operation.
get · iOS 27.0+
timeCode
TypeScript
get timeCode(): _USDKit_USDStage_TimeCode
Swift declaration
var timeCode: USDStage.TimeCode { get set }
The time code to render at.
In automatic mode, the system reads this value to determine what
time to render at. Updating this value triggers a re-render.
In manual mode, this value is unused. Pass the time code directly
to ``render(_:to:at:)`` instead.
set · iOS 27.0+
timeCode
TypeScript
set timeCode(value: _USDKit_USDStage_TimeCode)
Swift declaration
var timeCode: USDStage.TimeCode { get set }
The time code to render at.
In automatic mode, the system reads this value to determine what
time to render at. Updating this value triggers a re-render.
In manual mode, this value is unused. Pass the time code directly
to ``render(_:to:at:)`` instead.
Creates a USDStageComponent in automatic mode and waits for the
first render to complete.
In automatic mode, the component manages rendering internally and
updates when the stage or time code changes.
The initializer returns once the stage has been fully processed,
including loading textures and compiling shaders.
- Parameters:
- stage: The USD stage to render.
- timeCode: The time code to render at. Defaults to `.default`.
- allowsHitTesting: Whether to generate collision shapes for hit testing. Defaults to `true`.