vue-babylonjs icon indicating copy to clipboard operation
vue-babylonjs copied to clipboard

Bounding Box

Open giuliobrugnaro opened this issue 5 years ago • 2 comments

Hello, I would like to load assets (.stl files) uploaded by users (so the origin of the file might not coincide with the centre of the mesh object): Is there a way to calculate the Bounding Box of a mesh (or more meshes ideally) and set its center as the target for the ArcRotate camera?

In BabylonJS I would use something like: mesh.getBoundinfo().boundingSphere.centerWorld

Thank you!

giuliobrugnaro avatar Jul 10 '19 08:07 giuliobrugnaro

Hi, sorry this is late, could you prepare a minimally reproducible example on Glitch or something similar? Here's a starter example on Glitch.

BrainBacon avatar Jul 17 '19 04:07 BrainBacon

Hi @BrainBacon, I was not able to get it working in Glitch but I have created a reproducible example and upload it here: https://github.com/gggggbbbbb/vue-babylon-test . In this example you can clearly see how the target ArcRotate camera does not correspond with the "center" of the displayed object (calculated from its bounding box) but rather with the global origin of the STL file loaded (which could be arbitrary).

giuliobrugnaro avatar Jul 26 '19 10:07 giuliobrugnaro