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

findTimeIndex

(
  • time
)
Number

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

Parameters:

  • time Number

Returns:

Number:

index

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]

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 }

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

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