@math.gl/culling 3.5.7 → 3.6.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/constants.d.ts +6 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +8 -0
  4. package/dist/es5/constants.js +7 -5
  5. package/dist/es5/constants.js.map +1 -1
  6. package/dist/es5/index.js +0 -12
  7. package/dist/es5/index.js.map +1 -1
  8. package/dist/es5/lib/algorithms/bounding-box-from-points.js.map +1 -1
  9. package/dist/es5/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
  10. package/dist/es5/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
  11. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js +12 -6
  12. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
  13. package/dist/es5/lib/bounding-volumes/bounding-sphere.js +8 -4
  14. package/dist/es5/lib/bounding-volumes/bounding-sphere.js.map +1 -1
  15. package/dist/es5/lib/bounding-volumes/bounding-volume.js +2 -0
  16. package/dist/es5/lib/bounding-volumes/bounding-volume.js.map +1 -0
  17. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js +4 -0
  18. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
  19. package/dist/es5/lib/culling-volume.js +6 -20
  20. package/dist/es5/lib/culling-volume.js.map +1 -1
  21. package/dist/es5/lib/perspective-frustum.js +17 -7
  22. package/dist/es5/lib/perspective-frustum.js.map +1 -1
  23. package/dist/es5/lib/perspective-off-center-frustum.js +17 -5
  24. package/dist/es5/lib/perspective-off-center-frustum.js.map +1 -1
  25. package/dist/es5/lib/plane.js +5 -1
  26. package/dist/es5/lib/plane.js.map +1 -1
  27. package/dist/esm/constants.js +7 -5
  28. package/dist/esm/constants.js.map +1 -1
  29. package/dist/esm/index.js +0 -2
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/lib/algorithms/bounding-box-from-points.js.map +1 -1
  32. package/dist/esm/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
  33. package/dist/esm/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
  34. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js +15 -6
  35. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
  36. package/dist/esm/lib/bounding-volumes/bounding-sphere.js +9 -4
  37. package/dist/esm/lib/bounding-volumes/bounding-sphere.js.map +1 -1
  38. package/dist/esm/lib/bounding-volumes/bounding-volume.js +2 -0
  39. package/dist/esm/lib/bounding-volumes/bounding-volume.js.map +1 -0
  40. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js +5 -0
  41. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
  42. package/dist/esm/lib/culling-volume.js +10 -16
  43. package/dist/esm/lib/culling-volume.js.map +1 -1
  44. package/dist/esm/lib/perspective-frustum.js +31 -5
  45. package/dist/esm/lib/perspective-frustum.js.map +1 -1
  46. package/dist/esm/lib/perspective-off-center-frustum.js +31 -3
  47. package/dist/esm/lib/perspective-off-center-frustum.js.map +1 -1
  48. package/dist/esm/lib/plane.js +6 -1
  49. package/dist/esm/lib/plane.js.map +1 -1
  50. package/dist/index.d.ts +12 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +13 -0
  53. package/{src → dist}/lib/algorithms/bounding-box-from-points.d.ts +3 -10
  54. package/dist/lib/algorithms/bounding-box-from-points.d.ts.map +1 -0
  55. package/dist/lib/algorithms/bounding-box-from-points.js +131 -0
  56. package/dist/{esm/lib → lib}/algorithms/bounding-sphere-from-points.d.ts +2 -5
  57. package/dist/lib/algorithms/bounding-sphere-from-points.d.ts.map +1 -0
  58. package/dist/lib/algorithms/bounding-sphere-from-points.js +140 -0
  59. package/dist/{es5/lib → lib}/algorithms/compute-eigen-decomposition.d.ts +7 -9
  60. package/dist/lib/algorithms/compute-eigen-decomposition.d.ts.map +1 -0
  61. package/dist/lib/algorithms/compute-eigen-decomposition.js +131 -0
  62. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +56 -0
  63. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -0
  64. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.js +111 -0
  65. package/dist/lib/bounding-volumes/bounding-sphere.d.ts +40 -0
  66. package/dist/lib/bounding-volumes/bounding-sphere.d.ts.map +1 -0
  67. package/dist/lib/bounding-volumes/bounding-sphere.js +118 -0
  68. package/dist/lib/bounding-volumes/bounding-volume.d.ts +30 -0
  69. package/dist/lib/bounding-volumes/bounding-volume.d.ts.map +1 -0
  70. package/dist/lib/bounding-volumes/bounding-volume.js +1 -0
  71. package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts +67 -0
  72. package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -0
  73. package/dist/lib/bounding-volumes/oriented-bounding-box.js +256 -0
  74. package/dist/lib/culling-volume.d.ts +46 -0
  75. package/dist/lib/culling-volume.d.ts.map +1 -0
  76. package/dist/lib/culling-volume.js +121 -0
  77. package/dist/lib/perspective-frustum.d.ts +140 -0
  78. package/dist/lib/perspective-frustum.d.ts.map +1 -0
  79. package/dist/lib/perspective-frustum.js +205 -0
  80. package/dist/lib/perspective-off-center-frustum.d.ts +122 -0
  81. package/dist/lib/perspective-off-center-frustum.d.ts.map +1 -0
  82. package/dist/lib/perspective-off-center-frustum.js +305 -0
  83. package/dist/lib/plane.d.ts +26 -0
  84. package/dist/lib/plane.d.ts.map +1 -0
  85. package/dist/lib/plane.js +63 -0
  86. package/package.json +5 -5
  87. package/src/constants.ts +8 -0
  88. package/src/{index.js → index.ts} +0 -4
  89. package/src/lib/algorithms/{bounding-box-from-points.js → bounding-box-from-points.ts} +17 -4
  90. package/src/lib/algorithms/{bounding-sphere-from-points.js → bounding-sphere-from-points.ts} +15 -3
  91. package/src/lib/algorithms/{compute-eigen-decomposition.js → compute-eigen-decomposition.ts} +40 -1
  92. package/src/lib/bounding-volumes/{axis-aligned-bounding-box.js → axis-aligned-bounding-box.ts} +45 -14
  93. package/src/lib/bounding-volumes/{bounding-sphere.js → bounding-sphere.ts} +44 -29
  94. package/src/lib/bounding-volumes/{bounding-volume.d.ts → bounding-volume.ts} +7 -7
  95. package/src/lib/bounding-volumes/{oriented-bounding-box.js → oriented-bounding-box.ts} +72 -14
  96. package/src/lib/{culling-volume.js → culling-volume.ts} +42 -34
  97. package/src/lib/{perspective-frustum.js → perspective-frustum.ts} +48 -66
  98. package/src/lib/{perspective-off-center-frustum.js → perspective-off-center-frustum.ts} +24 -14
  99. package/src/lib/{plane.js → plane.ts} +24 -17
  100. package/dist/es5/constants.d.ts +0 -6
  101. package/dist/es5/index.d.ts +0 -20
  102. package/dist/es5/lib/algorithms/bounding-box-from-points.d.ts +0 -22
  103. package/dist/es5/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
  104. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  105. package/dist/es5/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  106. package/dist/es5/lib/bounding-volumes/bounding-volume.d.ts +0 -32
  107. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  108. package/dist/es5/lib/culling-volume.d.ts +0 -55
  109. package/dist/es5/lib/plane.d.ts +0 -38
  110. package/dist/esm/constants.d.ts +0 -6
  111. package/dist/esm/index.d.ts +0 -20
  112. package/dist/esm/lib/algorithms/bounding-box-from-points.d.ts +0 -22
  113. package/dist/esm/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
  114. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  115. package/dist/esm/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  116. package/dist/esm/lib/bounding-volumes/bounding-volume.d.ts +0 -32
  117. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  118. package/dist/esm/lib/culling-volume.d.ts +0 -55
  119. package/dist/esm/lib/plane.d.ts +0 -38
  120. package/src/constants.d.ts +0 -6
  121. package/src/constants.js +0 -8
  122. package/src/index.d.ts +0 -20
  123. package/src/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
  124. package/src/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
  125. package/src/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  126. package/src/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  127. package/src/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  128. package/src/lib/culling-volume.d.ts +0 -55
  129. package/src/lib/plane.d.ts +0 -38
@@ -1,83 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- import {BoundingVolume} from './bounding-volume';
5
- import {Vector3, Matrix3, Quaternion} from '@math.gl/core';
6
- import BoundingSphere from './bounding-sphere';
7
- import Plane from '../plane';
8
- import {INTERSECTION_ENUM} from '../../constants';
9
-
10
- /**
11
- * An OrientedBoundingBox of some object is a closed and convex cuboid.
12
- * It can provide a tighter bounding volume than `BoundingSphere` or
13
- * `AxisAlignedBoundingBox` in many cases.
14
- */
15
- export default class OrientedBoundingBox implements BoundingVolume {
16
- center: Vector3;
17
- halfAxes: Matrix3;
18
-
19
- /**
20
- * An OrientedBoundingBox of some object is a closed and convex cuboid.
21
- * It can provide a tighter bounding volume than
22
- * `BoundingSphere` or `AxisAlignedBoundingBox` in many cases.
23
- */
24
- constructor(center?: readonly number[], halfAxes?: readonly number[]);
25
-
26
- /** Returns an array with three halfSizes for the bounding box */
27
- get halfSize(): number[];
28
-
29
- /** Returns a quaternion describing the orientation of the bounding box */
30
- get quaternion(): Quaternion;
31
-
32
- /**
33
- * Create OrientedBoundingBox from quaternion based OBB,
34
- */
35
- fromCenterHalfSizeQuaternion(center: number[], halfSize: number[], quaternion: number[]): OrientedBoundingBox;
36
-
37
- /** Duplicates a OrientedBoundingBox instance. */
38
- clone(): OrientedBoundingBox;
39
-
40
- /** Compares the provided OrientedBoundingBox component wise and returns */
41
- equals(right: OrientedBoundingBox): boolean;
42
-
43
- /** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
44
- getBoundingSphere(result?: BoundingSphere): BoundingSphere;
45
-
46
- /**
47
- * The distances calculated by the vector from the center of the bounding box
48
- * to position projected onto direction.
49
- *
50
- * - If you imagine the infinite number of planes with normal direction,
51
- * this computes the smallest distance to the closest and farthest planes
52
- * from `position` that intersect the bounding box.
53
- *
54
- * @param position The position to calculate the distance from.
55
- * @param direction The direction from position.
56
- * @param result An Interval (array of length 2) to store the nearest and farthest distances.
57
- * @returns Interval (array of length 2) with nearest and farthest distances
58
- * on the bounding box from position in direction.
59
- */
60
- computePlaneDistances(position: readonly number[], direction: readonly number[], result?: number[]): number[];
61
-
62
- // BoundingVolume interface
63
-
64
- /**
65
- * Applies a 4x4 affine transformation matrix to a bounding sphere.
66
- * @param transform The transformation matrix to apply to the bounding sphere.
67
- * @returns itself, i.e. the modified BoundingVolume.
68
- */
69
- transform(transform: readonly number[]): this;
70
-
71
- /** Computes the estimated distance from the closest point on a bounding box to a point. */
72
- distanceTo(point: readonly number[]): number;
73
-
74
- /**
75
- * Computes the estimated distance squared from the closest point
76
- * on a bounding box to a point.
77
- * See Geometric Tools for Computer Graphics 10.4.2
78
- */
79
- distanceSquaredTo(point: readonly number[]): number;
80
-
81
- /** Determines which side of a plane the oriented bounding box is located. */
82
- intersectPlane(plane: Plane): INTERSECTION_ENUM;
83
- }
@@ -1,55 +0,0 @@
1
- import {INTERSECTION_ENUM} from '../constants';
2
- import BoundingSphere from './bounding-volumes/bounding-sphere';
3
- import Plane from './plane';
4
-
5
- // A culling volume defined by planes.
6
- export default class CullingVolume {
7
- /**
8
- * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value
9
- * represents the case where the object bounding volume is entirely outside the culling volume.
10
- */
11
- static readonly MASK_OUTSIDE: number;
12
-
13
- /**
14
- * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
15
- * represents the case where the object bounding volume is entirely inside the culling volume.
16
- */
17
-
18
- static readonly MASK_INSIDE: number;
19
-
20
- /**
21
- * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
22
- * represents the case where the object bounding volume (may) intersect all planes of the culling volume.
23
- * */
24
-
25
- static readonly MASK_INDETERMINATE: number;
26
-
27
- /** Array of clipping planes. */
28
- readonly planes: Plane[];
29
-
30
- /**
31
- * Create a new `CullingVolume` bounded by an array of clipping planed
32
- * @param planes Array of clipping planes.
33
- * */
34
-
35
- constructor(planes?: Plane[]);
36
-
37
- /**
38
- * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
39
- * The planes are aligned to the x, y, and z axes in world coordinates.
40
- */
41
- fromBoundingSphere(boundingSphere: BoundingSphere): CullingVolume;
42
-
43
- /** Determines whether a bounding volume intersects the culling volume. */
44
- computeVisibility(boundingVolume): INTERSECTION_ENUM;
45
-
46
- /**
47
- * Determines whether a bounding volume intersects the culling volume.
48
- *
49
- * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
50
- * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
51
- * the parent (and therefore this) volume is completely inside plane[planeIndex]
52
- * and that plane check can be skipped.
53
- */
54
- computeVisibilityWithPlaneMask(boundingVolume: object, parentPlaneMask: number): number;
55
- }
@@ -1,38 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- import {Vector3} from '@math.gl/core';
5
-
6
- /** A plane in Hessian Normal Form */
7
- export default class Plane {
8
- readonly normal: Vector3;
9
- readonly distance: number;
10
-
11
- constructor(normal?: readonly number[], distance?: number);
12
-
13
- fromNormalDistance(normal: readonly number[], distance: number);
14
-
15
- /** Creates a plane from a normal and a point on the plane. */
16
- fromPointNormal(point: readonly number[], normal: readonly number[]);
17
-
18
- /** Creates a plane from the general equation */
19
- fromCoefficients(a: number, b: number, c: number, d: number): Plane;
20
-
21
- /** Duplicates a Plane instance. */
22
- clone(): Plane;
23
-
24
- /** Compares the provided Planes by normal and distance */
25
- equals(right: Plane): Plane;
26
-
27
- /** Computes the signed shortest distance of a point to a plane.
28
- * The sign of the distance determines which side of the plane the point is on.
29
- */
30
- getPointDistance(point: readonly number[]): number;
31
-
32
- /** Transforms the plane by the given transformation matrix. */
33
- transform(matrix4: readonly number[]): Plane;
34
-
35
- /** Projects a point onto the plane. */
36
- projectPointOntoPlane(point: readonly number[], result: Vector3): Vector3;
37
- projectPointOntoPlane(point: readonly number[], result?: readonly number[]): readonly number[];
38
- }
@@ -1,6 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- export type INTERSECTION_ENUM = number;
5
-
6
- export const INTERSECTION: {[id: string]: number};
@@ -1,20 +0,0 @@
1
- export {default as BoundingVolume} from './lib/bounding-volumes/bounding-volume';
2
- export {default as BoundingSphere} from './lib/bounding-volumes/bounding-sphere';
3
- export {default as AxisAlignedBoundingBox} from './lib/bounding-volumes/axis-aligned-bounding-box';
4
- export {default as OrientedBoundingBox} from './lib/bounding-volumes/oriented-bounding-box';
5
-
6
- export {default as CullingVolume} from './lib/culling-volume';
7
- export {default as Plane} from './lib/plane';
8
-
9
- export {default as makeBoundingSphereFromPoints} from './lib/algorithms/bounding-sphere-from-points';
10
- export {
11
- makeAxisAlignedBoundingBoxFromPoints,
12
- makeOrientedBoundingBoxFromPoints
13
- } from './lib/algorithms/bounding-box-from-points';
14
- export {default as computeEigenDecomposition} from './lib/algorithms/compute-eigen-decomposition';
15
-
16
- // Experimental, decide how to handle enums in typescript
17
- export {INTERSECTION_ENUM, INTERSECTION} from './constants';
18
-
19
- export type _PerspectiveFrustum = object;
20
- export type _PerspectiveOffCenterFrustum = object;
@@ -1,22 +0,0 @@
1
- import OrientedBoundingBox from '../bounding-volumes/oriented-bounding-box';
2
- import AxisAlignedBoundingBox from '../bounding-volumes/axis-aligned-bounding-box';
3
-
4
- /**
5
- * Computes an instance of an OrientedBoundingBox of the given positions.
6
- *
7
- * This is an implementation of Stefan Gottschalk's Collision Queries using Oriented Bounding Boxes solution (PHD thesis).
8
- * Reference: http://gamma.cs.unc.edu/users/gottschalk/main.pdf
9
- */
10
- export function makeOrientedBoundingBoxFromPoints(
11
- positions: number[][],
12
- result?: OrientedBoundingBox
13
- ): OrientedBoundingBox;
14
-
15
- /**
16
- * Computes an instance of an AxisAlignedBoundingBox. The box is determined by
17
- * finding the points spaced the farthest apart on the x, y, and z axes.
18
- */
19
- export function makeAxisAlignedBoundingBoxFromPoints(
20
- positions: readonly number[][],
21
- result?: AxisAlignedBoundingBox
22
- ): AxisAlignedBoundingBox;
@@ -1,39 +0,0 @@
1
- import {Matrix3} from '@math.gl/core';
2
-
3
- /**
4
- * Computes the eigenvectors and eigenvalues of a symmetric matrix.
5
- *
6
- * - Returns a diagonal matrix and unitary matrix such that:
7
- * `matrix = unitary matrix * diagonal matrix * transpose(unitary matrix)`
8
- * - The values along the diagonal of the diagonal matrix are the eigenvalues. The columns
9
- * of the unitary matrix are the corresponding eigenvectors.
10
- * - This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
11
- * section 8.4.3 The Classical Jacobi Algorithm
12
- *
13
- * @param matrix The 3x3 matrix to decompose into diagonal and unitary matrix. Expected to be symmetric.
14
- * @param result Optional object with unitary and diagonal properties which are matrices onto which to store the result.
15
- * @returns An object with unitary and diagonal properties which are the unitary and diagonal matrices, respectively.
16
- *
17
- * @example
18
- * const a = //... symmetric matrix
19
- * const result = {
20
- * unitary : new Matrix3(),
21
- * diagonal : new Matrix3()
22
- * };
23
- * computeEigenDecomposition(a, result);
24
- *
25
- * const unitaryTranspose = Matrix3.transpose(result.unitary, new Matrix3());
26
- * const b = Matrix3.multiply(result.unitary, result.diagonal, new Matrix3());
27
- * Matrix3.multiply(b, unitaryTranspose, b); // b is now equal to a
28
- *
29
- * const lambda = result.diagonal.getColumn(0, new Vector3()).x; // first eigenvalue
30
- * const v = result.unitary.getColumn(0, new Vector3()); // first eigenvector
31
- * const c = v.multiplyByScalar(lambda); // equal to v.transformByMatrix3(a)
32
- */
33
- export default function computeEigenDecomposition(
34
- matrix: number[],
35
- result?: object
36
- ): {
37
- unitary: Matrix3;
38
- diagonal: Matrix3;
39
- };
@@ -1,51 +0,0 @@
1
- import {BoundingVolume} from './bounding-volume';
2
- import {Vector3} from '@math.gl/core';
3
- import Plane from '../plane';
4
- import {INTERSECTION_ENUM} from '../../constants';
5
-
6
- /**
7
- * An axis aligned bounding box - aligned with coordinate axes
8
- * @see BoundingVolume
9
- * @see BoundingRectangle
10
- * @see OrientedBoundingBox
11
- */
12
- export default class AxisAlignedBoundingBox implements BoundingVolume {
13
- /** The center point of the bounding box. */
14
- readonly center: Vector3;
15
- /** The positive half diagonal of the bounding box. */
16
- readonly halfDiagonal: Vector3;
17
- /** The minimum point defining the bounding box. [0, 0, 0] for empty box */
18
- readonly minimum: Vector3;
19
- /** The maximum point defining the bounding box. [0, 0, 0] for empty box */
20
- readonly maximum: Vector3;
21
-
22
- /**
23
- * Creates an instance of an AxisAlignedBoundingBox from the minimum and maximum points along the x, y, and z axes.
24
- * @param minimum=[0, 0, 0] The minimum point along the x, y, and z axes.
25
- * @param maximum=[0, 0, 0] The maximum point along the x, y, and z axes.
26
- * @param center The center of the box; automatically computed if not supplied.
27
- */
28
- constructor(minimum?: readonly number[], maximum?: readonly number[], center?: readonly number[]);
29
-
30
- /** Duplicates a AxisAlignedBoundingBox instance. */
31
- clone(): AxisAlignedBoundingBox;
32
- /** Compares the provided AxisAlignedBoundingBox component wise */
33
- equals(right: AxisAlignedBoundingBox): boolean;
34
-
35
- // BoundingVolume interface
36
-
37
- /**
38
- * Applies a 4x4 affine transformation matrix to a bounding sphere.
39
- * @param transform The transformation matrix to apply to the bounding sphere.
40
- * @returns itself, i.e. the modified BoundingVolume.
41
- */
42
- transform(transform: readonly number[]): this;
43
-
44
- /** Computes the estimated distance from the closest point on a bounding box to a point. */
45
- distanceTo(point: readonly number[]): number;
46
- /** Computes the estimated distance squared from the closest point on a bounding box to a point. */
47
- distanceSquaredTo(point: readonly number[]): number;
48
-
49
- /** Determines which side of a plane a box is located. */
50
- intersectPlane(plane: Plane): INTERSECTION_ENUM;
51
- }
@@ -1,52 +0,0 @@
1
- import {BoundingVolume} from './bounding-volume';
2
- import {Vector3} from '@math.gl/core';
3
- import {INTERSECTION_ENUM} from '../../constants';
4
- import Plane from '../plane';
5
-
6
- /** A BoundingSphere */
7
- export default class BoundingSphere implements BoundingVolume {
8
- center: Vector3;
9
- radius: number;
10
-
11
- /** Creates a bounding sphere */
12
- constructor(center?: readonly number[], radius?: number);
13
-
14
- /** Sets the bounding sphere from `center` and `radius`. */
15
- fromCenterRadius(center: readonly number[], radius: number): this;
16
-
17
- /**
18
- * Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere
19
- * tightly and fully encompasses the box.
20
- */
21
- fromCornerPoints(corner: readonly number[], oppositeCorner: readonly number[]): this;
22
-
23
- /** Compares the provided BoundingSphere component wise */
24
- equals(right: BoundingSphere): boolean;
25
-
26
- /** Duplicates a BoundingSphere instance. */
27
- clone(): this;
28
-
29
- /** Computes a bounding sphere that contains both the left and right bounding spheres. */
30
- union(boundingSphere: BoundingSphere): this;
31
-
32
- /** Computes a bounding sphere by enlarging the provided sphere to contain the provided point. */
33
- expand(point: readonly number[]): this;
34
-
35
- // BoundingVolume interface
36
-
37
- /**
38
- * Applies a 4x4 affine transformation matrix to a bounding sphere.
39
- * @param sphere The bounding sphere to apply the transformation to.
40
- * @param transform The transformation matrix to apply to the bounding sphere.
41
- * @returns self.
42
- */
43
- transform(transform: readonly number[]): this;
44
-
45
- /** Computes the estimated distance squared from the closest point on a bounding sphere to a point. */
46
- distanceSquaredTo(point: readonly number[]): number;
47
- /** Computes the estimated distance from the closest point on a bounding sphere to a point. */
48
- distanceTo(point: readonly number[]): number;
49
-
50
- /** Determines which side of a plane a sphere is located. */
51
- intersectPlane(plane: Plane): INTERSECTION_ENUM;
52
- }
@@ -1,32 +0,0 @@
1
- import {INTERSECTION_ENUM} from '../../constants';
2
- import Plane from '../plane';
3
-
4
- /**
5
- * Common interface for BoundingVolumes
6
- * including BoundingSphere, AxisAlignedBoundingBox and OrientedBoundingBox
7
- */
8
- export interface BoundingVolume {
9
- /**
10
- * Applies a 4x4 affine transformation matrix to a bounding sphere.
11
- * @param sphere The bounding sphere to apply the transformation to.
12
- * @param transform The transformation matrix to apply to the bounding sphere.
13
- * @returns itself, i.e. the modified BoundingVolume.
14
- */
15
- transform(transform: readonly number[]): this;
16
-
17
- /** Computes the estimated distance squared from the closest point on a bounding sphere to a point. */
18
- distanceSquaredTo(point: readonly number[]): number;
19
- /** Computes the estimated distance from the closest point on a bounding sphere to a point. */
20
- distanceTo(point: readonly number[]): number;
21
-
22
- /**
23
- * Determines which side of a plane the oriented bounding box is located.
24
- *
25
- * @param plane The plane to test against.
26
- * @returns
27
- * - `INTERSECTION.INSIDE` if the entire box is on the side of the plane the normal is pointing.
28
- * - `INTERSECTION.OUTSIDE` if the entire box is on the opposite side.
29
- * - `INTERSECTION.INTERSECTING` if the box intersects the plane.
30
- */
31
- intersectPlane(plane: Plane): INTERSECTION_ENUM;
32
- }
@@ -1,83 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- import {BoundingVolume} from './bounding-volume';
5
- import {Vector3, Matrix3, Quaternion} from '@math.gl/core';
6
- import BoundingSphere from './bounding-sphere';
7
- import Plane from '../plane';
8
- import {INTERSECTION_ENUM} from '../../constants';
9
-
10
- /**
11
- * An OrientedBoundingBox of some object is a closed and convex cuboid.
12
- * It can provide a tighter bounding volume than `BoundingSphere` or
13
- * `AxisAlignedBoundingBox` in many cases.
14
- */
15
- export default class OrientedBoundingBox implements BoundingVolume {
16
- center: Vector3;
17
- halfAxes: Matrix3;
18
-
19
- /**
20
- * An OrientedBoundingBox of some object is a closed and convex cuboid.
21
- * It can provide a tighter bounding volume than
22
- * `BoundingSphere` or `AxisAlignedBoundingBox` in many cases.
23
- */
24
- constructor(center?: readonly number[], halfAxes?: readonly number[]);
25
-
26
- /** Returns an array with three halfSizes for the bounding box */
27
- get halfSize(): number[];
28
-
29
- /** Returns a quaternion describing the orientation of the bounding box */
30
- get quaternion(): Quaternion;
31
-
32
- /**
33
- * Create OrientedBoundingBox from quaternion based OBB,
34
- */
35
- fromCenterHalfSizeQuaternion(center: number[], halfSize: number[], quaternion: number[]): OrientedBoundingBox;
36
-
37
- /** Duplicates a OrientedBoundingBox instance. */
38
- clone(): OrientedBoundingBox;
39
-
40
- /** Compares the provided OrientedBoundingBox component wise and returns */
41
- equals(right: OrientedBoundingBox): boolean;
42
-
43
- /** Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box. */
44
- getBoundingSphere(result?: BoundingSphere): BoundingSphere;
45
-
46
- /**
47
- * The distances calculated by the vector from the center of the bounding box
48
- * to position projected onto direction.
49
- *
50
- * - If you imagine the infinite number of planes with normal direction,
51
- * this computes the smallest distance to the closest and farthest planes
52
- * from `position` that intersect the bounding box.
53
- *
54
- * @param position The position to calculate the distance from.
55
- * @param direction The direction from position.
56
- * @param result An Interval (array of length 2) to store the nearest and farthest distances.
57
- * @returns Interval (array of length 2) with nearest and farthest distances
58
- * on the bounding box from position in direction.
59
- */
60
- computePlaneDistances(position: readonly number[], direction: readonly number[], result?: number[]): number[];
61
-
62
- // BoundingVolume interface
63
-
64
- /**
65
- * Applies a 4x4 affine transformation matrix to a bounding sphere.
66
- * @param transform The transformation matrix to apply to the bounding sphere.
67
- * @returns itself, i.e. the modified BoundingVolume.
68
- */
69
- transform(transform: readonly number[]): this;
70
-
71
- /** Computes the estimated distance from the closest point on a bounding box to a point. */
72
- distanceTo(point: readonly number[]): number;
73
-
74
- /**
75
- * Computes the estimated distance squared from the closest point
76
- * on a bounding box to a point.
77
- * See Geometric Tools for Computer Graphics 10.4.2
78
- */
79
- distanceSquaredTo(point: readonly number[]): number;
80
-
81
- /** Determines which side of a plane the oriented bounding box is located. */
82
- intersectPlane(plane: Plane): INTERSECTION_ENUM;
83
- }
@@ -1,55 +0,0 @@
1
- import {INTERSECTION_ENUM} from '../constants';
2
- import BoundingSphere from './bounding-volumes/bounding-sphere';
3
- import Plane from './plane';
4
-
5
- // A culling volume defined by planes.
6
- export default class CullingVolume {
7
- /**
8
- * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value
9
- * represents the case where the object bounding volume is entirely outside the culling volume.
10
- */
11
- static readonly MASK_OUTSIDE: number;
12
-
13
- /**
14
- * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
15
- * represents the case where the object bounding volume is entirely inside the culling volume.
16
- */
17
-
18
- static readonly MASK_INSIDE: number;
19
-
20
- /**
21
- * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value
22
- * represents the case where the object bounding volume (may) intersect all planes of the culling volume.
23
- * */
24
-
25
- static readonly MASK_INDETERMINATE: number;
26
-
27
- /** Array of clipping planes. */
28
- readonly planes: Plane[];
29
-
30
- /**
31
- * Create a new `CullingVolume` bounded by an array of clipping planed
32
- * @param planes Array of clipping planes.
33
- * */
34
-
35
- constructor(planes?: Plane[]);
36
-
37
- /**
38
- * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.
39
- * The planes are aligned to the x, y, and z axes in world coordinates.
40
- */
41
- fromBoundingSphere(boundingSphere: BoundingSphere): CullingVolume;
42
-
43
- /** Determines whether a bounding volume intersects the culling volume. */
44
- computeVisibility(boundingVolume): INTERSECTION_ENUM;
45
-
46
- /**
47
- * Determines whether a bounding volume intersects the culling volume.
48
- *
49
- * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling
50
- * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then
51
- * the parent (and therefore this) volume is completely inside plane[planeIndex]
52
- * and that plane check can be skipped.
53
- */
54
- computeVisibilityWithPlaneMask(boundingVolume: object, parentPlaneMask: number): number;
55
- }
@@ -1,38 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- import {Vector3} from '@math.gl/core';
5
-
6
- /** A plane in Hessian Normal Form */
7
- export default class Plane {
8
- readonly normal: Vector3;
9
- readonly distance: number;
10
-
11
- constructor(normal?: readonly number[], distance?: number);
12
-
13
- fromNormalDistance(normal: readonly number[], distance: number);
14
-
15
- /** Creates a plane from a normal and a point on the plane. */
16
- fromPointNormal(point: readonly number[], normal: readonly number[]);
17
-
18
- /** Creates a plane from the general equation */
19
- fromCoefficients(a: number, b: number, c: number, d: number): Plane;
20
-
21
- /** Duplicates a Plane instance. */
22
- clone(): Plane;
23
-
24
- /** Compares the provided Planes by normal and distance */
25
- equals(right: Plane): Plane;
26
-
27
- /** Computes the signed shortest distance of a point to a plane.
28
- * The sign of the distance determines which side of the plane the point is on.
29
- */
30
- getPointDistance(point: readonly number[]): number;
31
-
32
- /** Transforms the plane by the given transformation matrix. */
33
- transform(matrix4: readonly number[]): Plane;
34
-
35
- /** Projects a point onto the plane. */
36
- projectPointOntoPlane(point: readonly number[], result: Vector3): Vector3;
37
- projectPointOntoPlane(point: readonly number[], result?: readonly number[]): readonly number[];
38
- }
@@ -1,6 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- export type INTERSECTION_ENUM = number;
5
-
6
- export const INTERSECTION: {[id: string]: number};
package/src/constants.js DELETED
@@ -1,8 +0,0 @@
1
- // This file is derived from the Cesium math library under Apache 2 license
2
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
3
-
4
- export const INTERSECTION = Object.freeze({
5
- OUTSIDE: -1, // Represents that an object is not contained within the frustum.
6
- INTERSECTING: 0, // Represents that an object intersects one of the frustum's planes.
7
- INSIDE: 1 // Represents that an object is fully within the frustum.
8
- });
package/src/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export {default as BoundingVolume} from './lib/bounding-volumes/bounding-volume';
2
- export {default as BoundingSphere} from './lib/bounding-volumes/bounding-sphere';
3
- export {default as AxisAlignedBoundingBox} from './lib/bounding-volumes/axis-aligned-bounding-box';
4
- export {default as OrientedBoundingBox} from './lib/bounding-volumes/oriented-bounding-box';
5
-
6
- export {default as CullingVolume} from './lib/culling-volume';
7
- export {default as Plane} from './lib/plane';
8
-
9
- export {default as makeBoundingSphereFromPoints} from './lib/algorithms/bounding-sphere-from-points';
10
- export {
11
- makeAxisAlignedBoundingBoxFromPoints,
12
- makeOrientedBoundingBoxFromPoints
13
- } from './lib/algorithms/bounding-box-from-points';
14
- export {default as computeEigenDecomposition} from './lib/algorithms/compute-eigen-decomposition';
15
-
16
- // Experimental, decide how to handle enums in typescript
17
- export {INTERSECTION_ENUM, INTERSECTION} from './constants';
18
-
19
- export type _PerspectiveFrustum = object;
20
- export type _PerspectiveOffCenterFrustum = object;
@@ -1,17 +0,0 @@
1
- import BoundingSphere from '../bounding-volumes/bounding-sphere';
2
-
3
- /**
4
- * Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points.
5
- *
6
- * The bounding sphere is computed by running two algorithms, a naive algorithm and
7
- * Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.
8
- * Bounding sphere computation article http://blogs.agi.com/insight3d/index.php/2008/02/04/a-bounding
9
- *
10
- * @param positions An array of points that the bounding sphere will enclose.
11
- * @param result Optional object onto which to store the result.
12
- * @returns The modified result parameter or a new `BoundingSphere` instance if not provided.
13
- */
14
- export default function makeBoundingSphereFromPoints(
15
- positions: number[][],
16
- result?: BoundingSphere
17
- ): BoundingSphere;