@vertexvis/viewer 0.10.2-canary.7 → 0.11.0
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/cjs/{browser.esm-ae55f058.js → browser.esm-17419694.js} +25 -25
- package/dist/cjs/{bundle.esm-c457ad4d.js → bundle.esm-b79513ef.js} +231 -207
- package/dist/cjs/{constants-4277684a.js → constants-1d65ed39.js} +1 -1
- package/dist/cjs/{cursors-b93b43ef.js → cursors-8aaf500f.js} +1 -1
- package/dist/cjs/{dom-cdb50ebc.js → dom-40804039.js} +1 -1
- package/dist/cjs/index.cjs.js +8 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{markup-3dac4cef.js → markup-e84a143f.js} +11 -2
- package/dist/cjs/{measurement-b494bf55.js → measurement-4579193b.js} +2 -2
- package/dist/cjs/{orientation-42cc9e8d.js → orientation-09d0f3ef.js} +14 -7
- package/dist/cjs/{png-decoder-2add73dd.js → png-decoder-97ea96ba.js} +3 -3
- package/dist/cjs/{scene-23a0a330.js → scene-4397373a.js} +28524 -2446
- package/dist/cjs/{utils-6933381f.js → utils-414e6cfe.js} +2 -2
- package/dist/cjs/utils-440f0f7d.js +61 -0
- package/dist/cjs/vertex-scene-tree.cjs.entry.js +6 -5
- package/dist/cjs/vertex-viewer-dom-element_3.cjs.entry.js +4 -4
- package/dist/cjs/{vertex-viewer-markup-arrow_2.cjs.entry.js → vertex-viewer-markup-arrow_3.cjs.entry.js} +267 -4
- package/dist/cjs/vertex-viewer-markup-tool.cjs.entry.js +43 -9
- package/dist/cjs/vertex-viewer-markup.cjs.entry.js +25 -5
- package/dist/cjs/vertex-viewer-measurement-distance_2.cjs.entry.js +8 -8
- package/dist/cjs/vertex-viewer-measurement-tool.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-measurements.cjs.entry.js +5 -5
- package/dist/cjs/vertex-viewer-view-cube.cjs.entry.js +3 -3
- package/dist/cjs/vertex-viewer.cjs.entry.js +141 -48
- package/dist/cjs/viewer.cjs.js +1 -1
- package/dist/cjs/{viewport-e69f8223.js → viewport-fc405a48.js} +31 -7
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/scene-tree/scene-tree.js +3 -2
- package/dist/collection/components/viewer/viewer.js +28 -3
- package/dist/collection/components/viewer-markup/utils.js +65 -1
- package/dist/collection/components/viewer-markup/viewer-markup.js +72 -16
- package/dist/collection/components/viewer-markup-circle/utils.js +2 -55
- package/dist/collection/components/viewer-markup-circle/viewer-markup-circle.js +4 -4
- package/dist/collection/components/viewer-markup-freeform.tsx/utils.js +10 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.css +157 -0
- package/dist/collection/components/viewer-markup-freeform.tsx/viewer-markup-freeform.js +413 -0
- package/dist/collection/components/viewer-markup-tool/viewer-markup-tool.js +63 -9
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance-components.js +1 -1
- package/dist/collection/components/viewer-measurement-distance/viewer-measurement-distance.js +2 -2
- package/dist/collection/lib/cursors.js +1 -1
- package/dist/collection/lib/interactions/baseInteractionHandler.js +5 -4
- package/dist/collection/lib/interactions/flyToPartKeyInteraction.js +1 -1
- package/dist/collection/lib/interactions/interactionApi.js +101 -22
- package/dist/collection/lib/interactions/mouseInteractions.js +17 -15
- package/dist/collection/lib/interactions/multiTouchInteractionHandler.js +2 -2
- package/dist/collection/lib/mappers.js +4 -3
- package/dist/collection/lib/scenes/camera.js +8 -2
- package/dist/collection/lib/scenes/operations.js +1 -1
- package/dist/collection/lib/scenes/scene.js +5 -2
- package/dist/collection/lib/types/frame.js +8 -2
- package/dist/collection/lib/types/markup.js +9 -1
- package/dist/collection/lib/types/stencilBuffer.js +2 -2
- package/dist/collection/lib/types/viewport.js +32 -8
- package/dist/collection/testing/fixtures.js +2 -1
- package/dist/esm/{browser.esm-7dbdf78a.js → browser.esm-e4fb17dc.js} +25 -25
- package/dist/esm/{bundle.esm-590d2273.js → bundle.esm-d891316f.js} +232 -208
- package/dist/esm/{constants-083f6b2c.js → constants-037e417f.js} +1 -1
- package/dist/esm/{cursors-39294365.js → cursors-00835249.js} +1 -1
- package/dist/esm/{dom-43682375.js → dom-d0877f90.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/{markup-3ce3dccd.js → markup-9b29aa94.js} +11 -3
- package/dist/esm/{measurement-78bd27fc.js → measurement-8430d5d6.js} +2 -2
- package/dist/esm/{orientation-c3e2af18.js → orientation-bb34b652.js} +14 -7
- package/dist/esm/{png-decoder-dfb97536.js → png-decoder-c4745070.js} +3 -3
- package/dist/esm/{scene-30ac6229.js → scene-72760305.js} +28532 -2454
- package/dist/esm/utils-5fe43b8a.js +52 -0
- package/dist/esm/{utils-b857bd7c.js → utils-f8e0baf7.js} +2 -2
- package/dist/esm/vertex-scene-tree.entry.js +6 -5
- package/dist/esm/vertex-viewer-dom-element_3.entry.js +4 -4
- package/dist/esm/{vertex-viewer-markup-arrow_2.entry.js → vertex-viewer-markup-arrow_3.entry.js} +267 -5
- package/dist/esm/vertex-viewer-markup-tool.entry.js +43 -9
- package/dist/esm/vertex-viewer-markup.entry.js +25 -5
- package/dist/esm/vertex-viewer-measurement-distance_2.entry.js +8 -8
- package/dist/esm/vertex-viewer-measurement-tool.entry.js +5 -5
- package/dist/esm/vertex-viewer-measurements.entry.js +5 -5
- package/dist/esm/vertex-viewer-view-cube.entry.js +3 -3
- package/dist/esm/vertex-viewer.entry.js +141 -48
- package/dist/esm/viewer.js +1 -1
- package/dist/esm/{viewport-8fea0743.js → viewport-d6f5cd7b.js} +31 -7
- package/dist/types/components/viewer/viewer.d.ts +4 -0
- package/dist/types/components/viewer-markup/utils.d.ts +8 -0
- package/dist/types/components/viewer-markup/viewer-markup.d.ts +13 -6
- package/dist/types/components/viewer-markup-circle/utils.d.ts +1 -4
- package/dist/types/components/viewer-markup-freeform.tsx/utils.d.ts +3 -0
- package/dist/types/components/viewer-markup-freeform.tsx/viewer-markup-freeform.d.ts +116 -0
- package/dist/types/components/viewer-markup-tool/viewer-markup-tool.d.ts +13 -1
- package/dist/types/components.d.ts +107 -10
- package/dist/types/lib/interactions/interactionApi.d.ts +22 -6
- package/dist/types/lib/interactions/mouseInteractions.d.ts +7 -6
- package/dist/types/lib/scenes/camera.d.ts +5 -1
- package/dist/types/lib/scenes/scene.d.ts +1 -1
- package/dist/types/lib/types/frame.d.ts +4 -1
- package/dist/types/lib/types/markup.d.ts +12 -1
- package/dist/types/lib/types/viewport.d.ts +17 -0
- package/dist/viewer/index.esm.js +1 -1
- package/dist/viewer/p-012fb54f.js +4 -0
- package/dist/viewer/{p-3dc15d99.entry.js → p-117324c0.entry.js} +1 -1
- package/dist/viewer/{p-1ee75110.entry.js → p-1c772ec1.entry.js} +1 -1
- package/dist/viewer/p-1f8a238b.js +4 -0
- package/dist/viewer/p-21e8510d.js +4 -0
- package/dist/viewer/{p-e3105f9a.entry.js → p-3c2aff67.entry.js} +1 -1
- package/dist/viewer/p-5389e9d4.js +4 -0
- package/dist/viewer/p-59d075d4.js +17 -0
- package/dist/viewer/{p-5b078339.js → p-62c6f482.js} +1 -1
- package/dist/viewer/p-640cb5f8.js +18 -0
- package/dist/viewer/p-68aaf1f8.entry.js +4 -0
- package/dist/viewer/{p-05b2444e.js → p-75682963.js} +1 -1
- package/dist/viewer/{p-4183c421.entry.js → p-79c45c02.entry.js} +1 -1
- package/dist/viewer/p-835e158e.js +4 -0
- package/dist/viewer/p-8c255868.entry.js +4 -0
- package/dist/viewer/{p-f4a492e1.js → p-9faabd97.js} +1 -1
- package/dist/viewer/p-b122ee39.js +4 -0
- package/dist/viewer/p-b36b3d1a.js +4 -0
- package/dist/viewer/{p-7c71db57.entry.js → p-bc9e6919.entry.js} +1 -1
- package/dist/viewer/{p-f090a3f3.entry.js → p-c818c80e.entry.js} +1 -1
- package/dist/viewer/{p-e96bc9a2.js → p-d42a482c.js} +1 -1
- package/dist/viewer/p-f43e8cc2.entry.js +4 -0
- package/dist/viewer/p-f75436be.entry.js +4 -0
- package/dist/viewer/viewer.esm.js +1 -1
- package/package.json +18 -16
- package/readme.md +6 -6
- package/dist/cjs/utils-96f244e1.js +0 -104
- package/dist/esm/utils-a550c58f.js +0 -96
- package/dist/viewer/p-11bdd2c4.js +0 -4
- package/dist/viewer/p-14182324.entry.js +0 -4
- package/dist/viewer/p-2768474e.js +0 -4
- package/dist/viewer/p-2e11803d.js +0 -4
- package/dist/viewer/p-6d4ab5fc.js +0 -17
- package/dist/viewer/p-964642c6.js +0 -4
- package/dist/viewer/p-9e856d0a.entry.js +0 -4
- package/dist/viewer/p-a717d9ff.js +0 -4
- package/dist/viewer/p-a9434d8e.entry.js +0 -4
- package/dist/viewer/p-af806858.js +0 -4
- package/dist/viewer/p-b5c350a7.js +0 -4
- package/dist/viewer/p-d912dd24.js +0 -18
- package/dist/viewer/p-f6d75616.entry.js +0 -4
|
@@ -143,7 +143,7 @@ function clamp(value, min, max) {
|
|
|
143
143
|
* @param t The interpolation value between 0 and 1.
|
|
144
144
|
* @returns The interpolated value between `a` and `b`.
|
|
145
145
|
*/
|
|
146
|
-
function lerp(a, b, t) {
|
|
146
|
+
function lerp$2(a, b, t) {
|
|
147
147
|
t = clamp(t, 0, 1);
|
|
148
148
|
return t * (b - a) + a;
|
|
149
149
|
}
|
|
@@ -151,7 +151,7 @@ function lerp(a, b, t) {
|
|
|
151
151
|
/**
|
|
152
152
|
* Returns a new `Point` with the given horizontal and vertical position.
|
|
153
153
|
*/
|
|
154
|
-
function create(x, y) {
|
|
154
|
+
function create$b(x, y) {
|
|
155
155
|
if (x === void 0) { x = 0; }
|
|
156
156
|
if (y === void 0) { y = 0; }
|
|
157
157
|
return { x: x, y: y };
|
|
@@ -162,31 +162,31 @@ function create(x, y) {
|
|
|
162
162
|
function polar(length, radians) {
|
|
163
163
|
var x = Math.cos(radians) * length;
|
|
164
164
|
var y = Math.sin(radians) * length;
|
|
165
|
-
return create(x, y);
|
|
165
|
+
return create$b(x, y);
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* Returns the distance between two points.
|
|
169
169
|
*/
|
|
170
|
-
function distance(a, b) {
|
|
171
|
-
var delta = subtract(a, b);
|
|
170
|
+
function distance$2(a, b) {
|
|
171
|
+
var delta = subtract$1(a, b);
|
|
172
172
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* Returns a new `Point` where `b` is subtracted from `a`.
|
|
176
176
|
*/
|
|
177
|
-
function subtract(a, b) {
|
|
177
|
+
function subtract$1(a, b) {
|
|
178
178
|
return { x: a.x - b.x, y: a.y - b.y };
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* Returns a new `Point` where `b` is added to `a`.
|
|
182
182
|
*/
|
|
183
|
-
function add(a, b) {
|
|
183
|
+
function add$1(a, b) {
|
|
184
184
|
return { x: a.x + b.x, y: a.y + b.y };
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* Returns `true` if the `x` and `y` positions of `a` and `b` are equal.
|
|
188
188
|
*/
|
|
189
|
-
function isEqual(a, b) {
|
|
189
|
+
function isEqual$3(a, b) {
|
|
190
190
|
return a.x === b.x && a.y === b.y;
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
@@ -200,21 +200,21 @@ function isEqual(a, b) {
|
|
|
200
200
|
*/
|
|
201
201
|
function lerp$1(a, b, t) {
|
|
202
202
|
return {
|
|
203
|
-
x: lerp(a.x, b.x, t),
|
|
204
|
-
y: lerp(a.y, b.y, t),
|
|
203
|
+
x: lerp$2(a.x, b.x, t),
|
|
204
|
+
y: lerp$2(a.y, b.y, t),
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
208
|
* Returns a new `Point` where `x` and `y` are inverted.
|
|
209
209
|
*/
|
|
210
|
-
function negate(pt) {
|
|
211
|
-
return create(-pt.x, -pt.y);
|
|
210
|
+
function negate$1(pt) {
|
|
211
|
+
return create$b(-pt.x, -pt.y);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
215
215
|
* factors.
|
|
216
216
|
*/
|
|
217
|
-
function scale(pt, scaleX, scaleY) {
|
|
217
|
+
function scale$4(pt, scaleX, scaleY) {
|
|
218
218
|
return {
|
|
219
219
|
x: pt.x * scaleX,
|
|
220
220
|
y: pt.y * scaleY,
|
|
@@ -226,30 +226,30 @@ function scale(pt, scaleX, scaleY) {
|
|
|
226
226
|
* @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
|
|
227
227
|
* @returns A parsed Point.
|
|
228
228
|
*/
|
|
229
|
-
function fromJson(json) {
|
|
229
|
+
function fromJson$4(json) {
|
|
230
230
|
var obj = JSON.parse(json);
|
|
231
231
|
if (Array.isArray(obj)) {
|
|
232
232
|
var x = obj[0], y = obj[1];
|
|
233
|
-
return create(x, y);
|
|
233
|
+
return create$b(x, y);
|
|
234
234
|
}
|
|
235
235
|
else {
|
|
236
236
|
var x = obj.x, y = obj.y;
|
|
237
|
-
return create(x, y);
|
|
237
|
+
return create$b(x, y);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
var point = /*#__PURE__*/Object.freeze({
|
|
242
242
|
__proto__: null,
|
|
243
|
-
create: create,
|
|
243
|
+
create: create$b,
|
|
244
244
|
polar: polar,
|
|
245
|
-
distance: distance,
|
|
246
|
-
subtract: subtract,
|
|
247
|
-
add: add,
|
|
248
|
-
isEqual: isEqual,
|
|
245
|
+
distance: distance$2,
|
|
246
|
+
subtract: subtract$1,
|
|
247
|
+
add: add$1,
|
|
248
|
+
isEqual: isEqual$3,
|
|
249
249
|
lerp: lerp$1,
|
|
250
|
-
negate: negate,
|
|
251
|
-
scale: scale,
|
|
252
|
-
fromJson: fromJson
|
|
250
|
+
negate: negate$1,
|
|
251
|
+
scale: scale$4,
|
|
252
|
+
fromJson: fromJson$4
|
|
253
253
|
});
|
|
254
254
|
|
|
255
255
|
/**
|
|
@@ -259,8 +259,8 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
259
259
|
* @param b The ending point.
|
|
260
260
|
* @returns An angle in radians.
|
|
261
261
|
*/
|
|
262
|
-
function fromPoints(a, b) {
|
|
263
|
-
var delta = subtract(b, a);
|
|
262
|
+
function fromPoints$1(a, b) {
|
|
263
|
+
var delta = subtract$1(b, a);
|
|
264
264
|
var theta = Math.atan2(delta.y, delta.x);
|
|
265
265
|
return theta;
|
|
266
266
|
}
|
|
@@ -273,14 +273,14 @@ function fromPoints(a, b) {
|
|
|
273
273
|
* @deprecated Use {@link fromPoints} instead.
|
|
274
274
|
*/
|
|
275
275
|
function fromPointsInDegrees(a, b) {
|
|
276
|
-
var delta = subtract(b, a);
|
|
276
|
+
var delta = subtract$1(b, a);
|
|
277
277
|
var theta = Math.atan2(delta.y, delta.x);
|
|
278
|
-
return normalize(toDegrees(theta) - 270);
|
|
278
|
+
return normalize$1(toDegrees(theta) - 270);
|
|
279
279
|
}
|
|
280
280
|
/**
|
|
281
281
|
* Normalizes the given angle, in degrees, to a number between 0 and 359.
|
|
282
282
|
*/
|
|
283
|
-
function normalize(degrees) {
|
|
283
|
+
function normalize$1(degrees) {
|
|
284
284
|
return (degrees + 3600) % 360;
|
|
285
285
|
}
|
|
286
286
|
/**
|
|
@@ -298,9 +298,9 @@ function toRadians(degrees) {
|
|
|
298
298
|
|
|
299
299
|
var angle = /*#__PURE__*/Object.freeze({
|
|
300
300
|
__proto__: null,
|
|
301
|
-
fromPoints: fromPoints,
|
|
301
|
+
fromPoints: fromPoints$1,
|
|
302
302
|
fromPointsInDegrees: fromPointsInDegrees,
|
|
303
|
-
normalize: normalize,
|
|
303
|
+
normalize: normalize$1,
|
|
304
304
|
toDegrees: toDegrees,
|
|
305
305
|
toRadians: toRadians
|
|
306
306
|
});
|
|
@@ -428,7 +428,7 @@ function makeTRS(translation, rotation, scale) {
|
|
|
428
428
|
var t = makeTranslation(translation);
|
|
429
429
|
var r = makeRotation(rotation);
|
|
430
430
|
var s = makeScale(scale);
|
|
431
|
-
return multiply(multiply(t, r), s);
|
|
431
|
+
return multiply$2(multiply$2(t, r), s);
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
434
434
|
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
@@ -561,12 +561,12 @@ function makePerspective(near, far, fovY, aspect) {
|
|
|
561
561
|
* @returns A matrix.
|
|
562
562
|
*/
|
|
563
563
|
function makeLookAtView(position, lookAt, up) {
|
|
564
|
-
var z = normalize
|
|
565
|
-
var x = normalize
|
|
564
|
+
var z = normalize(subtract(position, lookAt));
|
|
565
|
+
var x = normalize(cross(up, z));
|
|
566
566
|
var y = cross(z, x);
|
|
567
|
-
var dotX = -dot(x, position);
|
|
568
|
-
var dotY = -dot(y, position);
|
|
569
|
-
var dotZ = -dot(z, position);
|
|
567
|
+
var dotX = -dot$1(x, position);
|
|
568
|
+
var dotY = -dot$1(y, position);
|
|
569
|
+
var dotZ = -dot$1(z, position);
|
|
570
570
|
/* eslint-disable prettier/prettier */
|
|
571
571
|
return [
|
|
572
572
|
x.x, y.x, z.x, 0,
|
|
@@ -590,8 +590,8 @@ function makeLookAtView(position, lookAt, up) {
|
|
|
590
590
|
* @returns A matrix.
|
|
591
591
|
*/
|
|
592
592
|
function makeLookAt(position, lookAt, up) {
|
|
593
|
-
var z = normalize
|
|
594
|
-
var x = normalize
|
|
593
|
+
var z = normalize(subtract(position, lookAt));
|
|
594
|
+
var x = normalize(cross(up, z));
|
|
595
595
|
var y = cross(z, x);
|
|
596
596
|
/* eslint-disable prettier/prettier */
|
|
597
597
|
return [
|
|
@@ -659,11 +659,11 @@ function invert(matrix) {
|
|
|
659
659
|
* @returns A rotation matrix.
|
|
660
660
|
*/
|
|
661
661
|
function lookAt(m, position, target, up) {
|
|
662
|
-
var z = subtract
|
|
662
|
+
var z = subtract(position, target);
|
|
663
663
|
if (magnitudeSquared(z) === 0) {
|
|
664
664
|
z = exports.__assign(exports.__assign({}, z), { z: 1 });
|
|
665
665
|
}
|
|
666
|
-
z = normalize
|
|
666
|
+
z = normalize(z);
|
|
667
667
|
var x = cross(up, z);
|
|
668
668
|
if (magnitudeSquared(x) === 0) {
|
|
669
669
|
if (Math.abs(up.z) === 1) {
|
|
@@ -672,10 +672,10 @@ function lookAt(m, position, target, up) {
|
|
|
672
672
|
else {
|
|
673
673
|
z = exports.__assign(exports.__assign({}, z), { z: z.z + 0.0001 });
|
|
674
674
|
}
|
|
675
|
-
z = normalize
|
|
675
|
+
z = normalize(z);
|
|
676
676
|
x = cross(up, z);
|
|
677
677
|
}
|
|
678
|
-
x = normalize
|
|
678
|
+
x = normalize(x);
|
|
679
679
|
var y = cross(z, x);
|
|
680
680
|
var res = __spreadArray([], m, true);
|
|
681
681
|
/* eslint-disable prettier/prettier */
|
|
@@ -694,7 +694,7 @@ function lookAt(m, position, target, up) {
|
|
|
694
694
|
/**
|
|
695
695
|
* Returns a post-multiplied matrix.
|
|
696
696
|
*/
|
|
697
|
-
function multiply(a, b) {
|
|
697
|
+
function multiply$2(a, b) {
|
|
698
698
|
var ae = a;
|
|
699
699
|
var be = b;
|
|
700
700
|
var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
|
|
@@ -741,7 +741,7 @@ function transpose(matrix) {
|
|
|
741
741
|
/**
|
|
742
742
|
* Multiplies the columns of a matrix by the given vector.
|
|
743
743
|
*/
|
|
744
|
-
function scale$
|
|
744
|
+
function scale$3(matrix, scale) {
|
|
745
745
|
var x = scale.x, y = scale.y, z = scale.z;
|
|
746
746
|
var m = __spreadArray([], matrix, true);
|
|
747
747
|
/* eslint-disable prettier/prettier */
|
|
@@ -783,7 +783,7 @@ function toObject(m) {
|
|
|
783
783
|
/**
|
|
784
784
|
* A type guard to check if `obj` is of type `Matrix4`.
|
|
785
785
|
*/
|
|
786
|
-
function isType(obj) {
|
|
786
|
+
function isType$2(obj) {
|
|
787
787
|
return Array.isArray(obj) && obj.length === 16;
|
|
788
788
|
}
|
|
789
789
|
|
|
@@ -805,15 +805,15 @@ var matrix4 = /*#__PURE__*/Object.freeze({
|
|
|
805
805
|
makeLookAt: makeLookAt,
|
|
806
806
|
invert: invert,
|
|
807
807
|
lookAt: lookAt,
|
|
808
|
-
multiply: multiply,
|
|
808
|
+
multiply: multiply$2,
|
|
809
809
|
transpose: transpose,
|
|
810
|
-
scale: scale$
|
|
810
|
+
scale: scale$3,
|
|
811
811
|
position: position,
|
|
812
812
|
toObject: toObject,
|
|
813
|
-
isType: isType
|
|
813
|
+
isType: isType$2
|
|
814
814
|
});
|
|
815
815
|
|
|
816
|
-
function create$
|
|
816
|
+
function create$a() {
|
|
817
817
|
var _a, _b, _c, _d, _e, _f;
|
|
818
818
|
var args = [];
|
|
819
819
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -873,15 +873,15 @@ function fromMatrixPosition(matrix) {
|
|
|
873
873
|
* @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
|
|
874
874
|
* @returns A parsed Vector3.
|
|
875
875
|
*/
|
|
876
|
-
function fromJson$
|
|
876
|
+
function fromJson$3(json) {
|
|
877
877
|
var obj = JSON.parse(json);
|
|
878
878
|
if (Array.isArray(obj)) {
|
|
879
879
|
var x = obj[0], y = obj[1], z = obj[2];
|
|
880
|
-
return create$
|
|
880
|
+
return create$a(x, y, z);
|
|
881
881
|
}
|
|
882
882
|
else {
|
|
883
883
|
var x = obj.x, y = obj.y, z = obj.z;
|
|
884
|
-
return create$
|
|
884
|
+
return create$a(x, y, z);
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
887
|
/**
|
|
@@ -896,7 +896,7 @@ function fromArray(nums, offset) {
|
|
|
896
896
|
var x = nums[offset];
|
|
897
897
|
var y = nums[offset + 1];
|
|
898
898
|
var z = nums[offset + 2];
|
|
899
|
-
return create$
|
|
899
|
+
return create$a(x, y, z);
|
|
900
900
|
}
|
|
901
901
|
/**
|
|
902
902
|
* Converts a Vector3 to an array where the values of the vector will be
|
|
@@ -913,48 +913,48 @@ function toArray(_a) {
|
|
|
913
913
|
* Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
|
|
914
914
|
*/
|
|
915
915
|
function right() {
|
|
916
|
-
return create$
|
|
916
|
+
return create$a(1, 0, 0);
|
|
917
917
|
}
|
|
918
918
|
/**
|
|
919
919
|
* Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
|
|
920
920
|
*/
|
|
921
921
|
function up() {
|
|
922
|
-
return create$
|
|
922
|
+
return create$a(0, 1, 0);
|
|
923
923
|
}
|
|
924
924
|
/**
|
|
925
925
|
* Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
|
|
926
926
|
*/
|
|
927
927
|
function forward() {
|
|
928
|
-
return create$
|
|
928
|
+
return create$a(0, 0, -1);
|
|
929
929
|
}
|
|
930
930
|
/**
|
|
931
931
|
* Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
|
|
932
932
|
*/
|
|
933
933
|
function left() {
|
|
934
|
-
return create$
|
|
934
|
+
return create$a(-1, 0, 0);
|
|
935
935
|
}
|
|
936
936
|
/**
|
|
937
937
|
* Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
|
|
938
938
|
*/
|
|
939
939
|
function down() {
|
|
940
|
-
return create$
|
|
940
|
+
return create$a(0, -1, 0);
|
|
941
941
|
}
|
|
942
942
|
/**
|
|
943
943
|
* Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
|
|
944
944
|
*/
|
|
945
945
|
function back() {
|
|
946
|
-
return create$
|
|
946
|
+
return create$a(0, 0, 1);
|
|
947
947
|
}
|
|
948
948
|
/**
|
|
949
949
|
* Returns a vector at the origin, Vector3(0, 0, 0).
|
|
950
950
|
*/
|
|
951
951
|
function origin() {
|
|
952
|
-
return create$
|
|
952
|
+
return create$a(0, 0, 0);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* Returns a vector with that will have a magnitude of 1.
|
|
956
956
|
*/
|
|
957
|
-
function normalize
|
|
957
|
+
function normalize(vector) {
|
|
958
958
|
var length = magnitude(vector);
|
|
959
959
|
return { x: vector.x / length, y: vector.y / length, z: vector.z / length };
|
|
960
960
|
}
|
|
@@ -992,7 +992,7 @@ function cross(a, b) {
|
|
|
992
992
|
/**
|
|
993
993
|
* Returns a vector that is the sum of two vectors.
|
|
994
994
|
*/
|
|
995
|
-
function add
|
|
995
|
+
function add(a) {
|
|
996
996
|
var vectors = [];
|
|
997
997
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
998
998
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -1004,7 +1004,7 @@ function add$1(a) {
|
|
|
1004
1004
|
/**
|
|
1005
1005
|
* Returns a vector that is the difference between two vectors.
|
|
1006
1006
|
*/
|
|
1007
|
-
function subtract
|
|
1007
|
+
function subtract(a) {
|
|
1008
1008
|
var vectors = [];
|
|
1009
1009
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1010
1010
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -1032,7 +1032,7 @@ function scale$2(scalar, vector) {
|
|
|
1032
1032
|
* multiplied together and then multiplied by the cosine of the angle between
|
|
1033
1033
|
* them.
|
|
1034
1034
|
*/
|
|
1035
|
-
function dot(a, b) {
|
|
1035
|
+
function dot$1(a, b) {
|
|
1036
1036
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
@@ -1043,7 +1043,7 @@ function dot(a, b) {
|
|
|
1043
1043
|
* result is never greater than 180 degrees.
|
|
1044
1044
|
*/
|
|
1045
1045
|
function angleTo(a, b) {
|
|
1046
|
-
var theta = dot(a, b) / (magnitude(a) * magnitude(b));
|
|
1046
|
+
var theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
|
|
1047
1047
|
// Clamp to avoid numerical problems.
|
|
1048
1048
|
return Math.acos(theta);
|
|
1049
1049
|
}
|
|
@@ -1063,7 +1063,7 @@ function angleTo(a, b) {
|
|
|
1063
1063
|
* ```
|
|
1064
1064
|
*/
|
|
1065
1065
|
function project(vector, onNormal) {
|
|
1066
|
-
return scale$2(dot(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
1066
|
+
return scale$2(dot$1(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
1067
1067
|
}
|
|
1068
1068
|
/**
|
|
1069
1069
|
* Returns a vector that is rotated about an origin point.
|
|
@@ -1099,7 +1099,7 @@ function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
|
|
|
1099
1099
|
/**
|
|
1100
1100
|
* Returns a vector that is multiplied with a matrix.
|
|
1101
1101
|
*/
|
|
1102
|
-
function transformMatrix(vector, m) {
|
|
1102
|
+
function transformMatrix$1(vector, m) {
|
|
1103
1103
|
var x = vector.x, y = vector.y, z = vector.z;
|
|
1104
1104
|
var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
|
|
1105
1105
|
return {
|
|
@@ -1112,38 +1112,38 @@ function transformMatrix(vector, m) {
|
|
|
1112
1112
|
* Euclidean distance between two vectors
|
|
1113
1113
|
*/
|
|
1114
1114
|
function distance$1(a, b) {
|
|
1115
|
-
return Math.sqrt(distanceSquared(a, b));
|
|
1115
|
+
return Math.sqrt(distanceSquared$1(a, b));
|
|
1116
1116
|
}
|
|
1117
1117
|
/**
|
|
1118
1118
|
* Returns the squared distance between two vectors. If you're just comparing
|
|
1119
1119
|
* distances, this is slightly more efficient than `distanceTo`.
|
|
1120
1120
|
*/
|
|
1121
|
-
function distanceSquared(a, b) {
|
|
1122
|
-
var _a = subtract
|
|
1121
|
+
function distanceSquared$1(a, b) {
|
|
1122
|
+
var _a = subtract(a, b), dx = _a.x, dy = _a.y, dz = _a.z;
|
|
1123
1123
|
return dx * dx + dy * dy + dz * dz;
|
|
1124
1124
|
}
|
|
1125
1125
|
/**
|
|
1126
1126
|
* Returns `true` if two vectors have the same values.
|
|
1127
1127
|
*/
|
|
1128
|
-
function isEqual$
|
|
1128
|
+
function isEqual$2(a, b) {
|
|
1129
1129
|
return a.x === b.x && a.y === b.y && a.z === b.z;
|
|
1130
1130
|
}
|
|
1131
1131
|
/**
|
|
1132
1132
|
* Returns a vector that contains the largest components of `a` and `b`.
|
|
1133
1133
|
*/
|
|
1134
1134
|
function max(a, b) {
|
|
1135
|
-
return create$
|
|
1135
|
+
return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
|
|
1136
1136
|
}
|
|
1137
1137
|
/**
|
|
1138
1138
|
* Returns a vector that contains the smallest components of `a` and `b`.
|
|
1139
1139
|
*/
|
|
1140
1140
|
function min(a, b) {
|
|
1141
|
-
return create$
|
|
1141
|
+
return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
|
|
1142
1142
|
}
|
|
1143
1143
|
/**
|
|
1144
1144
|
* Returns a vector that each of its component negated.
|
|
1145
1145
|
*/
|
|
1146
|
-
function negate
|
|
1146
|
+
function negate(vector) {
|
|
1147
1147
|
return { x: -vector.x, y: -vector.y, z: -vector.z };
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
@@ -1155,21 +1155,32 @@ function negate$1(vector) {
|
|
|
1155
1155
|
* @param t A value between 0 and 1.
|
|
1156
1156
|
* @returns A point between `a` and `b`.
|
|
1157
1157
|
*/
|
|
1158
|
-
function lerp
|
|
1158
|
+
function lerp(a, b, t) {
|
|
1159
1159
|
return {
|
|
1160
|
-
x: lerp(a.x, b.x, t),
|
|
1161
|
-
y: lerp(a.y, b.y, t),
|
|
1162
|
-
z: lerp(a.z, b.z, t),
|
|
1160
|
+
x: lerp$2(a.x, b.x, t),
|
|
1161
|
+
y: lerp$2(a.y, b.y, t),
|
|
1162
|
+
z: lerp$2(a.z, b.z, t),
|
|
1163
1163
|
};
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Maps a normalized device coordinate (NDC) space to world space coordinates.
|
|
1167
|
+
*
|
|
1168
|
+
* @param ndc A point in normalized device coordinates.
|
|
1169
|
+
* @param worldMatrix A camera's world matrix.
|
|
1170
|
+
* @param projectionMatrixInverse A camera's inverse projection matrix.
|
|
1171
|
+
* @returns A point in world space coordinates.
|
|
1172
|
+
*/
|
|
1173
|
+
function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
|
|
1174
|
+
return transformMatrix$1(transformMatrix$1(ndc, projectionMatrixInverse), worldMatrix);
|
|
1164
1175
|
}
|
|
1165
1176
|
|
|
1166
1177
|
var vector3 = /*#__PURE__*/Object.freeze({
|
|
1167
1178
|
__proto__: null,
|
|
1168
|
-
create: create$
|
|
1179
|
+
create: create$a,
|
|
1169
1180
|
isValid: isValid,
|
|
1170
1181
|
fromMatrixScale: fromMatrixScale,
|
|
1171
1182
|
fromMatrixPosition: fromMatrixPosition,
|
|
1172
|
-
fromJson: fromJson$
|
|
1183
|
+
fromJson: fromJson$3,
|
|
1173
1184
|
fromArray: fromArray,
|
|
1174
1185
|
toArray: toArray,
|
|
1175
1186
|
right: right,
|
|
@@ -1179,32 +1190,33 @@ var vector3 = /*#__PURE__*/Object.freeze({
|
|
|
1179
1190
|
down: down,
|
|
1180
1191
|
back: back,
|
|
1181
1192
|
origin: origin,
|
|
1182
|
-
normalize: normalize
|
|
1193
|
+
normalize: normalize,
|
|
1183
1194
|
magnitude: magnitude,
|
|
1184
1195
|
magnitudeSquared: magnitudeSquared,
|
|
1185
1196
|
cross: cross,
|
|
1186
|
-
add: add
|
|
1187
|
-
subtract: subtract
|
|
1197
|
+
add: add,
|
|
1198
|
+
subtract: subtract,
|
|
1188
1199
|
multiply: multiply$1,
|
|
1189
1200
|
scale: scale$2,
|
|
1190
|
-
dot: dot,
|
|
1201
|
+
dot: dot$1,
|
|
1191
1202
|
angleTo: angleTo,
|
|
1192
1203
|
project: project,
|
|
1193
1204
|
rotateAboutAxis: rotateAboutAxis,
|
|
1194
|
-
transformMatrix: transformMatrix,
|
|
1205
|
+
transformMatrix: transformMatrix$1,
|
|
1195
1206
|
distance: distance$1,
|
|
1196
|
-
distanceSquared: distanceSquared,
|
|
1197
|
-
isEqual: isEqual$
|
|
1207
|
+
distanceSquared: distanceSquared$1,
|
|
1208
|
+
isEqual: isEqual$2,
|
|
1198
1209
|
max: max,
|
|
1199
1210
|
min: min,
|
|
1200
|
-
negate: negate
|
|
1201
|
-
lerp: lerp
|
|
1211
|
+
negate: negate,
|
|
1212
|
+
lerp: lerp,
|
|
1213
|
+
transformNdcToWorldSpace: transformNdcToWorldSpace
|
|
1202
1214
|
});
|
|
1203
1215
|
|
|
1204
1216
|
/**
|
|
1205
1217
|
* Returns a `BoundingBox` with the given min and max points.
|
|
1206
1218
|
*/
|
|
1207
|
-
var create$
|
|
1219
|
+
var create$9 = function (min, max) {
|
|
1208
1220
|
return { min: min, max: max };
|
|
1209
1221
|
};
|
|
1210
1222
|
/**
|
|
@@ -1212,13 +1224,13 @@ var create$2 = function (min, max) {
|
|
|
1212
1224
|
* are contained by the bounding box.
|
|
1213
1225
|
*/
|
|
1214
1226
|
var fromVectors = function (vectors) {
|
|
1215
|
-
return union.apply(void 0, vectors.map(function (v) { return create$
|
|
1227
|
+
return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
|
|
1216
1228
|
};
|
|
1217
1229
|
/**
|
|
1218
1230
|
* Returns the center point of the given `BoundingBox`.
|
|
1219
1231
|
*/
|
|
1220
|
-
var center = function (boundingBox) {
|
|
1221
|
-
return scale$2(0.5, add
|
|
1232
|
+
var center$3 = function (boundingBox) {
|
|
1233
|
+
return scale$2(0.5, add(boundingBox.min, boundingBox.max));
|
|
1222
1234
|
};
|
|
1223
1235
|
function union(box) {
|
|
1224
1236
|
var rest = [];
|
|
@@ -1227,47 +1239,47 @@ function union(box) {
|
|
|
1227
1239
|
}
|
|
1228
1240
|
var boxes = __spreadArray([box], rest, true);
|
|
1229
1241
|
return boxes.reduce(function (a, b) {
|
|
1230
|
-
return create$
|
|
1242
|
+
return create$9(min(a.min, b.min), max(a.max, b.max));
|
|
1231
1243
|
});
|
|
1232
1244
|
}
|
|
1233
1245
|
/* eslint-enable padding-line-between-statements */
|
|
1234
1246
|
|
|
1235
1247
|
var boundingBox = /*#__PURE__*/Object.freeze({
|
|
1236
1248
|
__proto__: null,
|
|
1237
|
-
create: create$
|
|
1249
|
+
create: create$9,
|
|
1238
1250
|
fromVectors: fromVectors,
|
|
1239
|
-
center: center,
|
|
1251
|
+
center: center$3,
|
|
1240
1252
|
union: union
|
|
1241
1253
|
});
|
|
1242
1254
|
|
|
1243
1255
|
/**
|
|
1244
1256
|
* Returns a new `Rectangle` with the given position and size.
|
|
1245
1257
|
*/
|
|
1246
|
-
function create$
|
|
1258
|
+
function create$8(x, y, width, height) {
|
|
1247
1259
|
return { x: x, y: y, width: width, height: height };
|
|
1248
1260
|
}
|
|
1249
1261
|
/**
|
|
1250
1262
|
* Returns a new `Rectangle` at the origin point and given size.
|
|
1251
1263
|
*/
|
|
1252
1264
|
function fromDimensions(dimensions) {
|
|
1253
|
-
return create$
|
|
1265
|
+
return create$8(0, 0, dimensions.width, dimensions.height);
|
|
1254
1266
|
}
|
|
1255
1267
|
/**
|
|
1256
1268
|
* Returns a new `Rectangle` with the given position and size.
|
|
1257
1269
|
*/
|
|
1258
1270
|
function fromPointAndDimensions(point, dimensions) {
|
|
1259
|
-
return create$
|
|
1271
|
+
return create$8(point.x, point.y, dimensions.width, dimensions.height);
|
|
1260
1272
|
}
|
|
1261
1273
|
/**
|
|
1262
1274
|
* Returns a new `Rectangle` with the given top-left and bottom-right positions.
|
|
1263
1275
|
* The returned rectangle will always returns a positive width and height.
|
|
1264
1276
|
*/
|
|
1265
|
-
function fromPoints
|
|
1277
|
+
function fromPoints(topLeftPt, bottomRightPt) {
|
|
1266
1278
|
var minX = Math.min(topLeftPt.x, bottomRightPt.x);
|
|
1267
1279
|
var minY = Math.min(topLeftPt.y, bottomRightPt.y);
|
|
1268
1280
|
var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
|
|
1269
1281
|
var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
|
|
1270
|
-
return create$
|
|
1282
|
+
return create$8(minX, minY, maxX - minX, maxY - minY);
|
|
1271
1283
|
}
|
|
1272
1284
|
/**
|
|
1273
1285
|
* Returns a rectangle where the longest length of `rect` will be equal to the
|
|
@@ -1277,10 +1289,10 @@ function fromPoints$1(topLeftPt, bottomRightPt) {
|
|
|
1277
1289
|
*
|
|
1278
1290
|
* @see {@link cropFit}
|
|
1279
1291
|
*/
|
|
1280
|
-
function containFit(to, rect) {
|
|
1292
|
+
function containFit$1(to, rect) {
|
|
1281
1293
|
var scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
1282
1294
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1283
|
-
var position = subtract(center$
|
|
1295
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1284
1296
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1285
1297
|
}
|
|
1286
1298
|
/**
|
|
@@ -1291,10 +1303,10 @@ function containFit(to, rect) {
|
|
|
1291
1303
|
*
|
|
1292
1304
|
* @see {@link containFit}
|
|
1293
1305
|
*/
|
|
1294
|
-
function cropFit(to, rect) {
|
|
1306
|
+
function cropFit$1(to, rect) {
|
|
1295
1307
|
var scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
1296
1308
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1297
|
-
var position = subtract(center$
|
|
1309
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1298
1310
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1299
1311
|
}
|
|
1300
1312
|
/**
|
|
@@ -1305,10 +1317,10 @@ function cropFit(to, rect) {
|
|
|
1305
1317
|
* @param to - the maximum area this rectangle can have
|
|
1306
1318
|
* @param rect - the rectangle to scale to fit the specified area
|
|
1307
1319
|
*/
|
|
1308
|
-
function scaleFit(to, rect) {
|
|
1309
|
-
var scale = Math.min(Math.sqrt(to / area(rect)), 1);
|
|
1320
|
+
function scaleFit$1(to, rect) {
|
|
1321
|
+
var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
|
|
1310
1322
|
var dimensions$1 = floor(proportionalScale(scale, rect));
|
|
1311
|
-
var position = subtract(center$
|
|
1323
|
+
var position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
1312
1324
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1313
1325
|
}
|
|
1314
1326
|
/**
|
|
@@ -1322,52 +1334,52 @@ function scaleFit(to, rect) {
|
|
|
1322
1334
|
* @param scaleY The vertical scale factor.
|
|
1323
1335
|
* @returns A scaled rectangle.
|
|
1324
1336
|
*/
|
|
1325
|
-
function scale$
|
|
1337
|
+
function scale$1(rect, scaleOrScaleX, scaleY) {
|
|
1326
1338
|
if (scaleY == null) {
|
|
1327
|
-
return scale$
|
|
1339
|
+
return scale$1(rect, scaleOrScaleX, scaleOrScaleX);
|
|
1328
1340
|
}
|
|
1329
1341
|
else {
|
|
1330
1342
|
var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
|
|
1331
1343
|
var scaleX = scaleOrScaleX;
|
|
1332
|
-
return create$
|
|
1344
|
+
return create$8(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
|
|
1333
1345
|
}
|
|
1334
1346
|
}
|
|
1335
1347
|
/**
|
|
1336
1348
|
* Returns true if two rectangles are equal in position and size.
|
|
1337
1349
|
*/
|
|
1338
|
-
function isEqual$
|
|
1339
|
-
return isEqual(a, b) && isEqual
|
|
1350
|
+
function isEqual$1(a, b) {
|
|
1351
|
+
return isEqual$3(a, b) && isEqual(a, b);
|
|
1340
1352
|
}
|
|
1341
1353
|
/**
|
|
1342
1354
|
* Returns a rectangle that has its position shifted by a given offset. The
|
|
1343
1355
|
* size of the rectangle is unchanged.
|
|
1344
1356
|
*/
|
|
1345
1357
|
function offset(delta, rect) {
|
|
1346
|
-
return fromPointAndDimensions(add(topLeft(rect), delta), rect);
|
|
1358
|
+
return fromPointAndDimensions(add$1(topLeft(rect), delta), rect);
|
|
1347
1359
|
}
|
|
1348
1360
|
/**
|
|
1349
1361
|
* Returns the area of the rectangle.
|
|
1350
1362
|
*/
|
|
1351
|
-
function area(rect) {
|
|
1363
|
+
function area$1(rect) {
|
|
1352
1364
|
return rect.width * rect.height;
|
|
1353
1365
|
}
|
|
1354
1366
|
/**
|
|
1355
1367
|
* Returns the center point of the rectangle.
|
|
1356
1368
|
*/
|
|
1357
|
-
function center$
|
|
1369
|
+
function center$2(rect) {
|
|
1358
1370
|
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
1359
1371
|
}
|
|
1360
1372
|
/**
|
|
1361
1373
|
* Returns the top-left position of the rectangle, as a point.
|
|
1362
1374
|
*/
|
|
1363
1375
|
function topLeft(rect) {
|
|
1364
|
-
return create(rect.x, rect.y);
|
|
1376
|
+
return create$b(rect.x, rect.y);
|
|
1365
1377
|
}
|
|
1366
1378
|
/**
|
|
1367
1379
|
* Returns the bottom-right position of the rectangle, as a point.
|
|
1368
1380
|
*/
|
|
1369
1381
|
function bottomRight(rect) {
|
|
1370
|
-
return create(rect.x + rect.width, rect.y + rect.height);
|
|
1382
|
+
return create$b(rect.x + rect.width, rect.y + rect.height);
|
|
1371
1383
|
}
|
|
1372
1384
|
/**
|
|
1373
1385
|
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
@@ -1394,7 +1406,7 @@ function isSquare(rect) {
|
|
|
1394
1406
|
* @param padding The padding to add.
|
|
1395
1407
|
*/
|
|
1396
1408
|
function pad(rect, padding) {
|
|
1397
|
-
return create$
|
|
1409
|
+
return create$8(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
|
|
1398
1410
|
}
|
|
1399
1411
|
/**
|
|
1400
1412
|
* Parses a JSON string representation of a Rectangle and returns an object.
|
|
@@ -1406,28 +1418,28 @@ function fromJson$2(json) {
|
|
|
1406
1418
|
var obj = JSON.parse(json);
|
|
1407
1419
|
if (Array.isArray(obj)) {
|
|
1408
1420
|
var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
|
|
1409
|
-
return create$
|
|
1421
|
+
return create$8(x, y, width, height);
|
|
1410
1422
|
}
|
|
1411
1423
|
else {
|
|
1412
1424
|
var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
|
|
1413
|
-
return create$
|
|
1425
|
+
return create$8(x, y, width, height);
|
|
1414
1426
|
}
|
|
1415
1427
|
}
|
|
1416
1428
|
|
|
1417
1429
|
var rectangle = /*#__PURE__*/Object.freeze({
|
|
1418
1430
|
__proto__: null,
|
|
1419
|
-
create: create$
|
|
1431
|
+
create: create$8,
|
|
1420
1432
|
fromDimensions: fromDimensions,
|
|
1421
1433
|
fromPointAndDimensions: fromPointAndDimensions,
|
|
1422
|
-
fromPoints: fromPoints
|
|
1423
|
-
containFit: containFit,
|
|
1424
|
-
cropFit: cropFit,
|
|
1425
|
-
scaleFit: scaleFit,
|
|
1426
|
-
scale: scale$
|
|
1427
|
-
isEqual: isEqual$
|
|
1434
|
+
fromPoints: fromPoints,
|
|
1435
|
+
containFit: containFit$1,
|
|
1436
|
+
cropFit: cropFit$1,
|
|
1437
|
+
scaleFit: scaleFit$1,
|
|
1438
|
+
scale: scale$1,
|
|
1439
|
+
isEqual: isEqual$1,
|
|
1428
1440
|
offset: offset,
|
|
1429
|
-
area: area,
|
|
1430
|
-
center: center$
|
|
1441
|
+
area: area$1,
|
|
1442
|
+
center: center$2,
|
|
1431
1443
|
topLeft: topLeft,
|
|
1432
1444
|
bottomRight: bottomRight,
|
|
1433
1445
|
isPortrait: isPortrait,
|
|
@@ -1441,27 +1453,27 @@ var rectangle = /*#__PURE__*/Object.freeze({
|
|
|
1441
1453
|
* Returns a `Dimensions` with the given width and height.
|
|
1442
1454
|
*
|
|
1443
1455
|
*/
|
|
1444
|
-
var create$
|
|
1456
|
+
var create$7 = function (width, height) {
|
|
1445
1457
|
return { width: width, height: height };
|
|
1446
1458
|
};
|
|
1447
1459
|
/**
|
|
1448
1460
|
* Returns a `Dimensions` with the same width and height.
|
|
1449
1461
|
*/
|
|
1450
1462
|
var square = function (size) {
|
|
1451
|
-
return create$
|
|
1463
|
+
return create$7(size, size);
|
|
1452
1464
|
};
|
|
1453
1465
|
/**
|
|
1454
1466
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
1455
1467
|
* `false`.
|
|
1456
1468
|
*/
|
|
1457
|
-
var isEqual
|
|
1469
|
+
var isEqual = function (a, b) {
|
|
1458
1470
|
return a.width === b.width && a.height === b.height;
|
|
1459
1471
|
};
|
|
1460
1472
|
/**
|
|
1461
1473
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
1462
1474
|
* is scaled by `scaleY`.
|
|
1463
1475
|
*/
|
|
1464
|
-
var scale
|
|
1476
|
+
var scale = function (scaleX, scaleY, dimensions) {
|
|
1465
1477
|
return {
|
|
1466
1478
|
width: dimensions.width * scaleX,
|
|
1467
1479
|
height: dimensions.height * scaleY,
|
|
@@ -1471,7 +1483,7 @@ var scale$4 = function (scaleX, scaleY, dimensions) {
|
|
|
1471
1483
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
1472
1484
|
*/
|
|
1473
1485
|
var proportionalScale = function (scaleFactor, dimensions) {
|
|
1474
|
-
return scale
|
|
1486
|
+
return scale(scaleFactor, scaleFactor, dimensions);
|
|
1475
1487
|
};
|
|
1476
1488
|
/**
|
|
1477
1489
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
@@ -1490,8 +1502,8 @@ var trim = function (to, dimensions) {
|
|
|
1490
1502
|
*
|
|
1491
1503
|
* @see #cropFit()
|
|
1492
1504
|
*/
|
|
1493
|
-
var containFit
|
|
1494
|
-
var _a = containFit(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1505
|
+
var containFit = function (to, dimensions) {
|
|
1506
|
+
var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1495
1507
|
return { width: width, height: height };
|
|
1496
1508
|
};
|
|
1497
1509
|
/**
|
|
@@ -1501,8 +1513,8 @@ var containFit$1 = function (to, dimensions) {
|
|
|
1501
1513
|
*
|
|
1502
1514
|
* @see #containFit()
|
|
1503
1515
|
*/
|
|
1504
|
-
var cropFit
|
|
1505
|
-
var _a = cropFit(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1516
|
+
var cropFit = function (to, dimensions) {
|
|
1517
|
+
var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1506
1518
|
return { width: width, height: height };
|
|
1507
1519
|
};
|
|
1508
1520
|
/**
|
|
@@ -1513,8 +1525,8 @@ var cropFit$1 = function (to, dimensions) {
|
|
|
1513
1525
|
* @param to - the maximum area this dimensions can have
|
|
1514
1526
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
1515
1527
|
*/
|
|
1516
|
-
var scaleFit
|
|
1517
|
-
var _a = scaleFit(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1528
|
+
var scaleFit = function (to, dimensions) {
|
|
1529
|
+
var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1518
1530
|
return { width: width, height: height };
|
|
1519
1531
|
};
|
|
1520
1532
|
/**
|
|
@@ -1538,7 +1550,7 @@ var floor = function (dimensions) {
|
|
|
1538
1550
|
/**
|
|
1539
1551
|
* Returns the center point of the given `dimensions`.
|
|
1540
1552
|
*/
|
|
1541
|
-
var center$
|
|
1553
|
+
var center$1 = function (dimensions) {
|
|
1542
1554
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
1543
1555
|
};
|
|
1544
1556
|
/**
|
|
@@ -1552,7 +1564,7 @@ var aspectRatio = function (_a) {
|
|
|
1552
1564
|
/**
|
|
1553
1565
|
* Returns the area of the given `dimensions`.
|
|
1554
1566
|
*/
|
|
1555
|
-
var area
|
|
1567
|
+
var area = function (_a) {
|
|
1556
1568
|
var width = _a.width, height = _a.height;
|
|
1557
1569
|
return width * height;
|
|
1558
1570
|
};
|
|
@@ -1564,34 +1576,34 @@ var area$1 = function (_a) {
|
|
|
1564
1576
|
*/
|
|
1565
1577
|
var fitToRatio = function (ratio, dimensions) {
|
|
1566
1578
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
1567
|
-
return create$
|
|
1579
|
+
return create$7(dimensions.height * ratio, dimensions.height);
|
|
1568
1580
|
}
|
|
1569
|
-
return create$
|
|
1581
|
+
return create$7(dimensions.width, dimensions.width / ratio);
|
|
1570
1582
|
};
|
|
1571
1583
|
/**
|
|
1572
1584
|
* Converts a dimension to a rectangle, with an optional position.
|
|
1573
1585
|
*/
|
|
1574
1586
|
function toRectangle(dimensions, position) {
|
|
1575
|
-
if (position === void 0) { position = create(); }
|
|
1587
|
+
if (position === void 0) { position = create$b(); }
|
|
1576
1588
|
return fromPointAndDimensions(position, dimensions);
|
|
1577
1589
|
}
|
|
1578
1590
|
|
|
1579
1591
|
var dimensions = /*#__PURE__*/Object.freeze({
|
|
1580
1592
|
__proto__: null,
|
|
1581
|
-
create: create$
|
|
1593
|
+
create: create$7,
|
|
1582
1594
|
square: square,
|
|
1583
|
-
isEqual: isEqual
|
|
1584
|
-
scale: scale
|
|
1595
|
+
isEqual: isEqual,
|
|
1596
|
+
scale: scale,
|
|
1585
1597
|
proportionalScale: proportionalScale,
|
|
1586
1598
|
trim: trim,
|
|
1587
|
-
containFit: containFit
|
|
1588
|
-
cropFit: cropFit
|
|
1589
|
-
scaleFit: scaleFit
|
|
1599
|
+
containFit: containFit,
|
|
1600
|
+
cropFit: cropFit,
|
|
1601
|
+
scaleFit: scaleFit,
|
|
1590
1602
|
round: round,
|
|
1591
1603
|
floor: floor,
|
|
1592
|
-
center: center$
|
|
1604
|
+
center: center$1,
|
|
1593
1605
|
aspectRatio: aspectRatio,
|
|
1594
|
-
area: area
|
|
1606
|
+
area: area,
|
|
1595
1607
|
fitToRatio: fitToRatio,
|
|
1596
1608
|
toRectangle: toRectangle
|
|
1597
1609
|
});
|
|
@@ -1604,7 +1616,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
|
|
|
1604
1616
|
* @param value The values to populate the euler angle with.
|
|
1605
1617
|
* @returns A euler angle.
|
|
1606
1618
|
*/
|
|
1607
|
-
function create$
|
|
1619
|
+
function create$6(value) {
|
|
1608
1620
|
var _a, _b, _c, _d;
|
|
1609
1621
|
if (value === void 0) { value = {}; }
|
|
1610
1622
|
return {
|
|
@@ -1625,7 +1637,7 @@ function create$5(value) {
|
|
|
1625
1637
|
function fromDegrees(value) {
|
|
1626
1638
|
if (value === void 0) { value = {}; }
|
|
1627
1639
|
var _a = value.x, x = _a === void 0 ? 0 : _a, _b = value.y, y = _b === void 0 ? 0 : _b, _c = value.z, z = _c === void 0 ? 0 : _c, order = value.order;
|
|
1628
|
-
return create$
|
|
1640
|
+
return create$6({
|
|
1629
1641
|
x: toRadians(x),
|
|
1630
1642
|
y: toRadians(y),
|
|
1631
1643
|
z: toRadians(z),
|
|
@@ -1719,7 +1731,7 @@ function fromRotationMatrix(matrix, order) {
|
|
|
1719
1731
|
* @param json A JSON object.
|
|
1720
1732
|
* @returns A euler angle.
|
|
1721
1733
|
*/
|
|
1722
|
-
function fromJson$
|
|
1734
|
+
function fromJson$1(json) {
|
|
1723
1735
|
var obj = JSON.parse(json);
|
|
1724
1736
|
if (Array.isArray(obj)) {
|
|
1725
1737
|
var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
|
|
@@ -1745,10 +1757,10 @@ function isType$1(obj) {
|
|
|
1745
1757
|
|
|
1746
1758
|
var euler = /*#__PURE__*/Object.freeze({
|
|
1747
1759
|
__proto__: null,
|
|
1748
|
-
create: create$
|
|
1760
|
+
create: create$6,
|
|
1749
1761
|
fromDegrees: fromDegrees,
|
|
1750
1762
|
fromRotationMatrix: fromRotationMatrix,
|
|
1751
|
-
fromJson: fromJson$
|
|
1763
|
+
fromJson: fromJson$1,
|
|
1752
1764
|
isType: isType$1
|
|
1753
1765
|
});
|
|
1754
1766
|
|
|
@@ -1758,7 +1770,7 @@ var euler = /*#__PURE__*/Object.freeze({
|
|
|
1758
1770
|
*
|
|
1759
1771
|
* @param values The values to assign to the line.
|
|
1760
1772
|
*/
|
|
1761
|
-
function create$
|
|
1773
|
+
function create$5(values) {
|
|
1762
1774
|
var _a, _b;
|
|
1763
1775
|
if (values === void 0) { values = {}; }
|
|
1764
1776
|
return {
|
|
@@ -1769,8 +1781,8 @@ function create$6(values) {
|
|
|
1769
1781
|
/**
|
|
1770
1782
|
* Returns the point that is halfway between start and end.
|
|
1771
1783
|
*/
|
|
1772
|
-
function center
|
|
1773
|
-
return lerp
|
|
1784
|
+
function center(line) {
|
|
1785
|
+
return lerp(line.start, line.end, 0.5);
|
|
1774
1786
|
}
|
|
1775
1787
|
/**
|
|
1776
1788
|
* Returns a line where the start and end points are transformed with the given
|
|
@@ -1780,45 +1792,45 @@ function center$3(line) {
|
|
|
1780
1792
|
* @param matrix The matrix to apply.
|
|
1781
1793
|
* @returns A transformed line.
|
|
1782
1794
|
*/
|
|
1783
|
-
function transformMatrix
|
|
1784
|
-
var start = transformMatrix(line.start, matrix);
|
|
1785
|
-
var end = transformMatrix(line.end, matrix);
|
|
1795
|
+
function transformMatrix(line, matrix) {
|
|
1796
|
+
var start = transformMatrix$1(line.start, matrix);
|
|
1797
|
+
var end = transformMatrix$1(line.end, matrix);
|
|
1786
1798
|
return { start: start, end: end };
|
|
1787
1799
|
}
|
|
1788
1800
|
/**
|
|
1789
1801
|
* Euclidean distance between the start and end points of the line.
|
|
1790
1802
|
*/
|
|
1791
|
-
function distance
|
|
1803
|
+
function distance(line) {
|
|
1792
1804
|
return distance$1(line.start, line.end);
|
|
1793
1805
|
}
|
|
1794
1806
|
/**
|
|
1795
1807
|
* Returns the squared distance between a line's start and end point. If you're
|
|
1796
1808
|
* just comparing distances, this is slightly more efficient than `distanceTo`.
|
|
1797
1809
|
*/
|
|
1798
|
-
function distanceSquared
|
|
1799
|
-
return distanceSquared(line.start, line.end);
|
|
1810
|
+
function distanceSquared(line) {
|
|
1811
|
+
return distanceSquared$1(line.start, line.end);
|
|
1800
1812
|
}
|
|
1801
1813
|
/**
|
|
1802
1814
|
* Returns a vector describing the direction of the line from start to end.
|
|
1803
1815
|
*/
|
|
1804
1816
|
function direction(line) {
|
|
1805
|
-
return subtract
|
|
1817
|
+
return subtract(line.end, line.start);
|
|
1806
1818
|
}
|
|
1807
1819
|
|
|
1808
1820
|
var line3 = /*#__PURE__*/Object.freeze({
|
|
1809
1821
|
__proto__: null,
|
|
1810
|
-
create: create$
|
|
1811
|
-
center: center
|
|
1812
|
-
transformMatrix: transformMatrix
|
|
1813
|
-
distance: distance
|
|
1814
|
-
distanceSquared: distanceSquared
|
|
1822
|
+
create: create$5,
|
|
1823
|
+
center: center,
|
|
1824
|
+
transformMatrix: transformMatrix,
|
|
1825
|
+
distance: distance,
|
|
1826
|
+
distanceSquared: distanceSquared,
|
|
1815
1827
|
direction: direction
|
|
1816
1828
|
});
|
|
1817
1829
|
|
|
1818
1830
|
/**
|
|
1819
1831
|
* Creates a new matrix. If arguments are undefined, returns an identity matrix.
|
|
1820
1832
|
*/
|
|
1821
|
-
var create$
|
|
1833
|
+
var create$4 = function (a, b, c, d, tx, ty) {
|
|
1822
1834
|
if (a === void 0) { a = 1; }
|
|
1823
1835
|
if (b === void 0) { b = 0; }
|
|
1824
1836
|
if (c === void 0) { c = 0; }
|
|
@@ -1831,7 +1843,7 @@ var create$7 = function (a, b, c, d, tx, ty) {
|
|
|
1831
1843
|
* Returns an identity matrix.
|
|
1832
1844
|
*/
|
|
1833
1845
|
var identity = function () {
|
|
1834
|
-
return create$
|
|
1846
|
+
return create$4();
|
|
1835
1847
|
};
|
|
1836
1848
|
/**
|
|
1837
1849
|
* Creates a matrix that is translated by the given `tx` and `ty` values.
|
|
@@ -1856,7 +1868,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1856
1868
|
var b = matrix.b * cos + matrix.d * sin;
|
|
1857
1869
|
var c = matrix.a * -sin + matrix.c * cos;
|
|
1858
1870
|
var d = matrix.b * -sin + matrix.d * cos;
|
|
1859
|
-
return create$
|
|
1871
|
+
return create$4(a, b, c, d, matrix.tx, matrix.ty);
|
|
1860
1872
|
};
|
|
1861
1873
|
/**
|
|
1862
1874
|
* Translates the given matrix along the horizontal and vertical axis by the
|
|
@@ -1865,7 +1877,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1865
1877
|
var translate = function (dx, dy, matrix) {
|
|
1866
1878
|
var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
|
|
1867
1879
|
var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
|
|
1868
|
-
return create$
|
|
1880
|
+
return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
|
|
1869
1881
|
};
|
|
1870
1882
|
/**
|
|
1871
1883
|
* Returns the result of applying a geometric transformation of a matrix on the
|
|
@@ -1874,12 +1886,12 @@ var translate = function (dx, dy, matrix) {
|
|
|
1874
1886
|
var transformPoint = function (matrix, pt) {
|
|
1875
1887
|
var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
|
|
1876
1888
|
var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
|
|
1877
|
-
return create(x, y);
|
|
1889
|
+
return create$b(x, y);
|
|
1878
1890
|
};
|
|
1879
1891
|
|
|
1880
1892
|
var matrix = /*#__PURE__*/Object.freeze({
|
|
1881
1893
|
__proto__: null,
|
|
1882
|
-
create: create$
|
|
1894
|
+
create: create$4,
|
|
1883
1895
|
identity: identity,
|
|
1884
1896
|
translation: translation,
|
|
1885
1897
|
rotation: rotation,
|
|
@@ -1888,7 +1900,7 @@ var matrix = /*#__PURE__*/Object.freeze({
|
|
|
1888
1900
|
transformPoint: transformPoint
|
|
1889
1901
|
});
|
|
1890
1902
|
|
|
1891
|
-
function create$
|
|
1903
|
+
function create$3() {
|
|
1892
1904
|
var args = [];
|
|
1893
1905
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1894
1906
|
args[_i] = arguments[_i];
|
|
@@ -1925,15 +1937,15 @@ function determinant(matrix) {
|
|
|
1925
1937
|
/**
|
|
1926
1938
|
* Returns the dot product of the two vectors represented in this matrix.
|
|
1927
1939
|
*/
|
|
1928
|
-
function dot
|
|
1940
|
+
function dot(matrix) {
|
|
1929
1941
|
return matrix.a * matrix.c + matrix.b * matrix.d;
|
|
1930
1942
|
}
|
|
1931
1943
|
|
|
1932
1944
|
var matrix2 = /*#__PURE__*/Object.freeze({
|
|
1933
1945
|
__proto__: null,
|
|
1934
|
-
create: create$
|
|
1946
|
+
create: create$3,
|
|
1935
1947
|
determinant: determinant,
|
|
1936
|
-
dot: dot
|
|
1948
|
+
dot: dot
|
|
1937
1949
|
});
|
|
1938
1950
|
|
|
1939
1951
|
/**
|
|
@@ -1942,10 +1954,21 @@ var matrix2 = /*#__PURE__*/Object.freeze({
|
|
|
1942
1954
|
* @param values Values to assign to the plane.
|
|
1943
1955
|
* @returns A new plane.
|
|
1944
1956
|
*/
|
|
1945
|
-
function create$
|
|
1957
|
+
function create$2(values) {
|
|
1946
1958
|
if (values === void 0) { values = {}; }
|
|
1947
1959
|
return exports.__assign({ normal: origin(), constant: 0 }, values);
|
|
1948
1960
|
}
|
|
1961
|
+
/**
|
|
1962
|
+
* Creates a plane from a normal and an arbitrary point on a plane.
|
|
1963
|
+
*
|
|
1964
|
+
* @param normal A normal.
|
|
1965
|
+
* @param point A point on the plane.
|
|
1966
|
+
* @returns A new plane.
|
|
1967
|
+
*/
|
|
1968
|
+
function fromNormalAndCoplanarPoint(normal, point) {
|
|
1969
|
+
var constant = -dot$1(point, normal);
|
|
1970
|
+
return create$2({ normal: normal, constant: constant });
|
|
1971
|
+
}
|
|
1949
1972
|
/**
|
|
1950
1973
|
* Returns the perpendicular distance from the plane to the given point.
|
|
1951
1974
|
*
|
|
@@ -1954,7 +1977,7 @@ function create$9(values) {
|
|
|
1954
1977
|
* @returns A distance.
|
|
1955
1978
|
*/
|
|
1956
1979
|
function distanceToPoint(plane, point) {
|
|
1957
|
-
return dot(plane.normal, point) + plane.constant;
|
|
1980
|
+
return dot$1(plane.normal, point) + plane.constant;
|
|
1958
1981
|
}
|
|
1959
1982
|
/**
|
|
1960
1983
|
* Returns the point where the line intersects with this plane. If the line does
|
|
@@ -1967,7 +1990,7 @@ function distanceToPoint(plane, point) {
|
|
|
1967
1990
|
*/
|
|
1968
1991
|
function intersectLine(plane, line) {
|
|
1969
1992
|
var direction$1 = direction(line);
|
|
1970
|
-
var denominator = dot(plane.normal, direction$1);
|
|
1993
|
+
var denominator = dot$1(plane.normal, direction$1);
|
|
1971
1994
|
if (denominator === 0) {
|
|
1972
1995
|
if (distanceToPoint(plane, line.start) === 0) {
|
|
1973
1996
|
return line.start;
|
|
@@ -1976,12 +1999,12 @@ function intersectLine(plane, line) {
|
|
|
1976
1999
|
return undefined;
|
|
1977
2000
|
}
|
|
1978
2001
|
}
|
|
1979
|
-
var t = -(dot(line.start, plane.normal) + plane.constant) / denominator;
|
|
2002
|
+
var t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
|
|
1980
2003
|
if (t < 0 || t > 1) {
|
|
1981
2004
|
return undefined;
|
|
1982
2005
|
}
|
|
1983
2006
|
else {
|
|
1984
|
-
return add
|
|
2007
|
+
return add(line.start, scale$2(t, direction$1));
|
|
1985
2008
|
}
|
|
1986
2009
|
}
|
|
1987
2010
|
/**
|
|
@@ -1993,12 +2016,13 @@ function intersectLine(plane, line) {
|
|
|
1993
2016
|
*/
|
|
1994
2017
|
function projectPoint(plane, point) {
|
|
1995
2018
|
var d = distanceToPoint(plane, point);
|
|
1996
|
-
return add
|
|
2019
|
+
return add(point, scale$2(-d, plane.normal));
|
|
1997
2020
|
}
|
|
1998
2021
|
|
|
1999
2022
|
var plane = /*#__PURE__*/Object.freeze({
|
|
2000
2023
|
__proto__: null,
|
|
2001
|
-
create: create$
|
|
2024
|
+
create: create$2,
|
|
2025
|
+
fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
|
|
2002
2026
|
distanceToPoint: distanceToPoint,
|
|
2003
2027
|
intersectLine: intersectLine,
|
|
2004
2028
|
projectPoint: projectPoint
|
|
@@ -2008,7 +2032,7 @@ var plane = /*#__PURE__*/Object.freeze({
|
|
|
2008
2032
|
* Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
|
|
2009
2033
|
* w: 1}` is returned.
|
|
2010
2034
|
*/
|
|
2011
|
-
function create$
|
|
2035
|
+
function create$1(value) {
|
|
2012
2036
|
if (value === void 0) { value = {}; }
|
|
2013
2037
|
return exports.__assign({ x: 0, y: 0, z: 0, w: 1 }, value);
|
|
2014
2038
|
}
|
|
@@ -2018,14 +2042,14 @@ function create$a(value) {
|
|
|
2018
2042
|
* @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
|
|
2019
2043
|
* @returns A parsed `Quaternion`.
|
|
2020
2044
|
*/
|
|
2021
|
-
function fromJson
|
|
2045
|
+
function fromJson(json) {
|
|
2022
2046
|
var obj = JSON.parse(json);
|
|
2023
2047
|
if (Array.isArray(obj)) {
|
|
2024
2048
|
var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
|
|
2025
|
-
return create$
|
|
2049
|
+
return create$1({ x: x, y: y, z: z, w: w });
|
|
2026
2050
|
}
|
|
2027
2051
|
else {
|
|
2028
|
-
return create$
|
|
2052
|
+
return create$1(obj);
|
|
2029
2053
|
}
|
|
2030
2054
|
}
|
|
2031
2055
|
/**
|
|
@@ -2153,7 +2177,7 @@ function fromEuler(euler) {
|
|
|
2153
2177
|
/**
|
|
2154
2178
|
* Multiplies `a` x `b` and returns a new quaternion with the result.
|
|
2155
2179
|
*/
|
|
2156
|
-
function multiply
|
|
2180
|
+
function multiply(a, b) {
|
|
2157
2181
|
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
2158
2182
|
return {
|
|
2159
2183
|
x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,
|
|
@@ -2165,7 +2189,7 @@ function multiply$2(a, b) {
|
|
|
2165
2189
|
/**
|
|
2166
2190
|
* Type guard that checks if the given type is a Quaternion.
|
|
2167
2191
|
*/
|
|
2168
|
-
function isType
|
|
2192
|
+
function isType(obj) {
|
|
2169
2193
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2170
2194
|
var o = obj;
|
|
2171
2195
|
return (o != null &&
|
|
@@ -2177,13 +2201,13 @@ function isType$2(obj) {
|
|
|
2177
2201
|
|
|
2178
2202
|
var quaternion = /*#__PURE__*/Object.freeze({
|
|
2179
2203
|
__proto__: null,
|
|
2180
|
-
create: create$
|
|
2181
|
-
fromJson: fromJson
|
|
2204
|
+
create: create$1,
|
|
2205
|
+
fromJson: fromJson,
|
|
2182
2206
|
fromAxisAngle: fromAxisAngle,
|
|
2183
2207
|
fromMatrixRotation: fromMatrixRotation,
|
|
2184
2208
|
fromEuler: fromEuler,
|
|
2185
|
-
multiply: multiply
|
|
2186
|
-
isType: isType
|
|
2209
|
+
multiply: multiply,
|
|
2210
|
+
isType: isType
|
|
2187
2211
|
});
|
|
2188
2212
|
|
|
2189
2213
|
/**
|
|
@@ -2193,7 +2217,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
|
|
|
2193
2217
|
* @param value The values of the ray.
|
|
2194
2218
|
* @returns A new ray.
|
|
2195
2219
|
*/
|
|
2196
|
-
function create
|
|
2220
|
+
function create(value) {
|
|
2197
2221
|
var _a, _b;
|
|
2198
2222
|
if (value === void 0) { value = {}; }
|
|
2199
2223
|
return {
|
|
@@ -2209,7 +2233,7 @@ function create$b(value) {
|
|
|
2209
2233
|
* @returns A point on the ray.
|
|
2210
2234
|
*/
|
|
2211
2235
|
function at(ray, distance) {
|
|
2212
|
-
return add
|
|
2236
|
+
return add(scale$2(distance, ray.direction), ray.origin);
|
|
2213
2237
|
}
|
|
2214
2238
|
/**
|
|
2215
2239
|
* Computes the distance of the `ray`s origin to the given `plane`. Returns a
|
|
@@ -2221,13 +2245,13 @@ function at(ray, distance) {
|
|
|
2221
2245
|
* @returns The distance to the plane, or `undefined` if it cannot be computed.
|
|
2222
2246
|
*/
|
|
2223
2247
|
function distanceToPlane(ray, plane$1) {
|
|
2224
|
-
var d = dot(plane$1.normal, ray.direction);
|
|
2248
|
+
var d = dot$1(plane$1.normal, ray.direction);
|
|
2225
2249
|
if (d === 0) {
|
|
2226
2250
|
// Ray is on plane.
|
|
2227
2251
|
return distanceToPoint(plane$1, ray.origin) === 0 ? 0 : undefined;
|
|
2228
2252
|
}
|
|
2229
2253
|
else {
|
|
2230
|
-
var t = -(dot(ray.origin, plane$1.normal) + plane$1.constant) / d;
|
|
2254
|
+
var t = -(dot$1(ray.origin, plane$1.normal) + plane$1.constant) / d;
|
|
2231
2255
|
// Checks if ray intersects plane.
|
|
2232
2256
|
return t >= 0 ? t : undefined;
|
|
2233
2257
|
}
|
|
@@ -2248,7 +2272,7 @@ function intersectPlane(ray, plane) {
|
|
|
2248
2272
|
|
|
2249
2273
|
var ray = /*#__PURE__*/Object.freeze({
|
|
2250
2274
|
__proto__: null,
|
|
2251
|
-
create: create
|
|
2275
|
+
create: create,
|
|
2252
2276
|
at: at,
|
|
2253
2277
|
distanceToPlane: distanceToPlane,
|
|
2254
2278
|
intersectPlane: intersectPlane
|