Hello guys,
When loading for the first time. I add one main model to the scene and add the main mixer to the mixers array and play the animate function. When I add one more model to scene and add mixer to array mixers. The animation of main model display faster and not sync with other. How can I control that sync.
Below this is my code when I add other model to scene and animate function.
const changeColorWireframe = (color) => {
if (color != '' && modelWireframe && mixerMainModel) {
const mat = new THREE.MeshBasicMaterial({
color: color,
skinning: true,
wireframe: true,
})
modelWireframe.traverse((node) => {
if (node instanceof THREE.Mesh) {
node.receiveShadow = true
node.castShadow = true
node.material = mat
}
})
modelWireframe.name = 'wireframe_model'
mixerWireframe = new THREE.AnimationMixer(modelWireframe)
mixerWireframe.clipAction(model.animations[1]).play()
scene.add(modelWireframe)
const xyz = [...mixers, mixerWireframe]
setMixers(xyz)
animate()
}
}
const animate = () => {
requestAnimationFrame(animate)
const delta = clock.getDelta()
for (const mixer of mixers) {
mixer.update(delta)
}
render()
}
const render = () => {
gl.render(scene, camera)
}
This is my result
Please kindly help me