Get size of Object3D in Three.js

You could possibly create bounding box from your object:

var bbox = new THREE.Box3().setFromObject(icon);

If you have bounding box you can get it's min and max.

Max.z - Min.z -> height

Max.x - Min.x -> width

Max.y - Min.y -> depth


THREE.Sprite() has a geometry property so you can do:

if( iconSprite.geometry.boundingBox === undefined )
    iconSprite.geometry.computeBoundingBox ();

and you can get all the info you need from the .boundingBox property from its own properties .boundingBox.min and .boundingBox.max.


const boundingBox = new THREE.Box3().setFromObject(object)

const xSize = boundingBox.max.x - boundingBox.min.x
const ySize = boundingBox.max.y - boundingBox.min.y
const zSize = boundingBox.max.z - boundingBox.min.z

const maxSize = Math.max(xSize, ySize, zSize)