Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 front of it. How can I do this? I've tried many different ways, but I did not succeed.

Thanks

like image 794
clock131 Avatar asked Jun 20 '13 15:06

clock131


1 Answers

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.

like image 107
Tim Avatar answered Oct 14 '22 09:10

Tim