How to set up the AABB bounding box of 3D model at the front end?

as the title, I load 3D models to the page through webGL, but the location, size, angle and so on of some models are not very suitable. I want to do a script for automatic normalization and standardization of 3D models at the front end. My current thinking is as follows:

  1. get the AABB bounding box of the 3D model, and calculate the distance d from the farthest point of the bounding box to the center of the 3D model.
  2. record the farthest point from the origin of the model in all directions of the bounding box P of the model.
  3. the scale of the AABB bounding box m of the newly added scene is compared with the distance of each direction of the P bounding box above, and then the original model is magnified x times based on the minimum multiple x = min {p1max m.x, p2max m.y, p3max z}.

question: how to use the front end to get the AABB bounding box of the model?

Mar.28,2021
Menu