computeBoundingVolume method
Computes the internal bounding volumes of this mesh geometry.
Implementation
MeshGeometry computeBoundingVolume() {
final vertices = this.vertices;
final vertex = Vector3();
final aabb = this.aabb;
final boundingSphere = this.boundingSphere;
// compute AABB
aabb.min.set( double.infinity, double.infinity, double.infinity );
aabb.max.set( - double.infinity, - double.infinity, - double.infinity );
for ( int i = 0, l = vertices.length; i < l; i += 3 ) {
vertex.x = vertices[ i ];
vertex.y = vertices[ i + 1 ];
vertex.z = vertices[ i + 2 ];
aabb.expand( vertex );
}
// compute bounding sphere
aabb.getCenter( boundingSphere.center );
boundingSphere.radius = boundingSphere.center.distanceTo( aabb.max );
return this;
}