# Extract derived 3D scaling from a 3D Sprite to set to a 2D billboard

I am trying to get the derived position and scaling of a 3D Sprite and set them to a 2D Sprite.

I have managed to do the first part like this:

        var p:Point = sprite3d.local3DToGlobal(new Vector3D(0,0,0));
billboard.x = p.x;
billboard.y = p.y;


But I can't get the scaling part correctly. I am trying this:

        var mat:Matrix3D = sprite3d.transform.getRelativeMatrix3D(stage); // get derived matrix(?)
var scaleV:Vector3D = mat.decompose()[2]; // get scaling vector from derived matrix
var scale:Number = scaleV.length;
billboard.scaleX = scale;
billboard.scaleY = scale;


...but the result is apparently wrong.

PS. One might ask what I am trying to achieve. I am trying to create "billboard" 3D sprites, i.e. sprites which are affected by all 3D transformations except rotations, thus they always face the "camera".

• I think the scale in the Matrix will have been changed by the rotation of the 3D sprite, in which case you may need to multiply it by the inverse of the rotation matrix? – Jonathan Connell Oct 7 '12 at 11:27
• see a relevant Q&A on SO: stackoverflow.com/questions/12446835/… – gilad hoch Oct 7 '12 at 11:27
• @Jonathan Connell Come again? – Bill Kotsias Oct 7 '12 at 17:46