getBoundingSphereAt method
dynamic
getBoundingSphereAt(
- dynamic id,
- dynamic target
Implementation
getBoundingSphereAt( id, target ) {
final active = _active;
if ( active[ id ] == false ) {
return null;
}
// compute bounding sphere
final bound = _bounds[ id ];
final sphere = bound.sphere;
final geometry = this.geometry;
if ( bound.sphereInitialized == false ) {
sphere.empty();
getBoundingBoxAt( id, _box );
_box.getCenter( sphere.center );
final index = geometry?.index;
final position = geometry?.attributes['position'];
final drawRange = _drawRanges[ id ];
double maxRadiusSq = 0;
for (int i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
int iv = i;
if ( index != null) {
iv = index.getX(iv)!.toInt();
}
_vector.fromBuffer( position, iv );
maxRadiusSq = math.max( maxRadiusSq, sphere.center.distanceToSquared( _vector ) );
}
sphere.radius = math.sqrt( maxRadiusSq );
bound.sphereInitialized = true;
}
target.copy( sphere );
return target;
}