Having some trouble grasping the concept of Collada Animation in Three.js! I have an animation with a moving camera in 3Dsmax, and exported the scene into Collada.
loader.load( ColladaName, function ( collada ) {
model = collada.scene;
model.updateMatrix();
animations = collada.animations;
kfAnimationsLength = animations.length;
model.scale.x = model.scale.y = model.scale.z = 0.001; // 1/8 scale, modeled in cm
document.getElementById('preload').style.opacity = '0';
callback()
} );
I extracted the camera object from the collada:
model.traverse(function(child) {
if (child instanceof THREE.PerspectiveCamera) {
camera = child;
camera.near = 1;
camera.fov = 30;
camera.castShadow = true;
}
if (child instanceof THREE.SpotLight) {
child.castShadow = true;
child.shadowBias = 0.02;
child.shadowCameraNear = 1;
child.shadowCameraFov = 60;
child.intensity = 1.2;
child.shadowMapWidth = 1024; // default is 1024
child.shadowMapHeight = 1024; // default is 1024
child.shadowDarkness = 0.06; // default is 512
}
});
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
Next, I rendered it in my scene: camera.lookAt(scene.position) renderer.render(scene, camera);
Everything appears on the screen, I can see my model with the imported camera, but unfortunately my camera does not focus on the scene and doesn't replicate the x-rotation as in my 3Dsm zoom in and out! Whenever I log the camera position, it always shows: 0,0,0. Furthermore, if I log the model.children[0] position, which corresponds to the perspective camera imported from the collada, it also shows 0,0,0.
What could be causing this issue?
EDIT 1:
I attempted to update my camera matrix using the imported camera from the Collada file:
camera.matrixNeedsUpdate = true;
model.children[0].matrixNeedsUpdate = true;
model.children[0].lookAt(model.position)
camera.matrix.elements = model.children[0].matrix.elements
Unfortunately, I didn't see any noticeable results.