Applying Single Frame Actions to GLTF model

I am trying to apply different poses to a 3d model. I am exporting in the gltf format from blender where each pose is a single frame action in the NLA tool. The object appears to load correctly into the scene and animations are present as well, but when I try to play the single frame animation to change the pose, the object doesn’t move out of the rest position.

Here is my code to load and animate the model:

		//load 3d object
		var loader = new THREE.GLTFLoader( );
		//loader.setPath( 'models/3ds/portalgun/textures/' );

		 loadModel = () => {
				loader.load(
					'models/race9.gltf',
					(object) => {

						object.scene.name = "main-scene";
						scene.add(object.scene);
						var helper = new THREE.SkeletonHelper(object.scene);
						scene.add(helper);
						mixer = new THREE.AnimationMixer(object.scene);
						mixer.clipAction( object.animations[ 0 ] ).play();
						console.log(object);
					},
					 null,
					(error) => {
						console.log(error);
					}
				);
		 }

		var animate = function() {
			requestAnimationFrame( animate );


			var delta = clock.getDelta();
			if (mixer != null && mixer !== undefined) {
				mixer.update(delta);
			};
			renderer.render(scene, camera);
		}

		//run game loop
		var GameLoop = function()
		{
			animate();
		};

		GameLoop();

Below the file I’m using:

race9.gltf (177.3 KB)

https://www.dropbox.com/s/ko6kk78juvluep3/race9.bin?dl=0 (bin file)

Thanks for your help!!

Edit:

Solved using PR at (https://github.com/mrdoob/three.js/pull/13430 - Special thanks to Don McCurdy for the PR) Exported poses as single frames in a normal animation and split the clips in threejs. If anyone has specific questions about what I did, please feel free to ask.

You need to share the race9.bin file as well.

+1 to @looeee’s comment on the .bin file.

My first guess, though, would be that you need to set .clampWhenFinished:

var action = mixer.clipAction( object.animations[ 0 ] );
action.clampWhenFinished = true;
action.play(); 

Setting .timeScale to 0 may also do the trick.

https://threejs.org/docs/#api/en/animation/AnimationAction

No luck, but the bin file is now uploaded

I’m not sure what’s going on here yet, but just to try a workaround and eliminate one possible source of error — does it work if you create a second frame (with the same pose) in Blender, and export so there are two keyframes?

I’m having weird and inconsistent results when exporting the NLA Tracks. Only some (or none) of the animations are exported. Is there a different workflow that would work better for creating/exporting/animating different poses?

I tried doing as you said putting the same pose in multiple keyframes, but now when I export, I don’t see the animations at all in the scene.

race11.gltf (154.0 KB)

bin file : https://www.dropbox.com/s/bi7njplw4nyl8nj/race11.gltf?dl=0

I tried three different NLA Tracks:

The first is a single frame duplicated multiple times. This did animation was not present once I loaded the scene)

The second I made take multiple frames. This one loaded

The third is set on repeat for 8 frames . This one also loaded.

However, I am still unable to get the object to animate.