@pirireis/webglobeplugins 0.8.18 → 0.8.20
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 +11 -5
- package/Math/vector3d.ts +2 -0
- package/package.json +1 -1
- package/tests/Math/arc.test.ts +22 -0
- package/waveparticles/plugin.js +5 -5
package/Math/arc.ts
CHANGED
|
@@ -79,8 +79,6 @@ export class Arc {
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
// TODO: EDGE CASE: the points are on same location
|
|
84
82
|
intersectionMedium(medium: Plane, target: Arc | null = null): Arc | null {
|
|
85
83
|
// Orianted in right hand rule
|
|
86
84
|
if (this.pointA.equals(this.pointB)) return null; // arc is too short
|
|
@@ -97,6 +95,10 @@ export class Arc {
|
|
|
97
95
|
return null; // no intersection
|
|
98
96
|
}
|
|
99
97
|
|
|
98
|
+
// think as this.pointA is on y=1 on a x-y space. this.pointB is on the x>0 part of the space.
|
|
99
|
+
// any point on x<0 is outside. Any point y<this._dot is outside.
|
|
100
|
+
|
|
101
|
+
// A is before B with right hand rule
|
|
100
102
|
const [A, B] = (() => {
|
|
101
103
|
Vector3D.crossVectors(...intersectionPoints, _AxB);
|
|
102
104
|
if (_AxB.dot(this._AxB) >= 0) {
|
|
@@ -109,8 +111,7 @@ export class Arc {
|
|
|
109
111
|
|
|
110
112
|
Vector3D.crossVectors(this.pointA, A, _A_x_otherA);
|
|
111
113
|
Vector3D.crossVectors(this.pointA, B, _A_x_otherB);
|
|
112
|
-
|
|
113
|
-
// any point on x<0 is outside. Any point y<this._dot is outside.
|
|
114
|
+
|
|
114
115
|
const _yA = this.pointA.dot(A);
|
|
115
116
|
const _yB = this.pointA.dot(B);
|
|
116
117
|
|
|
@@ -119,6 +120,9 @@ export class Arc {
|
|
|
119
120
|
|
|
120
121
|
|
|
121
122
|
if (_xA < 0 && _xB < 0) {
|
|
123
|
+
if (_yA > _yB) {
|
|
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
|
+
}
|
|
122
126
|
return null; // no intersection
|
|
123
127
|
}
|
|
124
128
|
if (_yA < this._dot && _yB < this._dot) {
|
|
@@ -131,8 +135,10 @@ export class Arc {
|
|
|
131
135
|
];
|
|
132
136
|
if (target === null) {
|
|
133
137
|
target = new Arc(...resultPoints);
|
|
134
|
-
} else {
|
|
138
|
+
} else if (target instanceof Arc) {
|
|
135
139
|
target.setFromUnitVectors(...resultPoints);
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error("target is not null or an Arc instance");
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
return target;
|
package/Math/vector3d.ts
CHANGED
package/package.json
CHANGED
package/tests/Math/arc.test.ts
CHANGED
|
@@ -47,6 +47,28 @@ test("intersectionMedium 2 - single point arc", () => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
|
|
50
|
+
describe(`intersectionMedium 3 - return full arc`, () => {
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < 100; i++) {
|
|
53
|
+
test(`intersectionMedium 3 - return full arc ${i} `, () => {
|
|
54
|
+
_medium.set(new Vector3D(0, 0, 1), 0.001);
|
|
55
|
+
_0vector.randomUnit();
|
|
56
|
+
_0vector.z = Math.abs(_0vector.z);
|
|
57
|
+
_1vector.randomUnit();
|
|
58
|
+
_1vector.z = Math.abs(_1vector.z);
|
|
59
|
+
_0arc.setFromUnitVectors(_0vector, _1vector);
|
|
60
|
+
|
|
61
|
+
const _1arc = _0arc.intersectionMedium(_medium)!;
|
|
62
|
+
if (_1arc === null) {
|
|
63
|
+
console.log(_0arc, _medium);
|
|
64
|
+
}
|
|
65
|
+
expect(_1arc !== null).toBeTruthy();
|
|
66
|
+
expect(_0arc.equals(_1arc)).toBeTruthy();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
50
72
|
test(" populatePoints3D", () => {
|
|
51
73
|
|
|
52
74
|
});
|
package/waveparticles/plugin.js
CHANGED
|
@@ -20,7 +20,7 @@ const MAX_PIXELS_ON_DIMENSION = 2200;
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
export default class Plugin {
|
|
23
|
-
constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000,
|
|
23
|
+
constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000, flipY = true, drawTextureMaxPixelOnDimension = MAX_PIXELS_ON_DIMENSION } = {}) {
|
|
24
24
|
|
|
25
25
|
this.id = id;
|
|
26
26
|
this.globe = null;
|
|
@@ -31,7 +31,6 @@ export default class Plugin {
|
|
|
31
31
|
this._rgVectorFieldTexture = null;
|
|
32
32
|
this.globeShellWiggle = null;
|
|
33
33
|
this.waveUbo = null;
|
|
34
|
-
this._flipX = flipX;
|
|
35
34
|
this._flipY = flipY;
|
|
36
35
|
this._drawTextureResolution = {};
|
|
37
36
|
this._frameBuffer = null;
|
|
@@ -86,6 +85,7 @@ export default class Plugin {
|
|
|
86
85
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
87
86
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
88
87
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
88
|
+
|
|
89
89
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
90
90
|
return texture;
|
|
91
91
|
}
|
|
@@ -147,7 +147,7 @@ export default class Plugin {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
_createRGTexture() {
|
|
150
|
-
const { gl, _dataWidth, _dataHeight,
|
|
150
|
+
const { gl, _dataWidth, _dataHeight, } = this;
|
|
151
151
|
const texture = gl.createTexture();
|
|
152
152
|
// R32F
|
|
153
153
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
@@ -156,8 +156,8 @@ export default class Plugin {
|
|
|
156
156
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
157
157
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
158
158
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
159
|
-
gl.pixelStorei(gl.
|
|
160
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,
|
|
159
|
+
// gl.pixelStorei(gl.UNPACK_FLIP_X_WEBGL, this._flipX);
|
|
160
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
|
|
161
161
|
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
162
162
|
return texture;
|
|
163
163
|
}
|