@woosh/meep-engine 2.106.0 → 2.106.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/meep.cjs +320 -165
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +320 -165
- package/package.json +1 -1
- package/src/core/collection/array/array_copy.spec.d.ts +2 -0
- package/src/core/collection/array/array_copy.spec.d.ts.map +1 -0
- package/src/core/collection/array/array_copy.spec.js +19 -0
- package/src/core/collection/list/List.d.ts.map +1 -1
- package/src/core/collection/list/List.js +55 -30
- package/src/core/collection/list/List.spec.js +101 -0
- package/src/core/collection/list/ListForwarder.d.ts.map +1 -1
- package/src/core/collection/list/ListForwarder.js +49 -53
- package/src/core/collection/list/ListForwarder.spec.js +2 -0
- package/src/core/collection/list/SortedListProjection.d.ts +4 -1
- package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
- package/src/core/collection/list/SortedListProjection.js +4 -1
- package/src/core/collection/map/AbstractAsyncMap.d.ts.map +1 -1
- package/src/core/collection/map/AbstractAsyncMap.js +0 -3
- package/src/core/collection/map/AsyncMapWrapper.d.ts +6 -10
- package/src/core/collection/map/AsyncMapWrapper.d.ts.map +1 -1
- package/src/core/collection/map/AsyncMapWrapper.js +14 -9
- package/src/core/collection/map/HashMap.d.ts.map +1 -1
- package/src/core/collection/map/HashMap.js +14 -0
- package/src/core/collection/map/ObservedMap.d.ts +12 -3
- package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
- package/src/core/collection/map/ObservedMap.js +14 -4
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +100 -95
- package/src/core/collection/set/ArraySet.d.ts.map +1 -0
- package/src/core/collection/set/{Set.js → ArraySet.js} +2 -2
- package/src/core/collection/set/set_remove.d.ts +3 -3
- package/src/core/collection/set/set_remove.d.ts.map +1 -1
- package/src/core/collection/set/set_remove.js +5 -5
- package/src/core/color/oklab/find_gamut_intersection.js +1 -1
- package/src/core/geom/2d/Rectangle.d.ts +54 -5
- package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
- package/src/core/geom/2d/Rectangle.js +70 -3
- package/src/core/geom/2d/circle/Circle.d.ts +1 -1
- package/src/core/geom/2d/circle/Circle.js +1 -1
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
- package/src/core/geom/2d/compute_triangle_area_2d.js +7 -1
- package/src/core/geom/2d/shape/AbstractShape.d.ts +2 -0
- package/src/core/geom/2d/shape/AbstractShape.d.ts.map +1 -1
- package/src/core/geom/2d/shape/AbstractShape.js +8 -2
- package/src/core/geom/2d/shape/CircleShape.d.ts +14 -0
- package/src/core/geom/2d/shape/CircleShape.d.ts.map +1 -1
- package/src/core/geom/2d/shape/CircleShape.js +64 -22
- package/src/core/geom/2d/uv_map_circle_to_square.d.ts +8 -0
- package/src/core/geom/2d/uv_map_circle_to_square.d.ts.map +1 -0
- package/src/core/geom/2d/{UvUtils.js → uv_map_circle_to_square.js} +2 -17
- package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts +2 -0
- package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_circle_to_square.spec.js +28 -0
- package/src/core/geom/2d/uv_map_square_to_circle.d.ts +8 -0
- package/src/core/geom/2d/uv_map_square_to_circle.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_square_to_circle.js +14 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts +2 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.js +30 -0
- package/src/core/geom/Vector3.d.ts +13 -4
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +83 -36
- package/src/core/geom/Vector3.spec.js +113 -12
- package/src/core/collection/set/Set.d.ts.map +0 -1
- package/src/core/geom/2d/Geometry2D.d.ts +0 -31
- package/src/core/geom/2d/Geometry2D.d.ts.map +0 -1
- package/src/core/geom/2d/Geometry2D.js +0 -59
- package/src/core/geom/2d/UvUtils.d.ts +0 -15
- package/src/core/geom/2d/UvUtils.d.ts.map +0 -1
- package/src/core/geom/2d/UvUtils.spec.d.ts +0 -2
- package/src/core/geom/2d/UvUtils.spec.d.ts.map +0 -1
- package/src/core/geom/2d/UvUtils.spec.js +0 -55
- /package/src/core/collection/set/{Set.d.ts → ArraySet.d.ts} +0 -0
package/src/core/geom/Vector3.js
CHANGED
|
@@ -26,10 +26,23 @@ class Vector3 {
|
|
|
26
26
|
* @constructor
|
|
27
27
|
*/
|
|
28
28
|
constructor(x = 0, y = 0, z = 0) {
|
|
29
|
+
/**
|
|
30
|
+
* @type {number}
|
|
31
|
+
*/
|
|
29
32
|
this.x = x;
|
|
33
|
+
/**
|
|
34
|
+
* @type {number}
|
|
35
|
+
*/
|
|
30
36
|
this.y = y;
|
|
37
|
+
/**
|
|
38
|
+
* @type {number}
|
|
39
|
+
*/
|
|
31
40
|
this.z = z;
|
|
32
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @readonly
|
|
44
|
+
* @type {Signal<number,number,number,number,number,number>}
|
|
45
|
+
*/
|
|
33
46
|
this.onChanged = new Signal();
|
|
34
47
|
}
|
|
35
48
|
|
|
@@ -336,7 +349,11 @@ class Vector3 {
|
|
|
336
349
|
const ax = first.x, ay = first.y, az = first.z;
|
|
337
350
|
const bx = second.x, by = second.y, bz = second.z;
|
|
338
351
|
|
|
339
|
-
this._crossVectors(
|
|
352
|
+
this._crossVectors(
|
|
353
|
+
ax, ay, az,
|
|
354
|
+
bx, by, bz
|
|
355
|
+
);
|
|
356
|
+
|
|
340
357
|
}
|
|
341
358
|
|
|
342
359
|
/**
|
|
@@ -548,6 +565,7 @@ class Vector3 {
|
|
|
548
565
|
/**
|
|
549
566
|
*
|
|
550
567
|
* @param {THREE.Matrix4} matrix4
|
|
568
|
+
* @deprecated use {@link @applyMatrix4} directly instead, pass `mat.elements`
|
|
551
569
|
*/
|
|
552
570
|
applyMatrix4_three(matrix4) {
|
|
553
571
|
this.applyMatrix4(matrix4.elements);
|
|
@@ -576,7 +594,9 @@ class Vector3 {
|
|
|
576
594
|
* @param {ArrayLike<number>|number[]|Float32Array} m4
|
|
577
595
|
*/
|
|
578
596
|
applyDirectionMatrix4(m4) {
|
|
579
|
-
const x = this.x
|
|
597
|
+
const x = this.x;
|
|
598
|
+
const y = this.y;
|
|
599
|
+
const z = this.z;
|
|
580
600
|
|
|
581
601
|
const _x = m4[0] * x + m4[4] * y + m4[8] * z;
|
|
582
602
|
const _y = m4[1] * x + m4[5] * y + m4[9] * z;
|
|
@@ -607,25 +627,34 @@ class Vector3 {
|
|
|
607
627
|
}
|
|
608
628
|
|
|
609
629
|
/**
|
|
610
|
-
*
|
|
630
|
+
* @deprecated use non-three.js version instead
|
|
611
631
|
* @param {THREE.Matrix3} m
|
|
612
632
|
* @returns {Vector3}
|
|
613
633
|
*/
|
|
614
634
|
applyMatrix3_three(m) {
|
|
635
|
+
this.applyMatrix3(m.elements);
|
|
615
636
|
|
|
616
|
-
|
|
617
|
-
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
618
639
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
640
|
+
/**
|
|
641
|
+
*
|
|
642
|
+
* @param {number[]|Float32Array} mat
|
|
643
|
+
*/
|
|
644
|
+
applyMatrix3(mat) {
|
|
645
|
+
const x = this.x;
|
|
646
|
+
const y = this.y;
|
|
647
|
+
const z = this.z;
|
|
622
648
|
|
|
623
|
-
|
|
649
|
+
const _x = mat[0] * x + mat[3] * y + mat[6] * z;
|
|
650
|
+
const _y = mat[1] * x + mat[4] * y + mat[7] * z;
|
|
651
|
+
const _z = mat[2] * x + mat[5] * y + mat[8] * z;
|
|
624
652
|
|
|
653
|
+
this.set(_x, _y, _z);
|
|
625
654
|
}
|
|
626
655
|
|
|
627
656
|
/**
|
|
628
|
-
*
|
|
657
|
+
* @deprecated use non-three.js version instead
|
|
629
658
|
* @param {THREE.Matrix4} matrix4
|
|
630
659
|
*/
|
|
631
660
|
threejs_setFromMatrixPosition(matrix4) {
|
|
@@ -710,17 +739,7 @@ class Vector3 {
|
|
|
710
739
|
const y1 = other.y;
|
|
711
740
|
const z1 = other.z;
|
|
712
741
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
const mag2 = (x1 * x1 + y1 * y1 + z1 * z1);
|
|
716
|
-
|
|
717
|
-
const m = d / mag2;
|
|
718
|
-
|
|
719
|
-
const x = x1 * m;
|
|
720
|
-
const y = y1 * m;
|
|
721
|
-
const z = z1 * m;
|
|
722
|
-
|
|
723
|
-
this.set(x, y, z);
|
|
742
|
+
this._projectVectors(x0, y0, z0, x1, y1, z1);
|
|
724
743
|
}
|
|
725
744
|
|
|
726
745
|
/**
|
|
@@ -757,7 +776,10 @@ class Vector3 {
|
|
|
757
776
|
* @param {number} y1
|
|
758
777
|
* @param {number} z1
|
|
759
778
|
*/
|
|
760
|
-
_projectVectors(
|
|
779
|
+
_projectVectors(
|
|
780
|
+
x0, y0, z0,
|
|
781
|
+
x1, y1, z1
|
|
782
|
+
) {
|
|
761
783
|
|
|
762
784
|
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
763
785
|
|
|
@@ -779,12 +801,24 @@ class Vector3 {
|
|
|
779
801
|
* @param {number} theta
|
|
780
802
|
*/
|
|
781
803
|
setFromSphericalCoords(radius, phi, theta) {
|
|
804
|
+
assert.isNumber(radius, 'radius');
|
|
805
|
+
assert.notNaN(radius, 'radius');
|
|
806
|
+
|
|
807
|
+
assert.isNumber(phi, 'phi');
|
|
808
|
+
assert.notNaN(phi, 'phi');
|
|
782
809
|
|
|
783
|
-
|
|
810
|
+
assert.isNumber(theta, 'theta');
|
|
811
|
+
assert.notNaN(theta, 'theta');
|
|
784
812
|
|
|
785
|
-
const
|
|
786
|
-
const
|
|
787
|
-
|
|
813
|
+
const sin_phi = Math.sin(phi);
|
|
814
|
+
const cos_phi = Math.cos(phi);
|
|
815
|
+
|
|
816
|
+
const sin_theta = Math.sin(theta);
|
|
817
|
+
const cos_theta = Math.cos(theta);
|
|
818
|
+
|
|
819
|
+
const _x = radius * sin_phi * sin_theta;
|
|
820
|
+
const _y = radius * cos_phi;
|
|
821
|
+
const _z = radius * sin_phi * cos_theta;
|
|
788
822
|
|
|
789
823
|
this.set(_x, _y, _z);
|
|
790
824
|
}
|
|
@@ -792,11 +826,15 @@ class Vector3 {
|
|
|
792
826
|
/**
|
|
793
827
|
*
|
|
794
828
|
* @param {function} processor
|
|
829
|
+
* @param {*} [thisArg]
|
|
795
830
|
* @returns {Vector3}
|
|
796
831
|
*/
|
|
797
|
-
process(processor) {
|
|
798
|
-
|
|
799
|
-
this.
|
|
832
|
+
process(processor, thisArg) {
|
|
833
|
+
|
|
834
|
+
processor.call(thisArg, this.x, this.y, this.z);
|
|
835
|
+
|
|
836
|
+
this.onChanged.add(processor, thisArg);
|
|
837
|
+
|
|
800
838
|
return this;
|
|
801
839
|
}
|
|
802
840
|
|
|
@@ -810,6 +848,7 @@ class Vector3 {
|
|
|
810
848
|
*/
|
|
811
849
|
fromJSON(json) {
|
|
812
850
|
if (typeof json === 'number') {
|
|
851
|
+
// special case where input is a number
|
|
813
852
|
this.setScalar(json);
|
|
814
853
|
} else {
|
|
815
854
|
this.copy(json);
|
|
@@ -823,6 +862,7 @@ class Vector3 {
|
|
|
823
862
|
/**
|
|
824
863
|
*
|
|
825
864
|
* @param {BinaryBuffer} buffer
|
|
865
|
+
* @deprecated
|
|
826
866
|
*/
|
|
827
867
|
toBinaryBuffer(buffer) {
|
|
828
868
|
buffer.writeFloat64(this.x);
|
|
@@ -833,6 +873,7 @@ class Vector3 {
|
|
|
833
873
|
/**
|
|
834
874
|
*
|
|
835
875
|
* @param {BinaryBuffer} buffer
|
|
876
|
+
* @deprecated
|
|
836
877
|
*/
|
|
837
878
|
fromBinaryBuffer(buffer) {
|
|
838
879
|
const x = buffer.readFloat64();
|
|
@@ -845,6 +886,7 @@ class Vector3 {
|
|
|
845
886
|
/**
|
|
846
887
|
*
|
|
847
888
|
* @param {BinaryBuffer} buffer
|
|
889
|
+
* @deprecated
|
|
848
890
|
*/
|
|
849
891
|
toBinaryBufferFloat32(buffer) {
|
|
850
892
|
buffer.writeFloat32(this.x);
|
|
@@ -855,6 +897,7 @@ class Vector3 {
|
|
|
855
897
|
/**
|
|
856
898
|
*
|
|
857
899
|
* @param {BinaryBuffer} buffer
|
|
900
|
+
* @deprecated
|
|
858
901
|
*/
|
|
859
902
|
fromBinaryBufferFloat32(buffer) {
|
|
860
903
|
const x = buffer.readFloat32();
|
|
@@ -974,12 +1017,6 @@ Vector3.prototype.fromArray = Vector3.prototype.readFromArray;
|
|
|
974
1017
|
Vector3.prototype.toArray = Vector3.prototype.writeToArray;
|
|
975
1018
|
|
|
976
1019
|
|
|
977
|
-
/**
|
|
978
|
-
* @readonly
|
|
979
|
-
* @type {boolean}
|
|
980
|
-
*/
|
|
981
|
-
Vector3.prototype.isVector3 = true;
|
|
982
|
-
|
|
983
1020
|
/**
|
|
984
1021
|
* @readonly
|
|
985
1022
|
* @type {Vector3}
|
|
@@ -1036,10 +1073,20 @@ Vector3.forward = Object.freeze(new Vector3(0, 0, 1));
|
|
|
1036
1073
|
*/
|
|
1037
1074
|
Vector3.back = Object.freeze(new Vector3(0, 0, -1));
|
|
1038
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* @readonly
|
|
1078
|
+
* @type {boolean}
|
|
1079
|
+
*/
|
|
1080
|
+
Vector3.prototype.isVector3 = true;
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* @readonly
|
|
1084
|
+
* @type {string}
|
|
1085
|
+
*/
|
|
1039
1086
|
Vector3.typeName = "Vector3";
|
|
1040
1087
|
|
|
1041
1088
|
/**
|
|
1042
|
-
*
|
|
1089
|
+
* @deprecated use {@link v3_dot} directly instead
|
|
1043
1090
|
* @param {number} x0
|
|
1044
1091
|
* @param {number} y0
|
|
1045
1092
|
* @param {number} z0
|
|
@@ -7,28 +7,28 @@ test('slerp', () => {
|
|
|
7
7
|
const v = new Vector3();
|
|
8
8
|
|
|
9
9
|
v3_slerp(v, 0, 0, 0, 0, 0, 0, 0);
|
|
10
|
-
expect(v.toJSON()).toEqual({x: 0, y: 0, z: 0});
|
|
10
|
+
expect(v.toJSON()).toEqual({ x: 0, y: 0, z: 0 });
|
|
11
11
|
|
|
12
12
|
v3_slerp(v, 0, 0, 0, 0, 0, 0, 1);
|
|
13
|
-
expect(v.toJSON()).toEqual({x: 0, y: 0, z: 0});
|
|
13
|
+
expect(v.toJSON()).toEqual({ x: 0, y: 0, z: 0 });
|
|
14
14
|
|
|
15
15
|
v3_slerp(v, 1, 1, 1, 1, 1, 1, 0);
|
|
16
|
-
expect(v.toJSON()).toEqual({x: 1, y: 1, z: 1});
|
|
16
|
+
expect(v.toJSON()).toEqual({ x: 1, y: 1, z: 1 });
|
|
17
17
|
|
|
18
18
|
v3_slerp(v, 1, 1, 1, 1, 1, 1, 1);
|
|
19
|
-
expect(v.toJSON()).toEqual({x: 1, y: 1, z: 1});
|
|
19
|
+
expect(v.toJSON()).toEqual({ x: 1, y: 1, z: 1 });
|
|
20
20
|
|
|
21
21
|
v3_slerp(v, -1, -1, -1, -1, -1, -1, 0);
|
|
22
|
-
expect(v.toJSON()).toEqual({x: -1, y: -1, z: -1});
|
|
22
|
+
expect(v.toJSON()).toEqual({ x: -1, y: -1, z: -1 });
|
|
23
23
|
|
|
24
24
|
v3_slerp(v, -1, -1, -1, -1, -1, -1, 1);
|
|
25
|
-
expect(v.toJSON()).toEqual({x: -1, y: -1, z: -1});
|
|
25
|
+
expect(v.toJSON()).toEqual({ x: -1, y: -1, z: -1 });
|
|
26
26
|
|
|
27
27
|
v3_slerp(v, 1, 1, 1, -1, -1, -1, 0);
|
|
28
|
-
expect(v.toJSON()).toEqual({x: 1, y: 1, z: 1});
|
|
28
|
+
expect(v.toJSON()).toEqual({ x: 1, y: 1, z: 1 });
|
|
29
29
|
|
|
30
30
|
v3_slerp(v, 1, 1, 1, -1, -1, -1, 1);
|
|
31
|
-
expect(v.toJSON()).toEqual({x: -1, y: -1, z: -1});
|
|
31
|
+
expect(v.toJSON()).toEqual({ x: -1, y: -1, z: -1 });
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
v3_slerp(v, 1, 0, 0, 0, 1, 0, 0.5);
|
|
@@ -123,10 +123,10 @@ test("iterator symbol", () => {
|
|
|
123
123
|
|
|
124
124
|
const iterator = v[Symbol.iterator]();
|
|
125
125
|
|
|
126
|
-
expect(iterator.next()).toEqual({value: 5, done: false})
|
|
127
|
-
expect(iterator.next()).toEqual({value: 7, done: false})
|
|
128
|
-
expect(iterator.next()).toEqual({value: 11, done: false})
|
|
129
|
-
expect(iterator.next()).toEqual({done: true})
|
|
126
|
+
expect(iterator.next()).toEqual({ value: 5, done: false })
|
|
127
|
+
expect(iterator.next()).toEqual({ value: 7, done: false })
|
|
128
|
+
expect(iterator.next()).toEqual({ value: 11, done: false })
|
|
129
|
+
expect(iterator.next()).toEqual({ done: true })
|
|
130
130
|
|
|
131
131
|
});
|
|
132
132
|
|
|
@@ -181,4 +181,105 @@ test("setFromSphericalCoords", () => {
|
|
|
181
181
|
expect(v3.x).not.toBeNaN();
|
|
182
182
|
expect(v3.y).not.toBeNaN();
|
|
183
183
|
expect(v3.z).not.toBeNaN();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("isZero", () => {
|
|
187
|
+
|
|
188
|
+
expect(new Vector3(0, 0, 0).isZero()).toBe(true);
|
|
189
|
+
|
|
190
|
+
expect(new Vector3(0, 0, 1).isZero()).toBe(false);
|
|
191
|
+
expect(new Vector3(0, 1, 0).isZero()).toBe(false);
|
|
192
|
+
expect(new Vector3(1, 0, 0).isZero()).toBe(false);
|
|
193
|
+
|
|
194
|
+
expect(new Vector3(0, 0, -1).isZero()).toBe(false);
|
|
195
|
+
expect(new Vector3(0, -1, 0).isZero()).toBe(false);
|
|
196
|
+
expect(new Vector3(-1, 0, 0).isZero()).toBe(false);
|
|
197
|
+
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("multiply", () => {
|
|
201
|
+
|
|
202
|
+
const a = new Vector3(1, -3, 5);
|
|
203
|
+
const b = new Vector3(7, 11, -13);
|
|
204
|
+
|
|
205
|
+
a.multiply(b);
|
|
206
|
+
|
|
207
|
+
expect(a.x).toEqual(7);
|
|
208
|
+
expect(a.y).toEqual(-33);
|
|
209
|
+
expect(a.z).toEqual(-65);
|
|
210
|
+
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test("cross", () => {
|
|
214
|
+
|
|
215
|
+
const a = new Vector3(1, -3, 5);
|
|
216
|
+
const b = new Vector3(7, 11, -13);
|
|
217
|
+
|
|
218
|
+
a.cross(b);
|
|
219
|
+
|
|
220
|
+
expect(a.x).toEqual(-16);
|
|
221
|
+
expect(a.y).toEqual(48);
|
|
222
|
+
expect(a.z).toEqual(32);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("normalize", () => {
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
const a = new Vector3(1, 0, 0);
|
|
229
|
+
a.normalize();
|
|
230
|
+
expect(a.x).toBeCloseTo(1);
|
|
231
|
+
expect(a.y).toBeCloseTo(0);
|
|
232
|
+
expect(a.z).toBeCloseTo(0);
|
|
233
|
+
|
|
234
|
+
const b = new Vector3(0, 1, 0);
|
|
235
|
+
|
|
236
|
+
b.normalize();
|
|
237
|
+
expect(b.x).toBeCloseTo(0);
|
|
238
|
+
expect(b.y).toBeCloseTo(1);
|
|
239
|
+
expect(b.z).toBeCloseTo(0);
|
|
240
|
+
|
|
241
|
+
const c = new Vector3(0, 0, 1);
|
|
242
|
+
|
|
243
|
+
c.normalize();
|
|
244
|
+
expect(c.x).toBeCloseTo(0);
|
|
245
|
+
expect(c.y).toBeCloseTo(0);
|
|
246
|
+
expect(c.z).toBeCloseTo(1);
|
|
247
|
+
|
|
248
|
+
const d = new Vector3(-1, 0, 0);
|
|
249
|
+
|
|
250
|
+
d.normalize();
|
|
251
|
+
expect(d.x).toBeCloseTo(-1);
|
|
252
|
+
expect(d.y).toBeCloseTo(0);
|
|
253
|
+
expect(d.z).toBeCloseTo(0);
|
|
254
|
+
|
|
255
|
+
const e = new Vector3(0, -1, 0);
|
|
256
|
+
|
|
257
|
+
e.normalize();
|
|
258
|
+
expect(e.x).toBeCloseTo(0);
|
|
259
|
+
expect(e.y).toBeCloseTo(-1);
|
|
260
|
+
expect(e.z).toBeCloseTo(0);
|
|
261
|
+
|
|
262
|
+
const f = new Vector3(0, 0, -1);
|
|
263
|
+
|
|
264
|
+
f.normalize();
|
|
265
|
+
expect(f.x).toBeCloseTo(0);
|
|
266
|
+
expect(f.y).toBeCloseTo(0);
|
|
267
|
+
expect(f.z).toBeCloseTo(-1);
|
|
268
|
+
|
|
269
|
+
// try zero
|
|
270
|
+
const g = new Vector3(0, 0, 0);
|
|
271
|
+
|
|
272
|
+
g.normalize()
|
|
273
|
+
expect(g.x).toBe(0);
|
|
274
|
+
expect(g.y).toBe(0);
|
|
275
|
+
expect(g.z).toBe(0);
|
|
276
|
+
|
|
277
|
+
// length resizing
|
|
278
|
+
const h = new Vector3(-3, -5, -7);
|
|
279
|
+
|
|
280
|
+
h.normalize()
|
|
281
|
+
expect(h.x).toBeCloseTo(-0.329292779969071);
|
|
282
|
+
expect(h.y).toBeCloseTo(-0.5488212999484517);
|
|
283
|
+
expect(h.z).toBeCloseTo(-0.7683498199278324);
|
|
284
|
+
|
|
184
285
|
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Set.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/Set.js"],"names":[],"mappings":";AAOA;;GAEG;AACH;IAiBI;;;;;;OAMG;IACH,yBAIC;IA3BD;;OAEG;IACH;;;MAGE;IAEF;;;OAGG;IACH,aAAU;IAEV,eAAW;IAeX;;;OAGG;IACH,yBAEC;IAED;;;OAGG;IACH,oBAWC;IAED;;;OAGG;IACH,uBAWC;IAED;;;;;OAKG;IACH,wBAIC;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFW,QAAS,QAMnB;IAED;;;OAGG;IACH,qBAFW,QAAS,QAuBnB;IAED;;;;OAIG;IACH,2CAIC;IAED;;;OAGG;IACH,WAFa,GAAG,CAIf;CACJ;mBAjKkB,+BAA+B"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 2D version of a polygon collection
|
|
3
|
-
*/
|
|
4
|
-
export class Geometry2D {
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {Geometry2D} g0
|
|
8
|
-
* @param {number[]} m0 Transform matrix for first geometry (m 3x3)
|
|
9
|
-
* @param {Geometry2D} g1
|
|
10
|
-
* @param {number[]} m1 Transform matrix for second geometry (m 3x3)
|
|
11
|
-
* @returns {boolean}
|
|
12
|
-
*/
|
|
13
|
-
static overlapExists(g0: Geometry2D, m0: number[], g1: Geometry2D, m1: number[]): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* @example [x,y, x,y, x,y]
|
|
16
|
-
* @type {number[]}
|
|
17
|
-
*/
|
|
18
|
-
vertices: number[];
|
|
19
|
-
/**
|
|
20
|
-
* Triplets of indices of vertices making up a polygon
|
|
21
|
-
* @example [0,1,2, 3,4,5]
|
|
22
|
-
* @type {number[]}
|
|
23
|
-
*/
|
|
24
|
-
indices: number[];
|
|
25
|
-
/**
|
|
26
|
-
* Bounding box
|
|
27
|
-
* @type {AABB2}
|
|
28
|
-
*/
|
|
29
|
-
aabb: AABB2;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=Geometry2D.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Geometry2D.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Geometry2D.js"],"names":[],"mappings":"AAMA;;GAEG;AACH;IAuBI;;;;;;;OAOG;IACH,yBANW,UAAU,MACV,MAAM,EAAE,MACR,UAAU,MACV,MAAM,EAAE,GACN,OAAO,CAiBnB;IA3CG;;;OAGG;IACH,UAFU,MAAM,EAAE,CAEA;IAElB;;;;OAIG;IACH,SAFU,MAAM,EAAE,CAED;IAEjB;;;OAGG;IACH,YAAuB;CA2B9B"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import AABB2 from "../AABB2.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const aabb_0 = new AABB2();
|
|
5
|
-
const aabb_1 = new AABB2();
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 2D version of a polygon collection
|
|
9
|
-
*/
|
|
10
|
-
export class Geometry2D {
|
|
11
|
-
constructor() {
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @example [x,y, x,y, x,y]
|
|
15
|
-
* @type {number[]}
|
|
16
|
-
*/
|
|
17
|
-
this.vertices = [];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Triplets of indices of vertices making up a polygon
|
|
21
|
-
* @example [0,1,2, 3,4,5]
|
|
22
|
-
* @type {number[]}
|
|
23
|
-
*/
|
|
24
|
-
this.indices = [];
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Bounding box
|
|
28
|
-
* @type {AABB2}
|
|
29
|
-
*/
|
|
30
|
-
this.aabb = new AABB2();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {Geometry2D} g0
|
|
36
|
-
* @param {number[]} m0 Transform matrix for first geometry (m 3x3)
|
|
37
|
-
* @param {Geometry2D} g1
|
|
38
|
-
* @param {number[]} m1 Transform matrix for second geometry (m 3x3)
|
|
39
|
-
* @returns {boolean}
|
|
40
|
-
*/
|
|
41
|
-
static overlapExists(g0, m0, g1, m1) {
|
|
42
|
-
// first check for AABB overlap
|
|
43
|
-
|
|
44
|
-
aabb_0.copy(g0.aabb);
|
|
45
|
-
aabb_0.applyMatrix3(m0);
|
|
46
|
-
|
|
47
|
-
aabb_1.copy(g1.aabb);
|
|
48
|
-
aabb_1.applyMatrix3(m1);
|
|
49
|
-
|
|
50
|
-
if (!aabb_0.overlapExists(aabb_1)) {
|
|
51
|
-
//no overlap
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//overlap between AABBs, test individual triangle pairs
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* based on paper "Elliptification of Rectangular Imagery" by Chamberlain Fong, Joint Mathematics Meetings 2019, SIGMAA-ARTS
|
|
3
|
-
* @param {Vector2} result
|
|
4
|
-
* @param {number} u
|
|
5
|
-
* @param {number} v
|
|
6
|
-
*/
|
|
7
|
-
export function uv_mapCircleToSquare(result: Vector2, u: number, v: number): void;
|
|
8
|
-
/**
|
|
9
|
-
* based on paper "Elliptification of Rectangular Imagery" by Chamberlain Fong, Joint Mathematics Meetings 2019, SIGMAA-ARTS
|
|
10
|
-
* @param {Vector2} result
|
|
11
|
-
* @param {number} x
|
|
12
|
-
* @param {number} y
|
|
13
|
-
*/
|
|
14
|
-
export function uv_mapSquareToCircle(result: Vector2, x: number, y: number): void;
|
|
15
|
-
//# sourceMappingURL=UvUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UvUtils.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/UvUtils.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,yDAHW,MAAM,KACN,MAAM,QA2BhB;AAED;;;;;GAKG;AACH,yDAHW,MAAM,KACN,MAAM,QAShB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UvUtils.spec.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/UvUtils.spec.js"],"names":[],"mappings":""}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import Vector2 from "../Vector2.js";
|
|
2
|
-
import { uv_mapCircleToSquare, uv_mapSquareToCircle } from "./UvUtils.js";
|
|
3
|
-
|
|
4
|
-
test("uv_mapCircleToSquare", () => {
|
|
5
|
-
const v = new Vector2();
|
|
6
|
-
|
|
7
|
-
function check(inputX, inputY, outputX, outputY) {
|
|
8
|
-
|
|
9
|
-
uv_mapCircleToSquare(v, inputX, inputY);
|
|
10
|
-
|
|
11
|
-
expect(v.x).toBeCloseTo(outputX);
|
|
12
|
-
expect(v.y).toBeCloseTo(outputY);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
check(0, 0, 0, 0);
|
|
16
|
-
|
|
17
|
-
check(-1, 0, -1, 0);
|
|
18
|
-
check(1, 0, 1, 0);
|
|
19
|
-
check(0, -1, 0, -1);
|
|
20
|
-
check(0, 1, 0, 1);
|
|
21
|
-
|
|
22
|
-
const s = Math.SQRT1_2;
|
|
23
|
-
|
|
24
|
-
check(s, s, 1, 1);
|
|
25
|
-
check(-s, s, -1, 1);
|
|
26
|
-
check(-s, -s, -1, -1);
|
|
27
|
-
check(s, -s, 1, -1);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("uv_mapSquareToCircle", () => {
|
|
31
|
-
|
|
32
|
-
const v = new Vector2();
|
|
33
|
-
|
|
34
|
-
function check(inputX, inputY, outputX, outputY) {
|
|
35
|
-
|
|
36
|
-
uv_mapSquareToCircle(v, inputX, inputY);
|
|
37
|
-
|
|
38
|
-
expect(v.x).toBeCloseTo(outputX);
|
|
39
|
-
expect(v.y).toBeCloseTo(outputY);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
check(0, 0, 0, 0);
|
|
43
|
-
|
|
44
|
-
check(-1, 0, -1, 0);
|
|
45
|
-
check(1, 0, 1, 0);
|
|
46
|
-
check(0, -1, 0, -1);
|
|
47
|
-
check(0, 1, 0, 1);
|
|
48
|
-
|
|
49
|
-
const s = Math.SQRT1_2;
|
|
50
|
-
|
|
51
|
-
check(1, 1, s, s);
|
|
52
|
-
check(-1, 1, -s, s);
|
|
53
|
-
check(-1, -1, -s, -s);
|
|
54
|
-
check(1, -1, s, -s);
|
|
55
|
-
});
|
|
File without changes
|