- 수정됨
[threeJS] i want checking of some animations state.
- I want checking that 'some name' animation's state.
Like this,
if (skeletonMesh.getAniState('someName).end) somethingObj.position.x = 0;
- or call something function with event when end(start or ing) 'some name' animation.
Like this,
skeletonMesh.getAni('someName').addEventListener(()=>{}, 'end');
Let me know even if it's a little different.
Please help me!
You can get the current animation name this way:
AnimationState state;
int trackIndex = 0;
TrackEntry entry = state.getCurrent(trackIndex);
String animationName;
if (entry == null)
animationName = null;
else
animationName = entry.getAnimation().getName();
It doesn't have to be so long, of course:
if (state.getCurrent(0) != null && state.getCurrent(0).getAnimation().getName() == "someName") { ... }
If you know the AnimationState always has a TrackEntry:
if (state.getCurrent(0).getAnimation().getName() == "someName") { ... }
You can see documentation here:
API Reference - Spine Runtimes Guide
You can set a listener using AnimationState addListener
for the whole AnimationState, or TrackEntry listener
for just one entry. Here is an example using JavaScript:
spine-runtimes/hoverboard.js at 3.8
More examples here:
spine-runtimes/spine-ts/webgl/demos at 3.8
Your answers helped me. Thank you!