How to get the width/height/length of a mesh in THREE.js

user3213315 picture user3213315 · May 25, 2014 · Viewed 26.2k times · Source

I been researching various places about trying to get the width and height of a mesh but I have been able to find anything that works. I have a collada model that I imported and all I want to do is get the dimension of it in Webgl/Three.js Units so that I can calculate collision in my simple game. So how would I go about getting the width and height of a mesh in THREE.js?

Answer

vincent picture vincent · May 26, 2014

If you're ok with a basic bounding box, you can use a THREE.Box3

var box = new THREE.Box3().setFromObject( colladaModel );
console.log( box.min, box.max, box.getSize() );