@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,257 +0,0 @@
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
- }
@@ -1,66 +0,0 @@
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;
@@ -1,101 +0,0 @@
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;
@@ -1,100 +0,0 @@
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;
@@ -1,8 +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.Float2LegendWithRatio = void 0;
7
- const object_1 = __importDefault(require("./object"));
8
- exports.Float2LegendWithRatio = object_1.default;