How to go to a specific time/frame in a GLTF animation loop using THREE.js?

Viewed 115

I can start/stop/continue the animation by toggling "animit" var but how can I go to a specific frame in the loop?

This is the code I'm using:

    loader.load( modelurl, function( data ) {
        gltf = data;
        SophiaModel = gltf.scene;
        SophiaModel.traverse( function ( node ) {
            if ( node.isMesh || node.isLight ) {
                node.castShadow = true;
                node.receiveShadow = true;
                node.material.side = sides;
            }

            mixer = new THREE.AnimationMixer(SophiaModel);
            mixer.clipAction(gltf.animations[0]).play();

        } );

        SophiaModel.position.set( -10, -89.1, 20 );
        let s = 90;
        SophiaModel.scale.set(s,s,s);
        sceneCam2T.add( SophiaModel );
        },          
            undefined, function ( error ) {
            console.error( error );
        } 
    );
}

In render function:

    var delta = clock.getDelta();
    if (mixer != null && animit === 1) {
        mixer.update(delta);
    }
0 Answers
Related