@pirireis/webglobeplugins 0.9.11 → 0.9.12

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 (166) hide show
  1. package/Math/angle-calculation.js +8 -8
  2. package/Math/arc.js +18 -18
  3. package/Math/bounds/line-bbox.js +78 -80
  4. package/Math/constants.js +3 -3
  5. package/Math/juction/arc-plane.js +23 -23
  6. package/Math/juction/line-sphere.js +11 -11
  7. package/Math/juction/plane-plane.js +11 -11
  8. package/Math/line.js +14 -16
  9. package/Math/methods.js +65 -70
  10. package/Math/plane.js +16 -18
  11. package/Math/quaternion.js +45 -49
  12. package/Math/utils.js +2 -2
  13. package/Math/vec3.js +42 -45
  14. package/algorithms/search-binary.js +4 -4
  15. package/altitude-locator/draw-subset-obj.js +7 -8
  16. package/altitude-locator/plugin.js +98 -114
  17. package/arrowfield/adaptor.js +3 -4
  18. package/arrowfield/index.js +2 -2
  19. package/arrowfield/plugin.js +62 -65
  20. package/bearing-line/index.js +1 -1
  21. package/bearing-line/plugin.js +200 -226
  22. package/circle-line-chain/chain-list-map.js +82 -88
  23. package/circle-line-chain/plugin.js +134 -165
  24. package/circle-line-chain/util.js +1 -1
  25. package/compass-rose/compass-rose-padding-flat.js +108 -133
  26. package/compass-rose/compass-text-writer.js +62 -70
  27. package/compass-rose/index.js +2 -2
  28. package/compassrose/compassrose.js +46 -50
  29. package/compassrose/index.js +1 -1
  30. package/heatwave/index.js +2 -2
  31. package/heatwave/isobar/objectarraylabels.js +44 -48
  32. package/heatwave/isobar/plugin.js +104 -123
  33. package/heatwave/isobar/quadtreecontours.js +76 -92
  34. package/heatwave/plugins/heatwaveglobeshell.js +69 -87
  35. package/index.js +11 -11
  36. package/package.json +1 -1
  37. package/partialrings/buffer-manager.js +32 -64
  38. package/partialrings/index.js +1 -1
  39. package/partialrings/plugin.js +48 -84
  40. package/partialrings/program.js +136 -47
  41. package/pin/pin-object-array.js +83 -86
  42. package/pin/pin-point-totem.js +21 -22
  43. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +10 -10
  44. package/point-heat-map/plugin-webworker.js +40 -45
  45. package/point-heat-map/point-to-heat-map-flow.js +40 -42
  46. package/point-tracks/key-methods.js +1 -1
  47. package/point-tracks/plugin.js +137 -162
  48. package/programs/arrowfield/index.js +1 -1
  49. package/programs/arrowfield/logic.js +170 -62
  50. package/programs/arrowfield/object.js +33 -35
  51. package/programs/data2legend/density-to-legend.js +45 -21
  52. package/programs/data2legend/point-to-density-texture.js +52 -27
  53. package/programs/float2legendwithratio/index.js +1 -1
  54. package/programs/float2legendwithratio/logic.js +88 -42
  55. package/programs/float2legendwithratio/object.js +43 -46
  56. package/programs/globe-util/is-globe-moved.js +10 -11
  57. package/programs/globeshell/index.js +1 -1
  58. package/programs/globeshell/wiggle/index.js +1 -1
  59. package/programs/globeshell/wiggle/logic.js +191 -98
  60. package/programs/globeshell/wiggle/object.js +33 -35
  61. package/programs/helpers/blender/program.js +36 -19
  62. package/programs/helpers/fadeaway/index.js +1 -1
  63. package/programs/helpers/fadeaway/logic.js +35 -13
  64. package/programs/helpers/fadeaway/object.js +9 -10
  65. package/programs/helpers/index.js +1 -1
  66. package/programs/index.js +8 -8
  67. package/programs/line-on-globe/angled-line.js +91 -32
  68. package/programs/line-on-globe/circle-accurate-3d.js +82 -32
  69. package/programs/line-on-globe/circle-accurate-flat.js +108 -50
  70. package/programs/line-on-globe/circle-accurate.js +103 -33
  71. package/programs/line-on-globe/circle.js +97 -32
  72. package/programs/line-on-globe/degree-padding-around-circle-3d.js +83 -33
  73. package/programs/line-on-globe/lines-color-instanced-flat.js +79 -34
  74. package/programs/line-on-globe/linestrip.js +111 -45
  75. package/programs/line-on-globe/naive-accurate-flexible.js +120 -50
  76. package/programs/line-on-globe/to-the-surface.js +58 -29
  77. package/programs/line-on-globe/util.js +1 -1
  78. package/programs/picking/pickable-renderer.js +117 -33
  79. package/programs/point-on-globe/element-globe-surface-glow.js +78 -38
  80. package/programs/point-on-globe/element-point-glow.js +103 -35
  81. package/programs/point-on-globe/square-pixel-point.js +76 -27
  82. package/programs/programcache.js +13 -13
  83. package/programs/rings/distancering/circleflatprogram.js +63 -21
  84. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +156 -145
  85. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -197
  86. package/programs/rings/distancering/index.js +4 -4
  87. package/programs/rings/distancering/paddyflatprogram.js +73 -20
  88. package/programs/rings/distancering/paddyflatprogram2d.js +75 -22
  89. package/programs/rings/distancering/paddyflatprogram3d.js +73 -20
  90. package/programs/rings/partial-ring/piece-of-pie.js +137 -35
  91. package/programs/totems/camerauniformblock.js +64 -51
  92. package/programs/totems/canvas-webglobe-info.js +48 -40
  93. package/programs/totems/gpu-selection-uniform-block.js +44 -40
  94. package/programs/totems/index.js +1 -1
  95. package/programs/two-d/pixel-padding-for-compass.js +90 -29
  96. package/programs/util.js +6 -7
  97. package/programs/vectorfields/index.js +1 -1
  98. package/programs/vectorfields/logics/drawrectangleparticles.js +70 -29
  99. package/programs/vectorfields/logics/index.js +3 -3
  100. package/programs/vectorfields/logics/pixelbased.js +91 -35
  101. package/programs/vectorfields/logics/ubo.js +31 -25
  102. package/programs/vectorfields/pingpongbuffermanager.js +30 -34
  103. package/rangerings/index.js +4 -4
  104. package/rangerings/plugin.js +202 -258
  105. package/rangerings/rangeringangletext.js +108 -120
  106. package/rangerings/ring-account.js +52 -69
  107. package/shaders/fragment-toy/firework.js +55 -1
  108. package/shaders/fragment-toy/singularity.js +55 -1
  109. package/timetracks/adaptors-line-strip.js +26 -37
  110. package/timetracks/adaptors.js +47 -61
  111. package/timetracks/index.js +4 -4
  112. package/timetracks/plugin-line-strip.js +63 -71
  113. package/timetracks/plugin.js +69 -77
  114. package/timetracks/program-line-strip.js +296 -103
  115. package/timetracks/program.js +419 -113
  116. package/timetracks/programpoint-line-strip.js +97 -44
  117. package/timetracks/programpoint.js +90 -44
  118. package/util/account/bufferoffsetmanager.js +72 -95
  119. package/util/account/index.js +1 -1
  120. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -44
  121. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -94
  122. package/util/account/single-attribute-buffer-management/index.js +3 -3
  123. package/util/account/single-attribute-buffer-management/object-store.js +29 -30
  124. package/util/account/util.js +2 -4
  125. package/util/algorithms/search-binary.js +4 -4
  126. package/util/check/get.js +5 -5
  127. package/util/check/typecheck.js +13 -15
  128. package/util/geometry/index.js +9 -11
  129. package/util/gl-util/buffer/attribute-loader.js +8 -20
  130. package/util/gl-util/buffer/index.js +1 -1
  131. package/util/gl-util/draw-options/methods.js +8 -9
  132. package/util/gl-util/uniform-block/manager.js +67 -67
  133. package/util/heatwavedatamanager/datamanager.js +56 -116
  134. package/util/heatwavedatamanager/index.js +2 -2
  135. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +37 -40
  136. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -10
  137. package/util/index.js +6 -6
  138. package/util/interpolation/timetrack/index.js +1 -1
  139. package/util/interpolation/timetrack/timetrack-interpolator.js +27 -29
  140. package/util/interpolation/timetrack/web-worker-str.js +179 -1
  141. package/util/interpolation/timetrack/web-worker.js +4 -4
  142. package/util/jshelpers/data-filler.js +7 -7
  143. package/util/jshelpers/timefilters.js +7 -7
  144. package/util/picking/fence.js +7 -7
  145. package/util/picking/picker-displayer.js +46 -52
  146. package/util/programs/draw-texture-on-canvas.js +39 -21
  147. package/util/programs/shapesonglobe.js +104 -64
  148. package/util/programs/supersampletotextures.js +45 -39
  149. package/util/programs/texturetoglobe.js +98 -48
  150. package/util/shaderfunctions/geometrytransformations.js +322 -27
  151. package/util/shaderfunctions/nodata.js +7 -1
  152. package/util/shaderfunctions/noisefunctions.js +39 -9
  153. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  154. package/util/webglobe/rasteroverlay.js +35 -37
  155. package/util/webglobjectbuilders.js +55 -60
  156. package/util/webglobjectbuilders1.js +48 -49
  157. package/waveparticles/adaptor.js +6 -7
  158. package/waveparticles/index.js +2 -2
  159. package/waveparticles/plugin.js +79 -84
  160. package/wind/imagetovectorfieldandmagnitude.js +15 -15
  161. package/wind/index.js +4 -4
  162. package/wind/plugin.js +453 -251
  163. package/wind/vectorfieldimage.js +5 -5
  164. package/write-text/attached-text-writer.js +46 -48
  165. package/write-text/context-text.js +51 -58
  166. package/write-text/context-text3.js +69 -74
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("../../../util");
4
- var Logic = /** @class */ (function () {
5
- function Logic() {
3
+ const util_1 = require("../../../util");
4
+ class Logic {
5
+ constructor() {
6
6
  this.id = "GlobeShellProgram";
7
7
  this.description = "This program implements flyweight pattern for globe." +
8
8
  "At globes draw3D call stack, this program should be prior to any program that uses it." +
9
9
  "draw3D method of this object only sets Projetion, ModelView and Translate matrices and if the mode is 2D mapWH .";
10
10
  }
11
- Logic.prototype.init = function (globe, gl) {
11
+ init(globe, gl) {
12
12
  this.gl = gl;
13
13
  this.globe = globe;
14
14
  this.programWrapper = this._createProgramWrapper();
@@ -17,20 +17,119 @@ var Logic = /** @class */ (function () {
17
17
  this.resize();
18
18
  this.updateTime(0);
19
19
  this.setMesh({ xRes: 64, yRes: 64, eastWestTied: false });
20
- };
21
- Logic.prototype._createProgramWrapper = function () {
22
- var vertexShader = "#version 300 es\n #define R 6378.137\n #define PI 3.1415926535897932384626433832795\n #define POLE 20037508.34\n #define POLE_BY_PI 6366198.2\n #define HALF_PI 1.5707963267948966192313216916398\n\n uniform vec2 u_mesh_resolution;\n \n layout(std140) uniform ShellBlock {\n vec2 u_grid_offset_rad;\n vec2 u_grid_size_rad;\n float u_height;\n float u_wiggle;\n float u_time;\n float u_opacity;\n };\n\n uniform mat4 u_model_view_matrix;\n uniform mat4 u_projection_matrix;\n uniform vec3 u_translate;\n\n uniform vec2 u_mapWH;\n uniform vec2 u_scrWH;\n\n uniform bool u_is3D; \n\n out float v_opacity;\n out vec2 v_texture_coordinate;\n \n vec2 f_texCoord(){\n\n float x = mod( float(gl_VertexID), u_mesh_resolution.x ) / ( u_mesh_resolution.x - 1.0);\n float y = floor( float(gl_VertexID) / u_mesh_resolution.x ) / ( u_mesh_resolution.y - 1.0);\n return vec2(x, y);\n //return vec2( fract( float(gl_VertexID) / u_mesh_resolution.x ), floor(float(gl_VertexID) / u_mesh_resolution.x) / u_mesh_resolution.y);\n }\n\n vec3 f_onSphere(vec2 texCoord){\n float vert = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;\n float hor = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;\n float x = sin(vert) * cos(hor);\n float y = sin(vert) * sin(hor);\n float z = cos(vert);\n return vec3(x, y, z);\n }\n\n vec2 f_onFlat(vec2 texCoord){\n float x = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;\n float y = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;\n\n\n float mercX = x * POLE_BY_PI;\n float mercY = log(tan(HALF_PI - y / 2.0 )) * POLE_BY_PI;\n\n float normX = ( mercX - u_translate.x ) / u_mapWH.x;\n float normY = ( mercY - u_translate.y ) / u_mapWH.y;\n return vec2(normX, normY);\n } \n\n vec3 f_position(vec3 unit_sphere_pos, float wiggle){\n return unit_sphere_pos * (R + u_height + wiggle);\n }\n \n float f_wiggle(vec2 texCoord){\n float s_contrib = 0.6*sin(texCoord.x*2.0*PI + 3.0*u_time);\n float t_contrib = 0.8*cos(texCoord.y*4.1 + 5.0*u_time);\n return u_wiggle * s_contrib * t_contrib * sin(texCoord.y*PI*2.0);\n }\n\n void main() {\n vec2 texCoord = f_texCoord();\n if (u_is3D){\n vec3 unit_sphere_pos = f_onSphere(texCoord);\n float wiggle = f_wiggle(texCoord);\n vec3 position = f_position(unit_sphere_pos, wiggle);\n gl_Position = u_projection_matrix * u_model_view_matrix * vec4(position - u_translate, 1.0);\n } else {\n vec2 position = f_onFlat(texCoord);\n gl_Position = u_projection_matrix * vec4(\n position.x * u_scrWH.x,\n (1.0 - position.y) * u_scrWH.y,\n 0.0,\n 1.0);\n }\n v_texture_coordinate = texCoord;\n v_opacity = u_opacity;\n }\n ";
23
- var fragmentShader = "#version 300 es\n precision lowp float;\n in vec2 v_texture_coordinate;\n in float v_opacity;\n uniform sampler2D u_texture;\n out vec4 outColor;\n\n\n void main() {\n outColor = texture(u_texture, v_texture_coordinate);\n outColor.a *= v_opacity;\n }";
24
- var gl = this.gl;
25
- var program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
26
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
20
+ }
21
+ _createProgramWrapper() {
22
+ const vertexShader = `#version 300 es
23
+ #define R 6378.137
24
+ #define PI 3.1415926535897932384626433832795
25
+ #define POLE 20037508.34
26
+ #define POLE_BY_PI 6366198.2
27
+ #define HALF_PI 1.5707963267948966192313216916398
28
+
29
+ uniform vec2 u_mesh_resolution;
30
+
31
+ layout(std140) uniform ShellBlock {
32
+ vec2 u_grid_offset_rad;
33
+ vec2 u_grid_size_rad;
34
+ float u_height;
35
+ float u_wiggle;
36
+ float u_time;
37
+ float u_opacity;
38
+ };
39
+
40
+ uniform mat4 u_model_view_matrix;
41
+ uniform mat4 u_projection_matrix;
42
+ uniform vec3 u_translate;
43
+
44
+ uniform vec2 u_mapWH;
45
+ uniform vec2 u_scrWH;
46
+
47
+ uniform bool u_is3D;
48
+
49
+ out float v_opacity;
50
+ out vec2 v_texture_coordinate;
51
+
52
+ vec2 f_texCoord(){
53
+
54
+ float x = mod( float(gl_VertexID), u_mesh_resolution.x ) / ( u_mesh_resolution.x - 1.0);
55
+ float y = floor( float(gl_VertexID) / u_mesh_resolution.x ) / ( u_mesh_resolution.y - 1.0);
56
+ return vec2(x, y);
57
+ //return vec2( fract( float(gl_VertexID) / u_mesh_resolution.x ), floor(float(gl_VertexID) / u_mesh_resolution.x) / u_mesh_resolution.y);
58
+ }
59
+
60
+ vec3 f_onSphere(vec2 texCoord){
61
+ float vert = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;
62
+ float hor = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;
63
+ float x = sin(vert) * cos(hor);
64
+ float y = sin(vert) * sin(hor);
65
+ float z = cos(vert);
66
+ return vec3(x, y, z);
67
+ }
68
+
69
+ vec2 f_onFlat(vec2 texCoord){
70
+ float x = (texCoord.x * u_grid_size_rad.x ) + u_grid_offset_rad.x;
71
+ float y = (texCoord.y * u_grid_size_rad.y ) + u_grid_offset_rad.y;
72
+
73
+
74
+ float mercX = x * POLE_BY_PI;
75
+ float mercY = log(tan(HALF_PI - y / 2.0 )) * POLE_BY_PI;
76
+
77
+ float normX = ( mercX - u_translate.x ) / u_mapWH.x;
78
+ float normY = ( mercY - u_translate.y ) / u_mapWH.y;
79
+ return vec2(normX, normY);
80
+ }
81
+
82
+ vec3 f_position(vec3 unit_sphere_pos, float wiggle){
83
+ return unit_sphere_pos * (R + u_height + wiggle);
84
+ }
85
+
86
+ float f_wiggle(vec2 texCoord){
87
+ float s_contrib = 0.6*sin(texCoord.x*2.0*PI + 3.0*u_time);
88
+ float t_contrib = 0.8*cos(texCoord.y*4.1 + 5.0*u_time);
89
+ return u_wiggle * s_contrib * t_contrib * sin(texCoord.y*PI*2.0);
90
+ }
91
+
92
+ void main() {
93
+ vec2 texCoord = f_texCoord();
94
+ if (u_is3D){
95
+ vec3 unit_sphere_pos = f_onSphere(texCoord);
96
+ float wiggle = f_wiggle(texCoord);
97
+ vec3 position = f_position(unit_sphere_pos, wiggle);
98
+ gl_Position = u_projection_matrix * u_model_view_matrix * vec4(position - u_translate, 1.0);
99
+ } else {
100
+ vec2 position = f_onFlat(texCoord);
101
+ gl_Position = u_projection_matrix * vec4(
102
+ position.x * u_scrWH.x,
103
+ (1.0 - position.y) * u_scrWH.y,
104
+ 0.0,
105
+ 1.0);
106
+ }
107
+ v_texture_coordinate = texCoord;
108
+ v_opacity = u_opacity;
109
+ }
110
+ `;
111
+ const fragmentShader = `#version 300 es
112
+ precision lowp float;
113
+ in vec2 v_texture_coordinate;
114
+ in float v_opacity;
115
+ uniform sampler2D u_texture;
116
+ out vec4 outColor;
117
+
118
+
119
+ void main() {
120
+ outColor = texture(u_texture, v_texture_coordinate);
121
+ outColor.a *= v_opacity;
122
+ }`;
123
+ const gl = this.gl;
124
+ const program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
125
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
27
126
  gl.useProgram(program);
28
127
  this.shellBlockBindingPoint = 0;
29
- var shellBlockIndex = gl.getUniformBlockIndex(program, "ShellBlock");
128
+ const shellBlockIndex = gl.getUniformBlockIndex(program, "ShellBlock");
30
129
  gl.uniformBlockBinding(program, shellBlockIndex, this.shellBlockBindingPoint);
31
130
  gl.useProgram(currentProgram);
32
131
  return {
33
- program: program,
132
+ program,
34
133
  u_model_view_matrix: gl.getUniformLocation(program, "u_model_view_matrix"),
35
134
  u_projection_matrix: gl.getUniformLocation(program, "u_projection_matrix"),
36
135
  u_translate: gl.getUniformLocation(program, "u_translate"),
@@ -40,22 +139,21 @@ var Logic = /** @class */ (function () {
40
139
  u_texture: gl.getUniformLocation(program, "u_texture"),
41
140
  u_mesh_resolution: gl.getUniformLocation(program, "u_mesh_resolution"),
42
141
  };
43
- };
142
+ }
44
143
  // this method implements data part of flyweight pattern
45
- Logic.prototype.getShellBlockBufferManager = function () {
144
+ getShellBlockBufferManager() {
46
145
  return new ShellBlockManager(this.gl);
47
- };
48
- Logic.prototype.updateTime = function (time) {
49
- var _a = this, gl = _a.gl, programWrapper = _a.programWrapper;
50
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
146
+ }
147
+ updateTime(time) {
148
+ const { gl, programWrapper } = this;
149
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
51
150
  gl.useProgram(programWrapper.program);
52
151
  gl.uniform1f(this.programWrapper.u_time, time);
53
152
  gl.useProgram(currentProgram);
54
- };
55
- Logic.prototype.setRotationAndTranslation = function (uProjectionMatrix, uModelViewMatrix, uTranslate, resetCurrentProgram) {
56
- if (resetCurrentProgram === void 0) { resetCurrentProgram = false; }
57
- var gl = this.gl;
58
- var currentProgram = null;
153
+ }
154
+ setRotationAndTranslation(uProjectionMatrix, uModelViewMatrix, uTranslate, resetCurrentProgram = false) {
155
+ const gl = this.gl;
156
+ let currentProgram = null;
59
157
  if (resetCurrentProgram) {
60
158
  currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
61
159
  }
@@ -67,35 +165,35 @@ var Logic = /** @class */ (function () {
67
165
  gl.uniform3fv(this.programWrapper.u_translate, this._transformArray);
68
166
  if (resetCurrentProgram)
69
167
  gl.useProgram(currentProgram);
70
- };
71
- Logic.prototype.setGeometry = function () {
72
- var _a = this, globe = _a.globe, gl = _a.gl;
73
- var _b = this.programWrapper, u_is3D = _b.u_is3D, u_scrWH = _b.u_scrWH, program = _b.program;
74
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
75
- var is3D = this.globe.api_GetCurrentGeometry() === 0;
168
+ }
169
+ setGeometry() {
170
+ const { globe, gl } = this;
171
+ const { u_is3D, u_scrWH, program } = this.programWrapper;
172
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
173
+ const is3D = this.globe.api_GetCurrentGeometry() === 0;
76
174
  gl.useProgram(program);
77
175
  if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
78
176
  gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
79
177
  }
80
178
  gl.uniform1i(u_is3D, is3D);
81
179
  gl.useProgram(currentProgram);
82
- };
83
- Logic.prototype.resize = function () {
84
- var _a = this, gl = _a.gl, globe = _a.globe;
180
+ }
181
+ resize() {
182
+ const { gl, globe } = this;
85
183
  if (!globe)
86
184
  return;
87
- var _b = this.programWrapper, program = _b.program, u_scrWH = _b.u_scrWH;
88
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
185
+ const { program, u_scrWH } = this.programWrapper;
186
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
89
187
  gl.useProgram(program);
90
188
  if (globe.api_GetCurrentGeometry() === globe.api_GeometryTypes().FLAT) {
91
189
  gl.uniform2f(u_scrWH, globe.api_ScrW(), globe.api_ScrH());
92
190
  }
93
191
  gl.useProgram(currentProgram);
94
- };
192
+ }
95
193
  // only sets data does not draw
96
- Logic.prototype.draw3D = function (uProjectionMatrix, uModelViewMatrix, uTranslate) {
97
- var _a = this, gl = _a.gl, globe = _a.globe;
98
- var _b = this.programWrapper, program = _b.program, u_model_view_matrix = _b.u_model_view_matrix, u_projection_matrix = _b.u_projection_matrix, u_translate = _b.u_translate;
194
+ draw3D(uProjectionMatrix, uModelViewMatrix, uTranslate) {
195
+ const { gl, globe } = this;
196
+ const { program, u_model_view_matrix, u_projection_matrix, u_translate } = this.programWrapper;
99
197
  gl.disable(gl.DEPTH_TEST);
100
198
  gl.useProgram(program);
101
199
  gl.uniformMatrix4fv(u_projection_matrix, false, uProjectionMatrix);
@@ -103,15 +201,14 @@ var Logic = /** @class */ (function () {
103
201
  // this._transformArray.set([], 0);
104
202
  gl.uniform3f(u_translate, uTranslate.x, uTranslate.y, uTranslate.z);
105
203
  if (globe.api_GetCurrentGeometry() === 1) {
106
- var _c = globe.api_GetCurrentWorldWH(), width = _c.width, height = _c.height;
204
+ const { width, height } = globe.api_GetCurrentWorldWH();
107
205
  gl.uniform2fv(this.programWrapper.u_mapWH, [width, height]);
108
206
  }
109
207
  gl.enable(gl.DEPTH_TEST);
110
- };
111
- Logic.prototype.draw = function (texture, shellBlockDataManager, drawLines) {
112
- if (drawLines === void 0) { drawLines = false; }
113
- var _a = this, gl = _a.gl, programWrapper = _a.programWrapper, _vao = _a._vao, _drawCount = _a._drawCount;
114
- var program = programWrapper.program, u_texture = programWrapper.u_texture;
208
+ }
209
+ draw(texture, shellBlockDataManager, drawLines = false) {
210
+ const { gl, programWrapper, _vao, _drawCount } = this;
211
+ const { program, u_texture } = programWrapper;
115
212
  gl.useProgram(program);
116
213
  gl.bindVertexArray(_vao);
117
214
  gl.activeTexture(gl.TEXTURE0);
@@ -124,39 +221,38 @@ var Logic = /** @class */ (function () {
124
221
  gl.drawElements(gl.TRIANGLES, _drawCount, gl.UNSIGNED_SHORT, 0);
125
222
  shellBlockDataManager.unbind();
126
223
  gl.bindVertexArray(null);
127
- };
128
- Logic.prototype.free = function () {
129
- var _a = this, gl = _a.gl, programWrapper = _a.programWrapper, _vao = _a._vao, _indexBuffer = _a._indexBuffer;
224
+ }
225
+ free() {
226
+ const { gl, programWrapper, _vao, _indexBuffer } = this;
130
227
  gl.deleteBuffer(_indexBuffer);
131
228
  gl.deleteVertexArray(_vao);
132
229
  gl.deleteProgram(programWrapper.program);
133
- };
134
- Logic.prototype.setMesh = function (_a) {
135
- var xRes = _a.xRes, yRes = _a.yRes, eastWestTied = _a.eastWestTied;
230
+ }
231
+ setMesh({ xRes, yRes, eastWestTied }) {
136
232
  this._xRes = xRes;
137
233
  this._yRes = yRes;
138
- var _vao = this._meshUP(xRes, yRes, eastWestTied)._vao;
234
+ const { _vao } = this._meshUP(xRes, yRes, eastWestTied);
139
235
  this._vao = _vao;
140
236
  this._setUMeshResolution(xRes, yRes);
141
- };
142
- Logic.prototype._setUMeshResolution = function (xRes, yRes) {
143
- var _a = this, gl = _a.gl, programWrapper = _a.programWrapper;
144
- var u_mesh_resolution = programWrapper.u_mesh_resolution;
145
- var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
237
+ }
238
+ _setUMeshResolution(xRes, yRes) {
239
+ const { gl, programWrapper } = this;
240
+ const { u_mesh_resolution } = programWrapper;
241
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
146
242
  gl.useProgram(programWrapper.program);
147
243
  gl.uniform2f(u_mesh_resolution, xRes, yRes);
148
244
  gl.useProgram(currentProgram);
149
245
  this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
150
- };
151
- Logic.prototype._meshUP = function (xRes, yRes, eastWestTied) {
246
+ }
247
+ _meshUP(xRes, yRes, eastWestTied) {
152
248
  this._drawCount = 6 * ((xRes - 1) * (yRes - 1));
153
- var indices = new Uint16Array(this._drawCount);
249
+ const indices = new Uint16Array(this._drawCount);
154
250
  {
155
- var indicesIndex = 0;
156
- var index = 0;
157
- for (var j = 0; j < yRes - 1; j++) {
158
- for (var i = 0; i < xRes - 1; i++) {
159
- var ind = index + i;
251
+ let indicesIndex = 0;
252
+ let index = 0;
253
+ for (let j = 0; j < yRes - 1; j++) {
254
+ for (let i = 0; i < xRes - 1; i++) {
255
+ const ind = index + i;
160
256
  indices[indicesIndex++] = ind + xRes;
161
257
  indices[indicesIndex++] = ind + 1;
162
258
  indices[indicesIndex++] = ind;
@@ -167,9 +263,9 @@ var Logic = /** @class */ (function () {
167
263
  index += xRes;
168
264
  }
169
265
  if (eastWestTied) {
170
- var left = (yRes - 1);
171
- var right = 0;
172
- for (var i = 0; i < xRes - 1; i++) {
266
+ let left = (yRes - 1);
267
+ let right = 0;
268
+ for (let i = 0; i < xRes - 1; i++) {
173
269
  indices[indicesIndex++] = left + xRes;
174
270
  indices[indicesIndex++] = right;
175
271
  indices[indicesIndex++] = left;
@@ -181,49 +277,47 @@ var Logic = /** @class */ (function () {
181
277
  }
182
278
  }
183
279
  }
184
- var gl = this.gl;
185
- var _vao = gl.createVertexArray();
280
+ const gl = this.gl;
281
+ const _vao = gl.createVertexArray();
186
282
  gl.bindVertexArray(_vao);
187
- var indexBuffer = gl.createBuffer();
283
+ const indexBuffer = gl.createBuffer();
188
284
  this._indexBuffer = indexBuffer;
189
285
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
190
286
  gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
191
287
  gl.bindVertexArray(null);
192
- return { _vao: _vao };
193
- };
194
- return Logic;
195
- }());
288
+ return { _vao };
289
+ }
290
+ }
196
291
  exports.default = Logic;
197
- var ShellBlockManager = /** @class */ (function () {
198
- function ShellBlockManager(gl) {
292
+ class ShellBlockManager {
293
+ constructor(gl) {
199
294
  this.gl = gl;
200
295
  this.buffer = gl.createBuffer();
201
296
  gl.bindBuffer(gl.UNIFORM_BUFFER, this.buffer);
202
297
  gl.bufferData(gl.UNIFORM_BUFFER, 32, gl.DYNAMIC_DRAW);
203
298
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
204
299
  }
205
- ShellBlockManager.prototype.update = function (_a) {
206
- var _b = _a === void 0 ? {} : _a, _c = _b.gridSizeRad, gridSizeRad = _c === void 0 ? null : _c, _d = _b.gridOffsetRad, gridOffsetRad = _d === void 0 ? null : _d, _e = _b.height, height = _e === void 0 ? null : _e, _f = _b.wiggleInKM, wiggleInKM = _f === void 0 ? null : _f, _g = _b.innerTime, innerTime = _g === void 0 ? null : _g, _h = _b.opacity, opacity = _h === void 0 ? null : _h;
207
- var _j = this, gl = _j.gl, buffer = _j.buffer;
300
+ update({ gridSizeRad = null, gridOffsetRad = null, height = null, wiggleInKM = null, innerTime = null, opacity = null } = {}) {
301
+ const { gl, buffer } = this;
208
302
  gl.bindBuffer(gl.UNIFORM_BUFFER, buffer);
209
303
  if (gridOffsetRad !== null) {
210
- var offset = new Float32Array(gridOffsetRad);
304
+ const offset = new Float32Array(gridOffsetRad);
211
305
  gl.bufferSubData(gl.UNIFORM_BUFFER, 0, offset);
212
306
  }
213
307
  if (gridSizeRad !== null) {
214
- var size = new Float32Array(gridSizeRad);
308
+ const size = new Float32Array(gridSizeRad);
215
309
  gl.bufferSubData(gl.UNIFORM_BUFFER, 8, size);
216
310
  }
217
311
  if (height !== null) {
218
- var heightArray = new Float32Array([height]);
312
+ const heightArray = new Float32Array([height]);
219
313
  gl.bufferSubData(gl.UNIFORM_BUFFER, 16, heightArray);
220
314
  }
221
315
  if (wiggleInKM !== null) {
222
- var wiggleArray = new Float32Array([wiggleInKM]);
316
+ const wiggleArray = new Float32Array([wiggleInKM]);
223
317
  gl.bufferSubData(gl.UNIFORM_BUFFER, 20, wiggleArray);
224
318
  }
225
319
  if (innerTime !== null) {
226
- var innerTimeArray = new Float32Array([innerTime]);
320
+ const innerTimeArray = new Float32Array([innerTime]);
227
321
  gl.bufferSubData(gl.UNIFORM_BUFFER, 24, innerTimeArray);
228
322
  }
229
323
  if (opacity !== null) {
@@ -231,22 +325,21 @@ var ShellBlockManager = /** @class */ (function () {
231
325
  console.warn('Invalid opacity value');
232
326
  return;
233
327
  }
234
- var op = new Float32Array([opacity]);
328
+ const op = new Float32Array([opacity]);
235
329
  gl.bufferSubData(gl.UNIFORM_BUFFER, 28, op);
236
330
  }
237
331
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
238
- };
239
- ShellBlockManager.prototype.bind = function () {
240
- var _a = this, gl = _a.gl, buffer = _a.buffer;
332
+ }
333
+ bind() {
334
+ const { gl, buffer } = this;
241
335
  gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, buffer);
242
- };
243
- ShellBlockManager.prototype.free = function () {
244
- var _a = this, gl = _a.gl, buffer = _a.buffer;
336
+ }
337
+ free() {
338
+ const { gl, buffer } = this;
245
339
  gl.deleteBuffer(buffer);
246
- };
247
- ShellBlockManager.prototype.unbind = function () {
248
- var gl = this.gl;
340
+ }
341
+ unbind() {
342
+ const { gl } = this;
249
343
  gl.bindBufferBase(gl.UNIFORM_BUFFER, this.shellBlockBindingPoint, null);
250
- };
251
- return ShellBlockManager;
252
- }());
344
+ }
345
+ }
@@ -3,72 +3,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var programcache_1 = require("../../programcache");
7
- var logic_1 = __importDefault(require("./logic"));
8
- var GlobeShell = /** @class */ (function () {
9
- function GlobeShell(gl, globe, _a) {
10
- var _b = _a === void 0 ? {} : _a, _c = _b.minLon, minLon = _c === void 0 ? -180 : _c, _d = _b.maxLon, maxLon = _d === void 0 ? 180 : _d, _e = _b.minLat, minLat = _e === void 0 ? -90 : _e, _f = _b.maxLat, maxLat = _f === void 0 ? 90 : _f, _g = _b.height, height = _g === void 0 ? 0 : _g, _h = _b.u_opacity, u_opacity = _h === void 0 ? 1 : _h, _j = _b.wiggleInKM, wiggleInKM = _j === void 0 ? 0 : _j, _k = _b.wiggleSpeed, wiggleSpeed = _k === void 0 ? 0 : _k;
6
+ const programcache_1 = require("../../programcache");
7
+ const logic_1 = __importDefault(require("./logic"));
8
+ class GlobeShell {
9
+ constructor(gl, globe, { minLon = -180, maxLon = 180, minLat = -90, maxLat = 90, height = 0, u_opacity = 1, wiggleInKM = 0, wiggleSpeed = 0,
10
+ // eastWestTied, Not implemented yet
11
+ } = {}) {
11
12
  this.gl = gl;
12
13
  this.globe = globe;
13
14
  this.program = programcache_1.globeProgramCache.getProgram(globe, logic_1.default);
14
15
  this.shellBlockManager = this.program.getShellBlockBufferManager();
15
16
  this.update = this.shellBlockManager.update.bind(this.shellBlockManager);
16
17
  this.innerTime = 0;
17
- this.setBBox({ minLon: minLon, maxLon: maxLon, minLat: minLat, maxLat: maxLat });
18
+ this.setBBox({ minLon, maxLon, minLat, maxLat });
18
19
  this.setOpacity(u_opacity);
19
20
  this.setHeight(height);
20
- this.setWiggle({ wiggleSpeed: wiggleSpeed, wiggleInKM: wiggleInKM });
21
+ this.setWiggle({ wiggleSpeed, wiggleInKM });
21
22
  }
22
- GlobeShell.prototype.setTexture = function (texture) {
23
+ setTexture(texture) {
23
24
  this.texture = texture;
24
25
  this.globe.DrawRender();
25
- };
26
- GlobeShell.prototype.setHeight = function (height) {
27
- this.shellBlockManager.update({ height: height });
26
+ }
27
+ setHeight(height) {
28
+ this.shellBlockManager.update({ height });
28
29
  this.globe.DrawRender();
29
- };
30
- GlobeShell.prototype.setOpacity = function (opacity) {
31
- this.shellBlockManager.update({ opacity: opacity });
30
+ }
31
+ setOpacity(opacity) {
32
+ this.shellBlockManager.update({ opacity });
32
33
  this.globe.DrawRender();
33
- };
34
- GlobeShell.prototype.setBBox = function (_a) {
35
- var _b = _a === void 0 ? {} : _a, _c = _b.minLon, minLon = _c === void 0 ? -180 : _c, _d = _b.maxLon, maxLon = _d === void 0 ? 180 : _d, _e = _b.minLat, minLat = _e === void 0 ? -90 : _e, _f = _b.maxLat, maxLat = _f === void 0 ? 90 : _f;
36
- this.bbox = { minLon: minLon, maxLon: maxLon, minLat: minLat, maxLat: maxLat };
34
+ }
35
+ setBBox({ minLon = -180, maxLon = 180, minLat = -90, maxLat = 90 } = {}) {
36
+ this.bbox = { minLon, maxLon, minLat, maxLat };
37
37
  // x
38
- var horOffset = (minLon) * Math.PI / 180;
39
- var horSize = (maxLon - minLon) * Math.PI / 180;
38
+ const horOffset = (minLon) * Math.PI / 180;
39
+ const horSize = (maxLon - minLon) * Math.PI / 180;
40
40
  // y
41
- var vertOffset = (90 - maxLat) * Math.PI / 180;
42
- var vertSize = (maxLat - minLat) * Math.PI / 180;
43
- var offset_rad = new Float32Array([horOffset, vertOffset]);
44
- var size_rad = new Float32Array([horSize, vertSize]);
41
+ const vertOffset = (90 - maxLat) * Math.PI / 180;
42
+ const vertSize = (maxLat - minLat) * Math.PI / 180;
43
+ const offset_rad = new Float32Array([horOffset, vertOffset]);
44
+ const size_rad = new Float32Array([horSize, vertSize]);
45
45
  this.shellBlockManager.update({ gridSizeRad: size_rad, gridOffsetRad: offset_rad });
46
46
  this.globe.DrawRender();
47
- };
48
- GlobeShell.prototype.setWiggle = function (_a) {
49
- var _b = _a.wiggleSpeed, wiggleSpeed = _b === void 0 ? null : _b, _c = _a.wiggleInKM, wiggleInKM = _c === void 0 ? null : _c;
47
+ }
48
+ setWiggle({ wiggleSpeed = null, wiggleInKM = null }) {
50
49
  if (wiggleInKM !== null)
51
50
  this.wiggleInKM = wiggleInKM;
52
51
  if (wiggleSpeed !== null)
53
52
  this.wiggleSpeed = wiggleSpeed;
54
- this.shellBlockManager.update({ wiggleInKM: wiggleInKM });
55
- };
53
+ this.shellBlockManager.update({ wiggleInKM });
54
+ }
56
55
  /**
57
56
  *
58
57
  * @param {*} program modelView, projection, translate, mapWH, scrWH, should be set before calling this function
59
58
  */
60
- GlobeShell.prototype.draw = function () {
59
+ draw() {
61
60
  this.program.draw(this.texture, this.shellBlockManager);
62
61
  if (this.wiggleInKM > 0 && this.wiggleSpeed > 0) {
63
62
  this.innerTime += this.wiggleSpeed;
64
63
  this.shellBlockManager.update({ innerTime: this.innerTime });
65
64
  this.globe.DrawRender();
66
65
  }
67
- };
68
- GlobeShell.prototype.free = function () {
66
+ }
67
+ free() {
69
68
  programcache_1.globeProgramCache.releaseProgram(this.globe, logic_1.default);
70
69
  this.shellBlockManager.free();
71
- };
72
- return GlobeShell;
73
- }());
70
+ }
71
+ }
74
72
  exports.default = GlobeShell;
@@ -1,19 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var util_1 = require("../util");
3
+ const util_1 = require("../util");
4
4
  /**
5
5
  * Blends two float32textures with given ratio.
6
6
  */
7
- var vertexShader = "#version 300 es\nin vec2 a_position;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n v_texCoord = a_position * 0.5 + 0.5;\n}\n";
8
- var fragmentShader = "#version 300 es\nuniform sampler2D u_texture0;\nuniform sampler2D u_texture1;\nuniform float u_ratio;\nin v_texCoord;\nout vec4 outColor;\nvoid main() {\n vec4 color0 = texture(u_texture0, v_texCoord);\n vec4 color1 = texture(u_texture1, v_texCoord);\n outColor = mix(color0, color1, u_ratio);\n}\n";
9
- var BlenderProgram = /** @class */ (function () {
10
- function BlenderProgram(gl) {
7
+ const vertexShader = `#version 300 es
8
+ in vec2 a_position;
9
+ out vec2 v_texCoord;
10
+ void main() {
11
+ gl_Position = vec4(a_position, 0.0, 1.0);
12
+ v_texCoord = a_position * 0.5 + 0.5;
13
+ }
14
+ `;
15
+ const fragmentShader = `#version 300 es
16
+ uniform sampler2D u_texture0;
17
+ uniform sampler2D u_texture1;
18
+ uniform float u_ratio;
19
+ in v_texCoord;
20
+ out vec4 outColor;
21
+ void main() {
22
+ vec4 color0 = texture(u_texture0, v_texCoord);
23
+ vec4 color1 = texture(u_texture1, v_texCoord);
24
+ outColor = mix(color0, color1, u_ratio);
25
+ }
26
+ `;
27
+ class BlenderProgram {
28
+ constructor(gl) {
11
29
  this.gl = gl;
12
30
  this.programWrapper = this._createProgramWrapper();
13
31
  }
14
- BlenderProgram.prototype._craeteProgramWrapper = function () {
15
- var gl = this.gl;
16
- var program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
32
+ _craeteProgramWrapper() {
33
+ const gl = this.gl;
34
+ const program = (0, util_1.createProgram)(gl, vertexShader, fragmentShader);
17
35
  this.vao = gl.createVertexArray();
18
36
  gl.bindVertexArray(this.vao);
19
37
  this._buffer = gl.createBuffer();
@@ -30,10 +48,10 @@ var BlenderProgram = /** @class */ (function () {
30
48
  gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
31
49
  gl.bindVertexArray(null);
32
50
  gl.bindBuffer(gl.ARRAY_BUFFER, null);
33
- return { program: program, uniforms: { u_texture0: gl.getUniformLocation(program, 'u_texture0'), u_texture1: gl.getUniformLocation(program, 'u_texture1'), u_ratio: gl.getUniformLocation(program, 'u_ratio') } };
34
- };
35
- BlenderProgram.prototype.draw = function (ratio, texture0, texture1) {
36
- var gl = this.gl;
51
+ return { program, uniforms: { u_texture0: gl.getUniformLocation(program, 'u_texture0'), u_texture1: gl.getUniformLocation(program, 'u_texture1'), u_ratio: gl.getUniformLocation(program, 'u_ratio') } };
52
+ }
53
+ draw(ratio, texture0, texture1) {
54
+ const gl = this.gl;
37
55
  gl.useProgram(this.programWrapper.program);
38
56
  gl.bindVertexArray(this.vao);
39
57
  gl.activeTexture(gl.TEXTURE1);
@@ -45,10 +63,10 @@ var BlenderProgram = /** @class */ (function () {
45
63
  gl.uniform1f(this.programWrapper.uniforms.u_ratio, ratio);
46
64
  gl.drawArrays(gl.TRIANGLES, 0, 6);
47
65
  gl.bindVertexArray(null);
48
- };
49
- BlenderProgram.prototype.createFloat32Texture = function (width, height) {
50
- var gl = this.gl;
51
- var texture = gl.createTexture();
66
+ }
67
+ createFloat32Texture(width, height) {
68
+ const gl = this.gl;
69
+ const texture = gl.createTexture();
52
70
  gl.bindTexture(gl.TEXTURE_2D, texture);
53
71
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, null);
54
72
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
@@ -56,7 +74,6 @@ var BlenderProgram = /** @class */ (function () {
56
74
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
57
75
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
58
76
  return texture;
59
- };
60
- return BlenderProgram;
61
- }());
77
+ }
78
+ }
62
79
  exports.default = BlenderProgram;
@@ -3,5 +3,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var object_1 = __importDefault(require("./object"));
6
+ const object_1 = __importDefault(require("./object"));
7
7
  exports.default = object_1.default;