Hi guys! Babylon.js Playground
That’s a little box-dragging demo using moveWithCollisions at line 173… as the mover.
Although we cannot see the invisible ellipsoids, try dragging a box in a way that makes it go corner-to-corner with another box. You can see that they DO overlap a tiny bit… due to round-shaped collision ellipsoids.
Also notice this does not use the fancy new “dragBehavior” (drag center sphere)… but instead, it uses older DOM event listeners, and a utility func called getGroundPosition at line 65.
getGroundPosition has one little flaw. The ground plane MUST be “behind” any click-on-box point, or the drag will fail. Example: Click on TOP of red box, where there is no ground behind the box. No drag. There MUST BE ground behind the click-point… to get the box to drag.
I suppose the BEST thing… would be to attempt a dragBehavior modification/option… that uses a .moveWithCollisions() for its mesh-mover. Let’s listen for more thoughts on that, and maybe some tests. Be prepared for slow weekend forum… though. It’s going to take some substantial hacking on the dragBehavior device… to make it use moveWithCollisions(), IF it can be done at all.
.moveWithColisions does not use a POSITION to move-to. I think it uses a direction and magnitude… making it plenty challenging to deal-with. onPointerMove runs very fast when moving mouse, and line 171 is always calculating a diff BY SUBTRACTING two positions, and THAT means diff is a direction with magnitude (an arrow, with magnitude = arrow length)
So, moveWithCollisions does VERY fast TINY moves in a direction… and NOT tiny steps to a preset/future position. To sum, I don’t know how well a “hacked” dragBehavior… will enjoy that. heh.
If we ONLY had an actionManager.intersectEnterTrigger([a list of mesh]) with a executeCodeAction that does { get me out of intersect state in the same direction you entered-it from }. Currently, actionManagers only intersect-test with ONE other mesh that you must specify when registering the trigger. There is no such trigger as onIntersectEnter(any scene mesh except ground).
And, there’s problems with the “reverse that last drag move” (reject the overlap)… involving mouse move-speed at time of impact, and how deep into overlapping… we ARE… at time of onIntersectEnter. Could be trouble. DragBehavior might need to “remember” its trail. To de-overlap, maybe it goes backwards down “memory lane”… until onIntersectExit triggers, and then hang-out there.
AND, we might be overlapping 10-20 mesh all at the same time! OMG. Gotta back-out until ALL of them… exit intersect with dragged mesh. erf.
Not only do we need to reject the dragged mesh from overlapping any mesh in the list, but we also have to stop the pointer from continued dragging, and send IT back to where it was located… just before the intersect happened (so pointer stays-with overlap-rejected dragged-mesh).
We just aren’t there, yet. We just don’t have an easy add-on for dragBehavior… that refuses to allow mesh overlap with ANY mesh in a list of mesh. (Though I need to study dragBehavior more… learn its capabilities.)
In many scenes, the list could be ALL mesh except ground… which could mean LOTS of intersect testing on MANY scene mesh. That’s a BJS dragBehavior performance killer, and DOM onPointerMove perf killer, too. hmm.
Not very good news, eh Constantinos? Sorry. I dunno if webWorkers or SIMD (reduced instruction set/risc) would help us with those intense scene-wide collision/overlap testings… I doubt it. (Wingy scratches his beard in pondering.) Stay tuned for more/better comments.