I have a problem, when a import my glb file, I don’t know how to play its animations.
const loader = new GLTFLoader();
loader.load( 'models/soldier.glb', function ( gltf ) {
while(gltf.scene.children.leght){
console.log(gltf.scene.children[0])
scene.add(gltf.scene.children[0])
}
console.log(gltf)
gltf.scene.position.x = 0;
gltf.scene.position.y = 0;
gltf.scene.position.z = 0;
gltf.scene.scale.set(5,5,5)
gltf.scene.rotation.y = 360
//model = gltf.scene;
scene.add( gltf.scene )
mixer = new THREE.AnimationMixer( gltf.scene );
mixer.clipAction( gltf.animations[0] ).play();
}, function ( xhr ) {
console.log( (xhr.loaded/xhr.total*100)+"% loaded" )
},function ( error ){
console.log("error:")
})
element_001_hydrogen.glb (209.2 KB)
element_019_potassium.glb (2.5 MB)
atom.html (8.2 KB)