mouse position

Software: Away3D 3.x

robg, Newbie
Posted: 24 November 2011 11:43 AM   Total Posts: 2

i haven’t been entirely sure what to google or search for to help solve my problem, really hoping someone here can help a little…

currently my scene has a massive sphere with a texture mapped to it and the camera at the center of the sphere.

i’d like a way to click on the polygons within the sphere and update the texture at that position with something and dot etc..

the only part of the process where i need help is converting the 2d mouse position to a point on the inside of the sphere.

hope this makes sense…

   

robg, Newbie
Posted: 28 November 2011 03:00 PM   Total Posts: 2   [ # 1 ]

after a bit more reading it appears i need to work out how to cast a ray then work out the point of intersection with a sphere..

any ponters?

   

Avatar
Apprentice, Jr. Member
Posted: 28 November 2011 03:47 PM   Total Posts: 45   [ # 2 ]

As JohnBrookes pointed out here: http://away3d.com/forum/viewthread/1457/  -> check the Ray class in tools.utils, it also has a function called ‘intersectsSphere’, which might be what you need.

   

John Brookes, Moderator
Posted: 28 November 2011 05:14 PM   Total Posts: 732   [ # 3 ]

Think with this one (drawing on the bitmap) you might be better just using the mouseDetails.

not tried this on the inside of a sphere but works on the outside.
eg

bmMaterial = new BitmapMaterial(new imgAsset().bitmapData);
 
bmMaterial.lights lights;

 
 
earth = new Sphere(bmMaterial2503224);
 
scene.addChild(earth);
 
earth.mouseEnabled true;
 
earth.mouseDetails true;
 
 
earth.addEventListener(MouseEvent3D.MOUSE_DOWNearthMouseHandler);
}

private function earthMouseHandler(e:MouseEvent3D):void 
{
 
var c:Shape= new Shape();
 
c.graphics.clear();
 
c.graphics.beginFill(0xFFFFFF,0.5);
 
c.graphics.lineStyle(1.0);
 
c.graphics.drawEllipse(bmMaterial.bitmapData.width*e.uv.xbmMaterial.bitmapData.height*e.uv.y6,12);
 
c.graphics.endFill();
 
 var 
bd:BitmapData bmMaterial.bitmapData.clone();
 
bd.draw(c);
 
bmMaterial.bitmapData bd;

With the above there would be an issue where the image joins (where the two ends meet on the sphere) and drawing on both ends.
With a bit of thinking you can solve it wink

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X