One Logo Pool Ball
_RealityKit_ComputeGraph · IOS API REFERENCE

ComputeGraphComponent

struct · iOS 27.0+ · SDK 27.1

struct ComputeGraphComponent

A component that drives a compute graph–based particle simulation on an entity. Attach this component to any `Entity` to with a loaded `ComputeGraphResource` and execute it each frame using Metal compute pipelines. The system automatically creates and manages child entities for each graph output, each carrying its own `ModelComponent` and material. ```swift var component = ComputeGraphComponent(resource: resource) entity.components.set(component) ```

Members (32)

get · iOS 27.0+

randomSeed

TypeScript
get randomSeed(): (number) | null
Swift declaration
var randomSeed: UInt32? { get set }

An optional fixed random seed for the simulation. When `nil`, a random seed is chosen each time the simulation is (re)initialized.

set · iOS 27.0+

randomSeed

TypeScript
set randomSeed(value: (number) | null)
Swift declaration
var randomSeed: UInt32? { get set }

An optional fixed random seed for the simulation. When `nil`, a random seed is chosen each time the simulation is (re)initialized.

method · iOS 27.0+

setTexture

TypeScript
setTextureAt(texture: (SDKHandle) | null, index: number): void
Swift declaration
mutating func setTexture(_ texture: (any MTLTexture)?, at index: Int)

Binds a Metal texture to a parameter at the given index. - Parameters: - texture: The `MTLTexture` to bind, or `nil` to unbind the current texture. - index: The index of the texture parameter in the texture table.

method · iOS 27.0+

setTexture

TypeScript
setTexturePort(texture: (SDKHandle) | null, port: _ComputeGraph_ComputeNodeGraph_Port_Address): boolean
Swift declaration
@discardableResult mutating func setTexture(_ texture: (any MTLTexture)?, port: ComputeNodeGraph.Port.Address) -> Bool

Binds a Metal texture to a parameter identified by its port address. - Parameters: - texture: The `MTLTexture` to bind, or `nil` to unbind the current texture. - port: The port address identifying the texture parameter. - Returns: `true` if the port was found and the texture was set; `false` otherwise.

method · iOS 27.0+

fastForward

TypeScript
fastForwardStepCountStepDeltaTime(stepCount: number, stepDeltaTime: number): void
Swift declaration
mutating func fastForward(stepCount: Int, stepDeltaTime: Float)

Advances the particle simulation by multiple steps in a single operation. - Parameters: - stepCount: The number of simulation steps to execute. Each step represents one iteration of the simulation update cycle. Must be positive. - stepDeltaTime: The time interval (in seconds) to use for each simulation step. - Note: The simulation will be advanced by a total time of `stepCount * stepDeltaTime` seconds.

method · iOS 27.0+

fastForward

TypeScript
fastForward(): void
Swift declaration
mutating func fastForward()

Fast-forwards the simulation using the default prewarm behavior.

method · iOS 27.0+

uniformHandle

TypeScript
uniformHandle(name: string): (ComputeGraphComponent_UniformHandle) | null
Swift declaration
func uniformHandle(named name: String) -> ComputeGraphComponent.UniformHandle?

Returns a handle for the named uniform. - Parameter name: The name of the named uniform. - Returns: A ``UniformHandle``, or `nil` if no match is found.

get · iOS 27.0+

simulationRate

TypeScript
get simulationRate(): _ComputeGraph_ComputeGraphSimulation_SimulationRate
Swift declaration
var simulationRate: ComputeGraphSimulation.SimulationRate { get set }

The rate at which the simulation updates. Defaults to ``SimulationRate/default`` if no custom rate has been set.

set · iOS 27.0+

simulationRate

TypeScript
set simulationRate(value: _ComputeGraph_ComputeGraphSimulation_SimulationRate)
Swift declaration
var simulationRate: ComputeGraphSimulation.SimulationRate { get set }

The rate at which the simulation updates. Defaults to ``SimulationRate/default`` if no custom rate has been set.

method · iOS 27.0+

findBufferIndex

TypeScript
findBufferIndex(port: _ComputeGraph_ComputeNodeGraph_Port_Address): (number) | null
Swift declaration
func findBufferIndex(port: ComputeNodeGraph.Port.Address) -> Int?
method · iOS 27.0+

isOutputEnabled

TypeScript
isOutputEnabled(outputID: number): boolean
Swift declaration
func isOutputEnabled(_ outputID: ComputeNodeGraph.NodeID) -> Bool

Reads the enabled state of an output identified by ID - Returns: the enabled state, or false if the output is unknown

method · iOS 27.0+

replaceUniforms

TypeScript
replaceUniforms(data: ArrayBuffer): void
Swift declaration
mutating func replaceUniforms(_ data: Data)

Replaces the entire uniform buffer with the given data. You can query `pipelines.assembly.uniformBufferSize` for the required size. If too few bytes are provided, the remaining bytes retain their previous values. - Parameter data: Raw bytes to write into the uniform buffer.

method · iOS 27.0+

firstBufferIndex

TypeScript
firstBufferIndex(type: string): (number) | null
Swift declaration
func firstBufferIndex(type: String) -> Int?
method · iOS 27.0+

setOutputEnabled

TypeScript
setOutputEnabled(outputID: number, enabled: boolean): void
Swift declaration
mutating func setOutputEnabled(_ outputID: ComputeNodeGraph.NodeID, enabled: Bool)

Sets the enable state of an output identified by ID This will cause the output mesh to disappear, and output stages to stop executing. The simulation, however, will continue to execute. See ``pause()``, ``play()``, and ``RealityKit.Entity.isEnabled`` to control the simulation as a whole

method · iOS 27.0+

play

TypeScript
play(): void
Swift declaration
mutating func play()

Resumes the simulation from a paused or stepped state.

method · iOS 27.0+

step

TypeScript
step(): void
Swift declaration
mutating func step()

Advances the simulation by a single frame, then pauses.

method · iOS 27.0+

pause

TypeScript
pause(): void
Swift declaration
mutating func pause()

Pauses the simulation, freezing it at its current state.

method · iOS 27.0+

spawn

TypeScript
spawnElementIn(element: _ComputeGraph_ElementSpawnParameters, system?: (number) | null): void
Swift declaration
mutating func spawn(element: ElementSpawnParameters, in system: ComputeNodeGraph.NodeID? = nil)

Spawns a new element in the particle simulation. This method queues an element to be spawned during the next simulation update. The spawning is deferred and batched for performance reasons. - Parameters: - element: The spawn parameters defining the properties of the element to create - system: The ID of the specific system to spawn the element in. When `nil`, all systems will be asked to spawn the same element. - Note: The actual spawning occurs during the simulation update cycle.

method · iOS 27.0+

spawn

TypeScript
spawnElementsIn(elements: Array<_ComputeGraph_ElementSpawnParameters>, system?: (number) | null): void
Swift declaration
mutating func spawn(elements: [ElementSpawnParameters], in system: ComputeNodeGraph.NodeID? = nil)

Spawns elements into the particle simulation. This method queues an element to be spawned during the next simulation update. The spawning is deferred and batched for performance reasons. - Parameters: - element: The spawn parameters defining the properties of the element to create - system: The ID of the specific system to spawn the element in. When `nil`, all systems will be asked to spawn the same element. - Note: The actual spawning occurs during the simulation update cycle.

get · iOS 27.0+

state

TypeScript
get state(): ComputeGraphComponent_SimulationState
Swift declaration
var state: ComputeGraphComponent.SimulationState { get set }

The current playback state of the simulation.

set · iOS 27.0+

state

TypeScript
set state(value: ComputeGraphComponent_SimulationState)
Swift declaration
var state: ComputeGraphComponent.SimulationState { get set }

The current playback state of the simulation.

get · iOS 27.0+

models

TypeScript
get models(): Record<number, _RealityFoundation_ModelComponent>
Swift declaration
var models: [ComputeNodeGraph.NodeID : ModelComponent] { get set }

Per-output model component overrides, keyed by output node identifier. When non-`nil`, these model components replace those defined in ``resource``. Set to `[:]` to restore resource-defined models.

set · iOS 27.0+

models

TypeScript
set models(value: Record<number, _RealityFoundation_ModelComponent>)
Swift declaration
var models: [ComputeNodeGraph.NodeID : ModelComponent] { get set }

Per-output model component overrides, keyed by output node identifier. When non-`nil`, these model components replace those defined in ``resource``. Set to `[:]` to restore resource-defined models.

get · iOS 27.0+

resource

TypeScript
get resource(): (ComputeGraphResource) | null
Swift declaration
var resource: ComputeGraphResource? { get set }

The compute graph resource that defines the simulation. Assigning a new resource replaces the current graph and resets the simulation. Set to `nil` to detach the resource without destroying the entity.

set · iOS 27.0+

resource

TypeScript
set resource(value: (ComputeGraphResource) | null)
Swift declaration
var resource: ComputeGraphResource? { get set }

The compute graph resource that defines the simulation. Assigning a new resource replaces the current graph and resets the simulation. Set to `nil` to detach the resource without destroying the entity.

init · iOS 27.0+

init

TypeScript
static initResource(resource: ComputeGraphResource): ComputeGraphComponent
Swift declaration
init(resource: ComputeGraphResource)

Creates a `ComputeGraphComponent` and immediately attaches the given resource. - Parameter resource: The ``ComputeGraphResource`` that defines the simulation.

get · iOS 27.0+

materials

TypeScript
get materials(): Record<number, SDKHandle>
Swift declaration
var materials: [ComputeNodeGraph.NodeID : any Material] { get set }

Per-output material overrides, keyed by output node identifier. When non-`nil`, these materials replace the corresponding materials defined in ``resource``. Set to `[:]` to restore resource-defined materials.

set · iOS 27.0+

materials

TypeScript
set materials(value: Record<number, Implements<_RealityFoundation_Material> | SDKHandle>)
Swift declaration
var materials: [ComputeNodeGraph.NodeID : any Material] { get set }

Per-output material overrides, keyed by output node identifier. When non-`nil`, these materials replace the corresponding materials defined in ``resource``. Set to `[:]` to restore resource-defined materials.

get · iOS 27.0+

pipelines

TypeScript
get pipelines(): (_ComputeGraph_ComputeNodeGraph_Pipelines) | null
Swift declaration
var pipelines: ComputeNodeGraph.Pipelines? { get set }

The compiled pipelines used to execute the simulation. When `nil`, the pipelines from ``resource`` are used. Assigning a value overrides the resource's pipelines without replacing the loaded assets.

set · iOS 27.0+

pipelines

TypeScript
set pipelines(value: (_ComputeGraph_ComputeNodeGraph_Pipelines) | null)
Swift declaration
var pipelines: ComputeNodeGraph.Pipelines? { get set }

The compiled pipelines used to execute the simulation. When `nil`, the pipelines from ``resource`` are used. Assigning a value overrides the resource's pipelines without replacing the loaded assets.

method · iOS 27.0+

setBuffer

TypeScript
setBuffer(buffer: (SDKHandle) | null, bufferOffset: number, elementCount: (number) | null, index: number): void
Swift declaration
mutating func setBuffer(_ buffer: (any MTLBuffer)?, bufferOffset: Int = 0, elementCount: Int? = nil, at index: Int)

Binds a Metal buffer to a parameter. - Parameters: - buffer: The `MTLBuffer` to bind. - bufferOffset: Byte offset into `buffer`. Defaults to `0`. - elementCount: Number of elements in the buffer, for buffers with variable capacity. - at: Index into the device buffers table.

init · iOS 27.0+

init

TypeScript
static init(): ComputeGraphComponent
Swift declaration
init()

Creates a `ComputeGraphComponent` with no resource attached.

Skipped declarations

3 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ComputeGraphComponent.setUniformData(_:for:)

The iOS SDK compiler rejected this binding: instance method 'arg' requires that 'RawSpan' conform to 'Escapable'

ComputeGraphComponent.setUniformValue(_:for:)

This declaration needs Swift generic type arguments. (no canonical witness for V)

ComputeGraphComponent.setUniformValue(_:named:)

This declaration needs Swift generic type arguments. (no canonical witness for V)

All _RealityKit_ComputeGraph types →