Animation Actions
os.startFormAnimation(botOrBots: (string | Bot | (string | Bot)[]), nameOrIndex: (string | number), options?: StartFormAnimationOptions): Promise<void>
Starts the given animation on the given bot or list of bots using the given options. Returns a promise that resolves once the animation(s) have been started.
Triggers the @onFormAnimationStarted
and @onAnyFormAnimationStarted
listeners once the animation has started.
The first parameter is a (string | Bot | (string | Bot)[]) and is the bot or list of bots that the animation should be started on.
The second parameter is a (string | number) and is the name of the animation that should be started. Additionally, it can be the index number of the animation that should be played.
The third parameter is optional and is a StartFormAnimationOptions and is the options that should be used to play the animation.
Examples
await os.startFormAnimation(thisBot, "Run");
await os.startFormAnimation(getBots(inDimension("home")), "Run");
await os.startFormAnimation(thisBot, "Run", {
loop: {
mode: 'repeat',
count: 5
}
});
await os.startFormAnimation(thisBot, "Run", {
startTime: os.localTime + 5000
});
await os.startFormAnimation(thisBot, "Run", {
timeScale: 0.5
});
os.stopFormAnimation(botOrBots: (string | Bot | (string | Bot)[]), options?: StopFormAnimationOptions): Promise<void>
Stops the animations that are running on the given bot or list of bots using the given options. Returns a promise that resolves once the animations have been stopped.
This function only works for animations that have been started by os.startFormAnimation(botOrBots, nameOrIndex, options)
.
Triggers the @onFormAnimationStopped
and @onAnyFormAnimationStopped
listeners once the animation has stopped.
The first parameter is a (string | Bot | (string | Bot)[]) and is the bot or list of bots whose animations should be stopped.
The second parameter is optional and is a StopFormAnimationOptions and is the options that should be used for stopping the animations.
Examples
await os.stopFormAnimation(thisBot);
await os.stopFormAnimation(thisBot, {
fadeDuration: 1000 // Take 1 second to stop the animation
});
await os.stopFormAnimation(thisBot, {
stopTime: os.localTime + 5000
});
os.listFormAnimations(botOrAddress: (string | Bot)): Promise<FormAnimationData[]>
Retrieves the list of animations that are available on the given bot or GLTF mesh address. Returns a promise that resolves with the list of available animations.
The first parameter is a (string | Bot) and is the bot or address that the animation list should be retrieved from
Examples
const animations = await os.listFormAnimations(thisBot);
const animations = await os.listFormAnimations('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf');
os.bufferFormAddressGLTF(address: string): Promise<void>
Pre-caches the given GLTF mesh address so that it will load instantly when used on a bot later. Returns a promise that resolves once the address has been cached.
The first parameter is a string and is the address that should be cached.
Examples
await os.bufferFormAddressGLTF('https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Fox/glTF/Fox.gltf');
os.toast("Buffered!");