Jump to content

Gizmo: onDragStartObservable and onDragEndObservable always returns the same values


Dad72
 Share

Recommended Posts

Hi @trevordev,

I found, I think, a bug to recover the change of position / rotation / scaling with the observable DragStart and DragEnd which retrieves the same position value for example.

If I start with DragStart, I should recover the position of an object at the start, that's OK, but when we move and release (DragEnd) the position of the object should have changed, but it is the same as with DragStart and yet the object was moved on the stage, but not in the recoverable value in the observable.

A PG is better than a long explanation: (move the X axis (red) and look at the values in the console. the x position is the same as dragStart and dradEnd)

https://www.babylonjs-playground.com/#4TBMBR#8

PS: Using e.dragPlanePoint.x it gets the X position of the gizmo pointer and not the pivot object select (maybe we could get the object selected)

I find it very repetitive to use an observable for each axis. This gives :

This would be shorter :

gizmoManager.gizmos.positionGizmo.Gizmo.dragBehavior.onDragStartObservable.add((e)=>{
   console.log(e);
});
gizmoManager.gizmos.positionGizmo.Gizmo.dragBehavior.onDragEndObservable.add((e)=>{
   console.log(e);
});

than that :

gizmoManager.gizmos.positionGizmo.xGizmo.dragBehavior.onDragStartObservable.add((e)=>{
   console.log(e);
});
gizmoManager.gizmos.positionGizmo.yGizmo.dragBehavior.onDragStartObservable.add((e)=>{
    console.log(e);
});
gizmoManager.gizmos.positionGizmo.zGizmo.dragBehavior.onDragStartObservable.add((e)=>{
    console.log(e);
});

gizmoManager.gizmos.positionGizmo.xGizmo.dragBehavior.onDragEndObservable.add((e)=>{
   console.log(e);
});
gizmoManager.gizmos.positionGizmo.yGizmo.dragBehavior.onDragEndObservable.add((e)=>{
    console.log(e);
});
gizmoManager.gizmos.positionGizmo.zGizmo.dragBehavior.onDragEndObservable.add((e)=>{
    console.log(e);
});

 

Link to comment
Share on other sites

The values in the playground that are pushed to the array are objects so position will be pointing to the same x,y,z values. You should clone the positions when you store them to get a copy. See https://www.babylonjs-playground.com/#4TBMBR#10

As for unifying the sub gizmo events to parents I created this PR (https://github.com/BabylonJS/Babylon.js/pull/5268) which adds dragstart/end to position/rotation/scale gizmos.

 

 

Link to comment
Share on other sites

Thank you Trevor.

And for the use of dragStar and end on the position, rotation / scale. What changes?

gizmoManager.gizmos.positionGizmo.zGizmo.dragBehavior.onDragEndObservable.add()

should we do like this?

gizmoManager.gizmos.positionGizmo.dragBehavior.onDragEndObservable.add()

Or

gizmoManager.gizmos.positionGizmo.onDragEndObservable.add()

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...