var pMouse:Number3D = 
_view.camera.unproject(_view.mouseX, _view.mouseY);
                        _dir.x = pMouse.x;
                        _dir.y = pMouse.y;
                        _dir.z = pMouse.z;
                        _dir.normalize();
                        
                        pMouse.add(pMouse, _view.camera.position);

should do it.

fabrice


On Dec 21, 2009, at 5:05 PM, Soeren Meyer-Eppler wrote:

> I'm having a difficult time getting my mouse interaction code to work
> properly. Using the latest subversion code for away3d FP10 and a very
> simple setup with a sphere of radius 100 at (0,0,0) and a hoverCamera
> pointing at the sphere from a distance of 500. I want to be able to
> accurately pick points on the mathematical/ideal sphere. I.e. I
> _don't_ want to use MouseEvent3D and it's x,y,z,u,v coordinates on a
> face but rather a result given in exact polar coordinates.
> 
> What I think I should do is unproject the mouse position and cast a
> ray through the eye position (camera) and the mouse into the scene.
> Find the intersection with the sphere and voila. My first try had it's
> coordinates way off. I've searched the mail archives and found that I
> should be using a perspective lens instead of the default which helped
> a lot. But I still don't hit the exact spot under the mouse cursor.
> Note that my problem is not ray/sphere intersection but creating the
> correct ray in the first place.
> 
> Can anyone point me in the right direction (cheap pun)?
> 
> best regards,
> 
>    Sören

Reply via email to