Animating Any glTF Value With KHR_animation_pointer

This article explains how the KHR_animation_pointer extension expands glTF 2.0 animation capabilities beyond rigid transform targets. By leveraging the RFC 6901 JSON Pointer specification, this extension enables creators and developers to drive nearly any numerical or vector property across a glTF file—including material colors, camera settings, and light parameters—using the existing, highly optimized glTF animation timeline system.

The Limitation of Standard glTF Animations

Core glTF 2.0 defines animations through channels, where each channel specifies a target node and a restricted path property. By default, this path is limited to four fixed strings: translation, rotation, scale, and weights (for morph targets).

While this architecture handles standard skeletal meshes and object movement efficiently, it cannot animate materials, cameras, light intensities, or custom extension properties without introducing non-standard hacks or entirely custom animation frameworks.

The JSON Pointer Mechanism

The KHR_animation_pointer extension resolves this restriction by introducing a dynamic pathing system. Instead of relying solely on the predefined channel.target.path enum, the extension adds a pointer string inside the target's extension object:

{
  "channels": [
    {
      "sampler": 0,
      "target": {
        "extensions": {
          "KHR_animation_pointer": {
            "pointer": "/materials/0/pbrMetallicRoughness/baseColorFactor"
          }
        }
      }
    }
  ]
}

The pointer property follows the RFC 6901 standard, a formal syntax for identifying specific values inside a JSON document. Because glTF uses JSON as its structural backbone, a pointer string can uniquely locate any array element or object field throughout the asset.

How Data Binding and Playback Work

KHR_animation_pointer does not change how animation keyframes, timestamps, or interpolation curves are stored. It reuses glTF's existing sampler-and-accessor pipeline:

  1. Input and Output Samplers: The animation sampler still references an accessor for time inputs and an accessor for keyframe output values (e.g., SCALAR, VEC3, or VEC4 types).
  2. Path Resolution: When the runtime loads the glTF document, it parses the JSON Pointer path once to locate the target field in memory.
  3. Type Matching: The runtime verifies that the output accessor's data type matches the schema of the targeted JSON value. For example, animating /cameras/0/perspective/yfov requires a SCALAR, while animating /materials/0/emissiveFactor requires a VEC3.
  4. Value Application: During playback, the runtime evaluates the interpolated value at the current timestamp and writes it directly to the resolved target in the engine's internal scene graph.

Broadening Target Scope Across Extensions

Because the pointer is an absolute JSON path, it functions uniformly across both core glTF specifications and other Khronos extensions. Common animation targets include:

  • Materials: Altering opacity, roughness, metallic factor, emissive intensity, or texture coordinates over time.
  • Cameras: Animating field of view (yfov), focal length, or depth-of-field boundaries.
  • Punctual Lights (KHR_lights_punctual): Changing light color, range, inner/outer cone angles, and intensity to create flicker effects or day-night transitions.
  • Texture Transforms (KHR_texture_transform): Driving texture offsets and rotations for scrolling water, procedural noise, or conveyor belt animations.

Runtime Performance Considerations

Although JSON Pointer parsing relies on string traversal, real-time engines do not parse the path on every frame. During asset loading, engines resolve the pointer string to an internal pointer or property offset. Once mapped, the runtime updates the property at memory-speed identical to traditional translation, rotation, and scale updates, maintaining high performance in real-time graphics pipelines.