Last active
October 18, 2017 18:31
-
-
Save EvanBacon/3bd0eab626ab4ff1d7744d75fb519cf5 to your computer and use it in GitHub Desktop.
Three.js helper function for scaling the longest side of a mesh to a certain size. This is a debug method for AR development.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scaleLongestSideToSize = (mesh, size) => { | |
const { x: width, y: height, z: depth } = new THREE.Box3().setFromObject(mesh).getSize(); | |
const longest = Math.max(width, Math.max(height, depth)); | |
const scale = size / longest; | |
mesh.scale.set(scale, scale, scale); | |
} | |
export default scaleLongestSideToSize; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment