models’ bounding-boxes are not being shown, even using importedRoot.showBoundingBox = true;
even when the initial position of both cubes is matching perfectly the grid lines (5cm resolution), after dragging (same increments of 5cm are used) the cubes are placed out of position;
lastPosition is not snapped onDragStart. This leads to a value not snapped that is not correct after.
With a snap position:
I would not use moveWithCollision for such use cases. It was meant for ellipsoid camera/character in a static world. For more dynamics and precise movements, I suggest to use Physics V2 instead : Babylon.js docs
First, thank you very much for the info you’re sharing and, of course, your time.
About using the Physics engine, instead of the internal collision system, for a proper implementation in my case of use, I was completely misleading the docs, thinking both V1 and V2 were obsolete features. Once you’ve put me on the right track, I’m going to study the Physics V2 right now. I’ll come here again with my progress and, maybe, additional questions.
At this point, please help me to clarify myself about some aspects of the “collision” thing within the BJS Engine that reading the Docs and searching throughout the Forum I’m not able to grasp yet.
So we have here (I think) two different approaches intended to be used in very distinct scenarios:
basic usage via (let’s call it) Internal Collision System;
some external Physics Engine to be connected with BJS by means of a specific plugin, as is the case with the currently recommended Havok Physics Engine.
Of course, the second option is going to be very much versatile when you need “heavy-duty” dynamics simulations. In my case, it seems to be a little an overkill (am I wrong?) as I don’t need gravity and other type of forces neither, only “box-alike” collisions between imported models.
Here, my initial plan was to replicate the way I had it working in the case of (primitive) meshes, adapting to the singularities of imported GLBs:
to use the root mesh node named (properly) “root” that, as you know, the BJS’s GLTF/GLB importer creates as the parent for each imported hierarchy, in order to use its bounding box (as I do in this PG) for implementing later the collisions (if BBs can be used for it);
going then with the collisions, to specify thatImportedGlbRootNode.checkCollisions = true; for activating collisions of the imported models between them and with the room walls;
to drag the whole group (thatRootNode + GLB nodes) over the room floor with a call to thatImportedGlbRootNode.moveWithCollisions;.
Of course, I must be seriously misunderstanding all the “bounding boxes” role (AABB box) and use, here. Any clue on it?
I’m not sure it’s overkill. It’s a bit more code to create and dispose aggregate + setup but performance is also better.
Bounding box are used as proxy for collision detection. Basically, use the bounding box instead of testing every triangle against other mesh triangles.
If you want to “adapt” the glb to be same as with primitives, here are some tips/tricks to try:
Load scene with scene.useRightHandedSystem = true; then set it as false after. This will prevent creation of root transform
Load glb then bake transforms. This will flatten hierarchy : Babylon.js docs