@vertexvis/geometry 0.23.5 → 0.23.6-canary.1

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.
@@ -33,7 +33,7 @@ function lerp$2(a, b, t) {
33
33
  /**
34
34
  * Returns a new `Point` with the given horizontal and vertical position.
35
35
  */
36
- function create$c(x, y) {
36
+ function create$d(x, y) {
37
37
  if (x === void 0) { x = 0; }
38
38
  if (y === void 0) { y = 0; }
39
39
  return { x: x, y: y };
@@ -44,7 +44,7 @@ function create$c(x, y) {
44
44
  function polar(length, radians) {
45
45
  var x = Math.cos(radians) * length;
46
46
  var y = Math.sin(radians) * length;
47
- return create$c(x, y);
47
+ return create$d(x, y);
48
48
  }
49
49
  /**
50
50
  * Returns the distance between two points.
@@ -90,7 +90,7 @@ function lerp$1(a, b, t) {
90
90
  * Returns a new `Point` where `x` and `y` are inverted.
91
91
  */
92
92
  function negate$1(pt) {
93
- return create$c(-pt.x, -pt.y);
93
+ return create$d(-pt.x, -pt.y);
94
94
  }
95
95
  /**
96
96
  * Returns a new `Point` where `x` and `y` are multiplied by the given scale
@@ -124,7 +124,7 @@ function magnitude$2(pt) {
124
124
  function normalizeVector(pt) {
125
125
  var magnitudeOfPoint = magnitude$2(pt);
126
126
  if (magnitudeOfPoint === 0) {
127
- return create$c(0, 0);
127
+ return create$d(0, 0);
128
128
  }
129
129
  else {
130
130
  return scaleProportional(pt, 1 / magnitudeOfPoint);
@@ -143,17 +143,17 @@ function orthogonalVector(ptA, ptB) {
143
143
  var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
144
144
  // Handle vectors that are parallel to the x or y axis
145
145
  if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
146
- return create$c(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
146
+ return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
147
147
  }
148
148
  if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
149
149
  var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
150
150
  var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
151
- return normalizeVector(create$c(vectorXValue, vectorYValue));
151
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
152
152
  }
153
153
  else {
154
154
  var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
155
155
  var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
156
- return normalizeVector(create$c(vectorXValue, vectorYValue));
156
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
157
157
  }
158
158
  }
159
159
  /**
@@ -162,21 +162,21 @@ function orthogonalVector(ptA, ptB) {
162
162
  * @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
163
163
  * @returns A parsed Point.
164
164
  */
165
- function fromJson$4(json) {
165
+ function fromJson$5(json) {
166
166
  var obj = JSON.parse(json);
167
167
  if (Array.isArray(obj)) {
168
168
  var x = obj[0], y = obj[1];
169
- return create$c(x, y);
169
+ return create$d(x, y);
170
170
  }
171
171
  else {
172
172
  var x = obj.x, y = obj.y;
173
- return create$c(x, y);
173
+ return create$d(x, y);
174
174
  }
175
175
  }
176
176
 
177
177
  var point = /*#__PURE__*/Object.freeze({
178
178
  __proto__: null,
179
- create: create$c,
179
+ create: create$d,
180
180
  polar: polar,
181
181
  distance: distance$2,
182
182
  subtract: subtract$1,
@@ -190,7 +190,7 @@ var point = /*#__PURE__*/Object.freeze({
190
190
  normalizeVector: normalizeVector,
191
191
  normalDirectionVector: normalDirectionVector,
192
192
  orthogonalVector: orthogonalVector,
193
- fromJson: fromJson$4
193
+ fromJson: fromJson$5
194
194
  });
195
195
 
196
196
  /**
@@ -812,7 +812,7 @@ var matrix4 = /*#__PURE__*/Object.freeze({
812
812
  * @param value The values to populate the euler angle with.
813
813
  * @returns A euler angle.
814
814
  */
815
- function create$b(value) {
815
+ function create$c(value) {
816
816
  var _a, _b, _c, _d;
817
817
  if (value === void 0) { value = {}; }
818
818
  return {
@@ -833,7 +833,7 @@ function create$b(value) {
833
833
  function fromDegrees(value) {
834
834
  if (value === void 0) { value = {}; }
835
835
  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;
836
- return create$b({
836
+ return create$c({
837
837
  x: toRadians(x),
838
838
  y: toRadians(y),
839
839
  z: toRadians(z),
@@ -927,7 +927,7 @@ function fromRotationMatrix(matrix, order) {
927
927
  * @param json A JSON object.
928
928
  * @returns A euler angle.
929
929
  */
930
- function fromJson$3(json) {
930
+ function fromJson$4(json) {
931
931
  var obj = JSON.parse(json);
932
932
  if (Array.isArray(obj)) {
933
933
  var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
@@ -953,10 +953,10 @@ function isType$1(obj) {
953
953
 
954
954
  var euler = /*#__PURE__*/Object.freeze({
955
955
  __proto__: null,
956
- create: create$b,
956
+ create: create$c,
957
957
  fromDegrees: fromDegrees,
958
958
  fromRotationMatrix: fromRotationMatrix,
959
- fromJson: fromJson$3,
959
+ fromJson: fromJson$4,
960
960
  isType: isType$1
961
961
  });
962
962
 
@@ -964,7 +964,7 @@ var euler = /*#__PURE__*/Object.freeze({
964
964
  * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
965
965
  * w: 1}` is returned.
966
966
  */
967
- function create$a(value) {
967
+ function create$b(value) {
968
968
  if (value === void 0) { value = {}; }
969
969
  return tslib.__assign({ x: 0, y: 0, z: 0, w: 1 }, value);
970
970
  }
@@ -974,14 +974,14 @@ function create$a(value) {
974
974
  * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
975
975
  * @returns A parsed `Quaternion`.
976
976
  */
977
- function fromJson$2(json) {
977
+ function fromJson$3(json) {
978
978
  var obj = JSON.parse(json);
979
979
  if (Array.isArray(obj)) {
980
980
  var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
981
- return create$a({ x: x, y: y, z: z, w: w });
981
+ return create$b({ x: x, y: y, z: z, w: w });
982
982
  }
983
983
  else {
984
- return create$a(obj);
984
+ return create$b(obj);
985
985
  }
986
986
  }
987
987
  /**
@@ -1000,7 +1000,7 @@ function magnitude$1(q) {
1000
1000
  * Returns a quaternion where each component is multiplied by the `scalar`.
1001
1001
  */
1002
1002
  function scale$3(scalar, q) {
1003
- return create$a({
1003
+ return create$b({
1004
1004
  w: q.w * scalar,
1005
1005
  x: q.x * scalar,
1006
1006
  y: q.y * scalar,
@@ -1156,8 +1156,8 @@ function isType(obj) {
1156
1156
 
1157
1157
  var quaternion = /*#__PURE__*/Object.freeze({
1158
1158
  __proto__: null,
1159
- create: create$a,
1160
- fromJson: fromJson$2,
1159
+ create: create$b,
1160
+ fromJson: fromJson$3,
1161
1161
  normalize: normalize$1,
1162
1162
  magnitude: magnitude$1,
1163
1163
  scale: scale$3,
@@ -1168,7 +1168,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
1168
1168
  isType: isType
1169
1169
  });
1170
1170
 
1171
- function create$9() {
1171
+ function create$a() {
1172
1172
  var _a, _b, _c, _d, _e, _f;
1173
1173
  var args = [];
1174
1174
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1228,15 +1228,15 @@ function fromMatrixPosition(matrix) {
1228
1228
  * @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
1229
1229
  * @returns A parsed Vector3.
1230
1230
  */
1231
- function fromJson$1(json) {
1231
+ function fromJson$2(json) {
1232
1232
  var obj = JSON.parse(json);
1233
1233
  if (Array.isArray(obj)) {
1234
1234
  var x = obj[0], y = obj[1], z = obj[2];
1235
- return create$9(x, y, z);
1235
+ return create$a(x, y, z);
1236
1236
  }
1237
1237
  else {
1238
1238
  var x = obj.x, y = obj.y, z = obj.z;
1239
- return create$9(x, y, z);
1239
+ return create$a(x, y, z);
1240
1240
  }
1241
1241
  }
1242
1242
  /**
@@ -1251,7 +1251,7 @@ function fromArray(nums, offset) {
1251
1251
  var x = nums[offset];
1252
1252
  var y = nums[offset + 1];
1253
1253
  var z = nums[offset + 2];
1254
- return create$9(x, y, z);
1254
+ return create$a(x, y, z);
1255
1255
  }
1256
1256
  /**
1257
1257
  * Converts a Vector3 to an array where the values of the vector will be
@@ -1268,43 +1268,43 @@ function toArray(_a) {
1268
1268
  * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
1269
1269
  */
1270
1270
  function right() {
1271
- return create$9(1, 0, 0);
1271
+ return create$a(1, 0, 0);
1272
1272
  }
1273
1273
  /**
1274
1274
  * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
1275
1275
  */
1276
1276
  function up() {
1277
- return create$9(0, 1, 0);
1277
+ return create$a(0, 1, 0);
1278
1278
  }
1279
1279
  /**
1280
1280
  * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
1281
1281
  */
1282
1282
  function forward() {
1283
- return create$9(0, 0, -1);
1283
+ return create$a(0, 0, -1);
1284
1284
  }
1285
1285
  /**
1286
1286
  * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
1287
1287
  */
1288
1288
  function left() {
1289
- return create$9(-1, 0, 0);
1289
+ return create$a(-1, 0, 0);
1290
1290
  }
1291
1291
  /**
1292
1292
  * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
1293
1293
  */
1294
1294
  function down() {
1295
- return create$9(0, -1, 0);
1295
+ return create$a(0, -1, 0);
1296
1296
  }
1297
1297
  /**
1298
1298
  * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
1299
1299
  */
1300
1300
  function back() {
1301
- return create$9(0, 0, 1);
1301
+ return create$a(0, 0, 1);
1302
1302
  }
1303
1303
  /**
1304
1304
  * Returns a vector at the origin, Vector3(0, 0, 0).
1305
1305
  */
1306
1306
  function origin() {
1307
- return create$9(0, 0, 0);
1307
+ return create$a(0, 0, 0);
1308
1308
  }
1309
1309
  /**
1310
1310
  * Returns a vector with that will have a magnitude of 1.
@@ -1415,9 +1415,9 @@ function eulerTo(a, b) {
1415
1415
  var dotAB = dot$1(normalizedA, normalizedB);
1416
1416
  var vectorsAreParallel = Math.abs(dotAB) > dotDelta;
1417
1417
  if (vectorsAreParallel) {
1418
- return dotAB > 1 - 1e-6 ? create$b() : create$b({ x: Math.PI });
1418
+ return dotAB > 1 - 1e-6 ? create$c() : create$c({ x: Math.PI });
1419
1419
  }
1420
- var normalizedQ = normalize$1(create$a(tslib.__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1420
+ var normalizedQ = normalize$1(create$b(tslib.__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1421
1421
  return fromRotationMatrix(makeRotation(normalizedQ));
1422
1422
  }
1423
1423
  /**
@@ -1505,13 +1505,13 @@ function isEqual$2(a, b) {
1505
1505
  * Returns a vector that contains the largest components of `a` and `b`.
1506
1506
  */
1507
1507
  function max(a, b) {
1508
- return create$9(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1508
+ return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1509
1509
  }
1510
1510
  /**
1511
1511
  * Returns a vector that contains the smallest components of `a` and `b`.
1512
1512
  */
1513
1513
  function min(a, b) {
1514
- return create$9(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1514
+ return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1515
1515
  }
1516
1516
  /**
1517
1517
  * Returns a vector that each of its component negated.
@@ -1549,11 +1549,11 @@ function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
1549
1549
 
1550
1550
  var vector3 = /*#__PURE__*/Object.freeze({
1551
1551
  __proto__: null,
1552
- create: create$9,
1552
+ create: create$a,
1553
1553
  isValid: isValid,
1554
1554
  fromMatrixScale: fromMatrixScale,
1555
1555
  fromMatrixPosition: fromMatrixPosition,
1556
- fromJson: fromJson$1,
1556
+ fromJson: fromJson$2,
1557
1557
  fromArray: fromArray,
1558
1558
  toArray: toArray,
1559
1559
  right: right,
@@ -1590,7 +1590,7 @@ var vector3 = /*#__PURE__*/Object.freeze({
1590
1590
  /**
1591
1591
  * Returns a `BoundingBox` with the given min and max points.
1592
1592
  */
1593
- var create$8 = function (min, max) {
1593
+ var create$9 = function (min, max) {
1594
1594
  return { min: min, max: max };
1595
1595
  };
1596
1596
  /**
@@ -1598,7 +1598,7 @@ var create$8 = function (min, max) {
1598
1598
  * are contained by the bounding box.
1599
1599
  */
1600
1600
  var fromVectors = function (vectors) {
1601
- return union.apply(void 0, vectors.map(function (v) { return create$8(v, v); }));
1601
+ return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
1602
1602
  };
1603
1603
  /**
1604
1604
  * Returns the center point of the given `BoundingBox`.
@@ -1626,7 +1626,7 @@ function union(box) {
1626
1626
  }
1627
1627
  var boxes = tslib.__spreadArray([box], rest, true);
1628
1628
  return boxes.reduce(function (a, b) {
1629
- return create$8(min(a.min, b.min), max(a.max, b.max));
1629
+ return create$9(min(a.min, b.min), max(a.max, b.max));
1630
1630
  });
1631
1631
  }
1632
1632
  /* eslint-enable padding-line-between-statements */
@@ -1635,12 +1635,12 @@ function union(box) {
1635
1635
  * bounding box for each axis.
1636
1636
  */
1637
1637
  var lengths = function (box) {
1638
- return create$9(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1638
+ return create$a(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1639
1639
  };
1640
1640
 
1641
1641
  var boundingBox = /*#__PURE__*/Object.freeze({
1642
1642
  __proto__: null,
1643
- create: create$8,
1643
+ create: create$9,
1644
1644
  fromVectors: fromVectors,
1645
1645
  center: center$3,
1646
1646
  diagonal: diagonal,
@@ -1652,7 +1652,7 @@ var boundingBox = /*#__PURE__*/Object.freeze({
1652
1652
  /**
1653
1653
  * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
1654
1654
  */
1655
- var create$7 = function (boundingBox$1) {
1655
+ var create$8 = function (boundingBox$1) {
1656
1656
  var boundingBoxCenter = center$3(boundingBox$1);
1657
1657
  var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1658
1658
  var radius = magnitude(centerToBoundingPlane);
@@ -1663,26 +1663,26 @@ var create$7 = function (boundingBox$1) {
1663
1663
 
1664
1664
  var boundingSphere = /*#__PURE__*/Object.freeze({
1665
1665
  __proto__: null,
1666
- create: create$7
1666
+ create: create$8
1667
1667
  });
1668
1668
 
1669
1669
  /**
1670
1670
  * Returns a new `Rectangle` with the given position and size.
1671
1671
  */
1672
- function create$6(x, y, width, height) {
1672
+ function create$7(x, y, width, height) {
1673
1673
  return { x: x, y: y, width: width, height: height };
1674
1674
  }
1675
1675
  /**
1676
1676
  * Returns a new `Rectangle` at the origin point and given size.
1677
1677
  */
1678
1678
  function fromDimensions(dimensions) {
1679
- return create$6(0, 0, dimensions.width, dimensions.height);
1679
+ return create$7(0, 0, dimensions.width, dimensions.height);
1680
1680
  }
1681
1681
  /**
1682
1682
  * Returns a new `Rectangle` with the given position and size.
1683
1683
  */
1684
1684
  function fromPointAndDimensions(point, dimensions) {
1685
- return create$6(point.x, point.y, dimensions.width, dimensions.height);
1685
+ return create$7(point.x, point.y, dimensions.width, dimensions.height);
1686
1686
  }
1687
1687
  /**
1688
1688
  * Returns a new `Rectangle` with the given top-left and bottom-right positions.
@@ -1693,7 +1693,7 @@ function fromPoints(topLeftPt, bottomRightPt) {
1693
1693
  var minY = Math.min(topLeftPt.y, bottomRightPt.y);
1694
1694
  var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1695
1695
  var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1696
- return create$6(minX, minY, maxX - minX, maxY - minY);
1696
+ return create$7(minX, minY, maxX - minX, maxY - minY);
1697
1697
  }
1698
1698
  /**
1699
1699
  * Returns a rectangle where the longest length of `rect` will be equal to the
@@ -1755,7 +1755,7 @@ function scale$1(rect, scaleOrScaleX, scaleY) {
1755
1755
  else {
1756
1756
  var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
1757
1757
  var scaleX = scaleOrScaleX;
1758
- return create$6(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1758
+ return create$7(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1759
1759
  }
1760
1760
  }
1761
1761
  /**
@@ -1787,13 +1787,13 @@ function center$2(rect) {
1787
1787
  * Returns the top-left position of the rectangle, as a point.
1788
1788
  */
1789
1789
  function topLeft(rect) {
1790
- return create$c(rect.x, rect.y);
1790
+ return create$d(rect.x, rect.y);
1791
1791
  }
1792
1792
  /**
1793
1793
  * Returns the bottom-right position of the rectangle, as a point.
1794
1794
  */
1795
1795
  function bottomRight(rect) {
1796
- return create$c(rect.x + rect.width, rect.y + rect.height);
1796
+ return create$d(rect.x + rect.width, rect.y + rect.height);
1797
1797
  }
1798
1798
  /**
1799
1799
  * Returns `true` if the given rectangle has a portrait aspect ratio.
@@ -1820,7 +1820,7 @@ function isSquare(rect) {
1820
1820
  * @param padding The padding to add.
1821
1821
  */
1822
1822
  function pad(rect, padding) {
1823
- return create$6(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1823
+ return create$7(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1824
1824
  }
1825
1825
  /**
1826
1826
  * Returns `true` if the given rectangle contains all the given `points`.
@@ -1846,21 +1846,21 @@ function containsPoints(rect) {
1846
1846
  * @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
1847
1847
  * @returns A parsed Point.
1848
1848
  */
1849
- function fromJson(json) {
1849
+ function fromJson$1(json) {
1850
1850
  var obj = JSON.parse(json);
1851
1851
  if (Array.isArray(obj)) {
1852
1852
  var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
1853
- return create$6(x, y, width, height);
1853
+ return create$7(x, y, width, height);
1854
1854
  }
1855
1855
  else {
1856
1856
  var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
1857
- return create$6(x, y, width, height);
1857
+ return create$7(x, y, width, height);
1858
1858
  }
1859
1859
  }
1860
1860
 
1861
1861
  var rectangle = /*#__PURE__*/Object.freeze({
1862
1862
  __proto__: null,
1863
- create: create$6,
1863
+ create: create$7,
1864
1864
  fromDimensions: fromDimensions,
1865
1865
  fromPointAndDimensions: fromPointAndDimensions,
1866
1866
  fromPoints: fromPoints,
@@ -1879,21 +1879,21 @@ var rectangle = /*#__PURE__*/Object.freeze({
1879
1879
  isSquare: isSquare,
1880
1880
  pad: pad,
1881
1881
  containsPoints: containsPoints,
1882
- fromJson: fromJson
1882
+ fromJson: fromJson$1
1883
1883
  });
1884
1884
 
1885
1885
  /**
1886
1886
  * Returns a `Dimensions` with the given width and height.
1887
1887
  *
1888
1888
  */
1889
- var create$5 = function (width, height) {
1889
+ var create$6 = function (width, height) {
1890
1890
  return { width: width, height: height };
1891
1891
  };
1892
1892
  /**
1893
1893
  * Returns a `Dimensions` with the same width and height.
1894
1894
  */
1895
1895
  var square = function (size) {
1896
- return create$5(size, size);
1896
+ return create$6(size, size);
1897
1897
  };
1898
1898
  /**
1899
1899
  * Returns `true` if two dimensions have the same width and height. Otherwise
@@ -2009,21 +2009,21 @@ var area = function (_a) {
2009
2009
  */
2010
2010
  var fitToRatio = function (ratio, dimensions) {
2011
2011
  if (dimensions.width >= dimensions.height * ratio) {
2012
- return create$5(dimensions.height * ratio, dimensions.height);
2012
+ return create$6(dimensions.height * ratio, dimensions.height);
2013
2013
  }
2014
- return create$5(dimensions.width, dimensions.width / ratio);
2014
+ return create$6(dimensions.width, dimensions.width / ratio);
2015
2015
  };
2016
2016
  /**
2017
2017
  * Converts a dimension to a rectangle, with an optional position.
2018
2018
  */
2019
2019
  function toRectangle(dimensions, position) {
2020
- if (position === void 0) { position = create$c(); }
2020
+ if (position === void 0) { position = create$d(); }
2021
2021
  return fromPointAndDimensions(position, dimensions);
2022
2022
  }
2023
2023
 
2024
2024
  var dimensions = /*#__PURE__*/Object.freeze({
2025
2025
  __proto__: null,
2026
- create: create$5,
2026
+ create: create$6,
2027
2027
  square: square,
2028
2028
  isEqual: isEqual,
2029
2029
  scale: scale,
@@ -2047,7 +2047,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
2047
2047
  *
2048
2048
  * @param values The values to assign to the line.
2049
2049
  */
2050
- function create$4(values) {
2050
+ function create$5(values) {
2051
2051
  var _a, _b;
2052
2052
  if (values === void 0) { values = {}; }
2053
2053
  return {
@@ -2096,7 +2096,7 @@ function direction(line) {
2096
2096
 
2097
2097
  var line3 = /*#__PURE__*/Object.freeze({
2098
2098
  __proto__: null,
2099
- create: create$4,
2099
+ create: create$5,
2100
2100
  center: center,
2101
2101
  transformMatrix: transformMatrix,
2102
2102
  distance: distance,
@@ -2107,7 +2107,7 @@ var line3 = /*#__PURE__*/Object.freeze({
2107
2107
  /**
2108
2108
  * Creates a new matrix. If arguments are undefined, returns an identity matrix.
2109
2109
  */
2110
- var create$3 = function (a, b, c, d, tx, ty) {
2110
+ var create$4 = function (a, b, c, d, tx, ty) {
2111
2111
  if (a === void 0) { a = 1; }
2112
2112
  if (b === void 0) { b = 0; }
2113
2113
  if (c === void 0) { c = 0; }
@@ -2120,7 +2120,7 @@ var create$3 = function (a, b, c, d, tx, ty) {
2120
2120
  * Returns an identity matrix.
2121
2121
  */
2122
2122
  var identity = function () {
2123
- return create$3();
2123
+ return create$4();
2124
2124
  };
2125
2125
  /**
2126
2126
  * Creates a matrix that is translated by the given `tx` and `ty` values.
@@ -2145,7 +2145,7 @@ var rotate = function (degrees, matrix) {
2145
2145
  var b = matrix.b * cos + matrix.d * sin;
2146
2146
  var c = matrix.a * -sin + matrix.c * cos;
2147
2147
  var d = matrix.b * -sin + matrix.d * cos;
2148
- return create$3(a, b, c, d, matrix.tx, matrix.ty);
2148
+ return create$4(a, b, c, d, matrix.tx, matrix.ty);
2149
2149
  };
2150
2150
  /**
2151
2151
  * Translates the given matrix along the horizontal and vertical axis by the
@@ -2154,7 +2154,7 @@ var rotate = function (degrees, matrix) {
2154
2154
  var translate = function (dx, dy, matrix) {
2155
2155
  var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
2156
2156
  var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
2157
- return create$3(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2157
+ return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2158
2158
  };
2159
2159
  /**
2160
2160
  * Returns the result of applying a geometric transformation of a matrix on the
@@ -2163,12 +2163,12 @@ var translate = function (dx, dy, matrix) {
2163
2163
  var transformPoint = function (matrix, pt) {
2164
2164
  var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
2165
2165
  var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
2166
- return create$c(x, y);
2166
+ return create$d(x, y);
2167
2167
  };
2168
2168
 
2169
2169
  var matrix = /*#__PURE__*/Object.freeze({
2170
2170
  __proto__: null,
2171
- create: create$3,
2171
+ create: create$4,
2172
2172
  identity: identity,
2173
2173
  translation: translation,
2174
2174
  rotation: rotation,
@@ -2177,7 +2177,7 @@ var matrix = /*#__PURE__*/Object.freeze({
2177
2177
  transformPoint: transformPoint
2178
2178
  });
2179
2179
 
2180
- function create$2() {
2180
+ function create$3() {
2181
2181
  var args = [];
2182
2182
  for (var _i = 0; _i < arguments.length; _i++) {
2183
2183
  args[_i] = arguments[_i];
@@ -2220,7 +2220,7 @@ function dot(matrix) {
2220
2220
 
2221
2221
  var matrix2 = /*#__PURE__*/Object.freeze({
2222
2222
  __proto__: null,
2223
- create: create$2,
2223
+ create: create$3,
2224
2224
  determinant: determinant,
2225
2225
  dot: dot
2226
2226
  });
@@ -2231,7 +2231,7 @@ var matrix2 = /*#__PURE__*/Object.freeze({
2231
2231
  * @param values Values to assign to the plane.
2232
2232
  * @returns A new plane.
2233
2233
  */
2234
- function create$1(values) {
2234
+ function create$2(values) {
2235
2235
  if (values === void 0) { values = {}; }
2236
2236
  return tslib.__assign({ normal: origin(), constant: 0 }, values);
2237
2237
  }
@@ -2244,7 +2244,7 @@ function create$1(values) {
2244
2244
  */
2245
2245
  function fromNormalAndCoplanarPoint(normal, point) {
2246
2246
  var constant = -dot$1(point, normal);
2247
- return create$1({ normal: normal, constant: constant });
2247
+ return create$2({ normal: normal, constant: constant });
2248
2248
  }
2249
2249
  /**
2250
2250
  * Returns the perpendicular distance from the plane to the given point.
@@ -2298,7 +2298,7 @@ function projectPoint(plane, point) {
2298
2298
 
2299
2299
  var plane = /*#__PURE__*/Object.freeze({
2300
2300
  __proto__: null,
2301
- create: create$1,
2301
+ create: create$2,
2302
2302
  fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
2303
2303
  distanceToPoint: distanceToPoint,
2304
2304
  intersectLine: intersectLine,
@@ -2312,7 +2312,7 @@ var plane = /*#__PURE__*/Object.freeze({
2312
2312
  * @param value The values of the ray.
2313
2313
  * @returns A new ray.
2314
2314
  */
2315
- function create(value) {
2315
+ function create$1(value) {
2316
2316
  var _a, _b;
2317
2317
  if (value === void 0) { value = {}; }
2318
2318
  return {
@@ -2367,12 +2367,43 @@ function intersectPlane(ray, plane) {
2367
2367
 
2368
2368
  var ray = /*#__PURE__*/Object.freeze({
2369
2369
  __proto__: null,
2370
- create: create,
2370
+ create: create$1,
2371
2371
  at: at,
2372
2372
  distanceToPlane: distanceToPlane,
2373
2373
  intersectPlane: intersectPlane
2374
2374
  });
2375
2375
 
2376
+ /**
2377
+ * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,
2378
+ * w: 0}` is returned.
2379
+ */
2380
+ function create(value) {
2381
+ if (value === void 0) { value = {}; }
2382
+ return tslib.__assign({ x: 0, y: 0, z: 0, w: 0 }, value);
2383
+ }
2384
+ /**
2385
+ * Parses a JSON string representation of a `Vector4`.
2386
+ *
2387
+ * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
2388
+ * @returns A parsed `Vector4`.
2389
+ */
2390
+ function fromJson(json) {
2391
+ var obj = JSON.parse(json);
2392
+ if (Array.isArray(obj)) {
2393
+ var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
2394
+ return create({ x: x, y: y, z: z, w: w });
2395
+ }
2396
+ else {
2397
+ return create(obj);
2398
+ }
2399
+ }
2400
+
2401
+ var vector4 = /*#__PURE__*/Object.freeze({
2402
+ __proto__: null,
2403
+ create: create,
2404
+ fromJson: fromJson
2405
+ });
2406
+
2376
2407
  exports.Angle = angle;
2377
2408
  exports.BoundingBox = boundingBox;
2378
2409
  exports.BoundingSphere = boundingSphere;
@@ -2388,6 +2419,7 @@ exports.Quaternion = quaternion;
2388
2419
  exports.Ray = ray;
2389
2420
  exports.Rectangle = rectangle;
2390
2421
  exports.Vector3 = vector3;
2422
+ exports.Vector4 = vector4;
2391
2423
  exports.clamp = clamp;
2392
2424
  exports.lerp = lerp$2;
2393
2425
  //# sourceMappingURL=bundle.cjs.js.map