javascriptthree.jsmeshcollada

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


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?


Solution

  • 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 );