import { SerializableObject } from "../../core/SerializableObject" ; import { AnimationKey } from "../keys/AnimationKey" ; import * as Attributes from "../../core/Attributes" ; hidden export interface TokenCache { [ propertyPath ] : string [ ] ; } export interface SerializedAnimationTrack { typeName : string ; version : number ; times : number [ ] ; values : ( boolean | string ) [ ] ; } export interface SerializedNumberTrack { typeName : string ; version : number ; times : [ number , number , number ] [ ] ; values : [ number , number , number ] [ ] ; } export class AnimationTrack extends SerializableObject { hidden @ Attributes . unserializable ( ) tokenCache : TokenCache = { } ; getKeys ( ) { return [ ] ; } getSample ( time , target ? ) { const keys = this . getKeys ( ) ; if ( keys . length === 0 ) { return undefined ; } const keysAfter = keys . filter ( k => k . time > time ) ; if ( keysAfter . length === keys . length ) { return keysAfter [ 0 ] . getValue ( ) ; } const keysBefore = keys . filter ( k => k . time <= time ) ; console . assert ( keysBefore . length > 0 ) ; const srcKey = keysBefore [ keysBefore . length - 1 ] ; if ( keysBefore . length === keys . length ) { return srcKey . getValue ( ) ; } console . assert ( keysAfter . length > 0 ) ; const destKey = keysAfter [ 0 ] ; const factor = ( time - srcKey . time ) / ( destKey . time - srcKey . time ) ; return srcKey . lerp ( srcKey , destKey , factor , target ) ; } isLoaded ( ) { return true ; } createKey ( time , value , created ? ) { } removeKey ( key ) { } sortByTime ( removeDuplicates = true ) { } }