@vertexvis/geometry 0.10.2-canary.11 → 0.10.2-canary.12
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/bundle.cjs.js +208 -208
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +208 -208
- package/dist/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.js +208 -208
- 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/package.json +7 -7
- package/dist/bundle.cjs.min.js +0 -2
- package/dist/bundle.cjs.min.js.map +0 -1
- package/dist/bundle.esm.min.js +0 -2
- package/dist/bundle.esm.min.js.map +0 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -25,7 +25,7 @@ function clamp(value, min, max) {
|
|
|
25
25
|
* @param t The interpolation value between 0 and 1.
|
|
26
26
|
* @returns The interpolated value between `a` and `b`.
|
|
27
27
|
*/
|
|
28
|
-
function lerp(a, b, t) {
|
|
28
|
+
function lerp$2(a, b, t) {
|
|
29
29
|
t = clamp(t, 0, 1);
|
|
30
30
|
return t * (b - a) + a;
|
|
31
31
|
}
|
|
@@ -33,7 +33,7 @@ function lerp(a, b, t) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Returns a new `Point` with the given horizontal and vertical position.
|
|
35
35
|
*/
|
|
36
|
-
function create(x, y) {
|
|
36
|
+
function create$b(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,31 +44,31 @@ function create(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(x, y);
|
|
47
|
+
return create$b(x, y);
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Returns the distance between two points.
|
|
51
51
|
*/
|
|
52
|
-
function distance(a, b) {
|
|
53
|
-
var delta = subtract(a, b);
|
|
52
|
+
function distance$2(a, b) {
|
|
53
|
+
var delta = subtract$1(a, b);
|
|
54
54
|
return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Returns a new `Point` where `b` is subtracted from `a`.
|
|
58
58
|
*/
|
|
59
|
-
function subtract(a, b) {
|
|
59
|
+
function subtract$1(a, b) {
|
|
60
60
|
return { x: a.x - b.x, y: a.y - b.y };
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Returns a new `Point` where `b` is added to `a`.
|
|
64
64
|
*/
|
|
65
|
-
function add(a, b) {
|
|
65
|
+
function add$1(a, b) {
|
|
66
66
|
return { x: a.x + b.x, y: a.y + b.y };
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* Returns `true` if the `x` and `y` positions of `a` and `b` are equal.
|
|
70
70
|
*/
|
|
71
|
-
function isEqual(a, b) {
|
|
71
|
+
function isEqual$3(a, b) {
|
|
72
72
|
return a.x === b.x && a.y === b.y;
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -82,21 +82,21 @@ function isEqual(a, b) {
|
|
|
82
82
|
*/
|
|
83
83
|
function lerp$1(a, b, t) {
|
|
84
84
|
return {
|
|
85
|
-
x: lerp(a.x, b.x, t),
|
|
86
|
-
y: lerp(a.y, b.y, t),
|
|
85
|
+
x: lerp$2(a.x, b.x, t),
|
|
86
|
+
y: lerp$2(a.y, b.y, t),
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns a new `Point` where `x` and `y` are inverted.
|
|
91
91
|
*/
|
|
92
|
-
function negate(pt) {
|
|
93
|
-
return create(-pt.x, -pt.y);
|
|
92
|
+
function negate$1(pt) {
|
|
93
|
+
return create$b(-pt.x, -pt.y);
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Returns a new `Point` where `x` and `y` are multiplied by the given scale
|
|
97
97
|
* factors.
|
|
98
98
|
*/
|
|
99
|
-
function scale(pt, scaleX, scaleY) {
|
|
99
|
+
function scale$4(pt, scaleX, scaleY) {
|
|
100
100
|
return {
|
|
101
101
|
x: pt.x * scaleX,
|
|
102
102
|
y: pt.y * scaleY,
|
|
@@ -108,30 +108,30 @@ function scale(pt, scaleX, scaleY) {
|
|
|
108
108
|
* @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
|
|
109
109
|
* @returns A parsed Point.
|
|
110
110
|
*/
|
|
111
|
-
function fromJson(json) {
|
|
111
|
+
function fromJson$4(json) {
|
|
112
112
|
var obj = JSON.parse(json);
|
|
113
113
|
if (Array.isArray(obj)) {
|
|
114
114
|
var x = obj[0], y = obj[1];
|
|
115
|
-
return create(x, y);
|
|
115
|
+
return create$b(x, y);
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
var x = obj.x, y = obj.y;
|
|
119
|
-
return create(x, y);
|
|
119
|
+
return create$b(x, y);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
var point = /*#__PURE__*/Object.freeze({
|
|
124
124
|
__proto__: null,
|
|
125
|
-
create: create,
|
|
125
|
+
create: create$b,
|
|
126
126
|
polar: polar,
|
|
127
|
-
distance: distance,
|
|
128
|
-
subtract: subtract,
|
|
129
|
-
add: add,
|
|
130
|
-
isEqual: isEqual,
|
|
127
|
+
distance: distance$2,
|
|
128
|
+
subtract: subtract$1,
|
|
129
|
+
add: add$1,
|
|
130
|
+
isEqual: isEqual$3,
|
|
131
131
|
lerp: lerp$1,
|
|
132
|
-
negate: negate,
|
|
133
|
-
scale: scale,
|
|
134
|
-
fromJson: fromJson
|
|
132
|
+
negate: negate$1,
|
|
133
|
+
scale: scale$4,
|
|
134
|
+
fromJson: fromJson$4
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
/**
|
|
@@ -141,8 +141,8 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
141
141
|
* @param b The ending point.
|
|
142
142
|
* @returns An angle in radians.
|
|
143
143
|
*/
|
|
144
|
-
function fromPoints(a, b) {
|
|
145
|
-
var delta = subtract(b, a);
|
|
144
|
+
function fromPoints$1(a, b) {
|
|
145
|
+
var delta = subtract$1(b, a);
|
|
146
146
|
var theta = Math.atan2(delta.y, delta.x);
|
|
147
147
|
return theta;
|
|
148
148
|
}
|
|
@@ -155,14 +155,14 @@ function fromPoints(a, b) {
|
|
|
155
155
|
* @deprecated Use {@link fromPoints} instead.
|
|
156
156
|
*/
|
|
157
157
|
function fromPointsInDegrees(a, b) {
|
|
158
|
-
var delta = subtract(b, a);
|
|
158
|
+
var delta = subtract$1(b, a);
|
|
159
159
|
var theta = Math.atan2(delta.y, delta.x);
|
|
160
|
-
return normalize(toDegrees(theta) - 270);
|
|
160
|
+
return normalize$1(toDegrees(theta) - 270);
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Normalizes the given angle, in degrees, to a number between 0 and 359.
|
|
164
164
|
*/
|
|
165
|
-
function normalize(degrees) {
|
|
165
|
+
function normalize$1(degrees) {
|
|
166
166
|
return (degrees + 3600) % 360;
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
@@ -180,9 +180,9 @@ function toRadians(degrees) {
|
|
|
180
180
|
|
|
181
181
|
var angle = /*#__PURE__*/Object.freeze({
|
|
182
182
|
__proto__: null,
|
|
183
|
-
fromPoints: fromPoints,
|
|
183
|
+
fromPoints: fromPoints$1,
|
|
184
184
|
fromPointsInDegrees: fromPointsInDegrees,
|
|
185
|
-
normalize: normalize,
|
|
185
|
+
normalize: normalize$1,
|
|
186
186
|
toDegrees: toDegrees,
|
|
187
187
|
toRadians: toRadians
|
|
188
188
|
});
|
|
@@ -310,7 +310,7 @@ function makeTRS(translation, rotation, scale) {
|
|
|
310
310
|
var t = makeTranslation(translation);
|
|
311
311
|
var r = makeRotation(rotation);
|
|
312
312
|
var s = makeScale(scale);
|
|
313
|
-
return multiply(multiply(t, r), s);
|
|
313
|
+
return multiply$2(multiply$2(t, r), s);
|
|
314
314
|
}
|
|
315
315
|
/**
|
|
316
316
|
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
@@ -443,12 +443,12 @@ function makePerspective(near, far, fovY, aspect) {
|
|
|
443
443
|
* @returns A matrix.
|
|
444
444
|
*/
|
|
445
445
|
function makeLookAtView(position, lookAt, up) {
|
|
446
|
-
var z = normalize
|
|
447
|
-
var x = normalize
|
|
446
|
+
var z = normalize(subtract(position, lookAt));
|
|
447
|
+
var x = normalize(cross(up, z));
|
|
448
448
|
var y = cross(z, x);
|
|
449
|
-
var dotX = -dot(x, position);
|
|
450
|
-
var dotY = -dot(y, position);
|
|
451
|
-
var dotZ = -dot(z, position);
|
|
449
|
+
var dotX = -dot$1(x, position);
|
|
450
|
+
var dotY = -dot$1(y, position);
|
|
451
|
+
var dotZ = -dot$1(z, position);
|
|
452
452
|
/* eslint-disable prettier/prettier */
|
|
453
453
|
return [
|
|
454
454
|
x.x, y.x, z.x, 0,
|
|
@@ -472,8 +472,8 @@ function makeLookAtView(position, lookAt, up) {
|
|
|
472
472
|
* @returns A matrix.
|
|
473
473
|
*/
|
|
474
474
|
function makeLookAt(position, lookAt, up) {
|
|
475
|
-
var z = normalize
|
|
476
|
-
var x = normalize
|
|
475
|
+
var z = normalize(subtract(position, lookAt));
|
|
476
|
+
var x = normalize(cross(up, z));
|
|
477
477
|
var y = cross(z, x);
|
|
478
478
|
/* eslint-disable prettier/prettier */
|
|
479
479
|
return [
|
|
@@ -541,11 +541,11 @@ function invert(matrix) {
|
|
|
541
541
|
* @returns A rotation matrix.
|
|
542
542
|
*/
|
|
543
543
|
function lookAt(m, position, target, up) {
|
|
544
|
-
var z = subtract
|
|
544
|
+
var z = subtract(position, target);
|
|
545
545
|
if (magnitudeSquared(z) === 0) {
|
|
546
546
|
z = tslib.__assign(tslib.__assign({}, z), { z: 1 });
|
|
547
547
|
}
|
|
548
|
-
z = normalize
|
|
548
|
+
z = normalize(z);
|
|
549
549
|
var x = cross(up, z);
|
|
550
550
|
if (magnitudeSquared(x) === 0) {
|
|
551
551
|
if (Math.abs(up.z) === 1) {
|
|
@@ -554,10 +554,10 @@ function lookAt(m, position, target, up) {
|
|
|
554
554
|
else {
|
|
555
555
|
z = tslib.__assign(tslib.__assign({}, z), { z: z.z + 0.0001 });
|
|
556
556
|
}
|
|
557
|
-
z = normalize
|
|
557
|
+
z = normalize(z);
|
|
558
558
|
x = cross(up, z);
|
|
559
559
|
}
|
|
560
|
-
x = normalize
|
|
560
|
+
x = normalize(x);
|
|
561
561
|
var y = cross(z, x);
|
|
562
562
|
var res = tslib.__spreadArray([], m, true);
|
|
563
563
|
/* eslint-disable prettier/prettier */
|
|
@@ -576,7 +576,7 @@ function lookAt(m, position, target, up) {
|
|
|
576
576
|
/**
|
|
577
577
|
* Returns a post-multiplied matrix.
|
|
578
578
|
*/
|
|
579
|
-
function multiply(a, b) {
|
|
579
|
+
function multiply$2(a, b) {
|
|
580
580
|
var ae = a;
|
|
581
581
|
var be = b;
|
|
582
582
|
var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
|
|
@@ -623,7 +623,7 @@ function transpose(matrix) {
|
|
|
623
623
|
/**
|
|
624
624
|
* Multiplies the columns of a matrix by the given vector.
|
|
625
625
|
*/
|
|
626
|
-
function scale$
|
|
626
|
+
function scale$3(matrix, scale) {
|
|
627
627
|
var x = scale.x, y = scale.y, z = scale.z;
|
|
628
628
|
var m = tslib.__spreadArray([], matrix, true);
|
|
629
629
|
/* eslint-disable prettier/prettier */
|
|
@@ -665,7 +665,7 @@ function toObject(m) {
|
|
|
665
665
|
/**
|
|
666
666
|
* A type guard to check if `obj` is of type `Matrix4`.
|
|
667
667
|
*/
|
|
668
|
-
function isType(obj) {
|
|
668
|
+
function isType$2(obj) {
|
|
669
669
|
return Array.isArray(obj) && obj.length === 16;
|
|
670
670
|
}
|
|
671
671
|
|
|
@@ -687,15 +687,15 @@ var matrix4 = /*#__PURE__*/Object.freeze({
|
|
|
687
687
|
makeLookAt: makeLookAt,
|
|
688
688
|
invert: invert,
|
|
689
689
|
lookAt: lookAt,
|
|
690
|
-
multiply: multiply,
|
|
690
|
+
multiply: multiply$2,
|
|
691
691
|
transpose: transpose,
|
|
692
|
-
scale: scale$
|
|
692
|
+
scale: scale$3,
|
|
693
693
|
position: position,
|
|
694
694
|
toObject: toObject,
|
|
695
|
-
isType: isType
|
|
695
|
+
isType: isType$2
|
|
696
696
|
});
|
|
697
697
|
|
|
698
|
-
function create$
|
|
698
|
+
function create$a() {
|
|
699
699
|
var _a, _b, _c, _d, _e, _f;
|
|
700
700
|
var args = [];
|
|
701
701
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -755,15 +755,15 @@ function fromMatrixPosition(matrix) {
|
|
|
755
755
|
* @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
|
|
756
756
|
* @returns A parsed Vector3.
|
|
757
757
|
*/
|
|
758
|
-
function fromJson$
|
|
758
|
+
function fromJson$3(json) {
|
|
759
759
|
var obj = JSON.parse(json);
|
|
760
760
|
if (Array.isArray(obj)) {
|
|
761
761
|
var x = obj[0], y = obj[1], z = obj[2];
|
|
762
|
-
return create$
|
|
762
|
+
return create$a(x, y, z);
|
|
763
763
|
}
|
|
764
764
|
else {
|
|
765
765
|
var x = obj.x, y = obj.y, z = obj.z;
|
|
766
|
-
return create$
|
|
766
|
+
return create$a(x, y, z);
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
/**
|
|
@@ -778,7 +778,7 @@ function fromArray(nums, offset) {
|
|
|
778
778
|
var x = nums[offset];
|
|
779
779
|
var y = nums[offset + 1];
|
|
780
780
|
var z = nums[offset + 2];
|
|
781
|
-
return create$
|
|
781
|
+
return create$a(x, y, z);
|
|
782
782
|
}
|
|
783
783
|
/**
|
|
784
784
|
* Converts a Vector3 to an array where the values of the vector will be
|
|
@@ -795,48 +795,48 @@ function toArray(_a) {
|
|
|
795
795
|
* Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
|
|
796
796
|
*/
|
|
797
797
|
function right() {
|
|
798
|
-
return create$
|
|
798
|
+
return create$a(1, 0, 0);
|
|
799
799
|
}
|
|
800
800
|
/**
|
|
801
801
|
* Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
|
|
802
802
|
*/
|
|
803
803
|
function up() {
|
|
804
|
-
return create$
|
|
804
|
+
return create$a(0, 1, 0);
|
|
805
805
|
}
|
|
806
806
|
/**
|
|
807
807
|
* Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
|
|
808
808
|
*/
|
|
809
809
|
function forward() {
|
|
810
|
-
return create$
|
|
810
|
+
return create$a(0, 0, -1);
|
|
811
811
|
}
|
|
812
812
|
/**
|
|
813
813
|
* Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
|
|
814
814
|
*/
|
|
815
815
|
function left() {
|
|
816
|
-
return create$
|
|
816
|
+
return create$a(-1, 0, 0);
|
|
817
817
|
}
|
|
818
818
|
/**
|
|
819
819
|
* Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
|
|
820
820
|
*/
|
|
821
821
|
function down() {
|
|
822
|
-
return create$
|
|
822
|
+
return create$a(0, -1, 0);
|
|
823
823
|
}
|
|
824
824
|
/**
|
|
825
825
|
* Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
|
|
826
826
|
*/
|
|
827
827
|
function back() {
|
|
828
|
-
return create$
|
|
828
|
+
return create$a(0, 0, 1);
|
|
829
829
|
}
|
|
830
830
|
/**
|
|
831
831
|
* Returns a vector at the origin, Vector3(0, 0, 0).
|
|
832
832
|
*/
|
|
833
833
|
function origin() {
|
|
834
|
-
return create$
|
|
834
|
+
return create$a(0, 0, 0);
|
|
835
835
|
}
|
|
836
836
|
/**
|
|
837
837
|
* Returns a vector with that will have a magnitude of 1.
|
|
838
838
|
*/
|
|
839
|
-
function normalize
|
|
839
|
+
function normalize(vector) {
|
|
840
840
|
var length = magnitude(vector);
|
|
841
841
|
return { x: vector.x / length, y: vector.y / length, z: vector.z / length };
|
|
842
842
|
}
|
|
@@ -874,7 +874,7 @@ function cross(a, b) {
|
|
|
874
874
|
/**
|
|
875
875
|
* Returns a vector that is the sum of two vectors.
|
|
876
876
|
*/
|
|
877
|
-
function add
|
|
877
|
+
function add(a) {
|
|
878
878
|
var vectors = [];
|
|
879
879
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
880
880
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -886,7 +886,7 @@ function add$1(a) {
|
|
|
886
886
|
/**
|
|
887
887
|
* Returns a vector that is the difference between two vectors.
|
|
888
888
|
*/
|
|
889
|
-
function subtract
|
|
889
|
+
function subtract(a) {
|
|
890
890
|
var vectors = [];
|
|
891
891
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
892
892
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -914,7 +914,7 @@ function scale$2(scalar, vector) {
|
|
|
914
914
|
* multiplied together and then multiplied by the cosine of the angle between
|
|
915
915
|
* them.
|
|
916
916
|
*/
|
|
917
|
-
function dot(a, b) {
|
|
917
|
+
function dot$1(a, b) {
|
|
918
918
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
919
919
|
}
|
|
920
920
|
/**
|
|
@@ -925,7 +925,7 @@ function dot(a, b) {
|
|
|
925
925
|
* result is never greater than 180 degrees.
|
|
926
926
|
*/
|
|
927
927
|
function angleTo(a, b) {
|
|
928
|
-
var theta = dot(a, b) / (magnitude(a) * magnitude(b));
|
|
928
|
+
var theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
|
|
929
929
|
// Clamp to avoid numerical problems.
|
|
930
930
|
return Math.acos(theta);
|
|
931
931
|
}
|
|
@@ -945,7 +945,7 @@ function angleTo(a, b) {
|
|
|
945
945
|
* ```
|
|
946
946
|
*/
|
|
947
947
|
function project(vector, onNormal) {
|
|
948
|
-
return scale$2(dot(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
948
|
+
return scale$2(dot$1(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
949
949
|
}
|
|
950
950
|
/**
|
|
951
951
|
* Returns a vector that is rotated about an origin point.
|
|
@@ -981,7 +981,7 @@ function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
|
|
|
981
981
|
/**
|
|
982
982
|
* Returns a vector that is multiplied with a matrix.
|
|
983
983
|
*/
|
|
984
|
-
function transformMatrix(vector, m) {
|
|
984
|
+
function transformMatrix$1(vector, m) {
|
|
985
985
|
var x = vector.x, y = vector.y, z = vector.z;
|
|
986
986
|
var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
|
|
987
987
|
return {
|
|
@@ -994,38 +994,38 @@ function transformMatrix(vector, m) {
|
|
|
994
994
|
* Euclidean distance between two vectors
|
|
995
995
|
*/
|
|
996
996
|
function distance$1(a, b) {
|
|
997
|
-
return Math.sqrt(distanceSquared(a, b));
|
|
997
|
+
return Math.sqrt(distanceSquared$1(a, b));
|
|
998
998
|
}
|
|
999
999
|
/**
|
|
1000
1000
|
* Returns the squared distance between two vectors. If you're just comparing
|
|
1001
1001
|
* distances, this is slightly more efficient than `distanceTo`.
|
|
1002
1002
|
*/
|
|
1003
|
-
function distanceSquared(a, b) {
|
|
1004
|
-
var _a = subtract
|
|
1003
|
+
function distanceSquared$1(a, b) {
|
|
1004
|
+
var _a = subtract(a, b), dx = _a.x, dy = _a.y, dz = _a.z;
|
|
1005
1005
|
return dx * dx + dy * dy + dz * dz;
|
|
1006
1006
|
}
|
|
1007
1007
|
/**
|
|
1008
1008
|
* Returns `true` if two vectors have the same values.
|
|
1009
1009
|
*/
|
|
1010
|
-
function isEqual$
|
|
1010
|
+
function isEqual$2(a, b) {
|
|
1011
1011
|
return a.x === b.x && a.y === b.y && a.z === b.z;
|
|
1012
1012
|
}
|
|
1013
1013
|
/**
|
|
1014
1014
|
* Returns a vector that contains the largest components of `a` and `b`.
|
|
1015
1015
|
*/
|
|
1016
1016
|
function max(a, b) {
|
|
1017
|
-
return create$
|
|
1017
|
+
return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
|
|
1018
1018
|
}
|
|
1019
1019
|
/**
|
|
1020
1020
|
* Returns a vector that contains the smallest components of `a` and `b`.
|
|
1021
1021
|
*/
|
|
1022
1022
|
function min(a, b) {
|
|
1023
|
-
return create$
|
|
1023
|
+
return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
|
|
1024
1024
|
}
|
|
1025
1025
|
/**
|
|
1026
1026
|
* Returns a vector that each of its component negated.
|
|
1027
1027
|
*/
|
|
1028
|
-
function negate
|
|
1028
|
+
function negate(vector) {
|
|
1029
1029
|
return { x: -vector.x, y: -vector.y, z: -vector.z };
|
|
1030
1030
|
}
|
|
1031
1031
|
/**
|
|
@@ -1037,21 +1037,21 @@ function negate$1(vector) {
|
|
|
1037
1037
|
* @param t A value between 0 and 1.
|
|
1038
1038
|
* @returns A point between `a` and `b`.
|
|
1039
1039
|
*/
|
|
1040
|
-
function lerp
|
|
1040
|
+
function lerp(a, b, t) {
|
|
1041
1041
|
return {
|
|
1042
|
-
x: lerp(a.x, b.x, t),
|
|
1043
|
-
y: lerp(a.y, b.y, t),
|
|
1044
|
-
z: lerp(a.z, b.z, t),
|
|
1042
|
+
x: lerp$2(a.x, b.x, t),
|
|
1043
|
+
y: lerp$2(a.y, b.y, t),
|
|
1044
|
+
z: lerp$2(a.z, b.z, t),
|
|
1045
1045
|
};
|
|
1046
1046
|
}
|
|
1047
1047
|
|
|
1048
1048
|
var vector3 = /*#__PURE__*/Object.freeze({
|
|
1049
1049
|
__proto__: null,
|
|
1050
|
-
create: create$
|
|
1050
|
+
create: create$a,
|
|
1051
1051
|
isValid: isValid,
|
|
1052
1052
|
fromMatrixScale: fromMatrixScale,
|
|
1053
1053
|
fromMatrixPosition: fromMatrixPosition,
|
|
1054
|
-
fromJson: fromJson$
|
|
1054
|
+
fromJson: fromJson$3,
|
|
1055
1055
|
fromArray: fromArray,
|
|
1056
1056
|
toArray: toArray,
|
|
1057
1057
|
right: right,
|
|
@@ -1061,32 +1061,32 @@ var vector3 = /*#__PURE__*/Object.freeze({
|
|
|
1061
1061
|
down: down,
|
|
1062
1062
|
back: back,
|
|
1063
1063
|
origin: origin,
|
|
1064
|
-
normalize: normalize
|
|
1064
|
+
normalize: normalize,
|
|
1065
1065
|
magnitude: magnitude,
|
|
1066
1066
|
magnitudeSquared: magnitudeSquared,
|
|
1067
1067
|
cross: cross,
|
|
1068
|
-
add: add
|
|
1069
|
-
subtract: subtract
|
|
1068
|
+
add: add,
|
|
1069
|
+
subtract: subtract,
|
|
1070
1070
|
multiply: multiply$1,
|
|
1071
1071
|
scale: scale$2,
|
|
1072
|
-
dot: dot,
|
|
1072
|
+
dot: dot$1,
|
|
1073
1073
|
angleTo: angleTo,
|
|
1074
1074
|
project: project,
|
|
1075
1075
|
rotateAboutAxis: rotateAboutAxis,
|
|
1076
|
-
transformMatrix: transformMatrix,
|
|
1076
|
+
transformMatrix: transformMatrix$1,
|
|
1077
1077
|
distance: distance$1,
|
|
1078
|
-
distanceSquared: distanceSquared,
|
|
1079
|
-
isEqual: isEqual$
|
|
1078
|
+
distanceSquared: distanceSquared$1,
|
|
1079
|
+
isEqual: isEqual$2,
|
|
1080
1080
|
max: max,
|
|
1081
1081
|
min: min,
|
|
1082
|
-
negate: negate
|
|
1083
|
-
lerp: lerp
|
|
1082
|
+
negate: negate,
|
|
1083
|
+
lerp: lerp
|
|
1084
1084
|
});
|
|
1085
1085
|
|
|
1086
1086
|
/**
|
|
1087
1087
|
* Returns a `BoundingBox` with the given min and max points.
|
|
1088
1088
|
*/
|
|
1089
|
-
var create$
|
|
1089
|
+
var create$9 = function (min, max) {
|
|
1090
1090
|
return { min: min, max: max };
|
|
1091
1091
|
};
|
|
1092
1092
|
/**
|
|
@@ -1094,13 +1094,13 @@ var create$2 = function (min, max) {
|
|
|
1094
1094
|
* are contained by the bounding box.
|
|
1095
1095
|
*/
|
|
1096
1096
|
var fromVectors = function (vectors) {
|
|
1097
|
-
return union.apply(void 0, vectors.map(function (v) { return create$
|
|
1097
|
+
return union.apply(void 0, vectors.map(function (v) { return create$9(v, v); }));
|
|
1098
1098
|
};
|
|
1099
1099
|
/**
|
|
1100
1100
|
* Returns the center point of the given `BoundingBox`.
|
|
1101
1101
|
*/
|
|
1102
|
-
var center = function (boundingBox) {
|
|
1103
|
-
return scale$2(0.5, add
|
|
1102
|
+
var center$3 = function (boundingBox) {
|
|
1103
|
+
return scale$2(0.5, add(boundingBox.min, boundingBox.max));
|
|
1104
1104
|
};
|
|
1105
1105
|
function union(box) {
|
|
1106
1106
|
var rest = [];
|
|
@@ -1109,47 +1109,47 @@ function union(box) {
|
|
|
1109
1109
|
}
|
|
1110
1110
|
var boxes = tslib.__spreadArray([box], rest, true);
|
|
1111
1111
|
return boxes.reduce(function (a, b) {
|
|
1112
|
-
return create$
|
|
1112
|
+
return create$9(min(a.min, b.min), max(a.max, b.max));
|
|
1113
1113
|
});
|
|
1114
1114
|
}
|
|
1115
1115
|
/* eslint-enable padding-line-between-statements */
|
|
1116
1116
|
|
|
1117
1117
|
var boundingBox = /*#__PURE__*/Object.freeze({
|
|
1118
1118
|
__proto__: null,
|
|
1119
|
-
create: create$
|
|
1119
|
+
create: create$9,
|
|
1120
1120
|
fromVectors: fromVectors,
|
|
1121
|
-
center: center,
|
|
1121
|
+
center: center$3,
|
|
1122
1122
|
union: union
|
|
1123
1123
|
});
|
|
1124
1124
|
|
|
1125
1125
|
/**
|
|
1126
1126
|
* Returns a new `Rectangle` with the given position and size.
|
|
1127
1127
|
*/
|
|
1128
|
-
function create$
|
|
1128
|
+
function create$8(x, y, width, height) {
|
|
1129
1129
|
return { x: x, y: y, width: width, height: height };
|
|
1130
1130
|
}
|
|
1131
1131
|
/**
|
|
1132
1132
|
* Returns a new `Rectangle` at the origin point and given size.
|
|
1133
1133
|
*/
|
|
1134
1134
|
function fromDimensions(dimensions) {
|
|
1135
|
-
return create$
|
|
1135
|
+
return create$8(0, 0, dimensions.width, dimensions.height);
|
|
1136
1136
|
}
|
|
1137
1137
|
/**
|
|
1138
1138
|
* Returns a new `Rectangle` with the given position and size.
|
|
1139
1139
|
*/
|
|
1140
1140
|
function fromPointAndDimensions(point, dimensions) {
|
|
1141
|
-
return create$
|
|
1141
|
+
return create$8(point.x, point.y, dimensions.width, dimensions.height);
|
|
1142
1142
|
}
|
|
1143
1143
|
/**
|
|
1144
1144
|
* Returns a new `Rectangle` with the given top-left and bottom-right positions.
|
|
1145
1145
|
* The returned rectangle will always returns a positive width and height.
|
|
1146
1146
|
*/
|
|
1147
|
-
function fromPoints
|
|
1147
|
+
function fromPoints(topLeftPt, bottomRightPt) {
|
|
1148
1148
|
var minX = Math.min(topLeftPt.x, bottomRightPt.x);
|
|
1149
1149
|
var minY = Math.min(topLeftPt.y, bottomRightPt.y);
|
|
1150
1150
|
var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
|
|
1151
1151
|
var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
|
|
1152
|
-
return create$
|
|
1152
|
+
return create$8(minX, minY, maxX - minX, maxY - minY);
|
|
1153
1153
|
}
|
|
1154
1154
|
/**
|
|
1155
1155
|
* Returns a rectangle where the longest length of `rect` will be equal to the
|
|
@@ -1159,10 +1159,10 @@ function fromPoints$1(topLeftPt, bottomRightPt) {
|
|
|
1159
1159
|
*
|
|
1160
1160
|
* @see {@link cropFit}
|
|
1161
1161
|
*/
|
|
1162
|
-
function containFit(to, rect) {
|
|
1162
|
+
function containFit$1(to, rect) {
|
|
1163
1163
|
var scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
1164
1164
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1165
|
-
var position = subtract(center$
|
|
1165
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1166
1166
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1167
1167
|
}
|
|
1168
1168
|
/**
|
|
@@ -1173,10 +1173,10 @@ function containFit(to, rect) {
|
|
|
1173
1173
|
*
|
|
1174
1174
|
* @see {@link containFit}
|
|
1175
1175
|
*/
|
|
1176
|
-
function cropFit(to, rect) {
|
|
1176
|
+
function cropFit$1(to, rect) {
|
|
1177
1177
|
var scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
1178
1178
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1179
|
-
var position = subtract(center$
|
|
1179
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1180
1180
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1181
1181
|
}
|
|
1182
1182
|
/**
|
|
@@ -1187,10 +1187,10 @@ function cropFit(to, rect) {
|
|
|
1187
1187
|
* @param to - the maximum area this rectangle can have
|
|
1188
1188
|
* @param rect - the rectangle to scale to fit the specified area
|
|
1189
1189
|
*/
|
|
1190
|
-
function scaleFit(to, rect) {
|
|
1191
|
-
var scale = Math.min(Math.sqrt(to / area(rect)), 1);
|
|
1190
|
+
function scaleFit$1(to, rect) {
|
|
1191
|
+
var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
|
|
1192
1192
|
var dimensions$1 = floor(proportionalScale(scale, rect));
|
|
1193
|
-
var position = subtract(center$
|
|
1193
|
+
var position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
1194
1194
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1195
1195
|
}
|
|
1196
1196
|
/**
|
|
@@ -1204,52 +1204,52 @@ function scaleFit(to, rect) {
|
|
|
1204
1204
|
* @param scaleY The vertical scale factor.
|
|
1205
1205
|
* @returns A scaled rectangle.
|
|
1206
1206
|
*/
|
|
1207
|
-
function scale$
|
|
1207
|
+
function scale$1(rect, scaleOrScaleX, scaleY) {
|
|
1208
1208
|
if (scaleY == null) {
|
|
1209
|
-
return scale$
|
|
1209
|
+
return scale$1(rect, scaleOrScaleX, scaleOrScaleX);
|
|
1210
1210
|
}
|
|
1211
1211
|
else {
|
|
1212
1212
|
var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
|
|
1213
1213
|
var scaleX = scaleOrScaleX;
|
|
1214
|
-
return create$
|
|
1214
|
+
return create$8(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
1217
|
/**
|
|
1218
1218
|
* Returns true if two rectangles are equal in position and size.
|
|
1219
1219
|
*/
|
|
1220
|
-
function isEqual$
|
|
1221
|
-
return isEqual(a, b) && isEqual
|
|
1220
|
+
function isEqual$1(a, b) {
|
|
1221
|
+
return isEqual$3(a, b) && isEqual(a, b);
|
|
1222
1222
|
}
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Returns a rectangle that has its position shifted by a given offset. The
|
|
1225
1225
|
* size of the rectangle is unchanged.
|
|
1226
1226
|
*/
|
|
1227
1227
|
function offset(delta, rect) {
|
|
1228
|
-
return fromPointAndDimensions(add(topLeft(rect), delta), rect);
|
|
1228
|
+
return fromPointAndDimensions(add$1(topLeft(rect), delta), rect);
|
|
1229
1229
|
}
|
|
1230
1230
|
/**
|
|
1231
1231
|
* Returns the area of the rectangle.
|
|
1232
1232
|
*/
|
|
1233
|
-
function area(rect) {
|
|
1233
|
+
function area$1(rect) {
|
|
1234
1234
|
return rect.width * rect.height;
|
|
1235
1235
|
}
|
|
1236
1236
|
/**
|
|
1237
1237
|
* Returns the center point of the rectangle.
|
|
1238
1238
|
*/
|
|
1239
|
-
function center$
|
|
1239
|
+
function center$2(rect) {
|
|
1240
1240
|
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
1241
1241
|
}
|
|
1242
1242
|
/**
|
|
1243
1243
|
* Returns the top-left position of the rectangle, as a point.
|
|
1244
1244
|
*/
|
|
1245
1245
|
function topLeft(rect) {
|
|
1246
|
-
return create(rect.x, rect.y);
|
|
1246
|
+
return create$b(rect.x, rect.y);
|
|
1247
1247
|
}
|
|
1248
1248
|
/**
|
|
1249
1249
|
* Returns the bottom-right position of the rectangle, as a point.
|
|
1250
1250
|
*/
|
|
1251
1251
|
function bottomRight(rect) {
|
|
1252
|
-
return create(rect.x + rect.width, rect.y + rect.height);
|
|
1252
|
+
return create$b(rect.x + rect.width, rect.y + rect.height);
|
|
1253
1253
|
}
|
|
1254
1254
|
/**
|
|
1255
1255
|
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
@@ -1276,7 +1276,7 @@ function isSquare(rect) {
|
|
|
1276
1276
|
* @param padding The padding to add.
|
|
1277
1277
|
*/
|
|
1278
1278
|
function pad(rect, padding) {
|
|
1279
|
-
return create$
|
|
1279
|
+
return create$8(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
|
|
1280
1280
|
}
|
|
1281
1281
|
/**
|
|
1282
1282
|
* Parses a JSON string representation of a Rectangle and returns an object.
|
|
@@ -1288,28 +1288,28 @@ function fromJson$2(json) {
|
|
|
1288
1288
|
var obj = JSON.parse(json);
|
|
1289
1289
|
if (Array.isArray(obj)) {
|
|
1290
1290
|
var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
|
|
1291
|
-
return create$
|
|
1291
|
+
return create$8(x, y, width, height);
|
|
1292
1292
|
}
|
|
1293
1293
|
else {
|
|
1294
1294
|
var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
|
|
1295
|
-
return create$
|
|
1295
|
+
return create$8(x, y, width, height);
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
var rectangle = /*#__PURE__*/Object.freeze({
|
|
1300
1300
|
__proto__: null,
|
|
1301
|
-
create: create$
|
|
1301
|
+
create: create$8,
|
|
1302
1302
|
fromDimensions: fromDimensions,
|
|
1303
1303
|
fromPointAndDimensions: fromPointAndDimensions,
|
|
1304
|
-
fromPoints: fromPoints
|
|
1305
|
-
containFit: containFit,
|
|
1306
|
-
cropFit: cropFit,
|
|
1307
|
-
scaleFit: scaleFit,
|
|
1308
|
-
scale: scale$
|
|
1309
|
-
isEqual: isEqual$
|
|
1304
|
+
fromPoints: fromPoints,
|
|
1305
|
+
containFit: containFit$1,
|
|
1306
|
+
cropFit: cropFit$1,
|
|
1307
|
+
scaleFit: scaleFit$1,
|
|
1308
|
+
scale: scale$1,
|
|
1309
|
+
isEqual: isEqual$1,
|
|
1310
1310
|
offset: offset,
|
|
1311
|
-
area: area,
|
|
1312
|
-
center: center$
|
|
1311
|
+
area: area$1,
|
|
1312
|
+
center: center$2,
|
|
1313
1313
|
topLeft: topLeft,
|
|
1314
1314
|
bottomRight: bottomRight,
|
|
1315
1315
|
isPortrait: isPortrait,
|
|
@@ -1323,27 +1323,27 @@ var rectangle = /*#__PURE__*/Object.freeze({
|
|
|
1323
1323
|
* Returns a `Dimensions` with the given width and height.
|
|
1324
1324
|
*
|
|
1325
1325
|
*/
|
|
1326
|
-
var create$
|
|
1326
|
+
var create$7 = function (width, height) {
|
|
1327
1327
|
return { width: width, height: height };
|
|
1328
1328
|
};
|
|
1329
1329
|
/**
|
|
1330
1330
|
* Returns a `Dimensions` with the same width and height.
|
|
1331
1331
|
*/
|
|
1332
1332
|
var square = function (size) {
|
|
1333
|
-
return create$
|
|
1333
|
+
return create$7(size, size);
|
|
1334
1334
|
};
|
|
1335
1335
|
/**
|
|
1336
1336
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
1337
1337
|
* `false`.
|
|
1338
1338
|
*/
|
|
1339
|
-
var isEqual
|
|
1339
|
+
var isEqual = function (a, b) {
|
|
1340
1340
|
return a.width === b.width && a.height === b.height;
|
|
1341
1341
|
};
|
|
1342
1342
|
/**
|
|
1343
1343
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
1344
1344
|
* is scaled by `scaleY`.
|
|
1345
1345
|
*/
|
|
1346
|
-
var scale
|
|
1346
|
+
var scale = function (scaleX, scaleY, dimensions) {
|
|
1347
1347
|
return {
|
|
1348
1348
|
width: dimensions.width * scaleX,
|
|
1349
1349
|
height: dimensions.height * scaleY,
|
|
@@ -1353,7 +1353,7 @@ var scale$4 = function (scaleX, scaleY, dimensions) {
|
|
|
1353
1353
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
1354
1354
|
*/
|
|
1355
1355
|
var proportionalScale = function (scaleFactor, dimensions) {
|
|
1356
|
-
return scale
|
|
1356
|
+
return scale(scaleFactor, scaleFactor, dimensions);
|
|
1357
1357
|
};
|
|
1358
1358
|
/**
|
|
1359
1359
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
@@ -1372,8 +1372,8 @@ var trim = function (to, dimensions) {
|
|
|
1372
1372
|
*
|
|
1373
1373
|
* @see #cropFit()
|
|
1374
1374
|
*/
|
|
1375
|
-
var containFit
|
|
1376
|
-
var _a = containFit(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1375
|
+
var containFit = function (to, dimensions) {
|
|
1376
|
+
var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1377
1377
|
return { width: width, height: height };
|
|
1378
1378
|
};
|
|
1379
1379
|
/**
|
|
@@ -1383,8 +1383,8 @@ var containFit$1 = function (to, dimensions) {
|
|
|
1383
1383
|
*
|
|
1384
1384
|
* @see #containFit()
|
|
1385
1385
|
*/
|
|
1386
|
-
var cropFit
|
|
1387
|
-
var _a = cropFit(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1386
|
+
var cropFit = function (to, dimensions) {
|
|
1387
|
+
var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1388
1388
|
return { width: width, height: height };
|
|
1389
1389
|
};
|
|
1390
1390
|
/**
|
|
@@ -1395,8 +1395,8 @@ var cropFit$1 = function (to, dimensions) {
|
|
|
1395
1395
|
* @param to - the maximum area this dimensions can have
|
|
1396
1396
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
1397
1397
|
*/
|
|
1398
|
-
var scaleFit
|
|
1399
|
-
var _a = scaleFit(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1398
|
+
var scaleFit = function (to, dimensions) {
|
|
1399
|
+
var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
|
|
1400
1400
|
return { width: width, height: height };
|
|
1401
1401
|
};
|
|
1402
1402
|
/**
|
|
@@ -1420,7 +1420,7 @@ var floor = function (dimensions) {
|
|
|
1420
1420
|
/**
|
|
1421
1421
|
* Returns the center point of the given `dimensions`.
|
|
1422
1422
|
*/
|
|
1423
|
-
var center$
|
|
1423
|
+
var center$1 = function (dimensions) {
|
|
1424
1424
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
1425
1425
|
};
|
|
1426
1426
|
/**
|
|
@@ -1434,7 +1434,7 @@ var aspectRatio = function (_a) {
|
|
|
1434
1434
|
/**
|
|
1435
1435
|
* Returns the area of the given `dimensions`.
|
|
1436
1436
|
*/
|
|
1437
|
-
var area
|
|
1437
|
+
var area = function (_a) {
|
|
1438
1438
|
var width = _a.width, height = _a.height;
|
|
1439
1439
|
return width * height;
|
|
1440
1440
|
};
|
|
@@ -1446,34 +1446,34 @@ var area$1 = function (_a) {
|
|
|
1446
1446
|
*/
|
|
1447
1447
|
var fitToRatio = function (ratio, dimensions) {
|
|
1448
1448
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
1449
|
-
return create$
|
|
1449
|
+
return create$7(dimensions.height * ratio, dimensions.height);
|
|
1450
1450
|
}
|
|
1451
|
-
return create$
|
|
1451
|
+
return create$7(dimensions.width, dimensions.width / ratio);
|
|
1452
1452
|
};
|
|
1453
1453
|
/**
|
|
1454
1454
|
* Converts a dimension to a rectangle, with an optional position.
|
|
1455
1455
|
*/
|
|
1456
1456
|
function toRectangle(dimensions, position) {
|
|
1457
|
-
if (position === void 0) { position = create(); }
|
|
1457
|
+
if (position === void 0) { position = create$b(); }
|
|
1458
1458
|
return fromPointAndDimensions(position, dimensions);
|
|
1459
1459
|
}
|
|
1460
1460
|
|
|
1461
1461
|
var dimensions = /*#__PURE__*/Object.freeze({
|
|
1462
1462
|
__proto__: null,
|
|
1463
|
-
create: create$
|
|
1463
|
+
create: create$7,
|
|
1464
1464
|
square: square,
|
|
1465
|
-
isEqual: isEqual
|
|
1466
|
-
scale: scale
|
|
1465
|
+
isEqual: isEqual,
|
|
1466
|
+
scale: scale,
|
|
1467
1467
|
proportionalScale: proportionalScale,
|
|
1468
1468
|
trim: trim,
|
|
1469
|
-
containFit: containFit
|
|
1470
|
-
cropFit: cropFit
|
|
1471
|
-
scaleFit: scaleFit
|
|
1469
|
+
containFit: containFit,
|
|
1470
|
+
cropFit: cropFit,
|
|
1471
|
+
scaleFit: scaleFit,
|
|
1472
1472
|
round: round,
|
|
1473
1473
|
floor: floor,
|
|
1474
|
-
center: center$
|
|
1474
|
+
center: center$1,
|
|
1475
1475
|
aspectRatio: aspectRatio,
|
|
1476
|
-
area: area
|
|
1476
|
+
area: area,
|
|
1477
1477
|
fitToRatio: fitToRatio,
|
|
1478
1478
|
toRectangle: toRectangle
|
|
1479
1479
|
});
|
|
@@ -1486,7 +1486,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
|
|
|
1486
1486
|
* @param value The values to populate the euler angle with.
|
|
1487
1487
|
* @returns A euler angle.
|
|
1488
1488
|
*/
|
|
1489
|
-
function create$
|
|
1489
|
+
function create$6(value) {
|
|
1490
1490
|
var _a, _b, _c, _d;
|
|
1491
1491
|
if (value === void 0) { value = {}; }
|
|
1492
1492
|
return {
|
|
@@ -1507,7 +1507,7 @@ function create$5(value) {
|
|
|
1507
1507
|
function fromDegrees(value) {
|
|
1508
1508
|
if (value === void 0) { value = {}; }
|
|
1509
1509
|
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;
|
|
1510
|
-
return create$
|
|
1510
|
+
return create$6({
|
|
1511
1511
|
x: toRadians(x),
|
|
1512
1512
|
y: toRadians(y),
|
|
1513
1513
|
z: toRadians(z),
|
|
@@ -1601,7 +1601,7 @@ function fromRotationMatrix(matrix, order) {
|
|
|
1601
1601
|
* @param json A JSON object.
|
|
1602
1602
|
* @returns A euler angle.
|
|
1603
1603
|
*/
|
|
1604
|
-
function fromJson$
|
|
1604
|
+
function fromJson$1(json) {
|
|
1605
1605
|
var obj = JSON.parse(json);
|
|
1606
1606
|
if (Array.isArray(obj)) {
|
|
1607
1607
|
var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
|
|
@@ -1627,10 +1627,10 @@ function isType$1(obj) {
|
|
|
1627
1627
|
|
|
1628
1628
|
var euler = /*#__PURE__*/Object.freeze({
|
|
1629
1629
|
__proto__: null,
|
|
1630
|
-
create: create$
|
|
1630
|
+
create: create$6,
|
|
1631
1631
|
fromDegrees: fromDegrees,
|
|
1632
1632
|
fromRotationMatrix: fromRotationMatrix,
|
|
1633
|
-
fromJson: fromJson$
|
|
1633
|
+
fromJson: fromJson$1,
|
|
1634
1634
|
isType: isType$1
|
|
1635
1635
|
});
|
|
1636
1636
|
|
|
@@ -1640,7 +1640,7 @@ var euler = /*#__PURE__*/Object.freeze({
|
|
|
1640
1640
|
*
|
|
1641
1641
|
* @param values The values to assign to the line.
|
|
1642
1642
|
*/
|
|
1643
|
-
function create$
|
|
1643
|
+
function create$5(values) {
|
|
1644
1644
|
var _a, _b;
|
|
1645
1645
|
if (values === void 0) { values = {}; }
|
|
1646
1646
|
return {
|
|
@@ -1651,8 +1651,8 @@ function create$6(values) {
|
|
|
1651
1651
|
/**
|
|
1652
1652
|
* Returns the point that is halfway between start and end.
|
|
1653
1653
|
*/
|
|
1654
|
-
function center
|
|
1655
|
-
return lerp
|
|
1654
|
+
function center(line) {
|
|
1655
|
+
return lerp(line.start, line.end, 0.5);
|
|
1656
1656
|
}
|
|
1657
1657
|
/**
|
|
1658
1658
|
* Returns a line where the start and end points are transformed with the given
|
|
@@ -1662,45 +1662,45 @@ function center$3(line) {
|
|
|
1662
1662
|
* @param matrix The matrix to apply.
|
|
1663
1663
|
* @returns A transformed line.
|
|
1664
1664
|
*/
|
|
1665
|
-
function transformMatrix
|
|
1666
|
-
var start = transformMatrix(line.start, matrix);
|
|
1667
|
-
var end = transformMatrix(line.end, matrix);
|
|
1665
|
+
function transformMatrix(line, matrix) {
|
|
1666
|
+
var start = transformMatrix$1(line.start, matrix);
|
|
1667
|
+
var end = transformMatrix$1(line.end, matrix);
|
|
1668
1668
|
return { start: start, end: end };
|
|
1669
1669
|
}
|
|
1670
1670
|
/**
|
|
1671
1671
|
* Euclidean distance between the start and end points of the line.
|
|
1672
1672
|
*/
|
|
1673
|
-
function distance
|
|
1673
|
+
function distance(line) {
|
|
1674
1674
|
return distance$1(line.start, line.end);
|
|
1675
1675
|
}
|
|
1676
1676
|
/**
|
|
1677
1677
|
* Returns the squared distance between a line's start and end point. If you're
|
|
1678
1678
|
* just comparing distances, this is slightly more efficient than `distanceTo`.
|
|
1679
1679
|
*/
|
|
1680
|
-
function distanceSquared
|
|
1681
|
-
return distanceSquared(line.start, line.end);
|
|
1680
|
+
function distanceSquared(line) {
|
|
1681
|
+
return distanceSquared$1(line.start, line.end);
|
|
1682
1682
|
}
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Returns a vector describing the direction of the line from start to end.
|
|
1685
1685
|
*/
|
|
1686
1686
|
function direction(line) {
|
|
1687
|
-
return subtract
|
|
1687
|
+
return subtract(line.end, line.start);
|
|
1688
1688
|
}
|
|
1689
1689
|
|
|
1690
1690
|
var line3 = /*#__PURE__*/Object.freeze({
|
|
1691
1691
|
__proto__: null,
|
|
1692
|
-
create: create$
|
|
1693
|
-
center: center
|
|
1694
|
-
transformMatrix: transformMatrix
|
|
1695
|
-
distance: distance
|
|
1696
|
-
distanceSquared: distanceSquared
|
|
1692
|
+
create: create$5,
|
|
1693
|
+
center: center,
|
|
1694
|
+
transformMatrix: transformMatrix,
|
|
1695
|
+
distance: distance,
|
|
1696
|
+
distanceSquared: distanceSquared,
|
|
1697
1697
|
direction: direction
|
|
1698
1698
|
});
|
|
1699
1699
|
|
|
1700
1700
|
/**
|
|
1701
1701
|
* Creates a new matrix. If arguments are undefined, returns an identity matrix.
|
|
1702
1702
|
*/
|
|
1703
|
-
var create$
|
|
1703
|
+
var create$4 = function (a, b, c, d, tx, ty) {
|
|
1704
1704
|
if (a === void 0) { a = 1; }
|
|
1705
1705
|
if (b === void 0) { b = 0; }
|
|
1706
1706
|
if (c === void 0) { c = 0; }
|
|
@@ -1713,7 +1713,7 @@ var create$7 = function (a, b, c, d, tx, ty) {
|
|
|
1713
1713
|
* Returns an identity matrix.
|
|
1714
1714
|
*/
|
|
1715
1715
|
var identity = function () {
|
|
1716
|
-
return create$
|
|
1716
|
+
return create$4();
|
|
1717
1717
|
};
|
|
1718
1718
|
/**
|
|
1719
1719
|
* Creates a matrix that is translated by the given `tx` and `ty` values.
|
|
@@ -1738,7 +1738,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1738
1738
|
var b = matrix.b * cos + matrix.d * sin;
|
|
1739
1739
|
var c = matrix.a * -sin + matrix.c * cos;
|
|
1740
1740
|
var d = matrix.b * -sin + matrix.d * cos;
|
|
1741
|
-
return create$
|
|
1741
|
+
return create$4(a, b, c, d, matrix.tx, matrix.ty);
|
|
1742
1742
|
};
|
|
1743
1743
|
/**
|
|
1744
1744
|
* Translates the given matrix along the horizontal and vertical axis by the
|
|
@@ -1747,7 +1747,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1747
1747
|
var translate = function (dx, dy, matrix) {
|
|
1748
1748
|
var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
|
|
1749
1749
|
var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
|
|
1750
|
-
return create$
|
|
1750
|
+
return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
|
|
1751
1751
|
};
|
|
1752
1752
|
/**
|
|
1753
1753
|
* Returns the result of applying a geometric transformation of a matrix on the
|
|
@@ -1756,12 +1756,12 @@ var translate = function (dx, dy, matrix) {
|
|
|
1756
1756
|
var transformPoint = function (matrix, pt) {
|
|
1757
1757
|
var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
|
|
1758
1758
|
var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
|
|
1759
|
-
return create(x, y);
|
|
1759
|
+
return create$b(x, y);
|
|
1760
1760
|
};
|
|
1761
1761
|
|
|
1762
1762
|
var matrix = /*#__PURE__*/Object.freeze({
|
|
1763
1763
|
__proto__: null,
|
|
1764
|
-
create: create$
|
|
1764
|
+
create: create$4,
|
|
1765
1765
|
identity: identity,
|
|
1766
1766
|
translation: translation,
|
|
1767
1767
|
rotation: rotation,
|
|
@@ -1770,7 +1770,7 @@ var matrix = /*#__PURE__*/Object.freeze({
|
|
|
1770
1770
|
transformPoint: transformPoint
|
|
1771
1771
|
});
|
|
1772
1772
|
|
|
1773
|
-
function create$
|
|
1773
|
+
function create$3() {
|
|
1774
1774
|
var args = [];
|
|
1775
1775
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1776
1776
|
args[_i] = arguments[_i];
|
|
@@ -1807,15 +1807,15 @@ function determinant(matrix) {
|
|
|
1807
1807
|
/**
|
|
1808
1808
|
* Returns the dot product of the two vectors represented in this matrix.
|
|
1809
1809
|
*/
|
|
1810
|
-
function dot
|
|
1810
|
+
function dot(matrix) {
|
|
1811
1811
|
return matrix.a * matrix.c + matrix.b * matrix.d;
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
1814
1814
|
var matrix2 = /*#__PURE__*/Object.freeze({
|
|
1815
1815
|
__proto__: null,
|
|
1816
|
-
create: create$
|
|
1816
|
+
create: create$3,
|
|
1817
1817
|
determinant: determinant,
|
|
1818
|
-
dot: dot
|
|
1818
|
+
dot: dot
|
|
1819
1819
|
});
|
|
1820
1820
|
|
|
1821
1821
|
/**
|
|
@@ -1824,7 +1824,7 @@ var matrix2 = /*#__PURE__*/Object.freeze({
|
|
|
1824
1824
|
* @param values Values to assign to the plane.
|
|
1825
1825
|
* @returns A new plane.
|
|
1826
1826
|
*/
|
|
1827
|
-
function create$
|
|
1827
|
+
function create$2(values) {
|
|
1828
1828
|
if (values === void 0) { values = {}; }
|
|
1829
1829
|
return tslib.__assign({ normal: origin(), constant: 0 }, values);
|
|
1830
1830
|
}
|
|
@@ -1836,7 +1836,7 @@ function create$9(values) {
|
|
|
1836
1836
|
* @returns A distance.
|
|
1837
1837
|
*/
|
|
1838
1838
|
function distanceToPoint(plane, point) {
|
|
1839
|
-
return dot(plane.normal, point) + plane.constant;
|
|
1839
|
+
return dot$1(plane.normal, point) + plane.constant;
|
|
1840
1840
|
}
|
|
1841
1841
|
/**
|
|
1842
1842
|
* Returns the point where the line intersects with this plane. If the line does
|
|
@@ -1849,7 +1849,7 @@ function distanceToPoint(plane, point) {
|
|
|
1849
1849
|
*/
|
|
1850
1850
|
function intersectLine(plane, line) {
|
|
1851
1851
|
var direction$1 = direction(line);
|
|
1852
|
-
var denominator = dot(plane.normal, direction$1);
|
|
1852
|
+
var denominator = dot$1(plane.normal, direction$1);
|
|
1853
1853
|
if (denominator === 0) {
|
|
1854
1854
|
if (distanceToPoint(plane, line.start) === 0) {
|
|
1855
1855
|
return line.start;
|
|
@@ -1858,12 +1858,12 @@ function intersectLine(plane, line) {
|
|
|
1858
1858
|
return undefined;
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
|
-
var t = -(dot(line.start, plane.normal) + plane.constant) / denominator;
|
|
1861
|
+
var t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
|
|
1862
1862
|
if (t < 0 || t > 1) {
|
|
1863
1863
|
return undefined;
|
|
1864
1864
|
}
|
|
1865
1865
|
else {
|
|
1866
|
-
return add
|
|
1866
|
+
return add(line.start, scale$2(t, direction$1));
|
|
1867
1867
|
}
|
|
1868
1868
|
}
|
|
1869
1869
|
/**
|
|
@@ -1875,12 +1875,12 @@ function intersectLine(plane, line) {
|
|
|
1875
1875
|
*/
|
|
1876
1876
|
function projectPoint(plane, point) {
|
|
1877
1877
|
var d = distanceToPoint(plane, point);
|
|
1878
|
-
return add
|
|
1878
|
+
return add(point, scale$2(-d, plane.normal));
|
|
1879
1879
|
}
|
|
1880
1880
|
|
|
1881
1881
|
var plane = /*#__PURE__*/Object.freeze({
|
|
1882
1882
|
__proto__: null,
|
|
1883
|
-
create: create$
|
|
1883
|
+
create: create$2,
|
|
1884
1884
|
distanceToPoint: distanceToPoint,
|
|
1885
1885
|
intersectLine: intersectLine,
|
|
1886
1886
|
projectPoint: projectPoint
|
|
@@ -1890,7 +1890,7 @@ var plane = /*#__PURE__*/Object.freeze({
|
|
|
1890
1890
|
* Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
|
|
1891
1891
|
* w: 1}` is returned.
|
|
1892
1892
|
*/
|
|
1893
|
-
function create$
|
|
1893
|
+
function create$1(value) {
|
|
1894
1894
|
if (value === void 0) { value = {}; }
|
|
1895
1895
|
return tslib.__assign({ x: 0, y: 0, z: 0, w: 1 }, value);
|
|
1896
1896
|
}
|
|
@@ -1900,14 +1900,14 @@ function create$a(value) {
|
|
|
1900
1900
|
* @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
|
|
1901
1901
|
* @returns A parsed `Quaternion`.
|
|
1902
1902
|
*/
|
|
1903
|
-
function fromJson
|
|
1903
|
+
function fromJson(json) {
|
|
1904
1904
|
var obj = JSON.parse(json);
|
|
1905
1905
|
if (Array.isArray(obj)) {
|
|
1906
1906
|
var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
|
|
1907
|
-
return create$
|
|
1907
|
+
return create$1({ x: x, y: y, z: z, w: w });
|
|
1908
1908
|
}
|
|
1909
1909
|
else {
|
|
1910
|
-
return create$
|
|
1910
|
+
return create$1(obj);
|
|
1911
1911
|
}
|
|
1912
1912
|
}
|
|
1913
1913
|
/**
|
|
@@ -2035,7 +2035,7 @@ function fromEuler(euler) {
|
|
|
2035
2035
|
/**
|
|
2036
2036
|
* Multiplies `a` x `b` and returns a new quaternion with the result.
|
|
2037
2037
|
*/
|
|
2038
|
-
function multiply
|
|
2038
|
+
function multiply(a, b) {
|
|
2039
2039
|
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
2040
2040
|
return {
|
|
2041
2041
|
x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,
|
|
@@ -2047,7 +2047,7 @@ function multiply$2(a, b) {
|
|
|
2047
2047
|
/**
|
|
2048
2048
|
* Type guard that checks if the given type is a Quaternion.
|
|
2049
2049
|
*/
|
|
2050
|
-
function isType
|
|
2050
|
+
function isType(obj) {
|
|
2051
2051
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2052
2052
|
var o = obj;
|
|
2053
2053
|
return (o != null &&
|
|
@@ -2059,13 +2059,13 @@ function isType$2(obj) {
|
|
|
2059
2059
|
|
|
2060
2060
|
var quaternion = /*#__PURE__*/Object.freeze({
|
|
2061
2061
|
__proto__: null,
|
|
2062
|
-
create: create$
|
|
2063
|
-
fromJson: fromJson
|
|
2062
|
+
create: create$1,
|
|
2063
|
+
fromJson: fromJson,
|
|
2064
2064
|
fromAxisAngle: fromAxisAngle,
|
|
2065
2065
|
fromMatrixRotation: fromMatrixRotation,
|
|
2066
2066
|
fromEuler: fromEuler,
|
|
2067
|
-
multiply: multiply
|
|
2068
|
-
isType: isType
|
|
2067
|
+
multiply: multiply,
|
|
2068
|
+
isType: isType
|
|
2069
2069
|
});
|
|
2070
2070
|
|
|
2071
2071
|
/**
|
|
@@ -2075,7 +2075,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
|
|
|
2075
2075
|
* @param value The values of the ray.
|
|
2076
2076
|
* @returns A new ray.
|
|
2077
2077
|
*/
|
|
2078
|
-
function create
|
|
2078
|
+
function create(value) {
|
|
2079
2079
|
var _a, _b;
|
|
2080
2080
|
if (value === void 0) { value = {}; }
|
|
2081
2081
|
return {
|
|
@@ -2091,7 +2091,7 @@ function create$b(value) {
|
|
|
2091
2091
|
* @returns A point on the ray.
|
|
2092
2092
|
*/
|
|
2093
2093
|
function at(ray, distance) {
|
|
2094
|
-
return add
|
|
2094
|
+
return add(scale$2(distance, ray.direction), ray.origin);
|
|
2095
2095
|
}
|
|
2096
2096
|
/**
|
|
2097
2097
|
* Computes the distance of the `ray`s origin to the given `plane`. Returns a
|
|
@@ -2103,13 +2103,13 @@ function at(ray, distance) {
|
|
|
2103
2103
|
* @returns The distance to the plane, or `undefined` if it cannot be computed.
|
|
2104
2104
|
*/
|
|
2105
2105
|
function distanceToPlane(ray, plane$1) {
|
|
2106
|
-
var d = dot(plane$1.normal, ray.direction);
|
|
2106
|
+
var d = dot$1(plane$1.normal, ray.direction);
|
|
2107
2107
|
if (d === 0) {
|
|
2108
2108
|
// Ray is on plane.
|
|
2109
2109
|
return distanceToPoint(plane$1, ray.origin) === 0 ? 0 : undefined;
|
|
2110
2110
|
}
|
|
2111
2111
|
else {
|
|
2112
|
-
var t = -(dot(ray.origin, plane$1.normal) + plane$1.constant) / d;
|
|
2112
|
+
var t = -(dot$1(ray.origin, plane$1.normal) + plane$1.constant) / d;
|
|
2113
2113
|
// Checks if ray intersects plane.
|
|
2114
2114
|
return t >= 0 ? t : undefined;
|
|
2115
2115
|
}
|
|
@@ -2130,7 +2130,7 @@ function intersectPlane(ray, plane) {
|
|
|
2130
2130
|
|
|
2131
2131
|
var ray = /*#__PURE__*/Object.freeze({
|
|
2132
2132
|
__proto__: null,
|
|
2133
|
-
create: create
|
|
2133
|
+
create: create,
|
|
2134
2134
|
at: at,
|
|
2135
2135
|
distanceToPlane: distanceToPlane,
|
|
2136
2136
|
intersectPlane: intersectPlane
|
|
@@ -2151,5 +2151,5 @@ exports.Ray = ray;
|
|
|
2151
2151
|
exports.Rectangle = rectangle;
|
|
2152
2152
|
exports.Vector3 = vector3;
|
|
2153
2153
|
exports.clamp = clamp;
|
|
2154
|
-
exports.lerp = lerp;
|
|
2154
|
+
exports.lerp = lerp$2;
|
|
2155
2155
|
//# sourceMappingURL=bundle.cjs.js.map
|