I need to center the geometry of each mesh of grouped (n-levels) models, coming from glTF files (I want to implement automatic scene explosion).
But of course I have to maintain nodes world positions.
I tried:
scene.traverse((node) => {
if (node.type==="Mesh") {
let center = new THREE.Vector3();
node.geometry.computeBoundingBox();
node.geometry.boundingBox.getCenter(center);
node.geometry.center();
node.position.add(center);
}
}
but it doesn’t seems to work (nodes are misplaced).
Any suggestion is welcome.