Drag3D on local XY plane?

Software: Away3D 4.x

sentoplene, Newbie
Posted: 24 July 2013 02:07 PM   Total Posts: 25

Hi,

I want to drag/position a mesh inside a container, on a local XY plane for example, while the container is being turned/rotated. For example. I have a plane with some elements inside a PlaneContainer and I have eyes a motor for example also inside the PlaneContainer. I want to be able to reposition the motor, but on the same xy plane inside the PlaneContainer.

public function startDraggingInteraction() :void
{
 
if (!_drag)
 
{
  _drag 
= new Drag3D(_view_meshDrag3D.PLANE_XY);
  
_drag.debug true;
  
_drag.useRotations true;
  
_drag.planeObject3d _mesh;
 
}
 
else
 
{
  _drag
.planeObject3d _mesh;
 
}
 
 _drag
.planePosition _mesh.scenePosition.clone();
 
 
_isDragging true;
 
_view.addEventListener(Event.ENTER_FRAMEhandleEnterFrame);

in the Drag3D.updateNormalPlanes method it will calculated the normal of the obj… so world = false; But the plane on which I can drag the mesh seems to stay in the World coordinates.

Is it possible to have the the DraggingPlane setup locally?

Hopefully I made myself clear…

   

sentoplene, Newbie
Posted: 24 July 2013 02:41 PM   Total Posts: 25   [ # 1 ]

Ok, got it to work…

Had to rewrite the Drag3D class a bit.
If I set the planePosition property… the Drag3D class recalculates the vital normal, which was set correctly by setting the planeObject…

So I rewrote the following in the Drag3D class:

public function set planePosition(pos:Vector3D):void
{
// switch (_planeid) {
//  //XZ
//  case PLANE_XZ:
//   _np.x = 0;
//   _np.y = 1;
//   _np.z = 0;
//   break;
//  //XY
//  case PLANE_XY:
//   _np.x = 0;
//   _np.y = 0;
//   _np.z = 1;
//   break;
//  //ZY
//  case PLANE_ZY:
//   _np.x = 1;
//   _np.y = 0;
//   _np.z = 0;
//   break;
// }

 
_a = -pos.x;
 
_b = -pos.y;
 
_c = -pos.z;
 
 
_d = -(_a*_np._b*_np._c*_np.z);
 
 if (
_debug)
  
updateDebug();

Now it works like a charm…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X