@pirireis/webglobeplugins 0.9.8 → 0.9.9

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 (213) hide show
  1. package/index.js +58 -15
  2. package/package.json +1 -1
  3. package/dist/Math/angle-calculation.js +0 -15
  4. package/dist/Math/arc.js +0 -65
  5. package/dist/Math/bounds/line-bbox.js +0 -188
  6. package/dist/Math/constants.js +0 -9
  7. package/dist/Math/frustum/camera.js +0 -24
  8. package/dist/Math/frustum/from-globeinfo.js +0 -48
  9. package/dist/Math/frustum/types.js +0 -2
  10. package/dist/Math/globe-util/horizon-plane.js +0 -112
  11. package/dist/Math/index.js +0 -1
  12. package/dist/Math/juction/arc-plane.js +0 -83
  13. package/dist/Math/juction/line-sphere.js +0 -25
  14. package/dist/Math/juction/plane-plane.js +0 -58
  15. package/dist/Math/line.js +0 -56
  16. package/dist/Math/matrix4.js +0 -1
  17. package/dist/Math/methods.js +0 -201
  18. package/dist/Math/plane.js +0 -60
  19. package/dist/Math/quaternion.js +0 -104
  20. package/dist/Math/types.js +0 -2
  21. package/dist/Math/utils.js +0 -4
  22. package/dist/Math/vec3.js +0 -126
  23. package/dist/algorithms/search-binary.js +0 -19
  24. package/dist/altitude-locator/adaptors.js +0 -1
  25. package/dist/altitude-locator/draw-subset-obj.js +0 -18
  26. package/dist/altitude-locator/keymethod.js +0 -1
  27. package/dist/altitude-locator/plugin.js +0 -341
  28. package/dist/altitude-locator/types.js +0 -23
  29. package/dist/arrowfield/adaptor.js +0 -14
  30. package/dist/arrowfield/index.js +0 -10
  31. package/dist/arrowfield/plugin.js +0 -86
  32. package/dist/bearing-line/index.js +0 -8
  33. package/dist/bearing-line/plugin.js +0 -449
  34. package/dist/circle-line-chain/chain-list-map.js +0 -205
  35. package/dist/circle-line-chain/init.js +0 -1
  36. package/dist/circle-line-chain/plugin.js +0 -424
  37. package/dist/circle-line-chain/util.js +0 -5
  38. package/dist/compass-rose/compass-rose-padding-flat.js +0 -225
  39. package/dist/compass-rose/compass-text-writer.js +0 -153
  40. package/dist/compass-rose/index.js +0 -7
  41. package/dist/compassrose/compassrose.js +0 -296
  42. package/dist/compassrose/index.js +0 -8
  43. package/dist/globe-types.js +0 -1
  44. package/dist/heatwave/index.js +0 -10
  45. package/dist/heatwave/isobar/objectarraylabels.js +0 -202
  46. package/dist/heatwave/isobar/plugin.js +0 -343
  47. package/dist/heatwave/isobar/quadtreecontours.js +0 -300
  48. package/dist/heatwave/plugins/heatwaveglobeshell.js +0 -206
  49. package/dist/index.js +0 -58
  50. package/dist/jest.config.js +0 -7
  51. package/dist/partialrings/buffer-manager.js +0 -81
  52. package/dist/partialrings/index.js +0 -41
  53. package/dist/partialrings/plugin.js +0 -135
  54. package/dist/partialrings/program.js +0 -286
  55. package/dist/pin/pin-object-array.js +0 -305
  56. package/dist/pin/pin-point-totem.js +0 -60
  57. package/dist/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -66
  58. package/dist/point-heat-map/index.js +0 -1
  59. package/dist/point-heat-map/plugin-webworker.js +0 -126
  60. package/dist/point-heat-map/point-to-heat-map-flow.js +0 -127
  61. package/dist/point-tracks/key-methods.js +0 -5
  62. package/dist/point-tracks/plugin.js +0 -338
  63. package/dist/programs/arrowfield/index.js +0 -7
  64. package/dist/programs/arrowfield/logic.js +0 -257
  65. package/dist/programs/arrowfield/object.js +0 -66
  66. package/dist/programs/data2legend/density-to-legend.js +0 -101
  67. package/dist/programs/data2legend/point-to-density-texture.js +0 -100
  68. package/dist/programs/float2legendwithratio/index.js +0 -8
  69. package/dist/programs/float2legendwithratio/logic.js +0 -171
  70. package/dist/programs/float2legendwithratio/object.js +0 -110
  71. package/dist/programs/globe-util/is-globe-moved.js +0 -21
  72. package/dist/programs/globeshell/index.js +0 -8
  73. package/dist/programs/globeshell/noise/noises.js +0 -1
  74. package/dist/programs/globeshell/wiggle/index.js +0 -8
  75. package/dist/programs/globeshell/wiggle/logic.js +0 -345
  76. package/dist/programs/globeshell/wiggle/object.js +0 -72
  77. package/dist/programs/helpers/blender/index.js +0 -1
  78. package/dist/programs/helpers/blender/program.js +0 -79
  79. package/dist/programs/helpers/fadeaway/index.js +0 -7
  80. package/dist/programs/helpers/fadeaway/logic.js +0 -72
  81. package/dist/programs/helpers/fadeaway/object.js +0 -20
  82. package/dist/programs/helpers/index.js +0 -8
  83. package/dist/programs/index.js +0 -58
  84. package/dist/programs/interface.js +0 -1
  85. package/dist/programs/line-on-globe/angled-line.js +0 -176
  86. package/dist/programs/line-on-globe/circle-accurate-3d.js +0 -141
  87. package/dist/programs/line-on-globe/circle-accurate-flat.js +0 -216
  88. package/dist/programs/line-on-globe/circle-accurate.js +0 -178
  89. package/dist/programs/line-on-globe/circle.js +0 -167
  90. package/dist/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -159
  91. package/dist/programs/line-on-globe/index.js +0 -1
  92. package/dist/programs/line-on-globe/lines-color-instanced-flat.js +0 -136
  93. package/dist/programs/line-on-globe/linestrip.js +0 -171
  94. package/dist/programs/line-on-globe/naive-accurate-flexible.js +0 -195
  95. package/dist/programs/line-on-globe/to-the-surface.js +0 -111
  96. package/dist/programs/line-on-globe/util.js +0 -8
  97. package/dist/programs/picking/pickable-renderer.js +0 -188
  98. package/dist/programs/point-on-globe/element-globe-surface-glow.js +0 -142
  99. package/dist/programs/point-on-globe/element-point-glow.js +0 -153
  100. package/dist/programs/point-on-globe/square-pixel-point.js +0 -174
  101. package/dist/programs/programcache.js +0 -131
  102. package/dist/programs/rings/distancering/circleflatprogram.js +0 -156
  103. package/dist/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -369
  104. package/dist/programs/rings/distancering/circlepaddysharedbuffer.js +0 -357
  105. package/dist/programs/rings/distancering/index.js +0 -14
  106. package/dist/programs/rings/distancering/paddyflatprogram.js +0 -172
  107. package/dist/programs/rings/distancering/paddyflatprogram2d.js +0 -174
  108. package/dist/programs/rings/distancering/paddyflatprogram3d.js +0 -172
  109. package/dist/programs/rings/distancering/shader.js +0 -1
  110. package/dist/programs/rings/index.js +0 -17
  111. package/dist/programs/rings/partial-ring/piece-of-pie.js +0 -275
  112. package/dist/programs/totems/camerauniformblock.js +0 -160
  113. package/dist/programs/totems/canvas-webglobe-info.js +0 -110
  114. package/dist/programs/totems/gpu-selection-uniform-block.js +0 -108
  115. package/dist/programs/totems/index.js +0 -40
  116. package/dist/programs/two-d/pixel-circle.js +0 -1
  117. package/dist/programs/two-d/pixel-padding-for-compass.js +0 -162
  118. package/dist/programs/util.js +0 -17
  119. package/dist/programs/vectorfields/index.js +0 -23
  120. package/dist/programs/vectorfields/logics/drawrectangleparticles.js +0 -107
  121. package/dist/programs/vectorfields/logics/index.js +0 -12
  122. package/dist/programs/vectorfields/logics/pixelbased.js +0 -142
  123. package/dist/programs/vectorfields/logics/ubo.js +0 -63
  124. package/dist/programs/vectorfields/pingpongbuffermanager.js +0 -76
  125. package/dist/rangerings/enum.js +0 -5
  126. package/dist/rangerings/index.js +0 -15
  127. package/dist/rangerings/plugin.js +0 -560
  128. package/dist/rangerings/rangeringangletext.js +0 -329
  129. package/dist/rangerings/ring-account.js +0 -117
  130. package/dist/shaders/fragment-toy/firework.js +0 -58
  131. package/dist/shaders/fragment-toy/singularity.js +0 -59
  132. package/dist/shape-on-terrain/arc/naive/plugin.js +0 -252
  133. package/dist/timetracks/adaptors-line-strip.js +0 -71
  134. package/dist/timetracks/adaptors.js +0 -122
  135. package/dist/timetracks/index.js +0 -19
  136. package/dist/timetracks/plugin-line-strip.js +0 -250
  137. package/dist/timetracks/plugin.js +0 -258
  138. package/dist/timetracks/program-line-strip.js +0 -611
  139. package/dist/timetracks/program.js +0 -772
  140. package/dist/timetracks/programpoint-line-strip.js +0 -154
  141. package/dist/timetracks/programpoint.js +0 -147
  142. package/dist/types.js +0 -15
  143. package/dist/util/account/bufferoffsetmanager.js +0 -179
  144. package/dist/util/account/index.js +0 -23
  145. package/dist/util/account/single-attribute-buffer-management/buffer-manager.js +0 -108
  146. package/dist/util/account/single-attribute-buffer-management/buffer-orchestrator.js +0 -150
  147. package/dist/util/account/single-attribute-buffer-management/index.js +0 -9
  148. package/dist/util/account/single-attribute-buffer-management/object-store.js +0 -51
  149. package/dist/util/account/single-attribute-buffer-management/types.js +0 -2
  150. package/dist/util/account/util.js +0 -22
  151. package/dist/util/algorithms/index.js +0 -1
  152. package/dist/util/algorithms/search-binary.js +0 -28
  153. package/dist/util/check/get.js +0 -18
  154. package/dist/util/check/index.js +0 -1
  155. package/dist/util/check/typecheck.js +0 -49
  156. package/dist/util/geometry/index.js +0 -51
  157. package/dist/util/gl-util/buffer/attribute-loader.js +0 -69
  158. package/dist/util/gl-util/buffer/index.js +0 -6
  159. package/dist/util/gl-util/buffer/types.js +0 -1
  160. package/dist/util/gl-util/draw-options/methods.js +0 -38
  161. package/dist/util/gl-util/draw-options/types.js +0 -15
  162. package/dist/util/gl-util/uniform-block/manager.js +0 -156
  163. package/dist/util/gl-util/uniform-block/shader.js +0 -1
  164. package/dist/util/gl-util/uniform-block/types.js +0 -8
  165. package/dist/util/heatwavedatamanager/datamanager.js +0 -152
  166. package/dist/util/heatwavedatamanager/index.js +0 -10
  167. package/dist/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -122
  168. package/dist/util/heatwavedatamanager/pointcoordsmeta.js +0 -20
  169. package/dist/util/index.js +0 -57
  170. package/dist/util/interpolation/index.js +0 -1
  171. package/dist/util/interpolation/timetrack/index.js +0 -5
  172. package/dist/util/interpolation/timetrack/timetrack-interpolator.js +0 -79
  173. package/dist/util/interpolation/timetrack/web-worker-str.js +0 -183
  174. package/dist/util/interpolation/timetrack/web-worker.js +0 -48
  175. package/dist/util/jshelpers/data-filler.js +0 -20
  176. package/dist/util/jshelpers/equality.js +0 -20
  177. package/dist/util/jshelpers/index.js +0 -37
  178. package/dist/util/jshelpers/timefilters.js +0 -32
  179. package/dist/util/picking/fence.js +0 -46
  180. package/dist/util/picking/picker-displayer.js +0 -139
  181. package/dist/util/programs/draw-texture-on-canvas.js +0 -89
  182. package/dist/util/programs/index.js +0 -17
  183. package/dist/util/programs/shapesonglobe.js +0 -214
  184. package/dist/util/programs/supersampletotextures.js +0 -113
  185. package/dist/util/programs/texturetoglobe.js +0 -182
  186. package/dist/util/shaderfunctions/geometrytransformations.js +0 -340
  187. package/dist/util/shaderfunctions/index.js +0 -18
  188. package/dist/util/shaderfunctions/nodata.js +0 -11
  189. package/dist/util/shaderfunctions/noisefunctions.js +0 -43
  190. package/dist/util/surface-line-data/arc-bboxes.js +0 -25
  191. package/dist/util/surface-line-data/arcs-to-cuts.js +0 -50
  192. package/dist/util/surface-line-data/cut-arc.js +0 -1
  193. package/dist/util/surface-line-data/flow.js +0 -28
  194. package/dist/util/surface-line-data/rbush-manager.js +0 -1
  195. package/dist/util/surface-line-data/types.js +0 -1
  196. package/dist/util/surface-line-data/web-worker.js +0 -1
  197. package/dist/util/webglobe/gldefaultstates.js +0 -7
  198. package/dist/util/webglobe/index.js +0 -18
  199. package/dist/util/webglobe/rasteroverlay.js +0 -78
  200. package/dist/util/webglobjectbuilders.js +0 -388
  201. package/dist/util/webglobjectbuilders1.js +0 -237
  202. package/dist/waveparticles/adaptor.js +0 -17
  203. package/dist/waveparticles/index.js +0 -10
  204. package/dist/waveparticles/plugin.js +0 -266
  205. package/dist/wind/imagetovectorfieldandmagnitude.js +0 -35
  206. package/dist/wind/index.js +0 -14
  207. package/dist/wind/plugin.js +0 -926
  208. package/dist/wind/vectorfieldimage.js +0 -25
  209. package/dist/write-text/attached-text-writer.js +0 -91
  210. package/dist/write-text/context-text.js +0 -98
  211. package/dist/write-text/context-text3.js +0 -155
  212. package/dist/write-text/index.js +0 -5
  213. package/dist/write-text/writer-plugin.js +0 -8
@@ -1,388 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createShader = createShader;
4
- exports.createProgram = createProgram;
5
- exports.createProgramWrapper = createProgramWrapper;
6
- exports.createTexture = createTexture;
7
- exports.bindTexture = bindTexture;
8
- exports.createBuffer = createBuffer;
9
- exports.bindAttribute = bindAttribute;
10
- exports.bindFramebuffer = bindFramebuffer;
11
- exports.decodeBase64 = decodeBase64;
12
- exports.createImageFromBase64 = createImageFromBase64;
13
- exports.getColorRamp = getColorRamp;
14
- exports.getColorRampDiscrate = getColorRampDiscrate;
15
- exports.getColorRampInterpolated = getColorRampInterpolated;
16
- exports.getColorRampModed = getColorRampModed;
17
- exports.defaultColorRamp = defaultColorRamp;
18
- exports.reloadCurrentGLProgram = reloadCurrentGLProgram;
19
- /**
20
- * Creates and compiles a WebGL shader.
21
- * @param gl The WebGL2RenderingContext.
22
- * @param type The type of shader (e.g., gl.VERTEX_SHADER or gl.FRAGMENT_SHADER).
23
- * @param source The GLSL source code for the shader.
24
- * @returns The compiled WebGLShader.
25
- * @throws An error if shader compilation fails.
26
- */
27
- function createShader(gl, type, source) {
28
- const shader = gl.createShader(type);
29
- if (!shader) {
30
- throw new Error("Failed to create WebGLShader.");
31
- }
32
- gl.shaderSource(shader, source);
33
- gl.compileShader(shader);
34
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
35
- const errorLog = gl.getShaderInfoLog(shader);
36
- const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
37
- const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
38
- gl.deleteShader(shader); // Clean up the failed shader
39
- throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
40
- }
41
- return shader;
42
- }
43
- /**
44
- * Creates, compiles, and links a WebGL program from vertex and fragment shader sources.
45
- * Note: This function logs errors to the console and returns `undefined` on failure.
46
- * Consider using `createProgramWrapper` for more robust error handling.
47
- * @param gl The WebGL2RenderingContext.
48
- * @param vertexSource The GLSL source code for the vertex shader.
49
- * @param fragmentSource The GLSL source code for the fragment shader.
50
- * @returns The linked WebGLProgram, or `undefined` if compilation or linking fails.
51
- */
52
- function createProgram(gl, vertexSource, fragmentSource) {
53
- const program = gl.createProgram();
54
- if (!program) {
55
- console.error("Failed to create WebGLProgram.");
56
- return undefined;
57
- }
58
- let vertexShader;
59
- let fragmentShader;
60
- try {
61
- vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
62
- fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
63
- }
64
- catch (e) { // Catching errors from createShader
65
- console.error(e.message);
66
- gl.deleteProgram(program); // Clean up the program if shaders failed
67
- return undefined;
68
- }
69
- gl.attachShader(program, vertexShader);
70
- gl.attachShader(program, fragmentShader);
71
- gl.linkProgram(program);
72
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
73
- console.error("Failed to link WebGL program:", gl.getProgramInfoLog(program));
74
- gl.deleteProgram(program);
75
- gl.deleteShader(vertexShader);
76
- gl.deleteShader(fragmentShader);
77
- return undefined;
78
- }
79
- // Detach and delete shaders after linking to free up resources
80
- gl.detachShader(program, vertexShader);
81
- gl.detachShader(program, fragmentShader);
82
- gl.deleteShader(vertexShader);
83
- gl.deleteShader(fragmentShader);
84
- return program;
85
- }
86
- /**
87
- * Creates, links a WebGL program, and wraps it with convenience properties
88
- * for attribute and uniform locations.
89
- * @param gl The WebGL2RenderingContext.
90
- * @param vertexSource The GLSL source code for the vertex shader.
91
- * @param fragmentSource The GLSL source code for the fragment shader.
92
- * @returns A ProgramWrapper object containing the WebGLProgram and its active attribute/uniform locations.
93
- * @throws An error if shader compilation or program linking fails.
94
- */
95
- function createProgramWrapper(gl, vertexSource, fragmentSource) {
96
- const program = gl.createProgram();
97
- if (!program) {
98
- throw new Error("Failed to create WebGLProgram.");
99
- }
100
- const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
101
- const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
102
- gl.attachShader(program, vertexShader);
103
- gl.attachShader(program, fragmentShader);
104
- gl.linkProgram(program);
105
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
106
- const errorLog = gl.getProgramInfoLog(program);
107
- gl.deleteProgram(program);
108
- gl.deleteShader(vertexShader);
109
- gl.deleteShader(fragmentShader);
110
- throw new Error(`Error linking program:\n${errorLog}`);
111
- }
112
- // Detach and delete shaders after linking
113
- gl.detachShader(program, vertexShader);
114
- gl.detachShader(program, fragmentShader);
115
- gl.deleteShader(vertexShader);
116
- gl.deleteShader(fragmentShader);
117
- // Using an object literal for dynamic properties
118
- const wrapper = { program: program };
119
- const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
120
- for (let i = 0; i < numAttributes; i++) {
121
- const attribute = gl.getActiveAttrib(program, i);
122
- if (attribute) {
123
- wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
124
- }
125
- }
126
- const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
127
- for (let i = 0; i < numUniforms; i++) {
128
- const uniform = gl.getActiveUniform(program, i);
129
- if (uniform) {
130
- wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
131
- }
132
- }
133
- return wrapper;
134
- }
135
- /**
136
- * Creates and configures a WebGL texture.
137
- * @param gl The WebGL2RenderingContext.
138
- * @param filter The texture filter (e.g., gl.LINEAR, gl.NEAREST).
139
- * @param data The image data (e.g., ImageData, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, ImageBitmap, or Uint8Array).
140
- * @param width The width of the texture (required if data is Uint8Array).
141
- * @param height The height of the texture (required if data is Uint8Array).
142
- * @returns The created WebGLTexture.
143
- * @throws An error if texture creation fails.
144
- */
145
- function createTexture(gl, filter, data, width, height) {
146
- const texture = gl.createTexture();
147
- if (!texture) {
148
- throw new Error("Failed to create WebGLTexture.");
149
- }
150
- gl.bindTexture(gl.TEXTURE_2D, texture);
151
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
152
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
153
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
154
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
155
- if (data instanceof Uint8Array) {
156
- if (width === undefined || height === undefined) {
157
- throw new Error("Width and height must be provided when data is Uint8Array.");
158
- }
159
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
160
- }
161
- else {
162
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
163
- }
164
- gl.bindTexture(gl.TEXTURE_2D, null);
165
- return texture;
166
- }
167
- /**
168
- * Binds a WebGL texture to a specific texture unit.
169
- * @param gl The WebGL2RenderingContext.
170
- * @param texture The WebGLTexture to bind.
171
- * @param unit The texture unit to activate (e.g., 0 for TEXTURE0, 1 for TEXTURE1).
172
- */
173
- function bindTexture(gl, texture, unit) {
174
- gl.activeTexture(gl.TEXTURE0 + unit);
175
- gl.bindTexture(gl.TEXTURE_2D, texture);
176
- }
177
- /**
178
- * Creates a WebGL buffer and uploads data to it.
179
- * @param gl The WebGL2RenderingContext.
180
- * @param data The data to upload to the buffer (e.g., Float32Array, Uint16Array).
181
- * @returns The created WebGLBuffer.
182
- * @throws An error if buffer creation fails.
183
- */
184
- function createBuffer(gl, data) {
185
- const buffer = gl.createBuffer();
186
- if (!buffer) {
187
- throw new Error("Failed to create WebGLBuffer.");
188
- }
189
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
190
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
191
- return buffer;
192
- }
193
- /**
194
- * Binds a buffer to a specific attribute location and configures the vertex attribute pointer.
195
- * @param gl The WebGL2RenderingContext.
196
- * @param buffer The WebGLBuffer to bind.
197
- * @param attribute The attribute location (e.g., from `gl.getAttribLocation`).
198
- * @param numComponents The number of components per vertex attribute (e.g., 2 for vec2, 3 for vec3).
199
- */
200
- function bindAttribute(gl, buffer, attribute, numComponents) {
201
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
202
- gl.enableVertexAttribArray(attribute);
203
- gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
204
- }
205
- /**
206
- * Binds a WebGL framebuffer and optionally attaches a texture to it.
207
- * @param gl The WebGL2RenderingContext.
208
- * @param framebuffer The WebGLFramebuffer to bind.
209
- * @param texture The WebGLTexture to attach to the framebuffer's COLOR_ATTACHMENT0, or `null` to unbind.
210
- */
211
- function bindFramebuffer(gl, framebuffer, texture) {
212
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
213
- if (texture) {
214
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
215
- }
216
- }
217
- /**
218
- * Decodes a base64 encoded string into a Uint8Array.
219
- * @param data The base64 encoded string.
220
- * @returns A Uint8Array containing the decoded bytes.
221
- */
222
- function decodeBase64(data) {
223
- const binary_string = atob(data);
224
- const len = binary_string.length;
225
- const bytes = new Uint8Array(len);
226
- for (let i = 0; i < len; i++) {
227
- bytes[i] = binary_string.charCodeAt(i);
228
- }
229
- return bytes;
230
- }
231
- /**
232
- * Creates an HTMLImageElement from a base64 encoded image string.
233
- * @param encodedData The base64 encoded image data (e.g., "iVBORw0KGgo...").
234
- * @returns An HTMLImageElement with the image data loaded.
235
- */
236
- function createImageFromBase64(encodedData) {
237
- const bytes = decodeBase64(encodedData);
238
- const blob = new Blob([bytes.buffer], { type: "image/png" });
239
- const urlCreator = window.URL || window.webkitURL;
240
- const imageUrl = urlCreator.createObjectURL(blob);
241
- const image = new Image();
242
- image.src = imageUrl;
243
- // Revoke the object URL after the image has loaded to free up memory
244
- image.onload = () => urlCreator.revokeObjectURL(imageUrl);
245
- return image;
246
- }
247
- /**
248
- * Creates a 1x256 pixel color ramp (gradient) as a Uint8Array.
249
- * @param colors An object where keys are stop positions (0.0-1.0) and values are CSS color strings (e.g., { "0.0": "#RRGGBB", "0.5": "rgba(R,G,B,A)" }).
250
- * @returns A Uint8Array representing the RGBA pixel data of the 1x256 color ramp.
251
- */
252
- function getColorRamp(colors) {
253
- const canvas = document.createElement('canvas');
254
- const ctx = canvas.getContext('2d');
255
- if (!ctx) {
256
- throw new Error("Failed to get 2D rendering context for canvas.");
257
- }
258
- canvas.width = 256;
259
- canvas.height = 1;
260
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
261
- for (const stop in colors) {
262
- // Ensure the stop is a valid number, although `addColorStop` can parse strings,
263
- // explicit conversion is safer for object keys if they come from arbitrary sources.
264
- const stopValue = parseFloat(stop);
265
- if (isNaN(stopValue)) {
266
- console.warn(`Invalid stop value for color ramp: ${stop}. Skipping.`);
267
- continue;
268
- }
269
- gradient.addColorStop(stopValue, colors[stop]);
270
- }
271
- ctx.fillStyle = gradient;
272
- ctx.fillRect(0, 0, 256, 1);
273
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
274
- }
275
- /**
276
- * Creates a 1x256 pixel discrete color ramp as a Uint8Array.
277
- * This ramp features sharp transitions between colors at specified thresholds.
278
- * @param values An array of CSS color strings.
279
- * @param thresholds An array of stop positions (0.0-1.0) for the colors.
280
- * @returns A Uint8Array representing the RGBA pixel data of the 1x256 discrete color ramp.
281
- */
282
- function getColorRampDiscrate(values, thresholds) {
283
- const canvas = document.createElement('canvas');
284
- const ctx = canvas.getContext('2d');
285
- if (!ctx) {
286
- throw new Error("Failed to get 2D rendering context for canvas.");
287
- }
288
- canvas.width = 256;
289
- canvas.height = 1;
290
- const gap = 1.0 / 256; // Represents one pixel width in normalized coordinates
291
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
292
- for (let i = 0; i < thresholds.length - 1; i++) {
293
- gradient.addColorStop(thresholds[i], values[i]);
294
- // Create a sharp transition by setting the next stop just before the next threshold
295
- gradient.addColorStop(Math.max(0, thresholds[i + 1] - gap), values[i]);
296
- }
297
- // Add the final color for the last segment
298
- gradient.addColorStop(thresholds[thresholds.length - 1], values[values.length - 1]);
299
- ctx.fillStyle = gradient;
300
- ctx.fillRect(0, 0, 256, 1);
301
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
302
- }
303
- /**
304
- * Creates a 1x256 pixel interpolated color ramp (smooth gradient) as a Uint8Array.
305
- * @param values An array of CSS color strings.
306
- * @param thresholds An array of stop positions (0.0-1.0) for the colors.
307
- * @returns A Uint8Array representing the RGBA pixel data of the 1x256 interpolated color ramp.
308
- */
309
- function getColorRampInterpolated(values, thresholds) {
310
- const canvas = document.createElement('canvas');
311
- const ctx = canvas.getContext('2d');
312
- if (!ctx) {
313
- throw new Error("Failed to get 2D rendering context for canvas.");
314
- }
315
- canvas.width = 256;
316
- canvas.height = 1;
317
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
318
- for (let i = 0; i < thresholds.length; i++) {
319
- gradient.addColorStop(thresholds[i], values[i]);
320
- }
321
- ctx.fillStyle = gradient;
322
- ctx.fillRect(0, 0, 256, 1);
323
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
324
- }
325
- /**
326
- * Creates a 1x256 pixel color ramp based on the specified mode (discrete or interpolated).
327
- * @param values An array of color hex values (e.g., ["#ff0000", "#00ff00", "#0000ff"]).
328
- * @param thresholds An array of thresholds (0.0-1.0) for the colors.
329
- * @param mode The ramp mode: "discrete" for sharp transitions, "interpolated" for smooth transitions (default).
330
- * @returns A Uint8Array representing the RGBA pixel data of the 1x256 color ramp.
331
- * @throws An error if an invalid mode is provided.
332
- */
333
- function getColorRampModed(values, thresholds, mode = "interpolated") {
334
- if (mode === "discrete") {
335
- return getColorRampDiscrate(values, thresholds);
336
- }
337
- else if (mode === "interpolated") {
338
- return getColorRampInterpolated(values, thresholds);
339
- }
340
- else {
341
- throw new Error("mode is not valid. Expected 'discrete' or 'interpolated'.");
342
- }
343
- }
344
- /**
345
- * Returns a default interpolated color ramp commonly used for visualizations.
346
- * @returns A Uint8Array representing the RGBA pixel data of the default 1x256 color ramp.
347
- */
348
- function defaultColorRamp() {
349
- const defaultRampColors = {
350
- "0.0": '#5e4fa2',
351
- "0.15": '#3288bd',
352
- "0.20": '#66c2a5',
353
- "0.25": '#66c2a5',
354
- "0.3": '#abdda4',
355
- "0.4": '#e6f598',
356
- "0.5": '#fee08b',
357
- "0.6": '#fdae61',
358
- "0.7": '#f46d43',
359
- "1.0": '#ff1e13'
360
- };
361
- return getColorRamp(defaultRampColors);
362
- }
363
- /**
364
- * A method decorator that reloads the current WebGL program after the decorated method executes.
365
- * This is useful for ensuring the correct program is active after a method might change it.
366
- * @returns A method decorator function.
367
- */
368
- function reloadCurrentGLProgram() {
369
- return function (target, key, descriptor) {
370
- const originalMethod = descriptor.value;
371
- // Ensure the target has a 'gl' property of type WebGL2RenderingContext
372
- if (!('gl' in target) || !(target.gl instanceof WebGL2RenderingContext)) {
373
- console.warn(`Decorator 'reloadCurrentGLProgram' applied to a method where 'this.gl' is not a WebGL2RenderingContext. This may not function as expected.`);
374
- // Optionally, throw an error here if strictness is desired
375
- }
376
- descriptor.value = function (...args) {
377
- const gl = this.gl;
378
- if (!gl) {
379
- console.error("reloadCurrentGLProgram decorator: 'gl' context not found on 'this'.");
380
- return originalMethod.apply(this, args);
381
- }
382
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
383
- originalMethod.apply(this, args);
384
- gl.useProgram(currentProgram);
385
- };
386
- return descriptor;
387
- };
388
- }
@@ -1,237 +0,0 @@
1
- "use strict";
2
- // export function createShader(gl, type, source) {
3
- // const shader = gl.createShader(type);
4
- // gl.shaderSource(shader, source);
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createShader = createShader;
7
- exports.createProgram = createProgram;
8
- exports.createProgramWrapper = createProgramWrapper;
9
- exports.createTexture = createTexture;
10
- exports.bindTexture = bindTexture;
11
- exports.createBuffer = createBuffer;
12
- exports.bindAttribute = bindAttribute;
13
- exports.bindFramebuffer = bindFramebuffer;
14
- exports.decodeBase64 = decodeBase64;
15
- exports.createImageFromBase64 = createImageFromBase64;
16
- exports.getColorRamp = getColorRamp;
17
- exports.getColorRampDiscrate = getColorRampDiscrate;
18
- exports.getColorRampInterpolated = getColorRampInterpolated;
19
- exports.getColorRampModed = getColorRampModed;
20
- exports.defaultColorRamp = defaultColorRamp;
21
- exports.reloadCurrentGLProgram = reloadCurrentGLProgram;
22
- // gl.compileShader(shader);
23
- // if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
24
- // throw new Error(gl.getShaderInfoLog(shader));
25
- // }
26
- // return shader;
27
- // }
28
- function createShader(gl, type, source) {
29
- const shader = gl.createShader(type);
30
- gl.shaderSource(shader, source);
31
- gl.compileShader(shader);
32
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
33
- const errorLog = gl.getShaderInfoLog(shader);
34
- const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
35
- const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
36
- throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
37
- }
38
- return shader;
39
- }
40
- function createProgram(gl, vertexSource, fragmentSource) {
41
- const program = gl.createProgram();
42
- const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
43
- const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
44
- gl.compileShader(vertexShader);
45
- if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
46
- console.error(gl.getShaderInfoLog(vertexShader));
47
- return;
48
- }
49
- gl.compileShader(fragmentShader);
50
- if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
51
- console.error(gl.getShaderInfoLog(fragmentShader));
52
- return;
53
- }
54
- gl.attachShader(program, vertexShader);
55
- gl.attachShader(program, fragmentShader);
56
- gl.linkProgram(program);
57
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
58
- console.error(gl.getProgramInfoLog(program));
59
- return;
60
- }
61
- return program;
62
- }
63
- function createProgramWrapper(gl, vertexSource, fragmentSource) {
64
- const program = gl.createProgram();
65
- const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
66
- const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
67
- gl.attachShader(program, vertexShader);
68
- gl.attachShader(program, fragmentShader);
69
- gl.linkProgram(program);
70
- if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
71
- // console.log(gl.getProgramInfoLog(program));
72
- throw new Error(gl.getProgramInfoLog(program));
73
- }
74
- const wrapper = { program: program };
75
- const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
76
- for (let i = 0; i < numAttributes; i++) {
77
- const attribute = gl.getActiveAttrib(program, i);
78
- wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
79
- }
80
- const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
81
- for (let i = 0; i < numUniforms; i++) {
82
- const uniform = gl.getActiveUniform(program, i);
83
- wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
84
- }
85
- return wrapper;
86
- }
87
- function createTexture(gl, filter, data, width, height) {
88
- const texture = gl.createTexture();
89
- gl.bindTexture(gl.TEXTURE_2D, texture);
90
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
91
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
92
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
93
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
94
- if (data instanceof Uint8Array) {
95
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
96
- }
97
- else {
98
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
99
- }
100
- gl.bindTexture(gl.TEXTURE_2D, null);
101
- return texture;
102
- }
103
- function bindTexture(gl, texture, unit) {
104
- gl.activeTexture(gl.TEXTURE0 + unit);
105
- gl.bindTexture(gl.TEXTURE_2D, texture);
106
- }
107
- function createBuffer(gl, data) {
108
- const buffer = gl.createBuffer();
109
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
110
- gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
111
- return buffer;
112
- }
113
- function bindAttribute(gl, buffer, attribute, numComponents) {
114
- gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
115
- gl.enableVertexAttribArray(attribute);
116
- gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
117
- }
118
- function bindFramebuffer(gl, framebuffer, texture) {
119
- if (texture) {
120
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
121
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
122
- }
123
- else {
124
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
125
- }
126
- }
127
- function decodeBase64(data) {
128
- const binary_string = atob(data);
129
- const len = binary_string.length;
130
- const bytes = new Uint8Array(len);
131
- for (let i = 0; i < len; i++) {
132
- bytes[i] = binary_string.charCodeAt(i);
133
- }
134
- return bytes;
135
- }
136
- function createImageFromBase64(encodedData) {
137
- const bytes = decodeBase64(encodedData);
138
- const blob = new Blob([bytes.buffer], { type: "image/png" });
139
- const urlCreator = window.URL || window.webkitURL;
140
- const imageUrl = urlCreator.createObjectURL(blob);
141
- const image = new Image();
142
- image.src = imageUrl;
143
- return image;
144
- }
145
- function getColorRamp(colors) {
146
- // console.log("getColorRamp", colors)
147
- const canvas = document.createElement('canvas');
148
- const ctx = canvas.getContext('2d');
149
- canvas.width = 256;
150
- canvas.height = 1;
151
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
152
- for (const stop in colors) {
153
- // console.log("stop", stop);
154
- gradient.addColorStop(colors[stop][0], colors[stop][1]);
155
- // Alttaki satir ile gradienti cevirip, shaderda ki `speed_t = 1.0 - speed_t`' kaldirdim.
156
- // gradientin en dusuk olmasi gereken siyah - mavi aralikta, mor renk gozlemledim.
157
- // gradient.addColorStop( 1.0 - colors[stop][0], colors[stop][1]);
158
- }
159
- ctx.fillStyle = gradient;
160
- ctx.fillRect(0, 0, 256, 1);
161
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
162
- }
163
- function getColorRampDiscrate(values, thresholds) {
164
- const canvas = document.createElement('canvas');
165
- const ctx = canvas.getContext('2d');
166
- canvas.width = 256;
167
- canvas.height = 1;
168
- const gap = 1.0 / 256;
169
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
170
- for (let i = 0; i < thresholds.length - 1; i++) {
171
- gradient.addColorStop(thresholds[i], values[i]);
172
- gradient.addColorStop(thresholds[i + 1] - gap, values[i]);
173
- }
174
- gradient.addColorStop(thresholds[thresholds.length - 1], values[values.length - 1]);
175
- ctx.fillStyle = gradient;
176
- ctx.fillRect(0, 0, 256, 1);
177
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
178
- }
179
- function getColorRampInterpolated(values, thresholds) {
180
- const canvas = document.createElement('canvas');
181
- const ctx = canvas.getContext('2d');
182
- canvas.width = 256;
183
- canvas.height = 1;
184
- const gradient = ctx.createLinearGradient(0, 0, 256, 0);
185
- // const gap = 1.0 / 256;
186
- // gradient.addColorStop(thresholds[0], values[0]);
187
- // gradient.addColorStop(thresholds[0] + gap, values[1]);
188
- for (let i = 0; i < thresholds.length; i++) {
189
- gradient.addColorStop(thresholds[i], values[i]);
190
- }
191
- // gradient.addColorStop(thresholds[thresholds.length - 1] - gap, values[values.length - 1]);
192
- ctx.fillStyle = gradient;
193
- ctx.fillRect(0, 0, 256, 1);
194
- return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
195
- }
196
- /**
197
- * values: n + 1 number of color hex values without alpha channel. Ex: ["#ff0000", "#00ff00", "#0000ff"]
198
- * thresholds: n number of thresholds. Ex: [0, 10, 20]
199
- * mode: [discrete, interpolated,]
200
- */
201
- function getColorRampModed(values, thresholds, mode = "interpolated") {
202
- if (mode === "discrete") {
203
- return getColorRampDiscrate(values, thresholds);
204
- }
205
- else if (mode === "interpolated") {
206
- return getColorRampInterpolated(values, thresholds);
207
- }
208
- else {
209
- throw new Error("mode is not valid");
210
- }
211
- }
212
- function defaultColorRamp() {
213
- const defaultRampColors = [
214
- [0.0, '#5e4fa2'],
215
- [0.15, '#3288bd'],
216
- [0.20, '#66c2a5'],
217
- [0.25, '#66c2a5'],
218
- [0.3, '#abdda4'],
219
- [0.4, '#e6f598'],
220
- [0.5, '#fee08b'],
221
- [0.6, '#fdae61'],
222
- [0.7, '#f46d43'],
223
- [1.0, '#ff1e13']
224
- ];
225
- return getColorRamp(defaultRampColors);
226
- }
227
- function reloadCurrentGLProgram() {
228
- return function (target, key, descriptor) {
229
- const originalMethod = descriptor.value;
230
- descriptor.value = function () {
231
- const gl = target.gl;
232
- const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
233
- originalMethod.apply(this, arguments);
234
- gl.useProgram(currentProgram);
235
- };
236
- };
237
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.centigradePlus90ToVectorArray = centigradePlus90ToVectorArray;
4
- function centigradePlus90ToVectorArray(centigradeArray, noDataValue = -9999) {
5
- const vectorArray = new Float32Array(centigradeArray.length * 2);
6
- for (let i = 0; i < centigradeArray.length; i++) {
7
- if (centigradeArray[i] === noDataValue) {
8
- vectorArray.set([0, 0], i * 2);
9
- continue;
10
- }
11
- const rad = (centigradeArray[i] + 90.0) * Math.PI / 180;
12
- const x = Math.cos(rad);
13
- const y = Math.sin(rad);
14
- vectorArray.set([x, y], i * 2);
15
- }
16
- return vectorArray;
17
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.VectorFieldWaveParticle = exports.centigradePlus90ToVectorArray = void 0;
7
- const plugin_1 = __importDefault(require("./plugin"));
8
- exports.VectorFieldWaveParticle = plugin_1.default;
9
- const adaptor_1 = require("./adaptor");
10
- Object.defineProperty(exports, "centigradePlus90ToVectorArray", { enumerable: true, get: function () { return adaptor_1.centigradePlus90ToVectorArray; } });