function createObject() {
const loader = new THREE.FBXLoader();
loader.load("Fish.fbx", function (object) {
object.mixer = new THREE.AnimationMixer(object);
mixers.push(object.mixer);
const action = object.mixer.clipAction(object.animations[0]);
action.play();
// 侧面面对镜头
object.rotation.y = Math.PI * 0.5;
// 加入场景
scene.add(object);
// 载入obj后动画循环
loop();
});
}
// 动画循环
function loop() {
requestAnimationFrame(loop);
if (mixers.length > 0) {
for (let i = 0; i < mixers.length; i++) {
mixers[i].update(clock.getDelta());
}
}
renderer.render(scene, camera);
}
标签:function,动画,threejs,object,mixer,mixers,FBXLoader
From: https://www.cnblogs.com/zhuoss/p/16869061.html