@pirireis/webglobeplugins 0.8.15-alpha → 0.8.18

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.
@@ -0,0 +1,52 @@
1
+
2
+
3
+
4
+
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
+
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
+
17
+ }
18
+
19
+
20
+
21
+
22
+
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
+
29
+ }
30
+
31
+
32
+
33
+ deleteArc(id: Arc['id']) {
34
+ this._arcToCutsManager.deleteArc(id);
35
+ }
36
+
37
+
38
+ queryBBox(bbox: BBox) {
39
+
40
+ const arcIDSet = new Set(this._rbush.query(bbox).map(x => x.id)); // sets Of ids of arcs
41
+
42
+ // arcs U bbox => arcs
43
+
44
+
45
+ // populate points
46
+ // return typed array of points belonging to all the arcs of cuts
47
+ }
48
+
49
+
50
+
51
+
52
+ }
File without changes
@@ -0,0 +1,27 @@
1
+ type BBox = {
2
+ minX: number;
3
+ minY: number;
4
+ maxX: number;
5
+ maxY: number;
6
+ id?: string;
7
+ }
8
+
9
+ type Point = { lon: number, lat: number };
10
+ type Vector = [number, number, number]; // x y z
11
+
12
+
13
+ type Arc = {
14
+ id: string;
15
+ start: number[];
16
+ end: number[];
17
+ };
18
+
19
+
20
+ interface RBUSH {
21
+ insert: (item: BBox) => void;
22
+ remove: (item: BBox) => void;
23
+ search: (bbox: BBox) => BBox[];
24
+ clear: () => void;
25
+ all: () => BBox[];
26
+
27
+ }
File without changes
@@ -20,7 +20,7 @@ const MAX_PIXELS_ON_DIMENSION = 2200;
20
20
 
21
21
 
22
22
  export default class Plugin {
23
- constructor(id, { fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000, dataWidth, dataHeight, drawTextureMaxPixelOnDimension = MAX_PIXELS_ON_DIMENSION } = {}) {
23
+ constructor(id, { dataWidth, dataHeight, fadeOpacity = 0.83, opacity = 0.75, minLon = -180, minLat = -90, maxLon = 180, maxLat = 90, patricleCount = 8000, flipX = false, flipY = true, drawTextureMaxPixelOnDimension = MAX_PIXELS_ON_DIMENSION } = {}) {
24
24
 
25
25
  this.id = id;
26
26
  this.globe = null;
@@ -31,6 +31,8 @@ export default class Plugin {
31
31
  this._rgVectorFieldTexture = null;
32
32
  this.globeShellWiggle = null;
33
33
  this.waveUbo = null;
34
+ this._flipX = flipX;
35
+ this._flipY = flipY;
34
36
  this._drawTextureResolution = {};
35
37
  this._frameBuffer = null;
36
38
  this._fadeOpacity = fadeOpacity;
@@ -145,7 +147,7 @@ export default class Plugin {
145
147
  }
146
148
 
147
149
  _createRGTexture() {
148
- const { gl, _dataWidth, _dataHeight } = this;
150
+ const { gl, _dataWidth, _dataHeight, flipX, flipY } = this;
149
151
  const texture = gl.createTexture();
150
152
  // R32F
151
153
  gl.bindTexture(gl.TEXTURE_2D, texture);
@@ -154,8 +156,8 @@ export default class Plugin {
154
156
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
155
157
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
156
158
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
157
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
158
-
159
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipX);
160
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
159
161
  gl.bindTexture(gl.TEXTURE_2D, null);
160
162
  return texture;
161
163
  }
@@ -186,11 +188,12 @@ export default class Plugin {
186
188
  }
187
189
 
188
190
 
189
- setVectorFieldData(data, dataWidth = null, dataHeight = null) {
191
+ setVectorFieldData(data, { dataWidth = null, dataHeight = null } = {}) {
190
192
  if (dataWidth !== null && dataHeight !== null) {
191
193
  this._dataWidth = dataWidth;
192
194
  this._dataHeight = dataHeight;
193
195
  }
196
+
194
197
  const { gl, _dataWidth, _dataHeight } = this;
195
198
  gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
196
199
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
@@ -253,7 +256,7 @@ export default class Plugin {
253
256
 
254
257
  setParticleDimensions(tail, wing) {
255
258
  if (0 < tail || 0 < wing) {
256
- this.waveUbo.update({ base_limp: [tail, wing] });
259
+ this.waveUbo.update({ tail_wing_base_limp: [tail, wing] });
257
260
  } else {
258
261
  console.error("tail and wing must be greater than 0");
259
262
  }
@@ -1,10 +0,0 @@
1
- export function testWebWorker() {
2
-
3
- const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
4
- worker.onmessage = (event) => {
5
- console.log(event.data);
6
- worker.terminate();
7
- };
8
- worker.postMessage("sumBigNumber");
9
- return worker;
10
- }
@@ -1,10 +0,0 @@
1
- export function sumBigNumber() {
2
- let sum = 0n;
3
- let length = 1000000n;
4
- let i = 0n;
5
- while (i < length) {
6
- sum += i;
7
- i++;
8
- }
9
- return sum;
10
- }
@@ -1,8 +0,0 @@
1
- import { sumBigNumber } from "./module";
2
-
3
- /* eslint-disable-next-line no-restricted-globals */
4
- self.onmessage = (event) => {
5
- const result = sumBigNumber();
6
- /* eslint-disable-next-line no-restricted-globals */
7
- self.postMessage(result);
8
- }