@math.gl/culling 3.6.0-alpha.5 → 3.6.0-alpha.6
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/es5/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
- package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
- package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
- package/dist/es5/lib/perspective-frustum.js +63 -58
- package/dist/es5/lib/perspective-frustum.js.map +1 -1
- package/dist/es5/lib/perspective-off-center-frustum.js +51 -51
- package/dist/es5/lib/perspective-off-center-frustum.js.map +1 -1
- package/dist/es5/lib/plane.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.map +1 -1
- package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
- package/dist/esm/lib/perspective-frustum.js +60 -55
- package/dist/esm/lib/perspective-frustum.js.map +1 -1
- package/dist/esm/lib/perspective-off-center-frustum.js +48 -46
- package/dist/esm/lib/perspective-off-center-frustum.js.map +1 -1
- package/dist/esm/lib/plane.js.map +1 -1
- package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +1 -1
- package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -1
- package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts +2 -2
- package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -1
- package/dist/lib/perspective-frustum.d.ts +52 -40
- package/dist/lib/perspective-frustum.d.ts.map +1 -1
- package/dist/lib/perspective-frustum.js +81 -96
- package/dist/lib/perspective-off-center-frustum.d.ts +74 -38
- package/dist/lib/perspective-off-center-frustum.d.ts.map +1 -1
- package/dist/lib/perspective-off-center-frustum.js +64 -99
- package/dist/lib/plane.d.ts +8 -8
- package/dist/lib/plane.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/algorithms/compute-eigen-decomposition.ts +3 -3
- package/src/lib/bounding-volumes/axis-aligned-bounding-box.ts +2 -2
- package/src/lib/bounding-volumes/oriented-bounding-box.ts +2 -2
- package/src/lib/perspective-frustum.ts +115 -118
- package/src/lib/perspective-off-center-frustum.ts +137 -131
- package/src/lib/plane.ts +11 -8
|
@@ -39,11 +39,10 @@ export default class PerspectiveOffCenterFrustum {
|
|
|
39
39
|
|
|
40
40
|
_defineProperty(this, "_infinitePerspective", new Matrix4());
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
near
|
|
44
|
-
far
|
|
45
|
-
|
|
46
|
-
};
|
|
42
|
+
const {
|
|
43
|
+
near = 1.0,
|
|
44
|
+
far = 500000000.0
|
|
45
|
+
} = options;
|
|
47
46
|
this.left = options.left;
|
|
48
47
|
this._left = undefined;
|
|
49
48
|
this.right = options.right;
|
|
@@ -52,10 +51,10 @@ export default class PerspectiveOffCenterFrustum {
|
|
|
52
51
|
this._top = undefined;
|
|
53
52
|
this.bottom = options.bottom;
|
|
54
53
|
this._bottom = undefined;
|
|
55
|
-
this.near =
|
|
56
|
-
this._near =
|
|
57
|
-
this.far =
|
|
58
|
-
this._far =
|
|
54
|
+
this.near = near;
|
|
55
|
+
this._near = near;
|
|
56
|
+
this.far = far;
|
|
57
|
+
this._far = far;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
clone() {
|
|
@@ -74,12 +73,14 @@ export default class PerspectiveOffCenterFrustum {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
get projectionMatrix() {
|
|
77
|
-
|
|
76
|
+
this._update();
|
|
77
|
+
|
|
78
78
|
return this._perspectiveMatrix;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
get infiniteProjectionMatrix() {
|
|
82
|
-
|
|
82
|
+
this._update();
|
|
83
|
+
|
|
83
84
|
return this._infinitePerspective;
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -109,7 +110,8 @@ export default class PerspectiveOffCenterFrustum {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {
|
|
112
|
-
|
|
113
|
+
this._update();
|
|
114
|
+
|
|
113
115
|
assert(Number.isFinite(drawingBufferWidth) && Number.isFinite(drawingBufferHeight));
|
|
114
116
|
assert(drawingBufferWidth > 0);
|
|
115
117
|
assert(drawingBufferHeight > 0);
|
|
@@ -125,43 +127,43 @@ export default class PerspectiveOffCenterFrustum {
|
|
|
125
127
|
return result;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
assert(Number.isFinite(frustum.right) && Number.isFinite(frustum.left) && Number.isFinite(frustum.top) && Number.isFinite(frustum.bottom) && Number.isFinite(frustum.near) && Number.isFinite(frustum.far));
|
|
132
|
-
const {
|
|
133
|
-
top,
|
|
134
|
-
bottom,
|
|
135
|
-
right,
|
|
136
|
-
left,
|
|
137
|
-
near,
|
|
138
|
-
far
|
|
139
|
-
} = frustum;
|
|
140
|
-
|
|
141
|
-
if (top !== frustum._top || bottom !== frustum._bottom || left !== frustum._left || right !== frustum._right || near !== frustum._near || far !== frustum._far) {
|
|
142
|
-
assert(frustum.near > 0 && frustum.near < frustum.far, 'near must be greater than zero and less than far.');
|
|
143
|
-
frustum._left = left;
|
|
144
|
-
frustum._right = right;
|
|
145
|
-
frustum._top = top;
|
|
146
|
-
frustum._bottom = bottom;
|
|
147
|
-
frustum._near = near;
|
|
148
|
-
frustum._far = far;
|
|
149
|
-
frustum._perspectiveMatrix = new Matrix4().frustum({
|
|
150
|
-
left,
|
|
151
|
-
right,
|
|
152
|
-
bottom,
|
|
130
|
+
_update() {
|
|
131
|
+
assert(Number.isFinite(this.right) && Number.isFinite(this.left) && Number.isFinite(this.top) && Number.isFinite(this.bottom) && Number.isFinite(this.near) && Number.isFinite(this.far));
|
|
132
|
+
const {
|
|
153
133
|
top,
|
|
154
|
-
near,
|
|
155
|
-
far
|
|
156
|
-
});
|
|
157
|
-
frustum._infinitePerspective = new Matrix4().frustum({
|
|
158
|
-
left,
|
|
159
|
-
right,
|
|
160
134
|
bottom,
|
|
161
|
-
|
|
135
|
+
right,
|
|
136
|
+
left,
|
|
162
137
|
near,
|
|
163
|
-
far
|
|
164
|
-
}
|
|
138
|
+
far
|
|
139
|
+
} = this;
|
|
140
|
+
|
|
141
|
+
if (top !== this._top || bottom !== this._bottom || left !== this._left || right !== this._right || near !== this._near || far !== this._far) {
|
|
142
|
+
assert(this.near > 0 && this.near < this.far, 'near must be greater than zero and less than far.');
|
|
143
|
+
this._left = left;
|
|
144
|
+
this._right = right;
|
|
145
|
+
this._top = top;
|
|
146
|
+
this._bottom = bottom;
|
|
147
|
+
this._near = near;
|
|
148
|
+
this._far = far;
|
|
149
|
+
this._perspectiveMatrix = new Matrix4().frustum({
|
|
150
|
+
left,
|
|
151
|
+
right,
|
|
152
|
+
bottom,
|
|
153
|
+
top,
|
|
154
|
+
near,
|
|
155
|
+
far
|
|
156
|
+
});
|
|
157
|
+
this._infinitePerspective = new Matrix4().frustum({
|
|
158
|
+
left,
|
|
159
|
+
right,
|
|
160
|
+
bottom,
|
|
161
|
+
top,
|
|
162
|
+
near,
|
|
163
|
+
far: Infinity
|
|
164
|
+
});
|
|
165
|
+
}
|
|
165
166
|
}
|
|
167
|
+
|
|
166
168
|
}
|
|
167
169
|
//# sourceMappingURL=perspective-off-center-frustum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/perspective-off-center-frustum.ts"],"names":["Vector3","Matrix4","assert","CullingVolume","Plane","scratchPlaneUpVector","scratchPlaneRightVector","scratchPlaneNearCenter","scratchPlaneFarCenter","scratchPlaneNormal","PerspectiveOffCenterFrustum","constructor","options","near","far","left","_left","undefined","right","_right","top","_top","bottom","_bottom","_near","_far","clone","equals","other","projectionMatrix","update","_perspectiveMatrix","infiniteProjectionMatrix","_infinitePerspective","computeCullingVolume","position","direction","up","planes","_cullingVolume","copy","normalize","cross","nearCenter","multiplyByScalar","add","farCenter","normal","subtract","fromPointNormal","negate","getPixelDimensions","drawingBufferWidth","drawingBufferHeight","distance","result","Number","isFinite","inverseNear","tanTheta","pixelHeight","pixelWidth","x","y","frustum","Infinity"],"mappings":";AASA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,MAA1B,QAAuC,eAAvC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,KAAP,MAAkB,SAAlB;AAEA,MAAMC,oBAAoB,GAAG,IAAIL,OAAJ,EAA7B;AACA,MAAMM,uBAAuB,GAAG,IAAIN,OAAJ,EAAhC;AACA,MAAMO,sBAAsB,GAAG,IAAIP,OAAJ,EAA/B;AACA,MAAMQ,qBAAqB,GAAG,IAAIR,OAAJ,EAA9B;AACA,MAAMS,kBAAkB,GAAG,IAAIT,OAAJ,EAA3B;AAEA,eAAe,MAAMU,2BAAN,CAAkC;AAqD/CC,EAAAA,WAAW,CAACC,OAA4B,GAAG,EAAhC,EAAoC;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,4CAxC9B,IAAIT,aAAJ,CAAkB,CACjC,IAAIC,KAAJ,EADiC,EAEjC,IAAIA,KAAJ,EAFiC,EAGjC,IAAIA,KAAJ,EAHiC,EAIjC,IAAIA,KAAJ,EAJiC,EAKjC,IAAIA,KAAJ,EALiC,EAMjC,IAAIA,KAAJ,EANiC,CAAlB,CAwC8B;;AAAA,gDAhC1B,IAAIH,OAAJ,EAgC0B;;AAAA,kDA/BxB,IAAIA,OAAJ,EA+BwB;;AAC7CW,IAAAA,OAAO,GAAG;AAACC,MAAAA,IAAI,EAAE,GAAP;AAAYC,MAAAA,GAAG,EAAE,WAAjB;AAA8B,SAAGF;AAAjC,KAAV;AAOA,SAAKG,IAAL,GAAYH,OAAO,CAACG,IAApB;AACA,SAAKC,KAAL,GAAaC,SAAb;AAOA,S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C;;AAEA,MACE5C,GAAG,KAAK4C,OAAO,CAAC3C,IAAhB,IACAC,MAAM,KAAK0C,OAAO,CAACzC,OADnB,IAEAR,IAAI,KAAKiD,OAAO,CAAChD,KAFjB,IAGAE,KAAK,KAAK8C,OAAO,CAAC7C,MAHlB,IAIAN,IAAI,KAAKmD,OAAO,CAACxC,KAJjB,IAKAV,GAAG,KAAKkD,OAAO,CAACvC,IANlB,EAOE;AACAvB,IAAAA,MAAM,CACJ8D,OAAO,CAACnD,IAAR,GAAe,CAAf,IAAoBmD,OAAO,CAACnD,IAAR,GAAemD,OAAO,CAAClD,GADvC,EAEJ,mDAFI,CAAN;AAKAkD,IAAAA,OAAO,CAAChD,KAAR,GAAgBD,IAAhB;AACAiD,IAAAA,OAAO,CAAC7C,MAAR,GAAiBD,KAAjB;AACA8C,IAAAA,OAAO,CAAC3C,IAAR,GAAeD,GAAf;AACA4C,IAAAA,OAAO,CAACzC,OAAR,GAAkBD,MAAlB;AACA0C,IAAAA,OAAO,CAACxC,KAAR,GAAgBX,IAAhB;AACAmD,IAAAA,OAAO,CAACvC,IAAR,GAAeX,GAAf;AACAkD,IAAAA,OAAO,CAACjC,kBAAR,GAA6B,IAAI9B,OAAJ,GAAc+D,OAAd,CAAsB;AACjDjD,MAAAA,IADiD;AAEjDG,MAAAA,KAFiD;AAGjDI,MAAAA,MAHiD;AAIjDF,MAAAA,GAJiD;AAKjDP,MAAAA,IALiD;AAMjDC,MAAAA;AANiD,KAAtB,CAA7B;AAQAkD,IAAAA,OAAO,CAAC/B,oBAAR,GAA+B,IAAIhC,OAAJ,GAAc+D,OAAd,CAAsB;AACnDjD,MAAAA,IADmD;AAEnDG,MAAAA,KAFmD;AAGnDI,MAAAA,MAHmD;AAInDF,MAAAA,GAJmD;AAKnDP,MAAAA,IALmD;AAMnDC,MAAAA,GAAG,EAAEmD;AAN8C,KAAtB,CAA/B;AAQD;AACF","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Note: This class is still an experimental export, mainly used by other test cases\n// - It has not been fully adapted to math.gl conventions\n// - Documentation has not been ported\n\n// @ts-nocheck\n\nimport {Vector3, Matrix4, assert} from '@math.gl/core';\nimport CullingVolume from './culling-volume';\nimport Plane from './plane';\n\nconst scratchPlaneUpVector = new Vector3();\nconst scratchPlaneRightVector = new Vector3();\nconst scratchPlaneNearCenter = new Vector3();\nconst scratchPlaneFarCenter = new Vector3();\nconst scratchPlaneNormal = new Vector3();\n\nexport default class PerspectiveOffCenterFrustum {\n left;\n _left;\n right;\n _right;\n top;\n _top;\n bottom;\n _bottom;\n near;\n _near;\n far;\n _far;\n _cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n ]);\n _perspectiveMatrix = new Matrix4();\n _infinitePerspective = new Matrix4();\n\n /**\n * The viewing frustum is defined by 6 planes.\n * Each plane is represented by a {@link Vector4} object, where the x, y, and z components\n * define the unit vector normal to the plane, and the w component is the distance of the\n * plane from the origin/camera position.\n *\n * @alias PerspectiveOffCenterFrustum\n * @constructor\n *\n * @param {Object} [options] An object with the following properties:\n * @param {Number} [options.left] The left clipping plane distance.\n * @param {Number} [options.right] The right clipping plane distance.\n * @param {Number} [options.top] The top clipping plane distance.\n * @param {Number} [options.bottom] The bottom clipping plane distance.\n * @param {Number} [options.near=1.0] The near clipping plane distance.\n * @param {Number} [options.far=500000000.0] The far clipping plane distance.\n *\n * @example\n * const frustum = new PerspectiveOffCenterFrustum({\n * left : -1.0,\n * right : 1.0,\n * top : 1.0,\n * bottom : -1.0,\n * near : 1.0,\n * far : 100.0\n * });\n *\n * @see PerspectiveFrustum\n */\n constructor(options: Record<string, any> = {}) {\n options = {near: 1.0, far: 500000000.0, ...options};\n\n /**\n * Defines the left clipping plane.\n * @type {Number}\n * @default undefined\n */\n this.left = options.left;\n this._left = undefined;\n\n /**\n * Defines the right clipping plane.\n * @type {Number}\n * @default undefined\n */\n this.right = options.right;\n this._right = undefined;\n\n /**\n * Defines the top clipping plane.\n * @type {Number}\n * @default undefined\n */\n this.top = options.top;\n this._top = undefined;\n\n /**\n * Defines the bottom clipping plane.\n * @type {Number}\n * @default undefined\n */\n this.bottom = options.bottom;\n this._bottom = undefined;\n\n /**\n * The distance of the near plane.\n * @type {Number}\n * @default 1.0\n */\n this.near = options.near;\n this._near = this.near;\n\n /**\n * The distance of the far plane.\n * @type {Number}\n * @default 500000000.0\n */\n this.far = options.far;\n this._far = this.far;\n }\n\n /**\n * Returns a duplicate of a PerspectiveOffCenterFrustum instance.\n * @returns {PerspectiveOffCenterFrustum} A new PerspectiveFrustum instance.\n * */\n clone() {\n return new PerspectiveOffCenterFrustum({\n right: this.right,\n left: this.left,\n top: this.top,\n bottom: this.bottom,\n near: this.near,\n far: this.far\n });\n }\n\n /**\n * Compares the provided PerspectiveOffCenterFrustum componentwise and returns\n * <code>true</code> if they are equal, <code>false</code> otherwise.\n *\n * @param {PerspectiveOffCenterFrustum} [other] The right hand side PerspectiveOffCenterFrustum.\n * @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.\n */\n equals(other) {\n return (\n other &&\n other instanceof PerspectiveOffCenterFrustum &&\n this.right === other.right &&\n this.left === other.left &&\n this.top === other.top &&\n this.bottom === other.bottom &&\n this.near === other.near &&\n this.far === other.far\n );\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum.\n * @memberof PerspectiveOffCenterFrustum.prototype\n * @type {Matrix4}\n *\n * @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix\n */\n get projectionMatrix() {\n update(this);\n return this._perspectiveMatrix;\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum with an infinite far plane.\n * @memberof PerspectiveOffCenterFrustum.prototype\n * @type {Matrix4}\n *\n * @see PerspectiveOffCenterFrustum#projectionMatrix\n */\n get infiniteProjectionMatrix() {\n update(this);\n return this._infinitePerspective;\n }\n\n /**\n * Creates a culling volume for this frustum.\n *\n * @param {Vector3} position The eye position.\n * @param {Vector3} direction The view direction.\n * @param {Vector3} up The up direction.\n * @returns {CullingVolume} A culling volume at the given position and orientation.\n *\n * @example\n * // Check if a bounding volume intersects the frustum.\n * const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);\n * const intersect = cullingVolume.computeVisibility(boundingVolume);\n */\n // eslint-disable-next-line complexity, max-statements\n computeCullingVolume(position, direction, up) {\n assert(position, 'position is required.');\n assert(direction, 'direction is required.');\n assert(up, 'up is required.');\n\n const planes = this._cullingVolume.planes;\n\n up = scratchPlaneUpVector.copy(up).normalize();\n const right = scratchPlaneRightVector.copy(direction).cross(up).normalize();\n\n const nearCenter = scratchPlaneNearCenter\n .copy(direction)\n .multiplyByScalar(this.near)\n .add(position);\n\n const farCenter = scratchPlaneFarCenter\n .copy(direction)\n .multiplyByScalar(this.far)\n .add(position);\n\n let normal = scratchPlaneNormal;\n\n // Left plane computation\n normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up);\n\n planes[0].fromPointNormal(position, normal);\n\n // Right plane computation\n normal\n .copy(right)\n .multiplyByScalar(this.right)\n .add(nearCenter)\n .subtract(position)\n .cross(up)\n .negate();\n\n planes[1].fromPointNormal(position, normal);\n\n // Bottom plane computation\n normal\n .copy(up)\n .multiplyByScalar(this.bottom)\n .add(nearCenter)\n .subtract(position)\n .cross(right)\n .negate();\n\n planes[2].fromPointNormal(position, normal);\n\n // Top plane computation\n normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right);\n\n planes[3].fromPointNormal(position, normal);\n\n normal = new Vector3().copy(direction);\n\n // Near plane computation\n planes[4].fromPointNormal(nearCenter, normal);\n\n // Far plane computation\n normal.negate();\n\n planes[5].fromPointNormal(farCenter, normal);\n\n return this._cullingVolume;\n }\n\n /**\n * Returns the pixel's width and height in meters.\n *\n * @param {Number} drawingBufferWidth The width of the drawing buffer.\n * @param {Number} drawingBufferHeight The height of the drawing buffer.\n * @param {Number} distance The distance to the near plane in meters.\n * @param {Vector2} result The object onto which to store the result.\n * @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.\n *\n * @exception {DeveloperError} drawingBufferWidth must be greater than zero.\n * @exception {DeveloperError} drawingBufferHeight must be greater than zero.\n *\n * @example\n * // Example 1\n * // Get the width and height of a pixel.\n * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());\n *\n * @example\n * // Example 2\n * // Get the width and height of a pixel if the near plane was set to 'distance'.\n * // For example, get the size of a pixel of an image on a billboard.\n * const position = camera.position;\n * const direction = camera.direction;\n * const toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive\n * const toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector\n * const distance = Vector3.magnitude(toCenterProj);\n * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());\n */\n getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {\n update(this);\n\n assert(Number.isFinite(drawingBufferWidth) && Number.isFinite(drawingBufferHeight));\n // 'Both drawingBufferWidth and drawingBufferHeight are required.'\n assert(drawingBufferWidth > 0);\n // 'drawingBufferWidth must be greater than zero.'\n assert(drawingBufferHeight > 0);\n // 'drawingBufferHeight must be greater than zero.'\n assert(distance > 0);\n // 'distance is required.');\n assert(result);\n // 'A result object is required.');\n\n const inverseNear = 1.0 / this.near;\n let tanTheta = this.top * inverseNear;\n const pixelHeight = (2.0 * distance * tanTheta) / drawingBufferHeight;\n tanTheta = this.right * inverseNear;\n const pixelWidth = (2.0 * distance * tanTheta) / drawingBufferWidth;\n\n result.x = pixelWidth;\n result.y = pixelHeight;\n return result;\n }\n}\n\n// eslint-disable-next-line complexity, max-statements\nfunction update(frustum) {\n assert(\n Number.isFinite(frustum.right) &&\n Number.isFinite(frustum.left) &&\n Number.isFinite(frustum.top) &&\n Number.isFinite(frustum.bottom) &&\n Number.isFinite(frustum.near) &&\n Number.isFinite(frustum.far)\n );\n // throw new DeveloperError('right, left, top, bottom, near, or far parameters are not set.');\n\n const {top, bottom, right, left, near, far} = frustum;\n\n if (\n top !== frustum._top ||\n bottom !== frustum._bottom ||\n left !== frustum._left ||\n right !== frustum._right ||\n near !== frustum._near ||\n far !== frustum._far\n ) {\n assert(\n frustum.near > 0 && frustum.near < frustum.far,\n 'near must be greater than zero and less than far.'\n );\n\n frustum._left = left;\n frustum._right = right;\n frustum._top = top;\n frustum._bottom = bottom;\n frustum._near = near;\n frustum._far = far;\n frustum._perspectiveMatrix = new Matrix4().frustum({\n left,\n right,\n bottom,\n top,\n near,\n far\n });\n frustum._infinitePerspective = new Matrix4().frustum({\n left,\n right,\n bottom,\n top,\n near,\n far: Infinity\n });\n }\n}\n"],"file":"perspective-off-center-frustum.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/perspective-off-center-frustum.ts"],"names":["Vector3","Matrix4","assert","CullingVolume","Plane","scratchPlaneUpVector","scratchPlaneRightVector","scratchPlaneNearCenter","scratchPlaneFarCenter","scratchPlaneNormal","PerspectiveOffCenterFrustum","constructor","options","near","far","left","_left","undefined","right","_right","top","_top","bottom","_bottom","_near","_far","clone","equals","other","projectionMatrix","_update","_perspectiveMatrix","infiniteProjectionMatrix","_infinitePerspective","computeCullingVolume","position","direction","up","planes","_cullingVolume","copy","normalize","cross","nearCenter","multiplyByScalar","add","farCenter","normal","subtract","fromPointNormal","negate","getPixelDimensions","drawingBufferWidth","drawingBufferHeight","distance","result","Number","isFinite","inverseNear","tanTheta","pixelHeight","pixelWidth","x","y","frustum","Infinity"],"mappings":";AAOA,SAAQA,OAAR,EAA0BC,OAA1B,EAAmCC,MAAnC,QAA8D,eAA9D;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,KAAP,MAAkB,S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AL,GAAYX,GAAZ;AACA,WAAKiB,kBAAL,GAA0B,IAAI9B,OAAJ,GAAc+D,OAAd,CAAsB;AAC9CjD,QAAAA,IAD8C;AAE9CG,QAAAA,KAF8C;AAG9CI,QAAAA,MAH8C;AAI9CF,QAAAA,GAJ8C;AAK9CP,QAAAA,IAL8C;AAM9CC,QAAAA;AAN8C,OAAtB,CAA1B;AAQA,WAAKmB,oBAAL,GAA4B,IAAIhC,OAAJ,GAAc+D,OAAd,CAAsB;AAChDjD,QAAAA,IADgD;AAEhDG,QAAAA,KAFgD;AAGhDI,QAAAA,MAHgD;AAIhDF,QAAAA,GAJgD;AAKhDP,QAAAA,IALgD;AAMhDC,QAAAA,GAAG,EAAEmD;AAN2C,OAAtB,CAA5B;AAQD;AACF;;AA3V8C","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Note: This class is still an experimental export, mainly used by other test cases\n// - It has not been fully adapted to math.gl conventions\n// - Documentation has not been ported\n\nimport {Vector3, Vector2, Matrix4, assert, NumericArray} from '@math.gl/core';\nimport CullingVolume from './culling-volume';\nimport Plane from './plane';\n\nconst scratchPlaneUpVector = new Vector3();\nconst scratchPlaneRightVector = new Vector3();\nconst scratchPlaneNearCenter = new Vector3();\nconst scratchPlaneFarCenter = new Vector3();\nconst scratchPlaneNormal = new Vector3();\n\ntype PerspectiveOffCenterFrustumOptions = {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n near?: number;\n far?: number;\n};\n\nexport default class PerspectiveOffCenterFrustum {\n /**\n * Defines the left clipping plane.\n * @type {Number}\n * @default undefined\n */\n left?: number;\n private _left?: number;\n /**\n * Defines the right clipping plane.\n * @type {Number}\n * @default undefined\n */\n right?: number;\n private _right?: number;\n /**\n * Defines the top clipping plane.\n * @type {Number}\n * @default undefined\n */\n top?: number;\n private _top?: number;\n /**\n * Defines the bottom clipping plane.\n * @type {Number}\n * @default undefined\n */\n bottom?: number;\n private _bottom?: number;\n /**\n * The distance of the near plane.\n * @type {Number}\n * @default 1.0\n */\n near: number;\n private _near: number;\n /**\n * The distance of the far plane.\n * @type {Number}\n * @default 500000000.0\n */\n far: number;\n private _far: number;\n\n private _cullingVolume = new CullingVolume([\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane(),\n new Plane()\n ]);\n private _perspectiveMatrix = new Matrix4();\n private _infinitePerspective = new Matrix4();\n\n /**\n * The viewing frustum is defined by 6 planes.\n * Each plane is represented by a {@link Vector4} object, where the x, y, and z components\n * define the unit vector normal to the plane, and the w component is the distance of the\n * plane from the origin/camera position.\n *\n * @alias PerspectiveOffCenterFrustum\n *\n * @example\n * const frustum = new PerspectiveOffCenterFrustum({\n * left : -1.0,\n * right : 1.0,\n * top : 1.0,\n * bottom : -1.0,\n * near : 1.0,\n * far : 100.0\n * });\n *\n * @see PerspectiveFrustum\n */\n constructor(options: PerspectiveOffCenterFrustumOptions = {}) {\n const {near = 1.0, far = 500000000.0} = options;\n\n this.left = options.left;\n this._left = undefined;\n\n this.right = options.right;\n this._right = undefined;\n\n this.top = options.top;\n this._top = undefined;\n\n this.bottom = options.bottom;\n this._bottom = undefined;\n\n this.near = near;\n this._near = near;\n\n this.far = far;\n this._far = far;\n }\n\n /**\n * Returns a duplicate of a PerspectiveOffCenterFrustum instance.\n * @returns {PerspectiveOffCenterFrustum} A new PerspectiveFrustum instance.\n * */\n clone(): PerspectiveOffCenterFrustum {\n return new PerspectiveOffCenterFrustum({\n right: this.right,\n left: this.left,\n top: this.top,\n bottom: this.bottom,\n near: this.near,\n far: this.far\n });\n }\n\n /**\n * Compares the provided PerspectiveOffCenterFrustum componentwise and returns\n * <code>true</code> if they are equal, <code>false</code> otherwise.\n *\n * @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.\n */\n equals(other: PerspectiveOffCenterFrustum): boolean {\n return (\n other &&\n other instanceof PerspectiveOffCenterFrustum &&\n this.right === other.right &&\n this.left === other.left &&\n this.top === other.top &&\n this.bottom === other.bottom &&\n this.near === other.near &&\n this.far === other.far\n );\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum.\n * @memberof PerspectiveOffCenterFrustum.prototype\n * @type {Matrix4}\n *\n * @see PerspectiveOffCenterFrustum#infiniteProjectionMatrix\n */\n get projectionMatrix(): Matrix4 {\n this._update();\n return this._perspectiveMatrix;\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum with an infinite far plane.\n * @memberof PerspectiveOffCenterFrustum.prototype\n * @type {Matrix4}\n *\n * @see PerspectiveOffCenterFrustum#projectionMatrix\n */\n get infiniteProjectionMatrix(): Matrix4 {\n this._update();\n return this._infinitePerspective;\n }\n\n /**\n * Creates a culling volume for this frustum.\n * @returns {CullingVolume} A culling volume at the given position and orientation.\n *\n * @example\n * // Check if a bounding volume intersects the frustum.\n * const cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);\n * const intersect = cullingVolume.computeVisibility(boundingVolume);\n */\n // eslint-disable-next-line complexity, max-statements\n computeCullingVolume(\n /** A Vector3 defines the eye position. */\n position: Readonly<NumericArray>,\n /** A Vector3 defines the view direction. */\n direction: Readonly<NumericArray>,\n /** A Vector3 defines the up direction. */\n up: Readonly<NumericArray>\n ): CullingVolume {\n assert(position, 'position is required.');\n assert(direction, 'direction is required.');\n assert(up, 'up is required.');\n\n const planes = this._cullingVolume.planes;\n\n up = scratchPlaneUpVector.copy(up).normalize();\n const right = scratchPlaneRightVector.copy(direction).cross(up).normalize();\n\n const nearCenter = scratchPlaneNearCenter\n .copy(direction)\n .multiplyByScalar(this.near)\n .add(position);\n\n const farCenter = scratchPlaneFarCenter\n .copy(direction)\n .multiplyByScalar(this.far)\n .add(position);\n\n let normal = scratchPlaneNormal;\n\n // Left plane computation\n normal.copy(right).multiplyByScalar(this.left).add(nearCenter).subtract(position).cross(up);\n\n planes[0].fromPointNormal(position, normal);\n\n // Right plane computation\n normal\n .copy(right)\n .multiplyByScalar(this.right)\n .add(nearCenter)\n .subtract(position)\n .cross(up)\n .negate();\n\n planes[1].fromPointNormal(position, normal);\n\n // Bottom plane computation\n normal\n .copy(up)\n .multiplyByScalar(this.bottom)\n .add(nearCenter)\n .subtract(position)\n .cross(right)\n .negate();\n\n planes[2].fromPointNormal(position, normal);\n\n // Top plane computation\n normal.copy(up).multiplyByScalar(this.top).add(nearCenter).subtract(position).cross(right);\n\n planes[3].fromPointNormal(position, normal);\n\n normal = new Vector3().copy(direction);\n\n // Near plane computation\n planes[4].fromPointNormal(nearCenter, normal);\n\n // Far plane computation\n normal.negate();\n\n planes[5].fromPointNormal(farCenter, normal);\n\n return this._cullingVolume;\n }\n\n /**\n * Returns the pixel's width and height in meters.\n *\n * @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.\n *\n * @exception {DeveloperError} drawingBufferWidth must be greater than zero.\n * @exception {DeveloperError} drawingBufferHeight must be greater than zero.\n *\n * @example\n * // Example 1\n * // Get the width and height of a pixel.\n * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());\n *\n * @example\n * // Example 2\n * // Get the width and height of a pixel if the near plane was set to 'distance'.\n * // For example, get the size of a pixel of an image on a billboard.\n * const position = camera.position;\n * const direction = camera.direction;\n * const toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive\n * const toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector\n * const distance = Vector3.magnitude(toCenterProj);\n * const pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());\n */\n getPixelDimensions(\n /** The width of the drawing buffer. */\n drawingBufferWidth: number,\n /** The height of the drawing buffer. */\n drawingBufferHeight: number,\n /** The distance to the near plane in meters. */\n distance: number,\n /** The object onto which to store the result. */\n result: Vector2\n ): Vector2 {\n this._update();\n\n assert(Number.isFinite(drawingBufferWidth) && Number.isFinite(drawingBufferHeight));\n // 'Both drawingBufferWidth and drawingBufferHeight are required.'\n assert(drawingBufferWidth > 0);\n // 'drawingBufferWidth must be greater than zero.'\n assert(drawingBufferHeight > 0);\n // 'drawingBufferHeight must be greater than zero.'\n assert(distance > 0);\n // 'distance is required.');\n assert(result);\n // 'A result object is required.');\n\n const inverseNear = 1.0 / this.near;\n let tanTheta = this.top * inverseNear;\n const pixelHeight = (2.0 * distance * tanTheta) / drawingBufferHeight;\n tanTheta = this.right * inverseNear;\n const pixelWidth = (2.0 * distance * tanTheta) / drawingBufferWidth;\n\n result.x = pixelWidth;\n result.y = pixelHeight;\n return result;\n }\n\n // eslint-disable-next-line complexity, max-statements\n private _update() {\n assert(\n Number.isFinite(this.right) &&\n Number.isFinite(this.left) &&\n Number.isFinite(this.top) &&\n Number.isFinite(this.bottom) &&\n Number.isFinite(this.near) &&\n Number.isFinite(this.far)\n );\n // throw new DeveloperError('right, left, top, bottom, near, or far parameters are not set.');\n\n const {top, bottom, right, left, near, far} = this;\n\n if (\n top !== this._top ||\n bottom !== this._bottom ||\n left !== this._left ||\n right !== this._right ||\n near !== this._near ||\n far !== this._far\n ) {\n assert(\n this.near > 0 && this.near < this.far,\n 'near must be greater than zero and less than far.'\n );\n\n this._left = left;\n this._right = right;\n this._top = top;\n this._bottom = bottom;\n this._near = near;\n this._far = far;\n this._perspectiveMatrix = new Matrix4().frustum({\n left,\n right,\n bottom,\n top,\n near,\n far\n });\n this._infinitePerspective = new Matrix4().frustum({\n left,\n right,\n bottom,\n top,\n near,\n far: Infinity\n });\n }\n }\n}\n"],"file":"perspective-off-center-frustum.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/plane.ts"],"names":["Vector3","equals","assert","scratchPosition","scratchNormal","Plane","constructor","normal","distance","fromNormalDistance","Number","isFinite","from","normalize","fromPointNormal","point","dot","fromCoefficients","a","b","c","d","set","len","clone","right","getPointDistance","transform","matrix4","copy","transformAsVector","scale","projectPointOntoPlane","result","pointDistance","scaledNormal","subtract","to"],"mappings":";AAIA,SAAQA,OAAR,EAAiBC,MAAjB,EAAyBC,MAAzB,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/plane.ts"],"names":["Vector3","equals","assert","scratchPosition","scratchNormal","Plane","constructor","normal","distance","fromNormalDistance","Number","isFinite","from","normalize","fromPointNormal","point","dot","fromCoefficients","a","b","c","d","set","len","clone","right","getPointDistance","transform","matrix4","copy","transformAsVector","scale","projectPointOntoPlane","result","pointDistance","scaledNormal","subtract","to"],"mappings":";AAIA,SAAQA,OAAR,EAAiBC,MAAjB,EAAyBC,MAAzB,QAAoD,eAApD;AAEA,MAAMC,eAAe,GAAG,IAAIH,OAAJ,EAAxB;AACA,MAAMI,aAAa,GAAG,IAAIJ,OAAJ,EAAtB;AAGA,eAAe,MAAMK,KAAN,CAAY;AAIzBC,EAAAA,WAAW,CAACC,MAA8B,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAlC,EAA6CC,QAAgB,GAAG,CAAhE,EAAmE;AAAA;;AAAA;;AAC5E,SAAKD,MAAL,GAAc,IAAIP,OAAJ,EAAd;AACA,SAAKQ,QAAL,GAAgB,CAAC,CAAjB;AACA,SAAKC,kBAAL,CAAwBF,MAAxB,EAAgCC,QAAhC;AACD;;AAGDC,EAAAA,kBAAkB,CAACF,MAAD,EAAiCC,QAAjC,EAAyD;AACzEN,IAAAA,MAAM,CAACQ,MAAM,CAACC,QAAP,CAAgBH,QAAhB,CAAD,CAAN;AACA,SAAKD,MAAL,CAAYK,IAAZ,CAAiBL,MAAjB,EAAyBM,SAAzB;AACA,SAAKL,QAAL,GAAgBA,QAAhB;AACA,WAAO,IAAP;AACD;;AAGDM,EAAAA,eAAe,CAACC,KAAD,EAAgCR,MAAhC,EAAsE;AACnFQ,IAAAA,KAAK,GAAGZ,eAAe,CAACS,IAAhB,CAAqBG,KAArB,CAAR;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;AACA,WAAO,KAAKd,eAAL,CAAqBC,KAArB,EAA4BR,MAA5B,CAAP;AACD;;AASDyB,EAAAA,qBAAqB,CAACjB,KAAD,EAAQkB,MAAM,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAjB,EAA4B;AAC/ClB,IAAAA,KAAK,GAAGZ,eAAe,CAACS,IAAhB,CAAqBG,KAArB,CAAR;AAEA,UAAMmB,aAAa,GAAG,KAAKR,gBAAL,CAAsBX,KAAtB,CAAtB;AACA,UAAMoB,YAAY,GAAG/B,aAAa,CAACyB,IAAd,CAAmB,KAAKtB,MAAxB,EAAgCwB,KAAhC,CAAsCG,aAAtC,CAArB;AAEA,WAAOnB,KAAK,CAACqB,QAAN,CAAeD,YAAf,EAA6BE,EAA7B,CAAgCJ,MAAhC,CAAP;AACD;;AAzEwB","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Vector3, equals, assert, NumericArray} from '@math.gl/core';\n\nconst scratchPosition = new Vector3();\nconst scratchNormal = new Vector3();\n\n// A plane in Hessian Normal Form\nexport default class Plane {\n readonly normal: Vector3;\n distance: number;\n\n constructor(normal: Readonly<NumericArray> = [0, 0, 1], distance: number = 0) {\n this.normal = new Vector3();\n this.distance = -0;\n this.fromNormalDistance(normal, distance);\n }\n\n /** Creates a plane from a normal and a distance from the origin. */\n fromNormalDistance(normal: Readonly<NumericArray>, distance: number): this {\n assert(Number.isFinite(distance));\n this.normal.from(normal).normalize();\n this.distance = distance;\n return this;\n }\n\n /** Creates a plane from a normal and a point on the plane. */\n fromPointNormal(point: Readonly<NumericArray>, normal: Readonly<NumericArray>): this {\n point = scratchPosition.from(point);\n this.normal.from(normal).normalize();\n const distance = -this.normal.dot(point);\n this.distance = distance;\n return this;\n }\n\n /** Creates a plane from the general equation */\n fromCoefficients(a: number, b: number, c: number, d: number): this {\n this.normal.set(a, b, c);\n assert(equals(this.normal.len(), 1));\n this.distance = d;\n return this;\n }\n\n /** Duplicates a Plane instance. */\n clone(): Plane {\n return new Plane(this.normal, this.distance);\n }\n\n /** Compares the provided Planes by normal and distance */\n equals(right: Plane): boolean {\n return equals(this.distance, right.distance) && equals(this.normal, right.normal);\n }\n\n /** Computes the signed shortest distance of a point to a plane.\n * The sign of the distance determines which side of the plane the point is on.\n */\n getPointDistance(point: Readonly<NumericArray>): number {\n return this.normal.dot(point) + this.distance;\n }\n\n /** Transforms the plane by the given transformation matrix. */\n transform(matrix4: Readonly<NumericArray>): this {\n const normal = scratchNormal.copy(this.normal).transformAsVector(matrix4).normalize();\n const point = this.normal.scale(-this.distance).transform(matrix4);\n return this.fromPointNormal(point, normal);\n }\n\n /** Projects a point onto the plane. */\n projectPointOntoPlane(point: Readonly<NumericArray>, result: Vector3): Vector3;\n projectPointOntoPlane(\n point: Readonly<NumericArray>,\n result?: readonly number[]\n ): readonly number[];\n\n projectPointOntoPlane(point, result = [0, 0, 0]) {\n point = scratchPosition.from(point);\n // projectedPoint = point - (normal.point + scale) * normal\n const pointDistance = this.getPointDistance(point);\n const scaledNormal = scratchNormal.copy(this.normal).scale(pointDistance);\n\n return point.subtract(scaledNormal).to(result);\n }\n}\n"],"file":"plane.js"}
|
|
@@ -37,7 +37,7 @@ export default class AxisAlignedBoundingBox implements BoundingVolume {
|
|
|
37
37
|
* @param {AxisAlignedBoundingBox} [right] The second AxisAlignedBoundingBox to compare with.
|
|
38
38
|
* @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
|
|
39
39
|
*/
|
|
40
|
-
equals(right:
|
|
40
|
+
equals(right: AxisAlignedBoundingBox): boolean;
|
|
41
41
|
/**
|
|
42
42
|
* Applies a 4x4 affine transformation matrix to a bounding sphere.
|
|
43
43
|
* @param transform The transformation matrix to apply to the bounding sphere.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axis-aligned-bounding-box.d.ts","sourceRoot":"","sources":["../../../src/lib/bounding-volumes/axis-aligned-bounding-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAK7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,cAAc;IACnE,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;;OAKG;gBAED,OAAO,GAAE,SAAS,MAAM,EAAc,EACtC,OAAO,GAAE,SAAS,MAAM,EAAc,EACtC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE;IAsB5B;;;;OAIG;IACH,KAAK;
|
|
1
|
+
{"version":3,"file":"axis-aligned-bounding-box.d.ts","sourceRoot":"","sources":["../../../src/lib/bounding-volumes/axis-aligned-bounding-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAK7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,YAAW,cAAc;IACnE,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,sDAAsD;IACtD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;;OAKG;gBAED,OAAO,GAAE,SAAS,MAAM,EAAc,EACtC,OAAO,GAAE,SAAS,MAAM,EAAc,EACtC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE;IAsB5B;;;;OAIG;IACH,KAAK,IAAI,sBAAsB;IAI/B;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO;IAO9C;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAS7C;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY;IAqB1C,2FAA2F;IAC3F,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAI5C,mGAAmG;IACnG,iBAAiB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;CAwBpD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3, Matrix3, Quaternion } from '@math.gl/core';
|
|
1
|
+
import { Vector3, Matrix3, Matrix4, Quaternion } from '@math.gl/core';
|
|
2
2
|
import type { BoundingVolume } from './bounding-volume';
|
|
3
3
|
import BoundingSphere from './bounding-sphere';
|
|
4
4
|
import type Plane from '../plane';
|
|
@@ -62,6 +62,6 @@ export default class OrientedBoundingBox implements BoundingVolume {
|
|
|
62
62
|
* @returns itself, i.e. the modified BoundingVolume.
|
|
63
63
|
*/
|
|
64
64
|
transform(transformation: readonly number[]): this;
|
|
65
|
-
getTransform():
|
|
65
|
+
getTransform(): Matrix4;
|
|
66
66
|
}
|
|
67
67
|
//# sourceMappingURL=oriented-bounding-box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oriented-bounding-box.d.ts","sourceRoot":"","sources":["../../../src/lib/bounding-volumes/oriented-bounding-box.ts"],"names":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AAM,EAAE,GAAG,MAAM;IAI5C;;;;OAIG;IACH,iBAAiB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;IAwCnD;;;;;;;;;;;;;OAaG;IAEH,qBAAqB,CACnB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,SAAS,EAAE,OAAO,EAClB,MAAM,GAAE,MAAM,EAAa,GAC1B,MAAM,EAAE;IAwFX;;;;OAIG;IACH,SAAS,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAgBlD,YAAY,IAAI,OAAO;CAKxB"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { Matrix4 } from '@math.gl/core';
|
|
2
|
-
import
|
|
1
|
+
import { Matrix4, NumericArray, Vector2 } from '@math.gl/core';
|
|
2
|
+
import CullingVolume from './culling-volume';
|
|
3
|
+
declare type PerspectiveFrustumOptions = {
|
|
4
|
+
/** The angle of the field of view (FOV), in radians. */
|
|
5
|
+
fov?: number;
|
|
6
|
+
/** The aspect ratio of the frustum's width to it's height. */
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
/** The distance of the near plane. */
|
|
9
|
+
near?: number;
|
|
10
|
+
/** The distance of the far plane. */
|
|
11
|
+
far?: number;
|
|
12
|
+
/** The offset in the x direction. */
|
|
13
|
+
xOffset?: number;
|
|
14
|
+
/** The offset in the y direction. */
|
|
15
|
+
yOffset?: number;
|
|
16
|
+
};
|
|
3
17
|
/**
|
|
4
18
|
* The viewing frustum is defined by 6 planes.
|
|
5
19
|
* Each plane is represented by a {@link Vector4} object, where the x, y, and z components
|
|
@@ -7,15 +21,6 @@ import PerspectiveOffCenterFrustum from './perspective-off-center-frustum';
|
|
|
7
21
|
* plane from the origin/camera position.
|
|
8
22
|
*
|
|
9
23
|
* @alias PerspectiveFrustum
|
|
10
|
-
* @constructor
|
|
11
|
-
*
|
|
12
|
-
* @param {Object} [options] An object with the following properties:
|
|
13
|
-
* @param {Number} [options.fov] The angle of the field of view (FOV), in radians.
|
|
14
|
-
* @param {Number} [options.aspectRatio] The aspect ratio of the frustum's width to it's height.
|
|
15
|
-
* @param {Number} [options.near=1.0] The distance of the near plane.
|
|
16
|
-
* @param {Number} [options.far=500000000.0] The distance of the far plane.
|
|
17
|
-
* @param {Number} [options.xOffset=0.0] The offset in the x direction.
|
|
18
|
-
* @param {Number} [options.yOffset=0.0] The offset in the y direction.
|
|
19
24
|
*
|
|
20
25
|
* @example
|
|
21
26
|
* var frustum = new PerspectiveFrustum({
|
|
@@ -28,46 +33,46 @@ import PerspectiveOffCenterFrustum from './perspective-off-center-frustum';
|
|
|
28
33
|
* @see PerspectiveOffCenterFrustum
|
|
29
34
|
*/
|
|
30
35
|
export default class PerspectiveFrustum {
|
|
31
|
-
_offCenterFrustum
|
|
36
|
+
private _offCenterFrustum;
|
|
32
37
|
/**
|
|
33
38
|
* The angle of the field of view (FOV), in radians. This angle will be used
|
|
34
39
|
* as the horizontal FOV if the width is greater than the height, otherwise
|
|
35
40
|
* it will be the vertical FOV.
|
|
36
41
|
*/
|
|
37
|
-
fov
|
|
38
|
-
_fov
|
|
39
|
-
_fovy
|
|
40
|
-
_sseDenominator
|
|
42
|
+
fov?: number;
|
|
43
|
+
private _fov;
|
|
44
|
+
private _fovy;
|
|
45
|
+
private _sseDenominator;
|
|
41
46
|
/**
|
|
42
47
|
* The aspect ratio of the frustum's width to it's height.
|
|
43
48
|
*/
|
|
44
|
-
aspectRatio
|
|
45
|
-
_aspectRatio
|
|
49
|
+
aspectRatio?: number;
|
|
50
|
+
private _aspectRatio;
|
|
46
51
|
/**
|
|
47
52
|
* The distance of the near plane.
|
|
48
53
|
* @default 1.0
|
|
49
54
|
*/
|
|
50
55
|
near: number;
|
|
51
|
-
_near
|
|
56
|
+
private _near;
|
|
52
57
|
/**
|
|
53
58
|
* The distance of the far plane.
|
|
54
59
|
* @default 500000000.0
|
|
55
60
|
*/
|
|
56
61
|
far: number;
|
|
57
|
-
_far
|
|
62
|
+
private _far;
|
|
58
63
|
/**
|
|
59
64
|
* Offsets the frustum in the x direction.
|
|
60
65
|
* @default 0.0
|
|
61
66
|
*/
|
|
62
67
|
xOffset: number;
|
|
63
|
-
_xOffset
|
|
68
|
+
private _xOffset;
|
|
64
69
|
/**
|
|
65
70
|
* Offsets the frustum in the y direction.
|
|
66
71
|
* @default 0.0
|
|
67
72
|
*/
|
|
68
73
|
yOffset: number;
|
|
69
|
-
_yOffset
|
|
70
|
-
constructor(options?:
|
|
74
|
+
private _yOffset;
|
|
75
|
+
constructor(options?: PerspectiveFrustumOptions);
|
|
71
76
|
/**
|
|
72
77
|
* Returns a duplicate of a PerspectiveFrustum instance.
|
|
73
78
|
*/
|
|
@@ -78,7 +83,7 @@ export default class PerspectiveFrustum {
|
|
|
78
83
|
*/
|
|
79
84
|
equals(other: PerspectiveFrustum): boolean;
|
|
80
85
|
/**
|
|
81
|
-
* Gets the perspective projection matrix computed from the view
|
|
86
|
+
* Gets the perspective projection matrix computed from the view this.
|
|
82
87
|
*/
|
|
83
88
|
get projectionMatrix(): Matrix4;
|
|
84
89
|
/**
|
|
@@ -94,26 +99,23 @@ export default class PerspectiveFrustum {
|
|
|
94
99
|
*/
|
|
95
100
|
get sseDenominator(): number;
|
|
96
101
|
/**
|
|
97
|
-
* Creates a culling volume for this
|
|
98
|
-
*
|
|
99
|
-
* @param {Vector3} position The eye position.
|
|
100
|
-
* @param {Vector3} direction The view direction.
|
|
101
|
-
* @param {Vector3} up The up direction.
|
|
102
|
+
* Creates a culling volume for this this.ion.
|
|
102
103
|
* @returns {CullingVolume} A culling volume at the given position and orientation.
|
|
103
104
|
*
|
|
104
105
|
* @example
|
|
105
|
-
* // Check if a bounding volume intersects the
|
|
106
|
-
* var cullingVolume =
|
|
106
|
+
* // Check if a bounding volume intersects the this.
|
|
107
|
+
* var cullingVolume = this.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);
|
|
107
108
|
* var intersect = cullingVolume.computeVisibility(boundingVolume);
|
|
108
109
|
*/
|
|
109
|
-
computeCullingVolume(
|
|
110
|
+
computeCullingVolume(
|
|
111
|
+
/** A Vector3 defines the eye position. */
|
|
112
|
+
position: Readonly<NumericArray>,
|
|
113
|
+
/** A Vector3 defines the view direction. */
|
|
114
|
+
direction: Readonly<NumericArray>,
|
|
115
|
+
/** A Vector3 defines the up direction. */
|
|
116
|
+
up: Readonly<NumericArray>): CullingVolume;
|
|
110
117
|
/**
|
|
111
118
|
* Returns the pixel's width and height in meters.
|
|
112
|
-
*
|
|
113
|
-
* @param {Number} drawingBufferWidth The width of the drawing buffer.
|
|
114
|
-
* @param {Number} drawingBufferHeight The height of the drawing buffer.
|
|
115
|
-
* @param {Number} distance The distance to the near plane in meters.
|
|
116
|
-
* @param {Vector2} result The object onto which to store the result.
|
|
117
119
|
* @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.
|
|
118
120
|
*
|
|
119
121
|
* @exception {DeveloperError} drawingBufferWidth must be greater than zero.
|
|
@@ -122,7 +124,7 @@ export default class PerspectiveFrustum {
|
|
|
122
124
|
* @example
|
|
123
125
|
* // Example 1
|
|
124
126
|
* // Get the width and height of a pixel.
|
|
125
|
-
* var pixelSize = camera.
|
|
127
|
+
* var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());
|
|
126
128
|
*
|
|
127
129
|
* @example
|
|
128
130
|
* // Example 2
|
|
@@ -133,8 +135,18 @@ export default class PerspectiveFrustum {
|
|
|
133
135
|
* var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive
|
|
134
136
|
* var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector
|
|
135
137
|
* var distance = Vector3.magnitude(toCenterProj);
|
|
136
|
-
* var pixelSize = camera.
|
|
138
|
+
* var pixelSize = camera.this.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());
|
|
137
139
|
*/
|
|
138
|
-
getPixelDimensions(
|
|
140
|
+
getPixelDimensions(
|
|
141
|
+
/** The width of the drawing buffer. */
|
|
142
|
+
drawingBufferWidth: number,
|
|
143
|
+
/** The height of the drawing buffer. */
|
|
144
|
+
drawingBufferHeight: number,
|
|
145
|
+
/** The distance to the near plane in meters. */
|
|
146
|
+
distance: number,
|
|
147
|
+
/** The object onto which to store the result. */
|
|
148
|
+
result?: Vector2): Vector2;
|
|
149
|
+
private _update;
|
|
139
150
|
}
|
|
151
|
+
export {};
|
|
140
152
|
//# sourceMappingURL=perspective-frustum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"perspective-frustum.d.ts","sourceRoot":"","sources":["../../src/lib/perspective-frustum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"perspective-frustum.d.ts","sourceRoot":"","sources":["../../src/lib/perspective-frustum.ts"],"names":[],"mappings":"AAOA,OAAO,EAAS,OAAO,EAAE,YAAY,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAErE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAI7C,aAAK,yBAAyB,GAAG;IAC/B,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC,OAAO,CAAC,iBAAiB,CAAqC;IAC9D;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,IAAI,CA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