three.js定向灯跟随相机 [英] three.js directional light following camera
问题描述
我在使用Three.js时遇到问题并且在相机后面照明。
I having a problem with Three.js and lighting following a camera.
我正在使用轨道控制鼠标移动/
I am using orbit control for the mouse movement/
在版本号66中,以下用途可以使用
In release number 66 the following use to work
light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position = camera.position;
scene.add(light);
然而,在版本号67和68中,照明不遵循相机。光只显示在一个面上。
However in release number 67 and 68 the lighting doesn't follow the camera. The light is only show on one face.
推荐答案
某些Object3D属性在r68中变为不可变,因此复制到.position直接将不再工作。相反,你需要在这些属性上使用各种方法:
Some of the Object3D properties have become immutable in r68, so copying to .position directly won't work anymore. Instead you need to use the various methods on these properties:
light.position.copy( camera.position );
我自己没有使用这些灯,但是从我收集的文档中我们不认为自动跟随任何事情。而且,这个位置是无关紧要的,因为它们的行为就像它们距离无限远;只有轮换才重要。
I've not used these lights myself, but from the documentation I gather that they aren't supposed to automatically follow anything. Also, the position is irrelevant since they act like they're an infinite distance away; only the rotation matters.
这篇关于three.js定向灯跟随相机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!