distanceTo method

  1. @override
double distanceTo(
  1. Vector3 point
)
override

Distance from point to the boundary surface in world units, 0 when point is inside.

Implementation

@override
double distanceTo(Vector3 point) {
  final dx = (point.x - center.x).abs() - halfExtents.x;
  final dy = (point.y - center.y).abs() - halfExtents.y;
  final dz = (point.z - center.z).abs() - halfExtents.z;
  final ox = dx > 0 ? dx : 0.0;
  final oy = dy > 0 ? dy : 0.0;
  final oz = dz > 0 ? dz : 0.0;
  return math.sqrt(ox * ox + oy * oy + oz * oz);
}