ThreeJS R69轨迹球控制,摄像头和定向光 [英] ThreeJS r69 Trackball controls, camera and directional Light
问题描述
我需要同步轨迹球控制和摄像头的定向光。
I need to sync trackball controls and camera with the directional light.
我的情况: INIT相机,灯光和控制一个空的场景。 加载bufferGeometry物镜,获得它的质心,并设置摄像机和控制位置和目标相对于所述物镜的质心。 基本上,我简单地设置摄像机的位置和controls.target有:
My case scenario: Init an empty scene with camera, lights and controls. Load a bufferGeometry obj, get its centroid and set camera and controls position and target relative to the obj centroid. Basically I simply set camera position and controls.target with:
camera.lookAt( position );
camera.position = position;
controls.target.copy( position );
,其中位置是Three.Vector3 OBJ。
where position is a Three.Vector3 obj.
定向光有与控制自动同步。
Directional light has to sync automatically with controls.
我做到了用threejs R66:
I did it using threejs r66:
function init(){
...
directionalLight.position = controls.object.position;
directionalLight.target.position = controls.target;
...
}
,其中控件是一个THREE.TrackballControls对象。
where controls is a THREE.TrackballControls object.
使用threejs R69不再工作了。 有什么建议?
With threejs r69 does not work anymore. Any suggestions?
谢谢
西蒙尼
使用点光源,而不是DirectionalLight的解决。
Solved using a pointLight instead a directionalLight.
变种POINTLIGHT =新THREE.PointLight(0XFFFFFF,1,100); camera.add(点光源);
var pointLight = new THREE.PointLight( 0xffffff, 1, 100 ); camera.add( pointLight );
感谢所有帮助
推荐答案
解决方案(感谢WestLangley)是:
The solution ( thanks to WestLangley ) is:
var pointLight = new THREE.PointLight( 0xffffff, 1, 100 );
camera.add( pointLight );
这篇关于ThreeJS R69轨迹球控制,摄像头和定向光的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!