0

I have used the following to calculate the centroid of an imported model;

geometry.computeBoundingBox();
var centroid = new THREE.Vector3();
centroid.addVectors( geometry.boundingBox.min, geometry.boundingBox.max );
centroid.multiplyScalar( - 0.5 );
centroid.applyMatrix4( mesh.matrixWorld );

https://stackoverflow.com/a/25269787

It works well, but I think BoundingBox has been deprecated. Should I be using boxHelper? How do I find centroid of boxHelper?

ShaunaL
  • 31
  • 5

1 Answers1

3

1) BoundingBoxHelper was deprecated, not the boundingBox property.

2) Don't use BoxHelper to find the centroid. Just use the boundingBox property.

2.5) The boundingBox property is a Box3 object, which has a getCenter method, which gives you what you're calculating.

geometry.computeBoundingBox();
var centroid = geometry.boundingBox.getCenter();
centroid.applyMatrix4( mesh.matrixWorld );
TheJim01
  • 8,411
  • 1
  • 30
  • 54