@pirireis/webglobeplugins 0.9.11 → 0.9.13

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 (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
@@ -1,46 +1,28 @@
1
- "use strict";
2
1
  // export function createShader(gl, type, source) {
3
2
  // const shader = gl.createShader(type);
4
3
  // 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
4
  // gl.compileShader(shader);
23
5
  // if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
24
6
  // throw new Error(gl.getShaderInfoLog(shader));
25
7
  // }
26
8
  // return shader;
27
9
  // }
28
- function createShader(gl, type, source) {
29
- var shader = gl.createShader(type);
10
+ export function createShader(gl, type, source) {
11
+ const shader = gl.createShader(type);
30
12
  gl.shaderSource(shader, source);
31
13
  gl.compileShader(shader);
32
14
  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
33
- var errorLog = gl.getShaderInfoLog(shader);
34
- var shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
35
- var sourceWithLineNumbers = source.split('\n').map(function (line, i) { return "".concat(i + 1, ": ").concat(line); }).join('\n');
36
- throw new Error("Error compiling ".concat(shaderType, ":\n").concat(errorLog, "\nSource:\n").concat(sourceWithLineNumbers));
15
+ const errorLog = gl.getShaderInfoLog(shader);
16
+ const shaderType = type === gl.VERTEX_SHADER ? 'VERTEX_SHADER' : 'FRAGMENT_SHADER';
17
+ const sourceWithLineNumbers = source.split('\n').map((line, i) => `${i + 1}: ${line}`).join('\n');
18
+ throw new Error(`Error compiling ${shaderType}:\n${errorLog}\nSource:\n${sourceWithLineNumbers}`);
37
19
  }
38
20
  return shader;
39
21
  }
40
- function createProgram(gl, vertexSource, fragmentSource) {
41
- var program = gl.createProgram();
42
- var vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
43
- var fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
22
+ export function createProgram(gl, vertexSource, fragmentSource) {
23
+ const program = gl.createProgram();
24
+ const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
25
+ const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
44
26
  gl.compileShader(vertexShader);
45
27
  if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
46
28
  console.error(gl.getShaderInfoLog(vertexShader));
@@ -60,10 +42,10 @@ function createProgram(gl, vertexSource, fragmentSource) {
60
42
  }
61
43
  return program;
62
44
  }
63
- function createProgramWrapper(gl, vertexSource, fragmentSource) {
64
- var program = gl.createProgram();
65
- var vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
66
- var fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
45
+ export function createProgramWrapper(gl, vertexSource, fragmentSource) {
46
+ const program = gl.createProgram();
47
+ const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexSource);
48
+ const fragmentShader = createShader(gl, gl.FRAGMENT_SHADER, fragmentSource);
67
49
  gl.attachShader(program, vertexShader);
68
50
  gl.attachShader(program, fragmentShader);
69
51
  gl.linkProgram(program);
@@ -71,21 +53,21 @@ function createProgramWrapper(gl, vertexSource, fragmentSource) {
71
53
  // console.log(gl.getProgramInfoLog(program));
72
54
  throw new Error(gl.getProgramInfoLog(program));
73
55
  }
74
- var wrapper = { program: program };
75
- var numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
76
- for (var i = 0; i < numAttributes; i++) {
77
- var attribute = gl.getActiveAttrib(program, i);
56
+ const wrapper = { program: program };
57
+ const numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
58
+ for (let i = 0; i < numAttributes; i++) {
59
+ const attribute = gl.getActiveAttrib(program, i);
78
60
  wrapper[attribute.name] = gl.getAttribLocation(program, attribute.name);
79
61
  }
80
- var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
81
- for (var i = 0; i < numUniforms; i++) {
82
- var uniform = gl.getActiveUniform(program, i);
62
+ const numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
63
+ for (let i = 0; i < numUniforms; i++) {
64
+ const uniform = gl.getActiveUniform(program, i);
83
65
  wrapper[uniform.name] = gl.getUniformLocation(program, uniform.name);
84
66
  }
85
67
  return wrapper;
86
68
  }
87
- function createTexture(gl, filter, data, width, height) {
88
- var texture = gl.createTexture();
69
+ export function createTexture(gl, filter, data, width, height) {
70
+ const texture = gl.createTexture();
89
71
  gl.bindTexture(gl.TEXTURE_2D, texture);
90
72
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
91
73
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
@@ -100,22 +82,22 @@ function createTexture(gl, filter, data, width, height) {
100
82
  gl.bindTexture(gl.TEXTURE_2D, null);
101
83
  return texture;
102
84
  }
103
- function bindTexture(gl, texture, unit) {
85
+ export function bindTexture(gl, texture, unit) {
104
86
  gl.activeTexture(gl.TEXTURE0 + unit);
105
87
  gl.bindTexture(gl.TEXTURE_2D, texture);
106
88
  }
107
- function createBuffer(gl, data) {
108
- var buffer = gl.createBuffer();
89
+ export function createBuffer(gl, data) {
90
+ const buffer = gl.createBuffer();
109
91
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
110
92
  gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
111
93
  return buffer;
112
94
  }
113
- function bindAttribute(gl, buffer, attribute, numComponents) {
95
+ export function bindAttribute(gl, buffer, attribute, numComponents) {
114
96
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
115
97
  gl.enableVertexAttribArray(attribute);
116
98
  gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);
117
99
  }
118
- function bindFramebuffer(gl, framebuffer, texture) {
100
+ export function bindFramebuffer(gl, framebuffer, texture) {
119
101
  if (texture) {
120
102
  gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
121
103
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
@@ -124,34 +106,34 @@ function bindFramebuffer(gl, framebuffer, texture) {
124
106
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
125
107
  }
126
108
  }
127
- function decodeBase64(data) {
128
- var binary_string = atob(data);
129
- var len = binary_string.length;
130
- var bytes = new Uint8Array(len);
131
- for (var i = 0; i < len; i++) {
109
+ export function decodeBase64(data) {
110
+ const binary_string = atob(data);
111
+ const len = binary_string.length;
112
+ const bytes = new Uint8Array(len);
113
+ for (let i = 0; i < len; i++) {
132
114
  bytes[i] = binary_string.charCodeAt(i);
133
115
  }
134
116
  return bytes;
135
117
  }
136
- function createImageFromBase64(encodedData) {
137
- var bytes = decodeBase64(encodedData);
138
- var blob = new Blob([bytes.buffer], { type: "image/png" });
139
- var urlCreator = window.URL || window.webkitURL;
140
- var imageUrl = urlCreator.createObjectURL(blob);
141
- var image = new Image();
118
+ export function createImageFromBase64(encodedData) {
119
+ const bytes = decodeBase64(encodedData);
120
+ const blob = new Blob([bytes.buffer], { type: "image/png" });
121
+ const urlCreator = window.URL || window.webkitURL;
122
+ const imageUrl = urlCreator.createObjectURL(blob);
123
+ const image = new Image();
142
124
  image.src = imageUrl;
143
125
  return image;
144
126
  }
145
- function getColorRamp(colors) {
127
+ export function getColorRamp(colors) {
146
128
  // console.log("getColorRamp", colors)
147
- var canvas = document.createElement('canvas');
148
- var ctx = canvas.getContext('2d');
129
+ const canvas = document.createElement('canvas');
130
+ const ctx = canvas.getContext('2d');
149
131
  canvas.width = 256;
150
132
  canvas.height = 1;
151
- var gradient = ctx.createLinearGradient(0, 0, 256, 0);
152
- for (var stop_1 in colors) {
133
+ const gradient = ctx.createLinearGradient(0, 0, 256, 0);
134
+ for (const stop in colors) {
153
135
  // console.log("stop", stop);
154
- gradient.addColorStop(colors[stop_1][0], colors[stop_1][1]);
136
+ gradient.addColorStop(colors[stop][0], colors[stop][1]);
155
137
  // Alttaki satir ile gradienti cevirip, shaderda ki `speed_t = 1.0 - speed_t`' kaldirdim.
156
138
  // gradientin en dusuk olmasi gereken siyah - mavi aralikta, mor renk gozlemledim.
157
139
  // gradient.addColorStop( 1.0 - colors[stop][0], colors[stop][1]);
@@ -160,14 +142,14 @@ function getColorRamp(colors) {
160
142
  ctx.fillRect(0, 0, 256, 1);
161
143
  return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
162
144
  }
163
- function getColorRampDiscrate(values, thresholds) {
164
- var canvas = document.createElement('canvas');
165
- var ctx = canvas.getContext('2d');
145
+ export function getColorRampDiscrate(values, thresholds) {
146
+ const canvas = document.createElement('canvas');
147
+ const ctx = canvas.getContext('2d');
166
148
  canvas.width = 256;
167
149
  canvas.height = 1;
168
- var gap = 1.0 / 256;
169
- var gradient = ctx.createLinearGradient(0, 0, 256, 0);
170
- for (var i = 0; i < thresholds.length - 1; i++) {
150
+ const gap = 1.0 / 256;
151
+ const gradient = ctx.createLinearGradient(0, 0, 256, 0);
152
+ for (let i = 0; i < thresholds.length - 1; i++) {
171
153
  gradient.addColorStop(thresholds[i], values[i]);
172
154
  gradient.addColorStop(thresholds[i + 1] - gap, values[i]);
173
155
  }
@@ -176,16 +158,16 @@ function getColorRampDiscrate(values, thresholds) {
176
158
  ctx.fillRect(0, 0, 256, 1);
177
159
  return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);
178
160
  }
179
- function getColorRampInterpolated(values, thresholds) {
180
- var canvas = document.createElement('canvas');
181
- var ctx = canvas.getContext('2d');
161
+ export function getColorRampInterpolated(values, thresholds) {
162
+ const canvas = document.createElement('canvas');
163
+ const ctx = canvas.getContext('2d');
182
164
  canvas.width = 256;
183
165
  canvas.height = 1;
184
- var gradient = ctx.createLinearGradient(0, 0, 256, 0);
166
+ const gradient = ctx.createLinearGradient(0, 0, 256, 0);
185
167
  // const gap = 1.0 / 256;
186
168
  // gradient.addColorStop(thresholds[0], values[0]);
187
169
  // gradient.addColorStop(thresholds[0] + gap, values[1]);
188
- for (var i = 0; i < thresholds.length; i++) {
170
+ for (let i = 0; i < thresholds.length; i++) {
189
171
  gradient.addColorStop(thresholds[i], values[i]);
190
172
  }
191
173
  // gradient.addColorStop(thresholds[thresholds.length - 1] - gap, values[values.length - 1]);
@@ -198,8 +180,7 @@ function getColorRampInterpolated(values, thresholds) {
198
180
  * thresholds: n number of thresholds. Ex: [0, 10, 20]
199
181
  * mode: [discrete, interpolated,]
200
182
  */
201
- function getColorRampModed(values, thresholds, mode) {
202
- if (mode === void 0) { mode = "interpolated"; }
183
+ export function getColorRampModed(values, thresholds, mode = "interpolated") {
203
184
  if (mode === "discrete") {
204
185
  return getColorRampDiscrate(values, thresholds);
205
186
  }
@@ -210,8 +191,8 @@ function getColorRampModed(values, thresholds, mode) {
210
191
  throw new Error("mode is not valid");
211
192
  }
212
193
  }
213
- function defaultColorRamp() {
214
- var defaultRampColors = [
194
+ export function defaultColorRamp() {
195
+ const defaultRampColors = [
215
196
  [0.0, '#5e4fa2'],
216
197
  [0.15, '#3288bd'],
217
198
  [0.20, '#66c2a5'],
@@ -225,12 +206,12 @@ function defaultColorRamp() {
225
206
  ];
226
207
  return getColorRamp(defaultRampColors);
227
208
  }
228
- function reloadCurrentGLProgram() {
209
+ export function reloadCurrentGLProgram() {
229
210
  return function (target, key, descriptor) {
230
- var originalMethod = descriptor.value;
211
+ const originalMethod = descriptor.value;
231
212
  descriptor.value = function () {
232
- var gl = target.gl;
233
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
213
+ const gl = target.gl;
214
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
234
215
  originalMethod.apply(this, arguments);
235
216
  gl.useProgram(currentProgram);
236
217
  };
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.centigradePlus90ToVectorArray = centigradePlus90ToVectorArray;
4
- function centigradePlus90ToVectorArray(centigradeArray, noDataValue) {
5
- if (noDataValue === void 0) { noDataValue = -9999; }
6
- var vectorArray = new Float32Array(centigradeArray.length * 2);
7
- for (var i = 0; i < centigradeArray.length; i++) {
1
+ function centigradePlus90ToVectorArray(centigradeArray, noDataValue = -9999) {
2
+ const vectorArray = new Float32Array(centigradeArray.length * 2);
3
+ for (let i = 0; i < centigradeArray.length; i++) {
8
4
  if (centigradeArray[i] === noDataValue) {
9
5
  vectorArray.set([0, 0], i * 2);
10
6
  continue;
11
7
  }
12
- var rad = (centigradeArray[i] + 90.0) * Math.PI / 180;
13
- var x = Math.cos(rad);
14
- var y = Math.sin(rad);
8
+ const rad = (centigradeArray[i] + 90.0) * Math.PI / 180;
9
+ const x = Math.cos(rad);
10
+ const y = Math.sin(rad);
15
11
  vectorArray.set([x, y], i * 2);
16
12
  }
17
13
  return vectorArray;
18
14
  }
15
+ export { centigradePlus90ToVectorArray };
@@ -1,10 +1,3 @@
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
- var plugin_1 = __importDefault(require("./plugin"));
8
- exports.VectorFieldWaveParticle = plugin_1.default;
9
- var adaptor_1 = require("./adaptor");
10
- Object.defineProperty(exports, "centigradePlus90ToVectorArray", { enumerable: true, get: function () { return adaptor_1.centigradePlus90ToVectorArray; } });
1
+ import VectorFieldWaveParticle from "./plugin";
2
+ import { centigradePlus90ToVectorArray } from "./adaptor";
3
+ export { centigradePlus90ToVectorArray, VectorFieldWaveParticle };
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var programs_1 = require("../programs");
4
- var util_1 = require("../util");
5
- var programs_2 = require("../programs");
6
- var programs_3 = require("../programs");
7
- var PixelBasedMove = programs_2.vectorfield.PixelBasedMove, DrawRectangleParticles = programs_2.vectorfield.DrawRectangleParticles, PingPongBufferManager = programs_2.vectorfield.PingPongBufferManager, WaveParticalUboManager = programs_2.vectorfield.WaveParticalUboManager;
8
- var MoveParticle = PixelBasedMove;
9
- var DrawParticle = DrawRectangleParticles;
1
+ import { GlobeShellWiggle } from "../programs";
2
+ import { defaultblendfunction } from "../util";
3
+ import { vectorfield } from "../programs";
4
+ import { FadeAway } from "../programs";
5
+ const { PixelBasedMove, DrawRectangleParticles, PingPongBufferManager, WaveParticalUboManager } = vectorfield;
6
+ const MoveParticle = PixelBasedMove;
7
+ const DrawParticle = DrawRectangleParticles;
10
8
  /**
11
9
  * STEPS:
12
10
  * 1. move particle | buffers: read b1 write b2 | swap buffers b1 <-> b2
@@ -15,10 +13,9 @@ var DrawParticle = DrawRectangleParticles;
15
13
  * 4. fade drawTexture1 to drawTexture2 | swap textures
16
14
  *
17
15
  */
18
- var MAX_PIXELS_ON_DIMENSION = 2200;
19
- var Plugin = /** @class */ (function () {
20
- function Plugin(id, _a) {
21
- var _b = _a === void 0 ? {} : _a, dataWidth = _b.dataWidth, dataHeight = _b.dataHeight, _c = _b.fadeOpacity, fadeOpacity = _c === void 0 ? 0.83 : _c, _d = _b.opacity, opacity = _d === void 0 ? 0.75 : _d, _e = _b.minLon, minLon = _e === void 0 ? -180 : _e, _f = _b.minLat, minLat = _f === void 0 ? -90 : _f, _g = _b.maxLon, maxLon = _g === void 0 ? 180 : _g, _h = _b.maxLat, maxLat = _h === void 0 ? 90 : _h, _j = _b.patricleCount, patricleCount = _j === void 0 ? 8000 : _j, _k = _b.flipY, flipY = _k === void 0 ? true : _k, _l = _b.drawTextureMaxPixelOnDimension, drawTextureMaxPixelOnDimension = _l === void 0 ? MAX_PIXELS_ON_DIMENSION : _l;
16
+ const MAX_PIXELS_ON_DIMENSION = 2200;
17
+ export default class Plugin {
18
+ 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 } = {}) {
22
19
  this.id = id;
23
20
  this.globe = null;
24
21
  this.gl = null;
@@ -38,23 +35,23 @@ var Plugin = /** @class */ (function () {
38
35
  this._dataHeight = dataHeight;
39
36
  this._drawTextureMaxPixelOnDimension = drawTextureMaxPixelOnDimension;
40
37
  this._globeshellparameters = {
41
- minLon: minLon,
42
- maxLon: maxLon,
43
- minLat: minLat,
44
- maxLat: maxLat,
38
+ minLon,
39
+ maxLon,
40
+ minLat,
41
+ maxLat,
45
42
  };
46
43
  this._stepIndex = 0;
47
44
  this._fullCycleStepCount = 3;
48
45
  this._isFreed = false;
49
46
  }
50
- Plugin.prototype.init = function (globe, gl) {
47
+ init(globe, gl) {
51
48
  this.globe = globe;
52
49
  this.gl = gl;
53
50
  this.moveParticle = new MoveParticle(gl);
54
51
  this.drawParticle = new DrawParticle(gl);
55
- this.fadeAway = new programs_3.FadeAway(gl);
56
- this.globeShellWiggle = new programs_1.GlobeShellWiggle(gl, globe, this._globeshellparameters);
57
- var inPositionLocation = this.moveParticle.getInPositionLocation();
52
+ this.fadeAway = new FadeAway(gl);
53
+ this.globeShellWiggle = new GlobeShellWiggle(gl, globe, this._globeshellparameters);
54
+ const inPositionLocation = this.moveParticle.getInPositionLocation();
58
55
  this.bufferManager = new PingPongBufferManager(gl, this._particleCount, inPositionLocation);
59
56
  this._rgVectorFieldTexture = this._createRGTexture();
60
57
  this.waveUbo = new WaveParticalUboManager(gl, 0);
@@ -63,10 +60,10 @@ var Plugin = /** @class */ (function () {
63
60
  this.setBBox(this._globeshellparameters);
64
61
  this.setOpacity(this._opacity);
65
62
  this.____drawIndex = 0;
66
- };
67
- Plugin.prototype._createDrawTexture = function () {
68
- var gl = this.gl;
69
- var texture = gl.createTexture();
63
+ }
64
+ _createDrawTexture() {
65
+ const gl = this.gl;
66
+ const texture = gl.createTexture();
70
67
  gl.bindTexture(gl.TEXTURE_2D, texture);
71
68
  // gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2200, 2200, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
72
69
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this._drawTextureResolution.width, this._drawTextureResolution.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
@@ -76,14 +73,14 @@ var Plugin = /** @class */ (function () {
76
73
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
77
74
  gl.bindTexture(gl.TEXTURE_2D, null);
78
75
  return texture;
79
- };
80
- Plugin.prototype._step = function () {
76
+ }
77
+ _step() {
81
78
  this._stepIndex = (this._stepIndex + 1) % this._fullCycleStepCount;
82
- };
83
- Plugin.prototype.draw3D = function () {
79
+ }
80
+ draw3D() {
84
81
  if (this._isFreed)
85
82
  return;
86
- var _a = this, gl = _a.gl, moveParticle = _a.moveParticle, drawParticle = _a.drawParticle, bufferManager = _a.bufferManager, globeShellWiggle = _a.globeShellWiggle, waveUbo = _a.waveUbo, fadeAway = _a.fadeAway, _rgVectorFieldTexture = _a._rgVectorFieldTexture;
83
+ const { gl, moveParticle, drawParticle, bufferManager, globeShellWiggle, waveUbo, fadeAway, _rgVectorFieldTexture } = this;
87
84
  gl.disable(gl.DEPTH_TEST);
88
85
  if (this._stepIndex === 0) {
89
86
  waveUbo.update({ random_seed: Math.random() });
@@ -93,8 +90,8 @@ var Plugin = /** @class */ (function () {
93
90
  }
94
91
  else if (this._stepIndex === 1) {
95
92
  this.____drawIndex = 1 - this.____drawIndex;
96
- var canvasWidth = gl.canvas.width;
97
- var canvasHeight = gl.canvas.height;
93
+ const canvasWidth = gl.canvas.width;
94
+ const canvasHeight = gl.canvas.height;
98
95
  // gl.viewport(0, 0, 2200, 2200);
99
96
  gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
100
97
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
@@ -105,8 +102,8 @@ var Plugin = /** @class */ (function () {
105
102
  gl.viewport(0, 0, canvasWidth, canvasHeight);
106
103
  }
107
104
  else {
108
- var canvasWidth = gl.canvas.width;
109
- var canvasHeight = gl.canvas.height;
105
+ const canvasWidth = gl.canvas.width;
106
+ const canvasHeight = gl.canvas.height;
110
107
  // gl.viewport(0, 0, 2200, 2200);
111
108
  gl.viewport(0, 0, this._drawTextureResolution.width, this._drawTextureResolution.height);
112
109
  gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
@@ -116,23 +113,23 @@ var Plugin = /** @class */ (function () {
116
113
  gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this._drawTextures[1 - this.____drawIndex], 0);
117
114
  fadeAway.draw(this._drawTextures[this.____drawIndex], this._fadeOpacity);
118
115
  gl.bindFramebuffer(gl.FRAMEBUFFER, null);
119
- (0, util_1.defaultblendfunction)(gl);
116
+ defaultblendfunction(gl);
120
117
  gl.viewport(0, 0, canvasWidth, canvasHeight);
121
118
  }
122
119
  globeShellWiggle.setTexture(this._drawTextures[this.____drawIndex]);
123
120
  globeShellWiggle.draw();
124
121
  this._step();
125
122
  gl.enable(gl.DEPTH_TEST);
126
- };
127
- Plugin.prototype.setCycleStepCount = function (value) {
123
+ }
124
+ setCycleStepCount(value) {
128
125
  if (value < 3) {
129
126
  this._fullCycleStepCount = 3;
130
127
  }
131
128
  this._fullCycleStepCount = value;
132
- };
133
- Plugin.prototype._createRGTexture = function () {
134
- var _a = this, gl = _a.gl, _dataWidth = _a._dataWidth, _dataHeight = _a._dataHeight;
135
- var texture = gl.createTexture();
129
+ }
130
+ _createRGTexture() {
131
+ const { gl, _dataWidth, _dataHeight, } = this;
132
+ const texture = gl.createTexture();
136
133
  // R32F
137
134
  gl.bindTexture(gl.TEXTURE_2D, texture);
138
135
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, null);
@@ -142,10 +139,10 @@ var Plugin = /** @class */ (function () {
142
139
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
143
140
  gl.bindTexture(gl.TEXTURE_2D, null);
144
141
  return texture;
145
- };
142
+ }
146
143
  // TODO: free all resources
147
- Plugin.prototype.free = function () {
148
- var _a = this, gl = _a.gl, fadeAway = _a.fadeAway, globeShellWiggle = _a.globeShellWiggle, _rgVectorFieldTexture = _a._rgVectorFieldTexture, bufferManager = _a.bufferManager, waveUbo = _a.waveUbo, _drawTextures = _a._drawTextures, _frameBuffer = _a._frameBuffer;
144
+ free() {
145
+ const { gl, fadeAway, globeShellWiggle, _rgVectorFieldTexture, bufferManager, waveUbo, _drawTextures, _frameBuffer } = this;
149
146
  this._isFreed = true;
150
147
  fadeAway.free();
151
148
  globeShellWiggle.free();
@@ -158,16 +155,15 @@ var Plugin = /** @class */ (function () {
158
155
  this.drawParticle = null;
159
156
  bufferManager.free();
160
157
  waveUbo.free();
161
- _drawTextures.forEach(function (texture) { return gl.deleteTexture(texture); });
158
+ _drawTextures.forEach(texture => gl.deleteTexture(texture));
162
159
  gl.deleteFramebuffer(_frameBuffer);
163
- };
160
+ }
164
161
  // setters
165
- Plugin.prototype.setParticleCount = function (value) {
162
+ setParticleCount(value) {
166
163
  this._particleCount = value;
167
164
  this.bufferManager.setParticleCount(value);
168
- };
169
- Plugin.prototype.setVectorFieldData = function (data, _a) {
170
- var _b = _a === void 0 ? {} : _a, _c = _b.dataWidth, dataWidth = _c === void 0 ? null : _c, _d = _b.dataHeight, dataHeight = _d === void 0 ? null : _d, flipY = _b.flipY;
165
+ }
166
+ setVectorFieldData(data, { dataWidth = null, dataHeight = null, flipY } = {}) {
171
167
  if (dataWidth !== null && dataHeight !== null) {
172
168
  this._dataWidth = dataWidth;
173
169
  this._dataHeight = dataHeight;
@@ -176,25 +172,25 @@ var Plugin = /** @class */ (function () {
176
172
  this._flipY = flipY;
177
173
  }
178
174
  this.__data = data;
179
- var _e = this, gl = _e.gl, _dataWidth = _e._dataWidth, _dataHeight = _e._dataHeight;
175
+ const { gl, _dataWidth, _dataHeight } = this;
180
176
  gl.bindTexture(gl.TEXTURE_2D, this._rgVectorFieldTexture);
181
177
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, this._flipY);
182
178
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, _dataWidth, _dataHeight, 0, gl.RG, gl.FLOAT, data);
183
179
  gl.bindTexture(gl.TEXTURE_2D, null);
184
180
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
185
- };
186
- Plugin.prototype.setHeight = function (value) {
181
+ }
182
+ setHeight(value) {
187
183
  this.globeShellWiggle.setHeight(value);
188
- };
189
- Plugin.prototype.setDropRate = function (value) {
184
+ }
185
+ setDropRate(value) {
190
186
  this.waveUbo.update({ drop_rate: value });
191
- };
192
- Plugin.prototype.__readAndWriteTextureData = function () {
193
- var _a = this, gl = _a.gl, _rgVectorFieldTexture = _a._rgVectorFieldTexture, _dataWidth = _a._dataWidth, _dataHeight = _a._dataHeight;
187
+ }
188
+ __readAndWriteTextureData() {
189
+ const { gl, _rgVectorFieldTexture, _dataWidth, _dataHeight } = this;
194
190
  // Step 1: Bind the texture to a framebuffer
195
191
  // Step 2: Read the texture data into a Float32Array
196
192
  gl.bindTexture(gl.TEXTURE_2D, _rgVectorFieldTexture);
197
- var textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
193
+ const textureData = new Float32Array(_dataWidth * _dataHeight * 2); // RG32F has 2 components per pixel
198
194
  gl.readPixels(0, 0, _dataWidth, _dataHeight, gl.RG, gl.FLOAT, textureData);
199
195
  gl.bindTexture(gl.TEXTURE_2D, null);
200
196
  // Step 3: Create a new texture and write the data back
@@ -203,18 +199,17 @@ var Plugin = /** @class */ (function () {
203
199
  // Replace the old texture with the new one
204
200
  this._rgVectorFieldTexture = this._createRGTexture();
205
201
  this.setVectorFieldData(textureData);
206
- };
207
- Plugin.prototype._drawTextureSizeFromBbox = function (_a) {
208
- var minLon = _a.minLon, minLat = _a.minLat, maxLon = _a.maxLon, maxLat = _a.maxLat;
209
- var horizon;
202
+ }
203
+ _drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat }) {
204
+ let horizon;
210
205
  if (minLon > 0 && maxLon < 0) {
211
206
  horizon = 360 - minLon + maxLon;
212
207
  }
213
208
  else {
214
209
  horizon = maxLon - minLon;
215
210
  }
216
- var vertical = maxLat - minLat;
217
- var width, height;
211
+ const vertical = maxLat - minLat;
212
+ let width, height;
218
213
  if (horizon > vertical) {
219
214
  width = this._drawTextureMaxPixelOnDimension;
220
215
  height = Math.floor(this._drawTextureMaxPixelOnDimension * vertical / horizon);
@@ -224,48 +219,45 @@ var Plugin = /** @class */ (function () {
224
219
  width = Math.floor(this._drawTextureMaxPixelOnDimension * horizon / vertical);
225
220
  }
226
221
  return {
227
- width: width,
228
- height: height
222
+ width,
223
+ height
229
224
  };
230
- };
231
- Plugin.prototype.setDrawTextureMaxPixelOnDimension = function (value) {
225
+ }
226
+ setDrawTextureMaxPixelOnDimension(value) {
232
227
  this._drawTextureMaxPixelOnDimension = value;
233
228
  this._drawTextureResolution = this._drawTextureSizeFromBbox(this._globeshellparameters);
234
229
  this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
235
230
  this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
236
- };
237
- Plugin.prototype.setParticleSpeed = function (value) {
231
+ }
232
+ setParticleSpeed(value) {
238
233
  this.waveUbo.update({ range: value });
239
- };
240
- Plugin.prototype.setFadeOpacity = function (value) {
234
+ }
235
+ setFadeOpacity(value) {
241
236
  this._fadeOpacity = value;
242
- };
243
- Plugin.prototype.setOpacity = function (value) {
237
+ }
238
+ setOpacity(value) {
244
239
  this.globeShellWiggle.setOpacity(value);
245
- };
246
- Plugin.prototype.setParticleDimensions = function (tail, wing) {
240
+ }
241
+ setParticleDimensions(tail, wing) {
247
242
  if (0 < tail || 0 < wing) {
248
243
  this.waveUbo.update({ tail_wing_base_limp: [tail, wing] });
249
244
  }
250
245
  else {
251
246
  console.error("tail and wing must be greater than 0");
252
247
  }
253
- };
254
- Plugin.prototype.setParticleColor = function (color) {
248
+ }
249
+ setParticleColor(color) {
255
250
  if (color.length !== 3) {
256
251
  console.error("color must be an array of rgb elements");
257
252
  return;
258
253
  }
259
- this.waveUbo.update({ color: color });
260
- };
261
- Plugin.prototype.setBBox = function (_a) {
262
- var minLon = _a.minLon, minLat = _a.minLat, maxLon = _a.maxLon, maxLat = _a.maxLat;
263
- this._globeshellparameters = { minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat };
264
- this.globeShellWiggle.setBBox({ minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat });
265
- this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon: minLon, minLat: minLat, maxLon: maxLon, maxLat: maxLat });
254
+ this.waveUbo.update({ color });
255
+ }
256
+ setBBox({ minLon, minLat, maxLon, maxLat }) {
257
+ this._globeshellparameters = { minLon, minLat, maxLon, maxLat };
258
+ this.globeShellWiggle.setBBox({ minLon, minLat, maxLon, maxLat });
259
+ this._drawTextureResolution = this._drawTextureSizeFromBbox({ minLon, minLat, maxLon, maxLat });
266
260
  this.waveUbo.update({ draw_texture_size: [this._drawTextureResolution.width, this._drawTextureResolution.height] });
267
261
  this._drawTextures = [this._createDrawTexture(), this._createDrawTexture()];
268
- };
269
- return Plugin;
270
- }());
271
- exports.default = Plugin;
262
+ }
263
+ }