A fluent builder for creating AnimationClip instances from code.

Use AnimationBuilder.create to start a new builder, chain .track() calls to add animation tracks, and call .build() to produce the clip.

const clip = AnimationBuilder.create()
.track(door, "position", { from: [0,0,0], to: [2,0,0], duration: 1 })
.build();
const clip = AnimationBuilder.create("DoorOpen")
.track(door, "position", { from: [0,0,0], to: [2,0,0], duration: 1 })
.track(light, "intensity", { from: 0, to: 5, duration: 1 })
.build(room);

Constructors

Methods

Constructors

Methods

  • Builds and returns the AnimationClip.

    Parameters

    • Optionalroot: Object3D<Object3DEventMap>

      Optional root Object3D for resolving track paths. When provided, tracks targeting a different object use target.name for named resolution.

    Returns AnimationClip

  • Adds an animation track for an Object3D's position or scale

    Parameters

    • target: Object3D
    • property: "position" | "scale"
    • keyframes: KF<Vec3Value>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for an Object3D's quaternion

    Parameters

    • target: Object3D
    • property: "quaternion"
    • keyframes: KF<QuatValue>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for an Object3D's rotation (Euler, converted to quaternion)

    Parameters

    • target: Object3D
    • property: "rotation"
    • keyframes: KF<EulerValue>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for an Object3D's visibility

    Parameters

    • target: Object3D
    • property: "visible"
    • keyframes: KF<boolean>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for a material's numeric property

    Parameters

    • target: Material
    • property:
          | "opacity"
          | "roughness"
          | "metalness"
          | "alphaTest"
          | "emissiveIntensity"
          | "envMapIntensity"
          | "bumpScale"
          | "displacementScale"
          | "displacementBias"
    • keyframes: KF<number>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for a material's color property

    Parameters

    • target: Material
    • property: "color" | "emissive"
    • keyframes: KF<ColorValue>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for a light's numeric property

    Parameters

    • target: Light
    • property: "intensity" | "distance" | "angle" | "penumbra" | "decay"
    • keyframes: KF<number>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for a light's color

    Parameters

    • target: Light
    • property: "color"
    • keyframes: KF<ColorValue>
    • Optionaloptions: TrackOptions

    Returns this

  • Adds an animation track for a camera's numeric property

    Parameters

    • target: PerspectiveCamera
    • property: "zoom" | "fov" | "near" | "far"
    • keyframes: KF<number>
    • Optionaloptions: TrackOptions

    Returns this