A sphere defined by a center and radius.

Hierarchy

  • Base
    • Sphere

Constructors

  • Creates a new Sphere.

    Parameters

    • center: Vector3 = ...

      center of the sphere. Default is a Vector3 at (0, 0, 0).

    • radius: number = -1

      radius of the sphere. Default is -1.

    Returns Sphere

Properties

center: Vector3

A Vector3 defining the center of the sphere. Default is (0, 0, 0).

radius: number

The radius of the sphere. Default is -1.

Accessors

  • get isBox2(): boolean
  • Returns boolean

  • get isBox3(): boolean
  • Returns boolean

  • get isColor(): boolean
  • Returns boolean

  • get isCylindrical(): boolean
  • Returns boolean

  • get isEuler(): boolean
  • Returns boolean

  • get isLine3(): boolean
  • Returns boolean

  • get isMatrix3(): boolean
  • Returns boolean

  • get isMatrix4(): boolean
  • Returns boolean

  • get isPlane(): boolean
  • Returns boolean

  • get isQuaternion(): boolean
  • Returns boolean

  • get isRay(): boolean
  • Returns boolean

  • get isSphere(): boolean
  • Read-only flag to check if a given object is of type Sphere.

    Returns boolean

  • get isSpherical(): boolean
  • Returns boolean

  • get isTriangle(): boolean
  • Returns boolean

  • get isVector2(): boolean
  • Returns boolean

  • get isVector3(): boolean
  • Returns boolean

  • get isVector4(): boolean
  • Returns boolean

Methods

  • Transforms this sphere with the provided Matrix4.

    Returns

    This instance.

    Parameters

    • matrix: Matrix4

      the Matrix4 to apply

    Returns Sphere

  • Clamps a point within the sphere. If the point is outside the sphere, it will clamp it to the closest point on the edge of the sphere. Points already inside the sphere will not be affected.

    Returns

    The clamped point.

    Parameters

    • point: Vector3

      Vector3 The point to clamp.

    • target: Vector3 = ...

      The result will be copied into this Vector3.

    Returns Vector3

  • Create new sphere with the same center and radius as this one.

    Returns

    The new sphere.

    Returns Sphere

  • containsPoint(point: Vector3): boolean
  • Checks to see if the sphere contains the provided point inclusive of the surface of the sphere.

    Returns

    True if point is contained by this sphere.

    Parameters

    • point: Vector3

      The Vector3 to be checked

    Returns boolean

  • Copies the values of the passed sphere's center and radius properties to this sphere.

    Returns

    This instance.

    Parameters

    • sphere: Sphere

      The sphere to copy.

    Returns Sphere

  • distanceToPoint(point: Vector3): number
  • Computes the closest distance from the boundary of the sphere to a point. If the sphere contains the point, the distance will be negative.

    Returns

    The distance to the point.

    Parameters

    • point: Vector3

      The point to compute the distance to.

    Returns number

  • equals(sphere: Sphere): boolean
  • Checks to see if the two spheres' centers and radii are equal.

    Returns

    True if the 2 spheres are equal.

    Parameters

    • sphere: Sphere

      The sphere to compare for equality.

    Returns boolean

  • Expands the boundaries of this sphere to include point.

    Returns

    This instance.

    Parameters

    • point: Vector3

      Vector3 that should be included in the sphere.

    Returns Sphere

  • Copmute a minimum bounding box for the sphere.

    Returns

    The bounding box.

    Parameters

    • target: Box3 = ...

      — the result will be copied into this Box3.

    Returns Box3

  • intersectsBox(box: Box3): boolean
  • Determines whether or not this sphere intersects a given box.

    Returns

    True if the sphere and box intersect.

    Parameters

    • box: Box3

      Box3 to check for intersection against.

    Returns boolean

  • intersectsPlane(plane: Plane): boolean
  • Determines whether or not this sphere intersects a given plane.

    Returns

    True if this sphere and plane intersect.

    Parameters

    • plane: Plane

      Plane to check for intersection against.

    Returns boolean

  • intersectsSphere(sphere: Sphere): boolean
  • Checks to see if two spheres intersect.

    Returns

    True if the spheres intersect.

    Parameters

    • sphere: Sphere

      Sphere to check for intersection against.

    Returns boolean

  • isEmpty(): boolean
  • Checks to see if the sphere is empty (the radius set to a negative number). Spheres with a radius of 0 contain only their center point and are not considered to be empty.

    Returns

    True if empty.

    Returns boolean

  • Makes the sphere empty by setting center to (0, 0, 0) and radius to -1.

    Returns

    This instance.

    Returns Sphere

  • Sets the center and radius properties of this sphere. Please note that this method only copies the values from the given center.

    Returns

    This instance

    Parameters

    • center: Vector3

      Center of the sphere.

    • radius: number

      Radius of the sphere.

    Returns Sphere

  • Computes the minimum bounding sphere for an array of points. If optionalCenteris given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing points is calculated.

    Returns

    This instance.

    Parameters

    • points: Vector3[]

      an Array of Vector3 positions.

    • Optional optionalCenter: Vector3

      Optional Vector3 position for the sphere's center.

    Returns Sphere

  • Translate the sphere's center by the provided offset Vector3.

    Returns

    This instance.

    Parameters

    • offset: Vector3

      The x, y, z offsets

    Returns Sphere

  • Expands this sphere to enclose both the original sphere and the given sphere based on algorithm

    Returns

    This instance.

    Parameters

    • sphere: Sphere

      Bounding sphere that will be unioned with this sphere.

    Returns Sphere