ThreeJS r69 Trackball controls, camera and directi

2019-08-04 22:33发布

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条回答
相关推荐>>
2楼-- · 2019-08-04 22:46

The solution ( thanks to WestLangley ) is:

var pointLight = new THREE.PointLight( 0xffffff, 1, 100 ); 
camera.add( pointLight );
查看更多
登录 后发表回答