A bounding sphere with a center and a radius.
| Name | Type | Default | Description |
|---|---|---|---|
center |
Cartesian3 |
Cartesian3.ZERO
|
optional The center of the bounding sphere. |
radius |
Number |
0.0
|
optional The radius of the bounding sphere. |
Members
-
The number of elements used to pack the object into an array.
-
center : Cartesian3
-
The center point of the sphere.
-
Default Value:
Cartesian3.ZERO -
The radius of the sphere.
-
Default Value:
0.0
Methods
-
staticCesium.BoundingSphere.clone(sphere, result) → BoundingSphere
-
Duplicates a BoundingSphere instance.
Name Type Description sphereBoundingSphere The bounding sphere to duplicate. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. (Returns undefined if sphere is undefined) -
staticCesium.BoundingSphere.computePlaneDistances(sphere, position, direction, result) → Interval
-
The distances calculated by the vector from the center of the bounding sphere to position projected onto direction plus/minus the radius of the bounding sphere.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding sphere.Name Type Description sphereBoundingSphere The bounding sphere to calculate the distance to. positionCartesian3 The position to calculate the distance from. directionCartesian3 The direction from position. resultInterval optional A Interval to store the nearest and farthest distances. Returns:
The nearest and farthest distances on the bounding sphere from position in direction. -
Computes the estimated distance squared from the closest point on a bounding sphere to a point.
Name Type Description sphereBoundingSphere The sphere. cartesianCartesian3 The point Returns:
The estimated distance squared from the bounding sphere to the point.Example:
// Sort bounding spheres from back to front spheres.sort(function(a, b) { return Cesium.BoundingSphere.distanceSquaredTo(b, camera.positionWC) - Cesium.BoundingSphere.distanceSquaredTo(a, camera.positionWC); }); -
Compares the provided BoundingSphere componentwise and returns
trueif they are equal,falseotherwise.Name Type Description leftBoundingSphere optional The first BoundingSphere. rightBoundingSphere optional The second BoundingSphere. Returns:
trueif left and right are equal,falseotherwise. -
staticCesium.BoundingSphere.expand(sphere, point, result) → BoundingSphere
-
Computes a bounding sphere by enlarging the provided sphere to contain the provided point.
Name Type Description sphereBoundingSphere A sphere to expand. pointCartesian3 A point to enclose in a bounding sphere. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromBoundingSpheres(boundingSpheres, result) → BoundingSphere
-
Computes a tight-fitting bounding sphere enclosing the provided array of bounding spheres.
Name Type Description boundingSpheresArray.<BoundingSphere> The array of bounding spheres. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromCornerPoints(corner, oppositeCorner, result) → BoundingSphere
-
Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere tighly and fully encompases the box.
Name Type Description cornerCartesian3 optional The minimum height over the rectangle. oppositeCornerCartesian3 optional The maximum height over the rectangle. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided.Example:
// Create a bounding sphere around the unit cube var sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5)); -
staticCesium.BoundingSphere.fromEllipsoid(ellipsoid, result) → BoundingSphere
-
Creates a bounding sphere encompassing an ellipsoid.
Name Type Description ellipsoidEllipsoid The ellipsoid around which to create a bounding sphere. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided.Example:
var boundingSphere = Cesium.BoundingSphere.fromEllipsoid(ellipsoid); -
staticCesium.BoundingSphere.fromEncodedCartesianVertices(positionsHigh, positionsLow, result) → BoundingSphere
-
Computes a tight-fitting bounding sphere enclosing a list of
EncodedCartesian3s, where the points are stored in parallel flat arrays in X, Y, Z, order. The bounding sphere is computed by running two algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.Name Type Description positionsHighArray.<Number> An array of high bits of the encoded cartesians that the bounding sphere will enclose. Each point is formed from three elements in the array in the order X, Y, Z. positionsLowArray.<Number> An array of low bits of the encoded cartesians that the bounding sphere will enclose. Each point is formed from three elements in the array in the order X, Y, Z. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if one was not provided. -
staticCesium.BoundingSphere.fromOrientedBoundingBox(orientedBoundingBox, result) → BoundingSphere
-
Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box.
Name Type Description orientedBoundingBoxOrientedBoundingBox The oriented bounding box. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromPoints(positions, result) → BoundingSphere
-
Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points. The bounding sphere is computed by running two algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
Name Type Description positionsArray.<Cartesian3> An array of points that the bounding sphere will enclose. Each point must have x,y, andzproperties.resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if one was not provided. -
staticCesium.BoundingSphere.fromRectangle2D(rectangle, projection, result) → BoundingSphere
-
Computes a bounding sphere from an rectangle projected in 2D.
Name Type Default Description rectangleRectangle The rectangle around which to create a bounding sphere. projectionObject GeographicProjectionoptional The projection used to project the rectangle into 2D. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromRectangle3D(rectangle, ellipsoid, surfaceHeight, result) → BoundingSphere
-
Computes a bounding sphere from an rectangle in 3D. The bounding sphere is created using a subsample of points on the ellipsoid and contained in the rectangle. It may not be accurate for all rectangles on all types of ellipsoids.
Name Type Default Description rectangleRectangle The valid rectangle used to create a bounding sphere. ellipsoidEllipsoid Ellipsoid.WGS84optional The ellipsoid used to determine positions of the rectangle. surfaceHeightNumber 0.0optional The height above the surface of the ellipsoid. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromRectangleWithHeights2D(rectangle, projection, minimumHeight, maximumHeight, result) → BoundingSphere
-
Computes a bounding sphere from an rectangle projected in 2D. The bounding sphere accounts for the object's minimum and maximum heights over the rectangle.
Name Type Default Description rectangleRectangle The rectangle around which to create a bounding sphere. projectionObject GeographicProjectionoptional The projection used to project the rectangle into 2D. minimumHeightNumber 0.0optional The minimum height over the rectangle. maximumHeightNumber 0.0optional The maximum height over the rectangle. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.fromVertices(positions, center, stride, result) → BoundingSphere
-
Computes a tight-fitting bounding sphere enclosing a list of 3D points, where the points are stored in a flat array in X, Y, Z, order. The bounding sphere is computed by running two algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
Name Type Default Description positionsArray.<Number> An array of points that the bounding sphere will enclose. Each point is formed from three elements in the array in the order X, Y, Z. centerCartesian3 Cartesian3.ZEROoptional The position to which the positions are relative, which need not be the origin of the coordinate system. This is useful when the positions are to be used for relative-to-center (RTC) rendering. strideNumber 3optional The number of array elements per vertex. It must be at least 3, but it may be higher. Regardless of the value of this parameter, the X coordinate of the first position is at array index 0, the Y coordinate is at array index 1, and the Z coordinate is at array index 2. When stride is 3, the X coordinate of the next position then begins at array index 3. If the stride is 5, however, two array elements are skipped and the next position begins at array index 5. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if one was not provided.Example:
// Compute the bounding sphere from 3 positions, each specified relative to a center. // In addition to the X, Y, and Z coordinates, the points array contains two additional // elements per point which are ignored for the purpose of computing the bounding sphere. var center = new Cesium.Cartesian3(1.0, 2.0, 3.0); var points = [1.0, 2.0, 3.0, 0.1, 0.2, 4.0, 5.0, 6.0, 0.1, 0.2, 7.0, 8.0, 9.0, 0.1, 0.2]; var sphere = Cesium.BoundingSphere.fromVertices(points, center, 5);See:
-
staticCesium.BoundingSphere.intersectPlane(sphere, plane) → Intersect
-
Determines which side of a plane a sphere is located.
Name Type Description sphereBoundingSphere The bounding sphere to test. planePlane The plane to test against. Returns:
Intersect.INSIDEif the entire sphere is on the side of the plane the normal is pointing,Intersect.OUTSIDEif the entire sphere is on the opposite side, andIntersect.INTERSECTINGif the sphere intersects the plane. -
Determines whether or not a sphere is hidden from view by the occluder.
Name Type Description sphereBoundingSphere The bounding sphere surrounding the occludee object. occluderOccluder The occluder. Returns:
trueif the sphere is not visible; otherwisefalse. -
Stores the provided instance into the provided array.
Name Type Default Description valueBoundingSphere The value to pack. arrayArray.<Number> The array to pack into. startingIndexNumber 0optional The index into the array at which to start packing the elements. Returns:
The array that was packed into -
staticCesium.BoundingSphere.projectTo2D(sphere, projection, result) → BoundingSphere
-
Creates a bounding sphere in 2D from a bounding sphere in 3D world coordinates.
Name Type Default Description sphereBoundingSphere The bounding sphere to transform to 2D. projectionObject GeographicProjectionoptional The projection to 2D. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.transform(sphere, transform, result) → BoundingSphere
-
Applies a 4x4 affine transformation matrix to a bounding sphere.
Name Type Description sphereBoundingSphere The bounding sphere to apply the transformation to. transformMatrix4 The transformation matrix to apply to the bounding sphere. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.transformWithoutScale(sphere, transform, result) → BoundingSphere
-
Applies a 4x4 affine transformation matrix to a bounding sphere where there is no scale The transformation matrix is not verified to have a uniform scale of 1. This method is faster than computing the general bounding sphere transform using
BoundingSphere.transform.Name Type Description sphereBoundingSphere The bounding sphere to apply the transformation to. transformMatrix4 The transformation matrix to apply to the bounding sphere. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided.Example:
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid); var boundingSphere = new Cesium.BoundingSphere(); var newBoundingSphere = Cesium.BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix); -
staticCesium.BoundingSphere.union(left, right, result) → BoundingSphere
-
Computes a bounding sphere that contains both the left and right bounding spheres.
Name Type Description leftBoundingSphere A sphere to enclose in a bounding sphere. rightBoundingSphere A sphere to enclose in a bounding sphere. resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
staticCesium.BoundingSphere.unpack(array, startingIndex, result) → BoundingSphere
-
Retrieves an instance from a packed array.
Name Type Default Description arrayArray.<Number> The packed array. startingIndexNumber 0optional The starting index of the element to be unpacked. resultBoundingSphere optional The object into which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if one was not provided. -
clone(result) → BoundingSphere
-
Duplicates this BoundingSphere instance.
Name Type Description resultBoundingSphere optional The object onto which to store the result. Returns:
The modified result parameter or a new BoundingSphere instance if none was provided. -
computePlaneDistances(position, direction, result) → Interval
-
The distances calculated by the vector from the center of the bounding sphere to position projected onto direction plus/minus the radius of the bounding sphere.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding sphere.Name Type Description positionCartesian3 The position to calculate the distance from. directionCartesian3 The direction from position. resultInterval optional A Interval to store the nearest and farthest distances. Returns:
The nearest and farthest distances on the bounding sphere from position in direction. -
Computes the estimated distance squared from the closest point on a bounding sphere to a point.
Name Type Description cartesianCartesian3 The point Returns:
The estimated distance squared from the bounding sphere to the point.Example:
// Sort bounding spheres from back to front spheres.sort(function(a, b) { return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC); }); -
Compares this BoundingSphere against the provided BoundingSphere componentwise and returns
trueif they are equal,falseotherwise.Name Type Description rightBoundingSphere optional The right hand side BoundingSphere. Returns:
trueif they are equal,falseotherwise. -
intersectPlane(plane) → Intersect
-
Determines which side of a plane the sphere is located.
Name Type Description planePlane The plane to test against. Returns:
Intersect.INSIDEif the entire sphere is on the side of the plane the normal is pointing,Intersect.OUTSIDEif the entire sphere is on the opposite side, andIntersect.INTERSECTINGif the sphere intersects the plane. -
Determines whether or not a sphere is hidden from view by the occluder.
Name Type Description occluderOccluder The occluder. Returns:
trueif the sphere is not visible; otherwisefalse.
