computeBoundingBox method

void computeBoundingBox()

Implementation

void computeBoundingBox() {
  boundingBox ??= Box3(null, null);

  var position = attributes["position"];
  var morphAttributesPosition = morphAttributes["position"];

  if (position != null && position is GLBufferAttribute) {
    print(
        'three.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false". ${this}');

    double inf = 9999999999.0;

    boundingBox!.set(Vector3(-inf, -inf, -inf), Vector3(inf, inf, inf));

    return;
  }

  if (position != null) {
    boundingBox!.setFromBufferAttribute(position);

    // process morph attributes if present

    if (morphAttributesPosition != null) {
      for (var i = 0, il = morphAttributesPosition.length; i < il; i++) {
        var morphAttribute = morphAttributesPosition[i];
        _bufferGeometrybox.setFromBufferAttribute(morphAttribute);

        if (morphTargetsRelative) {
          _bufferGeometryvector.addVectors(boundingBox!.min, _bufferGeometrybox.min);
          boundingBox!.expandByPoint(_bufferGeometryvector);

          _bufferGeometryvector.addVectors(boundingBox!.max, _bufferGeometrybox.max);
          boundingBox!.expandByPoint(_bufferGeometryvector);
        } else {
          boundingBox!.expandByPoint(_bufferGeometrybox.min);
          boundingBox!.expandByPoint(_bufferGeometrybox.max);
        }
      }
    }
  } else {
    boundingBox!.makeEmpty();
  }

  // if (boundingBox!.min.x == null ||
  //     boundingBox!.min.y == null ||
  //     boundingBox!.min.z == null) {
  //   print(
  //       'three.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values. ${this}');
  // }
}