I am struggling to synchronize trackball controls and camera with the directional light.
Here is my situation: I start by initializing an empty scene with a camera, lights, and controls. Then, I load a bufferGeometry obj, calculate its centroid, and adjust the camera and controls position and target based on the object's centroid. To achieve this, I simply set the camera position and controls target like so:
camera.lookAt( position );
camera.position = position;
controls.target.copy( position );
The "position" mentioned here refers to a Three.Vector3 object.
It is crucial for the directional light to automatically sync with the controls.
In version threejs r66, I managed to do this successfully:
function init(){
...
directionalLight.position = controls.object.position;
directionalLight.target.position = controls.target;
...
}
Here, "controls" represents a THREE.TrackballControls object.
However, this approach no longer works in threejs r69. Any suggestions?
Thank you,
Simone
I found a solution by using a pointLight instead of a directionalLight.
Here is how I implemented it:
var pointLight = new THREE.PointLight( 0xffffff, 1, 100 ); camera.add( pointLight );
Thanks to everyone for their assistance!