Julo0sS
Julo0sS

Reputation: 2102

three.js SpotLight orientation (direction) issue

Well, here is the problem,

Actually what I try to achieve is to place, at some places, some spotlights in a basic three.js example.

Here is the way I try to set the spotlight target position :

var light = new THREE.SpotLight(0xFFFFFF);
light.position.set(0,130,0);
light.target.position.set(200,-130,400);
scene.add(light);

The spotlight (light) keeps lighting the point (0,0,0) even if, when I console.log the target.position.(x,y,z) it gives me the right values...

Here is a quick fiddle I did with my full example.

http://jsfiddle.net/1xfno37y/7/

Upvotes: 9

Views: 11802

Answers (1)

Falk Thiele
Falk Thiele

Reputation: 4494

You have to update your light.target after changing (eg. setting position):

light.target.updateMatrixWorld();

Or just add your light.target to the scene:

scene.add( light.target );

Three.js r.71

http://jsfiddle.net/1xfno37y/19/

Further reading: Critical bug with spotLight.target.position #5555

Upvotes: 13

Related Questions