What steps will reproduce the problem?
1. Create a shaded sphere and place at 0, 0, 0
2. Create a directional light and place it somewhere
3. Place camera at any location and move the shaded object progressively
What is the expected output? What do you see instead?
specular and diffuse shading foci on the object should be placed correctly,
translations are being ignored
Please use labels and text to provide additional information.
BAD BEHAVIOUR: http://www.lidev.com.ar/demos/away3d/directional_lights_bug/
EXPECTED BEHAVIOUR:http://www.lidev.com.ar/demos/away3d/dirlights_pfix1/
Second demo runs with this patch in DirectionalLight.as
public function setDiffuseTransform(source:Object3D):void
{
if (!diffuseTransform[source])
diffuseTransform[source] = new MatrixAway3D();
// UGLY PATCH BY Li (REVIEW!!) -----------------------------------
direction.x = _light.x - source.scenePosition.x;
direction.y = _light.y - source.scenePosition.y;
direction.z = _light.z - source.scenePosition.z;
direction.normalize();
nx = direction.x;
ny = direction.y;
mod = Math.sqrt(nx*nx + ny*ny);
transform.rotationMatrix(ny/mod, -nx/mod, 0,
-Math.acos(-direction.z));
//clearTransform();
// ---------------------------------------------------------------
diffuseTransform[source].multiply3x3(transform,
source.sceneTransform);
diffuseTransform[source].normalize(diffuseTransform[source]);
}
public function setSpecularTransform(source:Object3D, view:View3D):void
{
//find halfway matrix between camera and direction matricies
cameraTransform = view.camera.transform;
cameraDirection.x = -cameraTransform.sxz;
cameraDirection.y = -cameraTransform.syz;
cameraDirection.z = -cameraTransform.szz;
// UGLY PATCH BY Li (REVIEW!!) -----------------------------------
var applDirection:Number3D = new Number3D(_light.x -
source.scenePosition.x,
_light.y -
source.scenePosition.y,
_light.z -
source.scenePosition.z);
applDirection.normalize();
// ---------------------------------------------------------------
halfVector.add(cameraDirection, applDirection);
halfVector.normalize();
nx = halfVector.x;
ny = halfVector.y;
mod = Math.sqrt(nx*nx + ny*ny);
halfTransform.rotationMatrix(-ny/mod, nx/mod, 0,
Math.acos(-halfVector.z));
if(!specularTransform[source][view])
specularTransform[source][view] = new MatrixAway3D();
specularTransform[source][view].multiply4x4(halfTransform,
source.sceneTransform);
specularTransform[source][view].normalize(specularTransform[source][view]);
}
Original issue reported on code.google.com by paleblue...@gmail.com on 20 Oct 2009 at 7:20
Original issue reported on code.google.com by
paleblue...@gmail.com
on 20 Oct 2009 at 7:20