.fbx文件需放在public目录下
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; // 旋转
that.scene.add(obj)
that.clock = new THREE.Clock()
// obj作为参数创建一个混合器,解析播放obj及其子对象包含的动画数据
that.mixer = new THREE.AnimationMixer(obj);
let animationAction = that.mixer.clipAction(obj.animations[0]);
// animationAction.timeScale = 1; //默认1,可以调节播放速度
// animationAction.loop = THREE.LoopOnce; //不循环播放
// animationAction.clampWhenFinished=true;//暂停在最后一帧播放的状态
animationAction.play(); //播放动画
}, undefined, function ( error ) {
console.error( error );
});
},
}