如何在THREE.JS中将对象放置在相机前面? [英] How to put an object in front of camera in THREE.JS?

查看:89
本文介绍了如何在THREE.JS中将对象放置在相机前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个物体放在相机的前面,但无法这样做.

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

我正在使用FlyControls来移动相机,现在我想在其前面放置一个对象.我怎样才能做到这一点?我尝试了许多不同的方法,但没有成功.

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.

谢谢

推荐答案

您是否尝试过将对象作为照相机的子对象,然后将其向前转换?

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);

以上内容将nanobot永久性地放置在镜头前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.

这篇关于如何在THREE.JS中将对象放置在相机前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆