@vertexvis/geometry 1.0.2-testing.4 → 1.0.2-testing.5

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/bundle.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var tslib = require('tslib');
4
-
5
3
  /**
6
4
  * Clamps the given value between `min` and `max`.
7
5
  *
@@ -31,24 +29,22 @@ function lerp$2(a, b, t) {
31
29
  /**
32
30
  * Returns a new `Point` with the given horizontal and vertical position.
33
31
  */
34
- function create$d(x, y) {
35
- if (x === void 0) { x = 0; }
36
- if (y === void 0) { y = 0; }
37
- return { x: x, y: y };
32
+ function create$d(x = 0, y = 0) {
33
+ return { x, y };
38
34
  }
39
35
  /**
40
36
  * Converts a polar coordinate (length and angle) into a Cartesian coordinate.
41
37
  */
42
38
  function polar(length, radians) {
43
- var x = Math.cos(radians) * length;
44
- var y = Math.sin(radians) * length;
39
+ const x = Math.cos(radians) * length;
40
+ const y = Math.sin(radians) * length;
45
41
  return create$d(x, y);
46
42
  }
47
43
  /**
48
44
  * Returns the distance between two points.
49
45
  */
50
46
  function distance$2(a, b) {
51
- var delta = subtract$1(a, b);
47
+ const delta = subtract$1(a, b);
52
48
  return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
53
49
  }
54
50
  /**
@@ -120,7 +116,7 @@ function magnitude$2(pt) {
120
116
  * Transforms a vector into the corresponding normal (unit) vector.
121
117
  */
122
118
  function normalizeVector(pt) {
123
- var magnitudeOfPoint = magnitude$2(pt);
119
+ const magnitudeOfPoint = magnitude$2(pt);
124
120
  if (magnitudeOfPoint === 0) {
125
121
  return create$d(0, 0);
126
122
  }
@@ -138,19 +134,19 @@ function normalDirectionVector(ptA, ptB) {
138
134
  * Returns a vector orthogonal to the vector between the two given points.
139
135
  */
140
136
  function orthogonalVector(ptA, ptB) {
141
- var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
137
+ const unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
142
138
  // Handle vectors that are parallel to the x or y axis
143
139
  if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
144
140
  return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
145
141
  }
146
142
  if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
147
- var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
148
- var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
143
+ const vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
144
+ const vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
149
145
  return normalizeVector(create$d(vectorXValue, vectorYValue));
150
146
  }
151
147
  else {
152
- var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
153
- var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
148
+ const vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
149
+ const vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
154
150
  return normalizeVector(create$d(vectorXValue, vectorYValue));
155
151
  }
156
152
  }
@@ -161,13 +157,13 @@ function orthogonalVector(ptA, ptB) {
161
157
  * @returns A parsed Point.
162
158
  */
163
159
  function fromJson$5(json) {
164
- var obj = JSON.parse(json);
160
+ const obj = JSON.parse(json);
165
161
  if (Array.isArray(obj)) {
166
- var x = obj[0], y = obj[1];
162
+ const [x, y] = obj;
167
163
  return create$d(x, y);
168
164
  }
169
165
  else {
170
- var x = obj.x, y = obj.y;
166
+ const { x, y } = obj;
171
167
  return create$d(x, y);
172
168
  }
173
169
  }
@@ -199,8 +195,8 @@ var point = /*#__PURE__*/Object.freeze({
199
195
  * @returns An angle in radians.
200
196
  */
201
197
  function fromPoints$1(a, b) {
202
- var delta = subtract$1(b, a);
203
- var theta = Math.atan2(delta.y, delta.x);
198
+ const delta = subtract$1(b, a);
199
+ const theta = Math.atan2(delta.y, delta.x);
204
200
  return theta;
205
201
  }
206
202
  /**
@@ -212,8 +208,8 @@ function fromPoints$1(a, b) {
212
208
  * @deprecated Use {@link fromPoints} instead.
213
209
  */
214
210
  function fromPointsInDegrees(a, b) {
215
- var delta = subtract$1(b, a);
216
- var theta = Math.atan2(delta.y, delta.x);
211
+ const delta = subtract$1(b, a);
212
+ const theta = Math.atan2(delta.y, delta.x);
217
213
  return normalize$2(toDegrees(theta) - 270);
218
214
  }
219
215
  /**
@@ -300,7 +296,7 @@ function makeZero() {
300
296
  * @returns A translation matrix.
301
297
  */
302
298
  function makeTranslation(translation) {
303
- var x = translation.x, y = translation.y, z = translation.z;
299
+ const { x, y, z } = translation;
304
300
  /* eslint-disable prettier/prettier */
305
301
  return [
306
302
  1, 0, 0, 0,
@@ -325,11 +321,11 @@ function makeTranslation(translation) {
325
321
  * @returns A rotation matrix.
326
322
  */
327
323
  function makeRotation(rotation) {
328
- var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
329
- var x2 = x + x, y2 = y + y, z2 = z + z;
330
- var xx = x * x2, xy = x * y2, xz = x * z2;
331
- var yy = y * y2, yz = y * z2, zz = z * z2;
332
- var wx = w * x2, wy = w * y2, wz = w * z2;
324
+ const { x, y, z, w } = rotation;
325
+ const x2 = x + x, y2 = y + y, z2 = z + z;
326
+ const xx = x * x2, xy = x * y2, xz = x * z2;
327
+ const yy = y * y2, yz = y * z2, zz = z * z2;
328
+ const wx = w * x2, wy = w * y2, wz = w * z2;
333
329
  /* eslint-disable prettier/prettier */
334
330
  return [
335
331
  1 - (yy + zz), xy - wz, xz + wy, 0,
@@ -353,7 +349,7 @@ function makeRotation(rotation) {
353
349
  * @returns A scale matrix.
354
350
  */
355
351
  function makeScale(scale) {
356
- var x = scale.x, y = scale.y, z = scale.z;
352
+ const { x, y, z } = scale;
357
353
  /* eslint-disable prettier/prettier */
358
354
  return [
359
355
  x, 0, 0, 0,
@@ -372,9 +368,9 @@ function makeScale(scale) {
372
368
  * @returns A transformed matrix in column-major form.
373
369
  */
374
370
  function makeTRS(translation, rotation, scale) {
375
- var t = makeTranslation(translation);
376
- var r = transpose(makeRotation(rotation));
377
- var s = makeScale(scale);
371
+ const t = makeTranslation(translation);
372
+ const r = transpose(makeRotation(rotation));
373
+ const s = makeScale(scale);
378
374
  return multiply$2(s, multiply$2(r, t));
379
375
  }
380
376
  /**
@@ -422,12 +418,12 @@ function makeBasis(x, y, z) {
422
418
  * @returns A matrix representing a view frustum.
423
419
  */
424
420
  function makeFrustum(left, right, top, bottom, near, far) {
425
- var x = (2 * near) / (right - left);
426
- var y = (2 * near) / (top - bottom);
427
- var a = (right + left) / (right - left);
428
- var b = (top + bottom) / (top - bottom);
429
- var c = -(far + near) / (far - near);
430
- var d = (-2 * far * near) / (far - near);
421
+ const x = (2 * near) / (right - left);
422
+ const y = (2 * near) / (top - bottom);
423
+ const a = (right + left) / (right - left);
424
+ const b = (top + bottom) / (top - bottom);
425
+ const c = -(far + near) / (far - near);
426
+ const d = (-2 * far * near) / (far - near);
431
427
  /* eslint-disable prettier/prettier */
432
428
  return [
433
429
  x, 0, 0, 0,
@@ -456,12 +452,12 @@ function makeFrustum(left, right, top, bottom, near, far) {
456
452
  * @returns A matrix.
457
453
  */
458
454
  function makePerspective(near, far, fovY, aspect) {
459
- var ymax = near * Math.tan(toRadians(fovY / 2.0));
460
- var xmax = ymax * aspect;
461
- var left = -xmax;
462
- var right = xmax;
463
- var top = ymax;
464
- var bottom = -ymax;
455
+ const ymax = near * Math.tan(toRadians(fovY / 2.0));
456
+ const xmax = ymax * aspect;
457
+ const left = -xmax;
458
+ const right = xmax;
459
+ const top = ymax;
460
+ const bottom = -ymax;
465
461
  return makeFrustum(left, right, top, bottom, near, far);
466
462
  }
467
463
  /**
@@ -482,12 +478,12 @@ function makePerspective(near, far, fovY, aspect) {
482
478
  * @returns A matrix.
483
479
  */
484
480
  function makeOrthographic(left, right, bottom, top, near, far) {
485
- var w = 1.0 / (right - left);
486
- var h = 1.0 / (top - bottom);
487
- var d = 1.0 / (far - near);
488
- var x = (right + left) * w;
489
- var y = (top + bottom) * h;
490
- var z = (far + near) * d;
481
+ const w = 1.0 / (right - left);
482
+ const h = 1.0 / (top - bottom);
483
+ const d = 1.0 / (far - near);
484
+ const x = (right + left) * w;
485
+ const y = (top + bottom) * h;
486
+ const z = (far + near) * d;
491
487
  /* eslint-disable prettier/prettier */
492
488
  return [
493
489
  2 * w, 0, 0, -x,
@@ -517,12 +513,12 @@ function makeOrthographic(left, right, bottom, top, near, far) {
517
513
  * @returns A matrix.
518
514
  */
519
515
  function makeLookAtView(position, lookAt, up) {
520
- var z = normalize(subtract(position, lookAt));
521
- var x = normalize(cross(up, z));
522
- var y = cross(z, x);
523
- var dotX = -dot$1(x, position);
524
- var dotY = -dot$1(y, position);
525
- var dotZ = -dot$1(z, position);
516
+ const z = normalize(subtract(position, lookAt));
517
+ const x = normalize(cross(up, z));
518
+ const y = cross(z, x);
519
+ const dotX = -dot$1(x, position);
520
+ const dotY = -dot$1(y, position);
521
+ const dotZ = -dot$1(z, position);
526
522
  /* eslint-disable prettier/prettier */
527
523
  return [
528
524
  x.x, y.x, z.x, 0,
@@ -546,9 +542,9 @@ function makeLookAtView(position, lookAt, up) {
546
542
  * @returns A matrix.
547
543
  */
548
544
  function makeLookAt(position, lookAt, up) {
549
- var z = normalize(subtract(position, lookAt));
550
- var x = normalize(cross(up, z));
551
- var y = cross(z, x);
545
+ const z = normalize(subtract(position, lookAt));
546
+ const x = normalize(cross(up, z));
547
+ const y = cross(z, x);
552
548
  /* eslint-disable prettier/prettier */
553
549
  return [
554
550
  x.x, x.y, x.z, 0,
@@ -563,28 +559,28 @@ function makeLookAt(position, lookAt, up) {
563
559
  * zero, then a zero matrix is returned.
564
560
  */
565
561
  function invert(matrix) {
566
- var a00 = matrix[0], a01 = matrix[1], a02 = matrix[2], a03 = matrix[3];
567
- var a10 = matrix[4], a11 = matrix[5], a12 = matrix[6], a13 = matrix[7];
568
- var a20 = matrix[8], a21 = matrix[9], a22 = matrix[10], a23 = matrix[11];
569
- var a30 = matrix[12], a31 = matrix[13], a32 = matrix[14], a33 = matrix[15];
570
- var b00 = a00 * a11 - a01 * a10;
571
- var b01 = a00 * a12 - a02 * a10;
572
- var b02 = a00 * a13 - a03 * a10;
573
- var b03 = a01 * a12 - a02 * a11;
574
- var b04 = a01 * a13 - a03 * a11;
575
- var b05 = a02 * a13 - a03 * a12;
576
- var b06 = a20 * a31 - a21 * a30;
577
- var b07 = a20 * a32 - a22 * a30;
578
- var b08 = a20 * a33 - a23 * a30;
579
- var b09 = a21 * a32 - a22 * a31;
580
- var b10 = a21 * a33 - a23 * a31;
581
- var b11 = a22 * a33 - a23 * a32;
562
+ const a00 = matrix[0], a01 = matrix[1], a02 = matrix[2], a03 = matrix[3];
563
+ const a10 = matrix[4], a11 = matrix[5], a12 = matrix[6], a13 = matrix[7];
564
+ const a20 = matrix[8], a21 = matrix[9], a22 = matrix[10], a23 = matrix[11];
565
+ const a30 = matrix[12], a31 = matrix[13], a32 = matrix[14], a33 = matrix[15];
566
+ const b00 = a00 * a11 - a01 * a10;
567
+ const b01 = a00 * a12 - a02 * a10;
568
+ const b02 = a00 * a13 - a03 * a10;
569
+ const b03 = a01 * a12 - a02 * a11;
570
+ const b04 = a01 * a13 - a03 * a11;
571
+ const b05 = a02 * a13 - a03 * a12;
572
+ const b06 = a20 * a31 - a21 * a30;
573
+ const b07 = a20 * a32 - a22 * a30;
574
+ const b08 = a20 * a33 - a23 * a30;
575
+ const b09 = a21 * a32 - a22 * a31;
576
+ const b10 = a21 * a33 - a23 * a31;
577
+ const b11 = a22 * a33 - a23 * a32;
582
578
  // Calculate the determinant
583
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
579
+ const det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
584
580
  if (!det) {
585
581
  return makeZero();
586
582
  }
587
- var oneOverDet = 1 / det;
583
+ const oneOverDet = 1 / det;
588
584
  return [
589
585
  (a11 * b11 - a12 * b10 + a13 * b09) * oneOverDet,
590
586
  (a02 * b10 - a01 * b11 - a03 * b09) * oneOverDet,
@@ -615,25 +611,25 @@ function invert(matrix) {
615
611
  * @returns A rotation matrix.
616
612
  */
617
613
  function lookAt(m, position, target, up) {
618
- var z = subtract(position, target);
614
+ let z = subtract(position, target);
619
615
  if (magnitudeSquared(z) === 0) {
620
- z = tslib.__assign(tslib.__assign({}, z), { z: 1 });
616
+ z = { ...z, z: 1 };
621
617
  }
622
618
  z = normalize(z);
623
- var x = cross(up, z);
619
+ let x = cross(up, z);
624
620
  if (magnitudeSquared(x) === 0) {
625
621
  if (Math.abs(up.z) === 1) {
626
- z = tslib.__assign(tslib.__assign({}, z), { x: z.x + 0.0001 });
622
+ z = { ...z, x: z.x + 0.0001 };
627
623
  }
628
624
  else {
629
- z = tslib.__assign(tslib.__assign({}, z), { z: z.z + 0.0001 });
625
+ z = { ...z, z: z.z + 0.0001 };
630
626
  }
631
627
  z = normalize(z);
632
628
  x = cross(up, z);
633
629
  }
634
630
  x = normalize(x);
635
- var y = cross(z, x);
636
- var res = tslib.__spreadArray([], m, true);
631
+ const y = cross(z, x);
632
+ const res = [...m];
637
633
  /* eslint-disable prettier/prettier */
638
634
  res[0] = x.x;
639
635
  res[1] = x.y;
@@ -651,18 +647,18 @@ function lookAt(m, position, target, up) {
651
647
  * Returns a post-multiplied matrix equal to ab.
652
648
  */
653
649
  function multiply$2(a, b) {
654
- var result = makeIdentity();
650
+ const result = makeIdentity();
655
651
  // Consider each row i in the final matrix
656
- for (var i = 0; i < 4; i++) {
652
+ for (let i = 0; i < 4; i++) {
657
653
  // Consider each column j in the final matrix
658
- for (var j = 0; j < 4; j++) {
654
+ for (let j = 0; j < 4; j++) {
659
655
  // Calculate the value at row i and column j
660
- var value = 0;
661
- for (var k = 0; k < 4; k++) {
656
+ let value = 0;
657
+ for (let k = 0; k < 4; k++) {
662
658
  // Calculate (ik + kj) and add it to the value
663
659
  value += a[i * 4 + k] * b[k * 4 + j];
664
660
  }
665
- var positionInResultingMatrix = 4 * i + j;
661
+ const positionInResultingMatrix = 4 * i + j;
666
662
  result[positionInResultingMatrix] = value;
667
663
  }
668
664
  }
@@ -686,8 +682,8 @@ function transpose(matrix) {
686
682
  * Multiplies the columns of a row-major matrix by the given vector.
687
683
  */
688
684
  function scale$4(matrix, scale) {
689
- var x = scale.x, y = scale.y, z = scale.z;
690
- var m = tslib.__spreadArray([], matrix, true);
685
+ const { x, y, z } = scale;
686
+ const m = [...matrix];
691
687
  /* eslint-disable prettier/prettier */
692
688
  m[0] *= x;
693
689
  m[1] *= x;
@@ -710,7 +706,7 @@ function scale$4(matrix, scale) {
710
706
  * Both matrices should have row-major format.
711
707
  */
712
708
  function position(originalMatrix, matrixWithDesiredPosition) {
713
- var m = tslib.__spreadArray([], originalMatrix, true);
709
+ const m = [...originalMatrix];
714
710
  m[12] = matrixWithDesiredPosition[12];
715
711
  m[13] = matrixWithDesiredPosition[13];
716
712
  m[14] = matrixWithDesiredPosition[14];
@@ -720,8 +716,8 @@ function position(originalMatrix, matrixWithDesiredPosition) {
720
716
  * Returns true if the matrix is an identity matrix.
721
717
  */
722
718
  function isIdentity(matrix) {
723
- var identity = makeIdentity();
724
- return matrix.every(function (v, i) { return v === identity[i]; });
719
+ const identity = makeIdentity();
720
+ return matrix.every((v, i) => v === identity[i]);
725
721
  }
726
722
  /**
727
723
  * Returns an object representation of a `Matrix4`.
@@ -804,9 +800,8 @@ var matrix4 = /*#__PURE__*/Object.freeze({
804
800
  * @param value The values to populate the Euler angles with.
805
801
  * @returns A set of Euler angles.
806
802
  */
807
- function create$c(value) {
803
+ function create$c(value = {}) {
808
804
  var _a, _b, _c, _d;
809
- if (value === void 0) { value = {}; }
810
805
  return {
811
806
  x: (_a = value.x) !== null && _a !== void 0 ? _a : 0,
812
807
  y: (_b = value.y) !== null && _b !== void 0 ? _b : 0,
@@ -822,14 +817,13 @@ function create$c(value) {
822
817
  * @param value The values to populate the Euler angles with.
823
818
  * @returns A set of Euler angles.
824
819
  */
825
- function fromDegrees(value) {
826
- if (value === void 0) { value = {}; }
827
- 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;
820
+ function fromDegrees(value = {}) {
821
+ const { x = 0, y = 0, z = 0, order } = value;
828
822
  return create$c({
829
823
  x: toRadians(x),
830
824
  y: toRadians(y),
831
825
  z: toRadians(z),
832
- order: order,
826
+ order,
833
827
  });
834
828
  }
835
829
  /**
@@ -843,13 +837,11 @@ function fromDegrees(value) {
843
837
  * @param matrix A pure rotation matrix, unscaled.
844
838
  * @param order The order that the rotations are applied.
845
839
  */
846
- function fromRotationMatrix(matrix, order, matrixIsColumnMajor) {
847
- if (order === void 0) { order = 'xyz'; }
848
- if (matrixIsColumnMajor === void 0) { matrixIsColumnMajor = true; }
849
- var m = matrixIsColumnMajor
840
+ function fromRotationMatrix(matrix, order = 'xyz', matrixIsColumnMajor = true) {
841
+ const m = matrixIsColumnMajor
850
842
  ? toObjectColumnMajor(matrix)
851
843
  : toObjectRowMajor(matrix);
852
- var x = 0, y = 0, z = 0;
844
+ let x = 0, y = 0, z = 0;
853
845
  if (order === 'xyz') {
854
846
  y = Math.asin(clamp(m.m13, -1, 1));
855
847
  if (Math.abs(m.m13) < 0.9999999) {
@@ -916,7 +908,7 @@ function fromRotationMatrix(matrix, order, matrixIsColumnMajor) {
916
908
  y = 0;
917
909
  }
918
910
  }
919
- return { x: x, y: y, z: z, order: order };
911
+ return { x, y, z, order };
920
912
  }
921
913
  /**
922
914
  * Returns a set of Euler angles that was decoded from a JSON string. Supports either
@@ -927,14 +919,14 @@ function fromRotationMatrix(matrix, order, matrixIsColumnMajor) {
927
919
  * @returns A set of Euler angles.
928
920
  */
929
921
  function fromJson$4(json) {
930
- var obj = JSON.parse(json);
922
+ const obj = JSON.parse(json);
931
923
  if (Array.isArray(obj)) {
932
- var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
933
- return { x: x, y: y, z: z, order: order };
924
+ const [x, y, z, order = 'xyz'] = obj;
925
+ return { x, y, z, order };
934
926
  }
935
927
  else {
936
- var x = obj.x, y = obj.y, z = obj.z, _b = obj.order, order = _b === void 0 ? 'xyz' : _b;
937
- return { x: x, y: y, z: z, order: order };
928
+ const { x, y, z, order = 'xyz' } = obj;
929
+ return { x, y, z, order };
938
930
  }
939
931
  }
940
932
  /**
@@ -942,7 +934,7 @@ function fromJson$4(json) {
942
934
  */
943
935
  function isType$1(obj) {
944
936
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
945
- var o = obj;
937
+ const o = obj;
946
938
  return (o != null &&
947
939
  o.hasOwnProperty('x') &&
948
940
  o.hasOwnProperty('y') &&
@@ -963,9 +955,8 @@ var euler = /*#__PURE__*/Object.freeze({
963
955
  * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
964
956
  * w: 1}` is returned.
965
957
  */
966
- function create$b(value) {
967
- if (value === void 0) { value = {}; }
968
- return tslib.__assign({ x: 0, y: 0, z: 0, w: 1 }, value);
958
+ function create$b(value = {}) {
959
+ return { x: 0, y: 0, z: 0, w: 1, ...value };
969
960
  }
970
961
  /**
971
962
  * Parses a JSON string representation of a `Quaternion`.
@@ -974,10 +965,10 @@ function create$b(value) {
974
965
  * @returns A parsed `Quaternion`.
975
966
  */
976
967
  function fromJson$3(json) {
977
- var obj = JSON.parse(json);
968
+ const obj = JSON.parse(json);
978
969
  if (Array.isArray(obj)) {
979
- var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
980
- return create$b({ x: x, y: y, z: z, w: w });
970
+ const [x, y, z, w] = obj;
971
+ return create$b({ x, y, z, w });
981
972
  }
982
973
  else {
983
974
  return create$b(obj);
@@ -1014,13 +1005,13 @@ function scale$3(scalar, q) {
1014
1005
  * @returns A rotated quaternion.
1015
1006
  */
1016
1007
  function fromAxisAngle(axis, radians) {
1017
- var halfAngle = radians / 2;
1018
- var s = Math.sin(halfAngle);
1019
- var x = axis.x * s;
1020
- var y = axis.y * s;
1021
- var z = axis.z * s;
1022
- var w = Math.cos(halfAngle);
1023
- return { x: x, y: y, z: z, w: w };
1008
+ const halfAngle = radians / 2;
1009
+ const s = Math.sin(halfAngle);
1010
+ const x = axis.x * s;
1011
+ const y = axis.y * s;
1012
+ const z = axis.z * s;
1013
+ const w = Math.cos(halfAngle);
1014
+ return { x, y, z, w };
1024
1015
  }
1025
1016
  /**
1026
1017
  * Returns a quaternion using the upper 3x3 of a pure rotation matrix
@@ -1028,14 +1019,14 @@ function fromAxisAngle(axis, radians) {
1028
1019
  */
1029
1020
  function fromMatrixRotation(matrix) {
1030
1021
  // Determine the scalars for each vector
1031
- var scale = fromMatrixScale(matrix);
1032
- var oneOverScaleVector = create$a(1 / scale.x, 1 / scale.y, 1 / scale.z);
1022
+ const scale = fromMatrixScale(matrix);
1023
+ const oneOverScaleVector = create$a(1 / scale.x, 1 / scale.y, 1 / scale.z);
1033
1024
  // Scale the matrix
1034
- var scaledMatrix = scale$4(matrix, oneOverScaleVector);
1035
- var sM = toObjectRowMajor(scaledMatrix);
1036
- var trace = sM.m11 + sM.m22 + sM.m33;
1025
+ const scaledMatrix = scale$4(matrix, oneOverScaleVector);
1026
+ const sM = toObjectRowMajor(scaledMatrix);
1027
+ const trace = sM.m11 + sM.m22 + sM.m33;
1037
1028
  if (trace > 0) {
1038
- var s = Math.sqrt(trace + 1) * 2;
1029
+ const s = Math.sqrt(trace + 1) * 2;
1039
1030
  return {
1040
1031
  x: (sM.m23 - sM.m32) / s,
1041
1032
  y: (sM.m31 - sM.m13) / s,
@@ -1044,7 +1035,7 @@ function fromMatrixRotation(matrix) {
1044
1035
  };
1045
1036
  }
1046
1037
  else if (sM.m11 > sM.m22 && sM.m11 > sM.m33) {
1047
- var s = Math.sqrt(1 + sM.m11 - sM.m22 - sM.m33) * 2;
1038
+ const s = Math.sqrt(1 + sM.m11 - sM.m22 - sM.m33) * 2;
1048
1039
  return {
1049
1040
  x: 0.25 * s,
1050
1041
  y: (sM.m12 + sM.m21) / s,
@@ -1053,7 +1044,7 @@ function fromMatrixRotation(matrix) {
1053
1044
  };
1054
1045
  }
1055
1046
  else if (sM.m22 > sM.m33) {
1056
- var s = Math.sqrt(1 + sM.m22 - sM.m11 - sM.m33) * 2;
1047
+ const s = Math.sqrt(1 + sM.m22 - sM.m11 - sM.m33) * 2;
1057
1048
  return {
1058
1049
  x: (sM.m12 + sM.m21) / s,
1059
1050
  y: 0.25 * s,
@@ -1062,7 +1053,7 @@ function fromMatrixRotation(matrix) {
1062
1053
  };
1063
1054
  }
1064
1055
  else {
1065
- var s = Math.sqrt(1 + sM.m33 - sM.m11 - sM.m22) * 2;
1056
+ const s = Math.sqrt(1 + sM.m33 - sM.m11 - sM.m22) * 2;
1066
1057
  return {
1067
1058
  x: (sM.m31 + sM.m13) / s,
1068
1059
  y: (sM.m23 + sM.m32) / s,
@@ -1072,14 +1063,14 @@ function fromMatrixRotation(matrix) {
1072
1063
  }
1073
1064
  }
1074
1065
  function fromEuler(euler) {
1075
- var ex = euler.x, ey = euler.y, ez = euler.z, order = euler.order;
1076
- var c1 = Math.cos(ex / 2);
1077
- var c2 = Math.cos(ey / 2);
1078
- var c3 = Math.cos(ez / 2);
1079
- var s1 = Math.sin(ex / 2);
1080
- var s2 = Math.sin(ey / 2);
1081
- var s3 = Math.sin(ez / 2);
1082
- var x = 0, y = 0, z = 0, w = 0;
1066
+ const { x: ex, y: ey, z: ez, order } = euler;
1067
+ const c1 = Math.cos(ex / 2);
1068
+ const c2 = Math.cos(ey / 2);
1069
+ const c3 = Math.cos(ez / 2);
1070
+ const s1 = Math.sin(ex / 2);
1071
+ const s2 = Math.sin(ey / 2);
1072
+ const s3 = Math.sin(ez / 2);
1073
+ let x = 0, y = 0, z = 0, w = 0;
1083
1074
  switch (order) {
1084
1075
  case 'xyz':
1085
1076
  x = s1 * c2 * c3 + c1 * s2 * s3;
@@ -1118,7 +1109,7 @@ function fromEuler(euler) {
1118
1109
  w = c1 * c2 * c3 + s1 * s2 * s3;
1119
1110
  break;
1120
1111
  }
1121
- return { x: x, y: y, z: z, w: w };
1112
+ return { x, y, z, w };
1122
1113
  }
1123
1114
  /**
1124
1115
  * Multiplies `a` x `b` and returns a new quaternion with the result.
@@ -1137,7 +1128,7 @@ function multiply$1(a, b) {
1137
1128
  */
1138
1129
  function isType(obj) {
1139
1130
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1140
- var o = obj;
1131
+ const o = obj;
1141
1132
  return (o != null &&
1142
1133
  o.hasOwnProperty('x') &&
1143
1134
  o.hasOwnProperty('y') &&
@@ -1159,12 +1150,8 @@ var quaternion = /*#__PURE__*/Object.freeze({
1159
1150
  scale: scale$3
1160
1151
  });
1161
1152
 
1162
- function create$a() {
1153
+ function create$a(...args) {
1163
1154
  var _a, _b, _c, _d, _e, _f;
1164
- var args = [];
1165
- for (var _i = 0; _i < arguments.length; _i++) {
1166
- args[_i] = arguments[_i];
1167
- }
1168
1155
  if (args.length === 1) {
1169
1156
  return {
1170
1157
  x: (_a = args[0].x) !== null && _a !== void 0 ? _a : 0,
@@ -1191,23 +1178,21 @@ function create$a() {
1191
1178
  * Checks if each component of the given vector is populated with a numeric
1192
1179
  * component. A component is invalid if it contains a non-finite or NaN value.
1193
1180
  */
1194
- function isValid$1(_a) {
1195
- var x = _a.x, y = _a.y, z = _a.z;
1196
- return [x, y, z].every(function (v) { return isFinite(v) && !isNaN(v); });
1181
+ function isValid$1({ x, y, z }) {
1182
+ return [x, y, z].every((v) => isFinite(v) && !isNaN(v));
1197
1183
  }
1198
1184
  /**
1199
1185
  * Checks if every component of the given vector is zero.
1200
1186
  * Useful for detecting potentially problematic camera vectors, for example.
1201
1187
  */
1202
- function isZeroVector(_a) {
1203
- var x = _a.x, y = _a.y, z = _a.z;
1204
- return [x, y, z].every(function (v) { return v === 0; });
1188
+ function isZeroVector({ x, y, z }) {
1189
+ return [x, y, z].every((v) => v === 0);
1205
1190
  }
1206
1191
  /**
1207
1192
  * Returns a vector representing the scale elements of `matrix`.
1208
1193
  */
1209
1194
  function fromMatrixScale(matrix) {
1210
- var m = toObjectRowMajor(matrix);
1195
+ const m = toObjectRowMajor(matrix);
1211
1196
  return {
1212
1197
  x: Math.hypot(m.m11, m.m12, m.m13),
1213
1198
  y: Math.hypot(m.m21, m.m22, m.m23),
@@ -1218,7 +1203,7 @@ function fromMatrixScale(matrix) {
1218
1203
  * Returns a vector representing the position elements of `matrix`.
1219
1204
  */
1220
1205
  function fromMatrixPosition(matrix) {
1221
- var m = toObjectRowMajor(matrix);
1206
+ const m = toObjectRowMajor(matrix);
1222
1207
  return { x: m.m41, y: m.m42, z: m.m43 };
1223
1208
  }
1224
1209
  /**
@@ -1228,13 +1213,13 @@ function fromMatrixPosition(matrix) {
1228
1213
  * @returns A parsed Vector3.
1229
1214
  */
1230
1215
  function fromJson$2(json) {
1231
- var obj = JSON.parse(json);
1216
+ const obj = JSON.parse(json);
1232
1217
  if (Array.isArray(obj)) {
1233
- var x = obj[0], y = obj[1], z = obj[2];
1218
+ const [x, y, z] = obj;
1234
1219
  return create$a(x, y, z);
1235
1220
  }
1236
1221
  else {
1237
- var x = obj.x, y = obj.y, z = obj.z;
1222
+ const { x, y, z } = obj;
1238
1223
  return create$a(x, y, z);
1239
1224
  }
1240
1225
  }
@@ -1245,11 +1230,10 @@ function fromJson$2(json) {
1245
1230
  * @see #toArray()
1246
1231
  * @see #create()
1247
1232
  */
1248
- function fromArray(nums, offset) {
1249
- if (offset === void 0) { offset = 0; }
1250
- var x = nums[offset];
1251
- var y = nums[offset + 1];
1252
- var z = nums[offset + 2];
1233
+ function fromArray(nums, offset = 0) {
1234
+ const x = nums[offset];
1235
+ const y = nums[offset + 1];
1236
+ const z = nums[offset + 2];
1253
1237
  return create$a(x, y, z);
1254
1238
  }
1255
1239
  /**
@@ -1259,8 +1243,7 @@ function fromArray(nums, offset) {
1259
1243
  * @see #fromArray()
1260
1244
  * @see #create()
1261
1245
  */
1262
- function toArray(_a) {
1263
- var x = _a.x, y = _a.y, z = _a.z;
1246
+ function toArray({ x, y, z }) {
1264
1247
  return [x, y, z];
1265
1248
  }
1266
1249
  /**
@@ -1309,7 +1292,7 @@ function origin() {
1309
1292
  * Returns a vector with that will have a magnitude of 1.
1310
1293
  */
1311
1294
  function normalize(vector) {
1312
- var length = magnitude(vector);
1295
+ const length = magnitude(vector);
1313
1296
  return { x: vector.x / length, y: vector.y / length, z: vector.z / length };
1314
1297
  }
1315
1298
  /**
@@ -1346,24 +1329,16 @@ function cross(a, b) {
1346
1329
  /**
1347
1330
  * Returns a vector that is the sum of two vectors.
1348
1331
  */
1349
- function add(a) {
1350
- var vectors = [];
1351
- for (var _i = 1; _i < arguments.length; _i++) {
1352
- vectors[_i - 1] = arguments[_i];
1353
- }
1354
- return vectors.reduce(function (res, next) {
1332
+ function add(a, ...vectors) {
1333
+ return vectors.reduce((res, next) => {
1355
1334
  return { x: res.x + next.x, y: res.y + next.y, z: res.z + next.z };
1356
1335
  }, a);
1357
1336
  }
1358
1337
  /**
1359
1338
  * Returns a vector that is the difference between two vectors.
1360
1339
  */
1361
- function subtract(a) {
1362
- var vectors = [];
1363
- for (var _i = 1; _i < arguments.length; _i++) {
1364
- vectors[_i - 1] = arguments[_i];
1365
- }
1366
- return vectors.reduce(function (res, next) {
1340
+ function subtract(a, ...vectors) {
1341
+ return vectors.reduce((res, next) => {
1367
1342
  return { x: res.x - next.x, y: res.y - next.y, z: res.z - next.z };
1368
1343
  }, a);
1369
1344
  }
@@ -1397,7 +1372,7 @@ function dot$1(a, b) {
1397
1372
  * result is never greater than 180 degrees.
1398
1373
  */
1399
1374
  function angleTo(a, b) {
1400
- var theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
1375
+ const theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
1401
1376
  // Clamp to avoid numerical problems.
1402
1377
  return Math.acos(theta);
1403
1378
  }
@@ -1408,15 +1383,18 @@ function angleTo(a, b) {
1408
1383
  * algorithm described in https://www.xarg.org/proof/quaternion-from-two-vectors/.
1409
1384
  */
1410
1385
  function eulerTo(a, b) {
1411
- var normalizedA = normalize(a);
1412
- var normalizedB = normalize(b);
1413
- var dotDelta = Math.cos(toRadians(1));
1414
- var dotAB = dot$1(normalizedA, normalizedB);
1415
- var vectorsAreParallel = Math.abs(dotAB) > dotDelta;
1386
+ const normalizedA = normalize(a);
1387
+ const normalizedB = normalize(b);
1388
+ const dotDelta = Math.cos(toRadians(1));
1389
+ const dotAB = dot$1(normalizedA, normalizedB);
1390
+ const vectorsAreParallel = Math.abs(dotAB) > dotDelta;
1416
1391
  if (vectorsAreParallel) {
1417
1392
  return dotAB > 1 - 1e-6 ? create$c() : create$c({ x: Math.PI });
1418
1393
  }
1419
- var normalizedQ = normalize$1(create$b(tslib.__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1394
+ const normalizedQ = normalize$1(create$b({
1395
+ w: 1 + dotAB,
1396
+ ...cross(normalizedA, normalizedB),
1397
+ }));
1420
1398
  return fromRotationMatrix(makeRotation(normalizedQ), 'xyz', false);
1421
1399
  }
1422
1400
  /**
@@ -1447,18 +1425,18 @@ function project(vector, onNormal) {
1447
1425
  */
1448
1426
  function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
1449
1427
  if (angle !== 0) {
1450
- var x = point.x, y = point.y, z = point.z;
1451
- var a = axisPosition.x, b = axisPosition.y, c = axisPosition.z;
1452
- var u = axisDirection.x, v = axisDirection.y, w = axisDirection.z;
1453
- var newX = (a * (v * v + w * w) - u * (b * v + c * w - u * x - v * y - w * z)) *
1428
+ const { x, y, z } = point;
1429
+ const { x: a, y: b, z: c } = axisPosition;
1430
+ const { x: u, y: v, z: w } = axisDirection;
1431
+ const newX = (a * (v * v + w * w) - u * (b * v + c * w - u * x - v * y - w * z)) *
1454
1432
  (1 - Math.cos(angle)) +
1455
1433
  x * Math.cos(angle) +
1456
1434
  (-c * v + b * w - w * y + v * z) * Math.sin(angle);
1457
- var newY = (b * (u * u + w * w) - v * (a * u + c * w - u * x - v * y - w * z)) *
1435
+ const newY = (b * (u * u + w * w) - v * (a * u + c * w - u * x - v * y - w * z)) *
1458
1436
  (1 - Math.cos(angle)) +
1459
1437
  y * Math.cos(angle) +
1460
1438
  (c * u - a * w + w * x - u * z) * Math.sin(angle);
1461
- var newZ = (c * (u * u + v * v) - w * (a * u + b * v - u * x - v * y - w * z)) *
1439
+ const newZ = (c * (u * u + v * v) - w * (a * u + b * v - u * x - v * y - w * z)) *
1462
1440
  (1 - Math.cos(angle)) +
1463
1441
  z * Math.cos(angle) +
1464
1442
  (-b * u + a * v - v * x + u * y) * Math.sin(angle);
@@ -1484,8 +1462,8 @@ function transformMatrix$1(vector, m) {
1484
1462
  * @param m A Matrix4 item written in column-major form.
1485
1463
  */
1486
1464
  function multiplyByTransformMatrixColumnMajor(vector, m) {
1487
- var x = vector.x, y = vector.y, z = vector.z;
1488
- var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
1465
+ const { x, y, z } = vector;
1466
+ const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
1489
1467
  return {
1490
1468
  x: (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,
1491
1469
  y: (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,
@@ -1498,8 +1476,8 @@ function multiplyByTransformMatrixColumnMajor(vector, m) {
1498
1476
  * @param m A Matrix4 item written in row-major form.
1499
1477
  */
1500
1478
  function multiplyByTransformMatrixRowMajor(vector, m) {
1501
- var x = vector.x, y = vector.y, z = vector.z;
1502
- var w = 1 / (m[12] * x + m[13] * y + m[14] * z + m[15]);
1479
+ const { x, y, z } = vector;
1480
+ const w = 1 / (m[12] * x + m[13] * y + m[14] * z + m[15]);
1503
1481
  return {
1504
1482
  x: (m[0] * x + m[1] * y + m[2] * z + m[3]) * w,
1505
1483
  y: (m[4] * x + m[5] * y + m[6] * z + m[7]) * w,
@@ -1517,7 +1495,7 @@ function distance$1(a, b) {
1517
1495
  * distances, this is slightly more efficient than `distanceTo`.
1518
1496
  */
1519
1497
  function distanceSquared$1(a, b) {
1520
- var _a = subtract(a, b), dx = _a.x, dy = _a.y, dz = _a.z;
1498
+ const { x: dx, y: dy, z: dz } = subtract(a, b);
1521
1499
  return dx * dx + dy * dy + dz * dz;
1522
1500
  }
1523
1501
  /**
@@ -1618,42 +1596,38 @@ var vector3 = /*#__PURE__*/Object.freeze({
1618
1596
  /**
1619
1597
  * Returns a `BoundingBox` with the given min and max points.
1620
1598
  */
1621
- var create$9 = function (min, max) {
1622
- return { min: min, max: max };
1599
+ const create$9 = (min, max) => {
1600
+ return { min, max };
1623
1601
  };
1624
1602
  /**
1625
1603
  * Construct a minimal bounding box for a set of vectors, such that all vectors
1626
1604
  * are contained by the bounding box.
1627
1605
  */
1628
- var fromVectors = function (vectors) {
1629
- return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
1606
+ const fromVectors = (vectors) => {
1607
+ return union(...vectors.map((v) => create$9(v, v)));
1630
1608
  };
1631
1609
  /**
1632
1610
  * Returns the center point of the given `BoundingBox`.
1633
1611
  */
1634
- var center$3 = function (boundingBox) {
1612
+ const center$3 = (boundingBox) => {
1635
1613
  return scale$2(0.5, add(boundingBox.min, boundingBox.max));
1636
1614
  };
1637
1615
  /**
1638
1616
  * Returns the diagonal vector between the `min` and `max` vectors of the
1639
1617
  * given `BoundingBox`.
1640
1618
  */
1641
- var diagonal = function (boundingBox) {
1619
+ const diagonal = (boundingBox) => {
1642
1620
  return subtract(boundingBox.max, boundingBox.min);
1643
1621
  };
1644
1622
  /**
1645
1623
  * Returns a floating-point spatial error tolerance based on the extents of the box.
1646
1624
  */
1647
- var epsilon = function (boundingBox) {
1625
+ const epsilon = (boundingBox) => {
1648
1626
  return (Math.max(Math.max(magnitude(boundingBox.max), magnitude(boundingBox.min)), magnitude(diagonal(boundingBox))) * 1e-6);
1649
1627
  };
1650
- function union(box) {
1651
- var rest = [];
1652
- for (var _i = 1; _i < arguments.length; _i++) {
1653
- rest[_i - 1] = arguments[_i];
1654
- }
1655
- var boxes = tslib.__spreadArray([box], rest, true);
1656
- return boxes.reduce(function (a, b) {
1628
+ function union(box, ...rest) {
1629
+ const boxes = [box, ...rest];
1630
+ return boxes.reduce((a, b) => {
1657
1631
  return create$9(min(a.min, b.min), max(a.max, b.max));
1658
1632
  });
1659
1633
  }
@@ -1662,7 +1636,7 @@ function union(box) {
1662
1636
  * Returns the distance between the min and max for the provided
1663
1637
  * bounding box for each axis.
1664
1638
  */
1665
- var lengths = function (box) {
1639
+ const lengths = (box) => {
1666
1640
  return create$a(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1667
1641
  };
1668
1642
  /**
@@ -1670,8 +1644,8 @@ var lengths = function (box) {
1670
1644
  * component. A component is invalid if it contains a non-finite or NaN value.
1671
1645
  */
1672
1646
  function isValid(boundingBox) {
1673
- var maxIsValid = isValid$1(boundingBox.max);
1674
- var minIsValid = isValid$1(boundingBox.min);
1647
+ const maxIsValid = isValid$1(boundingBox.max);
1648
+ const minIsValid = isValid$1(boundingBox.min);
1675
1649
  return maxIsValid && minIsValid;
1676
1650
  }
1677
1651
 
@@ -1690,13 +1664,13 @@ var boundingBox = /*#__PURE__*/Object.freeze({
1690
1664
  /**
1691
1665
  * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
1692
1666
  */
1693
- var create$8 = function (boundingBox$1) {
1694
- var boundingBoxCenter = center$3(boundingBox$1);
1695
- var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1696
- var radius = magnitude(centerToBoundingPlane);
1697
- var length = Math.max(radius, magnitude(boundingBoxCenter));
1698
- var epsilon = length === 0 ? 1.0 : length * 1e-6;
1699
- return { center: boundingBoxCenter, radius: radius, epsilon: epsilon };
1667
+ const create$8 = (boundingBox$1) => {
1668
+ const boundingBoxCenter = center$3(boundingBox$1);
1669
+ const centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1670
+ const radius = magnitude(centerToBoundingPlane);
1671
+ const length = Math.max(radius, magnitude(boundingBoxCenter));
1672
+ const epsilon = length === 0 ? 1.0 : length * 1e-6;
1673
+ return { center: boundingBoxCenter, radius, epsilon };
1700
1674
  };
1701
1675
 
1702
1676
  var boundingSphere = /*#__PURE__*/Object.freeze({
@@ -1708,7 +1682,7 @@ var boundingSphere = /*#__PURE__*/Object.freeze({
1708
1682
  * Returns a new `Rectangle` with the given position and size.
1709
1683
  */
1710
1684
  function create$7(x, y, width, height) {
1711
- return { x: x, y: y, width: width, height: height };
1685
+ return { x, y, width, height };
1712
1686
  }
1713
1687
  /**
1714
1688
  * Returns a new `Rectangle` at the origin point and given size.
@@ -1727,10 +1701,10 @@ function fromPointAndDimensions(point, dimensions) {
1727
1701
  * The returned rectangle will always returns a positive width and height.
1728
1702
  */
1729
1703
  function fromPoints(topLeftPt, bottomRightPt) {
1730
- var minX = Math.min(topLeftPt.x, bottomRightPt.x);
1731
- var minY = Math.min(topLeftPt.y, bottomRightPt.y);
1732
- var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1733
- var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1704
+ const minX = Math.min(topLeftPt.x, bottomRightPt.x);
1705
+ const minY = Math.min(topLeftPt.y, bottomRightPt.y);
1706
+ const maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1707
+ const maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1734
1708
  return create$7(minX, minY, maxX - minX, maxY - minY);
1735
1709
  }
1736
1710
  /**
@@ -1742,9 +1716,9 @@ function fromPoints(topLeftPt, bottomRightPt) {
1742
1716
  * @see {@link cropFit}
1743
1717
  */
1744
1718
  function containFit$1(to, rect) {
1745
- var scale = Math.min(to.width / rect.width, to.height / rect.height);
1746
- var dimensions$1 = proportionalScale(scale, rect);
1747
- var position = subtract$1(center$2(to), center$1(dimensions$1));
1719
+ const scale = Math.min(to.width / rect.width, to.height / rect.height);
1720
+ const dimensions$1 = proportionalScale(scale, rect);
1721
+ const position = subtract$1(center$2(to), center$1(dimensions$1));
1748
1722
  return fromPointAndDimensions(position, dimensions$1);
1749
1723
  }
1750
1724
  /**
@@ -1756,9 +1730,9 @@ function containFit$1(to, rect) {
1756
1730
  * @see {@link containFit}
1757
1731
  */
1758
1732
  function cropFit$1(to, rect) {
1759
- var scale = Math.max(to.width / rect.width, to.height / rect.height);
1760
- var dimensions$1 = proportionalScale(scale, rect);
1761
- var position = subtract$1(center$2(to), center$1(dimensions$1));
1733
+ const scale = Math.max(to.width / rect.width, to.height / rect.height);
1734
+ const dimensions$1 = proportionalScale(scale, rect);
1735
+ const position = subtract$1(center$2(to), center$1(dimensions$1));
1762
1736
  return fromPointAndDimensions(position, dimensions$1);
1763
1737
  }
1764
1738
  /**
@@ -1770,9 +1744,9 @@ function cropFit$1(to, rect) {
1770
1744
  * @param rect - the rectangle to scale to fit the specified area
1771
1745
  */
1772
1746
  function scaleFit$1(to, rect) {
1773
- var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
1774
- var dimensions$1 = floor(proportionalScale(scale, rect));
1775
- var position = subtract$1(center$2(rect), center$1(dimensions$1));
1747
+ const scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
1748
+ const dimensions$1 = floor(proportionalScale(scale, rect));
1749
+ const position = subtract$1(center$2(rect), center$1(dimensions$1));
1776
1750
  return fromPointAndDimensions(position, dimensions$1);
1777
1751
  }
1778
1752
  /**
@@ -1791,8 +1765,8 @@ function scale$1(rect, scaleOrScaleX, scaleY) {
1791
1765
  return scale$1(rect, scaleOrScaleX, scaleOrScaleX);
1792
1766
  }
1793
1767
  else {
1794
- var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
1795
- var scaleX = scaleOrScaleX;
1768
+ const { x, y, width, height } = rect;
1769
+ const scaleX = scaleOrScaleX;
1796
1770
  return create$7(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1797
1771
  }
1798
1772
  }
@@ -1866,12 +1840,8 @@ function pad(rect, padding) {
1866
1840
  * @param rect The rectangle to check against.
1867
1841
  * @param points The points to check.
1868
1842
  */
1869
- function containsPoints(rect) {
1870
- var points = [];
1871
- for (var _i = 1; _i < arguments.length; _i++) {
1872
- points[_i - 1] = arguments[_i];
1873
- }
1874
- return points.every(function (point) {
1843
+ function containsPoints(rect, ...points) {
1844
+ return points.every((point) => {
1875
1845
  return (rect.x <= point.x &&
1876
1846
  rect.x + rect.width >= point.x &&
1877
1847
  rect.y <= point.y &&
@@ -1885,13 +1855,13 @@ function containsPoints(rect) {
1885
1855
  * @returns A parsed Point.
1886
1856
  */
1887
1857
  function fromJson$1(json) {
1888
- var obj = JSON.parse(json);
1858
+ const obj = JSON.parse(json);
1889
1859
  if (Array.isArray(obj)) {
1890
- var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
1860
+ const [x, y, width, height] = obj;
1891
1861
  return create$7(x, y, width, height);
1892
1862
  }
1893
1863
  else {
1894
- var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
1864
+ const { x, y, width, height } = obj;
1895
1865
  return create$7(x, y, width, height);
1896
1866
  }
1897
1867
  }
@@ -1924,27 +1894,27 @@ var rectangle = /*#__PURE__*/Object.freeze({
1924
1894
  * Returns a `Dimensions` with the given width and height.
1925
1895
  *
1926
1896
  */
1927
- var create$6 = function (width, height) {
1928
- return { width: width, height: height };
1897
+ const create$6 = (width, height) => {
1898
+ return { width, height };
1929
1899
  };
1930
1900
  /**
1931
1901
  * Returns a `Dimensions` with the same width and height.
1932
1902
  */
1933
- var square = function (size) {
1903
+ const square = (size) => {
1934
1904
  return create$6(size, size);
1935
1905
  };
1936
1906
  /**
1937
1907
  * Returns `true` if two dimensions have the same width and height. Otherwise
1938
1908
  * `false`.
1939
1909
  */
1940
- var isEqual = function (a, b) {
1910
+ const isEqual = (a, b) => {
1941
1911
  return a.width === b.width && a.height === b.height;
1942
1912
  };
1943
1913
  /**
1944
1914
  * Returns a scaled dimensions, where the width is scaled by `scaleX` and height
1945
1915
  * is scaled by `scaleY`.
1946
1916
  */
1947
- var scale = function (scaleX, scaleY, dimensions) {
1917
+ const scale = (scaleX, scaleY, dimensions) => {
1948
1918
  return {
1949
1919
  width: dimensions.width * scaleX,
1950
1920
  height: dimensions.height * scaleY,
@@ -1953,14 +1923,14 @@ var scale = function (scaleX, scaleY, dimensions) {
1953
1923
  /**
1954
1924
  * Returns a dimension where each length is scaled by `scaleFactor`.
1955
1925
  */
1956
- var proportionalScale = function (scaleFactor, dimensions) {
1926
+ const proportionalScale = (scaleFactor, dimensions) => {
1957
1927
  return scale(scaleFactor, scaleFactor, dimensions);
1958
1928
  };
1959
1929
  /**
1960
1930
  * Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
1961
1931
  * into `to`.
1962
1932
  */
1963
- var trim = function (to, dimensions) {
1933
+ const trim = (to, dimensions) => {
1964
1934
  return {
1965
1935
  width: Math.min(to.width, dimensions.width),
1966
1936
  height: Math.min(to.height, dimensions.height),
@@ -1973,9 +1943,9 @@ var trim = function (to, dimensions) {
1973
1943
  *
1974
1944
  * @see #cropFit()
1975
1945
  */
1976
- var containFit = function (to, dimensions) {
1977
- var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
1978
- return { width: width, height: height };
1946
+ const containFit = (to, dimensions) => {
1947
+ const { width, height } = containFit$1(toRectangle(to), toRectangle(dimensions));
1948
+ return { width, height };
1979
1949
  };
1980
1950
  /**
1981
1951
  * Returns a `Dimensions` where the shortest length of `dimensions` will be
@@ -1984,9 +1954,9 @@ var containFit = function (to, dimensions) {
1984
1954
  *
1985
1955
  * @see #containFit()
1986
1956
  */
1987
- var cropFit = function (to, dimensions) {
1988
- var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
1989
- return { width: width, height: height };
1957
+ const cropFit = (to, dimensions) => {
1958
+ const { width, height } = cropFit$1(toRectangle(to), toRectangle(dimensions));
1959
+ return { width, height };
1990
1960
  };
1991
1961
  /**
1992
1962
  * Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally
@@ -1996,14 +1966,14 @@ var cropFit = function (to, dimensions) {
1996
1966
  * @param to - the maximum area this dimensions can have
1997
1967
  * @param dimensions - the dimensions to scale to fit the specified area
1998
1968
  */
1999
- var scaleFit = function (to, dimensions) {
2000
- var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
2001
- return { width: width, height: height };
1969
+ const scaleFit = (to, dimensions) => {
1970
+ const { width, height } = scaleFit$1(to, toRectangle(dimensions));
1971
+ return { width, height };
2002
1972
  };
2003
1973
  /**
2004
1974
  * Returns a `Dimensions` with each length rounded.
2005
1975
  */
2006
- var round = function (dimensions) {
1976
+ const round = (dimensions) => {
2007
1977
  return {
2008
1978
  width: Math.round(dimensions.width),
2009
1979
  height: Math.round(dimensions.height),
@@ -2012,7 +1982,7 @@ var round = function (dimensions) {
2012
1982
  /**
2013
1983
  * Returns a `Dimensions` with each length rounded down.
2014
1984
  */
2015
- var floor = function (dimensions) {
1985
+ const floor = (dimensions) => {
2016
1986
  return {
2017
1987
  width: Math.floor(dimensions.width),
2018
1988
  height: Math.floor(dimensions.height),
@@ -2021,22 +1991,20 @@ var floor = function (dimensions) {
2021
1991
  /**
2022
1992
  * Returns the center point of the given `dimensions`.
2023
1993
  */
2024
- var center$1 = function (dimensions) {
1994
+ const center$1 = (dimensions) => {
2025
1995
  return { x: dimensions.width / 2, y: dimensions.height / 2 };
2026
1996
  };
2027
1997
  /**
2028
1998
  * Returns the aspect ratio of the given `dimensions`, as defined by width over
2029
1999
  * height.
2030
2000
  */
2031
- var aspectRatio = function (_a) {
2032
- var width = _a.width, height = _a.height;
2001
+ const aspectRatio = ({ width, height }) => {
2033
2002
  return width / height;
2034
2003
  };
2035
2004
  /**
2036
2005
  * Returns the area of the given `dimensions`.
2037
2006
  */
2038
- var area = function (_a) {
2039
- var width = _a.width, height = _a.height;
2007
+ const area = ({ width, height }) => {
2040
2008
  return width * height;
2041
2009
  };
2042
2010
  /**
@@ -2045,7 +2013,7 @@ var area = function (_a) {
2045
2013
  * @param ratio - Aspect ratio to fit the provided Dimensions to
2046
2014
  * @param dimensions - Dimensions to fit to the specified ratio
2047
2015
  */
2048
- var fitToRatio = function (ratio, dimensions) {
2016
+ const fitToRatio = (ratio, dimensions) => {
2049
2017
  if (dimensions.width >= dimensions.height * ratio) {
2050
2018
  return create$6(dimensions.height * ratio, dimensions.height);
2051
2019
  }
@@ -2054,8 +2022,7 @@ var fitToRatio = function (ratio, dimensions) {
2054
2022
  /**
2055
2023
  * Converts a dimension to a rectangle, with an optional position.
2056
2024
  */
2057
- function toRectangle(dimensions, position) {
2058
- if (position === void 0) { position = create$d(); }
2025
+ function toRectangle(dimensions, position = create$d()) {
2059
2026
  return fromPointAndDimensions(position, dimensions);
2060
2027
  }
2061
2028
 
@@ -2085,9 +2052,8 @@ var dimensions = /*#__PURE__*/Object.freeze({
2085
2052
  *
2086
2053
  * @param values The values to assign to the line.
2087
2054
  */
2088
- function create$5(values) {
2055
+ function create$5(values = {}) {
2089
2056
  var _a, _b;
2090
- if (values === void 0) { values = {}; }
2091
2057
  return {
2092
2058
  start: (_a = values.start) !== null && _a !== void 0 ? _a : origin(),
2093
2059
  end: (_b = values.end) !== null && _b !== void 0 ? _b : origin(),
@@ -2108,9 +2074,9 @@ function center(line) {
2108
2074
  * @returns A transformed line.
2109
2075
  */
2110
2076
  function transformMatrix(line, matrix) {
2111
- var start = multiplyByTransformMatrixColumnMajor(line.start, matrix);
2112
- var end = multiplyByTransformMatrixColumnMajor(line.end, matrix);
2113
- return { start: start, end: end };
2077
+ const start = multiplyByTransformMatrixColumnMajor(line.start, matrix);
2078
+ const end = multiplyByTransformMatrixColumnMajor(line.end, matrix);
2079
+ return { start, end };
2114
2080
  }
2115
2081
  /**
2116
2082
  * Euclidean distance between the start and end points of the line.
@@ -2145,62 +2111,56 @@ var line3 = /*#__PURE__*/Object.freeze({
2145
2111
  /**
2146
2112
  * Creates a new matrix. If arguments are undefined, returns an identity matrix.
2147
2113
  */
2148
- var create$4 = function (a, b, c, d, tx, ty) {
2149
- if (a === void 0) { a = 1; }
2150
- if (b === void 0) { b = 0; }
2151
- if (c === void 0) { c = 0; }
2152
- if (d === void 0) { d = 1; }
2153
- if (tx === void 0) { tx = 0; }
2154
- if (ty === void 0) { ty = 0; }
2155
- return { a: a, b: b, c: c, d: d, tx: tx, ty: ty };
2114
+ const create$4 = (a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) => {
2115
+ return { a, b, c, d, tx, ty };
2156
2116
  };
2157
2117
  /**
2158
2118
  * Returns an identity matrix.
2159
2119
  */
2160
- var identity = function () {
2120
+ const identity = () => {
2161
2121
  return create$4();
2162
2122
  };
2163
2123
  /**
2164
2124
  * Creates a matrix that is translated by the given `tx` and `ty` values.
2165
2125
  */
2166
- var translation = function (tx, ty) {
2126
+ const translation = (tx, ty) => {
2167
2127
  return translate(tx, ty, identity());
2168
2128
  };
2169
2129
  /**
2170
2130
  * Creates a matrix that is rotated by the given degrees.
2171
2131
  */
2172
- var rotation = function (degrees) {
2132
+ const rotation = (degrees) => {
2173
2133
  return rotate(degrees, identity());
2174
2134
  };
2175
2135
  /**
2176
2136
  * Rotates the given matrix by the given degrees.
2177
2137
  */
2178
- var rotate = function (degrees, matrix) {
2179
- var radians = toRadians(degrees);
2180
- var cos = Math.cos(radians);
2181
- var sin = Math.sin(radians);
2182
- var a = matrix.a * cos + matrix.c * sin;
2183
- var b = matrix.b * cos + matrix.d * sin;
2184
- var c = matrix.a * -sin + matrix.c * cos;
2185
- var d = matrix.b * -sin + matrix.d * cos;
2138
+ const rotate = (degrees, matrix) => {
2139
+ const radians = toRadians(degrees);
2140
+ const cos = Math.cos(radians);
2141
+ const sin = Math.sin(radians);
2142
+ const a = matrix.a * cos + matrix.c * sin;
2143
+ const b = matrix.b * cos + matrix.d * sin;
2144
+ const c = matrix.a * -sin + matrix.c * cos;
2145
+ const d = matrix.b * -sin + matrix.d * cos;
2186
2146
  return create$4(a, b, c, d, matrix.tx, matrix.ty);
2187
2147
  };
2188
2148
  /**
2189
2149
  * Translates the given matrix along the horizontal and vertical axis by the
2190
2150
  * given `dx` and `dy` delta values.
2191
2151
  */
2192
- var translate = function (dx, dy, matrix) {
2193
- var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
2194
- var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
2152
+ const translate = (dx, dy, matrix) => {
2153
+ const newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
2154
+ const newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
2195
2155
  return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2196
2156
  };
2197
2157
  /**
2198
2158
  * Returns the result of applying a geometric transformation of a matrix on the
2199
2159
  * given point.
2200
2160
  */
2201
- var transformPoint = function (matrix, pt) {
2202
- var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
2203
- var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
2161
+ const transformPoint = (matrix, pt) => {
2162
+ const x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
2163
+ const y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
2204
2164
  return create$d(x, y);
2205
2165
  };
2206
2166
 
@@ -2215,11 +2175,7 @@ var matrix = /*#__PURE__*/Object.freeze({
2215
2175
  translation: translation
2216
2176
  });
2217
2177
 
2218
- function create$3() {
2219
- var args = [];
2220
- for (var _i = 0; _i < arguments.length; _i++) {
2221
- args[_i] = arguments[_i];
2222
- }
2178
+ function create$3(...args) {
2223
2179
  if (args.length === 2) {
2224
2180
  return {
2225
2181
  a: args[0].x,
@@ -2269,9 +2225,8 @@ var matrix2 = /*#__PURE__*/Object.freeze({
2269
2225
  * @param values Values to assign to the plane.
2270
2226
  * @returns A new plane.
2271
2227
  */
2272
- function create$2(values) {
2273
- if (values === void 0) { values = {}; }
2274
- return tslib.__assign({ normal: origin(), constant: 0 }, values);
2228
+ function create$2(values = {}) {
2229
+ return { normal: origin(), constant: 0, ...values };
2275
2230
  }
2276
2231
  /**
2277
2232
  * Creates a plane from a normal and an arbitrary point on a plane.
@@ -2281,8 +2236,8 @@ function create$2(values) {
2281
2236
  * @returns A new plane.
2282
2237
  */
2283
2238
  function fromNormalAndCoplanarPoint(normal, point) {
2284
- var constant = -dot$1(point, normal);
2285
- return create$2({ normal: normal, constant: constant });
2239
+ const constant = -dot$1(point, normal);
2240
+ return create$2({ normal, constant });
2286
2241
  }
2287
2242
  /**
2288
2243
  * Returns the perpendicular distance from the plane to the given point.
@@ -2304,8 +2259,8 @@ function distanceToPoint(plane, point) {
2304
2259
  * @returns An intersecting point on the plane and line.
2305
2260
  */
2306
2261
  function intersectLine(plane, line) {
2307
- var direction$1 = direction(line);
2308
- var denominator = dot$1(plane.normal, direction$1);
2262
+ const direction$1 = direction(line);
2263
+ const denominator = dot$1(plane.normal, direction$1);
2309
2264
  if (denominator === 0) {
2310
2265
  if (distanceToPoint(plane, line.start) === 0) {
2311
2266
  return line.start;
@@ -2314,7 +2269,7 @@ function intersectLine(plane, line) {
2314
2269
  return undefined;
2315
2270
  }
2316
2271
  }
2317
- var t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
2272
+ const t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
2318
2273
  if (t < 0 || t > 1) {
2319
2274
  return undefined;
2320
2275
  }
@@ -2330,7 +2285,7 @@ function intersectLine(plane, line) {
2330
2285
  * @returns The projected point.
2331
2286
  */
2332
2287
  function projectPoint(plane, point) {
2333
- var d = distanceToPoint(plane, point);
2288
+ const d = distanceToPoint(plane, point);
2334
2289
  return add(point, scale$2(-d, plane.normal));
2335
2290
  }
2336
2291
 
@@ -2350,9 +2305,8 @@ var plane = /*#__PURE__*/Object.freeze({
2350
2305
  * @param value The values of the ray.
2351
2306
  * @returns A new ray.
2352
2307
  */
2353
- function create$1(value) {
2308
+ function create$1(value = {}) {
2354
2309
  var _a, _b;
2355
- if (value === void 0) { value = {}; }
2356
2310
  return {
2357
2311
  origin: (_a = value.origin) !== null && _a !== void 0 ? _a : origin(),
2358
2312
  direction: (_b = value.direction) !== null && _b !== void 0 ? _b : forward(),
@@ -2378,13 +2332,13 @@ function at(ray, distance) {
2378
2332
  * @returns The distance to the plane, or `undefined` if it cannot be computed.
2379
2333
  */
2380
2334
  function distanceToPlane(ray, plane$1) {
2381
- var d = dot$1(plane$1.normal, ray.direction);
2335
+ const d = dot$1(plane$1.normal, ray.direction);
2382
2336
  if (d === 0) {
2383
2337
  // Ray is on plane.
2384
2338
  return distanceToPoint(plane$1, ray.origin) === 0 ? 0 : undefined;
2385
2339
  }
2386
2340
  else {
2387
- var t = -(dot$1(ray.origin, plane$1.normal) + plane$1.constant) / d;
2341
+ const t = -(dot$1(ray.origin, plane$1.normal) + plane$1.constant) / d;
2388
2342
  // Checks if ray intersects plane.
2389
2343
  return t >= 0 ? t : undefined;
2390
2344
  }
@@ -2399,7 +2353,7 @@ function distanceToPlane(ray, plane$1) {
2399
2353
  * intersect.
2400
2354
  */
2401
2355
  function intersectPlane(ray, plane) {
2402
- var t = distanceToPlane(ray, plane);
2356
+ const t = distanceToPlane(ray, plane);
2403
2357
  return t != null ? at(ray, t) : undefined;
2404
2358
  }
2405
2359
 
@@ -2415,9 +2369,8 @@ var ray = /*#__PURE__*/Object.freeze({
2415
2369
  * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,
2416
2370
  * w: 0}` is returned.
2417
2371
  */
2418
- function create(value) {
2419
- if (value === void 0) { value = {}; }
2420
- return tslib.__assign({ x: 0, y: 0, z: 0, w: 0 }, value);
2372
+ function create(value = {}) {
2373
+ return { x: 0, y: 0, z: 0, w: 0, ...value };
2421
2374
  }
2422
2375
  /**
2423
2376
  * Parses a JSON string representation of a `Vector4`.
@@ -2426,10 +2379,10 @@ function create(value) {
2426
2379
  * @returns A parsed `Vector4`.
2427
2380
  */
2428
2381
  function fromJson(json) {
2429
- var obj = JSON.parse(json);
2382
+ const obj = JSON.parse(json);
2430
2383
  if (Array.isArray(obj)) {
2431
- var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
2432
- return create({ x: x, y: y, z: z, w: w });
2384
+ const [x, y, z, w] = obj;
2385
+ return create({ x, y, z, w });
2433
2386
  }
2434
2387
  else {
2435
2388
  return create(obj);