Skip to content

Instantly share code, notes, and snippets.

@jlewin
Last active December 23, 2015 10:19
Show Gist options
  • Select an option

  • Save jlewin/6620401 to your computer and use it in GitHub Desktop.

Select an option

Save jlewin/6620401 to your computer and use it in GitHub Desktop.
Get bounding box for STL
<script src="../build/three.min.js"></script>
<script src="js/loaders/STLLoader.js"></script>
<script>
var loader = new THREE.STLLoader();
loader.addEventListener('load', function (event) {
var geometry = event.content;
if (geometry.boundingBox === null) {
geometry.computeBoundingBox();
}
// Dumps something like the following to the console: {x: -0.4995945, y: -0.5, z: -0.18 }
console.log(geometry.boundingBox.min);
console.log(geometry.boundingBox.max);
});
loader.load('models/stl/ascii/slotted_disk.stl');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment