@pirireis/webglobeplugins 0.9.6 → 0.9.7

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 (226) hide show
  1. package/package.json +5 -2
  2. package/Math/angle-calculation.js +0 -14
  3. package/Math/arc.ts +0 -76
  4. package/Math/bounds/line-bbox.js +0 -225
  5. package/Math/constants.ts +0 -11
  6. package/Math/frustum/camera.ts +0 -32
  7. package/Math/frustum/from-globeinfo.ts +0 -63
  8. package/Math/frustum/types.ts +0 -11
  9. package/Math/globe-util/horizon-plane.ts +0 -137
  10. package/Math/index.js +0 -0
  11. package/Math/juction/arc-plane.ts +0 -114
  12. package/Math/juction/line-sphere.ts +0 -30
  13. package/Math/juction/plane-plane.ts +0 -66
  14. package/Math/line.ts +0 -70
  15. package/Math/matrix4.ts +0 -0
  16. package/Math/methods.js +0 -237
  17. package/Math/plane.ts +0 -86
  18. package/Math/quaternion.ts +0 -120
  19. package/Math/roadmap.md +0 -10
  20. package/Math/types.ts +0 -45
  21. package/Math/utils.js +0 -3
  22. package/Math/vec3.ts +0 -155
  23. package/algorithms/search-binary.js +0 -14
  24. package/altitude-locator/adaptors.js +0 -0
  25. package/altitude-locator/draw-subset-obj.js +0 -27
  26. package/altitude-locator/keymethod.js +0 -0
  27. package/altitude-locator/plugin.js +0 -439
  28. package/altitude-locator/types.js +0 -26
  29. package/arrowfield/adaptor.js +0 -11
  30. package/arrowfield/index.js +0 -3
  31. package/arrowfield/plugin.js +0 -128
  32. package/bearing-line/index.js +0 -2
  33. package/bearing-line/plugin.js +0 -512
  34. package/circle-line-chain/chain-list-map.js +0 -221
  35. package/circle-line-chain/init.js +0 -0
  36. package/circle-line-chain/plugin.js +0 -469
  37. package/circle-line-chain/readme.md +0 -57
  38. package/circle-line-chain/util.js +0 -1
  39. package/compass-rose/compass-rose-padding-flat.js +0 -266
  40. package/compass-rose/compass-text-writer.js +0 -173
  41. package/compass-rose/index.js +0 -3
  42. package/compassrose/compassrose.js +0 -341
  43. package/compassrose/index.js +0 -2
  44. package/depth-locator/readme.md +0 -26
  45. package/globe-types.ts +0 -13
  46. package/heatwave/index.js +0 -4
  47. package/heatwave/isobar/objectarraylabels.js +0 -247
  48. package/heatwave/isobar/plugin.js +0 -340
  49. package/heatwave/isobar/quadtreecontours.js +0 -336
  50. package/heatwave/plugins/heatwaveglobeshell.js +0 -258
  51. package/jest.config.js +0 -6
  52. package/partialrings/buffer-manager.js +0 -89
  53. package/partialrings/goals.md +0 -17
  54. package/partialrings/index.js +0 -3
  55. package/partialrings/plugin.js +0 -160
  56. package/partialrings/program.js +0 -324
  57. package/pin/pin-object-array.js +0 -381
  58. package/pin/pin-point-totem.js +0 -77
  59. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +0 -78
  60. package/point-heat-map/index.js +0 -0
  61. package/point-heat-map/plugin-webworker.js +0 -151
  62. package/point-heat-map/point-to-heat-map-flow.js +0 -150
  63. package/point-heat-map/readme.md +0 -15
  64. package/point-tracks/key-methods.js +0 -3
  65. package/point-tracks/plugin.js +0 -394
  66. package/programs/arrowfield/index.js +0 -2
  67. package/programs/arrowfield/logic.js +0 -286
  68. package/programs/arrowfield/object.js +0 -89
  69. package/programs/data2legend/density-to-legend.js +0 -115
  70. package/programs/data2legend/point-to-density-texture.js +0 -114
  71. package/programs/float2legendwithratio/index.js +0 -3
  72. package/programs/float2legendwithratio/logic.js +0 -194
  73. package/programs/float2legendwithratio/object.js +0 -141
  74. package/programs/globe-util/is-globe-moved.js +0 -27
  75. package/programs/globeshell/index.js +0 -2
  76. package/programs/globeshell/noise/noises.js +0 -0
  77. package/programs/globeshell/wiggle/index.js +0 -6
  78. package/programs/globeshell/wiggle/logic.js +0 -371
  79. package/programs/globeshell/wiggle/object.js +0 -93
  80. package/programs/helpers/blender/index.js +0 -0
  81. package/programs/helpers/blender/program.js +0 -91
  82. package/programs/helpers/fadeaway/index.js +0 -3
  83. package/programs/helpers/fadeaway/logic.js +0 -76
  84. package/programs/helpers/fadeaway/object.js +0 -20
  85. package/programs/helpers/index.js +0 -2
  86. package/programs/index.js +0 -21
  87. package/programs/interface.ts +0 -7
  88. package/programs/line-on-globe/angled-line.js +0 -206
  89. package/programs/line-on-globe/circle-accurate-3d.js +0 -167
  90. package/programs/line-on-globe/circle-accurate-flat.js +0 -262
  91. package/programs/line-on-globe/circle-accurate.js +0 -202
  92. package/programs/line-on-globe/circle.js +0 -191
  93. package/programs/line-on-globe/degree-padding-around-circle-3d.js +0 -188
  94. package/programs/line-on-globe/index.js +0 -0
  95. package/programs/line-on-globe/lines-color-instanced-flat.js +0 -151
  96. package/programs/line-on-globe/linestrip.ts +0 -228
  97. package/programs/line-on-globe/naive-accurate-flexible.js +0 -239
  98. package/programs/line-on-globe/to-the-surface.js +0 -129
  99. package/programs/line-on-globe/util.js +0 -8
  100. package/programs/picking/pickable-renderer.js +0 -216
  101. package/programs/point-on-globe/element-globe-surface-glow.js +0 -168
  102. package/programs/point-on-globe/element-point-glow.js +0 -184
  103. package/programs/point-on-globe/square-pixel-point.js +0 -189
  104. package/programs/programcache.ts +0 -131
  105. package/programs/rings/distancering/circleflatprogram.js +0 -136
  106. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +0 -378
  107. package/programs/rings/distancering/circlepaddysharedbuffer.js +0 -420
  108. package/programs/rings/distancering/index.js +0 -5
  109. package/programs/rings/distancering/paddyflatprogram.js +0 -146
  110. package/programs/rings/distancering/paddyflatprogram2d.js +0 -150
  111. package/programs/rings/distancering/paddyflatprogram3d.js +0 -146
  112. package/programs/rings/distancering/shader.js +0 -0
  113. package/programs/rings/index.js +0 -1
  114. package/programs/rings/partial-ring/piece-of-pie.js +0 -315
  115. package/programs/totems/camerauniformblock.d.ts +0 -48
  116. package/programs/totems/camerauniformblock.js +0 -197
  117. package/programs/totems/canvas-webglobe-info.js +0 -136
  118. package/programs/totems/gpu-selection-uniform-block.js +0 -132
  119. package/programs/totems/index.ts +0 -2
  120. package/programs/two-d/pixel-circle.js +0 -0
  121. package/programs/two-d/pixel-padding-for-compass.js +0 -174
  122. package/programs/util.js +0 -20
  123. package/programs/vectorfields/index.js +0 -3
  124. package/programs/vectorfields/logics/drawrectangleparticles.js +0 -125
  125. package/programs/vectorfields/logics/index.js +0 -5
  126. package/programs/vectorfields/logics/pixelbased.js +0 -161
  127. package/programs/vectorfields/logics/ubo.js +0 -64
  128. package/programs/vectorfields/pingpongbuffermanager.js +0 -80
  129. package/publish.bat +0 -60
  130. package/rangerings/enum.js +0 -3
  131. package/rangerings/index.js +0 -5
  132. package/rangerings/plugin.js +0 -649
  133. package/rangerings/rangeringangletext.js +0 -368
  134. package/rangerings/ring-account.js +0 -129
  135. package/shaders/fragment-toy/firework.js +0 -55
  136. package/shaders/fragment-toy/singularity.js +0 -59
  137. package/shape-on-terrain/arc/naive/plugin.ts +0 -304
  138. package/shape-on-terrain/goal.md +0 -12
  139. package/tests/Math/junction/arc-plane.test.ts +0 -133
  140. package/tests/Math/junction/plane-plane.test.ts +0 -82
  141. package/tests/Math/plane.test.ts +0 -43
  142. package/tests/Math/vec3.test.ts +0 -14
  143. package/timetracks/adaptors-line-strip.js +0 -80
  144. package/timetracks/adaptors.js +0 -133
  145. package/timetracks/index.js +0 -6
  146. package/timetracks/plugin-line-strip.js +0 -295
  147. package/timetracks/plugin.js +0 -304
  148. package/timetracks/program-line-strip.js +0 -688
  149. package/timetracks/program.js +0 -850
  150. package/timetracks/programpoint-line-strip.js +0 -175
  151. package/timetracks/programpoint.js +0 -168
  152. package/timetracks/readme.md +0 -1
  153. package/tsconfig.json +0 -22
  154. package/types.ts +0 -17
  155. package/util/account/bufferoffsetmanager.js +0 -209
  156. package/util/account/index.js +0 -6
  157. package/util/account/single-attribute-buffer-management/buffer-manager.ts +0 -119
  158. package/util/account/single-attribute-buffer-management/buffer-orchestrator.ts +0 -173
  159. package/util/account/single-attribute-buffer-management/index.ts +0 -13
  160. package/util/account/single-attribute-buffer-management/object-store.ts +0 -65
  161. package/util/account/single-attribute-buffer-management/types.ts +0 -39
  162. package/util/account/util.js +0 -22
  163. package/util/algorithms/index.js +0 -0
  164. package/util/algorithms/search-binary.js +0 -26
  165. package/util/check/get.js +0 -13
  166. package/util/check/index.js +0 -0
  167. package/util/check/typecheck.js +0 -39
  168. package/util/geometry/index.js +0 -53
  169. package/util/gl-util/buffer/attribute-loader.ts +0 -85
  170. package/util/gl-util/buffer/index.ts +0 -6
  171. package/util/gl-util/buffer/types.ts +0 -13
  172. package/util/gl-util/draw-options/methods.ts +0 -66
  173. package/util/gl-util/draw-options/types.ts +0 -28
  174. package/util/gl-util/uniform-block/manager.ts +0 -187
  175. package/util/gl-util/uniform-block/roadmap.md +0 -70
  176. package/util/gl-util/uniform-block/shader.js +0 -0
  177. package/util/gl-util/uniform-block/types.ts +0 -27
  178. package/util/heatwavedatamanager/datamanager.js +0 -168
  179. package/util/heatwavedatamanager/index.js +0 -3
  180. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +0 -133
  181. package/util/heatwavedatamanager/pointcoordsmeta.js +0 -22
  182. package/util/index.js +0 -13
  183. package/util/interpolation/index.js +0 -0
  184. package/util/interpolation/timetrack/index.js +0 -9
  185. package/util/interpolation/timetrack/timetrack-interpolator.js +0 -88
  186. package/util/interpolation/timetrack/web-worker-str.js +0 -180
  187. package/util/interpolation/timetrack/web-worker.js +0 -51
  188. package/util/jshelpers/data-filler.js +0 -19
  189. package/util/jshelpers/equality.js +0 -17
  190. package/util/jshelpers/index.js +0 -1
  191. package/util/jshelpers/timefilters.js +0 -32
  192. package/util/picking/fence.js +0 -46
  193. package/util/picking/picker-displayer.js +0 -177
  194. package/util/programs/draw-texture-on-canvas.js +0 -102
  195. package/util/programs/index.js +0 -1
  196. package/util/programs/shapesonglobe.js +0 -246
  197. package/util/programs/supersampletotextures.js +0 -142
  198. package/util/programs/texturetoglobe.js +0 -203
  199. package/util/shaderfunctions/geometrytransformations.ts +0 -388
  200. package/util/shaderfunctions/index.js +0 -2
  201. package/util/shaderfunctions/nodata.js +0 -10
  202. package/util/shaderfunctions/noisefunctions.js +0 -44
  203. package/util/surface-line-data/arc-bboxes.ts +0 -42
  204. package/util/surface-line-data/arcs-to-cuts.js +0 -74
  205. package/util/surface-line-data/cut-arc.js +0 -0
  206. package/util/surface-line-data/flow.ts +0 -52
  207. package/util/surface-line-data/rbush-manager.js +0 -0
  208. package/util/surface-line-data/types.ts +0 -27
  209. package/util/surface-line-data/web-worker.js +0 -0
  210. package/util/webglobe/gldefaultstates.js +0 -5
  211. package/util/webglobe/index.js +0 -2
  212. package/util/webglobe/rasteroverlay.js +0 -96
  213. package/util/webglobjectbuilders.ts +0 -456
  214. package/util/webglobjectbuilders1.js +0 -271
  215. package/waveparticles/adaptor.js +0 -16
  216. package/waveparticles/index.js +0 -3
  217. package/waveparticles/plugin.js +0 -313
  218. package/wind/imagetovectorfieldandmagnitude.js +0 -39
  219. package/wind/index.js +0 -5
  220. package/wind/plugin.js +0 -1057
  221. package/wind/vectorfieldimage.js +0 -27
  222. package/write-text/attached-text-writer.js +0 -105
  223. package/write-text/context-text.js +0 -125
  224. package/write-text/context-text3.js +0 -178
  225. package/write-text/index.js +0 -1
  226. package/write-text/writer-plugin.js +0 -7
@@ -1,394 +0,0 @@
1
- import { BufferOrchestrator, BufferManager, ObjectStore } from "../util/account";
2
-
3
- import { PickerDisplayer } from "../util/picking/picker-displayer";
4
- import { PointOnGlobeProgramCache } from "../programs/point-on-globe/square-pixel-point";
5
-
6
- import { wgs84ToCartesian3d, wgs84ToMercator } from "../Math/methods";
7
-
8
- /**
9
- * @typedef {number} long
10
- * @typedef {number} lat
11
- * @typedef {number} height
12
- * @typedef {string} ID
13
- * @typedef {string} trackID
14
- * @typedef {[number, number, number, number]} rgba 0-1
15
- * @typedef { long ,lat, height, ID } Point
16
- * @typedef {Array<Point>, rgba, trackID} Track
17
- */
18
-
19
-
20
- class PointTracksPlugin {
21
-
22
- constructor(id, { pointSize = 2, hoveredPointSize = 4, selectionPointFilling = 4, opacity = 1.0 } = {}) {
23
- this.id = id;
24
- this._isFreed = false;
25
- this._pointProgram = null
26
- this._vao = null;
27
- this._bufferManagersMap = null;
28
- this._bufferOrchestrator = null;
29
- this._pickerDisplayer = null
30
- this._selectedID = -1;
31
- this._selectedObj = null;
32
- this._tracksToPointsMap = new Map(); // one to many
33
- this._opacity = opacity;
34
- this.program = null
35
- this._lastWH = { w: 0, h: 0 };
36
- this._focusParams = { on: false, length: 0, elementBuffer: null, trackIDs: [] };
37
- this.pointSizes = {
38
- pointSize,
39
- selectionPointFilling,
40
- hoveredPointSize
41
- }
42
- }
43
-
44
-
45
- init(globe, gl) {
46
-
47
- this.globe = globe;
48
- this.gl = gl;
49
- this._pickerDisplayer = new PickerDisplayer(globe);
50
- this._pointProgram = PointOnGlobeProgramCache.get(globe);
51
- this._focusParams.elementBuffer = gl.createBuffer();
52
- this._initBufferManagers();
53
- }
54
-
55
-
56
- _initBufferManagers() {
57
- const { gl } = this;
58
- const initialCapacity = 10;
59
- const bufferType = "DYNAMIC_DRAW";
60
- this._bufferOrchestrator = new BufferOrchestrator({ initialCapacity });
61
- this._bufferManagersMap = new Map(
62
- [
63
- ["pos3D", {
64
- bufferManager: new BufferManager(gl, 3, { bufferType, initialCapacity }),
65
- adaptor: (item) => new Float32Array(wgs84ToCartesian3d(item.long, item.lat, item.height / 1000)) // height is in meters
66
- }],
67
- ["pos2D", {
68
- bufferManager: new BufferManager(gl, 2, { bufferType, initialCapacity }),
69
- adaptor: (item) => new Float32Array(wgs84ToMercator(item.long, item.lat))
70
- }],
71
- ["rgba", {
72
- bufferManager: new BufferManager(gl, 4, { bufferType, initialCapacity }),
73
- adaptor: (item) => item.rgba
74
- }],
75
- ["objectStore", {
76
- bufferManager: new ObjectStore({ initialCapacity }),
77
- adaptor: (item) => {
78
- return {
79
- trackID: item.trackID, pointID: item.pointID
80
- }
81
- }
82
- }]
83
- ]
84
- );
85
-
86
- this._vao = this._pointProgram.createVAO(
87
- this._bufferManagersMap.get("pos3D").bufferManager.buffer,
88
- this._bufferManagersMap.get("pos2D").bufferManager.buffer,
89
- this._bufferManagersMap.get("rgba").bufferManager.buffer,
90
- );
91
- }
92
-
93
-
94
- setPointSize(size) {
95
- this.pointSizes.pointSize = size;
96
- this.globe?.DrawRender();
97
- }
98
-
99
- setSelectionPointFilling(size) {
100
- this.pointSizes.selectionPointFilling = size;
101
- this.globe?.DrawRender();
102
- }
103
-
104
- setHoveredPointSize(size) {
105
- this.pointSizes.hoveredPointSize = size;
106
- this.globe?.DrawRender();
107
- }
108
-
109
- setOpacity(opacity) {
110
- if (opacity < 0 || opacity > 1) return;
111
- this._opacity = opacity;
112
- this.globe?.DrawRender();
113
- }
114
-
115
- getCurrentSelection() {
116
- return this._selectedObj;
117
- }
118
-
119
-
120
- /**
121
- *
122
- * @param {*} x screen x
123
- * @param {*} y screen y
124
- * @param {*} callback callback on selection
125
- */
126
- screenSelection(x, y, callback) {
127
- const { pointSizes, _pickerDisplayer } = this;
128
- const objectStore = this._bufferManagersMap.get("objectStore").bufferManager;
129
- const wrapper = (selectedIDsSet) => {
130
- const selectedIDs = Array.from(selectedIDsSet);
131
- if (selectedIDs.length === 0) {
132
- this._selectedObj = null;
133
- this._selectedID = -1;
134
- callback([]);
135
- return;
136
- }
137
- const selectedPoints = [];
138
- for (let i = 0; i < selectedIDs.length; i++) {
139
- const id = selectedIDs[i];
140
- if (i === 0) {
141
- this._selectedID = id;
142
- this._selectedObj = objectStore.get(id);
143
- }
144
- const obj = objectStore.get(id);
145
- selectedPoints.push(obj);
146
- }
147
-
148
- callback(selectedPoints);
149
- }
150
- _pickerDisplayer.pickXY(x, y, pointSizes.selectionPointFilling, wrapper);
151
- }
152
-
153
-
154
- /**
155
- * @param {Array<Track>} tracks
156
- * @returns
157
- */
158
- insertBulk(tracks) {
159
- this._fillTracksToPointsMap(tracks); // TODO error should be at the top
160
- const flattenedPoints = tracks.map(trackToFlatPoints).flat();
161
- const currentLoad = this._bufferOrchestrator.length;
162
- if (currentLoad + flattenedPoints.length >= 2147483647) {
163
- throw new Error("Too many points, Point count cannot exceed 2147483647");
164
- }
165
- const { _bufferManagersMap, _bufferOrchestrator } = this;
166
- _bufferOrchestrator.insertBulk(flattenedPoints, _bufferManagersMap);
167
- this._refillFocus();
168
-
169
- this.globe?.DrawRender();
170
-
171
- }
172
-
173
-
174
- flush() {
175
- const capacity = 100
176
- this._bufferOrchestrator?.flush({ capacity });
177
- this._bufferManagersMap.forEach(({ bufferManager }) => bufferManager.resetWithCapacity(capacity));
178
- this._turnOffFocus();
179
- this._tracksToPointsMap.clear();
180
- this.globe?.DrawRender();
181
- }
182
-
183
- /**
184
- * @param {string} trackID
185
- */
186
- deleteTrack(trackID) {
187
- const pointSet = this._tracksToPointsMap.get(trackID);
188
- const points = Array.from(pointSet);
189
- const { _bufferOrchestrator, _bufferManagersMap } = this;
190
- _bufferOrchestrator.deleteBulk(
191
- points.map((pointID) => keyMethod(trackID, pointID)),
192
- _bufferManagersMap
193
- );
194
- this._tracksToPointsMap.delete(trackID);
195
- this._redraw = true;
196
- this._refillFocus();
197
-
198
- this.globe?.DrawRender();
199
- }
200
-
201
-
202
- /**
203
- * @param {string} trackID
204
- * @param {Array<string>} pointIDs
205
- */
206
- deletePoints(trackID, pointIDs) {
207
- const { _bufferOrchestrator, _bufferManagersMap } = this;
208
- _bufferOrchestrator.deleteBulk(
209
- pointIDs.map((pointID) => keyMethod(trackID, pointID)),
210
- _bufferManagersMap
211
- );
212
- this._deletePointsFromTracksMap(trackID, pointIDs);
213
- this._refillFocus();
214
- this.globe?.DrawRender();
215
- }
216
-
217
- focusTracks(trackIDs = null) {
218
- if (!this.globe) return;
219
- if (!trackIDs) {
220
- this._focusParams.on = false;
221
- this.globe?.DrawRender();
222
- return;
223
- }
224
- this._focusParams.on = this._fillElementBuffer(trackIDs);
225
- if (!this._focusParams.on) {
226
- this._turnOffFocus();
227
- }
228
- this.globe.DrawRender();
229
- }
230
-
231
-
232
- // GLOBE API METHODS
233
-
234
- free() {
235
- if (this._isFreed) return;
236
- this._isFreed = true;
237
- this._pickerDisplayer.free();
238
- PointOnGlobeProgramCache.release(this.globe);
239
- this.gl.deleteBuffer(this._focusParams.elementBuffer);
240
- this._bufferManagersMap.forEach(
241
- ({ bufferManager, adaptor }) => bufferManager.free()
242
- );
243
- }
244
-
245
-
246
- draw3D() {
247
- const { gl, _pointProgram, _pickerDisplayer, _bufferOrchestrator, _vao } = this;
248
- this.resize();
249
-
250
- _pickerDisplayer.bindFBO();
251
- _pickerDisplayer.clearTextures();
252
-
253
- if (this._focusParams.on) {
254
- _pointProgram.draw(_vao, this._focusParams.length,
255
- {
256
- hoveredID: this._selectedID,
257
- opacity: this._opacity,
258
- pointSize: this.pointSizes.pointSize,
259
- hoveredPointSize: this.pointSizes.hoveredPointSize,
260
- elementBuffer: this._focusParams.elementBuffer
261
- });
262
- } else {
263
- _pointProgram.draw(_vao, _bufferOrchestrator.length,
264
- {
265
- hoveredID: this._selectedID,
266
- opacity: this._opacity,
267
- pointSize: this.pointSizes.pointSize,
268
- hoveredPointSize: this.pointSizes.hoveredPointSize
269
- });
270
- }
271
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
272
- _pickerDisplayer.drawColorTexture();
273
-
274
- this._selfSelect();
275
- }
276
-
277
-
278
- resize() {
279
- const w = this.globe.api_ScrW();
280
- const h = this.globe.api_ScrH();
281
- if (w === this._lastWH.w && h === this._lastWH.h) return;
282
-
283
- this._lastWH.w = w;
284
- this._lastWH.h = h;
285
- this._pickerDisplayer.resize();
286
- this.globe?.DrawRender();
287
- }
288
-
289
- // IMPLICIT METHODS
290
-
291
- _fillTracksToPointsMap(tracks) {
292
- for (const track of tracks) {
293
- const trackID = track.trackID;
294
- const points = track.points;
295
- if (!this._tracksToPointsMap.has(trackID)) {
296
- this._tracksToPointsMap.set(trackID, new Set());
297
- }
298
- const pointSet = this._tracksToPointsMap.get(trackID);
299
- for (let p = 0; p < points.length; p++) {
300
- const pointID = points[p].ID;
301
- pointSet.add(pointID);
302
- }
303
- }
304
- }
305
-
306
- _refillFocus() {
307
- if (this._focusParams.on) {
308
- this.focusTracks(this._focusParams.trackIDs);
309
- }
310
- }
311
-
312
- _deletePointsFromTracksMap(trackID, pointIDs) {
313
- const trackSet = this._tracksToPointsMap.get(trackID);
314
- for (const pointID of pointIDs) {
315
- trackSet.delete(pointID);
316
- }
317
- }
318
-
319
-
320
- _selfSelect() {
321
- const { globe } = this;
322
- const pos = globe.api_GetMousePos();
323
- const x = pos.canvasX;
324
- const y = globe.api_ScrH() - pos.canvasY;
325
- this.screenSelection(x, y, (selectedPoints) => {
326
- });
327
-
328
- }
329
-
330
- _turnOffFocus() {
331
- const { gl } = this;
332
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._focusParams.elementBuffer);
333
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([]), gl.STATIC_DRAW);
334
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
335
- this._focusParams.length = 0;
336
- this._focusParams.on = false;
337
- }
338
-
339
- _fillElementBuffer(trackIDs) {
340
-
341
- let length = 0;
342
- const indexes = [];
343
- const foundTracks = []
344
- for (const trackID of trackIDs) {
345
- const pointSet = this._tracksToPointsMap.get(trackID);
346
- if (!pointSet) continue;
347
- foundTracks.push(trackID);
348
- const points = Array.from(pointSet);
349
- for (const pointID of points) {
350
- const key = keyMethod(trackID, pointID);
351
- const index = this._bufferOrchestrator.offsetMap.get(key);
352
- indexes.push(index);
353
- length++;
354
- }
355
- }
356
- this._focusParams.trackIDs = foundTracks;
357
- this._focusParams.length = length;
358
- if (length === 0) {
359
- return false;
360
- }
361
- const { gl } = this;
362
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._focusParams.elementBuffer);
363
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(indexes), gl.STATIC_DRAW);
364
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
365
- return true;
366
- }
367
-
368
- }
369
-
370
-
371
- const trackToFlatPoints = (track) => {
372
-
373
- const trackID = track.trackID;
374
- const points = track.points;
375
- const rgba = new Float32Array(track.rgba);
376
- const flatPoints = [];
377
- for (const point of points) {
378
- flatPoints.push({
379
- key: keyMethod(trackID, point.ID),
380
- long: point.long,
381
- lat: point.lat,
382
- height: point.height,
383
- pointID: point.ID,
384
- rgba,
385
- trackID
386
- });
387
- }
388
- return flatPoints;
389
- }
390
-
391
- const keyMethod = (trackID, pointID) => `${trackID}_${pointID}`;
392
-
393
-
394
- export { PointTracksPlugin, keyMethod }
@@ -1,2 +0,0 @@
1
- import ArrowField from './object';
2
- export default ArrowField;
@@ -1,286 +0,0 @@
1
- import { createProgram } from "../../util";
2
- import { globeProgramCache } from "../programcache";
3
- import { CameraUniformBlockTotem } from "../totems";
4
-
5
- const arrowVertexShader = `#version 300 es
6
- #define R 6378.137
7
- #define PI 3.1415926535897932384626433832795
8
- #define POLE 20037508.34
9
- #define POLE_BY_PI 6366198.2
10
- #define HALF_PI 1.5707963267948966192313216916398
11
-
12
- uniform sampler2D rotation; // rotation of arrow
13
-
14
- out vec4 v_color;
15
-
16
- layout(std140) uniform CameraBlock {
17
- mat4 u_view;
18
- mat4 u_projection;
19
- vec3 u_translate;
20
- bool u_is3D;
21
- vec2 u_mapWH;
22
- vec2 u_scrWH;
23
- float u_zlevel;
24
- };
25
-
26
- layout(std140) uniform ArrowBlock {
27
- vec4 u_color;
28
- vec2 u_bbox_offset_rad;
29
- vec2 u_bbox_size_rad;
30
- vec2 u_resolution;
31
- float u_length_ratio;
32
- float u_width_ratio;
33
- float u_height;
34
- float u_no_data_value;
35
- };
36
-
37
- vec2 f_texCoord(){
38
- float fID = float(gl_InstanceID);
39
- float x = mod( fID, u_resolution.x ) / ( u_resolution.x - 1.0);
40
- float y = 1.0 - floor( fID / u_resolution.x ) / ( u_resolution.y - 1.0);
41
- return vec2(x, y);
42
- }
43
-
44
- vec2 f_radCoord(vec2 texCoord){
45
- float x = (texCoord.x * u_bbox_size_rad.x ) + u_bbox_offset_rad.x;
46
- float y = (texCoord.y * u_bbox_size_rad.y ) + u_bbox_offset_rad.y;
47
- return vec2(x, y);
48
- }
49
-
50
- vec3 f_onSphere(vec2 radCoord){
51
- float x = sin(radCoord.y) * cos(radCoord.x);
52
- float y = sin(radCoord.y) * sin(radCoord.x);
53
- float z = cos(radCoord.y);
54
- return vec3(x, y, z) * (R + u_height);
55
- }
56
-
57
-
58
- vec2 f_onFlat(vec2 radCoord){
59
- float mercX = radCoord.x * POLE_BY_PI;
60
- float mercY = log(tan(HALF_PI - radCoord.y * 0.5)) * POLE_BY_PI;
61
- float normX = ( mercX - u_translate.x ) / u_mapWH.x;
62
- float normY = ( mercY - u_translate.y ) / u_mapWH.y;
63
- return vec2(normX, normY);
64
- }
65
-
66
- void main() {
67
- // escape if no data
68
- vec2 texCoord = f_texCoord();
69
- vec2 geoCoord = vec2( texCoord.x , 1.0 - texCoord.y );
70
-
71
-
72
- float angle = texture(rotation, texCoord).r;
73
-
74
- if ( angle == u_no_data_value ) {
75
- gl_Position = vec4(-2.0, -2.0, 0.0, 1.0);
76
- return;
77
- }
78
- vec2 arrowLimb;
79
- if (0.0 == mod(float(gl_VertexID), 2.0)) {
80
- arrowLimb = vec2(0.0, 0.0);
81
- } else if (gl_VertexID == 1) {
82
- // tail
83
- arrowLimb = vec2( cos(angle), sin(angle)) * u_length_ratio / (170.0 );
84
- } else if (gl_VertexID == 3) {
85
- // right wing
86
- arrowLimb = vec2( cos(angle + 0.45), sin(angle + 0.45)) * u_width_ratio / (170.0 );
87
- } else if (gl_VertexID == 5) {
88
- // left wing
89
- arrowLimb = vec2( cos(angle - 0.45), sin(angle - 0.45)) * u_width_ratio / (170.0 );
90
- }
91
-
92
-
93
- vec2 radCoord = f_radCoord(geoCoord + arrowLimb);
94
- if ( u_is3D ) {
95
- vec3 spherePos = f_onSphere(radCoord);
96
- gl_Position = u_projection * u_view * vec4(spherePos - u_translate, 1.0);
97
- } else {
98
- vec2 flatPos = f_onFlat(radCoord);
99
- gl_Position = u_projection * vec4(
100
- flatPos.x * u_scrWH.x,
101
- (1.0 - flatPos.y) * u_scrWH.y,
102
- 0.0, 1.0
103
- );
104
- }
105
-
106
-
107
- v_color = u_color;
108
- gl_PointSize = 4.0;
109
- }
110
- `;
111
-
112
-
113
- const arrowFragmentShader = `#version 300 es
114
- precision highp float;
115
- in vec4 v_color;
116
- out vec4 outColor;
117
-
118
- void main() {
119
- outColor = v_color;
120
- }
121
- `;
122
-
123
-
124
- export default class ArrowFieldLogic {
125
-
126
- constructor() {
127
- this.gl = null;
128
- this.globe = null;
129
- this.cameraUniformBlockTotem = null;
130
- this.program = null;
131
- this.cameraBlockBindingPoint = 0;
132
- this.arrayBlockBindingPoint = 1;
133
- }
134
-
135
- init(globe, gl) {
136
- this.gl = gl;
137
- this.globe = globe;
138
- this.cameraUniformBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
139
- this.program = this._createProgram();
140
- }
141
-
142
- _createProgram() {
143
- const gl = this.gl;
144
- const program = createProgram(gl, arrowVertexShader, arrowFragmentShader);
145
-
146
- const cameraBlockIndex = gl.getUniformBlockIndex(program, "CameraBlock");
147
- gl.uniformBlockBinding(program, cameraBlockIndex, this.cameraBlockBindingPoint);
148
-
149
-
150
-
151
- const arrowBlockIndex = gl.getUniformBlockIndex(program, "ArrowBlock");
152
- gl.uniformBlockBinding(program, arrowBlockIndex, this.arrayBlockBindingPoint);
153
-
154
- this.textureLocations = {
155
- rotationLocation: gl.getUniformLocation(program, "rotation"),
156
- }
157
-
158
- return program;
159
- }
160
-
161
- getArrowBlockBufferManager() {
162
- return new ArrowBlockBufferManager(this.gl, this.arrayBlockBindingPoint);
163
- }
164
-
165
- // initial load type is static.
166
- // after that, it is dynamic.
167
- getTextureManager(width, height) {
168
- return new TextureManager(this.gl, width, height, this.textureLocations);
169
- }
170
-
171
- draw(arrowBlockManager, textureManager, instanceCount) {
172
- const { gl, cameraBlockBindingPoint, cameraUniformBlockTotem } = this;
173
- gl.useProgram(this.program);
174
- arrowBlockManager.bind();
175
- textureManager.activate();
176
- cameraUniformBlockTotem.bind(cameraBlockBindingPoint);
177
- gl.drawArraysInstanced(gl.LINES, 0, 6, instanceCount);
178
- // gl.drawArraysInstanced(gl.POINTS, 0, 4, instanceCount);
179
- cameraUniformBlockTotem.unbind(cameraBlockBindingPoint);
180
- arrowBlockManager.unbind();
181
- }
182
-
183
- free() {
184
- const { gl, program } = this;
185
- gl.deleteProgram(program);
186
- globeProgramCache.releaseProgram(this.globe, CameraUniformBlockTotem);
187
- }
188
- }
189
-
190
-
191
- class ArrowBlockBufferManager {
192
- constructor(gl, bindingPoint) {
193
- this.gl = gl;
194
- this.bindingPoint = bindingPoint;
195
- this.ubo = gl.createBuffer();
196
- gl.bindBuffer(gl.UNIFORM_BUFFER, this.ubo);
197
- // 4 + 2+ 2 + 2 + 1 +1 +1 +1+1= 15 ~= 16
198
- gl.bufferData(gl.UNIFORM_BUFFER, 56, gl.DYNAMIC_DRAW);
199
- gl.bindBuffer(gl.UNIFORM_BUFFER, null);
200
- }
201
-
202
- update({
203
- color = null,
204
- bboxOffsetRad = null,
205
- bboxSizeRad = null,
206
- resolution = null,
207
- tailLengthRatio = null,
208
- wingLengthRatio = null,
209
- height = null,
210
- opacity = null,
211
- noDataValue = null,
212
- } = {}) {
213
- const { gl, ubo } = this;
214
- gl.bindBuffer(gl.UNIFORM_BUFFER, ubo);
215
- if (color !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 0, new Float32Array(color));
216
- if (opacity !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 12, new Float32Array([opacity]));
217
- if (bboxOffsetRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 16, new Float32Array(bboxOffsetRad));
218
- if (bboxSizeRad !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 24, new Float32Array(bboxSizeRad));
219
- if (resolution !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 32, new Float32Array(resolution));
220
- if (tailLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 40, new Float32Array([tailLengthRatio]));
221
- if (wingLengthRatio !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 44, new Float32Array([wingLengthRatio]));
222
- if (height !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 48, new Float32Array([height]));
223
- if (noDataValue !== null) gl.bufferSubData(gl.UNIFORM_BUFFER, 52, new Float32Array([noDataValue]));
224
- gl.bindBuffer(gl.UNIFORM_BUFFER, null);
225
- }
226
-
227
- bind() {
228
- const { gl, ubo, bindingPoint } = this;
229
- gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, ubo);
230
- }
231
-
232
- unbind() {
233
- const { gl, bindingPoint } = this;
234
- gl.bindBufferBase(gl.UNIFORM_BUFFER, bindingPoint, null);
235
- }
236
-
237
- free() {
238
- const { gl, ubo } = this;
239
- gl.deleteBuffer(ubo);
240
- }
241
- }
242
-
243
- class TextureManager {
244
-
245
- constructor(gl, width, height, { rotationLocation }) {
246
- this.gl = gl;
247
- this.width = width;
248
- this.height = height;
249
- this.rotationLocation = rotationLocation;
250
- this.rotationTexture = this._createFloatTexture();
251
- }
252
-
253
- _createFloatTexture() {
254
- const { gl, width, height } = this;
255
- const texture = gl.createTexture();
256
- gl.bindTexture(gl.TEXTURE_2D, texture);
257
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
258
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
259
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, null);
260
- gl.bindTexture(gl.TEXTURE_2D, null);
261
- return texture;
262
- }
263
-
264
- setData(rotation) {
265
- const { gl, rotationTexture, width, height } = this;
266
- // gl flip y axis
267
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
268
- gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
269
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.R32F, width, height, 0, gl.RED, gl.FLOAT, rotation);
270
- gl.bindTexture(gl.TEXTURE_2D, null);
271
- gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
272
- }
273
-
274
- activate() {
275
- const { gl, rotationTexture } = this;
276
-
277
- gl.activeTexture(gl.TEXTURE0);
278
- gl.bindTexture(gl.TEXTURE_2D, rotationTexture);
279
- gl.uniform1i(this.rotationLocation, 0);
280
- }
281
-
282
- free() {
283
- const { gl, rotationTexture } = this;
284
- gl.deleteTexture(rotationTexture);
285
- }
286
- }