Skip to content
Advertisement

making two animations at once in A-frame

For example, by using camera rig, I want to move from A to B then B to C in just one single click. I normally write “to 0 0 0” in the event “onclick”.

I want trigger both animations “1” and “1_1”. At the moment it is only the “1_1” that is triggered by a click. I’m using a timeline from https://www.npmjs.com/package/aframe-animation-timeline-component

My code can be found in https://glitch.com/edit/#!/winter-deserted-topaz

Advertisement

Answer

The topic is general, so I’ll split it into separate cases:

  1. Firing two simultaneous animations

    If the animation components within an entity share an event ( defined in startEvents ) they will all fire at once:

    JavaScript
  2. Starting an animation after another one is finished

    You can wait for one animation to finish and start another one with a bit of javascript.

    You can determine if an animation has ended with the animationcomplete__(ID is the ‘name’ string after the animation__ bit) event.

    Then you can emit a signal, which starts the second animation:

    JavaScript
Advertisement