Threejs/React-Three-Fiber Animation Reset Thumbnail Keyframe - three.js

I am making an animation in react-three-fiber that plays 1 repetition and then resets correctly. However, when it is interrupted midway through, the default/resting/thumbnail keyframe changes to the place where the animation was interrupted. The animation still works, it's just where it resets to that's incorrect. Is there a way to reset this default keyframe to the correct one?

I've found a workaround, but a I hope somebody else has a better answer:
actions['key'].stop().play()
actions['key'].paused = true
Basically, if you play and then pause it immediately, the animation will be on the first frame

Related

Unity Animation Cycle Offset not working

The way I understand it, is if I have an animation that's 30 seconds long and is also a loop, through Cycle Offset I can make this animation start at a time different than second 0. So I could make it start at second 10, go to 30, then back to 0, to 30 and keep looping that way. I have a Game Object, an Animation Controller and an Animation Clip. I set a whole bunch of different values for the Cycle Offset of the Animation by selecting it in the Project Folder and then updated its settings in the Inspector and it does nothing, the animation still starts at second 0 every time, regardless of what value I write in.
Not sure if this helps at all, but I also duplicated my Game Object, Animation Controller and Animation Clip so I actually have 2 of each. I did however, go to my Animator window, to make sure the default state for each Animation Controller is different and it is. I also checked that each object has a different Animation Controller. I honestly don't even think this part matters that much, because even if these were wrong, the animation would at least start from a later point on both game objects when changing the Cycle Offset. What happens though, is basically nothing, the animation just starts from second 0, goes to 30 and loops every time.
What am I missing?
Thanks in advance!
Figured out the error. I guess entering the value manually for some reason it wasn't working. What I had to do instead is to first drag my cursor over the text "Cycle Offset" to modify the value that way.
I don't know if it is the same problem but I had a similar one. What I did wrong was I was setting the cycle offset value as frame (if wanted to offset the animation 15 frames I entered 15)
It seems this field must be entered as rate to full cycle. If you want to offset the animation half way you should enter 0.5. This sould offset 15 frames for a 30 frame clip.

Is it possible to play skin animation in reverse? [Three.js]

How would I go about playing an animation backwards?
I've tried giving the animation handler negative delta but that just stops it. Subtracting the delta from this.currentTime of the animation doesn't work either.
Any ideas?
Since Three.js r69 it's possible to play animations in reverse order by setting animation.timeScale = -1 though only when animation.loop = true.
See Reverse animation, feature request #5062 for more updates.
I am using r126
Set action.loop = THREE.LoopPingPong will play the clip with the choosen number of action.repetitions, alternately playing forward and backward. (doc)

How to properly setup a Cocos2D Animation Sequence with repeating animations

what is the recommended approach to playing animation sequences that include as the end-stone a repeating animation. For example, here are a few scenarios:
Sprite appears on screen, play intro animation, then repeat forever an "idle" animation
Sprite with "idle" animation performs some action thus I need to play some other specific animation at the end of which the sprite should start idling again.
CCSequence does not let me do this, as the "idle" animation is wrapped into a CCRepeatForever.
If I simply chose to run whatever animation I like above the idling animation I get frame flickering (looks like both animations are played at the same time) — sucks.
All animations are inside CCAnimationCache ... any advice will be highly appreciated.
I don't know if there is a recommended approach. What I would do is running the second animation (the repeating one) with a delay or by chaining it to the first through the animation completion handler.
An easy way to do the chaining is adding at the end of your first animation a CCCallFunc action, like here, that will call trigger the second animation:
CCActionInterval* action = [CCSequence actions:
[CCProgressFromTo actionWithDuration:duration_ from:100.f to:0.f],
[CCCallFunc actionWithTarget:self selector:#selector(startSecondAction)],
nil ];

How to stop animation on the start position / frame zero

I tried to stop the animation objects with a button, I want to when it stops, the object is located at the starting position.
For example I have a cube with animated moving position. when the stop button is pressed, the cube back to its original position.
When no animations are playing, Unity does not change the object's position at all - so stopping it will not reset the position for you. It will just not move it any more.
If you want to return the object to the configuration it was in before you started playing your animation, you have to do it yourself. Your options are:
Make the start position be set by an animation as well. That way you can just play that animation after the other one has finished.
Make the animation you're playing return the object to its start position at the end - i.e. have the last frame of the animation be back at the object's start position.
Write code that captures and restores the object's position, by saving the values of transform.position/transform.rotation and then setting them again when the animation has finished.

sound is freezing the cocos2d/box2d scene

my contact listener should play a sound when it feels hit, but if i put this line on the detection part of the listener in my tick method like this :
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:#"boom.m4a"];
the scene is freezing on start for 1 sec, and then all the forces that should be applied on start are gone,and all balls fall down to earth because of gravity, what would not happen if were no freezing,because they have initial impulse that turned off due to freezing..
why my sound freeze the scene ?
how can i pre-loading main game effects before the game starts ??
thanks
Looks like you are not using fixed time step when updating b2World. To preload background music use preloadSoundEffect method of SimpleAudioEngine.

Resources