@pirireis/webglobeplugins 0.9.13 → 0.9.15
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/package.json +1 -1
- package/programs/index.js +1 -1
- package/programs/line-on-globe/linestrip.js +1 -1
- package/programs/vectorfields/logics/drawrectangleparticles.js +7 -13
- package/programs/vectorfields/logics/index.js +1 -3
- package/programs/vectorfields/logics/pixelbased.js +7 -16
- package/util/webglobjectbuilders.js +13 -20
- package/waveparticles/plugin.js +14 -9
package/package.json
CHANGED
package/programs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { GlobeShellWiggle } from "./globeshell/wiggle";
|
|
|
3
3
|
import { CameraUniformBlockTotem, CameraUniformBlockString } from "./totems/index";
|
|
4
4
|
import ArrowField from "./arrowfield";
|
|
5
5
|
import { glProgramCache, globeProgramCache, noRegisterGlobeProgramCache } from "./programcache";
|
|
6
|
-
import * as vectorfield from "./vectorfields";
|
|
6
|
+
import * as vectorfield from "./vectorfields/index";
|
|
7
7
|
import { FadeAway } from "./helpers";
|
|
8
8
|
import * as rings from "./rings";
|
|
9
9
|
export { Float2LegendWithRatio, GlobeShellWiggle, ArrowField, CameraUniformBlockTotem, CameraUniformBlockString, glProgramCache, globeProgramCache, noRegisterGlobeProgramCache, vectorfield, FadeAway, rings };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createProgram } from "../../util/webglobjectbuilders";
|
|
2
2
|
import "../interface";
|
|
3
|
-
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems";
|
|
3
|
+
import { CameraUniformBlockString, CameraUniformBlockTotemCache } from "../totems/index";
|
|
4
4
|
import { cartesian3DToGLPosition, mercatorXYToGLPosition, } from "../../util/shaderfunctions/geometrytransformations.js";
|
|
5
5
|
import { noRegisterGlobeProgramCache } from "../programcache";
|
|
6
6
|
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
@@ -88,17 +88,11 @@ class Logic {
|
|
|
88
88
|
this.program = null;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.logic.draw(bufferManager, vectorTexture, uboManager);
|
|
91
|
+
export const drawRectangleParticlesProgramCache = Object.freeze({
|
|
92
|
+
getProgram: (gl) => {
|
|
93
|
+
return glProgramCache.getProgram(gl, Logic);
|
|
94
|
+
},
|
|
95
|
+
releaseProgram: (gl) => {
|
|
96
|
+
glProgramCache.releaseProgram(gl, Logic);
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
glProgramCache.releaseProgram(this.gl, Logic);
|
|
101
|
-
this.logic = null;
|
|
102
|
-
this.gl = null;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
98
|
+
});
|
|
@@ -120,20 +120,11 @@ class Logic {
|
|
|
120
120
|
return this.gl.getAttribLocation(this.program, 'in_position');
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
export
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.logic.move(bufferManager, vectorTexture, uboManager);
|
|
130
|
-
}
|
|
131
|
-
free() {
|
|
132
|
-
glProgramCache.releaseProgram(this.gl, Logic);
|
|
133
|
-
this.program = null;
|
|
134
|
-
this.gl = null;
|
|
123
|
+
export const pixelBasedMoveProgramCache = Object.freeze({
|
|
124
|
+
getProgram: (gl) => {
|
|
125
|
+
return glProgramCache.getProgram(gl, Logic);
|
|
126
|
+
},
|
|
127
|
+
releaseProgram: (gl) => {
|
|
128
|
+
glProgramCache.releaseProgram(gl, Logic);
|
|
135
129
|
}
|
|
136
|
-
|
|
137
|
-
return this.logic.getInPositionLocation();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
130
|
+
});
|
|
@@ -241,14 +241,7 @@ export function getColorRamp(colors) {
|
|
|
241
241
|
canvas.height = 1;
|
|
242
242
|
const gradient = ctx.createLinearGradient(0, 0, 256, 0);
|
|
243
243
|
for (const stop in colors) {
|
|
244
|
-
|
|
245
|
-
// explicit conversion is safer for object keys if they come from arbitrary sources.
|
|
246
|
-
const stopValue = parseFloat(stop);
|
|
247
|
-
if (isNaN(stopValue)) {
|
|
248
|
-
console.warn(`Invalid stop value for color ramp: ${stop}. Skipping.`);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
gradient.addColorStop(stopValue, colors[stop]);
|
|
244
|
+
gradient.addColorStop(colors[stop][0], colors[stop][1]);
|
|
252
245
|
}
|
|
253
246
|
ctx.fillStyle = gradient;
|
|
254
247
|
ctx.fillRect(0, 0, 256, 1);
|
|
@@ -328,18 +321,18 @@ export function getColorRampModed(values, thresholds, mode = "interpolated") {
|
|
|
328
321
|
* @returns A Uint8Array representing the RGBA pixel data of the default 1x256 color ramp.
|
|
329
322
|
*/
|
|
330
323
|
export function defaultColorRamp() {
|
|
331
|
-
const defaultRampColors =
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
324
|
+
const defaultRampColors = [
|
|
325
|
+
[0.0, '#5e4fa2'],
|
|
326
|
+
[0.15, '#3288bd'],
|
|
327
|
+
[0.20, '#66c2a5'],
|
|
328
|
+
[0.25, '#66c2a5'],
|
|
329
|
+
[0.3, '#abdda4'],
|
|
330
|
+
[0.4, '#e6f598'],
|
|
331
|
+
[0.5, '#fee08b'],
|
|
332
|
+
[0.6, '#fdae61'],
|
|
333
|
+
[0.7, '#f46d43'],
|
|
334
|
+
[1.0, '#ff1e13']
|
|
335
|
+
];
|
|
343
336
|
return getColorRamp(defaultRampColors);
|
|
344
337
|
}
|
|
345
338
|
/**
|
package/waveparticles/plugin.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GlobeShellWiggle } from "../programs";
|
|
2
2
|
import { defaultblendfunction } from "../util";
|
|
3
|
-
import { vectorfield } from "../programs";
|
|
3
|
+
import { vectorfield } from "../programs/index";
|
|
4
|
+
import { pixelBasedMoveProgramCache } from "../programs/vectorfields/logics/pixelbased";
|
|
5
|
+
import { drawRectangleParticlesProgramCache } from "../programs/vectorfields/logics/drawrectangleparticles";
|
|
4
6
|
import { FadeAway } from "../programs";
|
|
5
|
-
const {
|
|
6
|
-
const MoveParticle = PixelBasedMove;
|
|
7
|
-
const DrawParticle = DrawRectangleParticles;
|
|
7
|
+
const { PingPongBufferManager, WaveParticalUboManager } = vectorfield;
|
|
8
8
|
/**
|
|
9
9
|
* STEPS:
|
|
10
10
|
* 1. move particle | buffers: read b1 write b2 | swap buffers b1 <-> b2
|
|
@@ -47,8 +47,8 @@ export default class Plugin {
|
|
|
47
47
|
init(globe, gl) {
|
|
48
48
|
this.globe = globe;
|
|
49
49
|
this.gl = gl;
|
|
50
|
-
this.moveParticle =
|
|
51
|
-
this.drawParticle =
|
|
50
|
+
this.moveParticle = pixelBasedMoveProgramCache.getProgram(gl);
|
|
51
|
+
this.drawParticle = drawRectangleParticlesProgramCache.getProgram(gl);
|
|
52
52
|
this.fadeAway = new FadeAway(gl);
|
|
53
53
|
this.globeShellWiggle = new GlobeShellWiggle(gl, globe, this._globeshellparameters);
|
|
54
54
|
const inPositionLocation = this.moveParticle.getInPositionLocation();
|
|
@@ -142,16 +142,21 @@ export default class Plugin {
|
|
|
142
142
|
}
|
|
143
143
|
// TODO: free all resources
|
|
144
144
|
free() {
|
|
145
|
-
|
|
145
|
+
if (this._isFreed) {
|
|
146
|
+
console.warn("WaveParticle plugin is already freed");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
;
|
|
146
150
|
this._isFreed = true;
|
|
151
|
+
const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
|
|
147
152
|
fadeAway.free();
|
|
148
153
|
globeShellWiggle.free();
|
|
149
154
|
gl.deleteTexture(_rgVectorFieldTexture);
|
|
150
155
|
// glProgramCache.releaseProgram(gl, MoveParticle);
|
|
151
|
-
|
|
156
|
+
pixelBasedMoveProgramCache.getProgram(gl);
|
|
152
157
|
this.moveParticle = null;
|
|
153
158
|
// glProgramCache.releaseProgram(gl, DrawParticle);
|
|
154
|
-
|
|
159
|
+
drawRectangleParticlesProgramCache.getProgram(gl);
|
|
155
160
|
this.drawParticle = null;
|
|
156
161
|
bufferManager.free();
|
|
157
162
|
waveUbo.free();
|