【问题标题】:Unexpected movement behavior combining an Object3D group, PerspectiveCamera and FlyControl结合 Object3D 组、PerspectiveCamera 和 FlyControl 的意外运动行为
【发布时间】:2013-11-27 00:17:24
【问题描述】:

为了编写 HUD,我在 Object3D 中插入了一个摄像头,目的是将 HUD 元素放置在同一个 Object3D 中。

我现在没有更新相机,而是更新了 HUD,并希望更新其中的所有对象。不过,

  • 移动鼠标时,摄像机似乎围绕场景中心旋转。
  • 当按 W(用于向前移动相机)时,我现在在场景中心前侧向移动。

包括此处描述的精简行:

scene = new THREE.Scene();
hud = new THREE.Object3D();
camera = new THREE.PerspectiveCamera(...);
hud.add(camera);
scene.add(hud);

control = new THREE.FlyControls(hud, renderer.domElement);

【问题讨论】:

    标签: three.js


    【解决方案1】:

    您可以将 HUD Object3D 添加到相机,而不是相反。这应该按预期工作。

    hud = new THREE.Object3D();
    camera = new THREE.PerspectiveCamera(...);
    camera.add(hud);
    scene.add(camera);
    
    control = new THREE.FlyControls(camera, renderer.domElement);
    

    【讨论】:

    • 谢谢!我现在知道关键是在向相机添加元素后将相机读取到场景中!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-13
    • 2016-07-09
    • 1970-01-01
    • 2014-03-27
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多