ThreeJS r69 Trackball controls, camera and directional Light

久未见 提交于 2019-12-11 13:41:38

问题


I need to sync trackball controls and camera with the directional light.

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

where position is a Three.Vector3 obj.

Directional light has to sync automatically with controls.

I did it using threejs r66:

function init(){
...
directionalLight.position = controls.object.position;
directionalLight.target.position = controls.target;
...
}

where controls is a THREE.TrackballControls object.

With threejs r69 does not work anymore. Any suggestions?

Thanks,

Simone


Solved using a pointLight instead a directionalLight.

var pointLight = new THREE.PointLight( 0xffffff, 1, 100 ); camera.add( pointLight );

Thanks all for the help


回答1:


The solution ( thanks to WestLangley ) is:

var pointLight = new THREE.PointLight( 0xffffff, 1, 100 ); 
camera.add( pointLight );


来源:https://stackoverflow.com/questions/27920101/threejs-r69-trackball-controls-camera-and-directional-light

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!