-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(culling): Add BoundingVolume interface
- Loading branch information
Showing
29 changed files
with
290 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# BoundingVolume (Interface) | ||
|
||
An interface defining common operations for bounding volumes (i.e. `BoundingSphere`, `AxisAlignedBoundingBox`, `OrientedBoundingBox`). | ||
|
||
## Global Functions | ||
|
||
## Members | ||
|
||
### intersectPlane(plane : Plane) : INTERSECTION | ||
|
||
Determines which side of a plane a sphere is located. | ||
|
||
- `plane` The plane to test against. | ||
Returns | ||
- `INTERSECTION.INSIDE` if the entire sphere is on the side of the plane the normal is pointing | ||
- `INTERSECTION.OUTSIDE` if the entire sphere is on the opposite side | ||
- `INTERSECTION.INTERSECTING` if the sphere intersects the plane. | ||
|
||
### transform(transform : Number[16]) : BoundingSphere | ||
|
||
Applies a 4x4 affine transformation matrix to a bounding sphere. | ||
|
||
- `transform` The transformation matrix to apply to the bounding sphere. | ||
|
||
### distanceSquaredTo(point) : Number | ||
|
||
Computes the estimated distance squared from the closest point on a bounding sphere to a point. | ||
|
||
- `point` The point | ||
|
||
Returns | ||
|
||
- The estimated distance squared from the bounding sphere to the point. | ||
|
||
<!-- | ||
### transformWithoutScale(sphere, transform, result) | ||
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 {@link BoundingSphere.transform}. | ||
@param {BoundingSphere} sphere The bounding sphere to apply the transformation to. | ||
@param {Matrix4} transform The transformation matrix to apply to the bounding sphere. | ||
- `result` Optional object onto which to store the result. | ||
Returns | ||
- The modified `result` parameter or a new `BoundingSphere` instance if none was provided. | ||
@example | ||
var modelMatrix = Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid); | ||
var boundingSphere = new BoundingSphere(); | ||
var newBoundingSphere = BoundingSphere.transformWithoutScale(boundingSphere, modelMatrix); | ||
### computePlaneDistances (sphere, position, direction, result) | ||
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. | ||
@param {BoundingSphere} sphere The bounding sphere to calculate the distance to. | ||
@param {Cartesian3} position The position to calculate the distance from. | ||
@param {Cartesian3} direction The direction from position. | ||
@param {Interval} [result] A Interval to store the nearest and farthest distances. | ||
@returns {Interval} The nearest and farthest distances on the bounding sphere from position in direction. | ||
--> | ||
|
||
## Attribution | ||
|
||
This class was ported from [Cesium](https://github.com/AnalyticalGraphicsInc/cesium) under the Apache 2 License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../algorithms/bounding-box-from-points.d.ts → .../algorithms/bounding-box-from-points.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...gorithms/bounding-sphere-from-points.d.ts → ...gorithms/bounding-sphere-from-points.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
modules/culling/src/lib/bounding-volumes/axis-aligned-bounding-box.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {BoundingVolume} from './bounding-volume'; | ||
import {Vector3} from '@math.gl/core'; | ||
import Plane from '../plane'; | ||
import {INTERSECTION_ENUM} from '../../constants'; | ||
|
||
/** | ||
* An axis aligned bounding box - aligned with coordinate axes | ||
* @see BoundingVolume | ||
* @see BoundingRectangle | ||
* @see OrientedBoundingBox | ||
*/ | ||
export default class AxisAlignedBoundingBox implements BoundingVolume { | ||
/** The center point of the bounding box. */ | ||
readonly center: Vector3; | ||
/** The positive half diagonal of the bounding box. */ | ||
readonly halfDiagonal: Vector3; | ||
/** The minimum point defining the bounding box. [0, 0, 0] for empty box */ | ||
readonly minimum: Vector3; | ||
/** The maximum point defining the bounding box. [0, 0, 0] for empty box */ | ||
readonly maximum: Vector3; | ||
|
||
/** | ||
* Creates an instance of an AxisAlignedBoundingBox from the minimum and maximum points along the x, y, and z axes. | ||
* @param minimum=[0, 0, 0] The minimum point along the x, y, and z axes. | ||
* @param maximum=[0, 0, 0] The maximum point along the x, y, and z axes. | ||
* @param center The center of the box; automatically computed if not supplied. | ||
*/ | ||
constructor(minimum?: readonly number[], maximum?: readonly number[], center?: readonly number[]); | ||
|
||
/** Duplicates a AxisAlignedBoundingBox instance. */ | ||
clone(): AxisAlignedBoundingBox; | ||
/** Compares the provided AxisAlignedBoundingBox component wise */ | ||
equals(right: AxisAlignedBoundingBox): boolean; | ||
|
||
// BoundingVolume interface | ||
|
||
/** | ||
* Applies a 4x4 affine transformation matrix to a bounding sphere. | ||
* @param transform The transformation matrix to apply to the bounding sphere. | ||
* @returns itself, i.e. the modified BoundingVolume. | ||
*/ | ||
transform(transform: readonly number[]): this; | ||
|
||
/** Computes the estimated distance from the closest point on a bounding box to a point. */ | ||
distanceTo(point: readonly number[]): number; | ||
/** Computes the estimated distance squared from the closest point on a bounding box to a point. */ | ||
distanceSquaredTo(point: readonly number[]): number; | ||
|
||
/** Determines which side of a plane a box is located. */ | ||
intersectPlane(plane: Plane): INTERSECTION_ENUM; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.