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