52

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?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
  • Please show what you attempted in order for others to be able to help. – Anonymous May 25 '14 at 20:12
  • Can someone tell me why I got -rep? I just want to know to not do it again on my future questions –  May 26 '14 at 00:18
  • You got negative reputation because someone down voted your question. A down vote is meant to mean "This question does not show any research effort; it is unclear or not useful." – Anonymous May 26 '14 at 00:19
  • Thank You! I appreciate that you answered :D Also I couldnt add the code before since I was doing this on a tablet, but vincent posted the perfect answer :D –  May 26 '14 at 00:35
  • 1
    You're welcome. You may want to still add the code because otherwise, your question is on its way to being closed. – Anonymous May 26 '14 at 00:55

1 Answers1

88

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

let measure = new THREE.Vector3();
let box = colladaModel.getSize(measure);
console.log( measure );
vincent
  • 1,525
  • 12
  • 18