@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.
@@ -29,7 +29,7 @@ function lerp$2(a, b, t) {
29
29
  /**
30
30
  * Returns a new `Point` with the given horizontal and vertical position.
31
31
  */
32
- function create$c(x, y) {
32
+ function create$d(x, y) {
33
33
  if (x === void 0) { x = 0; }
34
34
  if (y === void 0) { y = 0; }
35
35
  return { x: x, y: y };
@@ -40,7 +40,7 @@ function create$c(x, y) {
40
40
  function polar(length, radians) {
41
41
  var x = Math.cos(radians) * length;
42
42
  var y = Math.sin(radians) * length;
43
- return create$c(x, y);
43
+ return create$d(x, y);
44
44
  }
45
45
  /**
46
46
  * Returns the distance between two points.
@@ -86,7 +86,7 @@ function lerp$1(a, b, t) {
86
86
  * Returns a new `Point` where `x` and `y` are inverted.
87
87
  */
88
88
  function negate$1(pt) {
89
- return create$c(-pt.x, -pt.y);
89
+ return create$d(-pt.x, -pt.y);
90
90
  }
91
91
  /**
92
92
  * Returns a new `Point` where `x` and `y` are multiplied by the given scale
@@ -120,7 +120,7 @@ function magnitude$2(pt) {
120
120
  function normalizeVector(pt) {
121
121
  var magnitudeOfPoint = magnitude$2(pt);
122
122
  if (magnitudeOfPoint === 0) {
123
- return create$c(0, 0);
123
+ return create$d(0, 0);
124
124
  }
125
125
  else {
126
126
  return scaleProportional(pt, 1 / magnitudeOfPoint);
@@ -139,17 +139,17 @@ function orthogonalVector(ptA, ptB) {
139
139
  var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
140
140
  // Handle vectors that are parallel to the x or y axis
141
141
  if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
142
- return create$c(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
142
+ return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
143
143
  }
144
144
  if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
145
145
  var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
146
146
  var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
147
- return normalizeVector(create$c(vectorXValue, vectorYValue));
147
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
148
148
  }
149
149
  else {
150
150
  var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
151
151
  var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
152
- return normalizeVector(create$c(vectorXValue, vectorYValue));
152
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
153
153
  }
154
154
  }
155
155
  /**
@@ -158,21 +158,21 @@ function orthogonalVector(ptA, ptB) {
158
158
  * @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
159
159
  * @returns A parsed Point.
160
160
  */
161
- function fromJson$4(json) {
161
+ function fromJson$5(json) {
162
162
  var obj = JSON.parse(json);
163
163
  if (Array.isArray(obj)) {
164
164
  var x = obj[0], y = obj[1];
165
- return create$c(x, y);
165
+ return create$d(x, y);
166
166
  }
167
167
  else {
168
168
  var x = obj.x, y = obj.y;
169
- return create$c(x, y);
169
+ return create$d(x, y);
170
170
  }
171
171
  }
172
172
 
173
173
  var point = /*#__PURE__*/Object.freeze({
174
174
  __proto__: null,
175
- create: create$c,
175
+ create: create$d,
176
176
  polar: polar,
177
177
  distance: distance$2,
178
178
  subtract: subtract$1,
@@ -186,7 +186,7 @@ var point = /*#__PURE__*/Object.freeze({
186
186
  normalizeVector: normalizeVector,
187
187
  normalDirectionVector: normalDirectionVector,
188
188
  orthogonalVector: orthogonalVector,
189
- fromJson: fromJson$4
189
+ fromJson: fromJson$5
190
190
  });
191
191
 
192
192
  /**
@@ -808,7 +808,7 @@ var matrix4 = /*#__PURE__*/Object.freeze({
808
808
  * @param value The values to populate the euler angle with.
809
809
  * @returns A euler angle.
810
810
  */
811
- function create$b(value) {
811
+ function create$c(value) {
812
812
  var _a, _b, _c, _d;
813
813
  if (value === void 0) { value = {}; }
814
814
  return {
@@ -829,7 +829,7 @@ function create$b(value) {
829
829
  function fromDegrees(value) {
830
830
  if (value === void 0) { value = {}; }
831
831
  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;
832
- return create$b({
832
+ return create$c({
833
833
  x: toRadians(x),
834
834
  y: toRadians(y),
835
835
  z: toRadians(z),
@@ -923,7 +923,7 @@ function fromRotationMatrix(matrix, order) {
923
923
  * @param json A JSON object.
924
924
  * @returns A euler angle.
925
925
  */
926
- function fromJson$3(json) {
926
+ function fromJson$4(json) {
927
927
  var obj = JSON.parse(json);
928
928
  if (Array.isArray(obj)) {
929
929
  var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
@@ -949,10 +949,10 @@ function isType$1(obj) {
949
949
 
950
950
  var euler = /*#__PURE__*/Object.freeze({
951
951
  __proto__: null,
952
- create: create$b,
952
+ create: create$c,
953
953
  fromDegrees: fromDegrees,
954
954
  fromRotationMatrix: fromRotationMatrix,
955
- fromJson: fromJson$3,
955
+ fromJson: fromJson$4,
956
956
  isType: isType$1
957
957
  });
958
958
 
@@ -960,7 +960,7 @@ var euler = /*#__PURE__*/Object.freeze({
960
960
  * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
961
961
  * w: 1}` is returned.
962
962
  */
963
- function create$a(value) {
963
+ function create$b(value) {
964
964
  if (value === void 0) { value = {}; }
965
965
  return __assign({ x: 0, y: 0, z: 0, w: 1 }, value);
966
966
  }
@@ -970,14 +970,14 @@ function create$a(value) {
970
970
  * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
971
971
  * @returns A parsed `Quaternion`.
972
972
  */
973
- function fromJson$2(json) {
973
+ function fromJson$3(json) {
974
974
  var obj = JSON.parse(json);
975
975
  if (Array.isArray(obj)) {
976
976
  var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
977
- return create$a({ x: x, y: y, z: z, w: w });
977
+ return create$b({ x: x, y: y, z: z, w: w });
978
978
  }
979
979
  else {
980
- return create$a(obj);
980
+ return create$b(obj);
981
981
  }
982
982
  }
983
983
  /**
@@ -996,7 +996,7 @@ function magnitude$1(q) {
996
996
  * Returns a quaternion where each component is multiplied by the `scalar`.
997
997
  */
998
998
  function scale$3(scalar, q) {
999
- return create$a({
999
+ return create$b({
1000
1000
  w: q.w * scalar,
1001
1001
  x: q.x * scalar,
1002
1002
  y: q.y * scalar,
@@ -1152,8 +1152,8 @@ function isType(obj) {
1152
1152
 
1153
1153
  var quaternion = /*#__PURE__*/Object.freeze({
1154
1154
  __proto__: null,
1155
- create: create$a,
1156
- fromJson: fromJson$2,
1155
+ create: create$b,
1156
+ fromJson: fromJson$3,
1157
1157
  normalize: normalize$1,
1158
1158
  magnitude: magnitude$1,
1159
1159
  scale: scale$3,
@@ -1164,7 +1164,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
1164
1164
  isType: isType
1165
1165
  });
1166
1166
 
1167
- function create$9() {
1167
+ function create$a() {
1168
1168
  var _a, _b, _c, _d, _e, _f;
1169
1169
  var args = [];
1170
1170
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1224,15 +1224,15 @@ function fromMatrixPosition(matrix) {
1224
1224
  * @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
1225
1225
  * @returns A parsed Vector3.
1226
1226
  */
1227
- function fromJson$1(json) {
1227
+ function fromJson$2(json) {
1228
1228
  var obj = JSON.parse(json);
1229
1229
  if (Array.isArray(obj)) {
1230
1230
  var x = obj[0], y = obj[1], z = obj[2];
1231
- return create$9(x, y, z);
1231
+ return create$a(x, y, z);
1232
1232
  }
1233
1233
  else {
1234
1234
  var x = obj.x, y = obj.y, z = obj.z;
1235
- return create$9(x, y, z);
1235
+ return create$a(x, y, z);
1236
1236
  }
1237
1237
  }
1238
1238
  /**
@@ -1247,7 +1247,7 @@ function fromArray(nums, offset) {
1247
1247
  var x = nums[offset];
1248
1248
  var y = nums[offset + 1];
1249
1249
  var z = nums[offset + 2];
1250
- return create$9(x, y, z);
1250
+ return create$a(x, y, z);
1251
1251
  }
1252
1252
  /**
1253
1253
  * Converts a Vector3 to an array where the values of the vector will be
@@ -1264,43 +1264,43 @@ function toArray(_a) {
1264
1264
  * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
1265
1265
  */
1266
1266
  function right() {
1267
- return create$9(1, 0, 0);
1267
+ return create$a(1, 0, 0);
1268
1268
  }
1269
1269
  /**
1270
1270
  * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
1271
1271
  */
1272
1272
  function up() {
1273
- return create$9(0, 1, 0);
1273
+ return create$a(0, 1, 0);
1274
1274
  }
1275
1275
  /**
1276
1276
  * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
1277
1277
  */
1278
1278
  function forward() {
1279
- return create$9(0, 0, -1);
1279
+ return create$a(0, 0, -1);
1280
1280
  }
1281
1281
  /**
1282
1282
  * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
1283
1283
  */
1284
1284
  function left() {
1285
- return create$9(-1, 0, 0);
1285
+ return create$a(-1, 0, 0);
1286
1286
  }
1287
1287
  /**
1288
1288
  * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
1289
1289
  */
1290
1290
  function down() {
1291
- return create$9(0, -1, 0);
1291
+ return create$a(0, -1, 0);
1292
1292
  }
1293
1293
  /**
1294
1294
  * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
1295
1295
  */
1296
1296
  function back() {
1297
- return create$9(0, 0, 1);
1297
+ return create$a(0, 0, 1);
1298
1298
  }
1299
1299
  /**
1300
1300
  * Returns a vector at the origin, Vector3(0, 0, 0).
1301
1301
  */
1302
1302
  function origin() {
1303
- return create$9(0, 0, 0);
1303
+ return create$a(0, 0, 0);
1304
1304
  }
1305
1305
  /**
1306
1306
  * Returns a vector with that will have a magnitude of 1.
@@ -1411,9 +1411,9 @@ function eulerTo(a, b) {
1411
1411
  var dotAB = dot$1(normalizedA, normalizedB);
1412
1412
  var vectorsAreParallel = Math.abs(dotAB) > dotDelta;
1413
1413
  if (vectorsAreParallel) {
1414
- return dotAB > 1 - 1e-6 ? create$b() : create$b({ x: Math.PI });
1414
+ return dotAB > 1 - 1e-6 ? create$c() : create$c({ x: Math.PI });
1415
1415
  }
1416
- var normalizedQ = normalize$1(create$a(__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1416
+ var normalizedQ = normalize$1(create$b(__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1417
1417
  return fromRotationMatrix(makeRotation(normalizedQ));
1418
1418
  }
1419
1419
  /**
@@ -1501,13 +1501,13 @@ function isEqual$2(a, b) {
1501
1501
  * Returns a vector that contains the largest components of `a` and `b`.
1502
1502
  */
1503
1503
  function max(a, b) {
1504
- return create$9(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1504
+ return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1505
1505
  }
1506
1506
  /**
1507
1507
  * Returns a vector that contains the smallest components of `a` and `b`.
1508
1508
  */
1509
1509
  function min(a, b) {
1510
- return create$9(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1510
+ return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1511
1511
  }
1512
1512
  /**
1513
1513
  * Returns a vector that each of its component negated.
@@ -1545,11 +1545,11 @@ function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
1545
1545
 
1546
1546
  var vector3 = /*#__PURE__*/Object.freeze({
1547
1547
  __proto__: null,
1548
- create: create$9,
1548
+ create: create$a,
1549
1549
  isValid: isValid,
1550
1550
  fromMatrixScale: fromMatrixScale,
1551
1551
  fromMatrixPosition: fromMatrixPosition,
1552
- fromJson: fromJson$1,
1552
+ fromJson: fromJson$2,
1553
1553
  fromArray: fromArray,
1554
1554
  toArray: toArray,
1555
1555
  right: right,
@@ -1586,7 +1586,7 @@ var vector3 = /*#__PURE__*/Object.freeze({
1586
1586
  /**
1587
1587
  * Returns a `BoundingBox` with the given min and max points.
1588
1588
  */
1589
- var create$8 = function (min, max) {
1589
+ var create$9 = function (min, max) {
1590
1590
  return { min: min, max: max };
1591
1591
  };
1592
1592
  /**
@@ -1594,7 +1594,7 @@ var create$8 = function (min, max) {
1594
1594
  * are contained by the bounding box.
1595
1595
  */
1596
1596
  var fromVectors = function (vectors) {
1597
- return union.apply(void 0, vectors.map(function (v) { return create$8(v, v); }));
1597
+ return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
1598
1598
  };
1599
1599
  /**
1600
1600
  * Returns the center point of the given `BoundingBox`.
@@ -1622,7 +1622,7 @@ function union(box) {
1622
1622
  }
1623
1623
  var boxes = __spreadArray([box], rest, true);
1624
1624
  return boxes.reduce(function (a, b) {
1625
- return create$8(min(a.min, b.min), max(a.max, b.max));
1625
+ return create$9(min(a.min, b.min), max(a.max, b.max));
1626
1626
  });
1627
1627
  }
1628
1628
  /* eslint-enable padding-line-between-statements */
@@ -1631,12 +1631,12 @@ function union(box) {
1631
1631
  * bounding box for each axis.
1632
1632
  */
1633
1633
  var lengths = function (box) {
1634
- return create$9(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1634
+ return create$a(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1635
1635
  };
1636
1636
 
1637
1637
  var boundingBox = /*#__PURE__*/Object.freeze({
1638
1638
  __proto__: null,
1639
- create: create$8,
1639
+ create: create$9,
1640
1640
  fromVectors: fromVectors,
1641
1641
  center: center$3,
1642
1642
  diagonal: diagonal,
@@ -1648,7 +1648,7 @@ var boundingBox = /*#__PURE__*/Object.freeze({
1648
1648
  /**
1649
1649
  * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
1650
1650
  */
1651
- var create$7 = function (boundingBox$1) {
1651
+ var create$8 = function (boundingBox$1) {
1652
1652
  var boundingBoxCenter = center$3(boundingBox$1);
1653
1653
  var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1654
1654
  var radius = magnitude(centerToBoundingPlane);
@@ -1659,26 +1659,26 @@ var create$7 = function (boundingBox$1) {
1659
1659
 
1660
1660
  var boundingSphere = /*#__PURE__*/Object.freeze({
1661
1661
  __proto__: null,
1662
- create: create$7
1662
+ create: create$8
1663
1663
  });
1664
1664
 
1665
1665
  /**
1666
1666
  * Returns a new `Rectangle` with the given position and size.
1667
1667
  */
1668
- function create$6(x, y, width, height) {
1668
+ function create$7(x, y, width, height) {
1669
1669
  return { x: x, y: y, width: width, height: height };
1670
1670
  }
1671
1671
  /**
1672
1672
  * Returns a new `Rectangle` at the origin point and given size.
1673
1673
  */
1674
1674
  function fromDimensions(dimensions) {
1675
- return create$6(0, 0, dimensions.width, dimensions.height);
1675
+ return create$7(0, 0, dimensions.width, dimensions.height);
1676
1676
  }
1677
1677
  /**
1678
1678
  * Returns a new `Rectangle` with the given position and size.
1679
1679
  */
1680
1680
  function fromPointAndDimensions(point, dimensions) {
1681
- return create$6(point.x, point.y, dimensions.width, dimensions.height);
1681
+ return create$7(point.x, point.y, dimensions.width, dimensions.height);
1682
1682
  }
1683
1683
  /**
1684
1684
  * Returns a new `Rectangle` with the given top-left and bottom-right positions.
@@ -1689,7 +1689,7 @@ function fromPoints(topLeftPt, bottomRightPt) {
1689
1689
  var minY = Math.min(topLeftPt.y, bottomRightPt.y);
1690
1690
  var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1691
1691
  var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1692
- return create$6(minX, minY, maxX - minX, maxY - minY);
1692
+ return create$7(minX, minY, maxX - minX, maxY - minY);
1693
1693
  }
1694
1694
  /**
1695
1695
  * Returns a rectangle where the longest length of `rect` will be equal to the
@@ -1751,7 +1751,7 @@ function scale$1(rect, scaleOrScaleX, scaleY) {
1751
1751
  else {
1752
1752
  var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
1753
1753
  var scaleX = scaleOrScaleX;
1754
- return create$6(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1754
+ return create$7(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1755
1755
  }
1756
1756
  }
1757
1757
  /**
@@ -1783,13 +1783,13 @@ function center$2(rect) {
1783
1783
  * Returns the top-left position of the rectangle, as a point.
1784
1784
  */
1785
1785
  function topLeft(rect) {
1786
- return create$c(rect.x, rect.y);
1786
+ return create$d(rect.x, rect.y);
1787
1787
  }
1788
1788
  /**
1789
1789
  * Returns the bottom-right position of the rectangle, as a point.
1790
1790
  */
1791
1791
  function bottomRight(rect) {
1792
- return create$c(rect.x + rect.width, rect.y + rect.height);
1792
+ return create$d(rect.x + rect.width, rect.y + rect.height);
1793
1793
  }
1794
1794
  /**
1795
1795
  * Returns `true` if the given rectangle has a portrait aspect ratio.
@@ -1816,7 +1816,7 @@ function isSquare(rect) {
1816
1816
  * @param padding The padding to add.
1817
1817
  */
1818
1818
  function pad(rect, padding) {
1819
- return create$6(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1819
+ return create$7(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1820
1820
  }
1821
1821
  /**
1822
1822
  * Returns `true` if the given rectangle contains all the given `points`.
@@ -1842,21 +1842,21 @@ function containsPoints(rect) {
1842
1842
  * @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
1843
1843
  * @returns A parsed Point.
1844
1844
  */
1845
- function fromJson(json) {
1845
+ function fromJson$1(json) {
1846
1846
  var obj = JSON.parse(json);
1847
1847
  if (Array.isArray(obj)) {
1848
1848
  var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
1849
- return create$6(x, y, width, height);
1849
+ return create$7(x, y, width, height);
1850
1850
  }
1851
1851
  else {
1852
1852
  var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
1853
- return create$6(x, y, width, height);
1853
+ return create$7(x, y, width, height);
1854
1854
  }
1855
1855
  }
1856
1856
 
1857
1857
  var rectangle = /*#__PURE__*/Object.freeze({
1858
1858
  __proto__: null,
1859
- create: create$6,
1859
+ create: create$7,
1860
1860
  fromDimensions: fromDimensions,
1861
1861
  fromPointAndDimensions: fromPointAndDimensions,
1862
1862
  fromPoints: fromPoints,
@@ -1875,21 +1875,21 @@ var rectangle = /*#__PURE__*/Object.freeze({
1875
1875
  isSquare: isSquare,
1876
1876
  pad: pad,
1877
1877
  containsPoints: containsPoints,
1878
- fromJson: fromJson
1878
+ fromJson: fromJson$1
1879
1879
  });
1880
1880
 
1881
1881
  /**
1882
1882
  * Returns a `Dimensions` with the given width and height.
1883
1883
  *
1884
1884
  */
1885
- var create$5 = function (width, height) {
1885
+ var create$6 = function (width, height) {
1886
1886
  return { width: width, height: height };
1887
1887
  };
1888
1888
  /**
1889
1889
  * Returns a `Dimensions` with the same width and height.
1890
1890
  */
1891
1891
  var square = function (size) {
1892
- return create$5(size, size);
1892
+ return create$6(size, size);
1893
1893
  };
1894
1894
  /**
1895
1895
  * Returns `true` if two dimensions have the same width and height. Otherwise
@@ -2005,21 +2005,21 @@ var area = function (_a) {
2005
2005
  */
2006
2006
  var fitToRatio = function (ratio, dimensions) {
2007
2007
  if (dimensions.width >= dimensions.height * ratio) {
2008
- return create$5(dimensions.height * ratio, dimensions.height);
2008
+ return create$6(dimensions.height * ratio, dimensions.height);
2009
2009
  }
2010
- return create$5(dimensions.width, dimensions.width / ratio);
2010
+ return create$6(dimensions.width, dimensions.width / ratio);
2011
2011
  };
2012
2012
  /**
2013
2013
  * Converts a dimension to a rectangle, with an optional position.
2014
2014
  */
2015
2015
  function toRectangle(dimensions, position) {
2016
- if (position === void 0) { position = create$c(); }
2016
+ if (position === void 0) { position = create$d(); }
2017
2017
  return fromPointAndDimensions(position, dimensions);
2018
2018
  }
2019
2019
 
2020
2020
  var dimensions = /*#__PURE__*/Object.freeze({
2021
2021
  __proto__: null,
2022
- create: create$5,
2022
+ create: create$6,
2023
2023
  square: square,
2024
2024
  isEqual: isEqual,
2025
2025
  scale: scale,
@@ -2043,7 +2043,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
2043
2043
  *
2044
2044
  * @param values The values to assign to the line.
2045
2045
  */
2046
- function create$4(values) {
2046
+ function create$5(values) {
2047
2047
  var _a, _b;
2048
2048
  if (values === void 0) { values = {}; }
2049
2049
  return {
@@ -2092,7 +2092,7 @@ function direction(line) {
2092
2092
 
2093
2093
  var line3 = /*#__PURE__*/Object.freeze({
2094
2094
  __proto__: null,
2095
- create: create$4,
2095
+ create: create$5,
2096
2096
  center: center,
2097
2097
  transformMatrix: transformMatrix,
2098
2098
  distance: distance,
@@ -2103,7 +2103,7 @@ var line3 = /*#__PURE__*/Object.freeze({
2103
2103
  /**
2104
2104
  * Creates a new matrix. If arguments are undefined, returns an identity matrix.
2105
2105
  */
2106
- var create$3 = function (a, b, c, d, tx, ty) {
2106
+ var create$4 = function (a, b, c, d, tx, ty) {
2107
2107
  if (a === void 0) { a = 1; }
2108
2108
  if (b === void 0) { b = 0; }
2109
2109
  if (c === void 0) { c = 0; }
@@ -2116,7 +2116,7 @@ var create$3 = function (a, b, c, d, tx, ty) {
2116
2116
  * Returns an identity matrix.
2117
2117
  */
2118
2118
  var identity = function () {
2119
- return create$3();
2119
+ return create$4();
2120
2120
  };
2121
2121
  /**
2122
2122
  * Creates a matrix that is translated by the given `tx` and `ty` values.
@@ -2141,7 +2141,7 @@ var rotate = function (degrees, matrix) {
2141
2141
  var b = matrix.b * cos + matrix.d * sin;
2142
2142
  var c = matrix.a * -sin + matrix.c * cos;
2143
2143
  var d = matrix.b * -sin + matrix.d * cos;
2144
- return create$3(a, b, c, d, matrix.tx, matrix.ty);
2144
+ return create$4(a, b, c, d, matrix.tx, matrix.ty);
2145
2145
  };
2146
2146
  /**
2147
2147
  * Translates the given matrix along the horizontal and vertical axis by the
@@ -2150,7 +2150,7 @@ var rotate = function (degrees, matrix) {
2150
2150
  var translate = function (dx, dy, matrix) {
2151
2151
  var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
2152
2152
  var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
2153
- return create$3(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2153
+ return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2154
2154
  };
2155
2155
  /**
2156
2156
  * Returns the result of applying a geometric transformation of a matrix on the
@@ -2159,12 +2159,12 @@ var translate = function (dx, dy, matrix) {
2159
2159
  var transformPoint = function (matrix, pt) {
2160
2160
  var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
2161
2161
  var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
2162
- return create$c(x, y);
2162
+ return create$d(x, y);
2163
2163
  };
2164
2164
 
2165
2165
  var matrix = /*#__PURE__*/Object.freeze({
2166
2166
  __proto__: null,
2167
- create: create$3,
2167
+ create: create$4,
2168
2168
  identity: identity,
2169
2169
  translation: translation,
2170
2170
  rotation: rotation,
@@ -2173,7 +2173,7 @@ var matrix = /*#__PURE__*/Object.freeze({
2173
2173
  transformPoint: transformPoint
2174
2174
  });
2175
2175
 
2176
- function create$2() {
2176
+ function create$3() {
2177
2177
  var args = [];
2178
2178
  for (var _i = 0; _i < arguments.length; _i++) {
2179
2179
  args[_i] = arguments[_i];
@@ -2216,7 +2216,7 @@ function dot(matrix) {
2216
2216
 
2217
2217
  var matrix2 = /*#__PURE__*/Object.freeze({
2218
2218
  __proto__: null,
2219
- create: create$2,
2219
+ create: create$3,
2220
2220
  determinant: determinant,
2221
2221
  dot: dot
2222
2222
  });
@@ -2227,7 +2227,7 @@ var matrix2 = /*#__PURE__*/Object.freeze({
2227
2227
  * @param values Values to assign to the plane.
2228
2228
  * @returns A new plane.
2229
2229
  */
2230
- function create$1(values) {
2230
+ function create$2(values) {
2231
2231
  if (values === void 0) { values = {}; }
2232
2232
  return __assign({ normal: origin(), constant: 0 }, values);
2233
2233
  }
@@ -2240,7 +2240,7 @@ function create$1(values) {
2240
2240
  */
2241
2241
  function fromNormalAndCoplanarPoint(normal, point) {
2242
2242
  var constant = -dot$1(point, normal);
2243
- return create$1({ normal: normal, constant: constant });
2243
+ return create$2({ normal: normal, constant: constant });
2244
2244
  }
2245
2245
  /**
2246
2246
  * Returns the perpendicular distance from the plane to the given point.
@@ -2294,7 +2294,7 @@ function projectPoint(plane, point) {
2294
2294
 
2295
2295
  var plane = /*#__PURE__*/Object.freeze({
2296
2296
  __proto__: null,
2297
- create: create$1,
2297
+ create: create$2,
2298
2298
  fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
2299
2299
  distanceToPoint: distanceToPoint,
2300
2300
  intersectLine: intersectLine,
@@ -2308,7 +2308,7 @@ var plane = /*#__PURE__*/Object.freeze({
2308
2308
  * @param value The values of the ray.
2309
2309
  * @returns A new ray.
2310
2310
  */
2311
- function create(value) {
2311
+ function create$1(value) {
2312
2312
  var _a, _b;
2313
2313
  if (value === void 0) { value = {}; }
2314
2314
  return {
@@ -2363,11 +2363,42 @@ function intersectPlane(ray, plane) {
2363
2363
 
2364
2364
  var ray = /*#__PURE__*/Object.freeze({
2365
2365
  __proto__: null,
2366
- create: create,
2366
+ create: create$1,
2367
2367
  at: at,
2368
2368
  distanceToPlane: distanceToPlane,
2369
2369
  intersectPlane: intersectPlane
2370
2370
  });
2371
2371
 
2372
- export { angle as Angle, boundingBox as BoundingBox, boundingSphere as BoundingSphere, dimensions as Dimensions, euler as Euler, line3 as Line3, matrix as Matrix, matrix2 as Matrix2, matrix4 as Matrix4, plane as Plane, point as Point, quaternion as Quaternion, ray as Ray, rectangle as Rectangle, vector3 as Vector3, clamp, lerp$2 as lerp };
2372
+ /**
2373
+ * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,
2374
+ * w: 0}` is returned.
2375
+ */
2376
+ function create(value) {
2377
+ if (value === void 0) { value = {}; }
2378
+ return __assign({ x: 0, y: 0, z: 0, w: 0 }, value);
2379
+ }
2380
+ /**
2381
+ * Parses a JSON string representation of a `Vector4`.
2382
+ *
2383
+ * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
2384
+ * @returns A parsed `Vector4`.
2385
+ */
2386
+ function fromJson(json) {
2387
+ var obj = JSON.parse(json);
2388
+ if (Array.isArray(obj)) {
2389
+ var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
2390
+ return create({ x: x, y: y, z: z, w: w });
2391
+ }
2392
+ else {
2393
+ return create(obj);
2394
+ }
2395
+ }
2396
+
2397
+ var vector4 = /*#__PURE__*/Object.freeze({
2398
+ __proto__: null,
2399
+ create: create,
2400
+ fromJson: fromJson
2401
+ });
2402
+
2403
+ export { angle as Angle, boundingBox as BoundingBox, boundingSphere as BoundingSphere, dimensions as Dimensions, euler as Euler, line3 as Line3, matrix as Matrix, matrix2 as Matrix2, matrix4 as Matrix4, plane as Plane, point as Point, quaternion as Quaternion, ray as Ray, rectangle as Rectangle, vector3 as Vector3, vector4 as Vector4, clamp, lerp$2 as lerp };
2373
2404
  //# sourceMappingURL=bundle.esm.js.map