@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.
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/es5/constants.js +7 -5
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/index.js +0 -12
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/algorithms/bounding-box-from-points.js.map +1 -1
- package/dist/es5/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
- package/dist/es5/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
- package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js +12 -6
- package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
- package/dist/es5/lib/bounding-volumes/bounding-sphere.js +8 -4
- package/dist/es5/lib/bounding-volumes/bounding-sphere.js.map +1 -1
- package/dist/es5/lib/bounding-volumes/bounding-volume.js +2 -0
- package/dist/es5/lib/bounding-volumes/bounding-volume.js.map +1 -0
- package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js +4 -0
- package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
- package/dist/es5/lib/culling-volume.js +6 -20
- package/dist/es5/lib/culling-volume.js.map +1 -1
- package/dist/es5/lib/perspective-frustum.js +17 -7
- package/dist/es5/lib/perspective-frustum.js.map +1 -1
- package/dist/es5/lib/perspective-off-center-frustum.js +17 -5
- package/dist/es5/lib/perspective-off-center-frustum.js.map +1 -1
- package/dist/es5/lib/plane.js +5 -1
- package/dist/es5/lib/plane.js.map +1 -1
- package/dist/esm/constants.js +7 -5
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/algorithms/bounding-box-from-points.js.map +1 -1
- package/dist/esm/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
- package/dist/esm/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
- package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js +15 -6
- package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
- package/dist/esm/lib/bounding-volumes/bounding-sphere.js +9 -4
- package/dist/esm/lib/bounding-volumes/bounding-sphere.js.map +1 -1
- package/dist/esm/lib/bounding-volumes/bounding-volume.js +2 -0
- package/dist/esm/lib/bounding-volumes/bounding-volume.js.map +1 -0
- package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js +5 -0
- package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
- package/dist/esm/lib/culling-volume.js +10 -16
- package/dist/esm/lib/culling-volume.js.map +1 -1
- package/dist/esm/lib/perspective-frustum.js +31 -5
- package/dist/esm/lib/perspective-frustum.js.map +1 -1
- package/dist/esm/lib/perspective-off-center-frustum.js +31 -3
- package/dist/esm/lib/perspective-off-center-frustum.js.map +1 -1
- package/dist/esm/lib/plane.js +6 -1
- package/dist/esm/lib/plane.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/{src → dist}/lib/algorithms/bounding-box-from-points.d.ts +3 -10
- package/dist/lib/algorithms/bounding-box-from-points.d.ts.map +1 -0
- package/dist/lib/algorithms/bounding-box-from-points.js +131 -0
- package/dist/{esm/lib → lib}/algorithms/bounding-sphere-from-points.d.ts +2 -5
- package/dist/lib/algorithms/bounding-sphere-from-points.d.ts.map +1 -0
- package/dist/lib/algorithms/bounding-sphere-from-points.js +140 -0
- package/dist/{es5/lib → lib}/algorithms/compute-eigen-decomposition.d.ts +7 -9
- package/dist/lib/algorithms/compute-eigen-decomposition.d.ts.map +1 -0
- package/dist/lib/algorithms/compute-eigen-decomposition.js +131 -0
- package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +56 -0
- package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -0
- package/dist/lib/bounding-volumes/axis-aligned-bounding-box.js +111 -0
- package/dist/lib/bounding-volumes/bounding-sphere.d.ts +40 -0
- package/dist/lib/bounding-volumes/bounding-sphere.d.ts.map +1 -0
- package/dist/lib/bounding-volumes/bounding-sphere.js +118 -0
- package/dist/lib/bounding-volumes/bounding-volume.d.ts +30 -0
- package/dist/lib/bounding-volumes/bounding-volume.d.ts.map +1 -0
- package/dist/lib/bounding-volumes/bounding-volume.js +1 -0
- package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts +67 -0
- package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -0
- package/dist/lib/bounding-volumes/oriented-bounding-box.js +256 -0
- package/dist/lib/culling-volume.d.ts +46 -0
- package/dist/lib/culling-volume.d.ts.map +1 -0
- package/dist/lib/culling-volume.js +121 -0
- package/dist/lib/perspective-frustum.d.ts +140 -0
- package/dist/lib/perspective-frustum.d.ts.map +1 -0
- package/dist/lib/perspective-frustum.js +205 -0
- package/dist/lib/perspective-off-center-frustum.d.ts +122 -0
- package/dist/lib/perspective-off-center-frustum.d.ts.map +1 -0
- package/dist/lib/perspective-off-center-frustum.js +305 -0
- package/dist/lib/plane.d.ts +26 -0
- package/dist/lib/plane.d.ts.map +1 -0
- package/dist/lib/plane.js +63 -0
- package/package.json +5 -5
- package/src/constants.ts +8 -0
- package/src/{index.js → index.ts} +0 -4
- package/src/lib/algorithms/{bounding-box-from-points.js → bounding-box-from-points.ts} +17 -4
- package/src/lib/algorithms/{bounding-sphere-from-points.js → bounding-sphere-from-points.ts} +15 -3
- package/src/lib/algorithms/{compute-eigen-decomposition.js → compute-eigen-decomposition.ts} +40 -1
- package/src/lib/bounding-volumes/{axis-aligned-bounding-box.js → axis-aligned-bounding-box.ts} +45 -14
- package/src/lib/bounding-volumes/{bounding-sphere.js → bounding-sphere.ts} +44 -29
- package/src/lib/bounding-volumes/{bounding-volume.d.ts → bounding-volume.ts} +7 -7
- package/src/lib/bounding-volumes/{oriented-bounding-box.js → oriented-bounding-box.ts} +72 -14
- package/src/lib/{culling-volume.js → culling-volume.ts} +42 -34
- package/src/lib/{perspective-frustum.js → perspective-frustum.ts} +48 -66
- package/src/lib/{perspective-off-center-frustum.js → perspective-off-center-frustum.ts} +24 -14
- package/src/lib/{plane.js → plane.ts} +24 -17
- package/dist/es5/constants.d.ts +0 -6
- package/dist/es5/index.d.ts +0 -20
- package/dist/es5/lib/algorithms/bounding-box-from-points.d.ts +0 -22
- package/dist/es5/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
- package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
- package/dist/es5/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
- package/dist/es5/lib/bounding-volumes/bounding-volume.d.ts +0 -32
- package/dist/es5/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
- package/dist/es5/lib/culling-volume.d.ts +0 -55
- package/dist/es5/lib/plane.d.ts +0 -38
- package/dist/esm/constants.d.ts +0 -6
- package/dist/esm/index.d.ts +0 -20
- package/dist/esm/lib/algorithms/bounding-box-from-points.d.ts +0 -22
- package/dist/esm/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
- package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
- package/dist/esm/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
- package/dist/esm/lib/bounding-volumes/bounding-volume.d.ts +0 -32
- package/dist/esm/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
- package/dist/esm/lib/culling-volume.d.ts +0 -55
- package/dist/esm/lib/plane.d.ts +0 -38
- package/src/constants.d.ts +0 -6
- package/src/constants.js +0 -8
- package/src/index.d.ts +0 -20
- package/src/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
- package/src/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
- package/src/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
- package/src/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
- package/src/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
- package/src/lib/culling-volume.d.ts +0 -55
- package/src/lib/plane.d.ts +0 -38
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
// Note: This class is still an experimental export, mainly used by other test cases
|
|
4
|
+
// - It has not been fully adapted to math.gl conventions
|
|
5
|
+
// - Documentation has not been ported
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
import { assert } from '@math.gl/core';
|
|
8
|
+
import PerspectiveOffCenterFrustum from './perspective-off-center-frustum';
|
|
9
|
+
const defined = (val) => val !== null && typeof val !== 'undefined';
|
|
10
|
+
/**
|
|
11
|
+
* The viewing frustum is defined by 6 planes.
|
|
12
|
+
* Each plane is represented by a {@link Vector4} object, where the x, y, and z components
|
|
13
|
+
* define the unit vector normal to the plane, and the w component is the distance of the
|
|
14
|
+
* plane from the origin/camera position.
|
|
15
|
+
*
|
|
16
|
+
* @alias PerspectiveFrustum
|
|
17
|
+
* @constructor
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} [options] An object with the following properties:
|
|
20
|
+
* @param {Number} [options.fov] The angle of the field of view (FOV), in radians.
|
|
21
|
+
* @param {Number} [options.aspectRatio] The aspect ratio of the frustum's width to it's height.
|
|
22
|
+
* @param {Number} [options.near=1.0] The distance of the near plane.
|
|
23
|
+
* @param {Number} [options.far=500000000.0] The distance of the far plane.
|
|
24
|
+
* @param {Number} [options.xOffset=0.0] The offset in the x direction.
|
|
25
|
+
* @param {Number} [options.yOffset=0.0] The offset in the y direction.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* var frustum = new PerspectiveFrustum({
|
|
29
|
+
* fov : Math.PI_OVER_THREE,
|
|
30
|
+
* aspectRatio : canvas.clientWidth / canvas.clientHeight
|
|
31
|
+
* near : 1.0,
|
|
32
|
+
* far : 1000.0
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @see PerspectiveOffCenterFrustum
|
|
36
|
+
*/
|
|
37
|
+
export default class PerspectiveFrustum {
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
this._offCenterFrustum = new PerspectiveOffCenterFrustum();
|
|
40
|
+
options = {
|
|
41
|
+
near: 1.0,
|
|
42
|
+
far: 500000000.0,
|
|
43
|
+
xOffset: 0.0,
|
|
44
|
+
yOffset: 0.0,
|
|
45
|
+
...options
|
|
46
|
+
};
|
|
47
|
+
this.fov = options.fov;
|
|
48
|
+
this.aspectRatio = options.aspectRatio;
|
|
49
|
+
this.near = options.near;
|
|
50
|
+
this._near = this.near;
|
|
51
|
+
this.far = options.far;
|
|
52
|
+
this._far = this.far;
|
|
53
|
+
this.xOffset = options.xOffset;
|
|
54
|
+
this._xOffset = this.xOffset;
|
|
55
|
+
this.yOffset = options.yOffset;
|
|
56
|
+
this._yOffset = this.yOffset;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a duplicate of a PerspectiveFrustum instance.
|
|
60
|
+
*/
|
|
61
|
+
clone() {
|
|
62
|
+
return new PerspectiveFrustum({
|
|
63
|
+
aspectRatio: this.aspectRatio,
|
|
64
|
+
fov: this.fov,
|
|
65
|
+
near: this.near,
|
|
66
|
+
far: this.far
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Compares the provided PerspectiveFrustum componentwise and returns
|
|
71
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
72
|
+
*/
|
|
73
|
+
equals(other) {
|
|
74
|
+
if (!defined(other) || !(other instanceof PerspectiveFrustum)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
update(this);
|
|
78
|
+
update(other);
|
|
79
|
+
return (this.fov === other.fov &&
|
|
80
|
+
this.aspectRatio === other.aspectRatio &&
|
|
81
|
+
this.near === other.near &&
|
|
82
|
+
this.far === other.far &&
|
|
83
|
+
this._offCenterFrustum.equals(other._offCenterFrustum));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the perspective projection matrix computed from the view frustum.
|
|
87
|
+
*/
|
|
88
|
+
get projectionMatrix() {
|
|
89
|
+
update(this);
|
|
90
|
+
return this._offCenterFrustum.projectionMatrix;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The perspective projection matrix computed from the view frustum with an infinite far plane.
|
|
94
|
+
*/
|
|
95
|
+
get infiniteProjectionMatrix() {
|
|
96
|
+
update(this);
|
|
97
|
+
return this._offCenterFrustum.infiniteProjectionMatrix;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the angle of the vertical field of view, in radians.
|
|
101
|
+
*/
|
|
102
|
+
get fovy() {
|
|
103
|
+
update(this);
|
|
104
|
+
return this._fovy;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
get sseDenominator() {
|
|
110
|
+
update(this);
|
|
111
|
+
return this._sseDenominator;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates a culling volume for this frustum.
|
|
115
|
+
*
|
|
116
|
+
* @param {Vector3} position The eye position.
|
|
117
|
+
* @param {Vector3} direction The view direction.
|
|
118
|
+
* @param {Vector3} up The up direction.
|
|
119
|
+
* @returns {CullingVolume} A culling volume at the given position and orientation.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Check if a bounding volume intersects the frustum.
|
|
123
|
+
* var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
|
|
124
|
+
* var intersect = cullingVolume.computeVisibility(boundingVolume);
|
|
125
|
+
*/
|
|
126
|
+
computeCullingVolume(position, direction, up) {
|
|
127
|
+
update(this);
|
|
128
|
+
return this._offCenterFrustum.computeCullingVolume(position, direction, up);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Returns the pixel's width and height in meters.
|
|
132
|
+
*
|
|
133
|
+
* @param {Number} drawingBufferWidth The width of the drawing buffer.
|
|
134
|
+
* @param {Number} drawingBufferHeight The height of the drawing buffer.
|
|
135
|
+
* @param {Number} distance The distance to the near plane in meters.
|
|
136
|
+
* @param {Vector2} result The object onto which to store the result.
|
|
137
|
+
* @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
|
|
138
|
+
*
|
|
139
|
+
* @exception {DeveloperError} drawingBufferWidth must be greater than zero.
|
|
140
|
+
* @exception {DeveloperError} drawingBufferHeight must be greater than zero.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* // Example 1
|
|
144
|
+
* // Get the width and height of a pixel.
|
|
145
|
+
* var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // Example 2
|
|
149
|
+
* // Get the width and height of a pixel if the near plane was set to 'distance'.
|
|
150
|
+
* // For example, get the size of a pixel of an image on a billboard.
|
|
151
|
+
* var position = camera.position;
|
|
152
|
+
* var direction = camera.direction;
|
|
153
|
+
* var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
|
|
154
|
+
* var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
|
|
155
|
+
* var distance = Vector3.magnitude(toCenterProj);
|
|
156
|
+
* var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
|
|
157
|
+
*/
|
|
158
|
+
getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {
|
|
159
|
+
update(this);
|
|
160
|
+
return this._offCenterFrustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// eslint-disable-next-line complexity, max-statements
|
|
164
|
+
function update(frustum) {
|
|
165
|
+
assert(Number.isFinite(frustum.fov) &&
|
|
166
|
+
Number.isFinite(frustum.aspectRatio) &&
|
|
167
|
+
Number.isFinite(frustum.near) &&
|
|
168
|
+
Number.isFinite(frustum.far));
|
|
169
|
+
// 'fov, aspectRatio, near, or far parameters are not set.'
|
|
170
|
+
const f = frustum._offCenterFrustum;
|
|
171
|
+
if (frustum.fov !== frustum._fov ||
|
|
172
|
+
frustum.aspectRatio !== frustum._aspectRatio ||
|
|
173
|
+
frustum.near !== frustum._near ||
|
|
174
|
+
frustum.far !== frustum._far ||
|
|
175
|
+
frustum.xOffset !== frustum._xOffset ||
|
|
176
|
+
frustum.yOffset !== frustum._yOffset) {
|
|
177
|
+
assert(frustum.fov >= 0 && frustum.fov < Math.PI);
|
|
178
|
+
// throw new DeveloperError('fov must be in the range [0, PI).');
|
|
179
|
+
assert(frustum.aspectRatio > 0);
|
|
180
|
+
// throw new DeveloperError('aspectRatio must be positive.');
|
|
181
|
+
assert(frustum.near >= 0 && frustum.near < frustum.far);
|
|
182
|
+
// throw new DeveloperError('near must be greater than zero and less than far.');
|
|
183
|
+
frustum._aspectRatio = frustum.aspectRatio;
|
|
184
|
+
frustum._fov = frustum.fov;
|
|
185
|
+
frustum._fovy =
|
|
186
|
+
frustum.aspectRatio <= 1
|
|
187
|
+
? frustum.fov
|
|
188
|
+
: Math.atan(Math.tan(frustum.fov * 0.5) / frustum.aspectRatio) * 2.0;
|
|
189
|
+
frustum._near = frustum.near;
|
|
190
|
+
frustum._far = frustum.far;
|
|
191
|
+
frustum._sseDenominator = 2.0 * Math.tan(0.5 * frustum._fovy);
|
|
192
|
+
frustum._xOffset = frustum.xOffset;
|
|
193
|
+
frustum._yOffset = frustum.yOffset;
|
|
194
|
+
f.top = frustum.near * Math.tan(0.5 * frustum._fovy);
|
|
195
|
+
f.bottom = -f.top;
|
|
196
|
+
f.right = frustum.aspectRatio * f.top;
|
|
197
|
+
f.left = -f.right;
|
|
198
|
+
f.near = frustum.near;
|
|
199
|
+
f.far = frustum.far;
|
|
200
|
+
f.right += frustum.xOffset;
|
|
201
|
+
f.left += frustum.xOffset;
|
|
202
|
+
f.top += frustum.yOffset;
|
|
203
|
+
f.bottom += frustum.yOffset;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Matrix4 } from '@math.gl/core';
|
|
2
|
+
import CullingVolume from './culling-volume';
|
|
3
|
+
export default class PerspectiveOffCenterFrustum {
|
|
4
|
+
left: any;
|
|
5
|
+
_left: any;
|
|
6
|
+
right: any;
|
|
7
|
+
_right: any;
|
|
8
|
+
top: any;
|
|
9
|
+
_top: any;
|
|
10
|
+
bottom: any;
|
|
11
|
+
_bottom: any;
|
|
12
|
+
near: any;
|
|
13
|
+
_near: any;
|
|
14
|
+
far: any;
|
|
15
|
+
_far: any;
|
|
16
|
+
_cullingVolume: CullingVolume;
|
|
17
|
+
_perspectiveMatrix: Matrix4;
|
|
18
|
+
_infinitePerspective: Matrix4;
|
|
19
|
+
/**
|
|
20
|
+
* The viewing frustum is defined by 6 planes.
|
|
21
|
+
* Each plane is represented by a {@link Vector4} object, where the x, y, and z components
|
|
22
|
+
* define the unit vector normal to the plane, and the w component is the distance of the
|
|
23
|
+
* plane from the origin/camera position.
|
|
24
|
+
*
|
|
25
|
+
* @alias PerspectiveOffCenterFrustum
|
|
26
|
+
* @constructor
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} [options] An object with the following properties:
|
|
29
|
+
* @param {Number} [options.left] The left clipping plane distance.
|
|
30
|
+
* @param {Number} [options.right] The right clipping plane distance.
|
|
31
|
+
* @param {Number} [options.top] The top clipping plane distance.
|
|
32
|
+
* @param {Number} [options.bottom] The bottom clipping plane distance.
|
|
33
|
+
* @param {Number} [options.near=1.0] The near clipping plane distance.
|
|
34
|
+
* @param {Number} [options.far=500000000.0] The far clipping plane distance.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const frustum = new PerspectiveOffCenterFrustum({
|
|
38
|
+
* left : -1.0,
|
|
39
|
+
* right : 1.0,
|
|
40
|
+
* top : 1.0,
|
|
41
|
+
* bottom : -1.0,
|
|
42
|
+
* near : 1.0,
|
|
43
|
+
* far : 100.0
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* @see PerspectiveFrustum
|
|
47
|
+
*/
|
|
48
|
+
constructor(options?: Record<string, any>);
|
|
49
|
+
/**
|
|
50
|
+
* Returns a duplicate of a PerspectiveOffCenterFrustum instance.
|
|
51
|
+
* @returns {PerspectiveOffCenterFrustum} A new PerspectiveFrustum instance.
|
|
52
|
+
* */
|
|
53
|
+
clone(): PerspectiveOffCenterFrustum;
|
|
54
|
+
/**
|
|
55
|
+
* Compares the provided PerspectiveOffCenterFrustum componentwise and returns
|
|
56
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
57
|
+
*
|
|
58
|
+
* @param {PerspectiveOffCenterFrustum} [other] The right hand side PerspectiveOffCenterFrustum.
|
|
59
|
+
* @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
60
|
+
*/
|
|
61
|
+
equals(other: any): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the perspective projection matrix computed from the view frustum.
|
|
64
|
+
* @memberof PerspectiveOffCenterFrustum.prototype
|
|
65
|
+
* @type {Matrix4}
|
|
66
|
+
*
|
|
67
|
+
* @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix
|
|
68
|
+
*/
|
|
69
|
+
get projectionMatrix(): Matrix4;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
|
|
72
|
+
* @memberof PerspectiveOffCenterFrustum.prototype
|
|
73
|
+
* @type {Matrix4}
|
|
74
|
+
*
|
|
75
|
+
* @see PerspectiveOffCenterFrustum#projectionMatrix
|
|
76
|
+
*/
|
|
77
|
+
get infiniteProjectionMatrix(): Matrix4;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a culling volume for this frustum.
|
|
80
|
+
*
|
|
81
|
+
* @param {Vector3} position The eye position.
|
|
82
|
+
* @param {Vector3} direction The view direction.
|
|
83
|
+
* @param {Vector3} up The up direction.
|
|
84
|
+
* @returns {CullingVolume} A culling volume at the given position and orientation.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Check if a bounding volume intersects the frustum.
|
|
88
|
+
* const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
|
|
89
|
+
* const intersect = cullingVolume.computeVisibility(boundingVolume);
|
|
90
|
+
*/
|
|
91
|
+
computeCullingVolume(position: any, direction: any, up: any): CullingVolume;
|
|
92
|
+
/**
|
|
93
|
+
* Returns the pixel's width and height in meters.
|
|
94
|
+
*
|
|
95
|
+
* @param {Number} drawingBufferWidth The width of the drawing buffer.
|
|
96
|
+
* @param {Number} drawingBufferHeight The height of the drawing buffer.
|
|
97
|
+
* @param {Number} distance The distance to the near plane in meters.
|
|
98
|
+
* @param {Vector2} result The object onto which to store the result.
|
|
99
|
+
* @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
|
|
100
|
+
*
|
|
101
|
+
* @exception {DeveloperError} drawingBufferWidth must be greater than zero.
|
|
102
|
+
* @exception {DeveloperError} drawingBufferHeight must be greater than zero.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Example 1
|
|
106
|
+
* // Get the width and height of a pixel.
|
|
107
|
+
* const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // Example 2
|
|
111
|
+
* // Get the width and height of a pixel if the near plane was set to 'distance'.
|
|
112
|
+
* // For example, get the size of a pixel of an image on a billboard.
|
|
113
|
+
* const position = camera.position;
|
|
114
|
+
* const direction = camera.direction;
|
|
115
|
+
* const toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
|
|
116
|
+
* const toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
|
|
117
|
+
* const distance = Vector3.magnitude(toCenterProj);
|
|
118
|
+
* const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
|
|
119
|
+
*/
|
|
120
|
+
getPixelDimensions(drawingBufferWidth: any, drawingBufferHeight: any, distance: any, result: any): any;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=perspective-off-center-frustum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perspective-off-center-frustum.d.ts","sourceRoot":"","sources":["../../src/lib/perspective-off-center-frustum.ts"],"names":[],"mappings":"AASA,OAAO,EAAU,OAAO,EAAS,MAAM,eAAe,CAAC;AACvD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAS7C,MAAM,CAAC,OAAO,OAAO,2BAA2B;IAC9C,IAAI,MAAC;IACL,KAAK,MAAC;IACN,KAAK,MAAC;IACN,MAAM,MAAC;IACP,GAAG,MAAC;IACJ,IAAI,MAAC;IACL,MAAM,MAAC;IACP,OAAO,MAAC;IACR,IAAI,MAAC;IACL,KAAK,MAAC;IACN,GAAG,MAAC;IACJ,IAAI,MAAC;IACL,cAAc,gBAOX;IACH,kBAAkB,UAAiB;IACnC,oBAAoB,UAAiB;IAErC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAoD7C;;;SAGK;IACL,KAAK;IAWL;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,KAAA;IAaZ;;;;;;OAMG;IACH,IAAI,gBAAgB,YAGnB;IAED;;;;;;OAMG;IACH,IAAI,wBAAwB,YAG3B;IAED;;;;;;;;;;;;OAYG;IAEH,oBAAoB,CAAC,QAAQ,KAAA,EAAE,SAAS,KAAA,EAAE,EAAE,KAAA;IAmE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,kBAAkB,CAAC,kBAAkB,KAAA,EAAE,mBAAmB,KAAA,EAAE,QAAQ,KAAA,EAAE,MAAM,KAAA;CAwB7E"}
|
|
@@ -0,0 +1,305 @@
|
|
|
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
|
+
// Note: This class is still an experimental export, mainly used by other test cases
|
|
4
|
+
// - It has not been fully adapted to math.gl conventions
|
|
5
|
+
// - Documentation has not been ported
|
|
6
|
+
// @ts-nocheck
|
|
7
|
+
import { Vector3, Matrix4, assert } from '@math.gl/core';
|
|
8
|
+
import CullingVolume from './culling-volume';
|
|
9
|
+
import Plane from './plane';
|
|
10
|
+
const scratchPlaneUpVector = new Vector3();
|
|
11
|
+
const scratchPlaneRightVector = new Vector3();
|
|
12
|
+
const scratchPlaneNearCenter = new Vector3();
|
|
13
|
+
const scratchPlaneFarCenter = new Vector3();
|
|
14
|
+
const scratchPlaneNormal = new Vector3();
|
|
15
|
+
export default class PerspectiveOffCenterFrustum {
|
|
16
|
+
/**
|
|
17
|
+
* The viewing frustum is defined by 6 planes.
|
|
18
|
+
* Each plane is represented by a {@link Vector4} object, where the x, y, and z components
|
|
19
|
+
* define the unit vector normal to the plane, and the w component is the distance of the
|
|
20
|
+
* plane from the origin/camera position.
|
|
21
|
+
*
|
|
22
|
+
* @alias PerspectiveOffCenterFrustum
|
|
23
|
+
* @constructor
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} [options] An object with the following properties:
|
|
26
|
+
* @param {Number} [options.left] The left clipping plane distance.
|
|
27
|
+
* @param {Number} [options.right] The right clipping plane distance.
|
|
28
|
+
* @param {Number} [options.top] The top clipping plane distance.
|
|
29
|
+
* @param {Number} [options.bottom] The bottom clipping plane distance.
|
|
30
|
+
* @param {Number} [options.near=1.0] The near clipping plane distance.
|
|
31
|
+
* @param {Number} [options.far=500000000.0] The far clipping plane distance.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const frustum = new PerspectiveOffCenterFrustum({
|
|
35
|
+
* left : -1.0,
|
|
36
|
+
* right : 1.0,
|
|
37
|
+
* top : 1.0,
|
|
38
|
+
* bottom : -1.0,
|
|
39
|
+
* near : 1.0,
|
|
40
|
+
* far : 100.0
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* @see PerspectiveFrustum
|
|
44
|
+
*/
|
|
45
|
+
constructor(options = {}) {
|
|
46
|
+
this._cullingVolume = new CullingVolume([
|
|
47
|
+
new Plane(),
|
|
48
|
+
new Plane(),
|
|
49
|
+
new Plane(),
|
|
50
|
+
new Plane(),
|
|
51
|
+
new Plane(),
|
|
52
|
+
new Plane()
|
|
53
|
+
]);
|
|
54
|
+
this._perspectiveMatrix = new Matrix4();
|
|
55
|
+
this._infinitePerspective = new Matrix4();
|
|
56
|
+
options = { near: 1.0, far: 500000000.0, ...options };
|
|
57
|
+
/**
|
|
58
|
+
* Defines the left clipping plane.
|
|
59
|
+
* @type {Number}
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
62
|
+
this.left = options.left;
|
|
63
|
+
this._left = undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Defines the right clipping plane.
|
|
66
|
+
* @type {Number}
|
|
67
|
+
* @default undefined
|
|
68
|
+
*/
|
|
69
|
+
this.right = options.right;
|
|
70
|
+
this._right = undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Defines the top clipping plane.
|
|
73
|
+
* @type {Number}
|
|
74
|
+
* @default undefined
|
|
75
|
+
*/
|
|
76
|
+
this.top = options.top;
|
|
77
|
+
this._top = undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Defines the bottom clipping plane.
|
|
80
|
+
* @type {Number}
|
|
81
|
+
* @default undefined
|
|
82
|
+
*/
|
|
83
|
+
this.bottom = options.bottom;
|
|
84
|
+
this._bottom = undefined;
|
|
85
|
+
/**
|
|
86
|
+
* The distance of the near plane.
|
|
87
|
+
* @type {Number}
|
|
88
|
+
* @default 1.0
|
|
89
|
+
*/
|
|
90
|
+
this.near = options.near;
|
|
91
|
+
this._near = this.near;
|
|
92
|
+
/**
|
|
93
|
+
* The distance of the far plane.
|
|
94
|
+
* @type {Number}
|
|
95
|
+
* @default 500000000.0
|
|
96
|
+
*/
|
|
97
|
+
this.far = options.far;
|
|
98
|
+
this._far = this.far;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns a duplicate of a PerspectiveOffCenterFrustum instance.
|
|
102
|
+
* @returns {PerspectiveOffCenterFrustum} A new PerspectiveFrustum instance.
|
|
103
|
+
* */
|
|
104
|
+
clone() {
|
|
105
|
+
return new PerspectiveOffCenterFrustum({
|
|
106
|
+
right: this.right,
|
|
107
|
+
left: this.left,
|
|
108
|
+
top: this.top,
|
|
109
|
+
bottom: this.bottom,
|
|
110
|
+
near: this.near,
|
|
111
|
+
far: this.far
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Compares the provided PerspectiveOffCenterFrustum componentwise and returns
|
|
116
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
117
|
+
*
|
|
118
|
+
* @param {PerspectiveOffCenterFrustum} [other] The right hand side PerspectiveOffCenterFrustum.
|
|
119
|
+
* @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
120
|
+
*/
|
|
121
|
+
equals(other) {
|
|
122
|
+
return (other &&
|
|
123
|
+
other instanceof PerspectiveOffCenterFrustum &&
|
|
124
|
+
this.right === other.right &&
|
|
125
|
+
this.left === other.left &&
|
|
126
|
+
this.top === other.top &&
|
|
127
|
+
this.bottom === other.bottom &&
|
|
128
|
+
this.near === other.near &&
|
|
129
|
+
this.far === other.far);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Gets the perspective projection matrix computed from the view frustum.
|
|
133
|
+
* @memberof PerspectiveOffCenterFrustum.prototype
|
|
134
|
+
* @type {Matrix4}
|
|
135
|
+
*
|
|
136
|
+
* @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix
|
|
137
|
+
*/
|
|
138
|
+
get projectionMatrix() {
|
|
139
|
+
update(this);
|
|
140
|
+
return this._perspectiveMatrix;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Gets the perspective projection matrix computed from the view frustum with an infinite far plane.
|
|
144
|
+
* @memberof PerspectiveOffCenterFrustum.prototype
|
|
145
|
+
* @type {Matrix4}
|
|
146
|
+
*
|
|
147
|
+
* @see PerspectiveOffCenterFrustum#projectionMatrix
|
|
148
|
+
*/
|
|
149
|
+
get infiniteProjectionMatrix() {
|
|
150
|
+
update(this);
|
|
151
|
+
return this._infinitePerspective;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates a culling volume for this frustum.
|
|
155
|
+
*
|
|
156
|
+
* @param {Vector3} position The eye position.
|
|
157
|
+
* @param {Vector3} direction The view direction.
|
|
158
|
+
* @param {Vector3} up The up direction.
|
|
159
|
+
* @returns {CullingVolume} A culling volume at the given position and orientation.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* // Check if a bounding volume intersects the frustum.
|
|
163
|
+
* const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
|
|
164
|
+
* const intersect = cullingVolume.computeVisibility(boundingVolume);
|
|
165
|
+
*/
|
|
166
|
+
// eslint-disable-next-line complexity, max-statements
|
|
167
|
+
computeCullingVolume(position, direction, up) {
|
|
168
|
+
assert(position, 'position is required.');
|
|
169
|
+
assert(direction, 'direction is required.');
|
|
170
|
+
assert(up, 'up is required.');
|
|
171
|
+
const planes = this._cullingVolume.planes;
|
|
172
|
+
up = scratchPlaneUpVector.copy(up).normalize();
|
|
173
|
+
const right = scratchPlaneRightVector.copy(direction).cross(up).normalize();
|
|
174
|
+
const nearCenter = scratchPlaneNearCenter
|
|
175
|
+
.copy(direction)
|
|
176
|
+
.multiplyByScalar(this.near)
|
|
177
|
+
.add(position);
|
|
178
|
+
const farCenter = scratchPlaneFarCenter
|
|
179
|
+
.copy(direction)
|
|
180
|
+
.multiplyByScalar(this.far)
|
|
181
|
+
.add(position);
|
|
182
|
+
let normal = scratchPlaneNormal;
|
|
183
|
+
// Left plane computation
|
|
184
|
+
normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up);
|
|
185
|
+
planes[0].fromPointNormal(position, normal);
|
|
186
|
+
// Right plane computation
|
|
187
|
+
normal
|
|
188
|
+
.copy(right)
|
|
189
|
+
.multiplyByScalar(this.right)
|
|
190
|
+
.add(nearCenter)
|
|
191
|
+
.subtract(position)
|
|
192
|
+
.cross(up)
|
|
193
|
+
.negate();
|
|
194
|
+
planes[1].fromPointNormal(position, normal);
|
|
195
|
+
// Bottom plane computation
|
|
196
|
+
normal
|
|
197
|
+
.copy(up)
|
|
198
|
+
.multiplyByScalar(this.bottom)
|
|
199
|
+
.add(nearCenter)
|
|
200
|
+
.subtract(position)
|
|
201
|
+
.cross(right)
|
|
202
|
+
.negate();
|
|
203
|
+
planes[2].fromPointNormal(position, normal);
|
|
204
|
+
// Top plane computation
|
|
205
|
+
normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right);
|
|
206
|
+
planes[3].fromPointNormal(position, normal);
|
|
207
|
+
normal = new Vector3().copy(direction);
|
|
208
|
+
// Near plane computation
|
|
209
|
+
planes[4].fromPointNormal(nearCenter, normal);
|
|
210
|
+
// Far plane computation
|
|
211
|
+
normal.negate();
|
|
212
|
+
planes[5].fromPointNormal(farCenter, normal);
|
|
213
|
+
return this._cullingVolume;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns the pixel's width and height in meters.
|
|
217
|
+
*
|
|
218
|
+
* @param {Number} drawingBufferWidth The width of the drawing buffer.
|
|
219
|
+
* @param {Number} drawingBufferHeight The height of the drawing buffer.
|
|
220
|
+
* @param {Number} distance The distance to the near plane in meters.
|
|
221
|
+
* @param {Vector2} result The object onto which to store the result.
|
|
222
|
+
* @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.
|
|
223
|
+
*
|
|
224
|
+
* @exception {DeveloperError} drawingBufferWidth must be greater than zero.
|
|
225
|
+
* @exception {DeveloperError} drawingBufferHeight must be greater than zero.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* // Example 1
|
|
229
|
+
* // Get the width and height of a pixel.
|
|
230
|
+
* const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* // Example 2
|
|
234
|
+
* // Get the width and height of a pixel if the near plane was set to 'distance'.
|
|
235
|
+
* // For example, get the size of a pixel of an image on a billboard.
|
|
236
|
+
* const position = camera.position;
|
|
237
|
+
* const direction = camera.direction;
|
|
238
|
+
* const toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
|
|
239
|
+
* const toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
|
|
240
|
+
* const distance = Vector3.magnitude(toCenterProj);
|
|
241
|
+
* const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
|
|
242
|
+
*/
|
|
243
|
+
getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {
|
|
244
|
+
update(this);
|
|
245
|
+
assert(Number.isFinite(drawingBufferWidth) && Number.isFinite(drawingBufferHeight));
|
|
246
|
+
// 'Both drawingBufferWidth and drawingBufferHeight are required.'
|
|
247
|
+
assert(drawingBufferWidth > 0);
|
|
248
|
+
// 'drawingBufferWidth must be greater than zero.'
|
|
249
|
+
assert(drawingBufferHeight > 0);
|
|
250
|
+
// 'drawingBufferHeight must be greater than zero.'
|
|
251
|
+
assert(distance > 0);
|
|
252
|
+
// 'distance is required.');
|
|
253
|
+
assert(result);
|
|
254
|
+
// 'A result object is required.');
|
|
255
|
+
const inverseNear = 1.0 / this.near;
|
|
256
|
+
let tanTheta = this.top * inverseNear;
|
|
257
|
+
const pixelHeight = (2.0 * distance * tanTheta) / drawingBufferHeight;
|
|
258
|
+
tanTheta = this.right * inverseNear;
|
|
259
|
+
const pixelWidth = (2.0 * distance * tanTheta) / drawingBufferWidth;
|
|
260
|
+
result.x = pixelWidth;
|
|
261
|
+
result.y = pixelHeight;
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// eslint-disable-next-line complexity, max-statements
|
|
266
|
+
function update(frustum) {
|
|
267
|
+
assert(Number.isFinite(frustum.right) &&
|
|
268
|
+
Number.isFinite(frustum.left) &&
|
|
269
|
+
Number.isFinite(frustum.top) &&
|
|
270
|
+
Number.isFinite(frustum.bottom) &&
|
|
271
|
+
Number.isFinite(frustum.near) &&
|
|
272
|
+
Number.isFinite(frustum.far));
|
|
273
|
+
// throw new DeveloperError('right, left, top, bottom, near, or far parameters are not set.');
|
|
274
|
+
const { top, bottom, right, left, near, far } = frustum;
|
|
275
|
+
if (top !== frustum._top ||
|
|
276
|
+
bottom !== frustum._bottom ||
|
|
277
|
+
left !== frustum._left ||
|
|
278
|
+
right !== frustum._right ||
|
|
279
|
+
near !== frustum._near ||
|
|
280
|
+
far !== frustum._far) {
|
|
281
|
+
assert(frustum.near > 0 && frustum.near < frustum.far, 'near must be greater than zero and less than far.');
|
|
282
|
+
frustum._left = left;
|
|
283
|
+
frustum._right = right;
|
|
284
|
+
frustum._top = top;
|
|
285
|
+
frustum._bottom = bottom;
|
|
286
|
+
frustum._near = near;
|
|
287
|
+
frustum._far = far;
|
|
288
|
+
frustum._perspectiveMatrix = new Matrix4().frustum({
|
|
289
|
+
left,
|
|
290
|
+
right,
|
|
291
|
+
bottom,
|
|
292
|
+
top,
|
|
293
|
+
near,
|
|
294
|
+
far
|
|
295
|
+
});
|
|
296
|
+
frustum._infinitePerspective = new Matrix4().frustum({
|
|
297
|
+
left,
|
|
298
|
+
right,
|
|
299
|
+
bottom,
|
|
300
|
+
top,
|
|
301
|
+
near,
|
|
302
|
+
far: Infinity
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Vector3 } from '@math.gl/core';
|
|
2
|
+
export default class Plane {
|
|
3
|
+
readonly normal: Vector3;
|
|
4
|
+
distance: number;
|
|
5
|
+
constructor(normal?: readonly number[], distance?: number);
|
|
6
|
+
/** Creates a plane from a normal and a distance from the origin. */
|
|
7
|
+
fromNormalDistance(normal: readonly number[], distance: number): this;
|
|
8
|
+
/** Creates a plane from a normal and a point on the plane. */
|
|
9
|
+
fromPointNormal(point: readonly number[], normal: readonly number[]): this;
|
|
10
|
+
/** Creates a plane from the general equation */
|
|
11
|
+
fromCoefficients(a: number, b: number, c: number, d: number): this;
|
|
12
|
+
/** Duplicates a Plane instance. */
|
|
13
|
+
clone(): Plane;
|
|
14
|
+
/** Compares the provided Planes by normal and distance */
|
|
15
|
+
equals(right: Plane): boolean;
|
|
16
|
+
/** Computes the signed shortest distance of a point to a plane.
|
|
17
|
+
* The sign of the distance determines which side of the plane the point is on.
|
|
18
|
+
*/
|
|
19
|
+
getPointDistance(point: readonly number[]): number;
|
|
20
|
+
/** Transforms the plane by the given transformation matrix. */
|
|
21
|
+
transform(matrix4: readonly number[]): this;
|
|
22
|
+
/** Projects a point onto the plane. */
|
|
23
|
+
projectPointOntoPlane(point: readonly number[], result: Vector3): Vector3;
|
|
24
|
+
projectPointOntoPlane(point: readonly number[], result?: readonly number[]): readonly number[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plane.d.ts","sourceRoot":"","sources":["../../src/lib/plane.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAiB,MAAM,eAAe,CAAC;AAMtD,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;gBAEL,MAAM,GAAE,SAAS,MAAM,EAAc,EAAE,QAAQ,GAAE,MAAU;IAMvE,oEAAoE;IACpE,kBAAkB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOrE,8DAA8D;IAC9D,eAAe,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAQ1E,gDAAgD;IAChD,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAOlE,mCAAmC;IACnC,KAAK,IAAI,KAAK;IAId,0DAA0D;IAC1D,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAI7B;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAIlD,+DAA+D;IAC/D,SAAS,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAM3C,uCAAuC;IACvC,qBAAqB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IACzE,qBAAqB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE;CAU/F"}
|