Hi all,
I get many requests about this and I keep sending code...

So I've added a new class dedicated to this particular functionality.
Drag3D.  in tools.utils package


you can use it to drag an object or just to get the intersection back.

here an example of implementation
                
                import away3d.tools.utils.Drag3D
                [... usual away code...]
                private var drag3d:Drag3D;

                 private function setUp():void
                {
                        //the object you want to drag
                        var _debugPrimitive:Sphere = new Sphere({radius:50, 
material:null});
                        this.scene.addChild(_debugPrimitive);
                        
                        //declare instance
                        drag3d = new Drag3D(this.view);
                        //which plane do you want to drag on
                        // note here that plane != Plane primitive!!
                        drag3d.plane = "xz";
                        // in case you want to check what you are doing
                        //drag3d.debug = true;
                        // to assign an object to be dragged
                        drag3d.object3d = _debugPrimitive;
                }
                

                private function myEnterFrame(event:Event = null):void
                {
                        //will update the object automatically on mouse moves
                        drag3d.updateDrag();  // its is of course handy to 
couple this with mouseEvents, like "if mouseisdown --> drag"

                        // in case you want only the position intersect back
                        var intersect:Number3D = drag3d.getIntersect();
                         
                        this.view.render();
                }

next to 0,0,0 default, there are also options for custom positions of plane, in 
case of AABB tests and even support for rotated planes
if you want object aligned calcs... 

here a little tech demo
http://www.closier.nl/playground/drag/drag3d.swf

cheers,


Fabrice

Reply via email to