@pirireis/webglobeplugins 0.9.7 → 0.9.8

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 (212) hide show
  1. package/dist/Math/angle-calculation.js +15 -0
  2. package/dist/Math/arc.js +65 -0
  3. package/dist/Math/bounds/line-bbox.js +188 -0
  4. package/dist/Math/constants.js +9 -0
  5. package/dist/Math/frustum/camera.js +24 -0
  6. package/dist/Math/frustum/from-globeinfo.js +48 -0
  7. package/dist/Math/frustum/types.js +2 -0
  8. package/dist/Math/globe-util/horizon-plane.js +112 -0
  9. package/dist/Math/index.js +1 -0
  10. package/dist/Math/juction/arc-plane.js +83 -0
  11. package/dist/Math/juction/line-sphere.js +25 -0
  12. package/dist/Math/juction/plane-plane.js +58 -0
  13. package/dist/Math/line.js +56 -0
  14. package/dist/Math/matrix4.js +1 -0
  15. package/dist/Math/methods.js +201 -0
  16. package/dist/Math/plane.js +60 -0
  17. package/dist/Math/quaternion.js +104 -0
  18. package/dist/Math/types.js +2 -0
  19. package/dist/Math/utils.js +4 -0
  20. package/dist/Math/vec3.js +126 -0
  21. package/dist/algorithms/search-binary.js +19 -0
  22. package/dist/altitude-locator/adaptors.js +1 -0
  23. package/dist/altitude-locator/draw-subset-obj.js +18 -0
  24. package/dist/altitude-locator/keymethod.js +1 -0
  25. package/dist/altitude-locator/plugin.js +341 -0
  26. package/dist/altitude-locator/types.js +23 -0
  27. package/dist/arrowfield/adaptor.js +14 -0
  28. package/dist/arrowfield/index.js +10 -0
  29. package/dist/arrowfield/plugin.js +86 -0
  30. package/dist/bearing-line/index.js +8 -0
  31. package/dist/bearing-line/plugin.js +449 -0
  32. package/dist/circle-line-chain/chain-list-map.js +205 -0
  33. package/dist/circle-line-chain/init.js +1 -0
  34. package/dist/circle-line-chain/plugin.js +424 -0
  35. package/dist/circle-line-chain/util.js +5 -0
  36. package/dist/compass-rose/compass-rose-padding-flat.js +225 -0
  37. package/dist/compass-rose/compass-text-writer.js +153 -0
  38. package/dist/compass-rose/index.js +7 -0
  39. package/dist/compassrose/compassrose.js +296 -0
  40. package/dist/compassrose/index.js +8 -0
  41. package/dist/globe-types.js +1 -0
  42. package/dist/heatwave/index.js +10 -0
  43. package/dist/heatwave/isobar/objectarraylabels.js +202 -0
  44. package/dist/heatwave/isobar/plugin.js +343 -0
  45. package/dist/heatwave/isobar/quadtreecontours.js +300 -0
  46. package/dist/heatwave/plugins/heatwaveglobeshell.js +206 -0
  47. package/dist/index.js +58 -0
  48. package/dist/jest.config.js +7 -0
  49. package/dist/partialrings/buffer-manager.js +81 -0
  50. package/dist/partialrings/index.js +41 -0
  51. package/dist/partialrings/plugin.js +135 -0
  52. package/dist/partialrings/program.js +286 -0
  53. package/dist/pin/pin-object-array.js +305 -0
  54. package/dist/pin/pin-point-totem.js +60 -0
  55. package/dist/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  56. package/dist/point-heat-map/index.js +1 -0
  57. package/dist/point-heat-map/plugin-webworker.js +126 -0
  58. package/dist/point-heat-map/point-to-heat-map-flow.js +127 -0
  59. package/dist/point-tracks/key-methods.js +5 -0
  60. package/dist/point-tracks/plugin.js +338 -0
  61. package/dist/programs/arrowfield/index.js +7 -0
  62. package/dist/programs/arrowfield/logic.js +257 -0
  63. package/dist/programs/arrowfield/object.js +66 -0
  64. package/dist/programs/data2legend/density-to-legend.js +101 -0
  65. package/dist/programs/data2legend/point-to-density-texture.js +100 -0
  66. package/dist/programs/float2legendwithratio/index.js +8 -0
  67. package/dist/programs/float2legendwithratio/logic.js +171 -0
  68. package/dist/programs/float2legendwithratio/object.js +110 -0
  69. package/dist/programs/globe-util/is-globe-moved.js +21 -0
  70. package/dist/programs/globeshell/index.js +8 -0
  71. package/dist/programs/globeshell/noise/noises.js +1 -0
  72. package/dist/programs/globeshell/wiggle/index.js +8 -0
  73. package/dist/programs/globeshell/wiggle/logic.js +345 -0
  74. package/dist/programs/globeshell/wiggle/object.js +72 -0
  75. package/dist/programs/helpers/blender/index.js +1 -0
  76. package/dist/programs/helpers/blender/program.js +79 -0
  77. package/dist/programs/helpers/fadeaway/index.js +7 -0
  78. package/dist/programs/helpers/fadeaway/logic.js +72 -0
  79. package/dist/programs/helpers/fadeaway/object.js +20 -0
  80. package/dist/programs/helpers/index.js +8 -0
  81. package/dist/programs/index.js +58 -0
  82. package/dist/programs/interface.js +1 -0
  83. package/dist/programs/line-on-globe/angled-line.js +176 -0
  84. package/dist/programs/line-on-globe/circle-accurate-3d.js +141 -0
  85. package/dist/programs/line-on-globe/circle-accurate-flat.js +216 -0
  86. package/dist/programs/line-on-globe/circle-accurate.js +178 -0
  87. package/dist/programs/line-on-globe/circle.js +167 -0
  88. package/dist/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
  89. package/dist/programs/line-on-globe/index.js +1 -0
  90. package/dist/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
  91. package/dist/programs/line-on-globe/linestrip.js +171 -0
  92. package/dist/programs/line-on-globe/naive-accurate-flexible.js +195 -0
  93. package/dist/programs/line-on-globe/to-the-surface.js +111 -0
  94. package/dist/programs/line-on-globe/util.js +8 -0
  95. package/dist/programs/picking/pickable-renderer.js +188 -0
  96. package/dist/programs/point-on-globe/element-globe-surface-glow.js +142 -0
  97. package/dist/programs/point-on-globe/element-point-glow.js +153 -0
  98. package/dist/programs/point-on-globe/square-pixel-point.js +174 -0
  99. package/dist/programs/programcache.js +131 -0
  100. package/dist/programs/rings/distancering/circleflatprogram.js +156 -0
  101. package/dist/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
  102. package/dist/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
  103. package/dist/programs/rings/distancering/index.js +14 -0
  104. package/dist/programs/rings/distancering/paddyflatprogram.js +172 -0
  105. package/dist/programs/rings/distancering/paddyflatprogram2d.js +174 -0
  106. package/dist/programs/rings/distancering/paddyflatprogram3d.js +172 -0
  107. package/dist/programs/rings/distancering/shader.js +1 -0
  108. package/dist/programs/rings/index.js +17 -0
  109. package/dist/programs/rings/partial-ring/piece-of-pie.js +275 -0
  110. package/dist/programs/totems/camerauniformblock.js +160 -0
  111. package/dist/programs/totems/canvas-webglobe-info.js +110 -0
  112. package/dist/programs/totems/gpu-selection-uniform-block.js +108 -0
  113. package/dist/programs/totems/index.js +40 -0
  114. package/dist/programs/two-d/pixel-circle.js +1 -0
  115. package/dist/programs/two-d/pixel-padding-for-compass.js +162 -0
  116. package/dist/programs/util.js +17 -0
  117. package/dist/programs/vectorfields/index.js +23 -0
  118. package/dist/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
  119. package/dist/programs/vectorfields/logics/index.js +12 -0
  120. package/dist/programs/vectorfields/logics/pixelbased.js +142 -0
  121. package/dist/programs/vectorfields/logics/ubo.js +63 -0
  122. package/dist/programs/vectorfields/pingpongbuffermanager.js +76 -0
  123. package/dist/rangerings/enum.js +5 -0
  124. package/dist/rangerings/index.js +15 -0
  125. package/dist/rangerings/plugin.js +560 -0
  126. package/dist/rangerings/rangeringangletext.js +329 -0
  127. package/dist/rangerings/ring-account.js +117 -0
  128. package/dist/shaders/fragment-toy/firework.js +58 -0
  129. package/dist/shaders/fragment-toy/singularity.js +59 -0
  130. package/dist/shape-on-terrain/arc/naive/plugin.js +252 -0
  131. package/dist/timetracks/adaptors-line-strip.js +71 -0
  132. package/dist/timetracks/adaptors.js +122 -0
  133. package/dist/timetracks/index.js +19 -0
  134. package/dist/timetracks/plugin-line-strip.js +250 -0
  135. package/dist/timetracks/plugin.js +258 -0
  136. package/dist/timetracks/program-line-strip.js +611 -0
  137. package/dist/timetracks/program.js +772 -0
  138. package/dist/timetracks/programpoint-line-strip.js +154 -0
  139. package/dist/timetracks/programpoint.js +147 -0
  140. package/dist/types.js +15 -0
  141. package/dist/util/account/bufferoffsetmanager.js +179 -0
  142. package/dist/util/account/index.js +23 -0
  143. package/dist/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
  144. package/dist/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
  145. package/dist/util/account/single-attribute-buffer-management/index.js +9 -0
  146. package/dist/util/account/single-attribute-buffer-management/object-store.js +51 -0
  147. package/dist/util/account/single-attribute-buffer-management/types.js +2 -0
  148. package/dist/util/account/util.js +22 -0
  149. package/dist/util/algorithms/index.js +1 -0
  150. package/dist/util/algorithms/search-binary.js +28 -0
  151. package/dist/util/check/get.js +18 -0
  152. package/dist/util/check/index.js +1 -0
  153. package/dist/util/check/typecheck.js +49 -0
  154. package/dist/util/geometry/index.js +51 -0
  155. package/dist/util/gl-util/buffer/attribute-loader.js +69 -0
  156. package/dist/util/gl-util/buffer/index.js +6 -0
  157. package/dist/util/gl-util/buffer/types.js +1 -0
  158. package/dist/util/gl-util/draw-options/methods.js +38 -0
  159. package/dist/util/gl-util/draw-options/types.js +15 -0
  160. package/dist/util/gl-util/uniform-block/manager.js +156 -0
  161. package/dist/util/gl-util/uniform-block/shader.js +1 -0
  162. package/dist/util/gl-util/uniform-block/types.js +8 -0
  163. package/dist/util/heatwavedatamanager/datamanager.js +152 -0
  164. package/dist/util/heatwavedatamanager/index.js +10 -0
  165. package/dist/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
  166. package/dist/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
  167. package/dist/util/index.js +57 -0
  168. package/dist/util/interpolation/index.js +1 -0
  169. package/dist/util/interpolation/timetrack/index.js +5 -0
  170. package/dist/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
  171. package/dist/util/interpolation/timetrack/web-worker-str.js +183 -0
  172. package/dist/util/interpolation/timetrack/web-worker.js +48 -0
  173. package/dist/util/jshelpers/data-filler.js +20 -0
  174. package/dist/util/jshelpers/equality.js +20 -0
  175. package/dist/util/jshelpers/index.js +37 -0
  176. package/dist/util/jshelpers/timefilters.js +32 -0
  177. package/dist/util/picking/fence.js +46 -0
  178. package/dist/util/picking/picker-displayer.js +139 -0
  179. package/dist/util/programs/draw-texture-on-canvas.js +89 -0
  180. package/dist/util/programs/index.js +17 -0
  181. package/dist/util/programs/shapesonglobe.js +214 -0
  182. package/dist/util/programs/supersampletotextures.js +113 -0
  183. package/dist/util/programs/texturetoglobe.js +182 -0
  184. package/dist/util/shaderfunctions/geometrytransformations.js +340 -0
  185. package/dist/util/shaderfunctions/index.js +18 -0
  186. package/dist/util/shaderfunctions/nodata.js +11 -0
  187. package/dist/util/shaderfunctions/noisefunctions.js +43 -0
  188. package/dist/util/surface-line-data/arc-bboxes.js +25 -0
  189. package/dist/util/surface-line-data/arcs-to-cuts.js +50 -0
  190. package/dist/util/surface-line-data/cut-arc.js +1 -0
  191. package/dist/util/surface-line-data/flow.js +28 -0
  192. package/dist/util/surface-line-data/rbush-manager.js +1 -0
  193. package/dist/util/surface-line-data/types.js +1 -0
  194. package/dist/util/surface-line-data/web-worker.js +1 -0
  195. package/dist/util/webglobe/gldefaultstates.js +7 -0
  196. package/dist/util/webglobe/index.js +18 -0
  197. package/dist/util/webglobe/rasteroverlay.js +78 -0
  198. package/dist/util/webglobjectbuilders.js +388 -0
  199. package/dist/util/webglobjectbuilders1.js +237 -0
  200. package/dist/waveparticles/adaptor.js +17 -0
  201. package/dist/waveparticles/index.js +10 -0
  202. package/dist/waveparticles/plugin.js +266 -0
  203. package/dist/wind/imagetovectorfieldandmagnitude.js +35 -0
  204. package/dist/wind/index.js +14 -0
  205. package/dist/wind/plugin.js +926 -0
  206. package/dist/wind/vectorfieldimage.js +25 -0
  207. package/dist/write-text/attached-text-writer.js +91 -0
  208. package/dist/write-text/context-text.js +98 -0
  209. package/dist/write-text/context-text3.js +155 -0
  210. package/dist/write-text/index.js +5 -0
  211. package/dist/write-text/writer-plugin.js +8 -0
  212. package/package.json +1 -1
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const util_1 = require("../../util");
4
+ const programcache_1 = require("../programcache");
5
+ const totems_1 = require("../totems");
6
+ const arrowVertexShader = `#version 300 es
7
+ #define R 6378.137
8
+ #define PI 3.1415926535897932384626433832795
9
+ #define POLE 20037508.34
10
+ #define POLE_BY_PI 6366198.2
11
+ #define HALF_PI 1.5707963267948966192313216916398
12
+
13
+ uniform sampler2D rotation; // rotation of arrow
14
+
15
+ out vec4 v_color;
16
+
17
+ layout(std140) uniform CameraBlock {
18
+ mat4 u_view;
19
+ mat4 u_projection;
20
+ vec3 u_translate;
21
+ bool u_is3D;
22
+ vec2 u_mapWH;
23
+ vec2 u_scrWH;
24
+ float u_zlevel;
25
+ };
26
+
27
+ layout(std140) uniform ArrowBlock {
28
+ vec4 u_color;
29
+ vec2 u_bbox_offset_rad;
30
+ vec2 u_bbox_size_rad;
31
+ vec2 u_resolution;
32
+ float u_length_ratio;
33
+ float u_width_ratio;
34
+ float u_height;
35
+ float u_no_data_value;
36
+ };
37
+
38
+ vec2 f_texCoord(){
39
+ float fID = float(gl_InstanceID);
40
+ float x = mod( fID, u_resolution.x ) / ( u_resolution.x - 1.0);
41
+ float y = 1.0 - floor( fID / u_resolution.x ) / ( u_resolution.y - 1.0);
42
+ return vec2(x, y);
43
+ }
44
+
45
+ vec2 f_radCoord(vec2 texCoord){
46
+ float x = (texCoord.x * u_bbox_size_rad.x ) + u_bbox_offset_rad.x;
47
+ float y = (texCoord.y * u_bbox_size_rad.y ) + u_bbox_offset_rad.y;
48
+ return vec2(x, y);
49
+ }
50
+
51
+ vec3 f_onSphere(vec2 radCoord){
52
+ float x = sin(radCoord.y) * cos(radCoord.x);
53
+ float y = sin(radCoord.y) * sin(radCoord.x);
54
+ float z = cos(radCoord.y);
55
+ return vec3(x, y, z) * (R + u_height);
56
+ }
57
+
58
+
59
+ vec2 f_onFlat(vec2 radCoord){
60
+ float mercX = radCoord.x * POLE_BY_PI;
61
+ float mercY = log(tan(HALF_PI - radCoord.y * 0.5)) * POLE_BY_PI;
62
+ float normX = ( mercX - u_translate.x ) / u_mapWH.x;
63
+ float normY = ( mercY - u_translate.y ) / u_mapWH.y;
64
+ return vec2(normX, normY);
65
+ }
66
+
67
+ void main() {
68
+ // escape if no data
69
+ vec2 texCoord = f_texCoord();
70
+ vec2 geoCoord = vec2( texCoord.x , 1.0 - texCoord.y );
71
+
72
+
73
+ float angle = texture(rotation, texCoord).r;
74
+
75
+ if ( angle == u_no_data_value ) {
76
+ gl_Position = vec4(-2.0, -2.0, 0.0, 1.0);
77
+ return;
78
+ }
79
+ vec2 arrowLimb;
80
+ if (0.0 == mod(float(gl_VertexID), 2.0)) {
81
+ arrowLimb = vec2(0.0, 0.0);
82
+ } else if (gl_VertexID == 1) {
83
+ // tail
84
+ arrowLimb = vec2( cos(angle), sin(angle)) * u_length_ratio / (170.0 );
85
+ } else if (gl_VertexID == 3) {
86
+ // right wing
87
+ arrowLimb = vec2( cos(angle + 0.45), sin(angle + 0.45)) * u_width_ratio / (170.0 );
88
+ } else if (gl_VertexID == 5) {
89
+ // left wing
90
+ arrowLimb = vec2( cos(angle - 0.45), sin(angle - 0.45)) * u_width_ratio / (170.0 );
91
+ }
92
+
93
+
94
+ vec2 radCoord = f_radCoord(geoCoord + arrowLimb);
95
+ if ( u_is3D ) {
96
+ vec3 spherePos = f_onSphere(radCoord);
97
+ gl_Position = u_projection * u_view * vec4(spherePos - u_translate, 1.0);
98
+ } else {
99
+ vec2 flatPos = f_onFlat(radCoord);
100
+ gl_Position = u_projection * vec4(
101
+ flatPos.x * u_scrWH.x,
102
+ (1.0 - flatPos.y) * u_scrWH.y,
103
+ 0.0, 1.0
104
+ );
105
+ }
106
+
107
+
108
+ v_color = u_color;
109
+ gl_PointSize = 4.0;
110
+ }
111
+ `;
112
+ const arrowFragmentShader = `#version 300 es
113
+ precision highp float;
114
+ in vec4 v_color;
115
+ out vec4 outColor;
116
+
117
+ void main() {
118
+ outColor = v_color;
119
+ }
120
+ `;
121
+ class ArrowFieldLogic {
122
+ constructor() {
123
+ this.gl = null;
124
+ this.globe = null;
125
+ this.cameraUniformBlockTotem = null;
126
+ this.program = null;
127
+ this.cameraBlockBindingPoint = 0;
128
+ this.arrayBlockBindingPoint = 1;
129
+ }
130
+ init(globe, gl) {
131
+ this.gl = gl;
132
+ this.globe = globe;
133
+ this.cameraUniformBlockTotem = programcache_1.globeProgramCache.getProgram(globe, totems_1.CameraUniformBlockTotem);
134
+ this.program = this._createProgram();
135
+ }
136
+ _createProgram() {
137
+ const gl = this.gl;
138
+ const program = (0, util_1.createProgram)(gl, arrowVertexShader, arrowFragmentShader);
139
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraBlock");
140
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
141
+ const arrowBlockIndex = gl.getUniformBlockIndex(program, "ArrowBlock");
142
+ gl.uniformBlockBinding(program, arrowBlockIndex, this.arrayBlockBindingPoint);
143
+ this.textureLocations = {
144
+ rotationLocation: gl.getUniformLocation(program, "rotation"),
145
+ };
146
+ return program;
147
+ }
148
+ getArrowBlockBufferManager() {
149
+ return new ArrowBlockBufferManager(this.gl, this.arrayBlockBindingPoint);
150
+ }
151
+ // initial load type is static.
152
+ // after that, it is dynamic.
153
+ getTextureManager(width, height) {
154
+ return new TextureManager(this.gl, width, height, this.textureLocations);
155
+ }
156
+ draw(arrowBlockManager, textureManager, instanceCount) {
157
+ const { gl, cameraBlockBindingPoint, cameraUniformBlockTotem } = this;
158
+ gl.useProgram(this.program);
159
+ arrowBlockManager.bind();
160
+ textureManager.activate();
161
+ cameraUniformBlockTotem.bind(cameraBlockBindingPoint);
162
+ gl.drawArraysInstanced(gl.LINES, 0, 6, instanceCount);
163
+ // gl.drawArraysInstanced(gl.POINTS, 0, 4, instanceCount);
164
+ cameraUniformBlockTotem.unbind(cameraBlockBindingPoint);
165
+ arrowBlockManager.unbind();
166
+ }
167
+ free() {
168
+ const { gl, program } = this;
169
+ gl.deleteProgram(program);
170
+ programcache_1.globeProgramCache.releaseProgram(this.globe, totems_1.CameraUniformBlockTotem);
171
+ }
172
+ }
173
+ exports.default = ArrowFieldLogic;
174
+ class ArrowBlockBufferManager {
175
+ constructor(gl, bindingPoint) {
176
+ this.gl = gl;
177
+ this.bindingPoint = bindingPoint;
178
+ this.ubo = gl.createBuffer();
179
+ gl.bindBuffer(gl.UNIFORM_BUFFER, this.ubo);
180
+ // 4 + 2+ 2 + 2 + 1 +1 +1 +1+1= 15 ~= 16
181
+ gl.bufferData(gl.UNIFORM_BUFFER, 56, gl.DYNAMIC_DRAW);
182
+ gl.bindBuffer(gl.UNIFORM_BUFFER, null);
183
+ }
184
+ update({ color = null, bboxOffsetRad = null, bboxSizeRad = null, resolution = null, tailLengthRatio = null, wingLengthRatio = null, height = null, opacity = null, noDataValue = null, } = {}) {
185
+ const { gl, ubo } = this;
186
+ gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
187
+ if (color !== null)
188
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color));
189
+ if (opacity !== null)
190
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 12, new Float32Array([opacity]));
191
+ if (bboxOffsetRad !== null)
192
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 16, new Float32Array(bboxOffsetRad));
193
+ if (bboxSizeRad !== null)
194
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 24, new Float32Array(bboxSizeRad));
195
+ if (resolution !== null)
196
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(resolution));
197
+ if (tailLengthRatio !== null)
198
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 40, new Float32Array([tailLengthRatio]));
199
+ if (wingLengthRatio !== null)
200
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 44, new Float32Array([wingLengthRatio]));
201
+ if (height !== null)
202
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 48, new Float32Array([height]));
203
+ if (noDataValue !== null)
204
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 52, new Float32Array([noDataValue]));
205
+ gl.bindBuffer(gl.UNIFORM_BUFFER, null);
206
+ }
207
+ bind() {
208
+ const { gl, ubo, bindingPoint } = this;
209
+ gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, ubo);
210
+ }
211
+ unbind() {
212
+ const { gl, bindingPoint } = this;
213
+ gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, null);
214
+ }
215
+ free() {
216
+ const { gl, ubo } = this;
217
+ gl.deleteBuffer(ubo);
218
+ }
219
+ }
220
+ class TextureManager {
221
+ constructor(gl, width, height, { rotationLocation }) {
222
+ this.gl = gl;
223
+ this.width = width;
224
+ this.height = height;
225
+ this.rotationLocation = rotationLocation;
226
+ this.rotationTexture = this._createFloatTexture();
227
+ }
228
+ _createFloatTexture() {
229
+ const { gl, width, height } = this;
230
+ const texture = gl.createTexture();
231
+ gl.bindTexture(gl.TEXTURE_2D, texture);
232
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
233
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
234
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, null);
235
+ gl.bindTexture(gl.TEXTURE_2D, null);
236
+ return texture;
237
+ }
238
+ setData(rotation) {
239
+ const { gl, rotationTexture, width, height } = this;
240
+ // gl flip y axis
241
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
242
+ gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
243
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, rotation);
244
+ gl.bindTexture(gl.TEXTURE_2D, null);
245
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
246
+ }
247
+ activate() {
248
+ const { gl, rotationTexture } = this;
249
+ gl.activeTexture(gl.TEXTURE0);
250
+ gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
251
+ gl.uniform1i(this.rotationLocation, 0);
252
+ }
253
+ free() {
254
+ const { gl, rotationTexture } = this;
255
+ gl.deleteTexture(rotationTexture);
256
+ }
257
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ // this contains vao, drawCount, ArrowBufferBlock, vao,
3
+ // how to, where to set instanced parameters
4
+ // the vectorfield buffer should be managed outside, since it can be static or dynamic.
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const logic_1 = __importDefault(require("./logic"));
10
+ const programcache_1 = require("../programcache");
11
+ const util_1 = require("../util");
12
+ class ArrowField {
13
+ constructor(gl, globe, { minLon = -180, maxLon = 180, minLat = -90, maxLat = 90, height = 0, opacity = 1, color = [0.04, 0.2, 0.8], targetWidth = 100, targetHeight = 100, dataWidth = null, dataHeight = null, tailLengthRatio = 1, wingLengthRatio = 0.5, noDataValue = null,
14
+ // maxMagnitude = null
15
+ } = {}) {
16
+ this.gl = gl;
17
+ this.globe = globe;
18
+ this.program = programcache_1.globeProgramCache.getProgram(globe, logic_1.default);
19
+ this.arrowBlockManager = this.program.getArrowBlockBufferManager();
20
+ this.instanceCount = targetWidth * targetHeight;
21
+ this.arrowBlockManager.update({ resolution: [targetWidth, targetHeight] });
22
+ this.textureManager = this.program.getTextureManager(dataWidth, dataHeight);
23
+ this.setBBox({ minLon, maxLon, minLat, maxLat });
24
+ this.update({ height, opacity, color, tailLengthRatio, wingLengthRatio, noDataValue });
25
+ }
26
+ setBBox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
27
+ this.bbox = { minLon, maxLon, minLat, maxLat };
28
+ const { bboxSizeRad, bboxOffsetRad } = (0, util_1.longlatbbox2normalbbox)(this.bbox);
29
+ this.arrowBlockManager.update({ bboxSizeRad, bboxOffsetRad });
30
+ this.globe.DrawRender();
31
+ }
32
+ update({ height, opacity, color, resolution, tailLengthRatio, wingLengthRatio, noDataValue } = {}) {
33
+ if (resolution) {
34
+ this.instanceCount = resolution[0] * resolution[1];
35
+ }
36
+ this.arrowBlockManager.update({
37
+ color,
38
+ resolution,
39
+ height,
40
+ opacity,
41
+ tailLengthRatio,
42
+ wingLengthRatio,
43
+ noDataValue,
44
+ });
45
+ this.globe.DrawRender();
46
+ }
47
+ setTargetResolution(width, height) {
48
+ this.instanceCount = width * height;
49
+ this.arrowBlockManager.update({ resolution: [width, height] });
50
+ this.globe.DrawRender();
51
+ }
52
+ draw() {
53
+ const { program, arrowBlockManager, textureManager, instanceCount } = this;
54
+ program.draw(arrowBlockManager, textureManager, instanceCount);
55
+ }
56
+ setData(rotation) {
57
+ this.textureManager.setData(rotation);
58
+ this.globe.DrawRender();
59
+ }
60
+ free() {
61
+ this.arrowBlockManager.free();
62
+ this.textureManager.free();
63
+ programcache_1.globeProgramCache.releaseProgram(this.gl, logic_1.default);
64
+ }
65
+ }
66
+ exports.default = ArrowField;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.densityToLegendProgramCache = void 0;
4
+ const util_1 = require("../../util/");
5
+ const programcache_1 = require("../programcache");
6
+ const vs = `#version 300 es
7
+ precision highp float;
8
+
9
+ uniform sampler2D u_density_texture;
10
+ in vec2 a_position;
11
+
12
+ out vec2 v_texcoord;
13
+
14
+ void main() {
15
+ gl_Position = vec4(a_position, 0.0, 1.0);
16
+ v_texcoord = a_position * 0.5 + 0.5;
17
+ }`;
18
+ const fs = `#version 300 es
19
+ precision highp float;
20
+
21
+ uniform sampler2D u_legend_texture;
22
+ uniform sampler2D u_density_texture;
23
+
24
+ uniform float u_opacity;
25
+ in vec2 v_texcoord;
26
+ out vec4 fragColor;
27
+
28
+ void main() {
29
+ float density = texture(u_density_texture, v_texcoord).r;
30
+ fragColor = texture(u_legend_texture, vec2(density, 0.5));
31
+ fragColor.a *= u_opacity * sqrt(density);
32
+ }`;
33
+ class DensityToLegendProgram {
34
+ constructor(globe) {
35
+ this.globe = globe;
36
+ this.gl = globe.gl;
37
+ this.program = (0, util_1.createProgram)(globe.gl, vs, fs);
38
+ const { gl, program } = this;
39
+ this.uniforms = {
40
+ densityTexture: gl.getUniformLocation(program, "u_density_texture"),
41
+ legendTexture: gl.getUniformLocation(program, "u_legend_texture"),
42
+ opacity: gl.getUniformLocation(program, "u_opacity"),
43
+ };
44
+ { // assign attribute locations
45
+ gl.bindAttribLocation(program, 0, "a_position");
46
+ }
47
+ {
48
+ this.vao = gl.createVertexArray();
49
+ const a_positionLocation = gl.getAttribLocation(program, "a_position");
50
+ gl.bindVertexArray(this.vao);
51
+ const buffer = gl.createBuffer();
52
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
53
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
54
+ -1, -1,
55
+ 1, -1,
56
+ 1, 1,
57
+ -1, 1,
58
+ ]), gl.STATIC_DRAW);
59
+ gl.enableVertexAttribArray(a_positionLocation);
60
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
61
+ gl.bindVertexArray(null);
62
+ // gl.bindBuffer(gl.ARRAY_BUFFER, null);
63
+ this._buffer = buffer;
64
+ }
65
+ {
66
+ this._lastOpacity = 1;
67
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
68
+ gl.useProgram(program);
69
+ gl.uniform1f(this.uniforms.opacity, this._lastOpacity);
70
+ gl.useProgram(currentProgram);
71
+ }
72
+ }
73
+ draw(densityTexture, legendTexture, opacity) {
74
+ const { gl, program, uniforms } = this;
75
+ gl.useProgram(program);
76
+ gl.bindVertexArray(this.vao);
77
+ gl.activeTexture(gl.TEXTURE1);
78
+ gl.bindTexture(gl.TEXTURE_2D, legendTexture);
79
+ gl.uniform1i(uniforms.legendTexture, 1);
80
+ gl.activeTexture(gl.TEXTURE0);
81
+ gl.bindTexture(gl.TEXTURE_2D, densityTexture);
82
+ gl.uniform1i(uniforms.densityTexture, 0);
83
+ if (this._lastOpacity !== opacity) {
84
+ gl.uniform1f(uniforms.opacity, opacity);
85
+ this._lastOpacity = opacity;
86
+ }
87
+ gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
88
+ gl.bindVertexArray(null);
89
+ }
90
+ free() {
91
+ const gl = this.gl;
92
+ gl.deleteVertexArray(this.vao);
93
+ gl.deleteBuffer(this._buffer);
94
+ gl.deleteProgram(this.program);
95
+ }
96
+ }
97
+ const densityToLegendProgramCache = {
98
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, DensityToLegendProgram),
99
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, DensityToLegendProgram)
100
+ };
101
+ exports.densityToLegendProgramCache = densityToLegendProgramCache;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pointToDensityTextureCache = void 0;
4
+ const util_1 = require("../../util/");
5
+ const programcache_1 = require("../programcache");
6
+ const camerauniformblock_1 = require("../totems/camerauniformblock");
7
+ const geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
8
+ const vs = `#version 300 es
9
+ precision highp float;
10
+
11
+ ${camerauniformblock_1.CameraUniformBlockString}
12
+ ${geometrytransformations_1.mercatorXYToGLPosition}
13
+ ${geometrytransformations_1.cartesian3DToGLPosition}
14
+
15
+ in vec3 position;
16
+ uniform float pointSize;
17
+
18
+ void main() {
19
+ if (is3D) {
20
+ gl_Position = cartesian3DToGLPosition(position);
21
+ } else {
22
+ gl_Position = mercatorXYToGLPosition(position.xy);
23
+ }
24
+ gl_PointSize = pointSize;
25
+ }
26
+ `;
27
+ const fs = `#version 300 es
28
+ precision highp float;
29
+ out vec4 fragColor;
30
+
31
+ void main() {
32
+ float r = length(gl_PointCoord - 0.5) * 2.0;
33
+ if (r > 1.0) discard;
34
+ // float density = smoothstep(0.1, 1.0, 1.0 - r);
35
+ fragColor = vec4((15.0/16.0)*sqrt(1.0-sqrt(r)));
36
+ }`;
37
+ class PointHeatmapProgram {
38
+ constructor(globe) {
39
+ this.globe = globe;
40
+ this.gl = globe.gl;
41
+ this._isFreed = false;
42
+ this.program = (0, util_1.createProgram)(globe.gl, vs, fs);
43
+ const { gl, program } = this;
44
+ this.uniforms = {
45
+ pointSize: gl.getUniformLocation(this.program, "pointSize"),
46
+ };
47
+ { // assign attribute locations
48
+ gl.bindAttribLocation(program, 0, "position");
49
+ }
50
+ { // arrange camera uniform block
51
+ this.cameraBlockBingingPoint = 0;
52
+ this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
53
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
54
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBingingPoint);
55
+ }
56
+ { // last values
57
+ this._lastPointSize = 0;
58
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
59
+ gl.useProgram(program);
60
+ gl.uniform1f(this.uniforms.pointSize, this._lastPointSize);
61
+ gl.useProgram(currentProgram);
62
+ }
63
+ }
64
+ createVAO(positionBuffer, vectorSize) {
65
+ const gl = this.gl;
66
+ const vao = gl.createVertexArray();
67
+ gl.bindVertexArray(vao);
68
+ gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
69
+ gl.enableVertexAttribArray(0);
70
+ gl.vertexAttribPointer(0, vectorSize, gl.FLOAT, false, 0, 0);
71
+ gl.bindVertexArray(null);
72
+ return vao;
73
+ }
74
+ draw(vao, length, pointSize = 5.0) {
75
+ const gl = this.gl;
76
+ gl.useProgram(this.program);
77
+ if (pointSize !== this._lastPointSize) {
78
+ gl.uniform1f(this.uniforms.pointSize, pointSize);
79
+ this._lastPointSize = pointSize;
80
+ }
81
+ gl.bindVertexArray(vao);
82
+ this.cameraBlockTotem.bind(this.cameraBlockBingingPoint);
83
+ gl.drawArrays(gl.POINTS, 0, length);
84
+ this.cameraBlockTotem.unbind(this.cameraBlockBingingPoint);
85
+ gl.bindVertexArray(null);
86
+ }
87
+ free() {
88
+ if (this._isFreed)
89
+ return;
90
+ const { gl, globe } = this;
91
+ camerauniformblock_1.CameraUniformBlockTotemCache.release(globe);
92
+ gl.deleteProgram(this.program);
93
+ this._isFreed = true;
94
+ }
95
+ }
96
+ const pointToDensityTextureCache = {
97
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointHeatmapProgram),
98
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointHeatmapProgram)
99
+ };
100
+ exports.pointToDensityTextureCache = pointToDensityTextureCache;
@@ -0,0 +1,8 @@
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.Float2LegendWithRatio = void 0;
7
+ const object_1 = __importDefault(require("./object"));
8
+ exports.Float2LegendWithRatio = object_1.default;