.fbx文件需放在public目錄下

image.png
import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
mounted(){
this.mod();
},
methods: {
mod(){
let that = this
let loader = new FBXLoader()
loader.load('three/SambaDancing.fbx', function(obj){
obj.scale.set(.35, .35, .35); // 放大縮小
obj.position.set(205, 0, -80); // 位置
obj.rotation.y += 1.55; // 旋轉(zhuǎn)
that.scene.add(obj)
that.clock = new THREE.Clock()
// obj作為參數(shù)創(chuàng)建一個(gè)混合器,解析播放obj及其子對(duì)象包含的動(dòng)畫(huà)數(shù)據(jù)
that.mixer = new THREE.AnimationMixer(obj);
let animationAction = that.mixer.clipAction(obj.animations[0]);
// animationAction.timeScale = 1; //默認(rèn)1,可以調(diào)節(jié)播放速度
// animationAction.loop = THREE.LoopOnce; //不循環(huán)播放
// animationAction.clampWhenFinished=true;//暫停在最后一幀播放的狀態(tài)
animationAction.play(); //播放動(dòng)畫(huà)
}, undefined, function ( error ) {
console.error( error );
});
},
}