Hi all! I have a quick question for ya’ll. I’m attempting provide the capability to add a bounding box to an object when clicked by the user. I’ve managed to easily add one but noticed the bounding box is always orientated with respect to the object. This isn’t a bad thing but I’d like to also have the option to orientate it with respect to the world. In other words a cube’s bounding box will not rotate with the cube but rather just grow or shrink in place to accommodate the cube’s shape. I put together a quick PG here: https://playground.babylonjs.com/#4F33I3#456
Would also be a big bonus to learn how to do this with an imported mesh too. Thanks!
@sebavan so are you saying that I would need to create a new mesh with my current mesh’s bounding info and then place a bounding box around the new mesh? Should I child the new mesh to the original? Need to make sure it gets updated appropriately when my original mesh is transformed, i.e scaled, moved, etc
Yup, this is what I am proposing. You could parent it, if it is easier, but you would need to apply a rotation equal to the opposite one of the mesh hierarchy which might be tricky. It might be simpler to sync every frame with the mesh you target or in the onWorldMatrixUpdatedObservable to save some processing.
Awesome. Ya ended up just updating the boundingInfo of then separate bounding box mesh whenever the original mesh was updated, which ultimately did the trick.