Drag3D and MouseEvent3D on ObjectContainer3D

Software: Away3D 4.x

Tayyab, Member
Posted: 04 April 2012 07:41 AM   Total Posts: 72

Hi there,

I have made a 3D shed. now i want to put in a window on one of the walls of the shed, and i want it to be able to be dragged around on that particular wall.

also how can make the window to only move on mousedown.
I have tried putting in the MouseEvent3D code but for some reason it does not work on objectContainer3D (my window is an objectContainer3D).

I have tried the same code on a mesh and works fine. but my window is a combination of linearExtrude and custom meshes.

and also in drag3d how can i limit the window movement, i mean not go beyond the walls of the shed. and to stick with the mouse cursor aswell.

I am attaching a screen grab of what i have.

Thanx,
Tayyab

 

   

Tayyab, Member
Posted: 04 April 2012 01:33 PM   Total Posts: 72   [ # 1 ]

Can somebody please reply, I am in real need of this solution to be solved!

   

Tayyab, Member
Posted: 05 April 2012 03:34 AM   Total Posts: 72   [ # 2 ]

can anyone please guide me to the right path to do this. I want the window to stick with mouse and stay inside the wall and when i release the mouse, fixes the window on that spot.

Tayyab.

   

Avatar
Fabrice Closier, Administrator
Posted: 05 April 2012 08:16 AM   Total Posts: 1265   [ # 3 ]

If you set the drag3d class to use the object planes, it will drag along the “window rotation planes instead of default world planes.  Drag3d.planeObject3d = mywindowconstruction;

The Drag3d required an update call, so if you want to limit the drag on mouseDown, simply add a boolean. onMouseDown dragWindow = true. onMouseUp dragWindow = false. On your enterFrame, if dragWindow, drag3dinstance.updateDrag();

   

Tayyab, Member
Posted: 06 April 2012 01:42 PM   Total Posts: 72   [ # 4 ]

thanx for the reply.. but how to get the onMouseDown to work on an objectContainer3D. it doesn’t seem to work.

   

Avatar
Fabrice Closier, Administrator
Posted: 06 April 2012 02:52 PM   Total Posts: 1265   [ # 5 ]

you can use any of the meshes inside.
or use regular mousedown. a container is just a “group”

   

Tayyab, Member
Posted: 06 April 2012 03:00 PM   Total Posts: 72   [ # 6 ]
_drag3D = new Drag3D(viewwindow);
   
_drag3D.plane Drag3D.PLANE_XY;
   
_drag3D.debug true;
   
_drag3D.offsetCenter true;
   
   
_drag3D.planeObject3d ObjectContainer3D(shedContainer);
   
window.addEventListener(MouseEvent3D.MOUSE_DOWNwindowMouseDown);
   
window.addEventListener(MouseEvent3D.MOUSE_UPwindowMouseUp);
   
addEventListener(Event.ENTER_FRAMEhandleEnterFrame1);
   function 
windowMouseUp(evt:MouseEvent3D):void
   {
    mouseDown 
false;
   
}
   
function windowMouseDown(evt:MouseEvent3D):void
   {
    mouseDown 
true;
   
}
   
function handleEnterFrame1(e:Event) : void
   {
    
//updating the dragged object on screen
    
if (mouseDown)
    
{
     move 
false;
     
_drag3D.updateDrag();
     
view.render();
    
}
   } 

this is my code for the movement of the window.

1. the red bit inside the window is ma mesh and the boundries are LinearExtrude. when i click on the red mesh the window does not drag on mouse down. but when i click on the blue boundry it works, i mean it starts dragging but its too slow.

2. also the onMouseDown and onMouseUp events are not firing properly, when i mouseDown on the blue boundry it starts draggin slowly and then untill i release the mouseDown on the blue boundry, it stays stuck with the mouse movement…

3. also when i change the camera panangle of the camera and then click on the window blue boundry, the window moves away from where the mouse is.

I am really confused. does anybody have any example of dragging an object and the object stays with the mouse.

Thanx,
Tayyab

   

Avatar
Fabrice Closier, Administrator
Posted: 06 April 2012 10:02 PM   Total Posts: 1265   [ # 7 ]

Look in the early builds example, or broomstick examples, I recall adding some drag3d demo class in there, code is similar if not exactly the same.

   

Tayyab, Member
Posted: 07 April 2012 02:13 PM   Total Posts: 72   [ # 8 ]

I have implemented the drag3d from the example you mentioned, but the drag is real slow, how can i make the object to stick with the mouse???

   

Tayyab, Member
Posted: 07 April 2012 04:52 PM   Total Posts: 72   [ # 9 ]

here is what i have done so far:
http://site.5thgarage.com.au/
it may take a bit of time to load, i have not got a preloader for it.

Here is the code:

_drag3D = new Drag3D(viewObjectContainer3D(window),Drag3D.PLANE_XY);
   
_drag3D.debug true;
   
_drag3D.offsetCenter true;
   
   
_drag3D.planeObject3d ObjectContainer3D(shedContainer);
   
window.addEventListener(MouseEvent3D.MOUSE_DOWNwindowMouseDown);
   
window.addEventListener(MouseEvent3D.MOUSE_UPwindowMouseUp);
   
stage.addEventListener(MouseEvent.MOUSE_UPstageMouseUp);
   
addEventListener(Event.ENTER_FRAMEhandleEnterFrame1);
   function 
stageMouseUp(evt:MouseEvent):void
   {
    mouseDown 
false;
    
ttrace("Stage Mouse Up");
   
}
   
function windowMouseUp(evt:MouseEvent3D):void
   {
    mouseDown 
false;
    
ttrace("Mouse Up");
   
}
   
function windowMouseDown(evt:MouseEvent3D):void
   {
    mouseDown 
true;
    
ttrace("Mouse Down");
   
}
   
function handleEnterFrame1(e:Event) : void
   {
    
//updating the dragged object on screen
    
if (mouseDown)
    
{
     move 
false;
     
_drag3D.updateDrag();
    
}
   } 

 

when you click and drag the window, you can move the window. but when you try to move the window again, it snaps to its old position and also the window moves around really slow :(

suggestions??

Thanx,
Tayyab

 

   

Avatar
Fabrice Closier, Administrator
Posted: 07 April 2012 08:02 PM   Total Posts: 1265   [ # 10 ]

It is not slow. You are probably not using the latest version of the engine.
After the new mouse picking was implemented the unproject method of the class lost the the camera translation values. If you update, you will have the expected result as the class regained what it was missing.

   

Tayyab, Member
Posted: 08 April 2012 08:42 AM   Total Posts: 72   [ # 11 ]

I have just downloaded the latest version of away3d 4.0 beta. and its the same as i had before ....:(

and please can you tell me why does it go back to its original place when i try to move it again???

   

Tayyab, Member
Posted: 08 April 2012 01:05 PM   Total Posts: 72   [ # 12 ]

oh Yess… its working fine now ... i downloaded the version from github… before i was downloading from away3d’d website ... thanx for your help smile

   

Tayyab, Member
Posted: 09 April 2012 10:21 AM   Total Posts: 72   [ # 13 ]

do you have any idea… how would you keep the window inside the shed?

I mean how can i force it to move inside the shed and not go outside.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X