@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,357 @@
1
+ "use strict";
2
+ /**
3
+ * ring data model
4
+ * [centerX, centerY, range, padding, r, g, b, a, hide]
5
+ *
6
+ * Buffer is initialized with ring capacity and buffer is created with that capacity. It might be called buffer orphaning.
7
+ *
8
+ * */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ /**
11
+ * TODO
12
+ * delete registerCenter
13
+ *
14
+ *
15
+ */
16
+ const RING_SIZE = 9;
17
+ class default_1 {
18
+ /**
19
+ * @param {WebGL2RenderingContext} gl
20
+ * @param {Object} options
21
+ * @param {Number} options.initialRingCapacity
22
+ * @param {String} options.bufferType - "static" or "dynamic"
23
+ * */
24
+ constructor(gl, globe, { initialRingCapacity = 20, bufferType = "STATIC_DRAW", implicitExtentionRate = 1.2 } = {}) {
25
+ this.gl = gl;
26
+ this.globe = globe;
27
+ this._capacity = initialRingCapacity;
28
+ this._ringCounter = 0;
29
+ this._length = 0;
30
+ this._centerMap = new Map(); // key, new MAP(x,y, rings:[])
31
+ this._ringOffsets = new Map();
32
+ this._removedRingsOffsetStack = [];
33
+ this._bufferType = gl[bufferType.toUpperCase()];
34
+ this.implicitExtentionRate = implicitExtentionRate;
35
+ this.buffer = gl.createBuffer();
36
+ { // initilize data
37
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
38
+ gl.bufferData(gl.ARRAY_BUFFER, initialRingCapacity * 4 * RING_SIZE, this._bufferType);
39
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
40
+ }
41
+ {
42
+ this._circleVAO = gl.createVertexArray();
43
+ gl.bindVertexArray(this._circleVAO);
44
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
45
+ gl.enableVertexAttribArray(0);
46
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
47
+ gl.enableVertexAttribArray(1);
48
+ gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
49
+ gl.enableVertexAttribArray(2);
50
+ gl.vertexAttribPointer(2, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
51
+ gl.enableVertexAttribArray(3);
52
+ gl.vertexAttribPointer(3, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
53
+ // set divisors to 1
54
+ gl.vertexAttribDivisor(0, 1);
55
+ gl.vertexAttribDivisor(1, 1);
56
+ gl.vertexAttribDivisor(2, 1);
57
+ gl.vertexAttribDivisor(3, 1);
58
+ gl.bindVertexArray(null);
59
+ }
60
+ {
61
+ this._paddingVAO = gl.createVertexArray();
62
+ gl.bindVertexArray(this._paddingVAO);
63
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
64
+ gl.enableVertexAttribArray(0);
65
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, RING_SIZE * 4, 0);
66
+ gl.enableVertexAttribArray(1);
67
+ gl.vertexAttribPointer(1, 1, gl.FLOAT, false, RING_SIZE * 4, 2 * 4);
68
+ gl.enableVertexAttribArray(2);
69
+ gl.vertexAttribPointer(2, 1, gl.FLOAT, false, RING_SIZE * 4, 3 * 4);
70
+ gl.enableVertexAttribArray(3);
71
+ gl.vertexAttribPointer(3, 4, gl.FLOAT, false, RING_SIZE * 4, 4 * 4);
72
+ gl.enableVertexAttribArray(4);
73
+ gl.vertexAttribPointer(4, 3, gl.FLOAT, false, RING_SIZE * 4, 8 * 4);
74
+ gl.vertexAttribDivisor(0, 1);
75
+ gl.vertexAttribDivisor(1, 1);
76
+ gl.vertexAttribDivisor(2, 1);
77
+ gl.vertexAttribDivisor(3, 1);
78
+ gl.vertexAttribDivisor(4, 1);
79
+ gl.bindVertexArray(null);
80
+ }
81
+ }
82
+ /**
83
+ * @param {String} centerID
84
+ * @param {Object} options
85
+ * @param {Number} options.x
86
+ * @param {Number} options.y
87
+ * */
88
+ registerCenter(centerID, { x = 0, y = 0 } = {}) {
89
+ this._centerMap.set(centerID, new Map([
90
+ ["x", x],
91
+ ["y", y],
92
+ ["rings", []] // ring keys
93
+ ]));
94
+ }
95
+ /**
96
+ *
97
+ * @param {null | number} newCapacity if null, vacuum defragmentation is applied -> capacity is set to the current ring count
98
+ */
99
+ defrag(newCapacity = null) {
100
+ const { _removedRingsOffsetStack, _ringOffsets } = this;
101
+ _removedRingsOffsetStack.sort();
102
+ this._capacity = newCapacity || this._ringCounter;
103
+ const arrayToLoad = new Float32Array(this._capacity * RING_SIZE);
104
+ const bufferData = this._getBufferData();
105
+ let arrayOffset = 0;
106
+ const newRingOffsets = new Map();
107
+ for (const [key, offset] of _ringOffsets) {
108
+ const ringOffset = offset / 4;
109
+ const ringData = bufferData.slice(ringOffset, ringOffset + RING_SIZE);
110
+ arrayToLoad.set(ringData, arrayOffset);
111
+ newRingOffsets.set(key, arrayOffset * 4);
112
+ arrayOffset += RING_SIZE;
113
+ }
114
+ const { gl, buffer } = this;
115
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
116
+ gl.bufferData(gl.ARRAY_BUFFER, arrayToLoad, this._bufferType);
117
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
118
+ this._ringOffsets = newRingOffsets;
119
+ this._removedRingsOffsetStack = [];
120
+ this._length = this._ringCounter;
121
+ }
122
+ extendBuffer(newCapacity) {
123
+ if (this._capacity >= newCapacity) {
124
+ console.warn("New capacity is smaller than the current capacity");
125
+ return;
126
+ }
127
+ this._capacity = newCapacity;
128
+ const { gl, buffer } = this;
129
+ const bufferData = this._getBufferData();
130
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
131
+ gl.bufferData(gl.ARRAY_BUFFER, newCapacity * RING_SIZE * 4, this._bufferType);
132
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
133
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
134
+ }
135
+ checkCapacity(sizeLeft = 1) {
136
+ return sizeLeft <= this._capacity - this._ringCounter;
137
+ }
138
+ capacityLeft() {
139
+ return this._capacity - this._ringCounter;
140
+ }
141
+ get capacity() {
142
+ return this._capacity;
143
+ }
144
+ get length() {
145
+ return this._length;
146
+ }
147
+ get ringCount() {
148
+ return this._ringCounter;
149
+ }
150
+ /**
151
+ * @param {Array<string>} centerIDs
152
+ * */
153
+ removeCenters(centerIDs) {
154
+ const { gl, buffer } = this;
155
+ const zero = new Float32Array([0]);
156
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
157
+ for (let centerID of centerIDs) {
158
+ if (!this._centerMap.has(centerID)) {
159
+ // console.warn("Center is not registered yet");
160
+ // return;
161
+ continue;
162
+ }
163
+ const center = this._centerMap.get(centerID);
164
+ const rings = center.get("rings");
165
+ for (let i = 0; i < rings.length; i++) {
166
+ // set range to 0, 3rd index of float32array
167
+ const offset = this._ringOffsets.get(rings[i]);
168
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset + 8, zero);
169
+ this._removedRingsOffsetStack.push(offset);
170
+ this._ringOffsets.delete(rings[i]);
171
+ }
172
+ this._ringCounter -= rings.length;
173
+ this._centerMap.delete(centerID);
174
+ }
175
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
176
+ this.globe.DrawRender();
177
+ }
178
+ /**
179
+ *
180
+ * @property {String} centerID
181
+ * @property {Number} x radians x
182
+ * @property {Number} y radians y
183
+ * @param {*} centerIDxyList
184
+ */
185
+ updateCentersXY(centerIDxyList) {
186
+ const { gl, buffer } = this;
187
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
188
+ for (let { centerID, x, y } of centerIDxyList) {
189
+ const center = this._centerMap.get(centerID);
190
+ center.set("x", x);
191
+ center.set("y", y);
192
+ const xyBlock = new Float32Array([x, y]);
193
+ const rings = center.get("rings");
194
+ for (let i = 0; i < rings.length; i++) {
195
+ const offset = this._ringOffsets.get(rings[i]);
196
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, xyBlock);
197
+ }
198
+ }
199
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
200
+ this.globe.DrawRender();
201
+ }
202
+ updateCentersHide(data) {
203
+ const { gl, buffer } = this;
204
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
205
+ for (let { centerID, hide = null } of data) {
206
+ if (hide === null)
207
+ continue;
208
+ const rings = this._centerMap.get(centerID).get("rings");
209
+ for (let i = 0; i < rings.length; i++) {
210
+ const offset = this._ringOffsets.get(rings[i]);
211
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset + 32, new Float32Array([hide]));
212
+ }
213
+ }
214
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
215
+ this.globe.DrawRender();
216
+ }
217
+ insertBulk(rangeRingDatas) {
218
+ const { gl, buffer } = this;
219
+ { // remove existring centers
220
+ const existingCenterIDs = [];
221
+ for (let { centerID } of rangeRingDatas) {
222
+ if (this._centerMap.has(centerID)) {
223
+ existingCenterIDs.push(centerID);
224
+ }
225
+ }
226
+ this.removeCenters(existingCenterIDs);
227
+ }
228
+ { // capacity check
229
+ let incomingRingSize = 0;
230
+ for (let { rings } of rangeRingDatas) {
231
+ incomingRingSize += rings.length;
232
+ // It should check if ring is already registered but for now it is not implemented.
233
+ // Reasons: increase in complexity and performance
234
+ }
235
+ this._implicitExtendBufferInNeed(incomingRingSize);
236
+ }
237
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
238
+ for (const { centerID, x, y, rings, hide = 0 } of rangeRingDatas) {
239
+ this.registerCenter(centerID, { x, y });
240
+ for (const { ringID, radius, padding, rgba } of rings) {
241
+ const key = this._ringKey(centerID, ringID);
242
+ const bufferData = new Float32Array([x, y, radius, padding, ...rgba, hide]);
243
+ const offset = this._nextBufferOffset();
244
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
245
+ this._ringOffsets.set(key, offset);
246
+ this._centerMap.get(centerID).get("rings").push(key);
247
+ }
248
+ }
249
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
250
+ this.globe.DrawRender();
251
+ }
252
+ /**
253
+ *
254
+ * @param {Array<{centerID, rgba}} centersColors
255
+ */
256
+ updateCentersColor(centersColors) {
257
+ const { gl, buffer } = this;
258
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
259
+ for (let { centerID, rgba } of centersColors) {
260
+ if (!this._centerMap.has(centerID)) {
261
+ console.warn("Center is not registered yet");
262
+ continue;
263
+ }
264
+ const rings = this._centerMap.get(centerID).get("rings");
265
+ const block = new Float32Array(rgba);
266
+ for (let i = 0; i < rings.length; i++) {
267
+ const offset = this._ringOffsets.get(rings[i]);
268
+ gl.bufferSubData(gl.ARRAY_BUFFER, offset + 16, block);
269
+ }
270
+ }
271
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
272
+ this.globe.DrawRender();
273
+ }
274
+ // ----------------- INTERNAL METHODS ----------------- //
275
+ bindCircleVAO() {
276
+ this.gl.bindVertexArray(this._circleVAO);
277
+ }
278
+ bindPaddingVAO() {
279
+ this.gl.bindVertexArray(this._paddingVAO);
280
+ }
281
+ free() {
282
+ this.gl.deleteBuffer(this.buffer);
283
+ this.gl.deleteVertexArray(this._circleVAO);
284
+ this.gl.deleteVertexArray(this._paddingVAO);
285
+ }
286
+ // ----------------- PRIVATE METHODS ----------------- //
287
+ _getBufferData() {
288
+ const { gl, buffer } = this;
289
+ const size = new Float32Array(this._length * RING_SIZE);
290
+ const bufferData = new Float32Array(size);
291
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
292
+ gl.getBufferSubData(gl.ARRAY_BUFFER, 0, bufferData);
293
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
294
+ return bufferData;
295
+ }
296
+ _ringKey(centerID, ringID) {
297
+ return `C=${centerID},R=${ringID}`;
298
+ }
299
+ _nextBufferOffset() {
300
+ if (!this.checkCapacity()) {
301
+ throw new Error("Buffer is full");
302
+ return;
303
+ }
304
+ let offset;
305
+ if (this._removedRingsOffsetStack.length > 0) {
306
+ offset = this._removedRingsOffsetStack.pop();
307
+ }
308
+ else {
309
+ offset = this._ringCounter * RING_SIZE * 4;
310
+ this._length++;
311
+ }
312
+ this._ringCounter++;
313
+ return offset;
314
+ }
315
+ _implicitExtendBufferInNeed(incomingRingSize) {
316
+ const overCapacity = incomingRingSize - this.capacityLeft();
317
+ if (overCapacity <= 0)
318
+ return;
319
+ const newCapacity = Math.ceil((this._capacity + overCapacity) * this.implicitExtentionRate);
320
+ this.extendBuffer(newCapacity);
321
+ }
322
+ async readRing(centerID, ringID) {
323
+ const key = this._ringKey(centerID, ringID);
324
+ if (!this._ringOffsets.has(key)) {
325
+ console.warn("Ring is not registered yet");
326
+ return;
327
+ }
328
+ const offset = this._ringOffsets.get(key);
329
+ const { gl, buffer } = this;
330
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
331
+ const bufferData = new Float32Array(9);
332
+ gl.getBufferSubData(gl.ARRAY_BUFFER, offset, bufferData);
333
+ return {
334
+ centerX: bufferData[0],
335
+ centerY: bufferData[1],
336
+ range: bufferData[2],
337
+ padding: bufferData[3],
338
+ rgba: [bufferData[4], bufferData[5], bufferData[6], bufferData[7]],
339
+ hide: bufferData[8]
340
+ };
341
+ }
342
+ }
343
+ exports.default = default_1;
344
+ /**
345
+ * Documentation
346
+ *
347
+ * Methods:
348
+ * - insertRings(centerIdringIdRadiusPaddingRgbaHide)
349
+ * - removeRings(centerIDringIDs)
350
+ * - removeCenters(centerIDs)
351
+ * - updateCentersXY(centerIDxyList)
352
+ * - updateCenters(centerDatas)
353
+ * - insertBulk(rangeRingDatas)
354
+ * - updateRing(centerID, ringID, { radius, padding, rgba, hide })
355
+ * - readRing(centerID, ringID)
356
+ *
357
+ */
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PaddingFreeAngleCache = exports.CirclePaddySharedBuffer = exports.PaddingProgramCache = exports.circleProgramCache = void 0;
7
+ const circleflatprogram_1 = require("./circleflatprogram");
8
+ Object.defineProperty(exports, "circleProgramCache", { enumerable: true, get: function () { return circleflatprogram_1.programCache; } });
9
+ const paddyflatprogram_1 = require("./paddyflatprogram");
10
+ Object.defineProperty(exports, "PaddingProgramCache", { enumerable: true, get: function () { return paddyflatprogram_1.PaddingProgramCache; } });
11
+ const circlepaddysharedbuffer_1 = __importDefault(require("./circlepaddysharedbuffer"));
12
+ exports.CirclePaddySharedBuffer = circlepaddysharedbuffer_1.default;
13
+ const circlepaddingfreeangleprogram_1 = require("./circlepaddingfreeangleprogram");
14
+ Object.defineProperty(exports, "PaddingFreeAngleCache", { enumerable: true, get: function () { return circlepaddingfreeangleprogram_1.PaddingFreeAngleCache; } });
@@ -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
+ });