Skip to content

Instantly share code, notes, and snippets.

@SirGordon
Last active October 6, 2015 14:33
Show Gist options
  • Save SirGordon/e3622e7cf4de3d99640e to your computer and use it in GitHub Desktop.
Save SirGordon/e3622e7cf4de3d99640e to your computer and use it in GitHub Desktop.
away3d get screen coords of 3d object
private function getStagePosition(cam:Camera3D, obj:ObjectContainer3D):Vector3D {
var camT:Matrix3D = cam.viewProjection.clone();
var planT:Matrix3D = obj.sceneTransform.clone();
planT.appendTranslation(0, obj.maxY, 0);
camT.prepend(planT);
var pv:Vector3D = Utils3D.projectVector(camT, new Vector3D());
pv.x = (pv.x * stage.stageWidth / 2) + stage.stageWidth / 2;
pv.y = (pv.y * -1 * stage.stageHeight / 2) + stage.stageHeight / 2;
return pv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment