looked very quickly at your code, since class caches few values to spare calcs, try call resize(); before you do setup the class. let me know how it goes, I will in case it doesn't fix your issue, try your class tomorrow.
also one detail, camera is standard of type Camera3D so view.camera.x, y, z is enough, no need to declare one. Fabrice On May 31, 2010, at 6:09 PM, abowman wrote: > Thanks for the class Fabrice. > > For some reason, when I move the mouse the sphere I'm dragging doesn't > stay under the mouse. > > http://abowman.nozonenet.com/away3d/dragTest.swf > http://abowman.nozonenet.com/away3d/DragTest.as > > What do I need to do to fix this? > > Thanks > > > On May 21, 4:49 am, Fabrice3D <[email protected]> wrote: >> 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 positionintersectback >> varintersect: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 demohttp://www.closier.nl/playground/drag/drag3d.swf >> >> cheers, >> >> Fabrice
