Vue2 + three.js
проблема в запуске анимации модели 3d. Есть модель, модель в папке public, вывожу на сцену , но не не воспроизводится анимация. консоль чистая
data() {
return {
model: '../assets/scene.gltf',
}
},
methods: {
init(){
let container = document.getElementById('container');
let loader = new GLTFLoader();
let scene = new THREE.Scene();
scene.background = new THREE.Color(0x00FFFFFF);
let camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 10000);
camera.rotation.y = 35 / 180 * Math.PI;
camera.position.x = 600;
camera.position.y = 100;
camera.position.z = 1000;
loader.load(this.model, model => {
let mod = model.animations[0]
console.log(mod);
scene.add(model.scene);
let mixer = new THREE.AnimationMixer( model.scene );
mixer.timeScale = 1/5
mixer.clipAction(mod).play();
// model.animations.forEach((clip)=>{
// mixer.clipAction( clip ).play();
// })
animate();
});
let hlight = new THREE.AmbientLight(0xffffff, 1);
scene.add(hlight);
let light1 = new THREE.PointLight(0xffffff, 1);
light1.position.set(500, 100, 950);
scene.add(light1);
let light2 = new THREE.PointLight(0xffffff, 1);
light2.position.set(-500, 300, 500);
scene.add(light2);
let renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
container.appendChild(renderer.domElement);
renderer.render(scene, camera);
let animate = function () {
requestAnimationFrame(animate);
renderer.render(scene, camera);
};
},
},
mounted() {
this.init();
}