UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

555 lines (248 loc) 7.32 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [EntityModelAnimation](./server.entitymodelanimation.md) ## EntityModelAnimation class Represents a single animation of the model used for an Entity. When to use: controlling individual animation playback, blending, and looping on model entities. Do NOT use for: block entities (they have no model animations). **Signature:** ```typescript export default class EntityModelAnimation implements protocol.Serializable ``` **Implements:** protocol.Serializable ## Remarks EntityModelAnimation instances are composed by an Entity and represent a single animation clip from the entity's model. Events are emitted through the parent Entity's event router and its world. <h2>Events</h2> Events emitted by this class are listed under `EntityModelAnimationEventPayloads`<!-- -->. They are emitted via the parent entity's event router. ## Example ```typescript const walkAnimation = entity.getModelAnimation('walk'); walkAnimation.setLoopMode(EntityModelAnimationLoopMode.LOOP); walkAnimation.play(); walkAnimation.setPlaybackRate(2); ``` \*\*Category:\*\* Entities ## Constructors <table><thead><tr><th> Constructor </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [(constructor)(options)](./server.entitymodelanimation._constructor_.md) </td><td> </td><td> Creates a new EntityModelAnimation instance. </td></tr> </tbody></table> ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [blendMode](./server.entitymodelanimation.blendmode.md) </td><td> `readonly` </td><td> [EntityModelAnimationBlendMode](./server.entitymodelanimationblendmode.md) </td><td> The blend mode of the entity model animation. \*\*Category:\*\* Entities </td></tr> <tr><td> [clampWhenFinished](./server.entitymodelanimation.clampwhenfinished.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation should clamp when finished, holding the last frame. \*\*Category:\*\* Entities </td></tr> <tr><td> [entity](./server.entitymodelanimation.entity.md) </td><td> `readonly` </td><td> [Entity](./server.entity.md) </td><td> The entity that the entity model animation belongs to. \*\*Category:\*\* Entities </td></tr> <tr><td> [fadesIn](./server.entitymodelanimation.fadesin.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation fades in when played or restarted. \*\*Category:\*\* Entities </td></tr> <tr><td> [fadesOut](./server.entitymodelanimation.fadesout.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation fades out when paused or stopped. \*\*Category:\*\* Entities </td></tr> <tr><td> [isPaused](./server.entitymodelanimation.ispaused.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation is currently paused. \*\*Category:\*\* Entities </td></tr> <tr><td> [isPlaying](./server.entitymodelanimation.isplaying.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation is currently playing. \*\*Category:\*\* Entities </td></tr> <tr><td> [isStopped](./server.entitymodelanimation.isstopped.md) </td><td> `readonly` </td><td> boolean </td><td> Whether the animation is currently stopped. \*\*Category:\*\* Entities </td></tr> <tr><td> [loopMode](./server.entitymodelanimation.loopmode.md) </td><td> `readonly` </td><td> [EntityModelAnimationLoopMode](./server.entitymodelanimationloopmode.md) </td><td> The loop mode of the entity model animation. \*\*Category:\*\* Entities </td></tr> <tr><td> [name](./server.entitymodelanimation.name.md) </td><td> `readonly` </td><td> string </td><td> The name of the entity model animation. </td></tr> <tr><td> [playbackRate](./server.entitymodelanimation.playbackrate.md) </td><td> `readonly` </td><td> number </td><td> The playback rate of the entity model animation. \*\*Category:\*\* Entities </td></tr> <tr><td> [weight](./server.entitymodelanimation.weight.md) </td><td> `readonly` </td><td> number </td><td> The weight of the entity model animation. \*\*Category:\*\* Entities </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [pause()](./server.entitymodelanimation.pause.md) </td><td> </td><td> Pauses the entity model animation, does nothing if already paused. \*\*Side effects:\*\* Emits `EntityModelAnimationEvent.PAUSE` when spawned. \*\*Category:\*\* Entities </td></tr> <tr><td> [play()](./server.entitymodelanimation.play.md) </td><td> </td><td> Plays the entity model animation, does nothing if already playing. \*\*Side effects:\*\* Emits `EntityModelAnimationEvent.PLAY` when spawned. \*\*Category:\*\* Entities </td></tr> <tr><td> [restart()](./server.entitymodelanimation.restart.md) </td><td> </td><td> Restarts the entity model animation from the beginning. </td></tr> <tr><td> [setBlendMode(blendMode)](./server.entitymodelanimation.setblendmode.md) </td><td> </td><td> Sets the blend mode of the entity model animation. </td></tr> <tr><td> [setClampWhenFinished(clampWhenFinished)](./server.entitymodelanimation.setclampwhenfinished.md) </td><td> </td><td> Sets whether the animation should clamp when finished, holding the last frame. </td></tr> <tr><td> [setFadesIn(fadesIn)](./server.entitymodelanimation.setfadesin.md) </td><td> </td><td> Sets whether the animation fades in when played or restarted. </td></tr> <tr><td> [setFadesOut(fadesOut)](./server.entitymodelanimation.setfadesout.md) </td><td> </td><td> Sets whether the animation fades out when paused or stopped. </td></tr> <tr><td> [setLoopMode(loopMode)](./server.entitymodelanimation.setloopmode.md) </td><td> </td><td> Sets the loop mode of the entity model animation. </td></tr> <tr><td> [setPlaybackRate(playbackRate)](./server.entitymodelanimation.setplaybackrate.md) </td><td> </td><td> Sets the playback rate of the entity model animation. </td></tr> <tr><td> [setWeight(weight)](./server.entitymodelanimation.setweight.md) </td><td> </td><td> Sets the weight of the entity model animation for blending with other playing animations. </td></tr> <tr><td> [stop()](./server.entitymodelanimation.stop.md) </td><td> </td><td> Stops the entity model animation, does nothing if already stopped. \*\*Side effects:\*\* Emits `EntityModelAnimationEvent.STOP` when spawned. \*\*Category:\*\* Entities </td></tr> </tbody></table>