我正在尝试在我的对象上实现第三人称相机。
我用立方体试过了,效果很好
立方体:
var object, camera;
cubeGeometry = new THREE.CubeGeometry( 50, 50, 50 );
cubeMaterial = new THREE.MeshLambertMaterial({ color: 0xFF0000 });
object = new THREE.Mesh( cubeGeometry, cubeMaterial );
scene.add( object );
camera = new THREE.PerspectiveCamera( 45, ASPECT, 0.2, 10000);
camera.position.z = -300;
camera.position.y = 100;
object.add(camera);
camera.lookAt(object.position);
renderer.render( scene, camera );
但我的模型不起作用:
var object, camera;
var loader = new THREE.OBJMTLLoader();
loader.addEventListener('load', function (event){
object = event.content;
object.updateMatrix();
object.scale.set(20,20,20);
scene.add(object);
}, false);
loader.load( "models/dragster.obj", "models/dragster.mtl" );
camera = new THREE.PerspectiveCamera( 45, ASPECT, 0.2, 10000);
object.add(camera);
camera.position.z = -300;
camera.position.y = 100;
camera.lookAt(object.position);
renderer.render( scene, camera );
当我将相机添加到场景时它可以工作,但是当我将它添加到对象时它不会
提前致谢