Hello
I’m trying this code to set balls in the row next to each other:
for (let i = 0; i < objects.length; i++) {
const object = objects[i]
// getting size
const ballBoundingBox = new THREE.Box3().setFromObject(object)
const ballSize = ballBoundingBox.getSize(new THREE.Vector3())
const radius = ballSize.x
// setting new position
const x = rowWidth = rowWidth + radius
object.position.set(x, 0, 0)
}
And that works file when all balls are in the same size, but if I set random ball sizes:
object.scale.setScalar(Math.random() * 0.05 + 0.05)
Balls start to overlap each other, and gaps appear. I can’t figure out what’s the problem. Please help
Attaching screenshots:
And pen: