AnimationBakeMixer
new AnimationBakeMixer(texture : THREE.DataTexture, options : Object)Playback controller for baked animation textures (VAT/OAT).
- Manages frame uniforms:
frameIndexUniform,framesCountUniform,frameTimeUniform - Supports modes: 'vertex' (VAT) and 'object' (OAT)
- Provides playback controls and frame interpolation
Constructor Parameters
textureTHREE.DataTextureoptionsoptionalObjectmodeoptional'vertex'|'object'Selects how the baked animation should be sampled.
Default is'vertex'.framesCountoptionalnumberOptional frame count override; inferred from metadata or texture otherwise.playoptionalbooleanStart in a playing state whentrue.
Default istrue.fpsoptionalnumberTarget frames per second for playback.
Default is60.playbackSpeedoptionalnumberPlayback speed multiplier where1equals real time.
Default is1.loopoptionalbooleanLoop animation whentrue, clamp to last frame otherwise.
Default istrue.
See also
Example
import { AnimationBakeMixer } from '@three-blocks/core';
const mixer = new AnimationBakeMixer(texture, { fps: 60, loop: true });
mixer.registerMaterial(material);
function render(deltaSeconds) {
mixer.update(deltaSeconds);
renderer.render(scene, camera);
}
Properties
# .duration : number
Total animation length in seconds. Filled from metadata when available, otherwise derived from frame count and frames per second.
# .time : number
Current playback time in seconds within the animation clip.
# .metadata : AnimationBakeMetadata|undefined
Last metadata object passed to {@link AnimationBakeMixer#init}.
Methods
init#
init(meta : AnimationBakeMetadata) : thisInitialize from metadata JSON (single entry point for configuration).
Expected VAT metadata keys: mode='vertex', framesOut, vertexCount, width, height, etc.
Expected OAT metadata keys: mode='object', framesOut, idCount, width, height, etc.
Parameters
AnimationBakeMetadataReturns
thissetConfig#
setConfig(config : AnimationBakeConfig)Update runtime playback configuration values.
Parameters
AnimationBakeConfiggetDuration#
getDuration() : numberReturns the effective duration of the baked animation in seconds. Falls back to frames / fps when metadata does not provide a duration.
Returns
numbergetTime#
getTime() : numberReturns the current playback time in seconds.
Returns
numbersetTime#
setTime(seconds : number, options : Object) : thisSet playback time in seconds. When wrap is true and looping is enabled the
provided value wraps into the current loop duration, otherwise it is clamped.
Parameters
secondsnumberoptionsoptionalObjectwrapoptionalbooleanDefault istrue.
Returns
thissetInterpolationOverride#
setInterpolationOverride(mode : 'auto'|'force0'|'force1')Set interpolation override.
Parameters
mode'auto' | 'force0' | 'force1'registerMaterial#
registerMaterial(material : THREE.NodeMaterial, mode : 'vertex'|'object'|Object) : THREE.NodeMaterialRegister a NodeMaterial to use the baked animation.
Pass opts.mode to override the mixer's mode per-material.
Note: You can also wire manually using
Parameters
materialTHREE.NodeMaterialmodeoptional'vertex' | 'object' | Object{ mode, geometry, positionAttribute, normalAttribute, vertexCount, instanceCount, frameIndexNode, framesCountNode, textureOffsetNode, idNode, positionInputNode, normalInputNode }Returns
THREE.NodeMaterialExample
animationTexturePosition( this.texture, mixer.frameIndexUniform, mixer.framesCountUniform, mixer.frameTimeUniform, mixer.textureOffsetUniform )
animationTextureNormal( this.texture, mixer.frameIndexUniform, mixer.framesCountUniform, mixer.frameTimeUniform, mixer.textureOffsetUniform )
play#
play()Begin playback of the baked animation using the current configuration.
pause#
pause()Pause playback while preserving the current frame and interpolation value.
stop#
stop()Stop playback and seek back to the first frame.
seekFrame#
seekFrame(frameIndex : number)Jump to a specific baked frame index.
Parameters
frameIndexnumberseekSeconds#
seekSeconds(seconds : number)Seek to a specific playback time in seconds.
Parameters
secondsnumberupdate#
update(deltaSeconds : number)Advance playback by the provided delta time.
Parameters
deltaSecondsnumberattachGUI#
attachGUI(gui : object, opts : Object) : thisAttach a standard playback GUI to this mixer. Compatible with lil-gui, dat.gui, and Three.js Inspector.
Parameters
guiobjectlil-gui or renderer.inspector.createParameters().optsoptionalObjectfolderNameoptionalstringCustom name for the created folder.
Returns
thisStatic Methods
inferFrames#
inferFrames(texture : THREE.DataTexture, options : Object) : numberInfer frame count from a baked animation texture.
Parameters
textureTHREE.DataTextureoptionsoptionalObjectvertexCountoptionalnumberVertex count for VAT data.objectCountoptionalnumberInstance/object count for OAT data.modeoptional'vertex'|'object'Specifies how to interpret the texture layout.
Default is'vertex'.
Returns
number — Inferred number of frames.Type Definitions
AnimationBakeMetadata#
mode:'vertex'|'object', framesOut:number, idCount:number, vertexCount:number, +6 more
Properties
modeoptional'vertex' | 'object'framesOutoptionalnumberidCountoptionalnumbervertexCountoptionalnumberwidthoptionalnumberheightoptionalnumberoriginalFramesoptionalnumbersampleStepoptionalnumberdurationoptionalnumberclipDurationoptionalnumberAnimationBakeConfig#
fps:number, playbackSpeed:number, loop:boolean, play:boolean
Properties
fpsoptionalnumberplaybackSpeedoptionalnumberloopoptionalbooleanplayoptionalboolean