物体总是在镜头前

时间:2014-11-23 17:49:43

标签: three.js

scene上,我有cameraobj

我希望我的obj始终关注camera

我尝试过:

function render() {
  camera.updateProjectionMatrix();

  var zCamVec = new THREE.Vector3(0,0,1);
  camera.localToWorld(zCamVec);

  obj.lookAt(zCamVec);

  renderer.render(scene, camera);
}

但没有运气:我的obj保持静止......

1 个答案:

答案 0 :(得分:0)

如果我理解你,对象需要在相机前面重新定位,然后看相机。

试试这个:

function render() {
  camera.updateProjectionMatrix();

  var zCamVec = new THREE.Vector3(0,0,1);
  var position = camera.localToWorld(zCamVec);

  obj.position.set(position.x, position.y, position.z);
  obj.lookAt(camera.position);

  renderer.render(scene, camera);
}