@pirireis/webglobeplugins 0.8.6 → 0.8.7

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.
Files changed (61) hide show
  1. package/bearing-line/plugin.js +51 -43
  2. package/circle-line-chain/plugin.js +52 -44
  3. package/compass-rose/compass-rose-padding-flat.js +3 -0
  4. package/compassrose/compassrose.js +1 -8
  5. package/heatwave/isobar/plugin.js +4 -1
  6. package/heatwave/isobar/quadtreecontours.js +0 -2
  7. package/heatwave/plugins/heatwaveglobeshell.js +2 -0
  8. package/package.json +1 -1
  9. package/partialrings/goals.md +2 -0
  10. package/partialrings/plugin.js +2 -1
  11. package/point-glow-line-to-earth/draw-subset-obj.js +27 -0
  12. package/point-glow-line-to-earth/keymethod.js +0 -0
  13. package/point-glow-line-to-earth/plugin.js +439 -0
  14. package/point-glow-line-to-earth/types.js +26 -0
  15. package/point-heat-map/index.js +0 -3
  16. package/point-heat-map/plugin-webworker.js +4 -9
  17. package/point-heat-map/point-to-heat-map-flow.js +0 -6
  18. package/point-tracks/plugin.js +4 -4
  19. package/programs/arrowfield/logic.js +6 -4
  20. package/programs/arrowfield/object.js +1 -1
  21. package/programs/float2legendwithratio/object.js +5 -4
  22. package/programs/globe-util/is-globe-moved.js +27 -0
  23. package/programs/globeshell/wiggle/logic.js +3 -7
  24. package/programs/globeshell/wiggle/object.js +1 -2
  25. package/programs/line-on-globe/circle-accurate-3d.js +16 -23
  26. package/programs/line-on-globe/circle-accurate-flat.js +21 -21
  27. package/programs/line-on-globe/lines-color-instanced-flat.js +6 -7
  28. package/programs/line-on-globe/naive-accurate-flexible.js +239 -0
  29. package/programs/line-on-globe/to-the-surface.js +129 -0
  30. package/programs/picking/pickable-renderer.js +216 -0
  31. package/programs/point-on-globe/element-globe-surface-glow.js +168 -0
  32. package/programs/point-on-globe/element-point-glow.js +184 -0
  33. package/programs/point-on-globe/square-pixel-point.js +2 -4
  34. package/programs/programcache.js +9 -0
  35. package/programs/rings/partial-ring/piece-of-pie.js +1 -1
  36. package/programs/totems/camerauniformblock.js +23 -2
  37. package/rangerings/plugin.js +9 -6
  38. package/shaders/fragment-toy/firework.js +55 -0
  39. package/shaders/fragment-toy/singularity.js +59 -0
  40. package/types.js +16 -0
  41. package/util/account/single-attribute-buffer-management/buffer-manager.js +1 -5
  42. package/util/account/util.js +17 -7
  43. package/util/check/typecheck.js +11 -0
  44. package/util/gl-util/buffer/integrate-buffer.js +74 -0
  45. package/util/gl-util/draw-options/client.js +59 -0
  46. package/util/gl-util/draw-options/methods.js +46 -0
  47. package/util/gl-util/draw-options/types.js +18 -0
  48. package/util/gl-util/uniform-block/manager.js +176 -0
  49. package/util/gl-util/uniform-block/roadmap.md +70 -0
  50. package/util/gl-util/uniform-block/shader.js +0 -0
  51. package/util/gl-util/uniform-block/types.js +7 -0
  52. package/util/jshelpers/equality.js +17 -0
  53. package/util/picking/picker-displayer.js +1 -1
  54. package/util/programs/shapesonglobe.js +17 -19
  55. package/util/shaderfunctions/geometrytransformations.js +27 -63
  56. package/bearing-line/roadmap.md +0 -15
  57. package/point-heat-map/plugin.js +0 -132
  58. package/programs/line-on-globe/naive-accurate.js +0 -221
  59. package/programs/line-on-globe/to-the-origin.js +0 -164
  60. package/util/jshelpers/timemethods.js +0 -19
  61. /package/{programs/point-on-globe/element-draw-glow.js → point-glow-line-to-earth/adaptors.js} +0 -0
@@ -0,0 +1,216 @@
1
+ import { createProgram } from "../../util";
2
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
+ import { mercatorXYToGLPosition, cartesian3DToGLPosition, R_3D, R } from "../../util/shaderfunctions/geometrytransformations";
4
+ import { noRegisterGlobeProgramCache } from "../programcache";
5
+ import "../../util/gl-util/draw-options/types";
6
+ import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
+ import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
8
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
9
+
10
+
11
+ const uniformBindingPoints = {
12
+ camera: 0,
13
+ flexible: 1
14
+ };
15
+
16
+ const uniformBlockManager = new UniformBlockManager(
17
+ "FlexibleBlock",
18
+ [
19
+ { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
20
+ { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
21
+ { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
22
+ { name: "u_size", type: "float", value: new Float32Array([1.0]) },
23
+ { name: "u_minimum_size", type: "float", value: new Float32Array([1.0]) },
24
+ { name: "u_draw_mode", type: "int", value: new Int32Array([0]) }, // 0.0 for point, 1.0 for line
25
+ { name: "u_is_circle", type: "bool", value: new Float32Array([1.0]) },
26
+ { name: "u_dash_count", type: "float", value: new Float32Array([1.0]) },
27
+ { name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
28
+ { name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
29
+ ], uniformBindingPoints.flexible);
30
+
31
+
32
+ const vs = `#version 300 es
33
+ ${R}
34
+ ${R_3D}
35
+ ${CameraUniformBlockString}
36
+ ${mercatorXYToGLPosition}
37
+ ${cartesian3DToGLPosition}
38
+
39
+ ${uniformBlockManager.glslCode()}
40
+
41
+ precision highp float;
42
+ precision highp int;
43
+
44
+ in vec3 pos3D;
45
+ in vec2 pos2D;
46
+ in vec4 rgba;
47
+ in float size;
48
+
49
+
50
+ flat out highp int vVertexID;
51
+
52
+ out vec4 v_rgba;
53
+
54
+ out float v_length;
55
+
56
+ void main() {
57
+
58
+ v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;
59
+ v_rgba.a *= u_opacity;
60
+ gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);
61
+
62
+ float size_fixer;
63
+ if(is3D){
64
+ gl_Position = cartesian3DToGLPosition(pos3D);
65
+ size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;
66
+ } else {
67
+ gl_Position = mercatorXYToGLPosition(pos2D);
68
+ size_fixer = smoothstep(2.0, 5.2, z_level);
69
+ }
70
+ gl_PointSize *= size_fixer;
71
+ switch (u_draw_mode) {
72
+ case 0:
73
+ vVertexID = gl_VertexID;
74
+ break;
75
+ case 1:
76
+ v_length = float(gl_VertexID % 2);
77
+ vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ }`;
83
+
84
+ const fs = `#version 300 es
85
+ precision highp float;
86
+ precision highp int;
87
+
88
+ ${uniformBlockManager.glslCode()}
89
+
90
+ flat in highp int vVertexID;
91
+
92
+ in vec4 v_rgba;
93
+ in float v_length;
94
+
95
+ layout(location = 0) out vec4 fragColor;
96
+ layout(location = 1) out int vertexID;
97
+
98
+ void main() {
99
+ vertexID = vVertexID;
100
+ fragColor = v_rgba;
101
+
102
+ switch (u_draw_mode) {
103
+ case 0:
104
+ float d = distance(gl_PointCoord, vec2(0.5, 0.5));
105
+ if (u_is_circle) {
106
+ if (d > 0.5) discard;
107
+ fragColor.a *= smoothstep(0.5, 0.45, d);
108
+ }
109
+ if (u_dash_opacity_multiplier < 1.0) {
110
+ float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;
111
+ fragColor.a *= dash;
112
+ }
113
+ break;
114
+ case 1:
115
+ if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {
116
+ fragColor.a *= u_dash_opacity_multiplier;
117
+ }
118
+ break;
119
+ }
120
+ }`;
121
+
122
+
123
+ class PointOnGlobeProgram {
124
+
125
+ constructor(globe) {
126
+
127
+ this.globe = globe;
128
+ this.gl = globe.gl;
129
+ this._isFreed = false;
130
+ this.program = createProgram(this.gl, vs, fs);
131
+
132
+ const { gl, program } = this;
133
+
134
+ // assign opacity
135
+
136
+
137
+ // assign attribute locations
138
+ gl.bindAttribLocation(program, 0, "pos3D");
139
+ gl.bindAttribLocation(program, 1, "pos2D");
140
+ gl.bindAttribLocation(program, 2, "rgba");
141
+ gl.bindAttribLocation(program, 3, "size");
142
+ // arrange camera uniform block
143
+
144
+
145
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
146
+ this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
147
+ uniformBlockManager.assignBindingPoint(this.gl, this.program);
148
+ this._defaultUBO = uniformBlockManager.createUBO(this.gl);
149
+
150
+ this._defaultUBO.update(new Map([
151
+ ["u_rgba", [1, 1, 1, 1]],
152
+ ["u_opacity", [1.0]],
153
+ ["u_size_multiplier", [1.0]],
154
+ ["u_size", [1.0]],
155
+ ["u_is_circle", [1.0]],
156
+ ]));
157
+ }
158
+
159
+
160
+ createUBO() {
161
+ const ubo = uniformBlockManager.createUBO(this.gl);
162
+ return ubo;
163
+ }
164
+
165
+ createVAO(pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
166
+
167
+ const { gl } = this;
168
+ const vao = gl.createVertexArray();
169
+ gl.bindVertexArray(vao);
170
+
171
+ attributeLoader(gl, pos3DBufferObj, 0, 3);
172
+ attributeLoader(gl, pos2DBufferObj, 1, 2);
173
+ attributeLoader(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
174
+ attributeLoader(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
175
+
176
+ gl.bindVertexArray(null);
177
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
178
+ return vao;
179
+ }
180
+
181
+
182
+ /**
183
+ *
184
+ * @param {vertexArrayObject} vao
185
+ * @param {DrawRangeIndexParams} drawOptions
186
+ */
187
+ draw(vao, drawOptions, ubo = null) {
188
+ const { gl, program } = this;
189
+ gl.useProgram(program);
190
+ gl.bindVertexArray(vao);
191
+ this.cameraBlockTotem.bind(uniformBindingPoints.camera);
192
+ ubo = ubo || this._defaultUBO;
193
+ ubo.bind();
194
+
195
+ drawArrays(gl, gl.POINTS, drawOptions);
196
+ ubo.unbind();
197
+ this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
198
+ gl.bindVertexArray(null);
199
+ }
200
+
201
+ free() {
202
+ if (this._isFreed) return;
203
+ const { gl, globe } = this;
204
+ CameraUniformBlockTotemCache.release(globe);
205
+ gl.deleteProgram(this.program);
206
+ this._isFreed = true;
207
+ }
208
+ }
209
+
210
+
211
+ const PickableRendererProgramCache = Object.freeze({
212
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
213
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
214
+ });
215
+
216
+ export { PickableRendererProgramCache };
@@ -0,0 +1,168 @@
1
+ /**
2
+ * *
3
+ * * *
4
+ * * * *
5
+ * * *
6
+ * *
7
+ */
8
+
9
+
10
+
11
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
12
+ import { PI, mercatorXYToGLPosition, cartesian3DToGLPosition, circleLimpFromLongLatRadCenterCartesian3D_accurate } from "../../util/shaderfunctions/geometrytransformations";
13
+ import { createProgram } from "../../util";
14
+ import { noRegisterGlobeProgramCache } from "../programcache";
15
+ import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
16
+ import { drawInstanced } from "../../util/gl-util/draw-options/methods";
17
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
18
+
19
+
20
+ const uboBlockManager = new UniformBlockManager(
21
+ "FlexibleBlock",
22
+ [
23
+ { name: "u_color", type: "vec4" },
24
+ { name: "u_radius", type: "float" }
25
+ ],
26
+ 1
27
+ );
28
+
29
+ const vs = `#version 300 es
30
+ ${PI}
31
+ ${CameraUniformBlockString}
32
+ ${cartesian3DToGLPosition}
33
+ ${circleLimpFromLongLatRadCenterCartesian3D_accurate}
34
+
35
+ uniform float edge_count;
36
+
37
+ in vec3 pos3D;
38
+ in float radius;
39
+ in vec4 color;
40
+
41
+ ${uboBlockManager.glslCode()}
42
+
43
+ out vec4 vColor;
44
+
45
+ void main() {
46
+
47
+ float radius_ = ( radius == -1.0 ) ? u_radius : radius;
48
+ vec4 color = ( color.r == -1.0 ) ? u_color : color;
49
+
50
+ if ( gl_VertexID == 0 ) {
51
+ gl_Position = cartesian3DToGLPosition(pos3D);
52
+ vColor = vColor;
53
+ } else {
54
+ float angle = PI * 2.0 * float( gl_VertexID - 1 ) / edge_count;
55
+ vec3 position = circleLimpFromLongLatRadCenterCartesian3D_accurate(pos3D, radius, angle);
56
+ gl_Position = cartesian3DToGLPosition(position);
57
+ float distance = distance(position, pos3D);
58
+
59
+
60
+
61
+ vColor = vec4(color.rgb, color.a * (1.0 - distance / radius));
62
+ }
63
+ }`;
64
+
65
+
66
+ const fs = `#version 300 es
67
+ precision highp float;
68
+
69
+ uniform float opacity;
70
+ in vec4 vColor;
71
+
72
+ out vec4 fragColor;
73
+
74
+ void main() {
75
+ fragColor = vColor;
76
+ fragColor.a *= opacity;
77
+ }`;
78
+
79
+
80
+ class Logic {
81
+ constructor(globe) {
82
+ this.globe = globe;
83
+ this.gl = globe.gl;
84
+
85
+ this._vaoCache = [];
86
+
87
+ this.program = createProgram(this.gl, vs, fs);
88
+
89
+ const { gl, program } = this;
90
+
91
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
92
+ gl.useProgram(program);
93
+ // set uniform locations
94
+ this._uniforms = {
95
+ edge_count_loc: gl.getUniformLocation(program, "edge_count"),
96
+ edge_count: 40,
97
+ opacity_loc: gl.getUniformLocation(program, "opacity"),
98
+ opacity: 1.0
99
+ };
100
+ // last values
101
+ gl.uniform1f(this._uniforms.edge_count_loc, this._uniforms.edge_count);
102
+ gl.uniform1f(this._uniforms.opacity_loc, this._uniforms.opacity);
103
+
104
+ gl.useProgram(currentProgram);
105
+ // assign attribute locations
106
+ gl.bindAttribLocation(program, 0, "pos3D");
107
+ gl.bindAttribLocation(program, 1, "radius");
108
+ gl.bindAttribLocation(program, 2, "color");
109
+ // camera uniform block
110
+ this.cameraUniformBlockTotem = CameraUniformBlockTotemCache.get(globe);
111
+ this.cameraBlockBindingPoint = 0;
112
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
113
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
114
+
115
+ uboBlockManager.assignBindingPoint(this.gl, this.program);
116
+ this._defaultUBO = uboBlockManager.createUBO(this.gl);
117
+ }
118
+
119
+
120
+ createVAO(pos3DObj, radiusObj, colorObj) {
121
+ const { gl } = this;
122
+ const vao = gl.createVertexArray();
123
+ const divisor = 1;
124
+ gl.bindVertexArray(vao);
125
+
126
+ // TODO constants to escape values
127
+ attributeLoader(gl, pos3DObj, 0, 3, { divisor });
128
+ attributeLoader(gl, radiusObj, 1, 1, { divisor, escapeValues: [-1] });
129
+ attributeLoader(gl, colorObj, 2, 4, { divisor, escapeValues: [-1, -1, -1, -1] });
130
+
131
+ gl.bindVertexArray(null);
132
+ this._vaoCache.push(vao);
133
+ return vao;
134
+ }
135
+
136
+
137
+ draw(vao, drawOptions, opacity = 1.0, ubo = null) {
138
+ const { gl, program } = this;
139
+ gl.useProgram(program);
140
+ gl.bindVertexArray(vao);
141
+ if (opacity !== this._uniforms.opacity) {
142
+ gl.uniform1f(this._uniforms.opacity_loc, opacity);
143
+ this._uniforms.opacity = opacity;
144
+ }
145
+ ubo = ubo || this._defaultUBO;
146
+ ubo.bind();
147
+ drawInstanced(gl, gl.TRIANGLE_FAN, drawOptions);
148
+ ubo.unbind();
149
+ gl.bindVertexArray(null);
150
+ }
151
+
152
+
153
+ free() {
154
+ if (this._isFreed) return;
155
+ CameraUniformBlockTotemCache.release(this.globe);
156
+ this.gl.deleteProgram(this.program);
157
+ for (const vao of this._vaoCache) this.gl.deleteVertexArray(vao);
158
+ this._isFreed = true;
159
+ }
160
+ }
161
+
162
+
163
+ const ElementGlobeSufaceGlowCache = Object.freeze({
164
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
165
+ release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe)
166
+ })
167
+
168
+ export { ElementGlobeSufaceGlowCache };
@@ -0,0 +1,184 @@
1
+ import { createProgram } from "../../util";
2
+ import { CameraUniformBlockTotemCache, CameraUniformBlockString } from "../totems";
3
+ import { mercatorXYToGLPosition, cartesian3DToGLPosition } from "../../util/shaderfunctions/geometrytransformations";
4
+ import { noRegisterGlobeProgramCache } from "../programcache";
5
+ import { attributeLoader } from "../../util/gl-util/buffer/integrate-buffer";
6
+ import { drawArrays } from "../../util/gl-util/draw-options/methods";
7
+ import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
8
+ import { singularity } from "../../shaders/fragment-toy/singularity";
9
+ import { firework } from "../../shaders/fragment-toy/firework";
10
+
11
+
12
+ const cameraBlockBindingPoint = 0;
13
+ const flexibleBlockBindingPoint = 1;
14
+
15
+ const uniformBlockManager = new UniformBlockManager(
16
+ "FlexibleBlock",
17
+ [
18
+ { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
19
+ { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
20
+ { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
21
+ { name: "u_size", type: "float", value: new Float32Array([1.0]) },
22
+ { name: "u_minimumSize", type: "float", value: new Float32Array([25.0]) },
23
+ { name: "u_phase", type: "float", value: new Float32Array([1.0]) },
24
+ ], flexibleBlockBindingPoint);
25
+
26
+ const vs = `#version 300 es
27
+ precision highp float;
28
+
29
+ ${CameraUniformBlockString}
30
+ ${mercatorXYToGLPosition}
31
+ ${cartesian3DToGLPosition}
32
+
33
+ ${uniformBlockManager.glslCode()}
34
+
35
+
36
+ in vec3 pos3D;
37
+ in vec2 pos2D;
38
+ in vec4 color;
39
+ in float size;
40
+
41
+ out vec4 vColor;
42
+ flat out float v_size;
43
+
44
+
45
+
46
+ void main() {
47
+
48
+ if(is3D){
49
+ gl_Position = cartesian3DToGLPosition(pos3D);
50
+ }
51
+ else {
52
+ gl_Position = mercatorXYToGLPosition(pos2D);
53
+ }
54
+
55
+ gl_PointSize = max(
56
+ ((size == -1.0) ? u_size : size ) * u_size_multiplier,
57
+ u_minimumSize);
58
+ v_size = gl_PointSize;
59
+ vColor = (color.r == -1.0) ? u_rgba : color;
60
+ vColor.a *= u_opacity;
61
+
62
+ }`;
63
+
64
+
65
+ const fs = `#version 300 es
66
+ precision highp float;
67
+
68
+ ${uniformBlockManager.glslCode()}
69
+
70
+ in vec4 vColor;
71
+ out vec4 fragColor;
72
+
73
+ flat in float v_size;
74
+
75
+ ${firework}
76
+ ${singularity}
77
+
78
+ void main() {
79
+ fragColor = vColor;
80
+
81
+ float dist = distance(gl_PointCoord, vec2(0.5, 0.5)) * 2.0;
82
+ if ( dist > 1.0) discard;
83
+
84
+ // center glow
85
+ float center_alpha = smoothstep(0.5, 0.0, dist) * 0.3;
86
+ // center_alpha = smoothstep(0.0, 1.0, center_alpha);
87
+
88
+ // circle pattern
89
+ float threshold = fract(( - dist + u_phase - 0.5));
90
+ float circle_alpha = sin( threshold * 1.57 );
91
+ circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, circle_alpha);
92
+
93
+ float outer_circle_alpha = sin(dist * 1.57 );
94
+ outer_circle_alpha = smoothstep((v_size / (v_size + .5)), 1.0, outer_circle_alpha);
95
+
96
+ // fragColor = singularity(gl_PointCoord, u_phase);
97
+
98
+ fragColor.a *= smoothstep(0.0, 1.1, ( 0.4 * u_opacity + center_alpha + circle_alpha+ outer_circle_alpha));
99
+ }`;
100
+
101
+ class Logic {
102
+
103
+ constructor(globe) {
104
+ this.globe = globe;
105
+ this.gl = globe.gl;
106
+
107
+ this.program = createProgram(this.gl, vs, fs);
108
+
109
+ const { gl, program } = this;
110
+
111
+
112
+ gl.bindAttribLocation(program, 0, "pos3D");
113
+ gl.bindAttribLocation(program, 1, "pos2D");
114
+ gl.bindAttribLocation(program, 2, "color");
115
+ gl.bindAttribLocation(program, 3, "size");
116
+ // assign uniform block
117
+
118
+ this.cameraBlockTotem = CameraUniformBlockTotemCache.get(globe);
119
+ this.cameraBlockTotem.assignBindingPoint(program, cameraBlockBindingPoint);
120
+
121
+ uniformBlockManager.assignBindingPoint(this.gl, this.program);
122
+ this._defaultUBO = uniformBlockManager.createUBO(this.gl);
123
+ }
124
+
125
+
126
+ createVAO(pos3DBuffer, pos2DBuffer, colorBuffer, sizeBuffer) {
127
+
128
+ const { gl } = this;
129
+
130
+ const vao = gl.createVertexArray();
131
+ gl.bindVertexArray(vao);
132
+
133
+ attributeLoader(gl, pos3DBuffer, 0, 3);
134
+ attributeLoader(gl, pos2DBuffer, 1, 2);
135
+ attributeLoader(gl, colorBuffer, 2, 4, { escapeValues: [-1, -1, -1, -1] });
136
+ attributeLoader(gl, sizeBuffer, 3, 1, { escapeValues: [-1] });
137
+
138
+ gl.bindVertexArray(null);
139
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
140
+
141
+ return vao;
142
+ }
143
+
144
+
145
+ createUBO() {
146
+ const ubo = uniformBlockManager.createUBO(this.gl);
147
+ return ubo;
148
+ }
149
+
150
+ draw(vao, drawOptions, ubo = null) {
151
+ const { gl, program, cameraBlockTotem } = this;
152
+ gl.useProgram(program);
153
+ gl.bindVertexArray(vao);
154
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
155
+
156
+ ubo = ubo || this._defaultUBO;
157
+
158
+ ubo.bind();
159
+ drawArrays(gl, gl.POINTS, drawOptions);
160
+ ubo.unbind();
161
+
162
+ gl.bindVertexArray(null);
163
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
164
+ this.globe.DrawRender();
165
+ }
166
+
167
+
168
+
169
+ // for singleton cache interation
170
+
171
+ free() {
172
+ if (this._isFreed) return;
173
+ CameraUniformBlockTotemCache.release(this.globe);
174
+ this.gl.deleteProgram(this.program);
175
+ this._isFreed = true;
176
+ }
177
+ }
178
+
179
+ const ElementPointGlowProgramCache = Object.freeze({
180
+ get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
181
+ release: globe => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
182
+ });
183
+
184
+ export { ElementPointGlowProgramCache };
@@ -171,8 +171,6 @@ class PointOnGlobeProgram {
171
171
  gl.bindVertexArray(null);
172
172
  }
173
173
 
174
-
175
-
176
174
  free() {
177
175
  if (this._isFreed) return;
178
176
  const { gl, globe } = this;
@@ -183,9 +181,9 @@ class PointOnGlobeProgram {
183
181
  }
184
182
 
185
183
 
186
- const pointOnGlobeProgramCache = Object.freeze({
184
+ const PointOnGlobeProgramCache = Object.freeze({
187
185
  get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram),
188
186
  release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram)
189
187
  });
190
188
 
191
- export { pointOnGlobeProgramCache };
189
+ export { PointOnGlobeProgramCache };
@@ -33,6 +33,9 @@ const globeProgramCache = (function () {
33
33
 
34
34
  function releaseProgram(globe, ProgramClass) {
35
35
  if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
36
+ if (cache.get(globe).get(ProgramClass).count === 0) {
37
+ throw new Error("The program counter is already 0, cannot release program");
38
+ }
36
39
  cache.get(globe).get(ProgramClass).count--;
37
40
  if (cache.get(globe).get(ProgramClass).count === 0) {
38
41
  globe.api_UnRegisterPlugin(cache.get(globe).get(ProgramClass).program.id); // it calls program.free()
@@ -68,6 +71,9 @@ const glProgramCache = (function () {
68
71
 
69
72
  function releaseProgram(gl, ProgramClass) {
70
73
  if (cache.has(gl) && cache.get(gl).has(ProgramClass)) {
74
+ if (cache.get(gl).get(ProgramClass).count === 0) {
75
+ throw new Error("The program counter is already 0, cannot release program");
76
+ }
71
77
  cache.get(gl).get(ProgramClass).count--;
72
78
  if (cache.get(gl).get(ProgramClass).count === 0) {
73
79
  cache.get(gl).get(ProgramClass).program.free();
@@ -103,6 +109,9 @@ const noRegisterGlobeProgramCache = (function () {
103
109
 
104
110
  function releaseProgram(globe, ProgramClass) {
105
111
  if (cache.has(globe) && cache.get(globe).has(ProgramClass)) {
112
+ if (cache.get(globe).get(ProgramClass).count === 0) {
113
+ throw new Error("The program counter is already 0, cannot release program");
114
+ }
106
115
  cache.get(globe).get(ProgramClass).count--;
107
116
  if (cache.get(globe).get(ProgramClass).count === 0) {
108
117
  cache.get(globe).get(ProgramClass).program.free();
@@ -309,7 +309,7 @@ export class Logic {
309
309
 
310
310
  }
311
311
 
312
- export const pieceOfPieProgramCache = Object.freeze({
312
+ export const PieceOfPieProgramCache = Object.freeze({
313
313
  get: (globe) => noRegisterGlobeProgramCache.getProgram(globe, Logic),
314
314
  release: (globe) => noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
315
315
  });
@@ -30,6 +30,10 @@ export default class
30
30
  this.gl = null;
31
31
  this.globe = null;
32
32
  this.ubo = null;
33
+ this._isMovedParams = {
34
+ lastLod: null,
35
+ isMoved: false,
36
+ }
33
37
  }
34
38
 
35
39
 
@@ -75,7 +79,7 @@ export default class
75
79
 
76
80
  const { gl, traslateFloat32, ubo, mapWHFloat32, globe } = this;
77
81
  gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
78
- { // view, projection, translate
82
+ { // view, projection, translat
79
83
  gl.bufferSubData(gl.UNIFORM_BUFFER, 0, modelView);
80
84
  gl.bufferSubData(gl.UNIFORM_BUFFER, 64, projection);
81
85
  traslateFloat32.set([translate.x, translate.y, translate.z], 0);
@@ -101,12 +105,24 @@ export default class
101
105
  gl.bufferSubData(gl.UNIFORM_BUFFER, 164, new Float32Array([
102
106
  Distance, Radian * Tilt, Radian * NorthAng, Radian * CenterLong, Radian * CenterLat
103
107
  ]));
104
-
105
108
  }
109
+
106
110
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
107
111
 
112
+ { // isMoved
113
+ const currentLOD = globe.api_GetCurrentLODWithDecimal()
114
+ this._isMovedParams.isMoved = this._isMovedParams.lastLod !== currentLOD || globe.api_IsScreenMoving();
115
+ this._isMovedParams.lastLod = currentLOD;
116
+ }
108
117
  }
109
118
 
119
+ assignBindingPoint(program, bindingPoint) {
120
+ const { gl } = this;
121
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
122
+ gl.uniformBlockBinding(program, cameraBlockIndex, bindingPoint);
123
+ }
124
+
125
+
110
126
  getUBO() {
111
127
  return this.ubo;
112
128
  }
@@ -124,6 +140,11 @@ export default class
124
140
  }
125
141
 
126
142
 
143
+ isMoved() {
144
+ return this._isMovedParams.isMoved;
145
+ }
146
+
147
+
127
148
  free() {
128
149
  const { gl, ubo } = this;
129
150
  gl.deleteBuffer(ubo);