How do I use Drag3D.getIntersect()?

Software: Away3D 4.x

jhocking, Newbie
Posted: 10 November 2011 09:51 PM   Total Posts: 12

I’m trying to use Drag3D in order to get 3D position at the mouse coordinates. I’ve seen this thread and that demo is exactly what I’m trying to do: http://www.mail-archive.com/away3d-dev@googlegroups.com/msg15129.html

From the API documentation, getIntersect() should be doing what I need, but I’m getting odd results. In my code I wrote:

movementPlane = new Drag3D(view, null, “xz”);

But this command:

movementPlane.getIntersect(mouseX, mouseY)

keeps returning (0, 0, 60) no matter where the mouse is located.

What am I doing wrong?

ADDITION: I just realized (0, 0, 60) is the position of the camera. When I changed it’s coordinates, sure enough now getIntersect() is returning those new coordinates.

So, why is getIntersect() returning the coordinates of the camera and not coordinates on the plane?

   

Avatar
Fabrice Closier, Administrator
Posted: 11 November 2011 10:05 AM   Total Posts: 1265   [ # 1 ]

What are the values of mouseX and mouseY that you pass?
Do you set object3d?

just runned a quick test

[... away cool init code…]
_drag3D = new Drag3D(_view, someSphere);
  _drag3D.plane = Drag3D.PLANE_ZY;
  _drag3D.debug = true;
  }
 
  public override function onCameraRender():void
  {
  //_drag3D.updateDrag();
  trace(_drag3D.getIntersect());
  }

all seems to work and returns me the intersect

   

jhocking, Newbie
Posted: 11 November 2011 01:20 PM   Total Posts: 12   [ # 2 ]

Thanks for your comment, because that verified for me that it does work and I just need to adjust something; I had given up on Drag3D after making my post.

After seeing your verification I went back and tried again, and this time I figured it out. My problem was that my camera was attached to a pivot and that was screwing things up. Presumably that means Drag3D is using the camera’s local coordinates; in the code for Drag3D you might want to use camera.scenePosition instead.

After making my post however I implemented my own ray intersection math to do what I need, and since this is slightly more flexible (eg. I can attach my camera to a pivot) I probably won’t use Drag3D after all.

   

Avatar
Fabrice Closier, Administrator
Posted: 11 November 2011 03:02 PM   Total Posts: 1265   [ # 3 ]

glad you figured it out. yes, there are loads of cases where you want something else. That’s simply out of the scope of what this class is ment to do.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X