Playing animation only once #2226
Replies: 13 comments 3 replies
-
@elalish I have a questions regarding events. Do we have something like 'timeudpate' event like audio html tag? In that way if I can get the value of currentTime in realtime then it is possible to play only once. When current time arrives at 0 again, then we can pause the animation and the current time can be reset again. example : https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_av_event_timeupdate_el |
Beta Was this translation helpful? Give feedback.
-
No, for now your best bet is |
Beta Was this translation helpful? Give feedback.
-
Here is a way i got it working, if others are looking for solutions.
Its not perfect. but works. |
Beta Was this translation helpful? Give feedback.
-
@dhruvadhia1 hey man. I added this codes to js but It is not working. Animation still in loop. Any other solutions ? |
Beta Was this translation helpful? Give feedback.
-
How about something like:
|
Beta Was this translation helpful? Give feedback.
-
@elalish , this code will pause any given animation after 1 second. However, the length of the animation could vary. try this code
|
Beta Was this translation helpful? Give feedback.
-
@elalish @dhruvadhia1 I tried both of your codes but animation still in loop maybe Im doing sth wrong or there is problem with codes. Did you try this codes on your project? If you dont mind can I see project? |
Beta Was this translation helpful? Give feedback.
-
try this link https://thecela.com/configurator/TEo1Y29GMTBNS0EwWUdWPQ==/QVF0PQ==/cDJBdW90PT0=# when you click on different hotspots, it will play animation either in loop or once. |
Beta Was this translation helpful? Give feedback.
-
I use a "setTimeout" to play and stop at the end
you can see the result here http://www.evolution-biologique.org/test-anim.html |
Beta Was this translation helpful? Give feedback.
-
Hello. I try to control an animation exported in GLB with your code but at the end of the anime it reboots. I wish I had a button to play it and a button to rewind it |
Beta Was this translation helpful? Give feedback.
-
Hi, The setTimeout solution works really well on the Webpage itself. But when going in AR mode, it doesn't work consistently. The problem seems to be apparent when the framerate fluctuates... Is it possible that the 3D engine that holds the animations/3D models, and the web page that holds the setTimeout function are running on two different internal timers? So if the 3D engine drops frames then the webpage keeps going then they become out of sync. |
Beta Was this translation helpful? Give feedback.
-
I'm working on implementing this feature (#3021). Please support me if you can. |
Beta Was this translation helpful? Give feedback.
-
It's my solution. And it's work fine.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Playing animation only once after clicking play for example instead of constant looping. One idea I had is that if I can get total duration of animation then too I can stop animation from playing once it reaches the end. But it would also be good to have method like playOnce().
Live Demo
https://glitch.com/edit/#!/model-viewer
https://thecela.com/configurator/TEo1Y29KUzBuSjlocVRJbXFOPT0=/QVF0PQ==/cDJBdW90PT0=
Version
Latest version
Browser Affected
All
OS
All
Beta Was this translation helpful? Give feedback.
All reactions