Issues with Drag3D

Software: Away3D 4.x

EMH, Newbie
Posted: 03 September 2011 05:02 AM   Total Posts: 2

I am working on a simple application using Broomstick to drag objects around a plane, so I am using Drag3D by adding a listener on each object and then setting that object to be the target of the Drag3D object when the mouse is pressed on it, and setting the target to be null when the mouse is released. This works very well in general, but I have noticed 2 odd effects:

1) When an object is clicked, and this is true for both the Cube and Loader3D loading a 3DS model that I’ve tried, and it becomes the drag target for the first time, it appears to jump up, as if it is moving higher on the plane that is perpendicular to the drag plane (up the Z-axis in this case, as I am dragging on the XY plane). I tried setting the z on the objects to zero hoping that maybe that would fix it, but the effect is the same.

2) Scaling an object amplifies both the “jumping up” effect described above, and it also seems to scale the drag effect by the amount the object was scaled, so moving small amounts causes the object to move dramatically.

In general though, it works great, so I’m hoping these problems have simple solutions. I can write and attach some sample code if that would help debug. Thanks!

   

John Brookes, Moderator
Posted: 03 September 2011 11:30 AM   Total Posts: 732   [ # 1 ]

Think theres an error in the drag3D class.

line 112 - 115

Change it to

if( _offsetCenter.x == 0 && _offsetCenter.y == 0 && _offsetCenter.z == 0 )
_offsetCenter.x = _offsetCenter.y = _offsetCenter.z = _eps;

   

Avatar
Fabrice Closier, Administrator
Posted: 03 September 2011 08:19 PM   Total Posts: 1265   [ # 2 ]

I’m finishing drag, rotation and other 3d interface things for Prefab atm. One of the option will be free drag, of course based on this class. I’ll look at this issue while busy with it.

In meanwhile make sure that “offsetCenter” boolean is set to true and that you use Perpective lens.

   

EMH, Newbie
Posted: 04 September 2011 02:01 AM   Total Posts: 2   [ # 3 ]

I’ll try all these suggestions and see what happens. I took a look at the Drag3D class figuring there was something small that needed to be fixed, but am a little too new to Away3D to be able to do much as of yet. I’m hoping that as I get familiar with the codebase, I’ll be able to make some contributions.  Thanks so much for your quick replies, and for putting together such a great engine!

   

EMH, Newbie
Posted: 04 September 2011 04:48 AM   Total Posts: 2   [ # 4 ]

Making the suggested change on lines 112-115, combined with enabling offsetCenter fixed the “jumping up” issue. However, the scaling problem remains. It appears the value reported for object3d.sceneposition on lines 109-111 is coming back multiplied by the scale, which affects the resulting offsetCenter value (since it is 10x the value it should be when it gets added to the object’s position). This causes the multiplying effect where a small change in mouse position has an amplified effect. It seems like somehow things have to be transformed back to undo the scaling before the object’s position is updated, or at the time it is retrieved initially, but I can’t see exactly how to do that.  This isn’t critical, and it sounds like this is something you are working on right now, just wanted to report my findings in case it sped up later debugging.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X