So, i have a 3d model created in blender and exported. The file is attached below if it’s needed. In it i have an armature with a wave animation. I would love to play it in three js as well, but i’m having some problems. I tried the method that everyone does and for some reason it doesn’t play the animation. Not only that, but the position of the armature is completely different than the one in blender. The good news is that a gltf viewer like https://gltf-viewer.donmccurdy.com/ loads it properly, so chances are something is wrong with my code. I’ve never done this before. Can anyone help?
contactCrate2.glb (703.5 KB)
this.gltfLoader.load(this.bakedModelUrls[this.index], gltf => {
this.mixer = new THREE.AnimationMixer(gltf.scene);
this.timer.runOnTick(() => {
this.mixer.update(this.timer.getDelta());
});
gltf.animations.forEach(clip => {
this.mixer.clipAction(clip).play();
});
gltf.scene.traverse(child => {
if (!child.isObject3D) return;
child.material = this.bakedMaterial;
});
this.scene.add(gltf.scene);
});
Here are the code bits from the Timer class, just in case:
tick() {
this.newTime = this.clock.getElapsedTime();
this.deltaTime = this.newTime - this.oldTime;
this.oldTime = this.newTime;
this.functionsToRunOnTick.forEach(func => func());
window.requestAnimationFrame(this.tick);
}
getDelta() {
return this.deltaTime;
}