I would like to have directional light on current camera position and with direction of current camera view vector. But I didn’t found any way how to obtain camera view vector of Away3D/Stage3D camera.
Is it possible to get direction or point on which is current camera looking to?
Thanks for any advice
Paul
RESOLVED: Camera view vectorSoftware: Away3D 4.x |
||
Sorceror, Newbie
Posted: 22 September 2011 10:39 AM Total Posts: 3 |
||
John Brookes, Moderator
Posted: 22 September 2011 10:49 AM Total Posts: 732 [ # 1 ] import away3d.core.math.Matrix3DUtils; |
||
Alejandro Santander, Administrator
Posted: 22 September 2011 03:35 PM Total Posts: 414 [ # 2 ] Nice one John! Sometimes I do this, light.transform = view.camera.transform.clone() |
||
Alex Bogartz, Sr. Member
Posted: 22 September 2011 04:14 PM Total Posts: 216 [ # 3 ] Ok, I know this is probably an easy answer, but how do I get the opposite? I can set the light to the left of the camera like so: mainLight.direction = Matrix3DUtils.getRight(view.camera.transform); But for “getLeft” (which doesn’t exist), I need to have the negative value of the vector. What’s the way to get that? |
||
|
||
|
||
Alex Bogartz, Sr. Member
Posted: 22 September 2011 04:34 PM Total Posts: 216 [ # 6 ] mainLight.direction = Matrix3DUtils.getRight(view.camera.transform); Still makes the light appear from the left of the scene. That second line appears to have no effect. |
||
John Brookes, Moderator
Posted: 22 September 2011 04:42 PM Total Posts: 732 [ # 7 ] var dir:Vector3D = Matrix3DUtils.getRight(view.camera.transform); |
||
Alex Bogartz, Sr. Member
Posted: 22 September 2011 04:55 PM Total Posts: 216 [ # 8 ] Works! Ok, so I think the reason the previous code didn’t work is that the setter for “direction” is like this:
public function set direction(value : Vector3D) : void It’s actually calling the lookAt for the light vector. And since lookAt isn’t a public function, you can’t call that on your own. Maybe it needs an applyDirection function so you could say:
light.direction.x*=1; For animating effects?
|
||
|
||
Alejandro Santander, Administrator
Posted: 22 September 2011 08:46 PM Total Posts: 414 [ # 10 ] Lads, I added getters for forwardVector, rightVector, upVector, backVector, Please sync to the latest github source. You can do things like:
var director:Vector3D = cube.downVector; |