computeBoundingSphere method
void
computeBoundingSphere()
override
Implementation
computeBoundingSphere() {
var vector = new Vector3();
if (this.boundingSphere == null) {
this.boundingSphere = new Sphere(null, null);
}
if (this.boundingBox == null) {
this.computeBoundingBox();
}
var start = this.attributes["instanceStart"];
var end = this.attributes["instanceEnd"];
if (start != null && end != null) {
var center = this.boundingSphere!.center;
this.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));
}
this.boundingSphere!.radius = Math.sqrt(maxRadiusSq);
if (this.boundingSphere!.radius == null) {
print(
'THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values. ${this}');
}
}
}