nanogl-gltf
Version:
43 lines (42 loc) • 1.51 kB
TypeScript
import AnimationChannel from './AnimationChannel';
import AnimationSampler from './AnimationSampler';
import Gltf2 from '../types/Gltf2';
import GltfLoader from '../io/GltfLoader';
import GltfTypes from '../types/GltfTypes';
import { IElement } from '../types/Elements';
/**
* The Animation element contains the data to animate a node, linking with samplers and channels.
*/
export default class Animation implements IElement {
readonly gltftype: GltfTypes.ANIMATION;
name: undefined | string;
extras: any;
/**
* Array of samplers used to sample the animation values and keyframes
*/
samplers: AnimationSampler[];
/**
* Array of channels used to animate the nodes
*/
channels: AnimationChannel[];
/**
* Duration of the animation
*/
duration: number;
/**
* Parse the Animation data, creates the samplers and channels.
*
* Is async as it needs to wait for all the samplers and channels to be created.
* @param gltfLoader GLTFLoader to use
* @param data Data to parse
*/
parse(gltfLoader: GltfLoader, data: Gltf2.IAnimation): Promise<any>;
/**
* Evaluate the animation at a given time, updating the nodes properties.
* It evaluates each channel, which in turn evaluates the sampler and apply the value to the node.
* @param t Time to evaluate the animation at
*/
evaluate(t: number): void;
getChannel(i: number): AnimationChannel;
getSampler(i: number): AnimationSampler;
}