Seeking advice on determining the size of a Three.js object. I am currently loading various objects from files and wish to find a way to automatically adjust scale or camera position to ensure the entire object fits within the frame. Since different files will be loaded, detecting the size is crucial:
Here's a snippet of code for context:
var group;
var loader = new THREE.STLLoader();
var group = new THREE.Object3D();
loader.load("stl_file.stl", function (geometry) {
console.log(geometry);
var mat = new THREE.MeshLambertMaterial({color: 0x999999});
group = new THREE.Mesh(geometry, mat);
group.scale.set(0.02, 0.02, 0.02);
scene.add(group);
});
I'm looking for a solution within this code that could help determine the object's size before setting the scale. Alternatively, I can adjust the camera position in a subsequent part of the script. What are your thoughts?
Jay