Capítulo 365 de 859

Chapter 365: Sphere

Core Idea

An analytical 3D sphere defined by a center and radius. This class is mainly used as a Bounding Sphere for 3D objects.

Key Concepts

  • center : Vector3: The center of the sphere
  • isSphere : boolean (readonly): This flag can be used for type testing.
  • radius : number: The radius of the sphere.

Reference Tables

Constructor

Signature
new Sphere( center : Vector3, radius : number )

Properties

PropertyDescription
.center : Vector3The center of the sphere
.isSphere : boolean (readonly)This flag can be used for type testing.
.radius : numberThe radius of the sphere.

Methods

MethodDescription
.applyMatrix4( matrix : Matrix4 ) : SphereTransforms this sphere with the given 4x4 transformation matrix.
.clampPoint( point : Vector3, target : Vector3 ) : Vector3Clamps 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.
.clone() : SphereReturns a new sphere with copied values from this instance.
.containsPoint( point : Vector3 ) : booleanReturns true if this sphere contains the given point inclusive of the surface of the sphere.
.copy( sphere : Sphere ) : SphereCopies the values of the given sphere to this instance.
.distanceToPoint( point : Vector3 ) : numberReturns the closest distance from the boundary of the sphere to the given point. If the sphere contains the point, the distance will be negative.
.equals( sphere : Sphere ) : booleanReturns true if this sphere is equal with the given one.
.expandByPoint( point : Vector3 ) : SphereExpands the boundaries of this sphere to include the given point.
.fromJSON( json : Object ) : SphereReturns a serialized structure of the bounding sphere.
.getBoundingBox( target : Box3 ) : Box3Returns a bounding box that encloses this sphere.
.intersectsBox( box : Box3 ) : booleanReturns true if this sphere intersects with the given box.
.intersectsPlane( plane : Plane ) : booleanReturns true if this sphere intersects with the given plane.
.intersectsSphere( sphere : Sphere ) : booleanReturns true if this sphere intersects with the given one.
.isEmpty() : booleanReturns true if the sphere is empty (the radius set to a negative number).
.makeEmpty() : SphereMakes this sphere empty which means in encloses a zero space in 3D.
.set( center : Vector3, radius : number ) : SphereSets the sphere's components by copying the given values.
.setFromPoints( points : Array.<Vector3>, optionalCenter : Vector3 ) : SphereComputes the minimum bounding sphere for list of points. If the optional center point is given, it is used as the sphere's center. Otherwise, the center of the axis-aligned bounding box encompassing …
.toJSON() : ObjectReturns a serialized structure of the bounding sphere.
.translate( offset : Vector3 ) : SphereTranslates the sphere's center by the given offset.
.union( sphere : Sphere ) : SphereExpands this sphere to enclose both the original sphere and the given sphere.

Key Takeaways

  1. Most relevant properties: center, isSphere, radius.
  2. Key methods: applyMatrix4, clampPoint, clone, containsPoint.

Connects To