@pirireis/webglobeplugins 0.9.9 → 0.9.11

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/Math/angle-calculation.js +15 -0
  2. package/Math/arc.js +65 -0
  3. package/Math/bounds/line-bbox.js +190 -0
  4. package/Math/constants.js +9 -0
  5. package/Math/frustum/camera.js +24 -0
  6. package/Math/frustum/from-globeinfo.js +48 -0
  7. package/Math/frustum/types.js +2 -0
  8. package/Math/globe-util/horizon-plane.js +112 -0
  9. package/Math/index.js +1 -0
  10. package/Math/juction/arc-plane.js +83 -0
  11. package/Math/juction/line-sphere.js +25 -0
  12. package/Math/juction/plane-plane.js +58 -0
  13. package/Math/line.js +58 -0
  14. package/Math/matrix4.js +1 -0
  15. package/Math/methods.js +206 -0
  16. package/Math/plane.js +62 -0
  17. package/Math/quaternion.js +108 -0
  18. package/Math/types.js +2 -0
  19. package/Math/utils.js +4 -0
  20. package/Math/vec3.js +129 -0
  21. package/algorithms/search-binary.js +19 -0
  22. package/altitude-locator/adaptors.js +1 -0
  23. package/altitude-locator/draw-subset-obj.js +19 -0
  24. package/altitude-locator/keymethod.js +1 -0
  25. package/altitude-locator/plugin.js +357 -0
  26. package/altitude-locator/types.js +23 -0
  27. package/arrowfield/adaptor.js +15 -0
  28. package/arrowfield/index.js +10 -0
  29. package/arrowfield/plugin.js +89 -0
  30. package/bearing-line/index.js +8 -0
  31. package/bearing-line/plugin.js +474 -0
  32. package/circle-line-chain/chain-list-map.js +211 -0
  33. package/circle-line-chain/init.js +1 -0
  34. package/circle-line-chain/plugin.js +449 -0
  35. package/circle-line-chain/util.js +5 -0
  36. package/compass-rose/compass-rose-padding-flat.js +247 -0
  37. package/compass-rose/compass-text-writer.js +161 -0
  38. package/compass-rose/index.js +7 -0
  39. package/compassrose/compassrose.js +300 -0
  40. package/compassrose/index.js +8 -0
  41. package/globe-types.js +1 -0
  42. package/heatwave/index.js +10 -0
  43. package/heatwave/isobar/objectarraylabels.js +206 -0
  44. package/heatwave/isobar/plugin.js +362 -0
  45. package/heatwave/isobar/quadtreecontours.js +316 -0
  46. package/heatwave/plugins/heatwaveglobeshell.js +224 -0
  47. package/index.js +11 -11
  48. package/jest.config.js +7 -0
  49. package/package.json +4 -4
  50. package/partialrings/buffer-manager.js +113 -0
  51. package/partialrings/index.js +41 -0
  52. package/partialrings/plugin.js +171 -0
  53. package/partialrings/program.js +197 -0
  54. package/pin/pin-object-array.js +308 -0
  55. package/pin/pin-point-totem.js +61 -0
  56. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  57. package/point-heat-map/index.js +1 -0
  58. package/point-heat-map/plugin-webworker.js +131 -0
  59. package/point-heat-map/point-to-heat-map-flow.js +129 -0
  60. package/point-tracks/key-methods.js +5 -0
  61. package/point-tracks/plugin.js +353 -0
  62. package/programs/arrowfield/index.js +7 -0
  63. package/programs/arrowfield/logic.js +149 -0
  64. package/programs/arrowfield/object.js +68 -0
  65. package/programs/data2legend/density-to-legend.js +77 -0
  66. package/programs/data2legend/point-to-density-texture.js +75 -0
  67. package/programs/float2legendwithratio/index.js +8 -0
  68. package/programs/float2legendwithratio/logic.js +125 -0
  69. package/programs/float2legendwithratio/object.js +113 -0
  70. package/programs/globe-util/is-globe-moved.js +22 -0
  71. package/programs/globeshell/index.js +8 -0
  72. package/programs/globeshell/noise/noises.js +1 -0
  73. package/programs/globeshell/wiggle/index.js +8 -0
  74. package/programs/globeshell/wiggle/logic.js +252 -0
  75. package/programs/globeshell/wiggle/object.js +74 -0
  76. package/programs/helpers/blender/index.js +1 -0
  77. package/programs/helpers/blender/program.js +62 -0
  78. package/programs/helpers/fadeaway/index.js +7 -0
  79. package/programs/helpers/fadeaway/logic.js +50 -0
  80. package/programs/helpers/fadeaway/object.js +21 -0
  81. package/programs/helpers/index.js +8 -0
  82. package/programs/index.js +58 -0
  83. package/programs/interface.js +1 -0
  84. package/programs/line-on-globe/angled-line.js +117 -0
  85. package/programs/line-on-globe/circle-accurate-3d.js +91 -0
  86. package/programs/line-on-globe/circle-accurate-flat.js +158 -0
  87. package/programs/line-on-globe/circle-accurate.js +108 -0
  88. package/programs/line-on-globe/circle.js +102 -0
  89. package/programs/line-on-globe/degree-padding-around-circle-3d.js +109 -0
  90. package/programs/line-on-globe/index.js +1 -0
  91. package/programs/line-on-globe/lines-color-instanced-flat.js +91 -0
  92. package/programs/line-on-globe/linestrip.js +110 -0
  93. package/programs/line-on-globe/naive-accurate-flexible.js +125 -0
  94. package/programs/line-on-globe/to-the-surface.js +82 -0
  95. package/programs/line-on-globe/util.js +8 -0
  96. package/programs/picking/pickable-renderer.js +104 -0
  97. package/programs/point-on-globe/element-globe-surface-glow.js +102 -0
  98. package/programs/point-on-globe/element-point-glow.js +85 -0
  99. package/programs/point-on-globe/square-pixel-point.js +125 -0
  100. package/programs/programcache.js +131 -0
  101. package/programs/rings/distancering/circleflatprogram.js +114 -0
  102. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +358 -0
  103. package/programs/rings/distancering/circlepaddysharedbuffer.js +433 -0
  104. package/programs/rings/distancering/index.js +14 -0
  105. package/programs/rings/distancering/paddyflatprogram.js +119 -0
  106. package/programs/rings/distancering/paddyflatprogram2d.js +121 -0
  107. package/programs/rings/distancering/paddyflatprogram3d.js +119 -0
  108. package/programs/rings/distancering/shader.js +1 -0
  109. package/programs/rings/index.js +17 -0
  110. package/programs/rings/partial-ring/piece-of-pie.js +173 -0
  111. package/programs/totems/camerauniformblock.js +147 -0
  112. package/programs/totems/canvas-webglobe-info.js +102 -0
  113. package/programs/totems/gpu-selection-uniform-block.js +104 -0
  114. package/programs/totems/index.js +40 -0
  115. package/programs/two-d/pixel-circle.js +1 -0
  116. package/programs/two-d/pixel-padding-for-compass.js +101 -0
  117. package/programs/util.js +18 -0
  118. package/programs/vectorfields/index.js +23 -0
  119. package/programs/vectorfields/logics/drawrectangleparticles.js +66 -0
  120. package/programs/vectorfields/logics/index.js +12 -0
  121. package/programs/vectorfields/logics/pixelbased.js +86 -0
  122. package/programs/vectorfields/logics/ubo.js +57 -0
  123. package/programs/vectorfields/pingpongbuffermanager.js +80 -0
  124. package/rangerings/enum.js +5 -0
  125. package/rangerings/index.js +15 -0
  126. package/rangerings/plugin.js +610 -0
  127. package/rangerings/rangeringangletext.js +341 -0
  128. package/rangerings/ring-account.js +134 -0
  129. package/shaders/fragment-toy/firework.js +4 -0
  130. package/shaders/fragment-toy/singularity.js +5 -0
  131. package/shape-on-terrain/arc/naive/plugin.js +252 -0
  132. package/timetracks/adaptors-line-strip.js +82 -0
  133. package/timetracks/adaptors.js +136 -0
  134. package/timetracks/index.js +19 -0
  135. package/timetracks/plugin-line-strip.js +254 -0
  136. package/timetracks/plugin.js +262 -0
  137. package/timetracks/program-line-strip.js +418 -0
  138. package/timetracks/program.js +466 -0
  139. package/timetracks/programpoint-line-strip.js +101 -0
  140. package/timetracks/programpoint.js +101 -0
  141. package/types.js +15 -0
  142. package/util/account/bufferoffsetmanager.js +202 -0
  143. package/util/account/index.js +23 -0
  144. package/util/account/single-attribute-buffer-management/buffer-manager.js +112 -0
  145. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +180 -0
  146. package/util/account/single-attribute-buffer-management/index.js +9 -0
  147. package/util/account/single-attribute-buffer-management/object-store.js +53 -0
  148. package/util/account/single-attribute-buffer-management/types.js +2 -0
  149. package/util/account/util.js +24 -0
  150. package/util/algorithms/index.js +1 -0
  151. package/util/algorithms/search-binary.js +28 -0
  152. package/util/check/get.js +18 -0
  153. package/util/check/index.js +1 -0
  154. package/util/check/typecheck.js +51 -0
  155. package/util/geometry/index.js +53 -0
  156. package/util/gl-util/buffer/attribute-loader.js +81 -0
  157. package/util/gl-util/buffer/index.js +6 -0
  158. package/util/gl-util/buffer/types.js +1 -0
  159. package/util/gl-util/draw-options/methods.js +38 -0
  160. package/util/gl-util/draw-options/types.js +15 -0
  161. package/util/gl-util/uniform-block/manager.js +168 -0
  162. package/util/gl-util/uniform-block/shader.js +1 -0
  163. package/util/gl-util/uniform-block/types.js +8 -0
  164. package/util/heatwavedatamanager/datamanager.js +212 -0
  165. package/util/heatwavedatamanager/index.js +10 -0
  166. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +125 -0
  167. package/util/heatwavedatamanager/pointcoordsmeta.js +21 -0
  168. package/util/index.js +57 -0
  169. package/util/interpolation/index.js +1 -0
  170. package/util/interpolation/timetrack/index.js +5 -0
  171. package/util/interpolation/timetrack/timetrack-interpolator.js +81 -0
  172. package/util/interpolation/timetrack/web-worker-str.js +5 -0
  173. package/util/interpolation/timetrack/web-worker.js +48 -0
  174. package/util/jshelpers/data-filler.js +20 -0
  175. package/util/jshelpers/equality.js +20 -0
  176. package/util/jshelpers/index.js +37 -0
  177. package/util/jshelpers/timefilters.js +32 -0
  178. package/util/picking/fence.js +46 -0
  179. package/util/picking/picker-displayer.js +145 -0
  180. package/util/programs/draw-texture-on-canvas.js +71 -0
  181. package/util/programs/index.js +17 -0
  182. package/util/programs/shapesonglobe.js +174 -0
  183. package/util/programs/supersampletotextures.js +107 -0
  184. package/util/programs/texturetoglobe.js +132 -0
  185. package/util/shaderfunctions/geometrytransformations.js +45 -0
  186. package/util/shaderfunctions/index.js +18 -0
  187. package/util/shaderfunctions/nodata.js +5 -0
  188. package/util/shaderfunctions/noisefunctions.js +13 -0
  189. package/util/surface-line-data/arc-bboxes.js +25 -0
  190. package/util/surface-line-data/arcs-to-cuts.js +53 -0
  191. package/util/surface-line-data/cut-arc.js +1 -0
  192. package/util/surface-line-data/flow.js +28 -0
  193. package/util/surface-line-data/rbush-manager.js +1 -0
  194. package/util/surface-line-data/types.js +1 -0
  195. package/util/surface-line-data/web-worker.js +1 -0
  196. package/util/webglobe/gldefaultstates.js +7 -0
  197. package/util/webglobe/index.js +18 -0
  198. package/util/webglobe/rasteroverlay.js +80 -0
  199. package/util/webglobjectbuilders.js +393 -0
  200. package/util/webglobjectbuilders1.js +238 -0
  201. package/waveparticles/adaptor.js +18 -0
  202. package/waveparticles/index.js +10 -0
  203. package/waveparticles/plugin.js +271 -0
  204. package/wind/imagetovectorfieldandmagnitude.js +35 -0
  205. package/wind/index.js +14 -0
  206. package/wind/plugin.js +724 -0
  207. package/wind/vectorfieldimage.js +25 -0
  208. package/write-text/attached-text-writer.js +93 -0
  209. package/write-text/context-text.js +105 -0
  210. package/write-text/context-text3.js +160 -0
  211. package/write-text/index.js +5 -0
  212. package/write-text/writer-plugin.js +8 -0
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CirclePadding3DCache = void 0;
4
+ var webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
5
+ var camerauniformblock_1 = require("../totems/camerauniformblock");
6
+ var programcache_1 = require("../programcache");
7
+ // import { vaoAttributeLoader } from "../../util/account/util";
8
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
9
+ var util_1 = require("./util");
10
+ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
11
+ /**
12
+ * TODO:
13
+ * 1. integrate geometry functions for radius angle and center
14
+ * 2. integrate attributes
15
+ *
16
+ * TODO:
17
+ * center_position is too small or doenst loaded as expected.
18
+ */
19
+ var INITIAL_EDGE_COUNT = 720;
20
+ var vertexShaderSource = "#version 300 es\nprecision highp float;\n".concat(camerauniformblock_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n").concat(geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate, "\n\n\nin vec3 center_position3d;\nin float big_radius;\nin float small_radius;\nin vec4 color;\n\nuniform float edge_count;\nuniform float step_angle;\nuniform int z_alpha_on;\n\nout float interpolation;\nout vec4 v_color;\nvoid main() {\n if( !is3D) {\n return;\n }\n v_color = color;\n if ( z_alpha_on == 1 ){\n float z_alpha = pow(z_level * 0.75, 3.0) * distance(big_radius, small_radius) / (R * 2.0);\n if ( z_alpha < 0.1 ) { return; }\n v_color.a *= z_alpha;\n }\n int pad_phase = gl_VertexID % 2; // 0 or 1\n interpolation = float( gl_VertexID - pad_phase) / edge_count;\n float angle = float( gl_VertexID - pad_phase) * step_angle;\n vec3 position;\n if ( pad_phase == 0 ) {\n position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, big_radius, angle);\n } else {\n position = circleLimpFromLongLatRadCenterCartesian3D_accurate(center_position3d, small_radius, angle);\n }\n gl_Position = cartesian3DToGLPosition(position);\n\n gl_PointSize = 5.0;\n}");
21
+ var fragmentShaderSource = "#version 300 es\n".concat(geometrytransformations_1.POLE, "\nprecision highp float;\nuniform float opacity;\nin vec4 v_color;\nin float interpolation;\nin vec2 v_limp;\nout vec4 color;\nvoid main() {\n color = v_color;\n color.a *= opacity;\n}\n");
22
+ var Logic = /** @class */ (function () {
23
+ function Logic(globe) {
24
+ this.globe = globe;
25
+ this.gl = globe.gl;
26
+ this._lastOpacity = 1.0;
27
+ this._lastEdgeCount = INITIAL_EDGE_COUNT;
28
+ this._lastStepAngle = 720 / INITIAL_EDGE_COUNT;
29
+ this._lastZAlphaMode = util_1.Z_ALPHA_MODE.ON;
30
+ this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
31
+ var _a = this, gl = _a.gl, program = _a.program;
32
+ this.program.uniforms = {
33
+ opacity: gl.getUniformLocation(program, "opacity"),
34
+ edgeCount: gl.getUniformLocation(program, "edge_count"),
35
+ stepAngle: gl.getUniformLocation(program, "step_angle"),
36
+ zAlphaMode: gl.getUniformLocation(program, "z_alpha_on")
37
+ };
38
+ { // initial uniform values
39
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
40
+ gl.useProgram(program);
41
+ gl.uniform1f(program.uniforms.opacity, 1.0);
42
+ gl.uniform1f(program.uniforms.edgeCount, INITIAL_EDGE_COUNT * 2);
43
+ gl.uniform1f(program.uniforms.stepAngle, this._lastStepAngle * Math.PI / 360);
44
+ gl.uniform1i(program.uniforms.zAlphaMode, util_1.Z_ALPHA_MODE.ON);
45
+ gl.useProgram(currentProgram);
46
+ }
47
+ { // assign attribute locations
48
+ gl.bindAttribLocation(program, 0, "center_position3d");
49
+ gl.bindAttribLocation(program, 1, "big_radius");
50
+ gl.bindAttribLocation(program, 2, "small_radius");
51
+ gl.bindAttribLocation(program, 3, "color");
52
+ }
53
+ this.cameraBindingPoint = 0;
54
+ this.cameraBlockTotem = camerauniformblock_1.CameraUniformBlockTotemCache.get(globe);
55
+ var cameraBlockLocation = gl.getUniformBlockIndex(program, "CameraUniformBlock");
56
+ gl.uniformBlockBinding(program, cameraBlockLocation, this.cameraBindingPoint);
57
+ }
58
+ Logic.prototype.createVAO = function (center3dObj, bigRadiusObj, smallRadiusObj, colorObj) {
59
+ var gl = this.gl;
60
+ var vao = gl.createVertexArray();
61
+ var divisor = 1;
62
+ gl.bindVertexArray(vao);
63
+ (0, attribute_loader_1.attributeLoader)(gl, center3dObj, 0, 3, { divisor: divisor });
64
+ (0, attribute_loader_1.attributeLoader)(gl, bigRadiusObj, 1, 1, { divisor: divisor });
65
+ (0, attribute_loader_1.attributeLoader)(gl, smallRadiusObj, 2, 1, { divisor: divisor });
66
+ (0, attribute_loader_1.attributeLoader)(gl, colorObj, 3, 4, { divisor: divisor });
67
+ gl.bindVertexArray(null);
68
+ return vao;
69
+ };
70
+ Logic.prototype.draw = function (vao, length, edgeCount, stepAngle, opacity, zAlphaMode) {
71
+ if (zAlphaMode === void 0) { zAlphaMode = util_1.Z_ALPHA_MODE.ON; }
72
+ var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem, cameraBindingPoint = _a.cameraBindingPoint;
73
+ gl.useProgram(program);
74
+ if (this._lastOpacity !== opacity) {
75
+ gl.uniform1f(program.uniforms.opacity, opacity);
76
+ this._lastOpacity = opacity;
77
+ }
78
+ if (this._lastEdgeCount !== edgeCount) {
79
+ gl.uniform1f(program.uniforms.edgeCount, 2 * edgeCount);
80
+ this._lastEdgeCount = edgeCount;
81
+ }
82
+ if (this._lastStepAngle !== stepAngle) {
83
+ gl.uniform1f(program.uniforms.stepAngle, stepAngle * Math.PI / 360);
84
+ this._lastStepAngle = stepAngle;
85
+ }
86
+ if (this._lastZAlphaMode !== zAlphaMode) {
87
+ gl.uniform1i(program.uniforms.zAlphaMode, zAlphaMode);
88
+ this._lastZAlphaMode = zAlphaMode;
89
+ }
90
+ gl.bindVertexArray(vao);
91
+ cameraBlockTotem.bind(cameraBindingPoint);
92
+ gl.drawArraysInstanced(gl.LINES, 0, edgeCount * 2, length);
93
+ // gl.drawArraysInstanced(gl.POINTS, 0, edgeCount, length);
94
+ cameraBlockTotem.unbind(cameraBindingPoint);
95
+ gl.bindVertexArray(null);
96
+ };
97
+ Logic.prototype.free = function () {
98
+ if (this.isFreed)
99
+ return;
100
+ camerauniformblock_1.CameraUniformBlockTotemCache.release(this.globe);
101
+ this.gl.deleteProgram(this.program);
102
+ this.isFreed = true;
103
+ };
104
+ return Logic;
105
+ }());
106
+ exports.CirclePadding3DCache = Object.freeze({
107
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
108
+ release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
109
+ });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Z_ALPHA_MODE = exports.LinesColorInstancedFlatCache = void 0;
4
+ var totems_1 = require("../totems");
5
+ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
+ var programcache_1 = require("../programcache");
7
+ var util_1 = require("../../util");
8
+ var util_2 = require("./util");
9
+ Object.defineProperty(exports, "Z_ALPHA_MODE", { enumerable: true, get: function () { return util_2.Z_ALPHA_MODE; } });
10
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
11
+ /**
12
+ * This program draws line between points provided from the first and second buffer.
13
+ * draw method gl.drawArraysInstanced( gl.POINTS, 0,2, lineCount);
14
+ * */
15
+ // TODO: find better way to eleminate edge case distance(posA, posB) > 37000000.0
16
+ var vertexShaderSource = "#version 300 es\nprecision highp float;\n".concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\nuniform float opacity;\nuniform int z_alpha_on;\n\nin vec2 posA;\nin vec2 posB;\nin vec4 color;\n\nout vec2 v_frame;\nout vec4 v_color;\nvoid main() {\n \n if ( is3D ) {\n return;\n }\n float gap = max( distance(posA.x, posB.x), distance(posA.y,posB.y)); // \n if ( gap > 37000000.0) { return; }\n float z_alpha;\n if ( z_alpha_on == 1 ){ \n z_alpha = pow(2.0,z_level+1.0) / ( 10000000.0 / gap);\n z_alpha = smoothstep(0.1,0.9, z_alpha);\n if( z_alpha < 0.01) {return;}\n } else {\n z_alpha = 1.0;\n }\n vec2 pos;\n if ( gl_VertexID == 0 ) {\n pos = posA;\n } else {\n pos = posB;\n }\n v_frame = pos;\n gl_Position = mercatorXYToGLPosition( pos );\n v_color = color;\n v_color.a *= z_alpha * opacity;\n gl_PointSize = 4.0;\n}");
17
+ var fragmentShaderSource = "#version 300 es\n".concat(geometrytransformations_1.POLE, "\nprecision highp float;\nin vec4 v_color;\nin vec2 v_frame;\nout vec4 outColor;\nvoid main() {\n if ( v_frame.x < -POLE || v_frame.x > POLE || v_frame.y < -POLE || v_frame.y > POLE ){ discard; }\n outColor = v_color;\n}");
18
+ var Logic = /** @class */ (function () {
19
+ function Logic(globe) {
20
+ this.globe = globe;
21
+ this.gl = globe.gl;
22
+ this.program = (0, util_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
23
+ this._lastOpicity = 1.0;
24
+ this._lastZAlphaOn = util_2.Z_ALPHA_MODE.OFF;
25
+ var _a = this, gl = _a.gl, program = _a.program;
26
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
27
+ gl.useProgram(program);
28
+ { // assign attribute locations
29
+ gl.bindAttribLocation(program, 0, 'posA');
30
+ gl.bindAttribLocation(program, 1, 'posB');
31
+ gl.bindAttribLocation(program, 2, 'color');
32
+ }
33
+ { // uniform locations
34
+ this._opacityLocation = gl.getUniformLocation(program, 'opacity');
35
+ this._zAlphaOnLocation = gl.getUniformLocation(program, 'z_alpha_on');
36
+ gl.uniform1i(this._zAlphaOnLocation, this._lastZAlphaOn);
37
+ gl.uniform1f(this._opacityLocation, this._lastOpicity);
38
+ }
39
+ { // uniform block
40
+ this._cameraUniformBlock = totems_1.CameraUniformBlockTotemCache.get(globe);
41
+ this._cameraBindingPoint = 0;
42
+ var cameraBlockBindingIndex = gl.getUniformBlockIndex(program, 'CameraUniformBlock');
43
+ gl.uniformBlockBinding(program, cameraBlockBindingIndex, this._cameraBindingPoint);
44
+ }
45
+ gl.useProgram(currentProgram);
46
+ }
47
+ Logic.prototype.createVAO = function (posAObj, posBObj, colorObj) {
48
+ var gl = this.gl;
49
+ var vao = gl.createVertexArray();
50
+ var divisor = 1;
51
+ gl.bindVertexArray(vao);
52
+ (0, attribute_loader_1.attributeLoader)(gl, posAObj, 0, 2, { divisor: divisor });
53
+ (0, attribute_loader_1.attributeLoader)(gl, posBObj, 1, 2, { divisor: divisor });
54
+ (0, attribute_loader_1.attributeLoader)(gl, colorObj, 2, 4, { divisor: divisor });
55
+ gl.bindVertexArray(null);
56
+ return vao;
57
+ };
58
+ Logic.prototype.draw = function (vao, lineCount, opacity, zAlphaOn) {
59
+ if (opacity === void 0) { opacity = 1.0; }
60
+ if (zAlphaOn === void 0) { zAlphaOn = util_2.Z_ALPHA_MODE.ON; }
61
+ var _a = this, gl = _a.gl, program = _a.program, _cameraBindingPoint = _a._cameraBindingPoint, _cameraUniformBlock = _a._cameraUniformBlock;
62
+ gl.useProgram(program);
63
+ _cameraUniformBlock.bind(_cameraBindingPoint);
64
+ gl.bindVertexArray(vao);
65
+ if (this._lastOpicity !== opacity) {
66
+ this._lastOpicity = opacity;
67
+ gl.uniform1f(this._opacityLocation, opacity);
68
+ }
69
+ if (this._lastZAlphaOn !== zAlphaOn) {
70
+ this._lastZAlphaOn = zAlphaOn;
71
+ gl.uniform1i(this._zAlphaOnLocation, zAlphaOn);
72
+ }
73
+ gl.drawArraysInstanced(gl.LINES, 0, 2, lineCount);
74
+ _cameraUniformBlock.unbind(_cameraBindingPoint);
75
+ gl.bindVertexArray(null);
76
+ };
77
+ Logic.prototype.free = function () {
78
+ if (this.isFreed)
79
+ return;
80
+ var _a = this, gl = _a.gl, program = _a.program, globe = _a.globe;
81
+ totems_1.CameraUniformBlockTotemCache.release(globe);
82
+ gl.deleteProgram(program);
83
+ this.isFreed = true;
84
+ };
85
+ return Logic;
86
+ }());
87
+ var LinesColorInstancedFlatCache = Object.freeze({
88
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
89
+ release: function (globe) { programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
90
+ });
91
+ exports.LinesColorInstancedFlatCache = LinesColorInstancedFlatCache;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineStripProgramCache = void 0;
4
+ var webglobjectbuilders_1 = require("../../util/webglobjectbuilders");
5
+ require("../interface");
6
+ var totems_1 = require("../totems");
7
+ var geometrytransformations_js_1 = require("../../util/shaderfunctions/geometrytransformations.js");
8
+ var programcache_1 = require("../programcache");
9
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
10
+ require("../../util/gl-util/buffer/attribute-loader");
11
+ var manager_1 = require("../../util/gl-util/uniform-block/manager");
12
+ require("../../util/gl-util/uniform-block/types");
13
+ var methods_1 = require("../../util/gl-util/draw-options/methods");
14
+ require("../../util/gl-util/draw-options/types");
15
+ var ESCAPE_VALUE = -1;
16
+ var uniformBindingPoints = {
17
+ camera: 0,
18
+ flexible: 1,
19
+ };
20
+ var one = new Float32Array([1]);
21
+ var flexibleBlockManager = new manager_1.UniformBlockManager('FlexibleAttributes', [
22
+ { name: "u_color", type: "vec4", value: new Float32Array([0.12, 1, 0.1, 1]) },
23
+ { name: "u_dash_opacity", type: "float", value: one },
24
+ { name: "u_dash_length", type: "float", value: one },
25
+ ], uniformBindingPoints.flexible);
26
+ var vertexShaderSource = "#version 300 es\nprecision highp float;\n\n".concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_js_1.cartesian3DToGLPosition, "\n").concat(geometrytransformations_js_1.mercatorXYToGLPosition, "\n\n").concat(flexibleBlockManager.glslCode(), "\n\nin vec3 position3d;\nin vec2 position2d;\nin vec4 color; \nin float dash_length;\nin float dash_opacity;\n\nout float v_dash_length;\nout float v_dash_opacity;\nout vec4 v_color;\n\nflat out vec3 v_flat_position;\nout vec3 v_position;\n\nvoid main() {\n\n v_color = ( color.r == -1.0 ) ? u_color : color;\n v_dash_length = ( dash_length == -1.0 ) ? u_dash_length : dash_length;\n v_dash_opacity = ( dash_opacity == -1.0 ) ? u_dash_opacity : dash_opacity;\n\n if ( is3D ) {\n gl_Position = cartesian3DToGLPosition( position3d );\n v_position = position3d;\n v_flat_position = position3d;\n } else {\n gl_Position = mercatorXYToGLPosition( position2d );\n v_position = vec3( position2d, 0.0 );\n v_flat_position = vec3( position2d, 0.0 );\n }\n gl_PointSize = 4.0;\n}");
27
+ var fragmentShaderSource = "#version 300 es\nprecision highp float;\n\nuniform float opacity;\n\nin vec4 v_color;\nin float v_dash_length;\nin float v_dash_opacity;\n\nflat in vec3 v_flat_position;\nin vec3 v_position;\n\n\nout vec4 outColor;\n\nvoid main() {\n outColor = v_color;\n return;\n float dash_length = v_dash_length;\n float dash_opacity = v_dash_opacity;\n\n if ( dash_length == 0.0 ) {\n outColor = vec4( v_color.rgb, v_color.a * v_dash_opacity );\n } else {\n float dist = distance( v_flat_position, v_position );\n // float alpha = mod( dist , v_dash_length * 2.0 ) / v_dash_length < 1.0 ? 1.0 : v_dash_opacity;\n outColor = vec4( v_color.rgb, v_color.a * opacity );\n }\n}";
28
+ console.log("LineStripProgram");
29
+ console.log(vertexShaderSource);
30
+ console.log(fragmentShaderSource);
31
+ var Logic = /** @class */ (function () {
32
+ function Logic(globe) {
33
+ this._vaosPublished = [];
34
+ this._ubosPublished = [];
35
+ this._opacity = {
36
+ value: 1,
37
+ location: null
38
+ };
39
+ console.log("LineStripProgram globe", globe);
40
+ this.gl = globe.gl;
41
+ this.globe = globe;
42
+ this.program = (0, webglobjectbuilders_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
43
+ var currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
44
+ this.gl.useProgram(this.program);
45
+ this._opacity.location = this.gl.getUniformLocation(this.program, "opacity");
46
+ this.gl.uniform1f(this._opacity.location, this._opacity.value);
47
+ // bind attribute locations
48
+ this.gl.bindAttribLocation(this.program, 0, "position3d");
49
+ this.gl.bindAttribLocation(this.program, 1, "position2d");
50
+ this.gl.bindAttribLocation(this.program, 2, "color");
51
+ this.gl.bindAttribLocation(this.program, 3, "dash_length");
52
+ this.gl.bindAttribLocation(this.program, 4, "dash_opacity");
53
+ this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
54
+ this.cameraBlockTotem.assignBindingPoint(this.program, uniformBindingPoints.camera);
55
+ flexibleBlockManager.assignBindingPoint(this.gl, this.program);
56
+ this._defaultFlexibleUBO = flexibleBlockManager.createUBO(this.gl);
57
+ this.gl.useProgram(currentProgram);
58
+ }
59
+ Logic.prototype.createUBO = function (bufferReadType) {
60
+ if (bufferReadType === void 0) { bufferReadType = "STATIC_DRAW"; }
61
+ var ubo = flexibleBlockManager.createUBO(this.gl, bufferReadType);
62
+ this._ubosPublished.push(ubo);
63
+ return ubo;
64
+ };
65
+ Logic.prototype.createVAO = function (position3D, position2D, color, dashLength, dashOpacity) {
66
+ var gl = this.gl;
67
+ var vao = gl.createVertexArray();
68
+ gl.bindVertexArray(vao);
69
+ (0, attribute_loader_1.attributeLoader)(gl, position3D, 0, 3);
70
+ (0, attribute_loader_1.attributeLoader)(gl, position2D, 1, 2);
71
+ (0, attribute_loader_1.attributeLoader)(gl, color, 2, 4, { escapeValues: [ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE, ESCAPE_VALUE] });
72
+ (0, attribute_loader_1.attributeLoader)(gl, dashLength, 3, 1, { escapeValues: [ESCAPE_VALUE] });
73
+ (0, attribute_loader_1.attributeLoader)(gl, dashOpacity, 4, 1, { escapeValues: [ESCAPE_VALUE] });
74
+ gl.bindVertexArray(null);
75
+ return vao;
76
+ };
77
+ Logic.prototype.draw = function (vao, drawOptions, opacity, flexibleUBO) {
78
+ if (opacity === void 0) { opacity = 1; }
79
+ if (flexibleUBO === void 0) { flexibleUBO = null; }
80
+ var _a = this, gl = _a.gl, program = _a.program, cameraBlockTotem = _a.cameraBlockTotem;
81
+ gl.useProgram(program);
82
+ if (opacity !== this._opacity.value) {
83
+ this._opacity.value = opacity;
84
+ this.gl.uniform1f(this._opacity.location, this._opacity.value);
85
+ }
86
+ var ubo = flexibleUBO || this._defaultFlexibleUBO;
87
+ cameraBlockTotem.bind(uniformBindingPoints.camera);
88
+ ubo.bind();
89
+ gl.bindVertexArray(vao);
90
+ (0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
91
+ (0, methods_1.drawArrays)(gl, gl.LINE_STRIP, drawOptions);
92
+ gl.bindVertexArray(null);
93
+ ubo.unbind();
94
+ cameraBlockTotem.unbind(uniformBindingPoints.camera);
95
+ };
96
+ Logic.prototype.free = function () {
97
+ var _this = this;
98
+ this._vaosPublished.forEach(function (vao) { return _this.gl.deleteVertexArray(vao); });
99
+ this._ubosPublished.forEach(function (ubo) { return ubo.free(); });
100
+ this.gl.deleteProgram(this.program);
101
+ this._defaultFlexibleUBO.free();
102
+ totems_1.CameraUniformBlockTotemCache.release(this.globe);
103
+ this.gl.deleteProgram(this.program);
104
+ };
105
+ return Logic;
106
+ }());
107
+ exports.LineStripProgramCache = Object.freeze({
108
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
109
+ release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); },
110
+ });
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LineOnGlobeCache = void 0;
4
+ var totems_1 = require("../totems");
5
+ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
+ var util_1 = require("../../util");
7
+ var programcache_1 = require("../programcache");
8
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
9
+ var manager_1 = require("../../util/gl-util/uniform-block/manager");
10
+ require("../../util/gl-util/draw-options/types");
11
+ var methods_1 = require("../../util/gl-util/draw-options/methods");
12
+ var GLOBE_MIDPOINT_COUNT = 30;
13
+ var escapeValue = -1.0;
14
+ var uniformBindingPoints = {
15
+ camera: 0,
16
+ flexible: 1
17
+ };
18
+ var uniformBlockManager = new manager_1.UniformBlockManager('FlexibleAttibutes', [
19
+ { name: 'u_color', type: 'vec4' },
20
+ { name: 'u_dash_ratio', type: 'float' },
21
+ { name: 'u_dash_opacity', type: 'float' }
22
+ ], uniformBindingPoints.flexible);
23
+ var vertexShader = "#version 300 es\nprecision highp float;\n\n".concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.slerp, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n\n").concat(uniformBlockManager.glslCode(), "\n\nin vec2 start_position;\nin vec3 start_position3d;\nin vec2 end_position;\nin vec3 end_position3d;\n\nin float dash_ratio;\nin float dash_opacity;\nin vec4 color;\n\nout float v_dash_ratio;\nout float v_dash_opacity;\nout vec4 v_color;\n\nout vec2 v_limp;\nout float interpolation;\n\nvoid main() {\n vec2 longLat;\n\n v_color = (color.r == -1.0) ? u_color: color;\n v_dash_ratio = (dash_ratio == -1.0) ? u_dash_ratio : dash_ratio;\n v_dash_opacity = (dash_opacity == -1.0) ? u_dash_opacity : dash_opacity;\n\n if (is3D) {\n interpolation = float(gl_VertexID) / ").concat(GLOBE_MIDPOINT_COUNT - 1, ".0;\n vec3 cartesian = slerp(start_position3d, end_position3d, interpolation);\n gl_Position = cartesian3DToGLPosition(cartesian);\n v_limp = vec2(0.0, 0.0);\n } else {\n if ( distance( start_position, end_position) > 30000000.0) { return; }\n interpolation = float(gl_VertexID);\n if (gl_VertexID % 2 == 0) {\n longLat = start_position;\n } else {\n longLat = end_position;\n }\n v_limp = longLat;\n gl_Position = mercatorXYToGLPosition(longLat);\n }\n}\n");
24
+ var fragmentShader = "#version 300 es\n".concat(geometrytransformations_1.POLE, "\nprecision highp float;\n\nuniform float opacity;\n\nin float interpolation;\nin vec2 v_limp;\nin vec4 v_color;\nin float v_dash_ratio;\nin float v_dash_opacity;\n\nout vec4 color;\n\nvoid main() {\n if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }\n color = v_color;\n color.a *= opacity;\n if ( v_dash_ratio >= 1.0 ) { return; }\n if (interpolation > 0.95) { return; }\n if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }\n\n}\n");
25
+ var Logic = /** @class */ (function () {
26
+ function Logic(globe) {
27
+ this.vaosPublished = [];
28
+ this.isFreed = false;
29
+ this.globe = globe;
30
+ this.gl = globe.gl;
31
+ this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
32
+ this._lastOpacity = 1.0;
33
+ var _a = this, gl = _a.gl, program = _a.program;
34
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
35
+ gl.useProgram(program);
36
+ // assign attribute locations
37
+ gl.bindAttribLocation(program, 0, "start_position");
38
+ gl.bindAttribLocation(program, 1, "start_position3d");
39
+ gl.bindAttribLocation(program, 2, "end_position");
40
+ gl.bindAttribLocation(program, 3, "end_position3d");
41
+ gl.bindAttribLocation(program, 4, "dash_ratio");
42
+ gl.bindAttribLocation(program, 5, "dash_opacity");
43
+ gl.bindAttribLocation(program, 6, "color");
44
+ this._opacityLocation = gl.getUniformLocation(program, "opacity");
45
+ gl.uniform1f(this._opacityLocation, this._lastOpacity);
46
+ gl.useProgram(currentProgram);
47
+ this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
48
+ this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
49
+ this._ubosPublished = [];
50
+ uniformBlockManager.assignBindingPoint(this.gl, this.program);
51
+ this._defaultFlexibleUBO = this.createUBO();
52
+ }
53
+ /**
54
+ *
55
+ * @param {*} vao
56
+ * @param {DrawRangeIndexParams} drawOptions
57
+ * @param {number} opacity
58
+ * @param {Object} flexibleOptions
59
+ * @param {Array<number, number, number, number>} flexibleOptions.color // 0-1
60
+ * @param {number} flexibleOptions.dash_opacity
61
+ * @param {number} flexibleOptions.dash_ratio
62
+ */
63
+ Logic.prototype.draw = function (vao, drawOptions, opacity, flexibleUBO) {
64
+ if (flexibleUBO === void 0) { flexibleUBO = null; }
65
+ var _a = this, gl = _a.gl, program = _a.program, globe = _a.globe, cameraBlockTotem = _a.cameraBlockTotem, _defaultFlexibleUBO = _a._defaultFlexibleUBO;
66
+ gl.useProgram(program);
67
+ cameraBlockTotem.bind(uniformBindingPoints.camera);
68
+ gl.bindVertexArray(vao);
69
+ if (opacity !== this._lastOpacity) {
70
+ gl.uniform1f(this._opacityLocation, opacity);
71
+ this._lastOpacity = opacity;
72
+ }
73
+ // this._setFlexibleUniforms(flexibleOptions);
74
+ var vertexCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
75
+ var ubo = flexibleUBO || _defaultFlexibleUBO;
76
+ ubo.bind();
77
+ (0, methods_1.drawInstanced)(gl, gl.LINE_STRIP, drawOptions, vertexCount);
78
+ ubo.unbind();
79
+ gl.bindVertexArray(null);
80
+ cameraBlockTotem.unbind(uniformBindingPoints.camera);
81
+ };
82
+ Logic.prototype.createUBO = function (bufferReadType) {
83
+ if (bufferReadType === void 0) { bufferReadType = "STATIC_DRAW"; }
84
+ var ubo = uniformBlockManager.createUBO(this.gl, bufferReadType);
85
+ this._ubosPublished.push(ubo);
86
+ ubo.update(new Map([
87
+ ["u_color", [1, 1, 1, 1]],
88
+ ["u_dash_ratio", [1]],
89
+ ["u_dash_opacity", [1]]
90
+ ]));
91
+ return ubo;
92
+ };
93
+ Logic.prototype.createVAO = function (startPotision2DBufferObj, startPotision3DBufferObj, endPosition2DBufferObj, endPosition3DBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
94
+ var gl = this.gl;
95
+ var vao = gl.createVertexArray();
96
+ gl.bindVertexArray(vao);
97
+ var divisor = 1;
98
+ (0, attribute_loader_1.attributeLoader)(gl, startPotision2DBufferObj, 0, 2, { divisor: divisor });
99
+ (0, attribute_loader_1.attributeLoader)(gl, startPotision3DBufferObj, 1, 3, { divisor: divisor });
100
+ (0, attribute_loader_1.attributeLoader)(gl, endPosition2DBufferObj, 2, 2, { divisor: divisor });
101
+ (0, attribute_loader_1.attributeLoader)(gl, endPosition3DBufferObj, 3, 3, { divisor: divisor });
102
+ (0, attribute_loader_1.attributeLoader)(gl, dashRatioBufferObj, 4, 1, { divisor: divisor, escapeValues: [escapeValue] });
103
+ (0, attribute_loader_1.attributeLoader)(gl, dashOpacityBufferObj, 5, 1, { divisor: divisor, escapeValues: [escapeValue] });
104
+ (0, attribute_loader_1.attributeLoader)(gl, colorBufferObj, 6, 4, { divisor: divisor, escapeValues: [escapeValue, escapeValue, escapeValue, escapeValue] });
105
+ gl.bindVertexArray(null);
106
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
107
+ this.vaosPublished.push(vao);
108
+ return vao;
109
+ };
110
+ Logic.prototype.free = function () {
111
+ var _this = this;
112
+ if (this.isFreed)
113
+ return;
114
+ totems_1.CameraUniformBlockTotemCache.release(this.globe);
115
+ this.gl.deleteProgram(this.program);
116
+ this.vaosPublished.forEach(function (vao) { return _this.gl.deleteVertexArray(vao); });
117
+ this._ubosPublished.forEach(function (ubo) { return ubo.free(); });
118
+ this.isFreed = true;
119
+ };
120
+ return Logic;
121
+ }());
122
+ exports.LineOnGlobeCache = Object.freeze({
123
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
124
+ release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
125
+ });
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var util_1 = require("./util");
4
+ var totems_1 = require("../totems");
5
+ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
6
+ var programcache_1 = require("../programcache");
7
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
8
+ require("../draw-options/types");
9
+ var methods_1 = require("../draw-options/methods");
10
+ var vs = "#version 300 es\n".concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\nin vec3 pos3D\nin vec4 color;\nout float ratio;\nout flat vec4 vColor;\nvoid main(){\n if ( gl_VertexID == 0) {\n gl_Position = cartesian3DToGLPosition(pos3D);\n ratio =0.0;\n } else {\n vec3 sea_level_pos3D = norm(pos3D) * R_3D;\n gl_Position = cartesian3DToGLPosition(pos3D);\n ratio = 1.0;\n }\n vColor = color; \n}");
11
+ var fs = "#version 300 es\nuniform float opacity;\nuniform float phase;\nuniform float fadeOpacity;\nin flat vec4 vColor;\nin float ratio;\nout vec4 fragColor;\nvoid main(){\n fragColor = vec4( vColor.rgb, vColor.a * opacity);\n if (fadeOpacity < 1.0) {\n float alpha= mix( fadeOpacity, vColor.a, fract( ratio + phase ));\n fragColor.a *= alpha;\n } \n}";
12
+ var Logic = /** @class */ (function () {
13
+ function Logic(globe) {
14
+ this.globe = globe;
15
+ this.gl = globe.gl;
16
+ this.program = (0, util_1.createProgram)(this.gl, vs, fs);
17
+ var _a = this, gl = _a.gl, program = _a.program;
18
+ this._opacity = {
19
+ lastValue: 1.0,
20
+ location: gl.getUniformLocation(program, 'opacity')
21
+ };
22
+ this._phase = {
23
+ lastValue: 1.0,
24
+ location: gl.getUniformLocation(program, 'phase')
25
+ };
26
+ this._fadeOpacity = {
27
+ lastValue: 1.0,
28
+ location: gl.getUniformBlockLocation(program, 'fadeOpacity')
29
+ };
30
+ var currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
31
+ gl.useProgram(program);
32
+ [this._opacity, this._phase, this._fadeOpacity].forEach(function (wrapper) { return gl.uniform1f(wrapper.location, wrapper.lastValue); });
33
+ gl.useProgram(currentProgram);
34
+ gl.useProgram(program);
35
+ gl.bindAttribLocation(program, 0, 'pos3D');
36
+ gl.bindAttribLocation(program, 1, 'color');
37
+ this.cameraUniformBlockTotem = new totems_1.CameraUniformBlockTotemCache.get(globe);
38
+ this.cameraBlockBindingPoint = 0;
39
+ var cameraBlockIndex = gl.getUniformBlockLocation(program, 'CameraUniformBlock');
40
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
41
+ }
42
+ Logic.prototype.createVao = function (pos3DObj, colorObj) {
43
+ var gl = this.gl;
44
+ var vao = gl.createVertexArray();
45
+ var divisor = 1;
46
+ gl.bindVertexArray(vao);
47
+ (0, attribute_loader_1.attributeLoader)(gl, pos3DObj, 0, 3, { divisor: divisor });
48
+ (0, attribute_loader_1.attributeLoader)(gl, colorObj, 1, 4, { divisor: divisor, escapeValue: [-1, -1, -1, -1] });
49
+ gl.bindVertexArray(null);
50
+ this._vaoCache.push(vao);
51
+ return vao;
52
+ };
53
+ /**
54
+ *
55
+ * @param {WebGL2RenderingContext.vertexArrayObject} vao
56
+ * @param {Render} drawOptions
57
+ */
58
+ Logic.prototype.draw = function (vao, drawOptions, _a) {
59
+ var _b = _a.opacity, opacity = _b === void 0 ? 1.0 : _b, _c = _a.fadeOpacity, fadeOpacity = _c === void 0 ? 1.0 : _c;
60
+ var _d = this, globe = _d.globe, gl = _d.gl, program = _d.program, _opacity = _d._opacity, _fadeOpacity = _d._fadeOpacity;
61
+ gl.useProgram(program);
62
+ gl.bindVertexArray(vao);
63
+ if (fadeOpacity < 1.0) {
64
+ this._updatePhase();
65
+ globe.drawRender();
66
+ }
67
+ if (fadeOpacity !== _fadeOpacity.lastValue) {
68
+ _fadeOpacity.lastValue = fadeOpacity;
69
+ gl.uniform1f(_fadeOpacity.location, fadeOpacity);
70
+ }
71
+ if (opacity !== _opacity.lastValue) {
72
+ _opacity.lastValue = opacity;
73
+ gl.uniform1f(_opacity.location, opacity);
74
+ }
75
+ (0, methods_1.drawInstanced)(gl, gl.TRIANGLE_FAN, drawOptions);
76
+ };
77
+ Logic.prototype._updatePhase = function () {
78
+ this._phase.lastValue = (Date.now() / 3.0) % 1000;
79
+ gl.uniform1f(_phase.location, _phase.lastValue);
80
+ };
81
+ return Logic;
82
+ }());
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Z_ALPHA_MODE = void 0;
4
+ var Z_ALPHA_MODE = Object.freeze({
5
+ ON: 1,
6
+ OFF: 0
7
+ });
8
+ exports.Z_ALPHA_MODE = Z_ALPHA_MODE;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PickableRendererProgramCache = void 0;
4
+ var util_1 = require("../../util");
5
+ var totems_1 = require("../totems");
6
+ var geometrytransformations_1 = require("../../util/shaderfunctions/geometrytransformations");
7
+ var programcache_1 = require("../programcache");
8
+ require("../../util/gl-util/draw-options/types");
9
+ var methods_1 = require("../../util/gl-util/draw-options/methods");
10
+ var attribute_loader_1 = require("../../util/gl-util/buffer/attribute-loader");
11
+ var manager_1 = require("../../util/gl-util/uniform-block/manager");
12
+ var uniformBindingPoints = {
13
+ camera: 0,
14
+ flexible: 1
15
+ };
16
+ var uniformBlockManager = new manager_1.UniformBlockManager("FlexibleBlock", [
17
+ { name: "u_rgba", type: "vec4", value: new Float32Array([1, 1, 1, 1]) },
18
+ { name: "u_opacity", type: "float", value: new Float32Array([1.0]) },
19
+ { name: "u_size_multiplier", type: "float", value: new Float32Array([1.0]) },
20
+ { name: "u_size", type: "float", value: new Float32Array([1.0]) },
21
+ { name: "u_minimum_size", type: "float", value: new Float32Array([1.0]) },
22
+ { name: "u_draw_mode", type: "int", value: new Int32Array([0]) }, // 0.0 for point, 1.0 for line
23
+ { name: "u_is_circle", type: "bool", value: new Float32Array([1.0]) },
24
+ { name: "u_dash_count", type: "float", value: new Float32Array([1.0]) },
25
+ { name: "u_dash_opacity_multiplier", type: "float", value: new Float32Array([1.0]) },
26
+ { name: "u_dash_phase", type: "float", value: new Float32Array([0.0]) },
27
+ ], uniformBindingPoints.flexible);
28
+ var vs = "#version 300 es\n".concat(geometrytransformations_1.R, "\n").concat(geometrytransformations_1.R_3D, "\n").concat(totems_1.CameraUniformBlockString, "\n").concat(geometrytransformations_1.mercatorXYToGLPosition, "\n").concat(geometrytransformations_1.cartesian3DToGLPosition, "\n\n").concat(uniformBlockManager.glslCode(), "\n\nprecision highp float;\nprecision highp int;\n\nin vec3 pos3D;\nin vec2 pos2D;\nin vec4 rgba;\nin float size;\n\n\nflat out highp int vVertexID;\n\nout vec4 v_rgba;\n\nout float v_length;\n\nvoid main() {\n \n v_rgba = (rgba.r == -1.0) ? u_rgba : rgba;\n v_rgba.a *= u_opacity;\n gl_PointSize = max(((size == -1.0) ? u_size : size) * u_size_multiplier, u_minimum_size);\n \n float size_fixer; \n if(is3D){\n gl_Position = cartesian3DToGLPosition(pos3D);\n size_fixer = smoothstep(0.15, 1.0, 0.5 * R_3D / gl_Position.w) ;\n } else {\n gl_Position = mercatorXYToGLPosition(pos2D);\n size_fixer = smoothstep(2.0, 5.2, z_level);\n }\n gl_PointSize *= size_fixer;\n switch (u_draw_mode) {\n case 0:\n vVertexID = gl_VertexID;\n break;\n case 1:\n v_length = float(gl_VertexID % 2);\n vVertexID = (gl_VertexID - gl_VertexID % 2) / 2; // a line takes two points\n break;\n default:\n break;\n }\n}");
29
+ var fs = "#version 300 es\nprecision highp float;\nprecision highp int;\n\n".concat(uniformBlockManager.glslCode(), "\n\nflat in highp int vVertexID;\n\nin vec4 v_rgba;\nin float v_length;\n\nlayout(location = 0) out vec4 fragColor;\nlayout(location = 1) out int vertexID;\n\nvoid main() {\n vertexID = vVertexID; \n fragColor = v_rgba;\n\n switch (u_draw_mode) {\n case 0:\n float d = distance(gl_PointCoord, vec2(0.5, 0.5));\n if (u_is_circle) {\n if (d > 0.5) discard;\n fragColor.a *= smoothstep(0.5, 0.45, d);\n }\n if (u_dash_opacity_multiplier < 1.0) {\n float dash = sin(d * 3.14159 * 2.0 * u_dash_count + u_dash_phase) * (1.0 - u_dash_opacity_multiplier) + u_dash_opacity_multiplier;\n fragColor.a *= dash;\n }\n break;\n case 1:\n if (u_dash_opacity_multiplier < 1.0 && fract((v_length + u_dash_phase) * u_dash_count) < 0.5) {\n fragColor.a *= u_dash_opacity_multiplier;\n }\n break;\n }\n}");
30
+ var PointOnGlobeProgram = /** @class */ (function () {
31
+ function PointOnGlobeProgram(globe) {
32
+ this.globe = globe;
33
+ this.gl = globe.gl;
34
+ this._isFreed = false;
35
+ this.program = (0, util_1.createProgram)(this.gl, vs, fs);
36
+ var _a = this, gl = _a.gl, program = _a.program;
37
+ // assign opacity
38
+ // assign attribute locations
39
+ gl.bindAttribLocation(program, 0, "pos3D");
40
+ gl.bindAttribLocation(program, 1, "pos2D");
41
+ gl.bindAttribLocation(program, 2, "rgba");
42
+ gl.bindAttribLocation(program, 3, "size");
43
+ // arrange camera uniform block
44
+ this.cameraBlockTotem = totems_1.CameraUniformBlockTotemCache.get(globe);
45
+ this.cameraBlockTotem.assignBindingPoint(program, uniformBindingPoints.camera);
46
+ uniformBlockManager.assignBindingPoint(this.gl, this.program);
47
+ this._defaultUBO = uniformBlockManager.createUBO(this.gl);
48
+ this._defaultUBO.update(new Map([
49
+ ["u_rgba", [1, 1, 1, 1]],
50
+ ["u_opacity", [1.0]],
51
+ ["u_size_multiplier", [1.0]],
52
+ ["u_size", [1.0]],
53
+ ["u_is_circle", [1.0]],
54
+ ]));
55
+ }
56
+ PointOnGlobeProgram.prototype.createUBO = function () {
57
+ var ubo = uniformBlockManager.createUBO(this.gl);
58
+ return ubo;
59
+ };
60
+ PointOnGlobeProgram.prototype.createVAO = function (pos3DBufferObj, pos2DBufferObj, rgbaBufferObj, sizeBufferObj) {
61
+ var gl = this.gl;
62
+ var vao = gl.createVertexArray();
63
+ gl.bindVertexArray(vao);
64
+ (0, attribute_loader_1.attributeLoader)(gl, pos3DBufferObj, 0, 3);
65
+ (0, attribute_loader_1.attributeLoader)(gl, pos2DBufferObj, 1, 2);
66
+ (0, attribute_loader_1.attributeLoader)(gl, rgbaBufferObj, 2, 4, { escapeValues: [-1, -1, -1, -1] });
67
+ (0, attribute_loader_1.attributeLoader)(gl, sizeBufferObj, 3, 1, { escapeValues: [-1] });
68
+ gl.bindVertexArray(null);
69
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
70
+ return vao;
71
+ };
72
+ /**
73
+ *
74
+ * @param {vertexArrayObject} vao
75
+ * @param {DrawRangeIndexParams} drawOptions
76
+ */
77
+ PointOnGlobeProgram.prototype.draw = function (vao, drawOptions, ubo) {
78
+ if (ubo === void 0) { ubo = null; }
79
+ var _a = this, gl = _a.gl, program = _a.program;
80
+ gl.useProgram(program);
81
+ gl.bindVertexArray(vao);
82
+ this.cameraBlockTotem.bind(uniformBindingPoints.camera);
83
+ ubo = ubo || this._defaultUBO;
84
+ ubo.bind();
85
+ (0, methods_1.drawArrays)(gl, gl.POINTS, drawOptions);
86
+ ubo.unbind();
87
+ this.cameraBlockTotem.unbind(uniformBindingPoints.camera);
88
+ gl.bindVertexArray(null);
89
+ };
90
+ PointOnGlobeProgram.prototype.free = function () {
91
+ if (this._isFreed)
92
+ return;
93
+ var _a = this, gl = _a.gl, globe = _a.globe;
94
+ totems_1.CameraUniformBlockTotemCache.release(globe);
95
+ gl.deleteProgram(this.program);
96
+ this._isFreed = true;
97
+ };
98
+ return PointOnGlobeProgram;
99
+ }());
100
+ var PickableRendererProgramCache = Object.freeze({
101
+ get: function (globe) { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, PointOnGlobeProgram); },
102
+ release: function (globe) { return programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, PointOnGlobeProgram); }
103
+ });
104
+ exports.PickableRendererProgramCache = PickableRendererProgramCache;