要計算出 3D Object 在 screen 的 2D position.
Away3DLite 的寫法:
public function calc2DCoords(screen_element:*):Point
{
{
var posn:Vector3D = screen_element.viewMatrix3D.position;
var screenX:Number = posn.x / posn.z;
var screenY:Number = posn.y / posn.z;
var screenX:Number = posn.x / posn.z;
var screenY:Number = posn.y / posn.z;
return new Point(screenX+screenW_offset,screenY+screeH_offset);
}
}
如果有 Away3D 就可以直接用 camera.screen function.
沒有留言:
張貼留言