I have a simple GLB file that is a mesh deform wave animation. I would like to place multiple copies of the wave but offset their start frames to get a more realistic ocean.
Is it possible to start a glb animation at say frame 10?
I have a simple GLB file that is a mesh deform wave animation. I would like to place multiple copies of the wave but offset their start frames to get a more realistic ocean.
Is it possible to start a glb animation at say frame 10?
Hi @Bill_Sullivan!
I believe the ideal way to go here would be to add a looped setTimeout
to all the elements with the same model. Hereβs how I would do it in steps:
wave
wave-animator.js
and write a component called wave-animator
and inside this component, the following:export const waveAnimatorComponent = {
init() {
this.delay = 100
this.waves = document.querySelectorAll('.wave')
this.el.sceneEl.addEventListener('realityready', () => {
this.waves.forEach((wave, idx) => {
setTimeout(() => {
wave.setAttribute('animation-mixer', {
clip: '*',
loop: 'repeat',
})
}, idx * this.delay)
})
})
},
}
Youβll notice that I added a delay of 100ms per wave. this wonβt delay the animation of the first wave because the index is 0, but every other wave animation will be delayed by increments of 100 milliseconds. You can edit the this.delay
value to then reflect the delay you wish to have per wave.
app.js
file, import this component like so:import { waveAnimatorComponent } from './wave-animator'
AFRAME.registerComponent('wave-animator', waveAnimatorComponent)
a-scene
attach the wave-animator
component and from that point on it should workHope this helps
Hi Joao,
Thanks for this. I was looking for something like animation-mixer.mixer.setTime(10) (I did find some showing this animation-mixer.mixer) but no examples of 8thwall implimention. I was starting to think along the lines of what youβve shown, adding the extra waves via java and delaying them being added to the scene to create the offset. What youβve shown should work for me, thank you!
Try using the animation-mixer
βs startAt
param?
Configures the animation clip to begin at a specific start time (in milliseconds). This is useful when you need to jump to an exact time in an animation. The input parameter will be scaled by the mixerβs timeScale. Negative values will result in a pause before the animation begins.