Camera lookAt not working with stereoeffect

一曲冷凌霜 提交于 2019-12-12 03:24:11

问题


When I use stereoeffect using the following code, how should I get my camera to lookAt a certain Vector3?

function animate() {
    var elapsedSeconds = clock.getElapsedTime();
    requestAnimationFrame(animate);

    update(clock.getDelta());
    render(clock.getDelta());
  }

  function update(dt) {
    resize();
    camera.updateProjectionMatrix();
    controls.update(dt);
  }

  function render(dt) {
    effect.render(scene, camera);
  }

I added camera.lookAt in my initialization code but I understand the render(..) function is constantly called and overrides my lookAt.

So, how do I correctly initialize the scene so that my lookAt point is set?


回答1:


I think its more likely the controls update sending the camera back to it's own target. Try setting the controls target instead.

    var lookat = vertex; /// whatever Vector3 you are using already

    controls.target = lookat;
    controls.update();


来源:https://stackoverflow.com/questions/36800799/camera-lookat-not-working-with-stereoeffect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!