@pirireis/webglobeplugins 0.8.22 → 0.8.24
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/Math/arc.ts +6 -4
- package/Math/plane.ts +1 -1
- package/Math/vector3d.ts +9 -0
- package/package.json +1 -1
- package/surface-cover-shapes/arc/naive/data-manager.ts +0 -0
- package/surface-cover-shapes/arc/naive/plugin.ts +0 -0
- package/tests/Math/arc.test.ts +51 -13
- package/tests/Math/vector3d.test.ts +33 -0
- package/util/surface-line-data/arc-bboxes.ts +24 -24
- package/util/surface-line-data/flow.ts +27 -27
- package/waveparticles/plugin.js +5 -1
- package/wind/plugin.js +9 -7
package/Math/arc.ts
CHANGED
|
@@ -115,8 +115,8 @@ export class Arc {
|
|
|
115
115
|
const _yA = this.pointA.dot(A);
|
|
116
116
|
const _yB = this.pointA.dot(B);
|
|
117
117
|
|
|
118
|
-
const _xA = _A_x_otherA.dot(this._AxB)
|
|
119
|
-
const _xB = _A_x_otherB.dot(this.
|
|
118
|
+
const _xA = _A_x_otherA.dot(this._imageinaryPlane.normal); // this._AxB.normalize() == this._imageinaryPlane.normal
|
|
119
|
+
const _xB = _A_x_otherB.dot(this._imageinaryPlane.normal);
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
if (_xA < 0 && _xB < 0) {
|
|
@@ -124,11 +124,11 @@ export class Arc {
|
|
|
124
124
|
throw new Error("A is before B with right hand rule but A is on the left side of the arc. This should not happen.");
|
|
125
125
|
}
|
|
126
126
|
return null; // no intersection
|
|
127
|
-
}
|
|
128
|
-
if (_yA < this._dot && _yB < this._dot) {
|
|
127
|
+
} else if (_xA > 0 && _xB > 0 && _yA < this._dot && _yB < this._dot) {
|
|
129
128
|
return null; // no intersection
|
|
130
129
|
}
|
|
131
130
|
|
|
131
|
+
|
|
132
132
|
const resultPoints: [Vector3D, Vector3D] = [
|
|
133
133
|
_xA < 0 ? this.pointA.clone() : A,
|
|
134
134
|
_yB <= this._dot ? this.pointB.clone() : B
|
|
@@ -186,6 +186,8 @@ export class Arc {
|
|
|
186
186
|
|
|
187
187
|
return points3D;
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
|
|
189
191
|
// cutBoundingBoxes(dotStep: number = 0.025): { minX: number, minY: number, maxX: number, maxY: number }[] {
|
|
190
192
|
// const pointA = this.pointA;
|
|
191
193
|
// const to = this.pointB;
|
package/Math/plane.ts
CHANGED
|
@@ -107,7 +107,7 @@ export class Plane {
|
|
|
107
107
|
static fromGlobeLookInfo(centerLongitude: Radians, centerLatitude: Radians, distance: Meter, target: Plane): boolean {
|
|
108
108
|
const radiansAngle = Math.PI * distance / WORLD_RADIUS_MERCATOR;
|
|
109
109
|
target.normal.setFromLonLat(centerLongitude, centerLatitude).normalize();
|
|
110
|
-
target.constant =
|
|
110
|
+
target.constant = Math.cos(radiansAngle);
|
|
111
111
|
return true;
|
|
112
112
|
}
|
|
113
113
|
|
package/Math/vector3d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export class Vector3D implements IVector3D {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
angle(other: Vector3D): number {
|
|
62
|
+
const a = this.length();
|
|
63
|
+
const b = other.length();
|
|
64
|
+
const c = this.dot(other);
|
|
65
|
+
const angle = Math.acos(c / (a * b));
|
|
66
|
+
|
|
67
|
+
return isNaN(angle) ? 0 : angle;
|
|
68
|
+
}
|
|
69
|
+
|
|
61
70
|
lerpVectors(a: Vector3D, b: Vector3D, t: number): Vector3D {
|
|
62
71
|
this.x = a.x + (b.x - a.x) * t;
|
|
63
72
|
this.y = a.y + (b.y - a.y) * t;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
package/tests/Math/arc.test.ts
CHANGED
|
@@ -48,27 +48,65 @@ test("intersectionMedium 2 - single point arc", () => {
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
describe(`intersectionMedium 3 - return full arc`, () => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
_medium.set(new Vector3D(0, 0, 1), 0
|
|
51
|
+
let i = 0;
|
|
52
|
+
test(`intersectionMedium 3 - return full arc ${i} `, () => {
|
|
53
|
+
for (let i = 0; i < 100; i++) {
|
|
54
|
+
_medium.set(new Vector3D(0, 0, 1), 0);
|
|
55
55
|
_0vector.randomUnit();
|
|
56
|
-
_0vector.z = Math.abs(_0vector.z);
|
|
56
|
+
_0vector.z = Math.abs(_0vector.z); // make sure point is above the plane
|
|
57
57
|
_1vector.randomUnit();
|
|
58
|
-
_1vector.z = Math.abs(_1vector.z);
|
|
58
|
+
_1vector.z = Math.abs(_1vector.z); // make sure point is above the plane
|
|
59
|
+
expect(Math.abs(_0vector.length() - 1) < 0.0001).toBeTruthy();
|
|
60
|
+
expect(Math.abs(_1vector.length() - 1) < 0.0001).toBeTruthy();
|
|
59
61
|
_0arc.setFromUnitVectors(_0vector, _1vector);
|
|
60
62
|
|
|
61
63
|
const _1arc = _0arc.intersectionMedium(_medium)!;
|
|
62
|
-
if (_1arc === null) {
|
|
63
|
-
|
|
64
|
-
}
|
|
64
|
+
// if (_1arc === null) {
|
|
65
|
+
// console.log(_0arc, _medium);
|
|
66
|
+
// }
|
|
65
67
|
expect(_1arc !== null).toBeTruthy();
|
|
66
68
|
expect(_0arc.equals(_1arc)).toBeTruthy();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
describe(`intersectionMedium 4 - return half arc`, () => {
|
|
75
|
+
let i = 0;
|
|
76
|
+
test(`intersectionMedium 4 - return half arc ${i} `, () => {
|
|
77
|
+
for (let i = 0; i < 100; i++) {
|
|
78
|
+
_medium.set(new Vector3D(0, 0, 1), 0);
|
|
79
|
+
|
|
80
|
+
_0vector.randomUnit();
|
|
81
|
+
_1vector.copy(_0vector);
|
|
82
|
+
_1vector.z *= -1;
|
|
83
|
+
|
|
84
|
+
expect(Math.abs(_0vector.length() - 1) < 0.0001).toBeTruthy();
|
|
85
|
+
expect(Math.abs(_1vector.length() - 1) < 0.0001).toBeTruthy();
|
|
86
|
+
_0arc.setFromUnitVectors(_0vector, _1vector);
|
|
87
|
+
|
|
88
|
+
const _1arc = _0arc.intersectionMedium(_medium)!;
|
|
89
|
+
// if (_1arc === null) {
|
|
90
|
+
// console.log(_0arc, _medium);
|
|
91
|
+
// }
|
|
92
|
+
expect(_1arc !== null).toBeTruthy();
|
|
93
|
+
|
|
94
|
+
expect([_1arc.pointA.z, _1arc.pointB.z].some((v) => v === 0)).toBeTruthy();
|
|
95
|
+
|
|
96
|
+
// expect(_0arc.equals(_1arc)).toBeTruthy();
|
|
97
|
+
}
|
|
98
|
+
});
|
|
69
99
|
});
|
|
70
100
|
|
|
71
101
|
|
|
72
|
-
test(" populatePoints3D", () => {
|
|
73
102
|
|
|
74
|
-
|
|
103
|
+
test("populatePoints3D 1", () => {
|
|
104
|
+
_0arc.setFromUnitVectors(new Vector3D(0, 1, 0), new Vector3D(0, 1, 0));
|
|
105
|
+
const result = _0arc.populatePoints3D(10);
|
|
106
|
+
expect(result.length).toBe(10 * 3);
|
|
107
|
+
_0vector.set(result[0], result[1], result[2]);
|
|
108
|
+
expect(_0vector.equals(_0arc.pointA)).toBeTruthy();
|
|
109
|
+
_0vector.set(result[27 + 0], result[27 + 1], result[27 + 2]);
|
|
110
|
+
expect(_0vector.equals(_0arc.pointB)).toBeTruthy();
|
|
111
|
+
});
|
|
112
|
+
|
|
@@ -69,3 +69,36 @@ test('cross same and negated', () => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
|
|
72
|
+
// console.log
|
|
73
|
+
// A Vector3D { x: 0.6389419688270773, y: -0.7692549385420794, z: 0 } B Vector3D { x: -0.6389419688270773, y: 0.7692549385420794, z: 0 } this.A Vector3D {
|
|
74
|
+
// x: -0.6002207824512262,
|
|
75
|
+
// y: -0.4133184680372552,
|
|
76
|
+
// z: 0.6847648182354102
|
|
77
|
+
// }
|
|
78
|
+
|
|
79
|
+
// at Arc.intersectionMedium(src / webglobeplugins / Math / arc.ts: 111: 17)
|
|
80
|
+
|
|
81
|
+
// console.log
|
|
82
|
+
// y < this._dot - 0.0655589757420102 0.0655589757420102 0.8489202601389976
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
test('negated dot', () => {
|
|
86
|
+
const A = _0vector.randomUnit().clone();
|
|
87
|
+
const B = _0vector.randomUnit();
|
|
88
|
+
|
|
89
|
+
const result = A.dot(B);
|
|
90
|
+
const result2 = A.dot(B.negate());
|
|
91
|
+
expect(result).toBe(-result2);
|
|
92
|
+
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
test('cross', () => {
|
|
99
|
+
const A = _0vector.randomUnit().clone();
|
|
100
|
+
const B = _0vector.randomUnit();
|
|
101
|
+
const result = A.cross(B);
|
|
102
|
+
expect(result.equals(new Vector3D(0, 0, 0))).toBe(false);
|
|
103
|
+
expect(result.length()).toBeCloseTo(A.length() * B.length() * Math.sin(A.angle(B)), 1e-6);
|
|
104
|
+
});
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
function naiveBBox(a: number[], b: number[]): BBox {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
// function naiveBBox(a: number[], b: number[]): BBox {
|
|
4
|
+
// return {
|
|
5
|
+
// minX: Math.min(a[0], b[0]),
|
|
6
|
+
// minY: Math.min(a[1], b[1]),
|
|
7
|
+
// maxX: Math.max(a[0], b[0]),
|
|
8
|
+
// maxY: Math.max(a[1], b[1])
|
|
9
|
+
// };
|
|
10
10
|
|
|
11
|
-
}
|
|
11
|
+
// }
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
function slerp(a: Vector, b: Vector, t: number, theta: number, sinTheta: number): Vector {
|
|
14
|
+
// function slerp(a: Vector, b: Vector, t: number, theta: number, sinTheta: number): Vector {
|
|
15
15
|
|
|
16
|
-
}
|
|
16
|
+
// }
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
function getArcBBoxes(arc: Arc, dotStep: number = 0.025): BBox[] {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
// function getArcBBoxes(arc: Arc, dotStep: number = 0.025): BBox[] {
|
|
20
|
+
// const start = arc.start;
|
|
21
|
+
// const end = arc.end;
|
|
22
|
+
// const a = [start[0], start[1], start[2]];
|
|
23
|
+
// const b = [end[0], end[1], end[2]];
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// const theta = Math.acos(a[0] * b[0] + a[1] * b[1] + a[2] * b[2]);
|
|
29
|
+
// const step = dotStep / theta;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// if (step >= 1) {
|
|
32
|
+
// return [naiveBBox(start, end)];
|
|
33
|
+
// }
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
// let points = [start] as Vector[];
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
// let currentStep =
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
}
|
|
41
|
+
// return bbox;
|
|
42
|
+
// }
|
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class FlowManager {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
// class FlowManager {
|
|
6
|
+
// _populateCount: number;
|
|
7
|
+
// _rbush: RBush<any>;
|
|
8
|
+
// _arcToCutsManager: ArcToCutsManager;
|
|
9
|
+
// consturctor({ populateCount = 36, dotDistanceOfArcCuts = 1 / Math.pow(2, 10 - 1) }) {
|
|
10
|
+
// this._populateCount = populateCount;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// // does the cutting and id mapping(one to many)
|
|
13
|
+
// // cuts have their bbox ready for rbush
|
|
14
|
+
// this._rbush = new RBush(1000);
|
|
15
|
+
// this._arcToCutsManager = new ArcToCutsManager({ dotDistanceOfArcCuts, rbush: this._rbush }); // 10km
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// }
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// /**
|
|
24
|
+
// * adds or updates an arc in the rbush and the cuts manager
|
|
25
|
+
// */
|
|
26
|
+
// insertArc(arc: Arc) {
|
|
27
|
+
// this._arcToCutsManager.insertArc(arc);
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
// }
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// deleteArc(id: Arc['id']) {
|
|
34
|
+
// this._arcToCutsManager.deleteArc(id);
|
|
35
|
+
// }
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
// queryBBox(bbox: BBox) {
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// const arcIDSet = new Set(this._rbush.query(bbox).map(x => x.id)); // sets Of ids of arcs
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
// // arcs U bbox => arcs
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
// // populate points
|
|
46
|
+
// // return typed array of points belonging to all the arcs of cuts
|
|
47
|
+
// }
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
}
|
|
52
|
+
// }
|
package/waveparticles/plugin.js
CHANGED
|
@@ -191,17 +191,21 @@ export default class Plugin {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
|
|
194
|
-
setVectorFieldData(data, { dataWidth = null, dataHeight = null } = {}) {
|
|
194
|
+
setVectorFieldData(data, { dataWidth = null, dataHeight = null, flipY } = {}) {
|
|
195
195
|
if (dataWidth !== null && dataHeight !== null) {
|
|
196
196
|
this._dataWidth = dataWidth;
|
|
197
197
|
this._dataHeight = dataHeight;
|
|
198
198
|
}
|
|
199
|
+
if (flipY !== undefined) {
|
|
200
|
+
this._flipY = flipY;
|
|
201
|
+
}
|
|
199
202
|
this.__data = data;
|
|
200
203
|
const { gl, _dataWidth, _dataHeight } = this;
|
|
201
204
|
gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
|
|
202
205
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
203
206
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
|
|
204
207
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
208
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
|
package/wind/plugin.js
CHANGED
|
@@ -605,11 +605,8 @@ export default class WindPlugin {
|
|
|
605
605
|
|
|
606
606
|
gl.useProgram(currentProgram);
|
|
607
607
|
|
|
608
|
-
if (this.coordinatesDataCalculator) {
|
|
609
|
-
const magnitude = imageToMagnitude(windData);
|
|
610
|
-
this.coordinatesDataCalculator.updateData(0, magnitude, magnitude);
|
|
611
608
|
|
|
612
|
-
|
|
609
|
+
this._setCoorcinatesDataCalculatorData();
|
|
613
610
|
this.resize();
|
|
614
611
|
}
|
|
615
612
|
|
|
@@ -640,10 +637,15 @@ export default class WindPlugin {
|
|
|
640
637
|
|
|
641
638
|
|
|
642
639
|
_createPointCoordinatesDataCalculator() {
|
|
643
|
-
if (!this.windData) {
|
|
644
|
-
throw new Error("wind plugin. _createPointCoordinatesDataCalculator is called before wind data is set.");
|
|
645
|
-
}
|
|
646
640
|
this.coordinatesDataCalculator = new PointCoordinatesDataCalculator(this.windData.bbox, this.windData.width, this.windData.height);
|
|
641
|
+
this._setCoorcinatesDataCalculatorData();
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
_setCoorcinatesDataCalculatorData() {
|
|
646
|
+
if (!this.windData || !this.coordinatesDataCalculator) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
647
649
|
const magnitude = imageToMagnitude(this.windData);
|
|
648
650
|
this.coordinatesDataCalculator.updateData(0, magnitude, magnitude);
|
|
649
651
|
}
|