Hiya Issabln. I think it depends upon the center/pivot of the attachedMesh, but that is giving you problems, I see. Finding centers on CSG-result mesh… might be troublesome, without doing some type of boundingBox update, if needed. That’s the short answer.
Wow, that #3 playground is complex. I cleaned it a little… removed physics for now, turned-on the SliceMesh function, reduced size of slicerBox, removed extra ground, and a few other things.
https://playground.babylonjs.com/#2VPMSK#7
Other helpers…SliceMesh func is not used for subtracting/intersecting with woodgrain board, but instead, for repeated clicking (doubleclicking) upon the woodgrain board… stacking gray slicerBoxes atop one another, until they turn brown, as best I can tell. Issabln probably has many adjustments planned for SliceMesh function… but right now… I’m not real sure of its intended purpose.
The other MAIN issues… how to position gizmos, when to updateBoundingInfo and updateBoundingBoxes after CSG operations, etc… I’m just getting started, and I’m not very experienced. I can use all the helper help I can get.
A smaller playground would sure make it easier to test, so maybe issabln and other helpers… can keep shrinking this playground until we can “see” the issue a bit better.
I would THINK that the gizmoManager .attachedMesh is somehow important, here, but after CSG operations happen, bounding boxes might need updating. I disabled line 54 in the #7 playground… but that is THE point of interest, I think. Issabln wants that gizmo to move-around, and re-center at various locations… AS the mouse-driven CSG changes… happen (I suspect).
When I turned-on SliceMesh() by setting line 57 var sliceBool = true;
, the click-on-woodgrain to launch gizmo there… quit working… because a different “picker” gets activated on woodgrain board.
I wish I had more info, but not yet. I’ve never even THOUGHT ABOUT moving around a BJS gizmo… based-upon an ever-changing CSG shape’s “origin” (pivot point). Gruesome! It makes my brain hurt. heh.
I think I am a bad minecraft scene-maker.
In short, I think maybe Issabln wants to attach the gizmo to the CSG adder/subtractor mesh… so IT can be positioned, rotated, and scaled… and then it is CSG- added/subtracted to/from the master mesh… to create a type of CSG-based master-mesh-editor. Cool. A modeler.
At other times, like when NOT in edit mode… Issabln wants the gizmo to attach to the NEW master mesh… at its new “volume center”. So, that is why master mesh MIGHT need some kind of boundingBox/boundingInfo update/re-calc (after the CSG edit)… before we try to find the master mesh center… and put the gizmo there.
Or, I could be wrong… by a mile. Needs a function. refreshBoundingAreaAndPutGizmoAtNewCenter(anyCsgMeshResult, gizmo)