@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.
@@ -0,0 +1 @@
1
+ export {};
@@ -27,7 +27,7 @@ function lerp$2(a, b, t) {
27
27
  /**
28
28
  * Returns a new `Point` with the given horizontal and vertical position.
29
29
  */
30
- function create$c(x, y) {
30
+ function create$d(x, y) {
31
31
  if (x === void 0) { x = 0; }
32
32
  if (y === void 0) { y = 0; }
33
33
  return { x: x, y: y };
@@ -38,7 +38,7 @@ function create$c(x, y) {
38
38
  function polar(length, radians) {
39
39
  var x = Math.cos(radians) * length;
40
40
  var y = Math.sin(radians) * length;
41
- return create$c(x, y);
41
+ return create$d(x, y);
42
42
  }
43
43
  /**
44
44
  * Returns the distance between two points.
@@ -84,7 +84,7 @@ function lerp$1(a, b, t) {
84
84
  * Returns a new `Point` where `x` and `y` are inverted.
85
85
  */
86
86
  function negate$1(pt) {
87
- return create$c(-pt.x, -pt.y);
87
+ return create$d(-pt.x, -pt.y);
88
88
  }
89
89
  /**
90
90
  * Returns a new `Point` where `x` and `y` are multiplied by the given scale
@@ -118,7 +118,7 @@ function magnitude$2(pt) {
118
118
  function normalizeVector(pt) {
119
119
  var magnitudeOfPoint = magnitude$2(pt);
120
120
  if (magnitudeOfPoint === 0) {
121
- return create$c(0, 0);
121
+ return create$d(0, 0);
122
122
  }
123
123
  else {
124
124
  return scaleProportional(pt, 1 / magnitudeOfPoint);
@@ -137,17 +137,17 @@ function orthogonalVector(ptA, ptB) {
137
137
  var unitVectorBetweenPoints = normalDirectionVector(ptA, ptB);
138
138
  // Handle vectors that are parallel to the x or y axis
139
139
  if (unitVectorBetweenPoints.x === 0 || unitVectorBetweenPoints.y === 0) {
140
- return create$c(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
140
+ return create$d(-1 * unitVectorBetweenPoints.y, unitVectorBetweenPoints.x);
141
141
  }
142
142
  if (Math.abs(unitVectorBetweenPoints.x) > Math.abs(unitVectorBetweenPoints.y)) {
143
143
  var vectorXValue = 1 - Math.pow(unitVectorBetweenPoints.x, 2);
144
144
  var vectorYValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
145
- return normalizeVector(create$c(vectorXValue, vectorYValue));
145
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
146
146
  }
147
147
  else {
148
148
  var vectorXValue = -1 * unitVectorBetweenPoints.x * unitVectorBetweenPoints.y;
149
149
  var vectorYValue = 1 - Math.pow(unitVectorBetweenPoints.y, 2);
150
- return normalizeVector(create$c(vectorXValue, vectorYValue));
150
+ return normalizeVector(create$d(vectorXValue, vectorYValue));
151
151
  }
152
152
  }
153
153
  /**
@@ -156,21 +156,21 @@ function orthogonalVector(ptA, ptB) {
156
156
  * @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
157
157
  * @returns A parsed Point.
158
158
  */
159
- function fromJson$4(json) {
159
+ function fromJson$5(json) {
160
160
  var obj = JSON.parse(json);
161
161
  if (Array.isArray(obj)) {
162
162
  var x = obj[0], y = obj[1];
163
- return create$c(x, y);
163
+ return create$d(x, y);
164
164
  }
165
165
  else {
166
166
  var x = obj.x, y = obj.y;
167
- return create$c(x, y);
167
+ return create$d(x, y);
168
168
  }
169
169
  }
170
170
 
171
171
  var point = /*#__PURE__*/Object.freeze({
172
172
  __proto__: null,
173
- create: create$c,
173
+ create: create$d,
174
174
  polar: polar,
175
175
  distance: distance$2,
176
176
  subtract: subtract$1,
@@ -184,7 +184,7 @@ var point = /*#__PURE__*/Object.freeze({
184
184
  normalizeVector: normalizeVector,
185
185
  normalDirectionVector: normalDirectionVector,
186
186
  orthogonalVector: orthogonalVector,
187
- fromJson: fromJson$4
187
+ fromJson: fromJson$5
188
188
  });
189
189
 
190
190
  /**
@@ -842,7 +842,7 @@ var matrix4 = /*#__PURE__*/Object.freeze({
842
842
  * @param value The values to populate the euler angle with.
843
843
  * @returns A euler angle.
844
844
  */
845
- function create$b(value) {
845
+ function create$c(value) {
846
846
  var _a, _b, _c, _d;
847
847
  if (value === void 0) { value = {}; }
848
848
  return {
@@ -863,7 +863,7 @@ function create$b(value) {
863
863
  function fromDegrees(value) {
864
864
  if (value === void 0) { value = {}; }
865
865
  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;
866
- return create$b({
866
+ return create$c({
867
867
  x: toRadians(x),
868
868
  y: toRadians(y),
869
869
  z: toRadians(z),
@@ -957,7 +957,7 @@ function fromRotationMatrix(matrix, order) {
957
957
  * @param json A JSON object.
958
958
  * @returns A euler angle.
959
959
  */
960
- function fromJson$3(json) {
960
+ function fromJson$4(json) {
961
961
  var obj = JSON.parse(json);
962
962
  if (Array.isArray(obj)) {
963
963
  var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
@@ -983,10 +983,10 @@ function isType$1(obj) {
983
983
 
984
984
  var euler = /*#__PURE__*/Object.freeze({
985
985
  __proto__: null,
986
- create: create$b,
986
+ create: create$c,
987
987
  fromDegrees: fromDegrees,
988
988
  fromRotationMatrix: fromRotationMatrix,
989
- fromJson: fromJson$3,
989
+ fromJson: fromJson$4,
990
990
  isType: isType$1
991
991
  });
992
992
 
@@ -994,7 +994,7 @@ var euler = /*#__PURE__*/Object.freeze({
994
994
  * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
995
995
  * w: 1}` is returned.
996
996
  */
997
- function create$a(value) {
997
+ function create$b(value) {
998
998
  if (value === void 0) { value = {}; }
999
999
  return __assign({ x: 0, y: 0, z: 0, w: 1 }, value);
1000
1000
  }
@@ -1004,14 +1004,14 @@ function create$a(value) {
1004
1004
  * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
1005
1005
  * @returns A parsed `Quaternion`.
1006
1006
  */
1007
- function fromJson$2(json) {
1007
+ function fromJson$3(json) {
1008
1008
  var obj = JSON.parse(json);
1009
1009
  if (Array.isArray(obj)) {
1010
1010
  var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
1011
- return create$a({ x: x, y: y, z: z, w: w });
1011
+ return create$b({ x: x, y: y, z: z, w: w });
1012
1012
  }
1013
1013
  else {
1014
- return create$a(obj);
1014
+ return create$b(obj);
1015
1015
  }
1016
1016
  }
1017
1017
  /**
@@ -1030,7 +1030,7 @@ function magnitude$1(q) {
1030
1030
  * Returns a quaternion where each component is multiplied by the `scalar`.
1031
1031
  */
1032
1032
  function scale$3(scalar, q) {
1033
- return create$a({
1033
+ return create$b({
1034
1034
  w: q.w * scalar,
1035
1035
  x: q.x * scalar,
1036
1036
  y: q.y * scalar,
@@ -1186,8 +1186,8 @@ function isType(obj) {
1186
1186
 
1187
1187
  var quaternion = /*#__PURE__*/Object.freeze({
1188
1188
  __proto__: null,
1189
- create: create$a,
1190
- fromJson: fromJson$2,
1189
+ create: create$b,
1190
+ fromJson: fromJson$3,
1191
1191
  normalize: normalize$1,
1192
1192
  magnitude: magnitude$1,
1193
1193
  scale: scale$3,
@@ -1198,7 +1198,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
1198
1198
  isType: isType
1199
1199
  });
1200
1200
 
1201
- function create$9() {
1201
+ function create$a() {
1202
1202
  var _a, _b, _c, _d, _e, _f;
1203
1203
  var args = [];
1204
1204
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1258,15 +1258,15 @@ function fromMatrixPosition(matrix) {
1258
1258
  * @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
1259
1259
  * @returns A parsed Vector3.
1260
1260
  */
1261
- function fromJson$1(json) {
1261
+ function fromJson$2(json) {
1262
1262
  var obj = JSON.parse(json);
1263
1263
  if (Array.isArray(obj)) {
1264
1264
  var x = obj[0], y = obj[1], z = obj[2];
1265
- return create$9(x, y, z);
1265
+ return create$a(x, y, z);
1266
1266
  }
1267
1267
  else {
1268
1268
  var x = obj.x, y = obj.y, z = obj.z;
1269
- return create$9(x, y, z);
1269
+ return create$a(x, y, z);
1270
1270
  }
1271
1271
  }
1272
1272
  /**
@@ -1281,7 +1281,7 @@ function fromArray(nums, offset) {
1281
1281
  var x = nums[offset];
1282
1282
  var y = nums[offset + 1];
1283
1283
  var z = nums[offset + 2];
1284
- return create$9(x, y, z);
1284
+ return create$a(x, y, z);
1285
1285
  }
1286
1286
  /**
1287
1287
  * Converts a Vector3 to an array where the values of the vector will be
@@ -1298,43 +1298,43 @@ function toArray(_a) {
1298
1298
  * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
1299
1299
  */
1300
1300
  function right() {
1301
- return create$9(1, 0, 0);
1301
+ return create$a(1, 0, 0);
1302
1302
  }
1303
1303
  /**
1304
1304
  * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
1305
1305
  */
1306
1306
  function up() {
1307
- return create$9(0, 1, 0);
1307
+ return create$a(0, 1, 0);
1308
1308
  }
1309
1309
  /**
1310
1310
  * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
1311
1311
  */
1312
1312
  function forward() {
1313
- return create$9(0, 0, -1);
1313
+ return create$a(0, 0, -1);
1314
1314
  }
1315
1315
  /**
1316
1316
  * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
1317
1317
  */
1318
1318
  function left() {
1319
- return create$9(-1, 0, 0);
1319
+ return create$a(-1, 0, 0);
1320
1320
  }
1321
1321
  /**
1322
1322
  * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
1323
1323
  */
1324
1324
  function down() {
1325
- return create$9(0, -1, 0);
1325
+ return create$a(0, -1, 0);
1326
1326
  }
1327
1327
  /**
1328
1328
  * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
1329
1329
  */
1330
1330
  function back() {
1331
- return create$9(0, 0, 1);
1331
+ return create$a(0, 0, 1);
1332
1332
  }
1333
1333
  /**
1334
1334
  * Returns a vector at the origin, Vector3(0, 0, 0).
1335
1335
  */
1336
1336
  function origin() {
1337
- return create$9(0, 0, 0);
1337
+ return create$a(0, 0, 0);
1338
1338
  }
1339
1339
  /**
1340
1340
  * Returns a vector with that will have a magnitude of 1.
@@ -1445,9 +1445,9 @@ function eulerTo(a, b) {
1445
1445
  var dotAB = dot$1(normalizedA, normalizedB);
1446
1446
  var vectorsAreParallel = Math.abs(dotAB) > dotDelta;
1447
1447
  if (vectorsAreParallel) {
1448
- return dotAB > 1 - 1e-6 ? create$b() : create$b({ x: Math.PI });
1448
+ return dotAB > 1 - 1e-6 ? create$c() : create$c({ x: Math.PI });
1449
1449
  }
1450
- var normalizedQ = normalize$1(create$a(__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1450
+ var normalizedQ = normalize$1(create$b(__assign({ w: 1 + dotAB }, cross(normalizedA, normalizedB))));
1451
1451
  return fromRotationMatrix(makeRotation(normalizedQ));
1452
1452
  }
1453
1453
  /**
@@ -1535,13 +1535,13 @@ function isEqual$2(a, b) {
1535
1535
  * Returns a vector that contains the largest components of `a` and `b`.
1536
1536
  */
1537
1537
  function max(a, b) {
1538
- return create$9(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1538
+ return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1539
1539
  }
1540
1540
  /**
1541
1541
  * Returns a vector that contains the smallest components of `a` and `b`.
1542
1542
  */
1543
1543
  function min(a, b) {
1544
- return create$9(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1544
+ return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1545
1545
  }
1546
1546
  /**
1547
1547
  * Returns a vector that each of its component negated.
@@ -1579,11 +1579,11 @@ function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
1579
1579
 
1580
1580
  var vector3 = /*#__PURE__*/Object.freeze({
1581
1581
  __proto__: null,
1582
- create: create$9,
1582
+ create: create$a,
1583
1583
  isValid: isValid,
1584
1584
  fromMatrixScale: fromMatrixScale,
1585
1585
  fromMatrixPosition: fromMatrixPosition,
1586
- fromJson: fromJson$1,
1586
+ fromJson: fromJson$2,
1587
1587
  fromArray: fromArray,
1588
1588
  toArray: toArray,
1589
1589
  right: right,
@@ -1620,7 +1620,7 @@ var vector3 = /*#__PURE__*/Object.freeze({
1620
1620
  /**
1621
1621
  * Returns a `BoundingBox` with the given min and max points.
1622
1622
  */
1623
- var create$8 = function (min, max) {
1623
+ var create$9 = function (min, max) {
1624
1624
  return { min: min, max: max };
1625
1625
  };
1626
1626
  /**
@@ -1628,7 +1628,7 @@ var create$8 = function (min, max) {
1628
1628
  * are contained by the bounding box.
1629
1629
  */
1630
1630
  var fromVectors = function (vectors) {
1631
- return union.apply(void 0, vectors.map(function (v) { return create$8(v, v); }));
1631
+ return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
1632
1632
  };
1633
1633
  /**
1634
1634
  * Returns the center point of the given `BoundingBox`.
@@ -1656,7 +1656,7 @@ function union(box) {
1656
1656
  }
1657
1657
  var boxes = __spreadArray([box], rest, true);
1658
1658
  return boxes.reduce(function (a, b) {
1659
- return create$8(min(a.min, b.min), max(a.max, b.max));
1659
+ return create$9(min(a.min, b.min), max(a.max, b.max));
1660
1660
  });
1661
1661
  }
1662
1662
  /* eslint-enable padding-line-between-statements */
@@ -1665,12 +1665,12 @@ function union(box) {
1665
1665
  * bounding box for each axis.
1666
1666
  */
1667
1667
  var lengths = function (box) {
1668
- return create$9(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1668
+ return create$a(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z);
1669
1669
  };
1670
1670
 
1671
1671
  var boundingBox = /*#__PURE__*/Object.freeze({
1672
1672
  __proto__: null,
1673
- create: create$8,
1673
+ create: create$9,
1674
1674
  fromVectors: fromVectors,
1675
1675
  center: center$3,
1676
1676
  diagonal: diagonal,
@@ -1682,7 +1682,7 @@ var boundingBox = /*#__PURE__*/Object.freeze({
1682
1682
  /**
1683
1683
  * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
1684
1684
  */
1685
- var create$7 = function (boundingBox$1) {
1685
+ var create$8 = function (boundingBox$1) {
1686
1686
  var boundingBoxCenter = center$3(boundingBox$1);
1687
1687
  var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1688
1688
  var radius = magnitude(centerToBoundingPlane);
@@ -1693,26 +1693,26 @@ var create$7 = function (boundingBox$1) {
1693
1693
 
1694
1694
  var boundingSphere = /*#__PURE__*/Object.freeze({
1695
1695
  __proto__: null,
1696
- create: create$7
1696
+ create: create$8
1697
1697
  });
1698
1698
 
1699
1699
  /**
1700
1700
  * Returns a new `Rectangle` with the given position and size.
1701
1701
  */
1702
- function create$6(x, y, width, height) {
1702
+ function create$7(x, y, width, height) {
1703
1703
  return { x: x, y: y, width: width, height: height };
1704
1704
  }
1705
1705
  /**
1706
1706
  * Returns a new `Rectangle` at the origin point and given size.
1707
1707
  */
1708
1708
  function fromDimensions(dimensions) {
1709
- return create$6(0, 0, dimensions.width, dimensions.height);
1709
+ return create$7(0, 0, dimensions.width, dimensions.height);
1710
1710
  }
1711
1711
  /**
1712
1712
  * Returns a new `Rectangle` with the given position and size.
1713
1713
  */
1714
1714
  function fromPointAndDimensions(point, dimensions) {
1715
- return create$6(point.x, point.y, dimensions.width, dimensions.height);
1715
+ return create$7(point.x, point.y, dimensions.width, dimensions.height);
1716
1716
  }
1717
1717
  /**
1718
1718
  * Returns a new `Rectangle` with the given top-left and bottom-right positions.
@@ -1723,7 +1723,7 @@ function fromPoints(topLeftPt, bottomRightPt) {
1723
1723
  var minY = Math.min(topLeftPt.y, bottomRightPt.y);
1724
1724
  var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1725
1725
  var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1726
- return create$6(minX, minY, maxX - minX, maxY - minY);
1726
+ return create$7(minX, minY, maxX - minX, maxY - minY);
1727
1727
  }
1728
1728
  /**
1729
1729
  * Returns a rectangle where the longest length of `rect` will be equal to the
@@ -1785,7 +1785,7 @@ function scale$1(rect, scaleOrScaleX, scaleY) {
1785
1785
  else {
1786
1786
  var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
1787
1787
  var scaleX = scaleOrScaleX;
1788
- return create$6(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1788
+ return create$7(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1789
1789
  }
1790
1790
  }
1791
1791
  /**
@@ -1817,13 +1817,13 @@ function center$2(rect) {
1817
1817
  * Returns the top-left position of the rectangle, as a point.
1818
1818
  */
1819
1819
  function topLeft(rect) {
1820
- return create$c(rect.x, rect.y);
1820
+ return create$d(rect.x, rect.y);
1821
1821
  }
1822
1822
  /**
1823
1823
  * Returns the bottom-right position of the rectangle, as a point.
1824
1824
  */
1825
1825
  function bottomRight(rect) {
1826
- return create$c(rect.x + rect.width, rect.y + rect.height);
1826
+ return create$d(rect.x + rect.width, rect.y + rect.height);
1827
1827
  }
1828
1828
  /**
1829
1829
  * Returns `true` if the given rectangle has a portrait aspect ratio.
@@ -1850,7 +1850,7 @@ function isSquare(rect) {
1850
1850
  * @param padding The padding to add.
1851
1851
  */
1852
1852
  function pad(rect, padding) {
1853
- return create$6(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1853
+ return create$7(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1854
1854
  }
1855
1855
  /**
1856
1856
  * Returns `true` if the given rectangle contains all the given `points`.
@@ -1876,21 +1876,21 @@ function containsPoints(rect) {
1876
1876
  * @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
1877
1877
  * @returns A parsed Point.
1878
1878
  */
1879
- function fromJson(json) {
1879
+ function fromJson$1(json) {
1880
1880
  var obj = JSON.parse(json);
1881
1881
  if (Array.isArray(obj)) {
1882
1882
  var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
1883
- return create$6(x, y, width, height);
1883
+ return create$7(x, y, width, height);
1884
1884
  }
1885
1885
  else {
1886
1886
  var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
1887
- return create$6(x, y, width, height);
1887
+ return create$7(x, y, width, height);
1888
1888
  }
1889
1889
  }
1890
1890
 
1891
1891
  var rectangle = /*#__PURE__*/Object.freeze({
1892
1892
  __proto__: null,
1893
- create: create$6,
1893
+ create: create$7,
1894
1894
  fromDimensions: fromDimensions,
1895
1895
  fromPointAndDimensions: fromPointAndDimensions,
1896
1896
  fromPoints: fromPoints,
@@ -1909,21 +1909,21 @@ var rectangle = /*#__PURE__*/Object.freeze({
1909
1909
  isSquare: isSquare,
1910
1910
  pad: pad,
1911
1911
  containsPoints: containsPoints,
1912
- fromJson: fromJson
1912
+ fromJson: fromJson$1
1913
1913
  });
1914
1914
 
1915
1915
  /**
1916
1916
  * Returns a `Dimensions` with the given width and height.
1917
1917
  *
1918
1918
  */
1919
- var create$5 = function (width, height) {
1919
+ var create$6 = function (width, height) {
1920
1920
  return { width: width, height: height };
1921
1921
  };
1922
1922
  /**
1923
1923
  * Returns a `Dimensions` with the same width and height.
1924
1924
  */
1925
1925
  var square = function (size) {
1926
- return create$5(size, size);
1926
+ return create$6(size, size);
1927
1927
  };
1928
1928
  /**
1929
1929
  * Returns `true` if two dimensions have the same width and height. Otherwise
@@ -2039,21 +2039,21 @@ var area = function (_a) {
2039
2039
  */
2040
2040
  var fitToRatio = function (ratio, dimensions) {
2041
2041
  if (dimensions.width >= dimensions.height * ratio) {
2042
- return create$5(dimensions.height * ratio, dimensions.height);
2042
+ return create$6(dimensions.height * ratio, dimensions.height);
2043
2043
  }
2044
- return create$5(dimensions.width, dimensions.width / ratio);
2044
+ return create$6(dimensions.width, dimensions.width / ratio);
2045
2045
  };
2046
2046
  /**
2047
2047
  * Converts a dimension to a rectangle, with an optional position.
2048
2048
  */
2049
2049
  function toRectangle(dimensions, position) {
2050
- if (position === void 0) { position = create$c(); }
2050
+ if (position === void 0) { position = create$d(); }
2051
2051
  return fromPointAndDimensions(position, dimensions);
2052
2052
  }
2053
2053
 
2054
2054
  var dimensions = /*#__PURE__*/Object.freeze({
2055
2055
  __proto__: null,
2056
- create: create$5,
2056
+ create: create$6,
2057
2057
  square: square,
2058
2058
  isEqual: isEqual,
2059
2059
  scale: scale,
@@ -2077,7 +2077,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
2077
2077
  *
2078
2078
  * @param values The values to assign to the line.
2079
2079
  */
2080
- function create$4(values) {
2080
+ function create$5(values) {
2081
2081
  var _a, _b;
2082
2082
  if (values === void 0) { values = {}; }
2083
2083
  return {
@@ -2126,7 +2126,7 @@ function direction(line) {
2126
2126
 
2127
2127
  var line3 = /*#__PURE__*/Object.freeze({
2128
2128
  __proto__: null,
2129
- create: create$4,
2129
+ create: create$5,
2130
2130
  center: center,
2131
2131
  transformMatrix: transformMatrix,
2132
2132
  distance: distance,
@@ -2137,7 +2137,7 @@ var line3 = /*#__PURE__*/Object.freeze({
2137
2137
  /**
2138
2138
  * Creates a new matrix. If arguments are undefined, returns an identity matrix.
2139
2139
  */
2140
- var create$3 = function (a, b, c, d, tx, ty) {
2140
+ var create$4 = function (a, b, c, d, tx, ty) {
2141
2141
  if (a === void 0) { a = 1; }
2142
2142
  if (b === void 0) { b = 0; }
2143
2143
  if (c === void 0) { c = 0; }
@@ -2150,7 +2150,7 @@ var create$3 = function (a, b, c, d, tx, ty) {
2150
2150
  * Returns an identity matrix.
2151
2151
  */
2152
2152
  var identity = function () {
2153
- return create$3();
2153
+ return create$4();
2154
2154
  };
2155
2155
  /**
2156
2156
  * Creates a matrix that is translated by the given `tx` and `ty` values.
@@ -2175,7 +2175,7 @@ var rotate = function (degrees, matrix) {
2175
2175
  var b = matrix.b * cos + matrix.d * sin;
2176
2176
  var c = matrix.a * -sin + matrix.c * cos;
2177
2177
  var d = matrix.b * -sin + matrix.d * cos;
2178
- return create$3(a, b, c, d, matrix.tx, matrix.ty);
2178
+ return create$4(a, b, c, d, matrix.tx, matrix.ty);
2179
2179
  };
2180
2180
  /**
2181
2181
  * Translates the given matrix along the horizontal and vertical axis by the
@@ -2184,7 +2184,7 @@ var rotate = function (degrees, matrix) {
2184
2184
  var translate = function (dx, dy, matrix) {
2185
2185
  var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
2186
2186
  var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
2187
- return create$3(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2187
+ return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
2188
2188
  };
2189
2189
  /**
2190
2190
  * Returns the result of applying a geometric transformation of a matrix on the
@@ -2193,12 +2193,12 @@ var translate = function (dx, dy, matrix) {
2193
2193
  var transformPoint = function (matrix, pt) {
2194
2194
  var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
2195
2195
  var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
2196
- return create$c(x, y);
2196
+ return create$d(x, y);
2197
2197
  };
2198
2198
 
2199
2199
  var matrix = /*#__PURE__*/Object.freeze({
2200
2200
  __proto__: null,
2201
- create: create$3,
2201
+ create: create$4,
2202
2202
  identity: identity,
2203
2203
  translation: translation,
2204
2204
  rotation: rotation,
@@ -2207,7 +2207,7 @@ var matrix = /*#__PURE__*/Object.freeze({
2207
2207
  transformPoint: transformPoint
2208
2208
  });
2209
2209
 
2210
- function create$2() {
2210
+ function create$3() {
2211
2211
  var args = [];
2212
2212
  for (var _i = 0; _i < arguments.length; _i++) {
2213
2213
  args[_i] = arguments[_i];
@@ -2250,7 +2250,7 @@ function dot(matrix) {
2250
2250
 
2251
2251
  var matrix2 = /*#__PURE__*/Object.freeze({
2252
2252
  __proto__: null,
2253
- create: create$2,
2253
+ create: create$3,
2254
2254
  determinant: determinant,
2255
2255
  dot: dot
2256
2256
  });
@@ -2261,7 +2261,7 @@ var matrix2 = /*#__PURE__*/Object.freeze({
2261
2261
  * @param values Values to assign to the plane.
2262
2262
  * @returns A new plane.
2263
2263
  */
2264
- function create$1(values) {
2264
+ function create$2(values) {
2265
2265
  if (values === void 0) { values = {}; }
2266
2266
  return __assign({ normal: origin(), constant: 0 }, values);
2267
2267
  }
@@ -2274,7 +2274,7 @@ function create$1(values) {
2274
2274
  */
2275
2275
  function fromNormalAndCoplanarPoint(normal, point) {
2276
2276
  var constant = -dot$1(point, normal);
2277
- return create$1({ normal: normal, constant: constant });
2277
+ return create$2({ normal: normal, constant: constant });
2278
2278
  }
2279
2279
  /**
2280
2280
  * Returns the perpendicular distance from the plane to the given point.
@@ -2328,7 +2328,7 @@ function projectPoint(plane, point) {
2328
2328
 
2329
2329
  var plane = /*#__PURE__*/Object.freeze({
2330
2330
  __proto__: null,
2331
- create: create$1,
2331
+ create: create$2,
2332
2332
  fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
2333
2333
  distanceToPoint: distanceToPoint,
2334
2334
  intersectLine: intersectLine,
@@ -2342,7 +2342,7 @@ var plane = /*#__PURE__*/Object.freeze({
2342
2342
  * @param value The values of the ray.
2343
2343
  * @returns A new ray.
2344
2344
  */
2345
- function create(value) {
2345
+ function create$1(value) {
2346
2346
  var _a, _b;
2347
2347
  if (value === void 0) { value = {}; }
2348
2348
  return {
@@ -2397,11 +2397,42 @@ function intersectPlane(ray, plane) {
2397
2397
 
2398
2398
  var ray = /*#__PURE__*/Object.freeze({
2399
2399
  __proto__: null,
2400
- create: create,
2400
+ create: create$1,
2401
2401
  at: at,
2402
2402
  distanceToPlane: distanceToPlane,
2403
2403
  intersectPlane: intersectPlane
2404
2404
  });
2405
2405
 
2406
- 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 };
2406
+ /**
2407
+ * Returns a new Vector4. If `value` is undefined, then `{x: 0, y: 0, z: 0,
2408
+ * w: 0}` is returned.
2409
+ */
2410
+ function create(value) {
2411
+ if (value === void 0) { value = {}; }
2412
+ return __assign({ x: 0, y: 0, z: 0, w: 0 }, value);
2413
+ }
2414
+ /**
2415
+ * Parses a JSON string representation of a `Vector4`.
2416
+ *
2417
+ * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
2418
+ * @returns A parsed `Vector4`.
2419
+ */
2420
+ function fromJson(json) {
2421
+ var obj = JSON.parse(json);
2422
+ if (Array.isArray(obj)) {
2423
+ var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
2424
+ return create({ x: x, y: y, z: z, w: w });
2425
+ }
2426
+ else {
2427
+ return create(obj);
2428
+ }
2429
+ }
2430
+
2431
+ var vector4 = /*#__PURE__*/Object.freeze({
2432
+ __proto__: null,
2433
+ create: create,
2434
+ fromJson: fromJson
2435
+ });
2436
+
2437
+ 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 };
2407
2438
  //# sourceMappingURL=bundle.esm.js.map