问题
In my project i am loading different kinds of model dynamically. How to scale the loaded object so that it fits completely inside a certain bounding box?
To clarify the situation, i do not want the loaded object to fit in my FOV. I already have a house loaded in my scene. I want the new loaded object to fit inside my house.
回答1:
Since you do have the bounding box of the house (call it boxH) and the bounding box of the object (call it boxO), take the ratios of the bounding box sizes
var sizeH = boxH.getSize(); // get the size of the bounding box of the house
var sizeO = boxO.getSize(); // get the size of the bounding box of the obj
var ratio = sizeH.divide( sizeO ); // get the ratio of the sizes
Now scale()
your object by the inverse maximum value in the ratio
variable.
来源:https://stackoverflow.com/questions/47868151/scale-object-to-fit-inside-certain-bounding-box-three-js