>From 3d space to screen coordinates you can use camera.screen(), which
returns a screen vertex for the position of a 3d object.

>From screen to 3d space its a bit more complicated since you can have
infinite solutions. Any ray that reaches the camera at your 2d coordinates
is a candidate line for you to place the 3d projection, practically
anywhere. However a good solution is to define a virtual (mathematical)
plane in space, always looking at the camera, and cast a ray from the
cameras perspective onto the plane and use this ray's intersection with the
plane as your produced 3d point. You can see this implemented in Rob's
Sierpisnki demo:
http://www.infiniteturtles.co.uk/blog/away3d-merry-christmas-2008

Near the start of the onEnterframe() he uses:

persp = camera.zoom/(1 + 1600/camera.focus);

            mouseVector.x = view.mouseX/persp;

            mouseVector.y = view.mouseY/persp;

            mouseVector.z = 1600;

where 1600 is how far the virtual plane is positioned from the camera.

Of course this latter topic is more subjective than the first, and you
could device many other ways to obtain a 3d coord from a screen coord.

Reply via email to