@vertexvis/geometry 0.10.2-canary.1 → 0.10.2-canary.13
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 +246 -200
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +246 -200
- package/dist/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.js +246 -200
- package/dist/cdn/bundle.esm.js.map +1 -1
- package/dist/cdn/bundle.esm.min.js +2 -2
- package/dist/cdn/bundle.esm.min.js.map +1 -1
- package/dist/cdn/point.d.ts +7 -0
- package/dist/cdn/rectangle.d.ts +14 -0
- package/dist/point.d.ts +7 -0
- package/dist/rectangle.d.ts +14 -0
- package/package.json +8 -8
- 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,38 +82,56 @@ 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,
|
|
103
103
|
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Parses a JSON string representation of a Point and returns an object.
|
|
107
|
+
*
|
|
108
|
+
* @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
|
|
109
|
+
* @returns A parsed Point.
|
|
110
|
+
*/
|
|
111
|
+
function fromJson$4(json) {
|
|
112
|
+
var obj = JSON.parse(json);
|
|
113
|
+
if (Array.isArray(obj)) {
|
|
114
|
+
var x = obj[0], y = obj[1];
|
|
115
|
+
return create$b(x, y);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
var x = obj.x, y = obj.y;
|
|
119
|
+
return create$b(x, y);
|
|
120
|
+
}
|
|
104
121
|
}
|
|
105
122
|
|
|
106
123
|
var point = /*#__PURE__*/Object.freeze({
|
|
107
124
|
__proto__: null,
|
|
108
|
-
create: create,
|
|
125
|
+
create: create$b,
|
|
109
126
|
polar: polar,
|
|
110
|
-
distance: distance,
|
|
111
|
-
subtract: subtract,
|
|
112
|
-
add: add,
|
|
113
|
-
isEqual: isEqual,
|
|
127
|
+
distance: distance$2,
|
|
128
|
+
subtract: subtract$1,
|
|
129
|
+
add: add$1,
|
|
130
|
+
isEqual: isEqual$3,
|
|
114
131
|
lerp: lerp$1,
|
|
115
|
-
negate: negate,
|
|
116
|
-
scale: scale
|
|
132
|
+
negate: negate$1,
|
|
133
|
+
scale: scale$4,
|
|
134
|
+
fromJson: fromJson$4
|
|
117
135
|
});
|
|
118
136
|
|
|
119
137
|
/**
|
|
@@ -123,8 +141,8 @@ var point = /*#__PURE__*/Object.freeze({
|
|
|
123
141
|
* @param b The ending point.
|
|
124
142
|
* @returns An angle in radians.
|
|
125
143
|
*/
|
|
126
|
-
function fromPoints(a, b) {
|
|
127
|
-
var delta = subtract(b, a);
|
|
144
|
+
function fromPoints$1(a, b) {
|
|
145
|
+
var delta = subtract$1(b, a);
|
|
128
146
|
var theta = Math.atan2(delta.y, delta.x);
|
|
129
147
|
return theta;
|
|
130
148
|
}
|
|
@@ -137,14 +155,14 @@ function fromPoints(a, b) {
|
|
|
137
155
|
* @deprecated Use {@link fromPoints} instead.
|
|
138
156
|
*/
|
|
139
157
|
function fromPointsInDegrees(a, b) {
|
|
140
|
-
var delta = subtract(b, a);
|
|
158
|
+
var delta = subtract$1(b, a);
|
|
141
159
|
var theta = Math.atan2(delta.y, delta.x);
|
|
142
|
-
return normalize(toDegrees(theta) - 270);
|
|
160
|
+
return normalize$1(toDegrees(theta) - 270);
|
|
143
161
|
}
|
|
144
162
|
/**
|
|
145
163
|
* Normalizes the given angle, in degrees, to a number between 0 and 359.
|
|
146
164
|
*/
|
|
147
|
-
function normalize(degrees) {
|
|
165
|
+
function normalize$1(degrees) {
|
|
148
166
|
return (degrees + 3600) % 360;
|
|
149
167
|
}
|
|
150
168
|
/**
|
|
@@ -162,9 +180,9 @@ function toRadians(degrees) {
|
|
|
162
180
|
|
|
163
181
|
var angle = /*#__PURE__*/Object.freeze({
|
|
164
182
|
__proto__: null,
|
|
165
|
-
fromPoints: fromPoints,
|
|
183
|
+
fromPoints: fromPoints$1,
|
|
166
184
|
fromPointsInDegrees: fromPointsInDegrees,
|
|
167
|
-
normalize: normalize,
|
|
185
|
+
normalize: normalize$1,
|
|
168
186
|
toDegrees: toDegrees,
|
|
169
187
|
toRadians: toRadians
|
|
170
188
|
});
|
|
@@ -292,7 +310,7 @@ function makeTRS(translation, rotation, scale) {
|
|
|
292
310
|
var t = makeTranslation(translation);
|
|
293
311
|
var r = makeRotation(rotation);
|
|
294
312
|
var s = makeScale(scale);
|
|
295
|
-
return multiply(multiply(t, r), s);
|
|
313
|
+
return multiply$2(multiply$2(t, r), s);
|
|
296
314
|
}
|
|
297
315
|
/**
|
|
298
316
|
* Returns a matrix that has the basis components (upper left 3x3 matrix) set to
|
|
@@ -425,12 +443,12 @@ function makePerspective(near, far, fovY, aspect) {
|
|
|
425
443
|
* @returns A matrix.
|
|
426
444
|
*/
|
|
427
445
|
function makeLookAtView(position, lookAt, up) {
|
|
428
|
-
var z = normalize
|
|
429
|
-
var x = normalize
|
|
446
|
+
var z = normalize(subtract(position, lookAt));
|
|
447
|
+
var x = normalize(cross(up, z));
|
|
430
448
|
var y = cross(z, x);
|
|
431
|
-
var dotX = -dot(x, position);
|
|
432
|
-
var dotY = -dot(y, position);
|
|
433
|
-
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);
|
|
434
452
|
/* eslint-disable prettier/prettier */
|
|
435
453
|
return [
|
|
436
454
|
x.x, y.x, z.x, 0,
|
|
@@ -454,8 +472,8 @@ function makeLookAtView(position, lookAt, up) {
|
|
|
454
472
|
* @returns A matrix.
|
|
455
473
|
*/
|
|
456
474
|
function makeLookAt(position, lookAt, up) {
|
|
457
|
-
var z = normalize
|
|
458
|
-
var x = normalize
|
|
475
|
+
var z = normalize(subtract(position, lookAt));
|
|
476
|
+
var x = normalize(cross(up, z));
|
|
459
477
|
var y = cross(z, x);
|
|
460
478
|
/* eslint-disable prettier/prettier */
|
|
461
479
|
return [
|
|
@@ -523,11 +541,11 @@ function invert(matrix) {
|
|
|
523
541
|
* @returns A rotation matrix.
|
|
524
542
|
*/
|
|
525
543
|
function lookAt(m, position, target, up) {
|
|
526
|
-
var z = subtract
|
|
544
|
+
var z = subtract(position, target);
|
|
527
545
|
if (magnitudeSquared(z) === 0) {
|
|
528
546
|
z = tslib.__assign(tslib.__assign({}, z), { z: 1 });
|
|
529
547
|
}
|
|
530
|
-
z = normalize
|
|
548
|
+
z = normalize(z);
|
|
531
549
|
var x = cross(up, z);
|
|
532
550
|
if (magnitudeSquared(x) === 0) {
|
|
533
551
|
if (Math.abs(up.z) === 1) {
|
|
@@ -536,10 +554,10 @@ function lookAt(m, position, target, up) {
|
|
|
536
554
|
else {
|
|
537
555
|
z = tslib.__assign(tslib.__assign({}, z), { z: z.z + 0.0001 });
|
|
538
556
|
}
|
|
539
|
-
z = normalize
|
|
557
|
+
z = normalize(z);
|
|
540
558
|
x = cross(up, z);
|
|
541
559
|
}
|
|
542
|
-
x = normalize
|
|
560
|
+
x = normalize(x);
|
|
543
561
|
var y = cross(z, x);
|
|
544
562
|
var res = tslib.__spreadArray([], m, true);
|
|
545
563
|
/* eslint-disable prettier/prettier */
|
|
@@ -558,7 +576,7 @@ function lookAt(m, position, target, up) {
|
|
|
558
576
|
/**
|
|
559
577
|
* Returns a post-multiplied matrix.
|
|
560
578
|
*/
|
|
561
|
-
function multiply(a, b) {
|
|
579
|
+
function multiply$2(a, b) {
|
|
562
580
|
var ae = a;
|
|
563
581
|
var be = b;
|
|
564
582
|
var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
|
|
@@ -605,7 +623,7 @@ function transpose(matrix) {
|
|
|
605
623
|
/**
|
|
606
624
|
* Multiplies the columns of a matrix by the given vector.
|
|
607
625
|
*/
|
|
608
|
-
function scale$
|
|
626
|
+
function scale$3(matrix, scale) {
|
|
609
627
|
var x = scale.x, y = scale.y, z = scale.z;
|
|
610
628
|
var m = tslib.__spreadArray([], matrix, true);
|
|
611
629
|
/* eslint-disable prettier/prettier */
|
|
@@ -647,7 +665,7 @@ function toObject(m) {
|
|
|
647
665
|
/**
|
|
648
666
|
* A type guard to check if `obj` is of type `Matrix4`.
|
|
649
667
|
*/
|
|
650
|
-
function isType(obj) {
|
|
668
|
+
function isType$2(obj) {
|
|
651
669
|
return Array.isArray(obj) && obj.length === 16;
|
|
652
670
|
}
|
|
653
671
|
|
|
@@ -669,15 +687,15 @@ var matrix4 = /*#__PURE__*/Object.freeze({
|
|
|
669
687
|
makeLookAt: makeLookAt,
|
|
670
688
|
invert: invert,
|
|
671
689
|
lookAt: lookAt,
|
|
672
|
-
multiply: multiply,
|
|
690
|
+
multiply: multiply$2,
|
|
673
691
|
transpose: transpose,
|
|
674
|
-
scale: scale$
|
|
692
|
+
scale: scale$3,
|
|
675
693
|
position: position,
|
|
676
694
|
toObject: toObject,
|
|
677
|
-
isType: isType
|
|
695
|
+
isType: isType$2
|
|
678
696
|
});
|
|
679
697
|
|
|
680
|
-
function create$
|
|
698
|
+
function create$a() {
|
|
681
699
|
var _a, _b, _c, _d, _e, _f;
|
|
682
700
|
var args = [];
|
|
683
701
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -737,15 +755,15 @@ function fromMatrixPosition(matrix) {
|
|
|
737
755
|
* @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
|
|
738
756
|
* @returns A parsed Vector3.
|
|
739
757
|
*/
|
|
740
|
-
function fromJson(json) {
|
|
758
|
+
function fromJson$3(json) {
|
|
741
759
|
var obj = JSON.parse(json);
|
|
742
760
|
if (Array.isArray(obj)) {
|
|
743
761
|
var x = obj[0], y = obj[1], z = obj[2];
|
|
744
|
-
return create$
|
|
762
|
+
return create$a(x, y, z);
|
|
745
763
|
}
|
|
746
764
|
else {
|
|
747
765
|
var x = obj.x, y = obj.y, z = obj.z;
|
|
748
|
-
return create$
|
|
766
|
+
return create$a(x, y, z);
|
|
749
767
|
}
|
|
750
768
|
}
|
|
751
769
|
/**
|
|
@@ -760,7 +778,7 @@ function fromArray(nums, offset) {
|
|
|
760
778
|
var x = nums[offset];
|
|
761
779
|
var y = nums[offset + 1];
|
|
762
780
|
var z = nums[offset + 2];
|
|
763
|
-
return create$
|
|
781
|
+
return create$a(x, y, z);
|
|
764
782
|
}
|
|
765
783
|
/**
|
|
766
784
|
* Converts a Vector3 to an array where the values of the vector will be
|
|
@@ -777,48 +795,48 @@ function toArray(_a) {
|
|
|
777
795
|
* Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
|
|
778
796
|
*/
|
|
779
797
|
function right() {
|
|
780
|
-
return create$
|
|
798
|
+
return create$a(1, 0, 0);
|
|
781
799
|
}
|
|
782
800
|
/**
|
|
783
801
|
* Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
|
|
784
802
|
*/
|
|
785
803
|
function up() {
|
|
786
|
-
return create$
|
|
804
|
+
return create$a(0, 1, 0);
|
|
787
805
|
}
|
|
788
806
|
/**
|
|
789
807
|
* Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
|
|
790
808
|
*/
|
|
791
809
|
function forward() {
|
|
792
|
-
return create$
|
|
810
|
+
return create$a(0, 0, -1);
|
|
793
811
|
}
|
|
794
812
|
/**
|
|
795
813
|
* Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
|
|
796
814
|
*/
|
|
797
815
|
function left() {
|
|
798
|
-
return create$
|
|
816
|
+
return create$a(-1, 0, 0);
|
|
799
817
|
}
|
|
800
818
|
/**
|
|
801
819
|
* Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
|
|
802
820
|
*/
|
|
803
821
|
function down() {
|
|
804
|
-
return create$
|
|
822
|
+
return create$a(0, -1, 0);
|
|
805
823
|
}
|
|
806
824
|
/**
|
|
807
825
|
* Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
|
|
808
826
|
*/
|
|
809
827
|
function back() {
|
|
810
|
-
return create$
|
|
828
|
+
return create$a(0, 0, 1);
|
|
811
829
|
}
|
|
812
830
|
/**
|
|
813
831
|
* Returns a vector at the origin, Vector3(0, 0, 0).
|
|
814
832
|
*/
|
|
815
833
|
function origin() {
|
|
816
|
-
return create$
|
|
834
|
+
return create$a(0, 0, 0);
|
|
817
835
|
}
|
|
818
836
|
/**
|
|
819
837
|
* Returns a vector with that will have a magnitude of 1.
|
|
820
838
|
*/
|
|
821
|
-
function normalize
|
|
839
|
+
function normalize(vector) {
|
|
822
840
|
var length = magnitude(vector);
|
|
823
841
|
return { x: vector.x / length, y: vector.y / length, z: vector.z / length };
|
|
824
842
|
}
|
|
@@ -856,7 +874,7 @@ function cross(a, b) {
|
|
|
856
874
|
/**
|
|
857
875
|
* Returns a vector that is the sum of two vectors.
|
|
858
876
|
*/
|
|
859
|
-
function add
|
|
877
|
+
function add(a) {
|
|
860
878
|
var vectors = [];
|
|
861
879
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
862
880
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -868,7 +886,7 @@ function add$1(a) {
|
|
|
868
886
|
/**
|
|
869
887
|
* Returns a vector that is the difference between two vectors.
|
|
870
888
|
*/
|
|
871
|
-
function subtract
|
|
889
|
+
function subtract(a) {
|
|
872
890
|
var vectors = [];
|
|
873
891
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
874
892
|
vectors[_i - 1] = arguments[_i];
|
|
@@ -896,7 +914,7 @@ function scale$2(scalar, vector) {
|
|
|
896
914
|
* multiplied together and then multiplied by the cosine of the angle between
|
|
897
915
|
* them.
|
|
898
916
|
*/
|
|
899
|
-
function dot(a, b) {
|
|
917
|
+
function dot$1(a, b) {
|
|
900
918
|
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
901
919
|
}
|
|
902
920
|
/**
|
|
@@ -907,7 +925,7 @@ function dot(a, b) {
|
|
|
907
925
|
* result is never greater than 180 degrees.
|
|
908
926
|
*/
|
|
909
927
|
function angleTo(a, b) {
|
|
910
|
-
var theta = dot(a, b) / (magnitude(a) * magnitude(b));
|
|
928
|
+
var theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
|
|
911
929
|
// Clamp to avoid numerical problems.
|
|
912
930
|
return Math.acos(theta);
|
|
913
931
|
}
|
|
@@ -927,7 +945,7 @@ function angleTo(a, b) {
|
|
|
927
945
|
* ```
|
|
928
946
|
*/
|
|
929
947
|
function project(vector, onNormal) {
|
|
930
|
-
return scale$2(dot(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
948
|
+
return scale$2(dot$1(onNormal, vector) / magnitude(onNormal), onNormal);
|
|
931
949
|
}
|
|
932
950
|
/**
|
|
933
951
|
* Returns a vector that is rotated about an origin point.
|
|
@@ -963,7 +981,7 @@ function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
|
|
|
963
981
|
/**
|
|
964
982
|
* Returns a vector that is multiplied with a matrix.
|
|
965
983
|
*/
|
|
966
|
-
function transformMatrix(vector, m) {
|
|
984
|
+
function transformMatrix$1(vector, m) {
|
|
967
985
|
var x = vector.x, y = vector.y, z = vector.z;
|
|
968
986
|
var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
|
|
969
987
|
return {
|
|
@@ -976,38 +994,38 @@ function transformMatrix(vector, m) {
|
|
|
976
994
|
* Euclidean distance between two vectors
|
|
977
995
|
*/
|
|
978
996
|
function distance$1(a, b) {
|
|
979
|
-
return Math.sqrt(distanceSquared(a, b));
|
|
997
|
+
return Math.sqrt(distanceSquared$1(a, b));
|
|
980
998
|
}
|
|
981
999
|
/**
|
|
982
1000
|
* Returns the squared distance between two vectors. If you're just comparing
|
|
983
1001
|
* distances, this is slightly more efficient than `distanceTo`.
|
|
984
1002
|
*/
|
|
985
|
-
function distanceSquared(a, b) {
|
|
986
|
-
var _a = subtract
|
|
1003
|
+
function distanceSquared$1(a, b) {
|
|
1004
|
+
var _a = subtract(a, b), dx = _a.x, dy = _a.y, dz = _a.z;
|
|
987
1005
|
return dx * dx + dy * dy + dz * dz;
|
|
988
1006
|
}
|
|
989
1007
|
/**
|
|
990
1008
|
* Returns `true` if two vectors have the same values.
|
|
991
1009
|
*/
|
|
992
|
-
function isEqual$
|
|
1010
|
+
function isEqual$2(a, b) {
|
|
993
1011
|
return a.x === b.x && a.y === b.y && a.z === b.z;
|
|
994
1012
|
}
|
|
995
1013
|
/**
|
|
996
1014
|
* Returns a vector that contains the largest components of `a` and `b`.
|
|
997
1015
|
*/
|
|
998
1016
|
function max(a, b) {
|
|
999
|
-
return create$
|
|
1017
|
+
return create$a(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
|
|
1000
1018
|
}
|
|
1001
1019
|
/**
|
|
1002
1020
|
* Returns a vector that contains the smallest components of `a` and `b`.
|
|
1003
1021
|
*/
|
|
1004
1022
|
function min(a, b) {
|
|
1005
|
-
return create$
|
|
1023
|
+
return create$a(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
|
|
1006
1024
|
}
|
|
1007
1025
|
/**
|
|
1008
1026
|
* Returns a vector that each of its component negated.
|
|
1009
1027
|
*/
|
|
1010
|
-
function negate
|
|
1028
|
+
function negate(vector) {
|
|
1011
1029
|
return { x: -vector.x, y: -vector.y, z: -vector.z };
|
|
1012
1030
|
}
|
|
1013
1031
|
/**
|
|
@@ -1019,21 +1037,21 @@ function negate$1(vector) {
|
|
|
1019
1037
|
* @param t A value between 0 and 1.
|
|
1020
1038
|
* @returns A point between `a` and `b`.
|
|
1021
1039
|
*/
|
|
1022
|
-
function lerp
|
|
1040
|
+
function lerp(a, b, t) {
|
|
1023
1041
|
return {
|
|
1024
|
-
x: lerp(a.x, b.x, t),
|
|
1025
|
-
y: lerp(a.y, b.y, t),
|
|
1026
|
-
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),
|
|
1027
1045
|
};
|
|
1028
1046
|
}
|
|
1029
1047
|
|
|
1030
1048
|
var vector3 = /*#__PURE__*/Object.freeze({
|
|
1031
1049
|
__proto__: null,
|
|
1032
|
-
create: create$
|
|
1050
|
+
create: create$a,
|
|
1033
1051
|
isValid: isValid,
|
|
1034
1052
|
fromMatrixScale: fromMatrixScale,
|
|
1035
1053
|
fromMatrixPosition: fromMatrixPosition,
|
|
1036
|
-
fromJson: fromJson,
|
|
1054
|
+
fromJson: fromJson$3,
|
|
1037
1055
|
fromArray: fromArray,
|
|
1038
1056
|
toArray: toArray,
|
|
1039
1057
|
right: right,
|
|
@@ -1043,32 +1061,32 @@ var vector3 = /*#__PURE__*/Object.freeze({
|
|
|
1043
1061
|
down: down,
|
|
1044
1062
|
back: back,
|
|
1045
1063
|
origin: origin,
|
|
1046
|
-
normalize: normalize
|
|
1064
|
+
normalize: normalize,
|
|
1047
1065
|
magnitude: magnitude,
|
|
1048
1066
|
magnitudeSquared: magnitudeSquared,
|
|
1049
1067
|
cross: cross,
|
|
1050
|
-
add: add
|
|
1051
|
-
subtract: subtract
|
|
1068
|
+
add: add,
|
|
1069
|
+
subtract: subtract,
|
|
1052
1070
|
multiply: multiply$1,
|
|
1053
1071
|
scale: scale$2,
|
|
1054
|
-
dot: dot,
|
|
1072
|
+
dot: dot$1,
|
|
1055
1073
|
angleTo: angleTo,
|
|
1056
1074
|
project: project,
|
|
1057
1075
|
rotateAboutAxis: rotateAboutAxis,
|
|
1058
|
-
transformMatrix: transformMatrix,
|
|
1076
|
+
transformMatrix: transformMatrix$1,
|
|
1059
1077
|
distance: distance$1,
|
|
1060
|
-
distanceSquared: distanceSquared,
|
|
1061
|
-
isEqual: isEqual$
|
|
1078
|
+
distanceSquared: distanceSquared$1,
|
|
1079
|
+
isEqual: isEqual$2,
|
|
1062
1080
|
max: max,
|
|
1063
1081
|
min: min,
|
|
1064
|
-
negate: negate
|
|
1065
|
-
lerp: lerp
|
|
1082
|
+
negate: negate,
|
|
1083
|
+
lerp: lerp
|
|
1066
1084
|
});
|
|
1067
1085
|
|
|
1068
1086
|
/**
|
|
1069
1087
|
* Returns a `BoundingBox` with the given min and max points.
|
|
1070
1088
|
*/
|
|
1071
|
-
var create$
|
|
1089
|
+
var create$9 = function (min, max) {
|
|
1072
1090
|
return { min: min, max: max };
|
|
1073
1091
|
};
|
|
1074
1092
|
/**
|
|
@@ -1076,13 +1094,13 @@ var create$2 = function (min, max) {
|
|
|
1076
1094
|
* are contained by the bounding box.
|
|
1077
1095
|
*/
|
|
1078
1096
|
var fromVectors = function (vectors) {
|
|
1079
|
-
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); }));
|
|
1080
1098
|
};
|
|
1081
1099
|
/**
|
|
1082
1100
|
* Returns the center point of the given `BoundingBox`.
|
|
1083
1101
|
*/
|
|
1084
|
-
var center = function (boundingBox) {
|
|
1085
|
-
return scale$2(0.5, add
|
|
1102
|
+
var center$3 = function (boundingBox) {
|
|
1103
|
+
return scale$2(0.5, add(boundingBox.min, boundingBox.max));
|
|
1086
1104
|
};
|
|
1087
1105
|
function union(box) {
|
|
1088
1106
|
var rest = [];
|
|
@@ -1091,47 +1109,47 @@ function union(box) {
|
|
|
1091
1109
|
}
|
|
1092
1110
|
var boxes = tslib.__spreadArray([box], rest, true);
|
|
1093
1111
|
return boxes.reduce(function (a, b) {
|
|
1094
|
-
return create$
|
|
1112
|
+
return create$9(min(a.min, b.min), max(a.max, b.max));
|
|
1095
1113
|
});
|
|
1096
1114
|
}
|
|
1097
1115
|
/* eslint-enable padding-line-between-statements */
|
|
1098
1116
|
|
|
1099
1117
|
var boundingBox = /*#__PURE__*/Object.freeze({
|
|
1100
1118
|
__proto__: null,
|
|
1101
|
-
create: create$
|
|
1119
|
+
create: create$9,
|
|
1102
1120
|
fromVectors: fromVectors,
|
|
1103
|
-
center: center,
|
|
1121
|
+
center: center$3,
|
|
1104
1122
|
union: union
|
|
1105
1123
|
});
|
|
1106
1124
|
|
|
1107
1125
|
/**
|
|
1108
1126
|
* Returns a new `Rectangle` with the given position and size.
|
|
1109
1127
|
*/
|
|
1110
|
-
function create$
|
|
1128
|
+
function create$8(x, y, width, height) {
|
|
1111
1129
|
return { x: x, y: y, width: width, height: height };
|
|
1112
1130
|
}
|
|
1113
1131
|
/**
|
|
1114
1132
|
* Returns a new `Rectangle` at the origin point and given size.
|
|
1115
1133
|
*/
|
|
1116
1134
|
function fromDimensions(dimensions) {
|
|
1117
|
-
return create$
|
|
1135
|
+
return create$8(0, 0, dimensions.width, dimensions.height);
|
|
1118
1136
|
}
|
|
1119
1137
|
/**
|
|
1120
1138
|
* Returns a new `Rectangle` with the given position and size.
|
|
1121
1139
|
*/
|
|
1122
1140
|
function fromPointAndDimensions(point, dimensions) {
|
|
1123
|
-
return create$
|
|
1141
|
+
return create$8(point.x, point.y, dimensions.width, dimensions.height);
|
|
1124
1142
|
}
|
|
1125
1143
|
/**
|
|
1126
1144
|
* Returns a new `Rectangle` with the given top-left and bottom-right positions.
|
|
1127
1145
|
* The returned rectangle will always returns a positive width and height.
|
|
1128
1146
|
*/
|
|
1129
|
-
function fromPoints
|
|
1147
|
+
function fromPoints(topLeftPt, bottomRightPt) {
|
|
1130
1148
|
var minX = Math.min(topLeftPt.x, bottomRightPt.x);
|
|
1131
1149
|
var minY = Math.min(topLeftPt.y, bottomRightPt.y);
|
|
1132
1150
|
var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
|
|
1133
1151
|
var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
|
|
1134
|
-
return create$
|
|
1152
|
+
return create$8(minX, minY, maxX - minX, maxY - minY);
|
|
1135
1153
|
}
|
|
1136
1154
|
/**
|
|
1137
1155
|
* Returns a rectangle where the longest length of `rect` will be equal to the
|
|
@@ -1141,10 +1159,10 @@ function fromPoints$1(topLeftPt, bottomRightPt) {
|
|
|
1141
1159
|
*
|
|
1142
1160
|
* @see {@link cropFit}
|
|
1143
1161
|
*/
|
|
1144
|
-
function containFit(to, rect) {
|
|
1162
|
+
function containFit$1(to, rect) {
|
|
1145
1163
|
var scale = Math.min(to.width / rect.width, to.height / rect.height);
|
|
1146
1164
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1147
|
-
var position = subtract(center$
|
|
1165
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1148
1166
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1149
1167
|
}
|
|
1150
1168
|
/**
|
|
@@ -1155,10 +1173,10 @@ function containFit(to, rect) {
|
|
|
1155
1173
|
*
|
|
1156
1174
|
* @see {@link containFit}
|
|
1157
1175
|
*/
|
|
1158
|
-
function cropFit(to, rect) {
|
|
1176
|
+
function cropFit$1(to, rect) {
|
|
1159
1177
|
var scale = Math.max(to.width / rect.width, to.height / rect.height);
|
|
1160
1178
|
var dimensions$1 = proportionalScale(scale, rect);
|
|
1161
|
-
var position = subtract(center$
|
|
1179
|
+
var position = subtract$1(center$2(to), center$1(dimensions$1));
|
|
1162
1180
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1163
1181
|
}
|
|
1164
1182
|
/**
|
|
@@ -1169,10 +1187,10 @@ function cropFit(to, rect) {
|
|
|
1169
1187
|
* @param to - the maximum area this rectangle can have
|
|
1170
1188
|
* @param rect - the rectangle to scale to fit the specified area
|
|
1171
1189
|
*/
|
|
1172
|
-
function scaleFit(to, rect) {
|
|
1173
|
-
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);
|
|
1174
1192
|
var dimensions$1 = floor(proportionalScale(scale, rect));
|
|
1175
|
-
var position = subtract(center$
|
|
1193
|
+
var position = subtract$1(center$2(rect), center$1(dimensions$1));
|
|
1176
1194
|
return fromPointAndDimensions(position, dimensions$1);
|
|
1177
1195
|
}
|
|
1178
1196
|
/**
|
|
@@ -1186,52 +1204,52 @@ function scaleFit(to, rect) {
|
|
|
1186
1204
|
* @param scaleY The vertical scale factor.
|
|
1187
1205
|
* @returns A scaled rectangle.
|
|
1188
1206
|
*/
|
|
1189
|
-
function scale$
|
|
1207
|
+
function scale$1(rect, scaleOrScaleX, scaleY) {
|
|
1190
1208
|
if (scaleY == null) {
|
|
1191
|
-
return scale$
|
|
1209
|
+
return scale$1(rect, scaleOrScaleX, scaleOrScaleX);
|
|
1192
1210
|
}
|
|
1193
1211
|
else {
|
|
1194
1212
|
var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
|
|
1195
1213
|
var scaleX = scaleOrScaleX;
|
|
1196
|
-
return create$
|
|
1214
|
+
return create$8(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
|
|
1197
1215
|
}
|
|
1198
1216
|
}
|
|
1199
1217
|
/**
|
|
1200
1218
|
* Returns true if two rectangles are equal in position and size.
|
|
1201
1219
|
*/
|
|
1202
|
-
function isEqual$
|
|
1203
|
-
return isEqual(a, b) && isEqual
|
|
1220
|
+
function isEqual$1(a, b) {
|
|
1221
|
+
return isEqual$3(a, b) && isEqual(a, b);
|
|
1204
1222
|
}
|
|
1205
1223
|
/**
|
|
1206
1224
|
* Returns a rectangle that has its position shifted by a given offset. The
|
|
1207
1225
|
* size of the rectangle is unchanged.
|
|
1208
1226
|
*/
|
|
1209
1227
|
function offset(delta, rect) {
|
|
1210
|
-
return fromPointAndDimensions(add(topLeft(rect), delta), rect);
|
|
1228
|
+
return fromPointAndDimensions(add$1(topLeft(rect), delta), rect);
|
|
1211
1229
|
}
|
|
1212
1230
|
/**
|
|
1213
1231
|
* Returns the area of the rectangle.
|
|
1214
1232
|
*/
|
|
1215
|
-
function area(rect) {
|
|
1233
|
+
function area$1(rect) {
|
|
1216
1234
|
return rect.width * rect.height;
|
|
1217
1235
|
}
|
|
1218
1236
|
/**
|
|
1219
1237
|
* Returns the center point of the rectangle.
|
|
1220
1238
|
*/
|
|
1221
|
-
function center$
|
|
1239
|
+
function center$2(rect) {
|
|
1222
1240
|
return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
|
|
1223
1241
|
}
|
|
1224
1242
|
/**
|
|
1225
1243
|
* Returns the top-left position of the rectangle, as a point.
|
|
1226
1244
|
*/
|
|
1227
1245
|
function topLeft(rect) {
|
|
1228
|
-
return create(rect.x, rect.y);
|
|
1246
|
+
return create$b(rect.x, rect.y);
|
|
1229
1247
|
}
|
|
1230
1248
|
/**
|
|
1231
1249
|
* Returns the bottom-right position of the rectangle, as a point.
|
|
1232
1250
|
*/
|
|
1233
1251
|
function bottomRight(rect) {
|
|
1234
|
-
return create(rect.x + rect.width, rect.y + rect.height);
|
|
1252
|
+
return create$b(rect.x + rect.width, rect.y + rect.height);
|
|
1235
1253
|
}
|
|
1236
1254
|
/**
|
|
1237
1255
|
* Returns `true` if the given rectangle has a portrait aspect ratio.
|
|
@@ -1250,54 +1268,82 @@ function isLandscape(rect) {
|
|
|
1250
1268
|
*/
|
|
1251
1269
|
function isSquare(rect) {
|
|
1252
1270
|
return rect.width === rect.height;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Pads a rectangle by the given amount, maintaining the center position.
|
|
1274
|
+
*
|
|
1275
|
+
* @param rect The rectangle to apply padding to.
|
|
1276
|
+
* @param padding The padding to add.
|
|
1277
|
+
*/
|
|
1278
|
+
function pad(rect, padding) {
|
|
1279
|
+
return create$8(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Parses a JSON string representation of a Rectangle and returns an object.
|
|
1283
|
+
*
|
|
1284
|
+
* @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
|
|
1285
|
+
* @returns A parsed Point.
|
|
1286
|
+
*/
|
|
1287
|
+
function fromJson$2(json) {
|
|
1288
|
+
var obj = JSON.parse(json);
|
|
1289
|
+
if (Array.isArray(obj)) {
|
|
1290
|
+
var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
|
|
1291
|
+
return create$8(x, y, width, height);
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
|
|
1295
|
+
return create$8(x, y, width, height);
|
|
1296
|
+
}
|
|
1253
1297
|
}
|
|
1254
1298
|
|
|
1255
1299
|
var rectangle = /*#__PURE__*/Object.freeze({
|
|
1256
1300
|
__proto__: null,
|
|
1257
|
-
create: create$
|
|
1301
|
+
create: create$8,
|
|
1258
1302
|
fromDimensions: fromDimensions,
|
|
1259
1303
|
fromPointAndDimensions: fromPointAndDimensions,
|
|
1260
|
-
fromPoints: fromPoints
|
|
1261
|
-
containFit: containFit,
|
|
1262
|
-
cropFit: cropFit,
|
|
1263
|
-
scaleFit: scaleFit,
|
|
1264
|
-
scale: scale$
|
|
1265
|
-
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,
|
|
1266
1310
|
offset: offset,
|
|
1267
|
-
area: area,
|
|
1268
|
-
center: center$
|
|
1311
|
+
area: area$1,
|
|
1312
|
+
center: center$2,
|
|
1269
1313
|
topLeft: topLeft,
|
|
1270
1314
|
bottomRight: bottomRight,
|
|
1271
1315
|
isPortrait: isPortrait,
|
|
1272
1316
|
isLandscape: isLandscape,
|
|
1273
|
-
isSquare: isSquare
|
|
1317
|
+
isSquare: isSquare,
|
|
1318
|
+
pad: pad,
|
|
1319
|
+
fromJson: fromJson$2
|
|
1274
1320
|
});
|
|
1275
1321
|
|
|
1276
1322
|
/**
|
|
1277
1323
|
* Returns a `Dimensions` with the given width and height.
|
|
1278
1324
|
*
|
|
1279
1325
|
*/
|
|
1280
|
-
var create$
|
|
1326
|
+
var create$7 = function (width, height) {
|
|
1281
1327
|
return { width: width, height: height };
|
|
1282
1328
|
};
|
|
1283
1329
|
/**
|
|
1284
1330
|
* Returns a `Dimensions` with the same width and height.
|
|
1285
1331
|
*/
|
|
1286
1332
|
var square = function (size) {
|
|
1287
|
-
return create$
|
|
1333
|
+
return create$7(size, size);
|
|
1288
1334
|
};
|
|
1289
1335
|
/**
|
|
1290
1336
|
* Returns `true` if two dimensions have the same width and height. Otherwise
|
|
1291
1337
|
* `false`.
|
|
1292
1338
|
*/
|
|
1293
|
-
var isEqual
|
|
1339
|
+
var isEqual = function (a, b) {
|
|
1294
1340
|
return a.width === b.width && a.height === b.height;
|
|
1295
1341
|
};
|
|
1296
1342
|
/**
|
|
1297
1343
|
* Returns a scaled dimensions, where the width is scaled by `scaleX` and height
|
|
1298
1344
|
* is scaled by `scaleY`.
|
|
1299
1345
|
*/
|
|
1300
|
-
var scale
|
|
1346
|
+
var scale = function (scaleX, scaleY, dimensions) {
|
|
1301
1347
|
return {
|
|
1302
1348
|
width: dimensions.width * scaleX,
|
|
1303
1349
|
height: dimensions.height * scaleY,
|
|
@@ -1307,7 +1353,7 @@ var scale$4 = function (scaleX, scaleY, dimensions) {
|
|
|
1307
1353
|
* Returns a dimension where each length is scaled by `scaleFactor`.
|
|
1308
1354
|
*/
|
|
1309
1355
|
var proportionalScale = function (scaleFactor, dimensions) {
|
|
1310
|
-
return scale
|
|
1356
|
+
return scale(scaleFactor, scaleFactor, dimensions);
|
|
1311
1357
|
};
|
|
1312
1358
|
/**
|
|
1313
1359
|
* Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
|
|
@@ -1326,8 +1372,8 @@ var trim = function (to, dimensions) {
|
|
|
1326
1372
|
*
|
|
1327
1373
|
* @see #cropFit()
|
|
1328
1374
|
*/
|
|
1329
|
-
var containFit
|
|
1330
|
-
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;
|
|
1331
1377
|
return { width: width, height: height };
|
|
1332
1378
|
};
|
|
1333
1379
|
/**
|
|
@@ -1337,8 +1383,8 @@ var containFit$1 = function (to, dimensions) {
|
|
|
1337
1383
|
*
|
|
1338
1384
|
* @see #containFit()
|
|
1339
1385
|
*/
|
|
1340
|
-
var cropFit
|
|
1341
|
-
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;
|
|
1342
1388
|
return { width: width, height: height };
|
|
1343
1389
|
};
|
|
1344
1390
|
/**
|
|
@@ -1349,8 +1395,8 @@ var cropFit$1 = function (to, dimensions) {
|
|
|
1349
1395
|
* @param to - the maximum area this dimensions can have
|
|
1350
1396
|
* @param dimensions - the dimensions to scale to fit the specified area
|
|
1351
1397
|
*/
|
|
1352
|
-
var scaleFit
|
|
1353
|
-
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;
|
|
1354
1400
|
return { width: width, height: height };
|
|
1355
1401
|
};
|
|
1356
1402
|
/**
|
|
@@ -1374,7 +1420,7 @@ var floor = function (dimensions) {
|
|
|
1374
1420
|
/**
|
|
1375
1421
|
* Returns the center point of the given `dimensions`.
|
|
1376
1422
|
*/
|
|
1377
|
-
var center$
|
|
1423
|
+
var center$1 = function (dimensions) {
|
|
1378
1424
|
return { x: dimensions.width / 2, y: dimensions.height / 2 };
|
|
1379
1425
|
};
|
|
1380
1426
|
/**
|
|
@@ -1388,7 +1434,7 @@ var aspectRatio = function (_a) {
|
|
|
1388
1434
|
/**
|
|
1389
1435
|
* Returns the area of the given `dimensions`.
|
|
1390
1436
|
*/
|
|
1391
|
-
var area
|
|
1437
|
+
var area = function (_a) {
|
|
1392
1438
|
var width = _a.width, height = _a.height;
|
|
1393
1439
|
return width * height;
|
|
1394
1440
|
};
|
|
@@ -1400,34 +1446,34 @@ var area$1 = function (_a) {
|
|
|
1400
1446
|
*/
|
|
1401
1447
|
var fitToRatio = function (ratio, dimensions) {
|
|
1402
1448
|
if (dimensions.width >= dimensions.height * ratio) {
|
|
1403
|
-
return create$
|
|
1449
|
+
return create$7(dimensions.height * ratio, dimensions.height);
|
|
1404
1450
|
}
|
|
1405
|
-
return create$
|
|
1451
|
+
return create$7(dimensions.width, dimensions.width / ratio);
|
|
1406
1452
|
};
|
|
1407
1453
|
/**
|
|
1408
1454
|
* Converts a dimension to a rectangle, with an optional position.
|
|
1409
1455
|
*/
|
|
1410
1456
|
function toRectangle(dimensions, position) {
|
|
1411
|
-
if (position === void 0) { position = create(); }
|
|
1457
|
+
if (position === void 0) { position = create$b(); }
|
|
1412
1458
|
return fromPointAndDimensions(position, dimensions);
|
|
1413
1459
|
}
|
|
1414
1460
|
|
|
1415
1461
|
var dimensions = /*#__PURE__*/Object.freeze({
|
|
1416
1462
|
__proto__: null,
|
|
1417
|
-
create: create$
|
|
1463
|
+
create: create$7,
|
|
1418
1464
|
square: square,
|
|
1419
|
-
isEqual: isEqual
|
|
1420
|
-
scale: scale
|
|
1465
|
+
isEqual: isEqual,
|
|
1466
|
+
scale: scale,
|
|
1421
1467
|
proportionalScale: proportionalScale,
|
|
1422
1468
|
trim: trim,
|
|
1423
|
-
containFit: containFit
|
|
1424
|
-
cropFit: cropFit
|
|
1425
|
-
scaleFit: scaleFit
|
|
1469
|
+
containFit: containFit,
|
|
1470
|
+
cropFit: cropFit,
|
|
1471
|
+
scaleFit: scaleFit,
|
|
1426
1472
|
round: round,
|
|
1427
1473
|
floor: floor,
|
|
1428
|
-
center: center$
|
|
1474
|
+
center: center$1,
|
|
1429
1475
|
aspectRatio: aspectRatio,
|
|
1430
|
-
area: area
|
|
1476
|
+
area: area,
|
|
1431
1477
|
fitToRatio: fitToRatio,
|
|
1432
1478
|
toRectangle: toRectangle
|
|
1433
1479
|
});
|
|
@@ -1440,7 +1486,7 @@ var dimensions = /*#__PURE__*/Object.freeze({
|
|
|
1440
1486
|
* @param value The values to populate the euler angle with.
|
|
1441
1487
|
* @returns A euler angle.
|
|
1442
1488
|
*/
|
|
1443
|
-
function create$
|
|
1489
|
+
function create$6(value) {
|
|
1444
1490
|
var _a, _b, _c, _d;
|
|
1445
1491
|
if (value === void 0) { value = {}; }
|
|
1446
1492
|
return {
|
|
@@ -1461,7 +1507,7 @@ function create$5(value) {
|
|
|
1461
1507
|
function fromDegrees(value) {
|
|
1462
1508
|
if (value === void 0) { value = {}; }
|
|
1463
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;
|
|
1464
|
-
return create$
|
|
1510
|
+
return create$6({
|
|
1465
1511
|
x: toRadians(x),
|
|
1466
1512
|
y: toRadians(y),
|
|
1467
1513
|
z: toRadians(z),
|
|
@@ -1581,7 +1627,7 @@ function isType$1(obj) {
|
|
|
1581
1627
|
|
|
1582
1628
|
var euler = /*#__PURE__*/Object.freeze({
|
|
1583
1629
|
__proto__: null,
|
|
1584
|
-
create: create$
|
|
1630
|
+
create: create$6,
|
|
1585
1631
|
fromDegrees: fromDegrees,
|
|
1586
1632
|
fromRotationMatrix: fromRotationMatrix,
|
|
1587
1633
|
fromJson: fromJson$1,
|
|
@@ -1594,7 +1640,7 @@ var euler = /*#__PURE__*/Object.freeze({
|
|
|
1594
1640
|
*
|
|
1595
1641
|
* @param values The values to assign to the line.
|
|
1596
1642
|
*/
|
|
1597
|
-
function create$
|
|
1643
|
+
function create$5(values) {
|
|
1598
1644
|
var _a, _b;
|
|
1599
1645
|
if (values === void 0) { values = {}; }
|
|
1600
1646
|
return {
|
|
@@ -1605,8 +1651,8 @@ function create$6(values) {
|
|
|
1605
1651
|
/**
|
|
1606
1652
|
* Returns the point that is halfway between start and end.
|
|
1607
1653
|
*/
|
|
1608
|
-
function center
|
|
1609
|
-
return lerp
|
|
1654
|
+
function center(line) {
|
|
1655
|
+
return lerp(line.start, line.end, 0.5);
|
|
1610
1656
|
}
|
|
1611
1657
|
/**
|
|
1612
1658
|
* Returns a line where the start and end points are transformed with the given
|
|
@@ -1616,45 +1662,45 @@ function center$3(line) {
|
|
|
1616
1662
|
* @param matrix The matrix to apply.
|
|
1617
1663
|
* @returns A transformed line.
|
|
1618
1664
|
*/
|
|
1619
|
-
function transformMatrix
|
|
1620
|
-
var start = transformMatrix(line.start, matrix);
|
|
1621
|
-
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);
|
|
1622
1668
|
return { start: start, end: end };
|
|
1623
1669
|
}
|
|
1624
1670
|
/**
|
|
1625
1671
|
* Euclidean distance between the start and end points of the line.
|
|
1626
1672
|
*/
|
|
1627
|
-
function distance
|
|
1673
|
+
function distance(line) {
|
|
1628
1674
|
return distance$1(line.start, line.end);
|
|
1629
1675
|
}
|
|
1630
1676
|
/**
|
|
1631
1677
|
* Returns the squared distance between a line's start and end point. If you're
|
|
1632
1678
|
* just comparing distances, this is slightly more efficient than `distanceTo`.
|
|
1633
1679
|
*/
|
|
1634
|
-
function distanceSquared
|
|
1635
|
-
return distanceSquared(line.start, line.end);
|
|
1680
|
+
function distanceSquared(line) {
|
|
1681
|
+
return distanceSquared$1(line.start, line.end);
|
|
1636
1682
|
}
|
|
1637
1683
|
/**
|
|
1638
1684
|
* Returns a vector describing the direction of the line from start to end.
|
|
1639
1685
|
*/
|
|
1640
1686
|
function direction(line) {
|
|
1641
|
-
return subtract
|
|
1687
|
+
return subtract(line.end, line.start);
|
|
1642
1688
|
}
|
|
1643
1689
|
|
|
1644
1690
|
var line3 = /*#__PURE__*/Object.freeze({
|
|
1645
1691
|
__proto__: null,
|
|
1646
|
-
create: create$
|
|
1647
|
-
center: center
|
|
1648
|
-
transformMatrix: transformMatrix
|
|
1649
|
-
distance: distance
|
|
1650
|
-
distanceSquared: distanceSquared
|
|
1692
|
+
create: create$5,
|
|
1693
|
+
center: center,
|
|
1694
|
+
transformMatrix: transformMatrix,
|
|
1695
|
+
distance: distance,
|
|
1696
|
+
distanceSquared: distanceSquared,
|
|
1651
1697
|
direction: direction
|
|
1652
1698
|
});
|
|
1653
1699
|
|
|
1654
1700
|
/**
|
|
1655
1701
|
* Creates a new matrix. If arguments are undefined, returns an identity matrix.
|
|
1656
1702
|
*/
|
|
1657
|
-
var create$
|
|
1703
|
+
var create$4 = function (a, b, c, d, tx, ty) {
|
|
1658
1704
|
if (a === void 0) { a = 1; }
|
|
1659
1705
|
if (b === void 0) { b = 0; }
|
|
1660
1706
|
if (c === void 0) { c = 0; }
|
|
@@ -1667,7 +1713,7 @@ var create$7 = function (a, b, c, d, tx, ty) {
|
|
|
1667
1713
|
* Returns an identity matrix.
|
|
1668
1714
|
*/
|
|
1669
1715
|
var identity = function () {
|
|
1670
|
-
return create$
|
|
1716
|
+
return create$4();
|
|
1671
1717
|
};
|
|
1672
1718
|
/**
|
|
1673
1719
|
* Creates a matrix that is translated by the given `tx` and `ty` values.
|
|
@@ -1692,7 +1738,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1692
1738
|
var b = matrix.b * cos + matrix.d * sin;
|
|
1693
1739
|
var c = matrix.a * -sin + matrix.c * cos;
|
|
1694
1740
|
var d = matrix.b * -sin + matrix.d * cos;
|
|
1695
|
-
return create$
|
|
1741
|
+
return create$4(a, b, c, d, matrix.tx, matrix.ty);
|
|
1696
1742
|
};
|
|
1697
1743
|
/**
|
|
1698
1744
|
* Translates the given matrix along the horizontal and vertical axis by the
|
|
@@ -1701,7 +1747,7 @@ var rotate = function (degrees, matrix) {
|
|
|
1701
1747
|
var translate = function (dx, dy, matrix) {
|
|
1702
1748
|
var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
|
|
1703
1749
|
var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
|
|
1704
|
-
return create$
|
|
1750
|
+
return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
|
|
1705
1751
|
};
|
|
1706
1752
|
/**
|
|
1707
1753
|
* Returns the result of applying a geometric transformation of a matrix on the
|
|
@@ -1710,12 +1756,12 @@ var translate = function (dx, dy, matrix) {
|
|
|
1710
1756
|
var transformPoint = function (matrix, pt) {
|
|
1711
1757
|
var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
|
|
1712
1758
|
var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
|
|
1713
|
-
return create(x, y);
|
|
1759
|
+
return create$b(x, y);
|
|
1714
1760
|
};
|
|
1715
1761
|
|
|
1716
1762
|
var matrix = /*#__PURE__*/Object.freeze({
|
|
1717
1763
|
__proto__: null,
|
|
1718
|
-
create: create$
|
|
1764
|
+
create: create$4,
|
|
1719
1765
|
identity: identity,
|
|
1720
1766
|
translation: translation,
|
|
1721
1767
|
rotation: rotation,
|
|
@@ -1724,7 +1770,7 @@ var matrix = /*#__PURE__*/Object.freeze({
|
|
|
1724
1770
|
transformPoint: transformPoint
|
|
1725
1771
|
});
|
|
1726
1772
|
|
|
1727
|
-
function create$
|
|
1773
|
+
function create$3() {
|
|
1728
1774
|
var args = [];
|
|
1729
1775
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1730
1776
|
args[_i] = arguments[_i];
|
|
@@ -1761,15 +1807,15 @@ function determinant(matrix) {
|
|
|
1761
1807
|
/**
|
|
1762
1808
|
* Returns the dot product of the two vectors represented in this matrix.
|
|
1763
1809
|
*/
|
|
1764
|
-
function dot
|
|
1810
|
+
function dot(matrix) {
|
|
1765
1811
|
return matrix.a * matrix.c + matrix.b * matrix.d;
|
|
1766
1812
|
}
|
|
1767
1813
|
|
|
1768
1814
|
var matrix2 = /*#__PURE__*/Object.freeze({
|
|
1769
1815
|
__proto__: null,
|
|
1770
|
-
create: create$
|
|
1816
|
+
create: create$3,
|
|
1771
1817
|
determinant: determinant,
|
|
1772
|
-
dot: dot
|
|
1818
|
+
dot: dot
|
|
1773
1819
|
});
|
|
1774
1820
|
|
|
1775
1821
|
/**
|
|
@@ -1778,7 +1824,7 @@ var matrix2 = /*#__PURE__*/Object.freeze({
|
|
|
1778
1824
|
* @param values Values to assign to the plane.
|
|
1779
1825
|
* @returns A new plane.
|
|
1780
1826
|
*/
|
|
1781
|
-
function create$
|
|
1827
|
+
function create$2(values) {
|
|
1782
1828
|
if (values === void 0) { values = {}; }
|
|
1783
1829
|
return tslib.__assign({ normal: origin(), constant: 0 }, values);
|
|
1784
1830
|
}
|
|
@@ -1790,7 +1836,7 @@ function create$9(values) {
|
|
|
1790
1836
|
* @returns A distance.
|
|
1791
1837
|
*/
|
|
1792
1838
|
function distanceToPoint(plane, point) {
|
|
1793
|
-
return dot(plane.normal, point) + plane.constant;
|
|
1839
|
+
return dot$1(plane.normal, point) + plane.constant;
|
|
1794
1840
|
}
|
|
1795
1841
|
/**
|
|
1796
1842
|
* Returns the point where the line intersects with this plane. If the line does
|
|
@@ -1803,7 +1849,7 @@ function distanceToPoint(plane, point) {
|
|
|
1803
1849
|
*/
|
|
1804
1850
|
function intersectLine(plane, line) {
|
|
1805
1851
|
var direction$1 = direction(line);
|
|
1806
|
-
var denominator = dot(plane.normal, direction$1);
|
|
1852
|
+
var denominator = dot$1(plane.normal, direction$1);
|
|
1807
1853
|
if (denominator === 0) {
|
|
1808
1854
|
if (distanceToPoint(plane, line.start) === 0) {
|
|
1809
1855
|
return line.start;
|
|
@@ -1812,12 +1858,12 @@ function intersectLine(plane, line) {
|
|
|
1812
1858
|
return undefined;
|
|
1813
1859
|
}
|
|
1814
1860
|
}
|
|
1815
|
-
var t = -(dot(line.start, plane.normal) + plane.constant) / denominator;
|
|
1861
|
+
var t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
|
|
1816
1862
|
if (t < 0 || t > 1) {
|
|
1817
1863
|
return undefined;
|
|
1818
1864
|
}
|
|
1819
1865
|
else {
|
|
1820
|
-
return add
|
|
1866
|
+
return add(line.start, scale$2(t, direction$1));
|
|
1821
1867
|
}
|
|
1822
1868
|
}
|
|
1823
1869
|
/**
|
|
@@ -1829,12 +1875,12 @@ function intersectLine(plane, line) {
|
|
|
1829
1875
|
*/
|
|
1830
1876
|
function projectPoint(plane, point) {
|
|
1831
1877
|
var d = distanceToPoint(plane, point);
|
|
1832
|
-
return add
|
|
1878
|
+
return add(point, scale$2(-d, plane.normal));
|
|
1833
1879
|
}
|
|
1834
1880
|
|
|
1835
1881
|
var plane = /*#__PURE__*/Object.freeze({
|
|
1836
1882
|
__proto__: null,
|
|
1837
|
-
create: create$
|
|
1883
|
+
create: create$2,
|
|
1838
1884
|
distanceToPoint: distanceToPoint,
|
|
1839
1885
|
intersectLine: intersectLine,
|
|
1840
1886
|
projectPoint: projectPoint
|
|
@@ -1844,7 +1890,7 @@ var plane = /*#__PURE__*/Object.freeze({
|
|
|
1844
1890
|
* Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
|
|
1845
1891
|
* w: 1}` is returned.
|
|
1846
1892
|
*/
|
|
1847
|
-
function create$
|
|
1893
|
+
function create$1(value) {
|
|
1848
1894
|
if (value === void 0) { value = {}; }
|
|
1849
1895
|
return tslib.__assign({ x: 0, y: 0, z: 0, w: 1 }, value);
|
|
1850
1896
|
}
|
|
@@ -1854,14 +1900,14 @@ function create$a(value) {
|
|
|
1854
1900
|
* @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
|
|
1855
1901
|
* @returns A parsed `Quaternion`.
|
|
1856
1902
|
*/
|
|
1857
|
-
function fromJson
|
|
1903
|
+
function fromJson(json) {
|
|
1858
1904
|
var obj = JSON.parse(json);
|
|
1859
1905
|
if (Array.isArray(obj)) {
|
|
1860
1906
|
var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
|
|
1861
|
-
return create$
|
|
1907
|
+
return create$1({ x: x, y: y, z: z, w: w });
|
|
1862
1908
|
}
|
|
1863
1909
|
else {
|
|
1864
|
-
return create$
|
|
1910
|
+
return create$1(obj);
|
|
1865
1911
|
}
|
|
1866
1912
|
}
|
|
1867
1913
|
/**
|
|
@@ -1989,7 +2035,7 @@ function fromEuler(euler) {
|
|
|
1989
2035
|
/**
|
|
1990
2036
|
* Multiplies `a` x `b` and returns a new quaternion with the result.
|
|
1991
2037
|
*/
|
|
1992
|
-
function multiply
|
|
2038
|
+
function multiply(a, b) {
|
|
1993
2039
|
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
1994
2040
|
return {
|
|
1995
2041
|
x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,
|
|
@@ -2001,7 +2047,7 @@ function multiply$2(a, b) {
|
|
|
2001
2047
|
/**
|
|
2002
2048
|
* Type guard that checks if the given type is a Quaternion.
|
|
2003
2049
|
*/
|
|
2004
|
-
function isType
|
|
2050
|
+
function isType(obj) {
|
|
2005
2051
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2006
2052
|
var o = obj;
|
|
2007
2053
|
return (o != null &&
|
|
@@ -2013,13 +2059,13 @@ function isType$2(obj) {
|
|
|
2013
2059
|
|
|
2014
2060
|
var quaternion = /*#__PURE__*/Object.freeze({
|
|
2015
2061
|
__proto__: null,
|
|
2016
|
-
create: create$
|
|
2017
|
-
fromJson: fromJson
|
|
2062
|
+
create: create$1,
|
|
2063
|
+
fromJson: fromJson,
|
|
2018
2064
|
fromAxisAngle: fromAxisAngle,
|
|
2019
2065
|
fromMatrixRotation: fromMatrixRotation,
|
|
2020
2066
|
fromEuler: fromEuler,
|
|
2021
|
-
multiply: multiply
|
|
2022
|
-
isType: isType
|
|
2067
|
+
multiply: multiply,
|
|
2068
|
+
isType: isType
|
|
2023
2069
|
});
|
|
2024
2070
|
|
|
2025
2071
|
/**
|
|
@@ -2029,7 +2075,7 @@ var quaternion = /*#__PURE__*/Object.freeze({
|
|
|
2029
2075
|
* @param value The values of the ray.
|
|
2030
2076
|
* @returns A new ray.
|
|
2031
2077
|
*/
|
|
2032
|
-
function create
|
|
2078
|
+
function create(value) {
|
|
2033
2079
|
var _a, _b;
|
|
2034
2080
|
if (value === void 0) { value = {}; }
|
|
2035
2081
|
return {
|
|
@@ -2045,7 +2091,7 @@ function create$b(value) {
|
|
|
2045
2091
|
* @returns A point on the ray.
|
|
2046
2092
|
*/
|
|
2047
2093
|
function at(ray, distance) {
|
|
2048
|
-
return add
|
|
2094
|
+
return add(scale$2(distance, ray.direction), ray.origin);
|
|
2049
2095
|
}
|
|
2050
2096
|
/**
|
|
2051
2097
|
* Computes the distance of the `ray`s origin to the given `plane`. Returns a
|
|
@@ -2057,13 +2103,13 @@ function at(ray, distance) {
|
|
|
2057
2103
|
* @returns The distance to the plane, or `undefined` if it cannot be computed.
|
|
2058
2104
|
*/
|
|
2059
2105
|
function distanceToPlane(ray, plane$1) {
|
|
2060
|
-
var d = dot(plane$1.normal, ray.direction);
|
|
2106
|
+
var d = dot$1(plane$1.normal, ray.direction);
|
|
2061
2107
|
if (d === 0) {
|
|
2062
2108
|
// Ray is on plane.
|
|
2063
2109
|
return distanceToPoint(plane$1, ray.origin) === 0 ? 0 : undefined;
|
|
2064
2110
|
}
|
|
2065
2111
|
else {
|
|
2066
|
-
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;
|
|
2067
2113
|
// Checks if ray intersects plane.
|
|
2068
2114
|
return t >= 0 ? t : undefined;
|
|
2069
2115
|
}
|
|
@@ -2084,7 +2130,7 @@ function intersectPlane(ray, plane) {
|
|
|
2084
2130
|
|
|
2085
2131
|
var ray = /*#__PURE__*/Object.freeze({
|
|
2086
2132
|
__proto__: null,
|
|
2087
|
-
create: create
|
|
2133
|
+
create: create,
|
|
2088
2134
|
at: at,
|
|
2089
2135
|
distanceToPlane: distanceToPlane,
|
|
2090
2136
|
intersectPlane: intersectPlane
|
|
@@ -2105,5 +2151,5 @@ exports.Ray = ray;
|
|
|
2105
2151
|
exports.Rectangle = rectangle;
|
|
2106
2152
|
exports.Vector3 = vector3;
|
|
2107
2153
|
exports.clamp = clamp;
|
|
2108
|
-
exports.lerp = lerp;
|
|
2154
|
+
exports.lerp = lerp$2;
|
|
2109
2155
|
//# sourceMappingURL=bundle.cjs.js.map
|