I am experimenting with creating games using Three.js and I would like to ask if there is a way to animate a GLFT model but instead of having the animation loop I would like to use random intervals. In my case, the game is about taking care of frogs (but I'm cool so I spelled it phrogs) and as an idle animation I want the frogs to croak randomly. Further on in development I also want to add randomly playing animations for movement, eating etc but right now I only need the croaking animation. Here is the code that loads the model and animates it:
const basePhrog = new GLTFLoader()
var obj
basePhrog.load('assets/models/Phrogs/base phrog/phrog.gltf', function (gltf) {
mixer = new THREE.AnimationMixer(gltf.scene)
obj = gltf.scene
var action = mixer.clipAction(gltf.animations[0])
scene.add(gltf.scene)
action.play()
})
My animate loop looks like this:
function animate () {
requestAnimationFrame(animate)
var delta = clock.getDelta()
if (mixer) mixer.update(delta)
renderer.render(scene, camera)
}
animate()
I hope you can help and thank you for any suggestions!