API Docs for:
Show:

LS.Animation.Track Class

Represents one track with data over time about one property Data could be stored in two forms, or an array containing arrays of [time,data] (unpacked data) or in a single typed array (packed data), depends on the attribute typed_mode

Constructor

LS.Animation.Track

()

Methods

addKeyframe

(
  • time
  • value
  • skip_replace
)
Number

Adds a new keyframe to this track

Parameters:

  • time Number

    time stamp in seconds

  • value

    anything you want to store

  • skip_replace Boolean

    if you want to replace existing keyframes at same time stamp or add it next to that

Returns:

Number:

index of keyframe

convertToTrans10

()

If the track used matrices, it transform them to position,quaternion and scale (10 floats, also known as trans10) this makes working with animations faster

findTimeIndex

(
  • time
)
Number

Returns nearest index of keyframe with time equal or less to specified time (Dichotimic search)

Parameters:

  • time Number

Returns:

Number:

the nearest index (lower-bound)

getIDasName

(
  • use_basename
  • root
)
String

used to change every track so instead of using UIDs for properties it uses node names this is used when you want to apply the same animation to different nodes in the scene

Parameters:

  • use_basename Boolean

    if you want to just use the node name, othewise it uses the fullname (name with path)

  • root LS.SceneNode

Returns:

String:

the result name

getKeyframe

(
  • index
)
Array

returns a keyframe given an index

Parameters:

  • index Number

Returns:

Array:

the keyframe in [time,data] format

getKeyframeByTime

(
  • time
)
Array

returns the first keyframe that matches this time

Parameters:

  • time Number

Returns:

Array:

keyframe in [time,value]

getNumberOfKeyframes

()

returns the number of keyframes

getPropertyInfo

(
  • scene
)
Object

returns information about the object being affected by this track based on its locator the object contains a reference to the object, the property name, the type of the data

Parameters:

Returns:

Object:

an object with the info { target, name, type, value }

getSample

(
  • time
  • interpolation
  • result
)

Samples the data in one time, taking into account interpolation. Warning: if no result container is provided the same container is reused between samples to avoid garbage, be careful.

Parameters:

  • time Number
  • interpolation Number

    [optional] the interpolation method could be LS.NONE, LS.LINEAR, LS.BEZIER

  • result

    [optional] the container where to store the data (in case is an array). IF NOT CONTAINER IS PROVIDED THE SAME ONE IS RETURNED EVERY TIME!

Returns:

:

data

getSampledData

(
  • start_time
  • end_time
  • num_samples
)
Array

returns an array containing N samples for this property over time using the interpolation of the track

Parameters:

  • start_time Number

    when to start sampling

  • end_time Number

    when to finish sampling

  • num_samples Number

    the number of samples

Returns:

Array:

an array containing all the samples

moveKeyframe

(
  • index
  • new_time
)
Number

changes a keyframe time and rearranges it

Parameters:

  • index Number
  • new_time Number

Returns:

Number:

new index

packData

()

takes all the keyframes and stores them inside a typed-array so they are faster to store in server or work with

removeKeyframe

(
  • index
)

removes one keyframe

Parameters:

  • index Number

removeScaling

()

If this track changes the scale, it forces it to be 1,1,1

sortKeyframes

()

Sometimes when moving keyframes they could end up not sorted by timestamp, which will cause problems when sampling, to avoid it, we can force to sort all keyframes

stretch

(
  • scale
)

Scales the time in every keyframe

Parameters:

  • scale Number

    the sacle to apply to all times

trim

(
  • start
  • end
)

removes keyframes that are before or after the time range

Parameters:

  • start Number

    time

  • end Number

    time

unpackData

()

takes all the keyframes and unpacks them so they are in a simple array, easier to work with

Properties

data contains all the keyframes, could be an array or a typed array

enabled if it must be applied

Boolean

interpolation type of interpolation LS.NONE, LS.LINEAR, LS.TRIGONOMETRIC, LS.BEZIER, LS.SPLICE

Number

looped if the last and the first keyframe should be connected

Boolean

name title to show in the editor

String

property the locator to the property this track should modify ( "node/component_uid/property" )

String

type if the data is number, vec2, color, etc

String