computeBoundingSphere method
void
computeBoundingSphere(
)
override
Implementation
@override
computeBoundingSphere() {
var vector = Vector3.init();
boundingSphere ??= Sphere(null, null);
if (boundingBox == null) {
computeBoundingBox();
}
var start = attributes["instanceStart"];
var end = attributes["instanceEnd"];
if (start != null && end != null) {
var center = boundingSphere!.center;
boundingBox!.getCenter(center);
num maxRadiusSq = 0;
for (var i = 0, il = start.count; i < il; i++) {
vector.fromBufferAttribute(start, i);
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
vector.fromBufferAttribute(end, i);
maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(vector));
}
boundingSphere!.radius = Math.sqrt(maxRadiusSq);
if (boundingSphere?.radius == null) {
print(
'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values. ${this}');
}
}
}