These are classes that I am using.

******************************************************************************

package {

        import away3d.cameras.*;
        import away3d.cameras.lenses.PerspectiveLens;
        import away3d.containers.*;
        import away3d.core.base.Object3D;
        import away3d.events.MouseEvent3D;
        import away3d.materials.*;
        import away3d.primitives.*;

        import flash.display.*;
        import flash.events.*;


        public class DragTest extends Sprite
        {
                protected var _camera : HoverCamera3D;
                protected var _view : View3D;
                protected var _drgClass:DraggingClassUsingDrag3D = new
DraggingClassUsingDrag3D;
                protected var cube:Cube = new Cube();


                public function DragTest()

                        {
                                super();
                                _createView();
                                _createScene();
                        }

                        protected function _createView() : void
                        {

                                _camera = new HoverCamera3D();

                                _camera.distance = 1000;
                                _camera.tiltAngle = 0;
                                _camera.panAngle = 180;
                                _view = new View3D();
                                _view.x = 300;
                                _view.y = 300;
                                _view.camera = _camera;
                                addChild(_view);
                                addEventListener(Event.ENTER_FRAME, 
_onEnterFrame);
                        }

                protected  function _createScene() : void
                        {


                                var mat : WireColorMaterial = new 
WireColorMaterial(0xcccccc);


                                cube.scaleX = 2;
                                cube.scaleY = 2;
                                cube.scaleZ = 2;
                                _view.scene.addChild(cube);
                                cube.x = 100;

                                _camera.lens = new PerspectiveLens()
                                _camera.zoom = 2;

                                
cube.addEventListener(MouseEvent3D.MOUSE_DOWN,onMouseDown);

                        }

                protected function      onMouseDown(event:MouseEvent3D):void
                {

                        _drgClass.MouseDown(event.target as Object3D);

                }

                protected function _onEnterFrame(ev : Event) : void
                {


                _camera.hover();
                _view.render();
                }
        }
}
**********************************************************************************************
package {

        import away3d.cameras.*;
        import away3d.cameras.lenses.PerspectiveLens;
        import away3d.containers.*;
        import away3d.core.base.Object3D;
        import away3d.events.MouseEvent3D;
        import away3d.materials.*;
        import away3d.primitives.*;
        import away3d.tools.utils.Drag3D;

        import flash.display.*;
        import flash.events.*;


        public class DraggingClassUsingDrag3D extends Sprite
        {
                protected var _camera : HoverCamera3D;
                protected var _view : View3D;
                protected var drag3d:Drag3D;
                protected var sphere : Sphere = new Sphere();
                protected var mouseDown:Boolean = false;

                public function DraggingClassUsingDrag3D()

                        {
                                super();
                                _createView();
                                _createScene();
                        }

                        protected function _createView() : void
                        {

                                _camera = new HoverCamera3D();

                                _camera.distance = 1000;
                                _camera.tiltAngle = 5;
                                _camera.panAngle = 175;
                                _view = new View3D();
                                _view.x = 300;
                                _view.y = 300;
                                _view.camera = _camera;
                                addChild(_view);
                                addEventListener(Event.ENTER_FRAME, 
_onEnterFrame);
                        }

                protected  function _createScene() : void
                        {

                                _camera.lens = new PerspectiveLens();
                                _camera.zoom = 2;
                                var mat : WireColorMaterial = new 
WireColorMaterial(0xcccccc);


                                sphere.radius = 5;
                                sphere.material = mat;
                                _view.scene.addChild(sphere);

                                _camera.lens = new PerspectiveLens()
                                _camera.zoom = 2;
                                _camera.distance = 1000;


                                sphere.segmentsW = 2;
                                sphere.segmentsH = 2;
                                sphere.x -= 200;
                                sphere.y += 200;


                                drag3d = new Drag3D(this._view);
                                drag3d.plane = "xy";
                                drag3d.debug = true;
                                drag3d.object3d = sphere;

                        }

                        public function MouseDown(object1:Object3D):void
                        {
                                trace("Inside MouseDown");
                                mouseDown = true;

                                
object1.addEventListener(MouseEvent3D.MOUSE_MOVE,MouseMove)

                        }


                        public function MouseMove(eve:MouseEvent3D):void
                        {
                                trace("Inside MouseMove");

                                var obj:Object3D = new Object3D();
                                obj = eve.currentTarget as Object3D;

                                if(mouseDown)
                                {


                                obj.x = sphere.x;
                                obj.y = sphere.y;
                                obj.z = sphere.z;

                                }
                                
obj.addEventListener(MouseEvent3D.MOUSE_UP,MouseUp)
                                
obj.addEventListener(MouseEvent3D.MOUSE_OUT,MouseOut)
                        }

                        public function MouseUp(event:MouseEvent3D):void
                        {
                                mouseDown = false;
                        }
                        public function MouseOut(event:MouseEvent3D):void
                        {
                                mouseDown = false;
                        }



                protected function _onEnterFrame(ev : Event) : void
                {
                //_camera.panAngle += (stage.mouseX - stage.stageWidth/2) / 100;
                drag3d.updateDrag();
                _camera.hover();
                _view.render();
                }
        }
}
*****************************************************************************************************************************
This is one approach I tried. When I did like this I could attain a
dragging. But the approach taken is not correct.I am not able to
maintain lock on the object. Here I passed the object to be dragged
from one class into the DraggingClassUsingDrag3D. Then I made the
object follow the sphere which inturn is following the mouse.
*****************************************************************************************************************************



On Sep 27, 2:34 pm, Bobby <[email protected]> wrote:
> Is there a function similar tostartDrag, stopDrag available in AS3
> available as part of Away3D engine.
>
> I have attained a reasonably good Dragging  function by hacking the
> Drag3D class. But I cant maintain the lock on the object. If I move
> the mouse very fast while dragging I lose hold of the object. Since
> this is a problem that people might have faced already I am confident
> someone must be having a solution already.

Reply via email to