0
votes

I have a three.js globe that I've been working on. I've got the OrbitControls working so that when I click and drag around the place the camera moves position quite nicely. However I'd like the light to move at the same time. I tried

 controls = new OrbitControls(camera,light,renderer.domElement );

but this doesn't work. Do I have to set up a separate control variabble that manages the light or can I control them both within the 'controls' variable. if so how do I do this?

Many thanks

1
You can also do this: scene.add( camera ); camera.add ( pointLight ); and then there is no need to update the light position in the render loop. - WestLangley

1 Answers

0
votes

Copy the cameras position and set it as spotlight position. Do this In your update function because you want the light to follow when you are moving the camera:

spotlight.position.copy( camera.getWorldPosition() );

jsfiddle: http://jsfiddle.net/L0rdzbej/128/