One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AnimationGraphResource

class · iOS 27.0+ · SDK 27.1

class AnimationGraphResource

A compiled animation graph that drives skeletal animation on an entity by blending and transitioning between animation clips at runtime. Compile an animation graph definition once into an ``AnimationGraphResource``, then attach it to one or more entities through ``AnimationGraphComponent``. The same resource can drive many entities — each ``AnimationGraphComponent`` keeps its own per-instance evaluation state, so animation timing, state-machine progress, and parameter values stay independent across characters that share a graph. ### Compile and attach a graph ```swift let resource = try AnimationGraphResource( definition: graphDefinition, nodeResourceMapping: clips, skeletonResource: skeleton ) entity.components.set(AnimationGraphComponent(graph: resource)) ``` ### Drive the graph with parameters A graph exposes a set of named, typed parameters that control its behavior at runtime, such as a movement speed or a trigger that initiates a transition. List the parameters declared by the graph through ``parameterNames``. Set values through the owning entity's parameter binding rather than through the resource itself: ```swift entity.parameters["MoveSpeed"] = BindableValue(Float(1.0)) ``` When the graph evaluates next, it picks up the values bound on the entity whose names and types match the graph's declared parameters. ### Validate before compiling To check a graph definition for errors without producing a resource — for example, in editor tooling — call ``validate(definition:nodeResourceMapping:skeletonResource:)``, which returns compiler diagnostics rather than throwing.

Members (3)

init · iOS 27.0+

init

TypeScript
static init(definition: ArrayBuffer, nodeResourceMapping: Record<number, AnimationResource>, skeletonResource: SkeletonResource): AnimationGraphResource
Swift declaration
convenience init(definition: Data, nodeResourceMapping: [Int : AnimationResource] = [:], skeletonResource: SkeletonResource) throws

Compiles an animation graph definition into a resource that can drive animation on an entity. To validate a definition without producing a resource — for example, when surfacing errors in editor tooling — call ``validate(definition:nodeResourceMapping:skeletonResource:)`` instead. - Parameters: - definition: The animation graph definition to compile. - nodeResourceMapping: A mapping from graph-node IDs to the ``AnimationResource`` clips those nodes reference. Defaults to empty. - skeletonResource: The ``SkeletonResource`` the graph targets. - Throws: An error if the compiler couldn't produce a resource from the definition. The thrown error carries every diagnostic the compiler reported.

get · iOS 27.0+

parameterNames

TypeScript
get parameterNames(): Array<string>
Swift declaration
var parameterNames: [String] { get }

The names of all parameters declared by the graph definition. Use this list to discover the parameters a graph exposes for runtime control. Set values for these parameters through the owning entity's parameter binding rather than through the resource itself, so that any entity using the graph can drive it with values that match its own state: ```swift entity.parameters["MoveSpeed"] = BindableValue(Float(1.0)) ```

static · iOS 27.0+

validate

TypeScript
static validate(definition: ArrayBuffer, nodeResourceMapping: Record<number, AnimationResource>, skeletonResource: SkeletonResource): Array<string>
Swift declaration
static func validate(definition: Data, nodeResourceMapping: [Int : AnimationResource] = [:], skeletonResource: SkeletonResource) -> [String]

Compiles an animation graph definition and returns any diagnostic messages the compiler produced, without producing a resource. Call this method to validate a definition at editor time without paying the cost of holding on to the compiled resource and without having to handle a thrown error. To produce a usable ``AnimationGraphResource``, call ``init(definition:nodeResourceMapping:skeletonResource:)`` instead. - Parameters: - definition: The animation graph definition to validate. - nodeResourceMapping: A mapping from graph-node IDs to the ``AnimationResource`` clips those nodes reference. Defaults to empty. - skeletonResource: The ``SkeletonResource`` the graph targets. - Returns: An array of diagnostic messages produced by the compiler. An empty array indicates the definition compiled cleanly.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →