Skip to main content

Animation

Defines keyframes and data for an Animation

Types

AnimationTimeData

interface AnimationTimeData {
positionnumber--

The track position

trackSpeednumber--

The speed of the ride on the track

modelDirectionDirection--

The direction (forwards or backwards) that the ride model is facing

trackstring?--

The name of the track the ride is on

}

TriggerInfo

interface TriggerInfo {
namenumber--

The name of the trigger

positionnumber--

The time position of the trigger in the animation

}

Properties

name

Animation.name: string

Name of the animation

length

Animation.length: number

Total length of the animation in seconds

Functions

new

Constructor
Animation.new() → Animation

Default constructor

fromLength

Animation.fromLength(
lengthnumber,
trackNamestring,
trackSpeednumber,
triggers{TriggerInfo}
) → Animation

Create a Animation

fromData

Constructor
Animation.fromData(datatable) → Result<Animation,string>

Constructs an Animation from a table of data. How it is converted is determined by the .version property.

  • 1 = v1
  • 2 = v2 By default, all animations will be treated as v1

fromDataV2

Constructor
Animation.fromDataV2(datatable) → Result<Animation,string>

Constructs an Animation using data spec v2

fromDataV1

Constructor
Animation.fromDataV1(datatable) → Result<Animation,string>

Constructs an Animation using data spec v1

fromBitBuffer

Constructor
Animation.fromBitBuffer(sourcestring) → Result<Animation,string>

Constructs an Animation from a BitBuffer string Currently not used with v2.

  • Thanks to Dekkonot for the Module!

Errors

TypeDescription
*will error if cannot load the BitBuffer*

fromInstance

Constructor
Animation.fromInstance(instanceInstance) → Result<Animation,string>

Constructs an Animation from an Instance

fromModuleScript

Constructor
Animation.fromModuleScript(moduleScriptModuleScript) → Result<Animation,string>

Constructs an Animation from an ModuleScript

fromKeyframeSequence

Constructor
Animation.fromKeyframeSequence(keyframeSequenceKeyframeSequence) → Result<Animation,string>

Constructs an Animation from a KeyframeSequence

canLerpData

Static
Animation.canLerpData() → boolean

Returns true if AnimationTimeData can be lerped

lerpData

Static
Animation.lerpData(
alphanumber
) → AnimationTimeData

Transition between two animationData. If modelDirection or track is not the same for both, will return second data

getData

Animation:getData(timePositionnumber) → AnimationTimeData?

Returns the AnimationData at a given time.

getTriggerList

Animation:getTriggerList() → {string}

Returns a list of the registered trigger names

getTriggers

Animation:getTriggers(namestring) → {types.TriggerInfo}

Returns all TriggerInfo with the given name

getFirstTrigger

Animation:getFirstTrigger(namestring) → TriggerInfo | nil

Returns the first trigger found with the given name. Triggers are ordered by time position

getTriggersPassed

Animation:getTriggersPassed(
startTimenumber,
endTimenumber,
updateDirectionboolean?,--

Default = true

includeStartTimeboolean?--

Default = false

) → {types.TriggerInfo}

Returns a list of triggers passed in this time range. If includeStartTime is true, will use the range [startTime, endTime]. Otherwise, will use (startTime, endTime]

getTriggersPassedForwards

Animation:getTriggersPassedForwards(
startTimenumber,
endTimenumber,
includeStartTimeboolean?--

Default = false

) → {types.TriggerInfo}

If includeStartTime is true, will use the range [startTime, endTime]. Otherwise, will use (startTime, endTime]

getTriggersPassedBackwards

Animation:getTriggersPassedBackwards(
startTimenumber,
endTimenumber,
includeStartTimeboolean?--

Default = false

) → {types.TriggerInfo}

If includeStartTime is true, will use the range [startTime, endTime]. Otherwise, will use [startTime, endTime)

getTracks

Animation:getTracks() → {string}

Returns a list with no duplicates of required track data

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Default constructor",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Animation"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 50,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_fromData",
            "desc": "Creates an Animation fromData without typeChecking",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "types.AnimationData"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Animation"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "private": true,
            "source": {
                "line": 79,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromLength",
            "desc": "Create a Animation",
            "params": [
                {
                    "name": "length",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "trackName",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "trackSpeed",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "triggers",
                    "desc": "",
                    "lua_type": "{TriggerInfo}"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Animation"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 141,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromData",
            "desc": "Constructs an Animation from a table of data.\nHow it is converted is determined by the .version property.\n- 1 = v1\n- 2 = v2\nBy default, all animations will be treated as v1",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 210,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromDataV2",
            "desc": "Constructs an Animation using data spec v2",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 229,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromDataV1",
            "desc": "Constructs an Animation using data spec v1",
            "params": [
                {
                    "name": "data",
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 242,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromBitBuffer",
            "desc": "Constructs an Animation from a BitBuffer string\nCurrently not used with v2.\n- Thanks to Dekkonot for the Module!",
            "params": [
                {
                    "name": "source",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "errors": [
                {
                    "lua_type": "*will error if cannot load the BitBuffer*",
                    "desc": ""
                }
            ],
            "source": {
                "line": 260,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromInstance",
            "desc": "Constructs an Animation from an Instance",
            "params": [
                {
                    "name": "instance",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 273,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromModuleScript",
            "desc": "Constructs an Animation from an ModuleScript",
            "params": [
                {
                    "name": "moduleScript",
                    "desc": "",
                    "lua_type": "ModuleScript"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 293,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "fromKeyframeSequence",
            "desc": "Constructs an Animation from a KeyframeSequence",
            "params": [
                {
                    "name": "keyframeSequence",
                    "desc": "",
                    "lua_type": "KeyframeSequence"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Result<Animation, string>"
                }
            ],
            "function_type": "static",
            "tags": [
                "Constructor"
            ],
            "source": {
                "line": 314,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_setKeyframeLengthKeyframes",
            "desc": "Caches keyframeLength data. Must be called when setting up data",
            "params": [
                {
                    "name": "keyframeLengthKeyframes",
                    "desc": "",
                    "lua_type": "{types.KeyframeLengthKeyframe}"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "()"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 398,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_getKeyframes",
            "desc": "Returns the Keyframes that are in the given time\nThe third return is the lerpValue\nIf time is less than or equal to zero, it will return only the first keyframe.\nIf time is greater than or equal to the length of the animation, it will return only the last keyframe.",
            "params": [
                {
                    "name": "timePosition",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "First keyframe.",
                    "lua_type": "KeyframeData?"
                },
                {
                    "desc": "Second keyframe.",
                    "lua_type": "KeyframeData?"
                },
                {
                    "desc": "Alpha value between the two keyframes",
                    "lua_type": "number?"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 465,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_getTrackData",
            "desc": "Gets the trackData",
            "params": [
                {
                    "name": "keyframeIndex",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "types.TrackData?"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 560,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_getModelDirection",
            "desc": "",
            "params": [
                {
                    "name": "keyframeIndex",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "types.Direction"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 598,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "_getTransitionType",
            "desc": "",
            "params": [
                {
                    "name": "keyframeIndex",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "types.TransitionType"
                }
            ],
            "function_type": "method",
            "private": true,
            "source": {
                "line": 607,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getData",
            "desc": "Returns the AnimationData at a given time.",
            "params": [
                {
                    "name": "timePosition",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AnimationTimeData?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 635,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "canLerpData",
            "desc": "Returns true if AnimationTimeData can be lerped",
            "params": [
                {
                    "name": "first",
                    "desc": "",
                    "lua_type": "AnimationTimeData"
                },
                {
                    "name": "second",
                    "desc": "",
                    "lua_type": "AnimationTimeData"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 740,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "lerpData",
            "desc": "Transition between two animationData.\nIf modelDirection or track is not the same for both, will return second data",
            "params": [
                {
                    "name": "first",
                    "desc": "",
                    "lua_type": "AnimationTimeData"
                },
                {
                    "name": "second",
                    "desc": "",
                    "lua_type": "AnimationTimeData"
                },
                {
                    "name": "alpha",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "AnimationTimeData"
                }
            ],
            "function_type": "static",
            "tags": [
                "Static"
            ],
            "source": {
                "line": 751,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTriggerList",
            "desc": "Returns a list of the registered trigger names",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{string}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 766,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTriggers",
            "desc": "Returns all TriggerInfo with the given name",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{types.TriggerInfo}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 784,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getFirstTrigger",
            "desc": "Returns the first trigger found with the given name.\nTriggers are ordered by time position",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TriggerInfo | nil"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 802,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTriggersPassed",
            "desc": "Returns a list of triggers passed in this time range.\nIf `includeStartTime` is `true`, will use the range `[startTime, endTime]`.\nOtherwise, will use `(startTime, endTime]`",
            "params": [
                {
                    "name": "startTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "endTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "updateDirection",
                    "desc": "Default = true",
                    "lua_type": "boolean?"
                },
                {
                    "name": "includeStartTime",
                    "desc": "Default = false",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{types.TriggerInfo}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 824,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTriggersPassedForwards",
            "desc": "If `includeStartTime` is `true`, will use the range `[startTime, endTime]`.\nOtherwise, will use `(startTime, endTime]`",
            "params": [
                {
                    "name": "startTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "endTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "includeStartTime",
                    "desc": "Default = false",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{types.TriggerInfo}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 852,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTriggersPassedBackwards",
            "desc": "If `includeStartTime` is `true`, will use the range `[startTime, endTime]`.\nOtherwise, will use `[startTime, endTime)`",
            "params": [
                {
                    "name": "startTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "endTime",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "includeStartTime",
                    "desc": "Default = false",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{types.TriggerInfo}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 892,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "getTracks",
            "desc": "Returns a list with no duplicates of required track data",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{string}"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 932,
                "path": "src/shared/animation/Animation.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "name",
            "desc": "Name of the animation",
            "lua_type": "string",
            "source": {
                "line": 39,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "length",
            "desc": "Total length of the animation in seconds",
            "lua_type": "number",
            "source": {
                "line": 43,
                "path": "src/shared/animation/Animation.lua"
            }
        }
    ],
    "types": [
        {
            "name": "AnimationTimeData",
            "desc": "",
            "fields": [
                {
                    "name": "position",
                    "lua_type": "number",
                    "desc": "The track position"
                },
                {
                    "name": "trackSpeed",
                    "lua_type": "number",
                    "desc": "The speed of the ride on the track"
                },
                {
                    "name": "modelDirection",
                    "lua_type": "Direction",
                    "desc": "The direction (forwards or backwards) that the ride model is facing"
                },
                {
                    "name": "track",
                    "lua_type": "string?",
                    "desc": "The name of the track the ride is on"
                }
            ],
            "source": {
                "line": 624,
                "path": "src/shared/animation/Animation.lua"
            }
        },
        {
            "name": "TriggerInfo",
            "desc": "",
            "fields": [
                {
                    "name": "name",
                    "lua_type": "number",
                    "desc": "The name of the trigger"
                },
                {
                    "name": "position",
                    "lua_type": "number",
                    "desc": "The time position of the trigger in the animation"
                }
            ],
            "source": {
                "line": 780,
                "path": "src/shared/animation/Animation.lua"
            }
        }
    ],
    "name": "Animation",
    "desc": "Defines keyframes and data for an Animation",
    "source": {
        "line": 35,
        "path": "src/shared/animation/Animation.lua"
    }
}