@vertexvis/geometry 0.13.1 → 0.13.2-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boundingSphere.d.ts +14 -0
- package/dist/bundle.cjs.js +80 -28
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +80 -29
- package/dist/bundle.esm.js.map +1 -1
- package/dist/cdn/__tests__/boundingSphere.test.d.ts +1 -0
- package/dist/cdn/boundingSphere.d.ts +14 -0
- package/dist/cdn/bundle.esm.js +80 -29
- package/dist/cdn/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.min.js +1 -1
- package/dist/cdn/bundle.esm.min.js.map +1 -1
- package/dist/cdn/index.d.ts +2 -1
- package/dist/cdn/matrix4.d.ts +18 -0
- package/dist/index.d.ts +2 -1
- package/dist/matrix4.d.ts +18 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as BoundingBox from './boundingBox';
|
|
2
|
+
import * as Vector3 from './vector3';
|
|
3
|
+
/**
|
|
4
|
+
* A `BoundingSphere` describes a bounding volume as a sphere.
|
|
5
|
+
*/
|
|
6
|
+
export interface BoundingSphere {
|
|
7
|
+
center: Vector3.Vector3;
|
|
8
|
+
radius: number;
|
|
9
|
+
epsilon: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const create: (boundingBox: BoundingBox.BoundingBox) => BoundingSphere;
|
package/dist/cdn/bundle.esm.js
CHANGED
|
@@ -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$
|
|
30
|
+
function create$c(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$b(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$
|
|
41
|
+
return create$c(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$
|
|
87
|
+
return create$c(-pt.x, -pt.y);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
@@ -106,17 +106,17 @@ function fromJson$4(json) {
|
|
|
106
106
|
var obj = JSON.parse(json);
|
|
107
107
|
if (Array.isArray(obj)) {
|
|
108
108
|
var x = obj[0], y = obj[1];
|
|
109
|
-
return create$
|
|
109
|
+
return create$c(x, y);
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
var x = obj.x, y = obj.y;
|
|
113
|
-
return create$
|
|
113
|
+
return create$c(x, y);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
var point = /*#__PURE__*/Object.freeze({
|
|
118
118
|
__proto__: null,
|
|
119
|
-
create: create$
|
|
119
|
+
create: create$c,
|
|
120
120
|
polar: polar,
|
|
121
121
|
distance: distance$2,
|
|
122
122
|
subtract: subtract$1,
|
|
@@ -454,6 +454,39 @@ function makePerspective(near, far, fovY, aspect) {
|
|
|
454
454
|
var bottom = -ymax;
|
|
455
455
|
return makeFrustum(left, right, top, bottom, near, far);
|
|
456
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Creates an orthographic projection matrix.
|
|
459
|
+
*
|
|
460
|
+
* Related to: gluOrtho. The viewing volume is cube-shaped and defined by
|
|
461
|
+
* the six parameters. The left and right values represent the coordinates of
|
|
462
|
+
* the vertical clipping planes, top and bottom values represent the coordinates
|
|
463
|
+
* of the horizontal clipping planes, and near and far values represent the
|
|
464
|
+
* coordinates of the depth clipping planes.
|
|
465
|
+
*
|
|
466
|
+
* @param left The coordinate of the left horizontal clipping plane.
|
|
467
|
+
* @param right The coordinate of the right horizontal clipping plane.
|
|
468
|
+
* @param bottom The coordinate of the bottom vertical clipping plane.
|
|
469
|
+
* @param top The coordinate of the top vertical clipping plane.
|
|
470
|
+
* @param near The coordinate of the near depth clipping plane.
|
|
471
|
+
* @param far The coordinate of the far depth clipping plane.
|
|
472
|
+
* @returns A matrix.
|
|
473
|
+
*/
|
|
474
|
+
function makeOrthographic(left, right, bottom, top, near, far) {
|
|
475
|
+
var w = 1.0 / (right - left);
|
|
476
|
+
var h = 1.0 / (top - bottom);
|
|
477
|
+
var d = 1.0 / (far - near);
|
|
478
|
+
var x = (right + left) * w;
|
|
479
|
+
var y = (top + bottom) * h;
|
|
480
|
+
var z = (far + near) * d;
|
|
481
|
+
/* eslint-disable prettier/prettier */
|
|
482
|
+
return [
|
|
483
|
+
2 * w, 0, 0, -x,
|
|
484
|
+
0, 2 * h, 0, -y,
|
|
485
|
+
0, 0, -2 * d, -z,
|
|
486
|
+
0, 0, 0, 1
|
|
487
|
+
];
|
|
488
|
+
/* eslint-enable prettier/prettier */
|
|
489
|
+
}
|
|
457
490
|
/**
|
|
458
491
|
* Matrix becomes a combination of an inverse translation and rotation.
|
|
459
492
|
*
|
|
@@ -714,6 +747,7 @@ var matrix4 = /*#__PURE__*/Object.freeze({
|
|
|
714
747
|
makeRotationAxis: makeRotationAxis,
|
|
715
748
|
makeFrustum: makeFrustum,
|
|
716
749
|
makePerspective: makePerspective,
|
|
750
|
+
makeOrthographic: makeOrthographic,
|
|
717
751
|
makeLookAtView: makeLookAtView,
|
|
718
752
|
makeLookAt: makeLookAt,
|
|
719
753
|
invert: invert,
|
|
@@ -726,7 +760,7 @@ var matrix4 = /*#__PURE__*/Object.freeze({
|
|
|
726
760
|
isType: isType$2
|
|
727
761
|
});
|
|
728
762
|
|
|
729
|
-
function create$
|
|
763
|
+
function create$b() {
|
|
730
764
|
var _a, _b, _c, _d, _e, _f;
|
|
731
765
|
var args = [];
|
|
732
766
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -790,11 +824,11 @@ function fromJson$3(json) {
|
|
|
790
824
|
var obj = JSON.parse(json);
|
|
791
825
|
if (Array.isArray(obj)) {
|
|
792
826
|
var x = obj[0], y = obj[1], z = obj[2];
|
|
793
|
-
return create$
|
|
827
|
+
return create$b(x, y, z);
|
|
794
828
|
}
|
|
795
829
|
else {
|
|
796
830
|
var x = obj.x, y = obj.y, z = obj.z;
|
|
797
|
-
return create$
|
|
831
|
+
return create$b(x, y, z);
|
|
798
832
|
}
|
|
799
833
|
}
|
|
800
834
|
/**
|
|
@@ -809,7 +843,7 @@ function fromArray(nums, offset) {
|
|
|
809
843
|
var x = nums[offset];
|
|
810
844
|
var y = nums[offset + 1];
|
|
811
845
|
var z = nums[offset + 2];
|
|
812
|
-
return create$
|
|
846
|
+
return create$b(x, y, z);
|
|
813
847
|
}
|
|
814
848
|
/**
|
|
815
849
|
* Converts a Vector3 to an array where the values of the vector will be
|
|
@@ -826,43 +860,43 @@ function toArray(_a) {
|
|
|
826
860
|
* Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
|
|
827
861
|
*/
|
|
828
862
|
function right() {
|
|
829
|
-
return create$
|
|
863
|
+
return create$b(1, 0, 0);
|
|
830
864
|
}
|
|
831
865
|
/**
|
|
832
866
|
* Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
|
|
833
867
|
*/
|
|
834
868
|
function up() {
|
|
835
|
-
return create$
|
|
869
|
+
return create$b(0, 1, 0);
|
|
836
870
|
}
|
|
837
871
|
/**
|
|
838
872
|
* Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
|
|
839
873
|
*/
|
|
840
874
|
function forward() {
|
|
841
|
-
return create$
|
|
875
|
+
return create$b(0, 0, -1);
|
|
842
876
|
}
|
|
843
877
|
/**
|
|
844
878
|
* Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
|
|
845
879
|
*/
|
|
846
880
|
function left() {
|
|
847
|
-
return create$
|
|
881
|
+
return create$b(-1, 0, 0);
|
|
848
882
|
}
|
|
849
883
|
/**
|
|
850
884
|
* Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
|
|
851
885
|
*/
|
|
852
886
|
function down() {
|
|
853
|
-
return create$
|
|
887
|
+
return create$b(0, -1, 0);
|
|
854
888
|
}
|
|
855
889
|
/**
|
|
856
890
|
* Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
|
|
857
891
|
*/
|
|
858
892
|
function back() {
|
|
859
|
-
return create$
|
|
893
|
+
return create$b(0, 0, 1);
|
|
860
894
|
}
|
|
861
895
|
/**
|
|
862
896
|
* Returns a vector at the origin, Vector3(0, 0, 0).
|
|
863
897
|
*/
|
|
864
898
|
function origin() {
|
|
865
|
-
return create$
|
|
899
|
+
return create$b(0, 0, 0);
|
|
866
900
|
}
|
|
867
901
|
/**
|
|
868
902
|
* Returns a vector with that will have a magnitude of 1.
|
|
@@ -1045,13 +1079,13 @@ function isEqual$2(a, b) {
|
|
|
1045
1079
|
* Returns a vector that contains the largest components of `a` and `b`.
|
|
1046
1080
|
*/
|
|
1047
1081
|
function max(a, b) {
|
|
1048
|
-
return create$
|
|
1082
|
+
return create$b(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
|
|
1049
1083
|
}
|
|
1050
1084
|
/**
|
|
1051
1085
|
* Returns a vector that contains the smallest components of `a` and `b`.
|
|
1052
1086
|
*/
|
|
1053
1087
|
function min(a, b) {
|
|
1054
|
-
return create$
|
|
1088
|
+
return create$b(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
|
|
1055
1089
|
}
|
|
1056
1090
|
/**
|
|
1057
1091
|
* Returns a vector that each of its component negated.
|
|
@@ -1089,7 +1123,7 @@ function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
|
|
|
1089
1123
|
|
|
1090
1124
|
var vector3 = /*#__PURE__*/Object.freeze({
|
|
1091
1125
|
__proto__: null,
|
|
1092
|
-
create: create$
|
|
1126
|
+
create: create$b,
|
|
1093
1127
|
isValid: isValid,
|
|
1094
1128
|
fromMatrixScale: fromMatrixScale,
|
|
1095
1129
|
fromMatrixPosition: fromMatrixPosition,
|
|
@@ -1129,7 +1163,7 @@ var vector3 = /*#__PURE__*/Object.freeze({
|
|
|
1129
1163
|
/**
|
|
1130
1164
|
* Returns a `BoundingBox` with the given min and max points.
|
|
1131
1165
|
*/
|
|
1132
|
-
var create$
|
|
1166
|
+
var create$a = function (min, max) {
|
|
1133
1167
|
return { min: min, max: max };
|
|
1134
1168
|
};
|
|
1135
1169
|
/**
|
|
@@ -1137,7 +1171,7 @@ var create$9 = function (min, max) {
|
|
|
1137
1171
|
* are contained by the bounding box.
|
|
1138
1172
|
*/
|
|
1139
1173
|
var fromVectors = function (vectors) {
|
|
1140
|
-
return union.apply(void 0, vectors.map(function (v) { return create$
|
|
1174
|
+
return union.apply(void 0, vectors.map(function (v) { return create$a(v, v); }));
|
|
1141
1175
|
};
|
|
1142
1176
|
/**
|
|
1143
1177
|
* Returns the center point of the given `BoundingBox`.
|
|
@@ -1152,19 +1186,36 @@ function union(box) {
|
|
|
1152
1186
|
}
|
|
1153
1187
|
var boxes = __spreadArray([box], rest, true);
|
|
1154
1188
|
return boxes.reduce(function (a, b) {
|
|
1155
|
-
return create$
|
|
1189
|
+
return create$a(min(a.min, b.min), max(a.max, b.max));
|
|
1156
1190
|
});
|
|
1157
1191
|
}
|
|
1158
1192
|
/* eslint-enable padding-line-between-statements */
|
|
1159
1193
|
|
|
1160
1194
|
var boundingBox = /*#__PURE__*/Object.freeze({
|
|
1161
1195
|
__proto__: null,
|
|
1162
|
-
create: create$
|
|
1196
|
+
create: create$a,
|
|
1163
1197
|
fromVectors: fromVectors,
|
|
1164
1198
|
center: center$3,
|
|
1165
1199
|
union: union
|
|
1166
1200
|
});
|
|
1167
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
|
|
1204
|
+
*/
|
|
1205
|
+
var create$9 = function (boundingBox$1) {
|
|
1206
|
+
var boundingBoxCenter = center$3(boundingBox$1);
|
|
1207
|
+
var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
|
|
1208
|
+
var radius = magnitude(centerToBoundingPlane);
|
|
1209
|
+
var length = Math.max(radius, magnitude(boundingBoxCenter));
|
|
1210
|
+
var epsilon = length === 0 ? 1.0 : length * 1e-6;
|
|
1211
|
+
return { center: boundingBoxCenter, radius: radius, epsilon: epsilon };
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
var boundingSphere = /*#__PURE__*/Object.freeze({
|
|
1215
|
+
__proto__: null,
|
|
1216
|
+
create: create$9
|
|
1217
|
+
});
|
|
1218
|
+
|
|
1168
1219
|
/**
|
|
1169
1220
|
* Returns a new `Rectangle` with the given position and size.
|
|
1170
1221
|
*/
|
|
@@ -1286,13 +1337,13 @@ function center$2(rect) {
|
|
|
1286
1337
|
* Returns the top-left position of the rectangle, as a point.
|
|
1287
1338
|
*/
|
|
1288
1339
|
function topLeft(rect) {
|
|
1289
|
-
return create$
|
|
1340
|
+
return create$c(rect.x, rect.y);
|
|
1290
1341
|
}
|
|
1291
1342
|
/**
|
|
1292
1343
|
* Returns the bottom-right position of the rectangle, as a point.
|
|
1293
1344
|
*/
|
|
1294
1345
|
function bottomRight(rect) {
|
|
1295
|
-
return create$
|
|
1346
|
+
return create$c(rect.x + rect.width, rect.y + rect.height);
|
|
1296
1347
|
}
|
|
1297
1348
|
/**
|
|
1298
1349
|
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
@@ -1497,7 +1548,7 @@ var fitToRatio = function (ratio, dimensions) {
|
|
|
1497
1548
|
* Converts a dimension to a rectangle, with an optional position.
|
|
1498
1549
|
*/
|
|
1499
1550
|
function toRectangle(dimensions, position) {
|
|
1500
|
-
if (position === void 0) { position = create$
|
|
1551
|
+
if (position === void 0) { position = create$c(); }
|
|
1501
1552
|
return fromPointAndDimensions(position, dimensions);
|
|
1502
1553
|
}
|
|
1503
1554
|
|
|
@@ -1799,7 +1850,7 @@ var translate = function (dx, dy, matrix) {
|
|
|
1799
1850
|
var transformPoint = function (matrix, pt) {
|
|
1800
1851
|
var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
|
|
1801
1852
|
var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
|
|
1802
|
-
return create$
|
|
1853
|
+
return create$c(x, y);
|
|
1803
1854
|
};
|
|
1804
1855
|
|
|
1805
1856
|
var matrix = /*#__PURE__*/Object.freeze({
|
|
@@ -2191,5 +2242,5 @@ var ray = /*#__PURE__*/Object.freeze({
|
|
|
2191
2242
|
intersectPlane: intersectPlane
|
|
2192
2243
|
});
|
|
2193
2244
|
|
|
2194
|
-
export { angle as Angle, boundingBox as BoundingBox, 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 };
|
|
2245
|
+
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 };
|
|
2195
2246
|
//# sourceMappingURL=bundle.esm.js.map
|