Fix for Away3D z-order rendering problem with ownCanvas = true
I have been using Away3D to create and render super-small 3D models for custom configurators! Unlike most product configurators that use 2D image splices, this uses a real CAD model to render, texture and interact on the web, in real-time!

When using ownCanvas=true, there are known problems with z-order and rendering on Away3D.

CORRECT_Z_ORDER & INTERSECTING_OBJECTS doesn't work on complex models. I added this method to Object3D.as to workaround this issue. This method calculates the absolute Z of the mesh in scene coordinates and sets its screenZOffset accordingly.

public function adjustAbsZOrder():void
       {
        var m1:Matrix3D = _scene == this ? transform : sceneTransform;
        updateDimensions();

        var v:Vector3D  = new Vector3D((_minX + _maxX)/2 , 
				       (_minY + _maxY)/2 , 
			               (_minZ + _maxZ)/2 );
        var tv:Vector3D = m1.transformVector(v);
        this.screenZOffset = tv.z;
       }


Paste that code to core/base/Object3D.as

and call mesh[i].adjustAbsZOrder() for all your meshes that require z-order fixes before you call render(). If a Mesh changes position or rotates, this method needs to be called again!

I also noticed that the distanceTo() method in Object3D does not use the screen transformations, except for the position. So, when a Mesh is rotated and moves closer to the target object, the distanceTo(target) still produces the same value as before.

Transforming m1 & m2 using their positions (like in the code above) before computing their dx/dy/dz works!

Hope that was of help!

You can contact me or leave your comments here.