@pirireis/webglobeplugins 0.9.9 → 0.9.10

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 (211) hide show
  1. package/Math/angle-calculation.js +15 -0
  2. package/Math/arc.js +65 -0
  3. package/Math/bounds/line-bbox.js +188 -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 +56 -0
  14. package/Math/matrix4.js +1 -0
  15. package/Math/methods.js +201 -0
  16. package/Math/plane.js +60 -0
  17. package/Math/quaternion.js +104 -0
  18. package/Math/types.js +2 -0
  19. package/Math/utils.js +4 -0
  20. package/Math/vec3.js +126 -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 +18 -0
  24. package/altitude-locator/keymethod.js +1 -0
  25. package/altitude-locator/plugin.js +341 -0
  26. package/altitude-locator/types.js +23 -0
  27. package/arrowfield/adaptor.js +14 -0
  28. package/arrowfield/index.js +10 -0
  29. package/arrowfield/plugin.js +86 -0
  30. package/bearing-line/index.js +8 -0
  31. package/bearing-line/plugin.js +449 -0
  32. package/circle-line-chain/chain-list-map.js +205 -0
  33. package/circle-line-chain/init.js +1 -0
  34. package/circle-line-chain/plugin.js +424 -0
  35. package/circle-line-chain/util.js +5 -0
  36. package/compass-rose/compass-rose-padding-flat.js +225 -0
  37. package/compass-rose/compass-text-writer.js +153 -0
  38. package/compass-rose/index.js +7 -0
  39. package/compassrose/compassrose.js +296 -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 +202 -0
  44. package/heatwave/isobar/plugin.js +343 -0
  45. package/heatwave/isobar/quadtreecontours.js +300 -0
  46. package/heatwave/plugins/heatwaveglobeshell.js +206 -0
  47. package/jest.config.js +7 -0
  48. package/package.json +4 -4
  49. package/partialrings/buffer-manager.js +81 -0
  50. package/partialrings/index.js +41 -0
  51. package/partialrings/plugin.js +135 -0
  52. package/partialrings/program.js +286 -0
  53. package/pin/pin-object-array.js +305 -0
  54. package/pin/pin-point-totem.js +60 -0
  55. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +66 -0
  56. package/point-heat-map/index.js +1 -0
  57. package/point-heat-map/plugin-webworker.js +126 -0
  58. package/point-heat-map/point-to-heat-map-flow.js +127 -0
  59. package/point-tracks/key-methods.js +5 -0
  60. package/point-tracks/plugin.js +338 -0
  61. package/programs/arrowfield/index.js +7 -0
  62. package/programs/arrowfield/logic.js +257 -0
  63. package/programs/arrowfield/object.js +66 -0
  64. package/programs/data2legend/density-to-legend.js +101 -0
  65. package/programs/data2legend/point-to-density-texture.js +100 -0
  66. package/programs/float2legendwithratio/index.js +8 -0
  67. package/programs/float2legendwithratio/logic.js +171 -0
  68. package/programs/float2legendwithratio/object.js +110 -0
  69. package/programs/globe-util/is-globe-moved.js +21 -0
  70. package/programs/globeshell/index.js +8 -0
  71. package/programs/globeshell/noise/noises.js +1 -0
  72. package/programs/globeshell/wiggle/index.js +8 -0
  73. package/programs/globeshell/wiggle/logic.js +345 -0
  74. package/programs/globeshell/wiggle/object.js +72 -0
  75. package/programs/helpers/blender/index.js +1 -0
  76. package/programs/helpers/blender/program.js +79 -0
  77. package/programs/helpers/fadeaway/index.js +7 -0
  78. package/programs/helpers/fadeaway/logic.js +72 -0
  79. package/programs/helpers/fadeaway/object.js +20 -0
  80. package/programs/helpers/index.js +8 -0
  81. package/programs/index.js +58 -0
  82. package/programs/interface.js +1 -0
  83. package/programs/line-on-globe/angled-line.js +176 -0
  84. package/programs/line-on-globe/circle-accurate-3d.js +141 -0
  85. package/programs/line-on-globe/circle-accurate-flat.js +216 -0
  86. package/programs/line-on-globe/circle-accurate.js +178 -0
  87. package/programs/line-on-globe/circle.js +167 -0
  88. package/programs/line-on-globe/degree-padding-around-circle-3d.js +159 -0
  89. package/programs/line-on-globe/index.js +1 -0
  90. package/programs/line-on-globe/lines-color-instanced-flat.js +136 -0
  91. package/programs/line-on-globe/linestrip.js +171 -0
  92. package/programs/line-on-globe/naive-accurate-flexible.js +195 -0
  93. package/programs/line-on-globe/to-the-surface.js +111 -0
  94. package/programs/line-on-globe/util.js +8 -0
  95. package/programs/picking/pickable-renderer.js +188 -0
  96. package/programs/point-on-globe/element-globe-surface-glow.js +142 -0
  97. package/programs/point-on-globe/element-point-glow.js +153 -0
  98. package/programs/point-on-globe/square-pixel-point.js +174 -0
  99. package/programs/programcache.js +131 -0
  100. package/programs/rings/distancering/circleflatprogram.js +156 -0
  101. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +369 -0
  102. package/programs/rings/distancering/circlepaddysharedbuffer.js +357 -0
  103. package/programs/rings/distancering/index.js +14 -0
  104. package/programs/rings/distancering/paddyflatprogram.js +172 -0
  105. package/programs/rings/distancering/paddyflatprogram2d.js +174 -0
  106. package/programs/rings/distancering/paddyflatprogram3d.js +172 -0
  107. package/programs/rings/distancering/shader.js +1 -0
  108. package/programs/rings/index.js +17 -0
  109. package/programs/rings/partial-ring/piece-of-pie.js +275 -0
  110. package/programs/totems/camerauniformblock.js +160 -0
  111. package/programs/totems/canvas-webglobe-info.js +110 -0
  112. package/programs/totems/gpu-selection-uniform-block.js +108 -0
  113. package/programs/totems/index.js +40 -0
  114. package/programs/two-d/pixel-circle.js +1 -0
  115. package/programs/two-d/pixel-padding-for-compass.js +162 -0
  116. package/programs/util.js +17 -0
  117. package/programs/vectorfields/index.js +23 -0
  118. package/programs/vectorfields/logics/drawrectangleparticles.js +107 -0
  119. package/programs/vectorfields/logics/index.js +12 -0
  120. package/programs/vectorfields/logics/pixelbased.js +142 -0
  121. package/programs/vectorfields/logics/ubo.js +63 -0
  122. package/programs/vectorfields/pingpongbuffermanager.js +76 -0
  123. package/rangerings/enum.js +5 -0
  124. package/rangerings/index.js +15 -0
  125. package/rangerings/plugin.js +560 -0
  126. package/rangerings/rangeringangletext.js +329 -0
  127. package/rangerings/ring-account.js +117 -0
  128. package/shaders/fragment-toy/firework.js +58 -0
  129. package/shaders/fragment-toy/singularity.js +59 -0
  130. package/shape-on-terrain/arc/naive/plugin.js +252 -0
  131. package/timetracks/adaptors-line-strip.js +71 -0
  132. package/timetracks/adaptors.js +122 -0
  133. package/timetracks/index.js +19 -0
  134. package/timetracks/plugin-line-strip.js +250 -0
  135. package/timetracks/plugin.js +258 -0
  136. package/timetracks/program-line-strip.js +611 -0
  137. package/timetracks/program.js +772 -0
  138. package/timetracks/programpoint-line-strip.js +154 -0
  139. package/timetracks/programpoint.js +147 -0
  140. package/types.js +15 -0
  141. package/util/account/bufferoffsetmanager.js +179 -0
  142. package/util/account/index.js +23 -0
  143. package/util/account/single-attribute-buffer-management/buffer-manager.js +108 -0
  144. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +150 -0
  145. package/util/account/single-attribute-buffer-management/index.js +9 -0
  146. package/util/account/single-attribute-buffer-management/object-store.js +51 -0
  147. package/util/account/single-attribute-buffer-management/types.js +2 -0
  148. package/util/account/util.js +22 -0
  149. package/util/algorithms/index.js +1 -0
  150. package/util/algorithms/search-binary.js +28 -0
  151. package/util/check/get.js +18 -0
  152. package/util/check/index.js +1 -0
  153. package/util/check/typecheck.js +49 -0
  154. package/util/geometry/index.js +51 -0
  155. package/util/gl-util/buffer/attribute-loader.js +69 -0
  156. package/util/gl-util/buffer/index.js +6 -0
  157. package/util/gl-util/buffer/types.js +1 -0
  158. package/util/gl-util/draw-options/methods.js +38 -0
  159. package/util/gl-util/draw-options/types.js +15 -0
  160. package/util/gl-util/uniform-block/manager.js +156 -0
  161. package/util/gl-util/uniform-block/shader.js +1 -0
  162. package/util/gl-util/uniform-block/types.js +8 -0
  163. package/util/heatwavedatamanager/datamanager.js +152 -0
  164. package/util/heatwavedatamanager/index.js +10 -0
  165. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +122 -0
  166. package/util/heatwavedatamanager/pointcoordsmeta.js +20 -0
  167. package/util/index.js +57 -0
  168. package/util/interpolation/index.js +1 -0
  169. package/util/interpolation/timetrack/index.js +5 -0
  170. package/util/interpolation/timetrack/timetrack-interpolator.js +79 -0
  171. package/util/interpolation/timetrack/web-worker-str.js +183 -0
  172. package/util/interpolation/timetrack/web-worker.js +48 -0
  173. package/util/jshelpers/data-filler.js +20 -0
  174. package/util/jshelpers/equality.js +20 -0
  175. package/util/jshelpers/index.js +37 -0
  176. package/util/jshelpers/timefilters.js +32 -0
  177. package/util/picking/fence.js +46 -0
  178. package/util/picking/picker-displayer.js +139 -0
  179. package/util/programs/draw-texture-on-canvas.js +89 -0
  180. package/util/programs/index.js +17 -0
  181. package/util/programs/shapesonglobe.js +214 -0
  182. package/util/programs/supersampletotextures.js +113 -0
  183. package/util/programs/texturetoglobe.js +182 -0
  184. package/util/shaderfunctions/geometrytransformations.js +340 -0
  185. package/util/shaderfunctions/index.js +18 -0
  186. package/util/shaderfunctions/nodata.js +11 -0
  187. package/util/shaderfunctions/noisefunctions.js +43 -0
  188. package/util/surface-line-data/arc-bboxes.js +25 -0
  189. package/util/surface-line-data/arcs-to-cuts.js +50 -0
  190. package/util/surface-line-data/cut-arc.js +1 -0
  191. package/util/surface-line-data/flow.js +28 -0
  192. package/util/surface-line-data/rbush-manager.js +1 -0
  193. package/util/surface-line-data/types.js +1 -0
  194. package/util/surface-line-data/web-worker.js +1 -0
  195. package/util/webglobe/gldefaultstates.js +7 -0
  196. package/util/webglobe/index.js +18 -0
  197. package/util/webglobe/rasteroverlay.js +78 -0
  198. package/util/webglobjectbuilders.js +388 -0
  199. package/util/webglobjectbuilders1.js +237 -0
  200. package/waveparticles/adaptor.js +17 -0
  201. package/waveparticles/index.js +10 -0
  202. package/waveparticles/plugin.js +266 -0
  203. package/wind/imagetovectorfieldandmagnitude.js +35 -0
  204. package/wind/index.js +14 -0
  205. package/wind/plugin.js +926 -0
  206. package/wind/vectorfieldimage.js +25 -0
  207. package/write-text/attached-text-writer.js +91 -0
  208. package/write-text/context-text.js +98 -0
  209. package/write-text/context-text3.js +155 -0
  210. package/write-text/index.js +5 -0
  211. package/write-text/writer-plugin.js +8 -0
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PaddingProgramCache = void 0;
37
+ const util_1 = require("../../../util");
38
+ const camerauniformblock_1 = __importStar(require("../../totems/camerauniformblock"));
39
+ const programcache_1 = require("../../programcache");
40
+ const vertexShader = `#version 300 es ` +
41
+ util_1.shaderfunctions.PI +
42
+ util_1.shaderfunctions.R +
43
+ util_1.shaderfunctions.POLE +
44
+ camerauniformblock_1.CameraUniformBlockString +
45
+ util_1.shaderfunctions.mercatorXYToGLPosition +
46
+ util_1.shaderfunctions.longLatRadToMercator +
47
+ util_1.shaderfunctions.longLatRadToCartesian3D +
48
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
49
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
50
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
51
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
52
+
53
+ in vec2 center;
54
+ in float radius;
55
+ in float pad_range;
56
+ in vec4 color;
57
+ in float flag;
58
+
59
+ uniform int compass;
60
+ uniform float pad_count;
61
+
62
+ uniform float opacity;
63
+
64
+
65
+ out vec2 v_limp;
66
+ out vec4 v_color;
67
+
68
+
69
+ void main() {
70
+
71
+ float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
72
+ if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
73
+ v_color = vec4(color.rgb, color.a * alpha_padding * opacity);
74
+
75
+ gl_PointSize = 2.0;
76
+
77
+ float odd = mod(float(gl_VertexID), 2.0);
78
+ float index = (float(gl_VertexID)- odd ) / 2.0;
79
+ float angle = 3.1415926535897932384626433832795 * 2.0 * (index / pad_count );
80
+ float radius_ = radius - (pad_range * odd);
81
+
82
+ if ( is3D){
83
+ gl_Position = projection * view * vec4(
84
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
85
+ v_limp = vec2(0.0, 0.0);
86
+ return;
87
+ }
88
+ vec2 limp;
89
+ if ( compass == 1 ){
90
+ limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
91
+ } else {
92
+ // limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
93
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
94
+ }
95
+ v_limp = limp;
96
+ gl_Position = mercatorXYToGLPosition(limp);
97
+ }`;
98
+ const fragmentShader = `#version 300 es
99
+ precision highp float; ` +
100
+ util_1.shaderfunctions.POLE + `
101
+ in vec4 v_color;
102
+ in vec2 v_limp;
103
+ out vec4 outColor;
104
+ void main() {
105
+ if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
106
+ outColor = v_color;
107
+ }`;
108
+ class Logic {
109
+ constructor(globe) {
110
+ this.globe = globe;
111
+ this.gl = globe.gl;
112
+ this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
113
+ { // bind positions so bufferManager can use them
114
+ this.gl.bindAttribLocation(this.program, 0, "center");
115
+ this.gl.bindAttribLocation(this.program, 1, "radius");
116
+ this.gl.bindAttribLocation(this.program, 2, "pad_range");
117
+ this.gl.bindAttribLocation(this.program, 3, "color");
118
+ this.gl.bindAttribLocation(this.program, 4, "flag");
119
+ }
120
+ this.cameraBlockBindingPoint = 0;
121
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
122
+ this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
123
+ this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, camerauniformblock_1.default);
124
+ this._padCountLocation = this.gl.getUniformLocation(this.program, "pad_count");
125
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
126
+ this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
127
+ this._compassMode = 1;
128
+ this._opacity = 1.0;
129
+ this._padCount = 360;
130
+ {
131
+ const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
132
+ this.gl.useProgram(this.program);
133
+ this.gl.uniform1i(this._compassLocation, 1);
134
+ this.gl.uniform1f(this._opacityLocation, 1.0);
135
+ this.gl.uniform1f(this._padCountLocation, 360);
136
+ this.gl.useProgram(currentProgram);
137
+ }
138
+ }
139
+ draw(vao, length, opaity) {
140
+ }
141
+ draw(attrBufferManager, padCount, compass, opacity) {
142
+ const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
143
+ gl.useProgram(program);
144
+ attrBufferManager.bindPaddingVAO();
145
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
146
+ // draw instanced
147
+ if (padCount !== this._padCount) {
148
+ this._padCount = padCount;
149
+ // console.log("padCount", padCount);
150
+ gl.uniform1f(_padCountLocation, padCount);
151
+ }
152
+ if (compass !== this._compassMode) {
153
+ // console.log("compass", compass);
154
+ gl.uniform1i(_compassLocation, compass);
155
+ this._compassMode = compass;
156
+ }
157
+ if (opacity !== this._opacity) {
158
+ // console.log("opacity", opacity);
159
+ this._opacity = opacity;
160
+ gl.uniform1f(this._opacityLocation, opacity);
161
+ }
162
+ gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
163
+ gl.bindVertexArray(null);
164
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
165
+ }
166
+ free() {
167
+ this.gl.deleteProgram(this.program);
168
+ programcache_1.globeProgramCache.releaseProgram(this.globe, camerauniformblock_1.default);
169
+ }
170
+ }
171
+ exports.PaddingProgramCache = Object.freeze({
172
+ getProgram: (globe) => { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
173
+ releaseProgram: (globe) => { programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
174
+ });
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.PaddingProgramCache = void 0;
37
+ const util_1 = require("../../../util");
38
+ const camerauniformblock_1 = __importStar(require("../../totems/camerauniformblock"));
39
+ const programcache_1 = require("../../programcache");
40
+ const vertexShader = `#version 300 es ` +
41
+ util_1.shaderfunctions.PI +
42
+ util_1.shaderfunctions.R +
43
+ util_1.shaderfunctions.POLE +
44
+ camerauniformblock_1.CameraUniformBlockString +
45
+ util_1.shaderfunctions.mercatorXYToGLPosition +
46
+ util_1.shaderfunctions.longLatRadToMercator +
47
+ util_1.shaderfunctions.longLatRadToCartesian3D +
48
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterCartesian3D +
49
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorCompass +
50
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistancePadding +
51
+ util_1.shaderfunctions.circleLimpFromLongLatRadCenterMercatorRealDistance + `
52
+
53
+ in vec2 center;
54
+ in float radius;
55
+ in float pad_range;
56
+ in vec4 color;
57
+ in float flag;
58
+
59
+ uniform int compass;
60
+ uniform float pad_count;
61
+
62
+ uniform float opacity;
63
+
64
+
65
+ out vec2 v_limp;
66
+ out vec4 v_color;
67
+
68
+
69
+ void main() {
70
+
71
+ float alpha_padding = z_level * z_level / (pad_range/ 100.0 );
72
+ if( flag == 2.0 || flag == 1.0 || radius == 0.0 || alpha_padding < 0.1 || z_level < 3.0 ) return; // 1.0 is hide
73
+ v_color = vec4(color.rgb, color.a * alpha_padding * opacity);
74
+
75
+ gl_PointSize = 2.0;
76
+
77
+ float odd = mod(float(gl_VertexID), 2.0);
78
+ float index = (float(gl_VertexID)- odd ) / 2.0;
79
+ float angle = 3.1415926535897932384626433832795 * 2.0 * (index / pad_count );
80
+ float radius_ = radius - (pad_range * odd);
81
+
82
+ if ( is3D){
83
+ gl_Position = projection * view * vec4(
84
+ circleLimpFromLongLatRadCenterCartesian3D( center, radius_, angle) - translate, 1.0);
85
+ v_limp = vec2(0.0, 0.0);
86
+ return;
87
+ }
88
+ vec2 limp;
89
+ if ( compass == 1 ){
90
+ limp = circleLimpFromLongLatRadCenterMercatorCompass(center , radius_, angle);
91
+ } else {
92
+ // limp = circleLimpFromLongLatRadCenterMercatorRealDistancePadding(center, radius_, angle);
93
+ limp = circleLimpFromLongLatRadCenterMercatorRealDistance(center, radius_, angle);
94
+ }
95
+ v_limp = limp;
96
+ gl_Position = mercatorXYToGLPosition(limp);
97
+ }`;
98
+ const fragmentShader = `#version 300 es
99
+ precision highp float; ` +
100
+ util_1.shaderfunctions.POLE + `
101
+ in vec4 v_color;
102
+ in vec2 v_limp;
103
+ out vec4 outColor;
104
+ void main() {
105
+ if ( v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE ){ discard; }
106
+ outColor = v_color;
107
+ }`;
108
+ class Logic {
109
+ constructor(globe) {
110
+ this.globe = globe;
111
+ this.gl = globe.gl;
112
+ this.program = (0, util_1.createProgram)(this.gl, vertexShader, fragmentShader);
113
+ { // bind positions so bufferManager can use them
114
+ this.gl.bindAttribLocation(this.program, 0, "center");
115
+ this.gl.bindAttribLocation(this.program, 1, "radius");
116
+ this.gl.bindAttribLocation(this.program, 2, "pad_range");
117
+ this.gl.bindAttribLocation(this.program, 3, "color");
118
+ this.gl.bindAttribLocation(this.program, 4, "flag");
119
+ }
120
+ this.cameraBlockBindingPoint = 0;
121
+ const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
122
+ this.gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
123
+ this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, camerauniformblock_1.default);
124
+ this._padCountLocation = this.gl.getUniformLocation(this.program, "pad_count");
125
+ this._opacityLocation = this.gl.getUniformLocation(this.program, "opacity");
126
+ this._compassLocation = this.gl.getUniformLocation(this.program, "compass");
127
+ this._compassMode = 1;
128
+ this._opacity = 1.0;
129
+ this._padCount = 360;
130
+ {
131
+ const currentProgram = this.gl.getParameter(this.gl.CURRENT_PROGRAM);
132
+ this.gl.useProgram(this.program);
133
+ this.gl.uniform1i(this._compassLocation, 1);
134
+ this.gl.uniform1f(this._opacityLocation, 1.0);
135
+ this.gl.uniform1f(this._padCountLocation, 360);
136
+ this.gl.useProgram(currentProgram);
137
+ }
138
+ }
139
+ draw(attrBufferManager, padCount, compass, opacity) {
140
+ const { gl, program, _padCountLocation, cameraBlockBindingPoint, cameraBlockTotem, _compassLocation } = this;
141
+ gl.useProgram(program);
142
+ attrBufferManager.bindPaddingVAO();
143
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
144
+ // draw instanced
145
+ if (padCount !== this._padCount) {
146
+ this._padCount = padCount;
147
+ // console.log("padCount", padCount);
148
+ gl.uniform1f(_padCountLocation, padCount);
149
+ }
150
+ if (compass !== this._compassMode) {
151
+ // console.log("compass", compass);
152
+ gl.uniform1i(_compassLocation, compass);
153
+ this._compassMode = compass;
154
+ }
155
+ if (opacity !== this._opacity) {
156
+ // console.log("opacity", opacity);
157
+ this._opacity = opacity;
158
+ gl.uniform1f(this._opacityLocation, opacity);
159
+ }
160
+ gl.drawArraysInstanced(gl.LINES, 0, padCount * 2, attrBufferManager.length);
161
+ gl.bindVertexArray(null);
162
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
163
+ }
164
+ free() {
165
+ this.gl.deleteProgram(this.program);
166
+ programcache_1.globeProgramCache.releaseProgram(this.globe, camerauniformblock_1.default);
167
+ }
168
+ }
169
+ exports.PaddingProgramCache = Object.freeze({
170
+ getProgram: (globe) => { return programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic); },
171
+ releaseProgram: (globe) => { programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic); }
172
+ });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./distancering"), exports);
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PieceOfPieProgramCache = exports.Logic = exports.ITEM_SIZE = void 0;
4
+ const util_1 = require("../../../util");
5
+ const totems_1 = require("../../totems");
6
+ const programcache_1 = require("../../programcache");
7
+ const geometrytransformations_1 = require("../../../util/shaderfunctions/geometrytransformations");
8
+ /**
9
+ * TODO:
10
+ * 1. Triangle face looks at screen. if rotation angle is positive the last vertex must be the faintest.
11
+ *
12
+ */
13
+ const drawModeMap = Object.freeze({
14
+ LINE_STRIP: 0,
15
+ TRIANGLE_FAN: 1,
16
+ });
17
+ //${ circleLimpFromLongLatRadCenterMercatorRealDistanceNew_accurate }
18
+ const vertexShaderSource = `#version 300 es
19
+
20
+ ${totems_1.CameraUniformBlockString}
21
+ ${geometrytransformations_1.PI}
22
+ ${geometrytransformations_1.longLatRadToMercator}
23
+ ${geometrytransformations_1.mercatorXYToGLPosition}
24
+ ${geometrytransformations_1.longLatRadToCartesian3D}
25
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterCartesian3D_accurate}
26
+ ${geometrytransformations_1.circleLimpFromLongLatRadCenterMercatorCompass_accurate}
27
+ ${geometrytransformations_1.cartesian3DToGLPosition}
28
+
29
+ uniform float edge_count;
30
+ uniform int draw_mode; // %2 => 0: LINE_STRIP, 1: TRIANGLE_FAN
31
+ uniform float plugin_alpha_multiplier;
32
+ //, lat, startAngle, tailAngle, ...rgba, radius, rgbaMode
33
+ // in vec2 center; // long, lat in radian
34
+ in vec2 center2d;
35
+ in vec3 center3d;
36
+ in float start_angle2d;
37
+ in float tail_angle2d;
38
+
39
+ in float start_angle3d;
40
+ in float tail_angle3d;
41
+
42
+ in vec4 color;
43
+ in float radius; // in meter
44
+ in float color_mode; // 0.0: constant, 1.0: fading, 2.0: hide
45
+ // flat out int vid;
46
+ // flat out float v_phase;
47
+ out vec2 v_pos;
48
+ out vec4 v_color;
49
+ // flat out float v_angle;
50
+
51
+ void main() {
52
+ // vid = gl_VertexID;
53
+ if (color_mode == 2.0 || radius == 0.0) { return; }
54
+ float start_angle, tail_angle;
55
+ if (is3D) {
56
+ start_angle = start_angle3d;
57
+ tail_angle = tail_angle3d;
58
+ } else {
59
+ start_angle = start_angle2d;
60
+ tail_angle = tail_angle2d;
61
+ }
62
+ float color_mode_ = color_mode;
63
+ if ( draw_mode == 0 && color_mode == 1.0) {color_mode_ = 0.0;}
64
+ float vertexID = float(gl_VertexID);
65
+ float radius_ = radius;
66
+ float alpha = plugin_alpha_multiplier;
67
+ if (draw_mode == 1) { // TRIANGLE_FAN
68
+ if (gl_VertexID == 0) {
69
+ radius_ = 0.0;
70
+ if ( color_mode == 1.0 ) { alpha = 0.0; }
71
+ }
72
+ vertexID -= 1.0;
73
+ }
74
+ float phase = ( vertexID / (edge_count - 1.0) );
75
+ // v_angle = tail_angle;
76
+
77
+ if ( color_mode_ == 1.0 ) {
78
+ if ( tail_angle < 0.0 ) {
79
+ v_color = vec4( color.rgb , color.a * ( 1.0 - phase ) * alpha );
80
+ } else {
81
+ v_color = vec4( color.rgb , color.a * phase * alpha );
82
+ }
83
+ } else {
84
+ v_color = vec4( color.rgb , color.a * alpha );
85
+ }
86
+ if ( color_mode == 0.0 && draw_mode == 1 ) {
87
+ v_color.a /= 2.0;
88
+ }
89
+ float angle;
90
+ if ( tail_angle > 0.0 ) {
91
+ angle = tail_angle * (-phase + 1.0) + start_angle;
92
+ } else {
93
+ angle = tail_angle * phase + start_angle;
94
+ }
95
+ if (is3D) {
96
+ vec3 pos = circleLimpFromLongLatRadCenterCartesian3D_accurate(center3d, radius_, angle);
97
+ v_pos = vec2(0.0, 0.0);
98
+ gl_Position = cartesian3DToGLPosition(pos);
99
+ }
100
+ else {
101
+ vec2 pos2 = circleLimpFromLongLatRadCenterMercatorCompass_accurate(center2d, radius_, angle);
102
+ v_pos = pos2;
103
+ gl_Position = mercatorXYToGLPosition(pos2);
104
+ }
105
+
106
+ gl_PointSize = 10.0;
107
+ }`;
108
+ const fragmentShaderSource = `#version 300 es` + geometrytransformations_1.POLE + geometrytransformations_1.PI + `
109
+ precision highp float;
110
+ // flat in int vid;
111
+ in vec4 v_color;
112
+ in vec2 v_pos;
113
+ // flat in float v_phase;
114
+ // in float v_angle;
115
+ out vec4 outColor;
116
+ void main() {
117
+ // if( vid % 2 == 0 ) { discard; }
118
+ // if ( mod(v_angle, PI / 36.0 ) < (PI / 72.0)) { discard; }
119
+ // if ( mod(v_angle * v_phase, PI / 90.0 ) < (PI / 180.0)) { discard; }
120
+ if ( v_pos.x < -POLE || v_pos.x > POLE || v_pos.y < -POLE || v_pos.y > POLE ) { discard; }
121
+ outColor = v_color;
122
+ }`;
123
+ exports.ITEM_SIZE = 10;
124
+ class Logic {
125
+ constructor(globe) {
126
+ this.globe = globe;
127
+ this.gl = globe.gl;
128
+ this._lastMode = 0;
129
+ this._lastEdgeCount = 64;
130
+ this._lastAlphaMultiplier = 1.0;
131
+ this.program = (0, util_1.createProgram)(this.gl, vertexShaderSource, fragmentShaderSource);
132
+ const { gl, program } = this;
133
+ { // set attributes locations
134
+ gl.bindAttribLocation(program, 0, 'center2d');
135
+ gl.bindAttribLocation(program, 1, 'center3d');
136
+ gl.bindAttribLocation(program, 2, 'start_angle2d');
137
+ gl.bindAttribLocation(program, 3, 'tail_angle2d');
138
+ gl.bindAttribLocation(program, 4, 'start_angle3d');
139
+ gl.bindAttribLocation(program, 5, 'tail_angle3d');
140
+ gl.bindAttribLocation(program, 6, 'color');
141
+ gl.bindAttribLocation(program, 7, 'radius');
142
+ gl.bindAttribLocation(program, 8, 'color_mode');
143
+ // vao
144
+ // instanced draw read 1
145
+ }
146
+ { // Uniforms
147
+ this._edgeCountLocation = gl.getUniformLocation(program, 'edge_count');
148
+ this._draw_modeLocation = gl.getUniformLocation(program, 'draw_mode');
149
+ this._plugin_alpha_multiplierLocation = gl.getUniformLocation(program, 'plugin_alpha_multiplier');
150
+ const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
151
+ gl.useProgram(program);
152
+ gl.uniform1i(this._draw_modeLocation, this._lastMode);
153
+ gl.uniform1f(this._edgeCountLocation, this._lastEdgeCount);
154
+ gl.uniform1f(this._plugin_alpha_multiplierLocation, 1.0);
155
+ this.cameraBlockBindingPoint = 0;
156
+ this.cameraBlockTotem = programcache_1.globeProgramCache.getProgram(globe, totems_1.CameraUniformBlockTotem);
157
+ const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraUniformBlock");
158
+ gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
159
+ gl.useProgram(currentProgram);
160
+ }
161
+ }
162
+ draw(length, vao, edgeCount, alphaMultiplier, drawMode) {
163
+ const { gl, program, cameraBlockTotem, cameraBlockBindingPoint } = this;
164
+ // gl.disable(gl.DEPTH_TEST);
165
+ gl.useProgram(program);
166
+ if (drawMode !== this._lastMode) {
167
+ gl.uniform1i(this._draw_modeLocation, drawModeMap[drawMode]);
168
+ this._lastMode = drawMode;
169
+ }
170
+ if (edgeCount !== this._lastEdgeCount) {
171
+ gl.uniform1f(this._edgeCountLocation, edgeCount);
172
+ this._lastEdgeCount = edgeCount;
173
+ }
174
+ if (alphaMultiplier !== this._lastAlphaMultiplier) {
175
+ gl.uniform1f(this._plugin_alpha_multiplierLocation, alphaMultiplier);
176
+ this._lastAlphaMultiplier = alphaMultiplier;
177
+ }
178
+ const overdraw = drawModeMap[drawMode];
179
+ cameraBlockTotem.bind(cameraBlockBindingPoint);
180
+ gl.bindVertexArray(vao);
181
+ gl.drawArraysInstanced(gl[drawMode], 0, edgeCount + overdraw, length);
182
+ cameraBlockTotem.unbind(cameraBlockBindingPoint);
183
+ gl.bindVertexArray(null);
184
+ // gl.enable(gl.DEPTH_TEST);
185
+ }
186
+ free() {
187
+ programcache_1.noRegisterGlobeProgramCache.releaseProgram(this.globe, totems_1.CameraUniformBlockTotem);
188
+ this.gl.deleteProgram(this.program);
189
+ this.program = null;
190
+ }
191
+ /**
192
+ * in vec2 center; // long, lat in radian
193
+ in float start_angle; // the start of partial circle from bearing point
194
+ in float tail_angle; // the rotation of the partial circle
195
+ in vec4 color;
196
+ in float radius; // in meter
197
+ in float color_mode; // 0.0: constant, 1.0: fading, 2.0: hide
198
+ */
199
+ createVAO(center2dObj, center3dObj, startAngle2DObj, tailAngle2DObj, startAngle3DObj, tailAngle3DObj, colorObj, radiusObj, colorModeObj) {
200
+ const { gl } = this;
201
+ const vao = gl.createVertexArray();
202
+ gl.bindVertexArray(vao);
203
+ {
204
+ const { buffer, stride, offset } = center2dObj;
205
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
206
+ gl.enableVertexAttribArray(0);
207
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
208
+ gl.vertexAttribDivisor(0, 1);
209
+ }
210
+ {
211
+ const { buffer, stride, offset } = center3dObj;
212
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
213
+ gl.enableVertexAttribArray(1);
214
+ gl.vertexAttribPointer(1, 3, gl.FLOAT, false, stride, offset);
215
+ gl.vertexAttribDivisor(1, 1);
216
+ }
217
+ {
218
+ const { buffer, stride, offset } = startAngle2DObj;
219
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
220
+ gl.enableVertexAttribArray(2);
221
+ gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
222
+ gl.vertexAttribDivisor(2, 1);
223
+ }
224
+ {
225
+ const { buffer, stride, offset } = tailAngle2DObj;
226
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
227
+ gl.enableVertexAttribArray(3);
228
+ gl.vertexAttribPointer(3, 1, gl.FLOAT, false, stride, offset);
229
+ gl.vertexAttribDivisor(3, 1);
230
+ }
231
+ {
232
+ const { buffer, stride, offset } = startAngle3DObj;
233
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
234
+ gl.enableVertexAttribArray(4);
235
+ gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
236
+ gl.vertexAttribDivisor(4, 1);
237
+ }
238
+ {
239
+ const { buffer, stride, offset } = tailAngle3DObj;
240
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
241
+ gl.enableVertexAttribArray(5);
242
+ gl.vertexAttribPointer(5, 1, gl.FLOAT, false, stride, offset);
243
+ gl.vertexAttribDivisor(5, 1);
244
+ }
245
+ {
246
+ const { buffer, stride, offset } = colorObj;
247
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
248
+ gl.enableVertexAttribArray(6);
249
+ gl.vertexAttribPointer(6, 4, gl.FLOAT, false, stride, offset);
250
+ gl.vertexAttribDivisor(6, 1);
251
+ }
252
+ {
253
+ const { buffer, stride, offset } = radiusObj;
254
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
255
+ gl.enableVertexAttribArray(7);
256
+ gl.vertexAttribPointer(7, 1, gl.FLOAT, false, stride, offset);
257
+ gl.vertexAttribDivisor(7, 1);
258
+ }
259
+ {
260
+ const { buffer, stride, offset } = colorModeObj;
261
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
262
+ gl.enableVertexAttribArray(8);
263
+ gl.vertexAttribPointer(8, 1, gl.FLOAT, false, stride, offset);
264
+ gl.vertexAttribDivisor(8, 1);
265
+ }
266
+ gl.bindVertexArray(null);
267
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
268
+ return vao;
269
+ }
270
+ }
271
+ exports.Logic = Logic;
272
+ exports.PieceOfPieProgramCache = Object.freeze({
273
+ get: (globe) => programcache_1.noRegisterGlobeProgramCache.getProgram(globe, Logic),
274
+ release: (globe) => programcache_1.noRegisterGlobeProgramCache.releaseProgram(globe, Logic)
275
+ });