I am currently working on a simple mesh animation stored in a .gltf file and I need it to start playing at a specific time in seconds.
Below is the setup for the loader and mixer:
GLTFLoader.load( 'myscene.gltf', function ( gltf ) {
model = gltf.scene;
scene.add( model );
mixer = new THREE.AnimationMixer( model );
mixer.clipAction(gltf.animations[0])
.setDuration( 60 ) //total of 1 min
.play();
render();
});
Within the render() function, this code snippet can be found:
function render() {
var delta = clock.getDelta();
if (mixer != null) {
mixer.update(delta);
};
//console.log(delta); //Doesn't show anything valuable.
renderer.clear();
composer.render();
counter++;
}
I have experimented with the method .startAt(10)
, which acts only as a delay before playing. It should ideally be renamed to .delay()
. The function startAt()
seems more suitable for what I am trying to achieve. Additionally, attempting to use .play(10)
has proven unsuccessful. Although mixer.time
does provide the actual elapsed time since play in seconds, it cannot be manually set to a specific value.
I find the concept of clock.getDelta()
puzzling, especially in terms of how it determines what part of the animation should be played next considering the seemingly repetitive numbers it outputs. How can I ensure that the animation starts at, let's say, 10 seconds in or even a specific keyframe number?