How to put an object in front of camera in THREE.JS?

后端 未结 4 1635
野性不改
野性不改 2021-02-09 03:47

I\'m trying to put an object in front of the camera, but have not been able to.

I\'m using the FlyControls what moves the camera, and I now want to put an object in fron

4条回答
  •  自闭症患者
    2021-02-09 04:23

    Have you tried making your object a child of your camera and then translating it forward?

    camera.add(nanobot);
    nanobot.position.set(0,0,-100);
    

    The above places the nanobot permanently 100 units in front of the camera... and that's where it will stay until you do:

    camera.remove(nanobot);
    

    ...at which point it should just stay where it is in global space until you move it using some other method.

提交回复
热议问题