DirectionalLight.direction does not appear to work dynamically?

Software: Away3D 4.x

Sean72, Newbie
Posted: 30 December 2014 07:30 AM   Total Posts: 28

I was trying to manipulate a DirectionalLight dynamically by updating its .direction, either by assignment of a new Vector3D or by using incrementBy on .direction directly. Neither seems to have any effect. I am able to change e.g. the light’s color dynamically and other properties, but not the .direction vector once it is set the first time. Of course, I can set it to anything the first time and it works fine.

Does it have anything to do with the position of my mesh? But that should not affect the light, since a directional light is infinite with no position, only a direction.

I know it is more common to move the camera, but in this case, I want to change the light direction on the fly.  I can trace out the .direction Vector3D value and see that it is indeed changing, but without visible effect.

While I’m asking, I notice that some older examples show the light direction coordinates ranging from -2000 to 2000, but most examples now only range from -1 to 1. Since the docs don’t say, what is the valid range for these coordinates?

   

rdoi, Member
Posted: 02 January 2015 10:06 PM   Total Posts: 86   [ # 1 ]
Sean72 - 30 December 2014 07:30 AM

I was trying to manipulate a DirectionalLight dynamically by updating its .direction, either by assignment of a new Vector3D or by using incrementBy on .direction directly. Neither seems to have any effect. I am able to change e.g. the light’s color dynamically and other properties, but not the .direction vector once it is set the first time. Of course, I can set it to anything the first time and it works fine.

Does it have anything to do with the position of my mesh? But that should not affect the light, since a directional light is infinite with no position, only a direction.

I know it is more common to move the camera, but in this case, I want to change the light direction on the fly.  I can trace out the .direction Vector3D value and see that it is indeed changing, but without visible effect.

I think changing the vector intenal values directly wont dispatch any update event. Try to reassign the vector back to itself (or to a new vector), so then it will inform the renderer about the change.

dirLight.directiondirLight.direction
Sean72 - 30 December 2014 07:30 AM

While I’m asking, I notice that some older examples show the light direction coordinates ranging from -2000 to 2000, but most examples now only range from -1 to 1. Since the docs don’t say, what is the valid range for these coordinates?

With “direction coordinate”, you mean the direction vector3d values?
Afaik, they are cartesian coordinates, where the “light must be pointing from where it is” in the 3d space, so it depends on scene scale.
Because the vector’s length is irrelevant in this case, and they are parallel, you can get to your desired direction with infinite combinations of x,y,z values, as far they form the same directional hypotenuse.

   

Sean72, Newbie
Posted: 18 January 2015 06:28 AM   Total Posts: 28   [ # 2 ]

I ended up using lookat instead, that worked in the way that the direction vector wouldn’t. There may yet be a way to use the direction vector, but I did not find it.

FWIW, in my setting up directional light vectors, x and y could be positive or negative, but whenever z was negative, the light would stay fixed in one position, regardless of the other values, so I would say that z should always be zero or positive.  There may well be a good reason for this, I just don’t know what it is.

   
   
‹‹ How to rotate a Sprite3D ?

X

Away3D Forum

Member Login

Username

Password

Remember_me



X