‘Simple’ Drag3D problem?

Software: Away3D 4.x

sentoplene, Newbie
Posted: 10 July 2013 01:39 PM   Total Posts: 25

I was trying to make a DraggableMeshContainer class, but I ran into some trouble. The meshes where disappearing when I started to drag with Drag3D.

So I broke it down to the simplest example possible, and it was still happening.

This is my example class:

public class Example002 extends Sprite
 {
  
//plane texture
  
[Embed(source="floor_diffuse.jpg")]
  
public static var FloorDiffuse:Class;
  
  
//engine variables
  
private var _view:View3D;
  
  
//scene objects
  
private var _sphere:Mesh;
  
  
// drag 
  
private var _drag :Drag3D;
  private var 
_isDragging :Boolean false;
  
  public function 
Example002()
  
{
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
//setup the view
   
_view = new View3D();
   
addChild(_view);
   
   
//setup the camera
   
_view.camera.= -600;
   
_view.camera.500;
   
_view.camera.lookAt(new Vector3D());
   
   
//setup the scene
   
_sphere = new Mesh(new SphereGeometry(100100), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)));
   
_sphere.mouseEnabled true;
   
_view.scene.addChild(_sphere);
   
   
_sphere.addEventListener(MouseEvent3D.MOUSE_DOWNstartDragging);
   
_sphere.addEventListener(MouseEvent3D.MOUSE_UPstopDragging);
   
   
//setup the render loop
   
addEventListener(Event.ENTER_FRAME_onEnterFrame);
   
stage.addEventListener(Event.RESIZEonResize);
   
onResize();
  
}

  
private function startDragging(event MouseEvent3D) : void
  {
   trace
('start');
   
_drag = new Drag3D(_view_sphereDrag3D.PLANE_ZY);
   
_isDragging true;
  
}

  
private function stopDragging(event MouseEvent3D) : void
  {
   trace
('stop');
   
_isDragging false;
  
}
  
  
private function _onEnterFrame(e:Event):void
  {
   
   
if (_isDragging)
   
{
    _drag
.updateDrag();
    
trace('_sphere.x: ' + (_sphere.x));
    
trace('_sphere.y: ' + (_sphere.y));
    
trace('_sphere.z: ' + (_sphere.z));
   
}
   
else
   
{
    _sphere
.rotationY += 1;
   
}
   
   _view
.render();
  
}
  
  
private function onResize(event:Event null):void
  {
   _view
.width stage.stageWidth;
   
_view.height stage.stageHeight;
  
}
 } 

What happens is that when _isDragging is set to true, after the _drag.updateDrag(), the coordinates of _sphere return NaN… I tried all the draggable planes… I am now a bit confused… it should be simple right?

I traced inside the Drag3D.updateDrag():

localIntersect _object3d.parent.inverseSceneTransform.transformVector(_intersect);
trace('localIntersect: ' + (localIntersect)); 

That traces like this: localIntersect: Vector3D(NaN, NaN, NaN)

Any ideas?
Am I using a wrong version? Last git update is last year for the Drag3D class.

   

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

Ok, my ‘problem’ is that it doesn’t work with the master branche of 4.0.11.

It does work with 4.1.1 BETA.

Just so you know.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X