@vertexvis/viewer 0.10.2-canary.7 → 0.11.0

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