I am uploading stl file to the scene using stlLoader and drawing bounding box using BoxHelper. Below is the screen shot while uploading the model ,
if you see , bounding box is touching the model in all the sides correctly.
I am rotating the model using transform controls , and updating the bounding box using BoxHelper.update(). If you see bounding box is bigger than the model . the box is not touching the corners of the model correctly. I guess while BoxHelper.update(), tranformation is applied to the box , so box is getting bigger. Is it correct ? is there any way I can get the correct bounding box which will touch the corners of the model correctly ?
I
Thanks for the reply. The example is using , model.rotation.set() function. I am using transformControls.js from threejs example directly. I tried setFromObject() function as mentioned in the example. Still it behaves same for me. Am I missing anything here ?
Yes. Most likely there is a bug in your code.
When I try TransformControls, the bounding box is recalculates as expected:
This is coming in quite late for you but in case it helps anyone else coming across this thread - make sure you setFromObject with the second argument set to true, ie.box.setFromObject(model, true) This ensures that the bounding box is the smallest it can be (as per the documentation page)
Oooh thanks! Didn’t know about that parameter… that’s a good one!