nanogl-gltf
Version:
60 lines (59 loc) • 2.04 kB
TypeScript
import AnimationSampler, { SamplerEvaluator } from './AnimationSampler';
import Node from './Node';
import Gltf2 from '../types/Gltf2';
import GltfLoader from '../io/GltfLoader';
import GltfTypes from '../types/GltfTypes';
import { IElement } from '../types/Elements';
import { TypedArray } from '../types/TypedArray';
export declare type applyFunc = (node: Node, value: TypedArray) => void;
/**
* The AnimationChannel element contains the data to animate a node property.
*/
export default class AnimationChannel implements IElement {
readonly gltftype: GltfTypes.ANIMATION_CHANNEL;
name: undefined | string;
extras: any;
/**
* Whether the channel is active or not
*/
_active: boolean;
/**
* Linked AnimationSampler
*/
sampler: AnimationSampler;
/**
* Node's property to animate (TRASLATION, ROTATION, SCALE or WEIGHTS)
*/
path: Gltf2.AnimationChannelTargetPath;
/**
* Function to apply the animation value to the corresponding node property
* (and manage node invalidation for translation, rotation and scale animation)
*/
applyFunction: applyFunc;
/**
* Node to animate
*/
node: Node;
/**
* TypedArray to store the animation value at each re-evaluate
*/
valueHolder: TypedArray;
/**
* SamplerEvaluator to use to evaluate the animation value at a given time
*/
evaluator: SamplerEvaluator;
/**
* Parse the AnimationChannel data, create the SamplerEvaluator and the valueHolder.
*
* Is async as it needs to wait for the target Node to be created.
* @param gltfLoader GLTFLoader to use
* @param data Data to parse
*/
parse(gltfLoader: GltfLoader, data: Gltf2.IAnimationChannel): Promise<any>;
/**
* Evaluate the animation at a given time, and apply the animation value to the corresponding node property,
* with the corresponding interpolation function.
* @param t Time to evaluate the animation at
*/
evaluate(t: number): void;
}