Three.js: Static light positions in scene

Created on 22 Feb 2012  路  2Comments  路  Source: mrdoob/three.js

Hi,

I would like to have a light attached to the Camera so that it does not rotate when I rotate the whole scene through THREE.TrackballControls.

I am setting up lights like this:

var light = new THREE.DirectionalLight( 0xFFFFFF, 1 );
light.position.set( -0.65, 0.59, 0.48 ).normalize();
scene.add( light );

I think the problem is because lights are binded to the scene. In OpenGL I could set them with an identity modelView matrix and have them fixed but not really sure how to do this with three.js. Has anybody had this problem before?

Thanks

Question

Most helpful comment

You can add the light to the camera with camera.add( light ). Then the light's position is relative to the camera's

All 2 comments

You can add the light to the camera with camera.add( light ). Then the light's position is relative to the camera's

Ops that was it, should have try it, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

boyravikumar picture boyravikumar  路  3Comments

scrubs picture scrubs  路  3Comments

fuzihaofzh picture fuzihaofzh  路  3Comments

Horray picture Horray  路  3Comments

zsitro picture zsitro  路  3Comments