Simple question, is it currently possible to have a THREE.DirectionalLight that points away from the center of the scene?
Yes, DirectionalLight shines in the direction of vector from its position to the position of its target:
var light = new THREE.DirectionalLight( 0xffffff );
light.position.set( fromX, fromY, fromZ );
light.target.position.set( toX, toY, toZ );
Or you can set target to be something from the scene graph:
light.target = myObject;
Though all direction vector settings have equivalent to some unit vector pointing to (0,0,0).
Thanks for the reply! Sorry if im wasting your time by doing something stupid here but ive put a snippet of my code below that i have been running, no matter where i set the target position to be it always points to (0,0,0). I have been running my code with shadowCameraVisible set to true so i can clearly see the direction and it never changes.
var light = new THREE.DirectionalLight(0xFFFFFF);
light.position.set(0, 1500, 0);
light.target.position.set(6000, 0, 3000);
light.shadowCameraVisible = true;
light.castShadow = true;
scene.add(light);
Also what do you mean by
'Though all direction vector settings have equivalent to some unit vector pointing to (0,0,0).'
Could this be causing my problem?
I'm not sure I understand what do you want to achieve.
Do you know what is directional light? It is light that shines in a constant direction everywhere in the space.
The only thing that matters for directional light is the orientation of the surface normal with respect to the light direction. It doesn't matter where in the space are both object and light.
I am trying to emulate a flash for a camera, so i began by first creating a directional light just facing in the direction my camera mesh is facing, but i am not having any luck in pointing the light the same was as the camera mesh is facing.
I tried doing this with a PointLight and it worked ok except for the fact that the light appeared behind the camera mesh too, thats why I switched to a directionallight.
Am I going the wrong way about this?
Thanks for your help so far
Hmmm, we actually don't have any light type which would be able do this.
While you should be able to point DirectionalLight in the right way, it would suffer the same problem like you had with PointLight - also surfaces behind the light would get illuminated.
For flash effect we would need to have true spotlights or area lights. See also #1173
Ah ok, well thanks for the help. Hopefully you guys will get round to doing this, ill just park it for now.
Keep up the great work
Most helpful comment
I'm not sure I understand what do you want to achieve.
Do you know what is directional light? It is light that shines in a constant direction everywhere in the space.
The only thing that matters for directional light is the orientation of the surface normal with respect to the light direction. It doesn't matter where in the space are both object and light.