Max gizmo size?

Hello everyone!
The problem I found starts on 11 second. When I want to scale the gizmo it starts to randomly jump in scaling and at the end of the video it becomes very big. Is there any way to set the maximum size of gizmo?

PLAYGROUND <–

edit:
I tried to use

// dynamically check size of mesh
mesh.onAfterWorldMatrixUpdateObservable.add(() => {

  // returns true if radius < 10 and false if radius > 10
  this.meshExpandingPrevention(mesh); 

});

but idk how to bite it so the gizmoManager.gizmos.boundingBoxGizmo.onScaleBoxDragEndObservable will stop scaling the mesh if it’s big enough

pinging @cedric our gizmo expert (He is out until next week so please bear with us ;))

2 Likes

Hi Symlis,

+1 to what Deltakosh said, Cedric should be able to give you a lot more context about this. Regarding just purely setting a max size, you can try adding a clamping behavior to the bounding box itself in order to prevent its size from exceeding certain parameters.

https://www.babylonjs-playground.com/#U8EJ66#4
(Lines 65 through 70.)

That may work as a stopgap, depending on the particular scenario you’re trying to handle. However, I’m not 100% sure this addresses the underlying issue of what you’re seeing, The artifact in your video (which I was able to reproduce in the Playground by dragging the gizmo past its far corner very fast) seems to be the result of some surprising behavior in the gizmo resize math, possibly involving a singularity on line 278 as the bounding box’s size tries to go to zero while drag distance is large. I’m not completely sure I’ve properly understood what that math is trying to do, though, so I could be wrong; Cedric will almost certainly know more about that and should be able to help more definitively when he gets back.

Hope this at least helps in the short term, though, and best of luck!

1 Like

@Deltakosh, @syntheticmagus, thank you for your answers!
That’s not a big deal, for now, I think nobody noticed this bug expect me! @syntheticmagus I’ve been testing your idea and I found something similar to the bug I found before. Differs in that scaling changes cylinder’s height now

Let me check if I can find a fix …

1 Like

The jittered scale happen because of Gimbal Lock in pointDragBehavior. Now the hard part trying to fix it :slight_smile:
Every time there is a call to lookat, there is a potential GimbalLock. It just needs to good condition to show its face :smiley:

I improved the plane management for pointerDragBehavior.

Thank you for your work!
I’ve tried a new version in my app and in the playground and it seems to be glitched still. That is very tricky bug! Here’s the video:

I guess I missed something. I’m taking a closer look.

I think I’ve found a simple fix. do not update drag axis plane to avoid jittering while dragging by CedricGuillemet · Pull Request #8597 · BabylonJS/Babylon.js · GitHub

1 Like

That’s it! Good job!

1 Like