@pirireis/webglobeplugins 1.0.2 → 1.0.4

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 (277) hide show
  1. package/package.json +2 -2
  2. package/plugins/alarms/alarmFadeInFadeOutPlugin/AlarmTimeLineFadeInFadeOutPlugin.js +399 -0
  3. package/{Math/angle-calculation.ts → webglobeplugins/Math/angle-calculation.js} +14 -18
  4. package/{Math/arc-cdf-points.ts → webglobeplugins/Math/arc-cdf-points.js} +272 -329
  5. package/{Math/arc-generate-points-exponantial.ts → webglobeplugins/Math/arc-generate-points-exponantial.js} +254 -299
  6. package/{Math/arc.ts → webglobeplugins/Math/arc.js} +292 -421
  7. package/{Math → webglobeplugins/Math}/bounds/line-bbox.js +186 -225
  8. package/{Math/circle-cdf-points.ts → webglobeplugins/Math/circle-cdf-points.js} +78 -143
  9. package/{Math/circle.ts → webglobeplugins/Math/circle.js} +33 -49
  10. package/{Math/constants.ts → webglobeplugins/Math/constants.js} +4 -12
  11. package/{Math/contour/quadtreecontours.ts → webglobeplugins/Math/contour/quadtreecontours.js} +300 -371
  12. package/{Math → webglobeplugins/Math}/contour/quadtreecontours1.js +298 -336
  13. package/{Math/finite-line-2d.ts → webglobeplugins/Math/finite-line-2d.js} +58 -68
  14. package/{Math/haversine.ts → webglobeplugins/Math/haversine.js} +22 -33
  15. package/webglobeplugins/Math/index.js +1 -0
  16. package/{Math/juction/arc-plane.ts → webglobeplugins/Math/juction/arc-plane.js} +143 -203
  17. package/{Math/juction/line-sphere.ts → webglobeplugins/Math/juction/line-sphere.js} +22 -32
  18. package/{Math/juction/plane-plane.ts → webglobeplugins/Math/juction/plane-plane.js} +53 -62
  19. package/{Math/line.ts → webglobeplugins/Math/line.js} +52 -84
  20. package/webglobeplugins/Math/matrix4.js +1 -0
  21. package/{Math/methods.ts → webglobeplugins/Math/methods.js} +126 -182
  22. package/{Math/plane.ts → webglobeplugins/Math/plane.js} +56 -92
  23. package/{Math/quaternion.ts → webglobeplugins/Math/quaternion.js} +106 -128
  24. package/{Math/templete-shapes/grid-visually-equal.ts → webglobeplugins/Math/templete-shapes/grid-visually-equal.js} +65 -118
  25. package/webglobeplugins/Math/tessellation/constants.js +1 -0
  26. package/{Math/tessellation/methods.ts → webglobeplugins/Math/tessellation/methods.js} +49 -79
  27. package/{Math/tessellation/nearest-value-padding.ts → webglobeplugins/Math/tessellation/nearest-value-padding.js} +112 -147
  28. package/{Math/tessellation/spherical-triangle-area.ts → webglobeplugins/Math/tessellation/spherical-triangle-area.js} +99 -127
  29. package/{Math/tessellation/tile-merger.ts → webglobeplugins/Math/tessellation/tile-merger.js} +429 -578
  30. package/{Math/tessellation/triangle-tessellation.ts → webglobeplugins/Math/tessellation/triangle-tessellation.js} +464 -533
  31. package/webglobeplugins/Math/tessellation/types.js +1 -0
  32. package/webglobeplugins/Math/types.js +1 -0
  33. package/{Math → webglobeplugins/Math}/utils.js +2 -3
  34. package/{Math/vec3.ts → webglobeplugins/Math/vec3.js} +155 -227
  35. package/{Math/xyz-tile.ts → webglobeplugins/Math/xyz-tile.js} +18 -26
  36. package/{algorithms → webglobeplugins/algorithms}/search-binary.js +16 -14
  37. package/webglobeplugins/altitude-locator/adaptors.js +1 -0
  38. package/webglobeplugins/altitude-locator/keymethod.js +1 -0
  39. package/{altitude-locator → webglobeplugins/altitude-locator}/plugin.js +344 -445
  40. package/{altitude-locator → webglobeplugins/altitude-locator}/types.js +21 -26
  41. package/{compass-rose → webglobeplugins/compass-rose}/compass-rose-padding-flat.js +230 -274
  42. package/{compass-rose/compass-text-writer.ts → webglobeplugins/compass-rose/compass-text-writer.js} +155 -210
  43. package/{compass-rose → webglobeplugins/compass-rose}/index.js +3 -3
  44. package/{constants.ts → webglobeplugins/constants.js} +6 -8
  45. package/{heatwave → webglobeplugins/heatwave}/datamanager.js +149 -168
  46. package/{heatwave → webglobeplugins/heatwave}/heatwave.js +206 -261
  47. package/{heatwave → webglobeplugins/heatwave}/index.js +5 -5
  48. package/{heatwave → webglobeplugins/heatwave}/isobar.js +306 -340
  49. package/{heatwave/texture-point-sampler.ts → webglobeplugins/heatwave/texture-point-sampler.js} +187 -220
  50. package/webglobeplugins/investigation-tools/draw/tiles/adapters.js +67 -0
  51. package/{investigation-tools/draw/tiles/tiles.ts → webglobeplugins/investigation-tools/draw/tiles/tiles.js} +128 -162
  52. package/{jest.config.js → webglobeplugins/jest.config.js} +7 -6
  53. package/{pin → webglobeplugins/pin}/pin-object-array1.js +300 -381
  54. package/{pin → webglobeplugins/pin}/pin-point-totem1.js +60 -77
  55. package/{programs → webglobeplugins/programs}/arrowfield/arrow-field.js +60 -89
  56. package/{programs → webglobeplugins/programs}/arrowfield/logic.js +141 -173
  57. package/{programs → webglobeplugins/programs}/data2legend/density-to-legend.js +68 -86
  58. package/{programs → webglobeplugins/programs}/data2legend/point-to-density-texture.js +67 -84
  59. package/{programs → webglobeplugins/programs}/float2legendwithratio/index.js +2 -3
  60. package/{programs → webglobeplugins/programs}/float2legendwithratio/logic.js +118 -144
  61. package/{programs → webglobeplugins/programs}/float2legendwithratio/object.js +104 -141
  62. package/{programs → webglobeplugins/programs}/helpers/blender.js +58 -73
  63. package/{programs/helpers/fadeaway.ts → webglobeplugins/programs/helpers/fadeaway.js} +60 -73
  64. package/{programs → webglobeplugins/programs}/index.js +20 -19
  65. package/{programs → webglobeplugins/programs}/line-on-globe/circle-accurate-3d.js +85 -112
  66. package/{programs → webglobeplugins/programs}/line-on-globe/circle-accurate-flat.js +148 -200
  67. package/{programs → webglobeplugins/programs}/line-on-globe/degree-padding-around-circle-3d.js +102 -134
  68. package/webglobeplugins/programs/line-on-globe/index.js +1 -0
  69. package/{programs → webglobeplugins/programs}/line-on-globe/lines-color-instanced-flat.js +80 -99
  70. package/webglobeplugins/programs/line-on-globe/linestrip/data.js +4 -0
  71. package/{programs/line-on-globe/linestrip/linestrip.ts → webglobeplugins/programs/line-on-globe/linestrip/linestrip.js} +93 -152
  72. package/{programs/line-on-globe/naive-accurate-flexible.ts → webglobeplugins/programs/line-on-globe/naive-accurate-flexible.js} +126 -175
  73. package/{programs → webglobeplugins/programs}/line-on-globe/util.js +5 -8
  74. package/{programs → webglobeplugins/programs}/picking/pickable-polygon-renderer.js +98 -129
  75. package/{programs → webglobeplugins/programs}/picking/pickable-renderer.js +98 -130
  76. package/{programs → webglobeplugins/programs}/point-on-globe/element-globe-surface-glow.js +93 -122
  77. package/{programs → webglobeplugins/programs}/point-on-globe/element-point-glow.js +80 -114
  78. package/{programs → webglobeplugins/programs}/point-on-globe/square-pixel-point.js +121 -139
  79. package/{programs/polygon-on-globe/texture-dem-triangles.ts → webglobeplugins/programs/polygon-on-globe/texture-dem-triangles.js} +178 -209
  80. package/{programs/programcache.ts → webglobeplugins/programs/programcache.js} +126 -134
  81. package/webglobeplugins/programs/rings/index.js +1 -0
  82. package/{programs/rings/partial-ring/piece-of-pie.ts → webglobeplugins/programs/rings/partial-ring/piece-of-pie.js} +152 -222
  83. package/webglobeplugins/programs/totems/attachments/adaptive-opacity.js +131 -0
  84. package/{programs/totems/dem-textures-manager.ts → webglobeplugins/programs/totems/attachments/dem-textures-manager.js} +263 -360
  85. package/webglobeplugins/programs/totems/camera-totem-attactment-interface.js +1 -0
  86. package/{programs/totems/camerauniformblock.ts → webglobeplugins/programs/totems/camerauniformblock.js} +225 -310
  87. package/{programs/totems/canvas-webglobe-info.ts → webglobeplugins/programs/totems/canvas-webglobe-info.js} +132 -147
  88. package/{programs/totems/globe-changes.ts → webglobeplugins/programs/totems/globe-changes.js} +59 -79
  89. package/{programs → webglobeplugins/programs}/totems/gpu-selection-uniform-block.js +99 -127
  90. package/{programs/totems/index.ts → webglobeplugins/programs/totems/index.js} +2 -2
  91. package/{programs → webglobeplugins/programs}/two-d/pixel-padding-for-compass.js +87 -101
  92. package/{programs → webglobeplugins/programs}/util.js +14 -19
  93. package/{programs/vectorfields/logics/constants.ts → webglobeplugins/programs/vectorfields/logics/constants.js} +4 -5
  94. package/{programs/vectorfields/logics/drawrectangleparticles.ts → webglobeplugins/programs/vectorfields/logics/drawrectangleparticles.js} +107 -136
  95. package/{programs → webglobeplugins/programs}/vectorfields/logics/index.js +2 -4
  96. package/webglobeplugins/programs/vectorfields/logics/particle-ubo.js +19 -0
  97. package/{programs/vectorfields/logics/pixelbased.ts → webglobeplugins/programs/vectorfields/logics/pixelbased.js} +89 -122
  98. package/{programs → webglobeplugins/programs}/vectorfields/logics/ubo.js +51 -57
  99. package/{programs/vectorfields/pingpongbuffermanager.ts → webglobeplugins/programs/vectorfields/pingpongbuffermanager.js} +99 -113
  100. package/{range-tools-on-terrain/bearing-line/adapters.ts → webglobeplugins/range-tools-on-terrain/bearing-line/adapters.js} +114 -154
  101. package/{range-tools-on-terrain/bearing-line/plugin.ts → webglobeplugins/range-tools-on-terrain/bearing-line/plugin.js} +457 -569
  102. package/webglobeplugins/range-tools-on-terrain/bearing-line/types.js +1 -0
  103. package/{range-tools-on-terrain/circle-line-chain/adapters.ts → webglobeplugins/range-tools-on-terrain/circle-line-chain/adapters.js} +85 -104
  104. package/{range-tools-on-terrain/circle-line-chain/chain-list-map.ts → webglobeplugins/range-tools-on-terrain/circle-line-chain/chain-list-map.js} +382 -446
  105. package/{range-tools-on-terrain/circle-line-chain/plugin.ts → webglobeplugins/range-tools-on-terrain/circle-line-chain/plugin.js} +464 -607
  106. package/webglobeplugins/range-tools-on-terrain/circle-line-chain/types.js +1 -0
  107. package/{range-tools-on-terrain/range-ring/adapters.ts → webglobeplugins/range-tools-on-terrain/range-ring/adapters.js} +93 -114
  108. package/{range-tools-on-terrain/range-ring/enum.ts → webglobeplugins/range-tools-on-terrain/range-ring/enum.js} +2 -2
  109. package/{range-tools-on-terrain/range-ring/plugin.ts → webglobeplugins/range-tools-on-terrain/range-ring/plugin.js} +377 -444
  110. package/webglobeplugins/range-tools-on-terrain/range-ring/rangeringangletext.js +331 -0
  111. package/webglobeplugins/range-tools-on-terrain/range-ring/types.js +9 -0
  112. package/webglobeplugins/semiplugins/interface.js +1 -0
  113. package/{semiplugins/lightweight/line-plugin.ts → webglobeplugins/semiplugins/lightweight/line-plugin.js} +221 -342
  114. package/{semiplugins/lightweight/piece-of-pie-plugin.ts → webglobeplugins/semiplugins/lightweight/piece-of-pie-plugin.js} +200 -275
  115. package/{semiplugins/shape-on-terrain/arc-plugin.ts → webglobeplugins/semiplugins/shape-on-terrain/arc-plugin.js} +481 -616
  116. package/{semiplugins/shape-on-terrain/circle-plugin.ts → webglobeplugins/semiplugins/shape-on-terrain/circle-plugin.js} +444 -588
  117. package/{semiplugins/shape-on-terrain/padding-1-degree.ts → webglobeplugins/semiplugins/shape-on-terrain/padding-1-degree.js} +539 -713
  118. package/{semiplugins/shape-on-terrain/terrain-polygon/adapters.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/adapters.js} +55 -69
  119. package/{semiplugins/shape-on-terrain/terrain-polygon/data/cache.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/cache.js} +104 -149
  120. package/{semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.js} +45 -58
  121. package/{semiplugins/shape-on-terrain/terrain-polygon/data/manager.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/manager.js} +4 -4
  122. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +241 -0
  123. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.js +76 -0
  124. package/{semiplugins/shape-on-terrain/terrain-polygon/data/random.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/random.js} +121 -165
  125. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/types.js +1 -0
  126. package/{semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.js} +64 -81
  127. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +162 -0
  128. package/{semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.ts → webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.js} +282 -265
  129. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/test-records.js +14 -0
  130. package/webglobeplugins/semiplugins/shape-on-terrain/terrain-polygon/types.js +8 -0
  131. package/webglobeplugins/semiplugins/shell/bbox-renderer/index.js +2 -0
  132. package/{semiplugins/shell/bbox-renderer/logic.ts → webglobeplugins/semiplugins/shell/bbox-renderer/logic.js} +209 -273
  133. package/webglobeplugins/semiplugins/shell/bbox-renderer/object.js +78 -0
  134. package/webglobeplugins/semiplugins/type.js +1 -0
  135. package/{semiplugins/utility/container-plugin.ts → webglobeplugins/semiplugins/utility/container-plugin.js} +94 -126
  136. package/{semiplugins/utility/object-pass-container-plugin.ts → webglobeplugins/semiplugins/utility/object-pass-container-plugin.js} +80 -101
  137. package/{shaders → webglobeplugins/shaders}/fragment-toy/firework.js +1 -1
  138. package/{shaders → webglobeplugins/shaders}/fragment-toy/singularity.js +2 -5
  139. package/{tracks → webglobeplugins/tracks}/point-heat-map/adaptors/timetracksplugin-format-to-this.js +63 -78
  140. package/webglobeplugins/tracks/point-heat-map/index.js +1 -0
  141. package/{tracks → webglobeplugins/tracks}/point-heat-map/plugin-webworker.js +121 -148
  142. package/{tracks → webglobeplugins/tracks}/point-heat-map/point-to-heat-map-flow.js +121 -150
  143. package/{tracks → webglobeplugins/tracks}/point-tracks/key-methods.js +2 -3
  144. package/{tracks → webglobeplugins/tracks}/point-tracks/plugin.js +401 -487
  145. package/{tracks → webglobeplugins/tracks}/timetracks/adaptors-line-strip.js +65 -79
  146. package/{tracks → webglobeplugins/tracks}/timetracks/plugin-line-strip.js +240 -295
  147. package/{tracks → webglobeplugins/tracks}/timetracks/program-line-strip.js +413 -495
  148. package/{tracks → webglobeplugins/tracks}/timetracks/programpoint-line-strip.js +109 -137
  149. package/webglobeplugins/types.js +19 -0
  150. package/{util → webglobeplugins/util}/account/bufferoffsetmanager.js +176 -209
  151. package/webglobeplugins/util/account/create-buffermap-orchastration.js +39 -0
  152. package/{util → webglobeplugins/util}/account/index.js +3 -6
  153. package/{util/account/single-attribute-buffer-management/buffer-manager.ts → webglobeplugins/util/account/single-attribute-buffer-management/buffer-manager.js} +119 -151
  154. package/{util/account/single-attribute-buffer-management/buffer-orchestrator.ts → webglobeplugins/util/account/single-attribute-buffer-management/buffer-orchestrator.js} +212 -238
  155. package/{util/account/single-attribute-buffer-management/buffer-orchestrator1.ts → webglobeplugins/util/account/single-attribute-buffer-management/buffer-orchestrator1.js} +159 -184
  156. package/{util/account/single-attribute-buffer-management/index.ts → webglobeplugins/util/account/single-attribute-buffer-management/index.js} +4 -11
  157. package/{util/account/single-attribute-buffer-management/object-store.ts → webglobeplugins/util/account/single-attribute-buffer-management/object-store.js} +55 -76
  158. package/webglobeplugins/util/account/single-attribute-buffer-management/types.js +1 -0
  159. package/{util → webglobeplugins/util}/account/util.js +18 -22
  160. package/webglobeplugins/util/algorithms/index.js +1 -0
  161. package/{util → webglobeplugins/util}/algorithms/search-binary.js +25 -26
  162. package/{util/build-strategy/static-dynamic.ts → webglobeplugins/util/build-strategy/static-dynamic.js} +41 -50
  163. package/webglobeplugins/util/check/index.js +1 -0
  164. package/webglobeplugins/util/check/typecheck.js +66 -0
  165. package/{util/frame-counter-trigger.ts → webglobeplugins/util/frame-counter-trigger.js} +84 -99
  166. package/{util/geometry/index.ts → webglobeplugins/util/geometry/index.js} +121 -155
  167. package/webglobeplugins/util/gl-util/buffer/attribute-loader.js +74 -0
  168. package/{util/gl-util/buffer/index.ts → webglobeplugins/util/gl-util/buffer/index.js} +3 -6
  169. package/{util/gl-util/draw-options/methods.ts → webglobeplugins/util/gl-util/draw-options/methods.js} +32 -47
  170. package/{util/gl-util/uniform-block/manager.ts → webglobeplugins/util/gl-util/uniform-block/manager.js} +209 -232
  171. package/{util/globe-default-gl-states.ts → webglobeplugins/util/globe-default-gl-states.js} +4 -5
  172. package/{util/helper-methods.ts → webglobeplugins/util/helper-methods.js} +8 -9
  173. package/{util → webglobeplugins/util}/index.js +10 -9
  174. package/webglobeplugins/util/interpolation/index.js +1 -0
  175. package/webglobeplugins/util/interpolation/timetrack/index.js +2 -0
  176. package/{util → webglobeplugins/util}/interpolation/timetrack/timetrack-interpolator.js +79 -94
  177. package/{util → webglobeplugins/util}/interpolation/timetrack/web-worker.js +46 -51
  178. package/{util/picking/fence.ts → webglobeplugins/util/picking/fence.js} +43 -47
  179. package/{util/picking/picker-displayer.ts → webglobeplugins/util/picking/picker-displayer.js} +176 -226
  180. package/{util → webglobeplugins/util}/programs/draw-from-pixel-coords.js +164 -201
  181. package/{util/programs/draw-texture-on-canvas.ts → webglobeplugins/util/programs/draw-texture-on-canvas.js} +69 -91
  182. package/{util → webglobeplugins/util}/programs/supersampletotextures.js +97 -130
  183. package/{util/programs/texturetoglobe.js → webglobeplugins/util/programs/texturetoglobe_delete.js} +128 -153
  184. package/{util/shaderfunctions/geometrytransformations.ts → webglobeplugins/util/shaderfunctions/geometrytransformations.js} +44 -106
  185. package/{util → webglobeplugins/util}/shaderfunctions/index.js +2 -2
  186. package/{util → webglobeplugins/util}/shaderfunctions/nodata.js +2 -4
  187. package/{util → webglobeplugins/util}/shaderfunctions/noisefunctions.js +7 -10
  188. package/{util/webglobjectbuilders.ts → webglobeplugins/util/webglobjectbuilders.js} +358 -446
  189. package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/adaptor.js +11 -11
  190. package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/index.js +3 -3
  191. package/{vectorfield → webglobeplugins/vectorfield}/arrowfield/plugin.js +83 -128
  192. package/{vectorfield → webglobeplugins/vectorfield}/waveparticles/adaptor.js +15 -16
  193. package/{vectorfield → webglobeplugins/vectorfield}/waveparticles/index.js +3 -3
  194. package/{vectorfield/waveparticles/plugin.ts → webglobeplugins/vectorfield/waveparticles/plugin.js} +455 -506
  195. package/webglobeplugins/vectorfield/wind/adapters/image-to-fields.js +92 -0
  196. package/webglobeplugins/vectorfield/wind/adapters/types.js +1 -0
  197. package/{vectorfield/wind/imagetovectorfieldandmagnitude.ts → webglobeplugins/vectorfield/wind/imagetovectorfieldandmagnitude.js} +53 -78
  198. package/{vectorfield → webglobeplugins/vectorfield}/wind/index.js +5 -5
  199. package/{vectorfield/wind/plugin-persistant.ts → webglobeplugins/vectorfield/wind/plugin-persistant.js} +390 -483
  200. package/{vectorfield → webglobeplugins/vectorfield}/wind/plugin.js +685 -883
  201. package/{vectorfield → webglobeplugins/vectorfield}/wind/vectorfieldimage.js +23 -27
  202. package/{write-text/context-text-bulk.ts → webglobeplugins/write-text/context-text-bulk.js} +200 -285
  203. package/webglobeplugins/write-text/context-text3.js +167 -0
  204. package/{write-text/context-text4.ts → webglobeplugins/write-text/context-text4.js} +146 -231
  205. package/{write-text → webglobeplugins/write-text}/context-textDELETE.js +94 -125
  206. package/{write-text/objectarraylabels/index.ts → webglobeplugins/write-text/objectarraylabels/index.js} +2 -2
  207. package/{write-text → webglobeplugins/write-text}/objectarraylabels/objectarraylabels.js +200 -247
  208. package/Math/index.js +0 -0
  209. package/Math/matrix4.ts +0 -0
  210. package/Math/mesh/mapbox-delaunay.d.ts +0 -74
  211. package/Math/roadmap.md +0 -10
  212. package/Math/tessellation/constants.ts +0 -1
  213. package/Math/tessellation/roadmap.md +0 -48
  214. package/Math/tessellation/types.ts +0 -1
  215. package/Math/types.ts +0 -68
  216. package/altitude-locator/adaptors.js +0 -0
  217. package/altitude-locator/keymethod.js +0 -0
  218. package/investigation-tools/draw/tiles/adapters.ts +0 -133
  219. package/programs/line-on-globe/index.js +0 -0
  220. package/programs/line-on-globe/linestrip/data.ts +0 -29
  221. package/programs/polygon-on-globe/roadmap.md +0 -8
  222. package/programs/rings/index.js +0 -1
  223. package/programs/totems/camera-totem-attactment-interface.ts +0 -4
  224. package/programs/vectorfields/logics/particle-ubo.ts +0 -23
  225. package/publish.bat +0 -62
  226. package/range-tools-on-terrain/bearing-line/types.ts +0 -65
  227. package/range-tools-on-terrain/circle-line-chain/types.ts +0 -43
  228. package/range-tools-on-terrain/range-ring/rangeringangletext.ts +0 -396
  229. package/range-tools-on-terrain/range-ring/types.ts +0 -30
  230. package/semiplugins/interface.ts +0 -14
  231. package/semiplugins/shape-on-terrain/goal.md +0 -12
  232. package/semiplugins/shape-on-terrain/terrain-polygon/data/cache-shortcuts.md +0 -20
  233. package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +0 -196
  234. package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.ts +0 -209
  235. package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.ts +0 -144
  236. package/semiplugins/shape-on-terrain/terrain-polygon/data/readme.md +0 -5
  237. package/semiplugins/shape-on-terrain/terrain-polygon/data/types.ts +0 -37
  238. package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +0 -146
  239. package/semiplugins/shape-on-terrain/terrain-polygon/notes.md +0 -90
  240. package/semiplugins/shape-on-terrain/terrain-polygon/types.ts +0 -69
  241. package/semiplugins/shell/bbox-renderer/index.ts +0 -2
  242. package/semiplugins/shell/bbox-renderer/object.ts +0 -129
  243. package/semiplugins/type.ts +0 -8
  244. package/terrain-plugin.mmd +0 -83
  245. package/tests/Math/arc-sampling-test.js +0 -367
  246. package/tests/Math/arc-sampling-test.ts +0 -429
  247. package/tests/Math/arc.test.ts +0 -77
  248. package/tests/Math/junction/arc-limit.test.ts +0 -7
  249. package/tests/Math/junction/arc-plane-points.test.ts +0 -196
  250. package/tests/Math/junction/arc-plane.test.ts +0 -172
  251. package/tests/Math/junction/line-sphere.test.ts +0 -127
  252. package/tests/Math/junction/plane-plane.test.ts +0 -91
  253. package/tests/Math/plane-test.ts +0 -17
  254. package/tests/Math/plane.test.ts +0 -43
  255. package/tests/Math/vec3.test.ts +0 -33
  256. package/tracks/point-heat-map/index.js +0 -0
  257. package/tracks/point-heat-map/readme.md +0 -15
  258. package/tracks/timetracks/readme.md +0 -1
  259. package/tsconfig.json +0 -22
  260. package/types/@pirireis/webglobe.d.ts +0 -102
  261. package/types/delaunator.d.ts +0 -40
  262. package/types/earcut.d.ts +0 -11
  263. package/types/rbush.d.ts +0 -57
  264. package/types.ts +0 -319
  265. package/util/account/create-buffermap-orchastration.ts +0 -85
  266. package/util/account/single-attribute-buffer-management/types.ts +0 -43
  267. package/util/algorithms/index.js +0 -0
  268. package/util/check/index.js +0 -0
  269. package/util/check/typecheck.ts +0 -74
  270. package/util/gl-util/buffer/attribute-loader.ts +0 -84
  271. package/util/interpolation/index.js +0 -0
  272. package/util/interpolation/timetrack/index.js +0 -9
  273. package/vectorfield/wind/adapters/image-to-fields.ts +0 -74
  274. package/vectorfield/wind/adapters/types.ts +0 -12
  275. package/vectorfield/wind/plugin-persistant copy.ts +0 -461
  276. package/write-text/context-text3.ts +0 -252
  277. package/write-text/objectarraylabels/objectarraylabels.d.ts +0 -72
@@ -1,616 +1,481 @@
1
- import { SemiPluginInterface, } from "../interface";
2
- import { Vec3, LongLat, Arc } from "../../Math/types";
3
- import { Globe, Meter, UBOHandler, PluginInterface, Color, Radian, BUFFER_TYPE, ElevationMode, GlobeChanges, UpdateColor } from "../../types";
4
- // import { ArcOnTerrainPluginOptions } from "./type";
5
- import { LineStripProgramCache, LineProgram } from "../../programs/line-on-globe/linestrip/linestrip";
6
- import { createBufferAndReadInfo } from "../../util/gl-util/buffer/attribute-loader";
7
- import { BufferManagersMap, BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
8
- import { globe3Dcoordinates, globe2Dcoordinates, RADIAN } from "../../Math/methods";
9
- import { generateArcPoints, evenlySpacedArcPoints } from "../../Math/arc-cdf-points";
10
- import { StaticDynamicState, StaticDynamicStrategy } from "../../util/build-strategy/static-dynamic";
11
- import { opacityCheck } from "../../util/check/typecheck";
12
- import { FrameCounterTrigger } from "../../util/frame-counter-trigger";
13
- import * as vec3 from "../../Math/vec3";
14
-
15
- import * as arc from "../../Math/arc";
16
-
17
- import { CameraUniformBlockTotem, CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
18
- import { WORLD_RADIUS_3D } from "../../Math/constants";
19
-
20
-
21
- const DYNAMIC_STRATEGY_START_LOD = 12;
22
-
23
- const INITAL_CAPACITY = 10;
24
- const _attractionPoint = [0, 0, 0] as Vec3;
25
- const _start = [0, 0, 0] as Vec3;
26
- const _end = [0, 0, 0] as Vec3;
27
- const _0arc = arc.create([1, 0, 0] as Vec3, [0, 1, 0] as Vec3); // zero arc for intersection tests
28
-
29
-
30
- export type ArcOnTerrainPluginOptions = {
31
- variativeColorsOn: boolean; // If true, arcs can have variative colors
32
- defaultColor: Color; // Default color in RGBA format
33
- defaultHeightFromGroundIn3D: Meter; // Default height from ground in 3D view
34
- flatViewOn: boolean; // If true, arcs are drawn in 2D flat view
35
- globeViewOn: boolean; // If true, arcs are drawn in 3D globe view
36
- // variativeColorsOn: boolean; // If true, arcs can have variative colors
37
- // defaultColor: [number, number, number, number]; // Default color in RGBA format
38
- // defaultHeightFromGroundIn3D: number; // Default height from ground in 3D view
39
- vertexCount: number; // Number of vertices per arc,
40
- cameraAttractionIsOn: boolean; // If true, camera attraction is enabled else evenly distributed arc points are used
41
- bufferType?: BUFFER_TYPE; // Buffer type for WebGL
42
- isMSL: boolean; // If true, the arc is drawn in MSL (Mean Sea Level) mode
43
- };
44
-
45
-
46
- export type ArcInput = {
47
- key: string,
48
- start: LongLat,
49
- end: LongLat,
50
- color: Color, // 0-1
51
- height?: Meter | null // height from ground in 3D view, null for default
52
- msl?: boolean | null
53
- }
54
-
55
-
56
- function createArc(start: LongLat, end: LongLat): Arc {
57
- vec3.fromLongLatToUnitVector(_start, [start[0] * RADIAN, start[1] * RADIAN]);
58
- vec3.fromLongLatToUnitVector(_end, [end[0] * RADIAN, end[1] * RADIAN]);
59
- return arc.create(_start, _end);
60
- }
61
- export class ArcOnTerrainPlugin implements PluginInterface, SemiPluginInterface, ElevationMode, UpdateColor {
62
- public id: string;
63
- private program: LineProgram | null = null;
64
- private bufferManagersMap: BufferManagersMap | null = null;
65
- private bufferOrchestrator: BufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
66
- private _opacity: number = 1;
67
- private _arcUBOHandler: UBOHandler | null = null;
68
- private _vao: WebGLVertexArrayObject | null = null;
69
- globe: any | null = null;
70
- private gl: WebGL2RenderingContext | null = null;
71
- private _arcMap: Map<string, [Arc, ArcInput]>;
72
- private _cameraUniformBlock: CameraUniformBlockTotem | null = null;
73
- private _staticDynamicStrategy: StaticDynamicStrategy | null = null;
74
- private _options: ArcOnTerrainPluginOptions;
75
- private _coordinaateBufferKeysForUpdate: string[] = [];
76
- private _freed: boolean = false;
77
- private _frameCounterTrigger: FrameCounterTrigger | null = null;
78
- constructor(id: string, {
79
- globeViewOn = true, // If true, arcs are drawn in 3D globe view
80
- flatViewOn = true, // If true, arcs are drawn in 2D flat view
81
- variativeColorsOn = false,
82
- defaultColor = [0.1, 0.1, 1, 1], // Default color in RGBA format
83
- defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
84
- vertexCount = 70, // Number of vertices per arc
85
- cameraAttractionIsOn = true, // If true, camera attraction is enabled else evenly distributed arc points are used
86
- bufferType = "STREAM_DRAW",
87
- isMSL = false
88
- }: Partial<ArcOnTerrainPluginOptions> = {}) {
89
- this.id = id;
90
- this._arcMap = new Map();
91
- this._options = {
92
- globeViewOn: globeViewOn ? true : false,
93
- flatViewOn: flatViewOn ? true : false,
94
- variativeColorsOn: variativeColorsOn ? true : false,
95
- defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
96
- defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
97
- vertexCount: vertexCount ? vertexCount : 70,
98
- cameraAttractionIsOn: cameraAttractionIsOn ? true : false,
99
- bufferType: bufferType ? bufferType : "STREAM_DRAW",
100
- isMSL: isMSL ? true : false
101
- };
102
-
103
- }
104
-
105
- increaseSpace(amount: number): void {
106
- if (this._freed) {
107
- console.warn("Plugin is freed, cannot increase space");
108
- return;
109
- }
110
- if (this.globe === null) {
111
- console.warn("Globe is not initialized.");
112
- return;
113
- }
114
- if (typeof amount !== "number" || amount <= 0) {
115
- console.warn("Invalid amount, must be a positive number");
116
- return;
117
- }
118
- this.bufferOrchestrator.ensureSpace(amount, this.bufferManagersMap!);
119
- }
120
-
121
- insertBulk(arcs: ArcInput[]) {
122
- const keys = [];
123
- let newItemCount = 0;
124
- for (let arcInput of arcs) {
125
- const { key, start, end } = arcInput;
126
- if (this._arcMap.has(key)) {
127
- this._arcMap.delete(key); // Remove old arc
128
- } else {
129
- newItemCount++;
130
- }
131
- const _arc = createArc(start, end);
132
- this._arcMap.set(key, [_arc, arcInput]); // Always set new color
133
- keys.push(key);
134
- }
135
- this.bufferOrchestrator.ensureSpace(newItemCount, this.bufferManagersMap!);
136
- this._buildArcs(keys);
137
- if (this._options.variativeColorsOn) {
138
- this.__fillColors(keys);
139
- }
140
- this.globe.DrawRender();
141
- }
142
-
143
-
144
- updateCoordinates(items: Pick<ArcInput, "key" | "start" | "end">[]): void {
145
- if (this._freed) {
146
- console.warn("Plugin is freed, cannot update coordinates");
147
- return;
148
- }
149
- if (this.globe === null || this.gl === null) {
150
- console.warn("Globe or WebGL context is not initialized, cannot update coordinates");
151
- return;
152
- }
153
- const updateKeys = []
154
- for (const { key, start, end } of items) {
155
- const arcInput = this._arcMap.get(key);
156
- if (!arcInput) {
157
- console.warn(`Arc with key ${key} not found in arcMap.`);
158
- continue;
159
- }
160
- const _arc = createArc(start, end);
161
- arc.copy(arcInput[0], _arc); // Update the arc in the map
162
- // Update the arc in the buffer
163
- updateKeys.push(key);
164
- }
165
- this._buildArcs(updateKeys);
166
-
167
- this.globe.DrawRender();
168
- }
169
-
170
-
171
- deleteBulk(keys: string[]) {
172
- if (!this.bufferOrchestrator || !this.bufferManagersMap || !this.globe) {
173
- console.warn("Buffer orchestrator or buffer manager map is not initialized.");
174
- return;
175
- }
176
- for (const key of keys) {
177
- if (this._arcMap.has(key)) {
178
- this._arcMap.delete(key);
179
- } else {
180
- console.warn(`Arc with key ${key} not found in arcMap.`);
181
- }
182
- }
183
- this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
184
- this.globe.DrawRender();
185
- }
186
-
187
-
188
- deleteAll() {
189
- if (!this.bufferOrchestrator || !this.bufferManagersMap || !this.globe) {
190
- console.warn("Buffer orchestrator or buffer manager map is not initialized.");
191
- return;
192
- }
193
- this.bufferOrchestrator.resetWithCapacity(this.bufferManagersMap, this._arcMap.size);
194
- this._arcMap.clear();
195
- this.globe.DrawRender();
196
- }
197
-
198
-
199
-
200
- updateColors(keyColorCouples: { key: string, color: Color }[], drawRender: boolean = true) {
201
- if (this._freed) {
202
- console.warn("Plugin is freed, cannot update color");
203
- return;
204
- }
205
- if (this._options.variativeColorsOn === false) {
206
- console.warn("Variative colors are not enabled in this plugin. Create another instance with variativeColorsOn: true to use this feature.");
207
- return;
208
- }
209
-
210
- const { bufferOrchestrator, bufferManagersMap } = this;
211
- if (!bufferOrchestrator || !bufferManagersMap) {
212
- console.warn("Buffer orchestrator or buffer manager map is not initialized.");
213
- return;
214
- }
215
-
216
- for (const { key, color } of keyColorCouples) {
217
-
218
- const arcInput = this._arcMap.get(key)
219
- if (!arcInput) {
220
- console.warn(`Arc with key ${key} not found in arcMap.`);
221
- return;
222
- }
223
-
224
- arcInput[1].color = color as Color; // Update the color in the arc map
225
- bufferOrchestrator.updateBulk(
226
- [{ key: key, color: color }],
227
- bufferManagersMap, ["color"]
228
- );
229
- }
230
- if (drawRender) {
231
- this.globe.DrawRender();
232
- }
233
- }
234
-
235
-
236
- setPluginOpacity(opacity: number, drawRender: boolean = false): void {
237
- if (!this.globe || !this.gl) {
238
- console.warn("Globe or WebGL context is not initialized.");
239
- return;
240
- }
241
- opacityCheck(opacity)
242
- this._opacity = opacity;
243
-
244
- if (drawRender) {
245
- this.globe.DrawRender();
246
- }
247
- }
248
-
249
-
250
-
251
-
252
-
253
-
254
- setDefaultColor(color: Color, drawRender = false): void {
255
- if (!this.globe || !this.gl) {
256
- console.warn("Globe or WebGL context is not initialized.");
257
- return;
258
- }
259
- this._options.defaultColor = color;
260
- this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
261
-
262
- if (drawRender) {
263
- this.globe.DrawRender();
264
- }
265
- }
266
-
267
-
268
- setElevationMode(mode: "msl" | "agl"): void {
269
- switch (mode) {
270
- case "msl":
271
- this._options.isMSL = true;
272
- break;
273
- case "agl":
274
- this._options.isMSL = false;
275
- break;
276
- default:
277
- throw new Error(`Unknown elevation mode: ${mode}`);
278
- }
279
- this._buildArcs(); // can be async
280
- this.globe.DrawRender();
281
- }
282
-
283
-
284
- setCameraAttraction(isOn: boolean) {
285
- if (!this.globe || !this.gl) {
286
- console.warn("Globe or WebGL context is not initialized.");
287
- return;
288
- }
289
- this._options.cameraAttractionIsOn = isOn;
290
- this.globe.DrawRender();
291
- }
292
-
293
-
294
- init(globe: Globe, gl: WebGL2RenderingContext) {
295
- this.globe = globe;
296
- this.gl = gl;
297
-
298
-
299
- this._frameCounterTrigger = new FrameCounterTrigger(globe, 15, 1000, (globeChanges: GlobeChanges) => {
300
- if (this._freed) return;
301
- this.__buildDynamicArcs();
302
- });
303
-
304
- this.program = LineStripProgramCache.get(globe) as LineProgram;
305
-
306
- this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD, () => {
307
- this.__buildStaticArcs();
308
- }); // Initialize static-dynamic strategy with a transition level of 8
309
-
310
- this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
311
-
312
- this._fillbufferManagersMap();
313
-
314
- this.bufferOrchestrator = new BufferOrchestrator();
315
-
316
- this._arcUBOHandler = this.program.createUBO();
317
- this._arcUBOHandler.update(new Map([
318
- ["u_color", new Float32Array(this._options.defaultColor)],
319
- ]));
320
- }
321
-
322
-
323
- draw3D() {
324
- // Drawing logic here
325
- if (!this.globe || !this.gl) {
326
- console.warn("Globe or WebGL context is not initialized.");
327
- return;
328
- }
329
- const globe = this.globe as Globe;
330
- this._staticDynamicStrategy?.updateState();
331
- // if (globe.api_IsScreenMoving()) {
332
- // this._buildArcs(); // can be async
333
- // }
334
- this._frameCounterTrigger?.trigger();
335
- const { gl, program, bufferOrchestrator, _vao, _arcUBOHandler, } = this;
336
- if (!gl || !program || !bufferOrchestrator || !_vao || !_arcUBOHandler) {
337
- console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
338
- return;
339
- }
340
-
341
- gl.disable(gl.DEPTH_TEST);
342
-
343
- const currentGeometry = globe.api_GetCurrentGeometry();
344
- if ((currentGeometry === 0 && !this._options.globeViewOn) || (currentGeometry === 1 && !this._options.flatViewOn)) return;
345
-
346
- const drawOptions = {
347
- drawRange: {
348
- first: 0,
349
- count: bufferOrchestrator.length * (this._options.vertexCount + 1)
350
- },
351
- indexes: null
352
- }
353
-
354
- program.draw(
355
- _vao,
356
- drawOptions,
357
- this._opacity,
358
- _arcUBOHandler
359
- );
360
- gl.enable(gl.DEPTH_TEST);
361
- }
362
-
363
-
364
- _buildArcs(subSetIDs: string[] | null = null) {
365
- const state = this._staticDynamicStrategy?.getState();
366
- if (state === StaticDynamicState.DYNAMIC) {
367
- this.__buildDynamicArcs(subSetIDs);
368
- } else if (subSetIDs || state === StaticDynamicState.TO_STATIC) {
369
- this.__buildStaticArcs(subSetIDs);
370
- }
371
- }
372
-
373
-
374
-
375
- __buildStaticArcs(subSetIDs: string[] | null = null) {
376
- const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap, bufferOrchestrator } = this;
377
- if (!globe || !_cameraUniformBlock || !bufferManagersMap || !bufferOrchestrator) {
378
- console.warn("Globe or camera uniform block is not initialized.");
379
- return;
380
- }
381
-
382
- const bufferKey = [this.globe!.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"]
383
- if (!this.bufferManagersMap?.has(bufferKey[0])) return;
384
-
385
- const longLat = [0, 0] as [number, number];
386
- const longLatArr = new Float32Array(2 * this._options.vertexCount);
387
-
388
- const data: [{
389
- key: string,
390
- longLatArr: Float32Array,
391
- height: Meter | null
392
- color?: Color
393
- msl?: boolean | null
394
- }] = [{
395
- key: "staticArcs",
396
- longLatArr: longLatArr,
397
- height: null,
398
- color: this._options.defaultColor,
399
- msl: null
400
- }];
401
-
402
- let keys;
403
- if (subSetIDs === null) {
404
- keys = _arcMap.keys();
405
- } else {
406
- keys = subSetIDs;
407
- }
408
-
409
-
410
- for (const key of keys) {
411
- const [arcInstance, arcInput] = _arcMap.get(key) as [Arc, ArcInput];
412
- arc.copy(_0arc, arcInstance);
413
- const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle as Radian, this._options.vertexCount);
414
-
415
- for (let i = 0; i < generatedPoints.length; i++) {
416
- const point = generatedPoints[i];
417
- vec3.fromUnitVectorToLongLat(longLat, point);
418
- longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
419
- }
420
-
421
- data[0].key = key;
422
- data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
423
- data[0].color = arcInput.color ?? this._options.defaultColor;
424
- data[0].msl = arcInput.msl ?? null;
425
-
426
- this.bufferOrchestrator.insertBulk(data, bufferManagersMap,
427
- bufferKey
428
- );
429
- }
430
- }
431
-
432
-
433
- __buildDynamicArcs(subSetIDs: string[] | null = null) {
434
-
435
- const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap } = this;
436
- if (!globe || !_cameraUniformBlock || !bufferManagersMap) {
437
- console.warn("Globe or camera uniform block is not initialized.");
438
- return;
439
- }
440
- const bufferKey = [
441
- this.globe!.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"
442
- ]
443
- if (!this.bufferManagersMap?.has(bufferKey[0])) return;
444
-
445
- const { cameraAttractionIsOn } = this._options;
446
-
447
- const lookAtPosition = _cameraUniformBlock.getLookAtVector();
448
- const cameraPosition = _cameraUniformBlock.getCameraVector();
449
- vec3.divideScalar(cameraPosition, cameraPosition, WORLD_RADIUS_3D);
450
-
451
- vec3.add(cameraPosition, cameraPosition, lookAtPosition);
452
- // vec3.normalize(cameraPosition, cameraPosition);
453
- vec3.divideScalar(cameraPosition, cameraPosition, 2);
454
- // vec3.multiplyScalar(cameraPosition, cameraPosition, 1.3);
455
-
456
-
457
-
458
- const _attractionStrength = (() => {
459
- const lod = globe.api_GetCurrentLODWithDecimal();
460
- if (lod < 11) {
461
- return 1;
462
- }
463
- return lod * (lod - 8.5);
464
- })();
465
-
466
- const result = [];
467
- const longLat = [0, 0] as [number, number];
468
-
469
- let keys;
470
- if (subSetIDs === null) {
471
- keys = _arcMap.keys();
472
- } else {
473
- keys = subSetIDs;
474
- }
475
-
476
- for (const key of keys) {
477
- const [arcInstance, arcInput] = _arcMap.get(key) as [Arc, ArcInput];
478
- arc.copy(_0arc, arcInstance);
479
- const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
480
- if (!isOnArc) {
481
- if (vec3.distanceSquared(cameraPosition, _0arc.p0) < vec3.distanceSquared(cameraPosition, _0arc.p1)) {
482
- vec3.copy(_attractionPoint, _0arc.p0)
483
- } else {
484
- vec3.copy(_attractionPoint, _0arc.p1);
485
- }
486
- }
487
- const generatedPoints = cameraAttractionIsOn ?
488
- generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, this._options.vertexCount, _attractionStrength)
489
- : evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle as Radian, this._options.vertexCount);
490
- const longLatArr = new Float32Array(2 * this._options.vertexCount);
491
- for (let i = 0; i < generatedPoints.length; i++) {
492
- const point = generatedPoints[i];
493
- vec3.fromUnitVectorToLongLat(longLat, point);
494
- longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
495
- }
496
- result.push({
497
- key: key,
498
- longLatArr: longLatArr,
499
- height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
500
- msl: arcInput.msl ?? null
501
- })
502
- }
503
- // this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, result.length);
504
-
505
- this.bufferOrchestrator.insertBulk(result, bufferManagersMap, bufferKey);
506
- }
507
-
508
-
509
- _fillbufferManagersMap() {
510
- const { gl, globe } = this;
511
- if (!gl || !globe) {
512
- console.warn("WebGL context or globe is not initialized.");
513
- return;
514
- }
515
- const g2D = globe2Dcoordinates(globe);
516
- const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
517
- this.bufferManagersMap = new Map();
518
- if (globeViewOn) {
519
- this.bufferManagersMap.set("position3d", {
520
- bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
521
- adaptor: (item: any) => {
522
- const { longLatArr, height = this._options.defaultHeightFromGroundIn3D, msl = this._options.isMSL } = item;
523
- const result = globe3Dcoordinates(globe, longLatArr, height, msl, { paddingCount: 1 });
524
- return result;
525
- }
526
- });
527
- }
528
-
529
- if (flatViewOn) {
530
- this.bufferManagersMap.set("position2d", {
531
- bufferManager: new BufferManager(gl, 2 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
532
- adaptor: (item: any) => {
533
- const { longLatArr } = item;
534
- return g2D(longLatArr, { paddingCount: 1 });
535
- }
536
- });
537
- }
538
-
539
- if (this._options.variativeColorsOn) {
540
- const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1)); // TODO: this could cause data races or unexpected overwrites.
541
- this.bufferManagersMap.set("color", {
542
- bufferManager: new BufferManager(gl, 4 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
543
- adaptor: (item: any) => {
544
- // Calculate color based on radius
545
- if (item.color) {
546
- for (let i = 0; i < this._options.vertexCount; i++) {
547
- _colorArray.set(item.color, 4 * i); // Fill color for each vertex
548
- }
549
- return _colorArray
550
- } else {
551
- return _colorArray.fill(-1, 0, 4 * (this._options.vertexCount)); // Fill with -1 if no color is provided
552
- }
553
- }
554
- });
555
- }
556
-
557
- const bufferObjects = [
558
- globeViewOn ? "position3d" : null,
559
- flatViewOn ? "position2d" : null,
560
- variativeColorsOn ? "color" : null
561
- ].map(
562
- (key) => {
563
- if (!key) return null;
564
- this._coordinaateBufferKeysForUpdate.push(key);
565
- // @ts-ignore
566
- const bufferManager = this.bufferManagersMap.get(key).bufferManager;
567
- // @ts-ignore
568
- return createBufferAndReadInfo(bufferManager.buffer);
569
- }
570
- )
571
-
572
-
573
- // @ts-ignore
574
- this._vao = this.program.createVAO(
575
- bufferObjects[0], // position3d
576
- bufferObjects[1], // position2d
577
- bufferObjects[2] // color
578
- );
579
- }
580
-
581
-
582
- __fillColors(subSetIDs: string[]) {
583
- if (this._options.variativeColorsOn === false) return;
584
- const data: [ArcInput] = [null!];
585
- for (const id of subSetIDs) {
586
- data[0] = this._arcMap.get(id)![1];
587
- this.bufferOrchestrator.insertBulk(
588
- data,
589
- this.bufferManagersMap!,
590
- ["color"]
591
- );
592
- }
593
- }
594
-
595
-
596
- free() {
597
- if (this._freed) {
598
- console.warn("Plugin already freed");
599
- return;
600
- }
601
- if (!this.gl || !this.program) {
602
- console.warn("WebGL context or program is not initialized.");
603
- return;
604
- }
605
- this._arcUBOHandler?.free();
606
- this.bufferManagersMap?.forEach((manager) => {
607
- manager.bufferManager.free();
608
- });
609
- CameraUniformBlockTotemCache.release(this.globe as Globe);
610
- LineStripProgramCache.release(this.globe as Globe);
611
- this.gl = null;
612
- this.globe = null;
613
- this._arcMap.clear();
614
- this._coordinaateBufferKeysForUpdate = [];
615
- }
616
- }
1
+ // import { ArcOnTerrainPluginOptions } from "./type";
2
+ import { LineStripProgramCache } from "../../programs/line-on-globe/linestrip/linestrip";
3
+ import { createBufferAndReadInfo } from "../../util/gl-util/buffer/attribute-loader";
4
+ import { BufferManager, BufferOrchestrator } from "../../util/account/single-attribute-buffer-management/index";
5
+ import { globe3Dcoordinates, globe2Dcoordinates, RADIAN } from "../../Math/methods";
6
+ import { generateArcPoints, evenlySpacedArcPoints } from "../../Math/arc-cdf-points";
7
+ import { StaticDynamicState, StaticDynamicStrategy } from "../../util/build-strategy/static-dynamic";
8
+ import { opacityCheck } from "../../util/check/typecheck";
9
+ import { FrameCounterTrigger } from "../../util/frame-counter-trigger";
10
+ import * as vec3 from "../../Math/vec3";
11
+ import * as arc from "../../Math/arc";
12
+ import { CameraUniformBlockTotemCache } from "../../programs/totems/camerauniformblock";
13
+ import { WORLD_RADIUS_3D } from "../../Math/constants";
14
+ const DYNAMIC_STRATEGY_START_LOD = 12;
15
+ const INITAL_CAPACITY = 10;
16
+ const _attractionPoint = [0, 0, 0];
17
+ const _start = [0, 0, 0];
18
+ const _end = [0, 0, 0];
19
+ const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
20
+ function createArc(start, end) {
21
+ vec3.fromLongLatToUnitVector(_start, [start[0] * RADIAN, start[1] * RADIAN]);
22
+ vec3.fromLongLatToUnitVector(_end, [end[0] * RADIAN, end[1] * RADIAN]);
23
+ return arc.create(_start, _end);
24
+ }
25
+ export class ArcOnTerrainPlugin {
26
+ id;
27
+ program = null;
28
+ bufferManagersMap = null;
29
+ bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
30
+ _opacity = 1;
31
+ _arcUBOHandler = null;
32
+ _vao = null;
33
+ globe = null;
34
+ gl = null;
35
+ _arcMap;
36
+ _cameraUniformBlock = null;
37
+ _staticDynamicStrategy = null;
38
+ _options;
39
+ _coordinaateBufferKeysForUpdate = [];
40
+ _freed = false;
41
+ _frameCounterTrigger = null;
42
+ constructor(id, { globeViewOn = true, // If true, arcs are drawn in 3D globe view
43
+ flatViewOn = true, // If true, arcs are drawn in 2D flat view
44
+ variativeColorsOn = false, defaultColor = [0.1, 0.1, 1, 1], // Default color in RGBA format
45
+ defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
46
+ vertexCount = 70, // Number of vertices per arc
47
+ cameraAttractionIsOn = true, // If true, camera attraction is enabled else evenly distributed arc points are used
48
+ bufferType = "STREAM_DRAW", isMSL = false } = {}) {
49
+ this.id = id;
50
+ this._arcMap = new Map();
51
+ this._options = {
52
+ globeViewOn: globeViewOn ? true : false,
53
+ flatViewOn: flatViewOn ? true : false,
54
+ variativeColorsOn: variativeColorsOn ? true : false,
55
+ defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
56
+ defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
57
+ vertexCount: vertexCount ? vertexCount : 70,
58
+ cameraAttractionIsOn: cameraAttractionIsOn ? true : false,
59
+ bufferType: bufferType ? bufferType : "STREAM_DRAW",
60
+ isMSL: isMSL ? true : false
61
+ };
62
+ }
63
+ increaseSpace(amount) {
64
+ if (this._freed) {
65
+ console.warn("Plugin is freed, cannot increase space");
66
+ return;
67
+ }
68
+ if (this.globe === null) {
69
+ console.warn("Globe is not initialized.");
70
+ return;
71
+ }
72
+ if (typeof amount !== "number" || amount <= 0) {
73
+ console.warn("Invalid amount, must be a positive number");
74
+ return;
75
+ }
76
+ this.bufferOrchestrator.ensureSpace(amount, this.bufferManagersMap);
77
+ }
78
+ insertBulk(arcs) {
79
+ const keys = [];
80
+ let newItemCount = 0;
81
+ for (let arcInput of arcs) {
82
+ const { key, start, end } = arcInput;
83
+ if (this._arcMap.has(key)) {
84
+ this._arcMap.delete(key); // Remove old arc
85
+ }
86
+ else {
87
+ newItemCount++;
88
+ }
89
+ const _arc = createArc(start, end);
90
+ this._arcMap.set(key, [_arc, arcInput]); // Always set new color
91
+ keys.push(key);
92
+ }
93
+ this.bufferOrchestrator.ensureSpace(newItemCount, this.bufferManagersMap);
94
+ this._buildArcs(keys);
95
+ if (this._options.variativeColorsOn) {
96
+ this.__fillColors(keys);
97
+ }
98
+ this.globe.DrawRender();
99
+ }
100
+ updateCoordinates(items) {
101
+ if (this._freed) {
102
+ console.warn("Plugin is freed, cannot update coordinates");
103
+ return;
104
+ }
105
+ if (this.globe === null || this.gl === null) {
106
+ console.warn("Globe or WebGL context is not initialized, cannot update coordinates");
107
+ return;
108
+ }
109
+ const updateKeys = [];
110
+ for (const { key, start, end } of items) {
111
+ const arcInput = this._arcMap.get(key);
112
+ if (!arcInput) {
113
+ console.warn(`Arc with key ${key} not found in arcMap.`);
114
+ continue;
115
+ }
116
+ const _arc = createArc(start, end);
117
+ arc.copy(arcInput[0], _arc); // Update the arc in the map
118
+ // Update the arc in the buffer
119
+ updateKeys.push(key);
120
+ }
121
+ this._buildArcs(updateKeys);
122
+ this.globe.DrawRender();
123
+ }
124
+ deleteBulk(keys) {
125
+ if (!this.bufferOrchestrator || !this.bufferManagersMap || !this.globe) {
126
+ console.warn("Buffer orchestrator or buffer manager map is not initialized.");
127
+ return;
128
+ }
129
+ for (const key of keys) {
130
+ if (this._arcMap.has(key)) {
131
+ this._arcMap.delete(key);
132
+ }
133
+ else {
134
+ console.warn(`Arc with key ${key} not found in arcMap.`);
135
+ }
136
+ }
137
+ this.bufferOrchestrator.deleteBulk(keys, this.bufferManagersMap);
138
+ this.globe.DrawRender();
139
+ }
140
+ deleteAll() {
141
+ if (!this.bufferOrchestrator || !this.bufferManagersMap || !this.globe) {
142
+ console.warn("Buffer orchestrator or buffer manager map is not initialized.");
143
+ return;
144
+ }
145
+ this.bufferOrchestrator.resetWithCapacity(this.bufferManagersMap, this._arcMap.size);
146
+ this._arcMap.clear();
147
+ this.globe.DrawRender();
148
+ }
149
+ updateColors(keyColorCouples, drawRender = true) {
150
+ if (this._freed) {
151
+ console.warn("Plugin is freed, cannot update color");
152
+ return;
153
+ }
154
+ if (this._options.variativeColorsOn === false) {
155
+ console.warn("Variative colors are not enabled in this plugin. Create another instance with variativeColorsOn: true to use this feature.");
156
+ return;
157
+ }
158
+ const { bufferOrchestrator, bufferManagersMap } = this;
159
+ if (!bufferOrchestrator || !bufferManagersMap) {
160
+ console.warn("Buffer orchestrator or buffer manager map is not initialized.");
161
+ return;
162
+ }
163
+ for (const { key, color } of keyColorCouples) {
164
+ const arcInput = this._arcMap.get(key);
165
+ if (!arcInput) {
166
+ console.warn(`Arc with key ${key} not found in arcMap.`);
167
+ return;
168
+ }
169
+ arcInput[1].color = color; // Update the color in the arc map
170
+ bufferOrchestrator.updateBulk([{ key: key, color: color }], bufferManagersMap, ["color"]);
171
+ }
172
+ if (drawRender) {
173
+ this.globe.DrawRender();
174
+ }
175
+ }
176
+ setPluginOpacity(opacity, drawRender = false) {
177
+ if (!this.globe || !this.gl) {
178
+ console.warn("Globe or WebGL context is not initialized.");
179
+ return;
180
+ }
181
+ opacityCheck(opacity);
182
+ this._opacity = opacity;
183
+ if (drawRender) {
184
+ this.globe.DrawRender();
185
+ }
186
+ }
187
+ setDefaultColor(color, drawRender = false) {
188
+ if (!this.globe || !this.gl) {
189
+ console.warn("Globe or WebGL context is not initialized.");
190
+ return;
191
+ }
192
+ this._options.defaultColor = color;
193
+ this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
194
+ if (drawRender) {
195
+ this.globe.DrawRender();
196
+ }
197
+ }
198
+ setElevationMode(mode) {
199
+ switch (mode) {
200
+ case "msl":
201
+ this._options.isMSL = true;
202
+ break;
203
+ case "agl":
204
+ this._options.isMSL = false;
205
+ break;
206
+ default:
207
+ throw new Error(`Unknown elevation mode: ${mode}`);
208
+ }
209
+ this._buildArcs(); // can be async
210
+ this.globe.DrawRender();
211
+ }
212
+ setCameraAttraction(isOn) {
213
+ if (!this.globe || !this.gl) {
214
+ console.warn("Globe or WebGL context is not initialized.");
215
+ return;
216
+ }
217
+ this._options.cameraAttractionIsOn = isOn;
218
+ this.globe.DrawRender();
219
+ }
220
+ init(globe, gl) {
221
+ this.globe = globe;
222
+ this.gl = gl;
223
+ this._frameCounterTrigger = new FrameCounterTrigger(globe, 15, 1000, (globeChanges) => {
224
+ if (this._freed)
225
+ return;
226
+ this.__buildDynamicArcs();
227
+ });
228
+ this.program = LineStripProgramCache.get(globe);
229
+ this._staticDynamicStrategy = new StaticDynamicStrategy(globe, DYNAMIC_STRATEGY_START_LOD, () => {
230
+ this.__buildStaticArcs();
231
+ }); // Initialize static-dynamic strategy with a transition level of 8
232
+ this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
233
+ this._fillbufferManagersMap();
234
+ this.bufferOrchestrator = new BufferOrchestrator();
235
+ this._arcUBOHandler = this.program.createUBO();
236
+ this._arcUBOHandler.update(new Map([
237
+ ["u_color", new Float32Array(this._options.defaultColor)],
238
+ ]));
239
+ }
240
+ draw3D() {
241
+ // Drawing logic here
242
+ if (!this.globe || !this.gl) {
243
+ console.warn("Globe or WebGL context is not initialized.");
244
+ return;
245
+ }
246
+ const globe = this.globe;
247
+ this._staticDynamicStrategy?.updateState();
248
+ // if (globe.api_IsScreenMoving()) {
249
+ // this._buildArcs(); // can be async
250
+ // }
251
+ this._frameCounterTrigger?.trigger();
252
+ const { gl, program, bufferOrchestrator, _vao, _arcUBOHandler, } = this;
253
+ if (!gl || !program || !bufferOrchestrator || !_vao || !_arcUBOHandler) {
254
+ console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
255
+ return;
256
+ }
257
+ gl.disable(gl.DEPTH_TEST);
258
+ const currentGeometry = globe.api_GetCurrentGeometry();
259
+ if ((currentGeometry === 0 && !this._options.globeViewOn) || (currentGeometry === 1 && !this._options.flatViewOn))
260
+ return;
261
+ const drawOptions = {
262
+ drawRange: {
263
+ first: 0,
264
+ count: bufferOrchestrator.length * (this._options.vertexCount + 1)
265
+ },
266
+ indexes: null
267
+ };
268
+ program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
269
+ gl.enable(gl.DEPTH_TEST);
270
+ }
271
+ _buildArcs(subSetIDs = null) {
272
+ const state = this._staticDynamicStrategy?.getState();
273
+ if (state === StaticDynamicState.DYNAMIC) {
274
+ this.__buildDynamicArcs(subSetIDs);
275
+ }
276
+ else if (subSetIDs || state === StaticDynamicState.TO_STATIC) {
277
+ this.__buildStaticArcs(subSetIDs);
278
+ }
279
+ }
280
+ __buildStaticArcs(subSetIDs = null) {
281
+ const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap, bufferOrchestrator } = this;
282
+ if (!globe || !_cameraUniformBlock || !bufferManagersMap || !bufferOrchestrator) {
283
+ console.warn("Globe or camera uniform block is not initialized.");
284
+ return;
285
+ }
286
+ const bufferKey = [this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"];
287
+ if (!this.bufferManagersMap?.has(bufferKey[0]))
288
+ return;
289
+ const longLat = [0, 0];
290
+ const longLatArr = new Float32Array(2 * this._options.vertexCount);
291
+ const data = [{
292
+ key: "staticArcs",
293
+ longLatArr: longLatArr,
294
+ height: null,
295
+ color: this._options.defaultColor,
296
+ msl: null
297
+ }];
298
+ let keys;
299
+ if (subSetIDs === null) {
300
+ keys = _arcMap.keys();
301
+ }
302
+ else {
303
+ keys = subSetIDs;
304
+ }
305
+ for (const key of keys) {
306
+ const [arcInstance, arcInput] = _arcMap.get(key);
307
+ arc.copy(_0arc, arcInstance);
308
+ const generatedPoints = evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
309
+ for (let i = 0; i < generatedPoints.length; i++) {
310
+ const point = generatedPoints[i];
311
+ vec3.fromUnitVectorToLongLat(longLat, point);
312
+ longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
313
+ }
314
+ data[0].key = key;
315
+ data[0].height = arcInput.height ?? this._options.defaultHeightFromGroundIn3D;
316
+ data[0].color = arcInput.color ?? this._options.defaultColor;
317
+ data[0].msl = arcInput.msl ?? null;
318
+ this.bufferOrchestrator.insertBulk(data, bufferManagersMap, bufferKey);
319
+ }
320
+ }
321
+ __buildDynamicArcs(subSetIDs = null) {
322
+ const { globe, _arcMap, _cameraUniformBlock, bufferManagersMap } = this;
323
+ if (!globe || !_cameraUniformBlock || !bufferManagersMap) {
324
+ console.warn("Globe or camera uniform block is not initialized.");
325
+ return;
326
+ }
327
+ const bufferKey = [
328
+ this.globe.api_GetCurrentGeometry() === 0 ? "position3d" : "position2d"
329
+ ];
330
+ if (!this.bufferManagersMap?.has(bufferKey[0]))
331
+ return;
332
+ const { cameraAttractionIsOn } = this._options;
333
+ const lookAtPosition = _cameraUniformBlock.getLookAtVector();
334
+ const cameraPosition = _cameraUniformBlock.getCameraVector();
335
+ vec3.divideScalar(cameraPosition, cameraPosition, WORLD_RADIUS_3D);
336
+ vec3.add(cameraPosition, cameraPosition, lookAtPosition);
337
+ // vec3.normalize(cameraPosition, cameraPosition);
338
+ vec3.divideScalar(cameraPosition, cameraPosition, 2);
339
+ // vec3.multiplyScalar(cameraPosition, cameraPosition, 1.3);
340
+ const _attractionStrength = (() => {
341
+ const lod = globe.api_GetCurrentLODWithDecimal();
342
+ if (lod < 11) {
343
+ return 1;
344
+ }
345
+ return lod * (lod - 8.5);
346
+ })();
347
+ const result = [];
348
+ const longLat = [0, 0];
349
+ let keys;
350
+ if (subSetIDs === null) {
351
+ keys = _arcMap.keys();
352
+ }
353
+ else {
354
+ keys = subSetIDs;
355
+ }
356
+ for (const key of keys) {
357
+ const [arcInstance, arcInput] = _arcMap.get(key);
358
+ arc.copy(_0arc, arcInstance);
359
+ const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
360
+ if (!isOnArc) {
361
+ if (vec3.distanceSquared(cameraPosition, _0arc.p0) < vec3.distanceSquared(cameraPosition, _0arc.p1)) {
362
+ vec3.copy(_attractionPoint, _0arc.p0);
363
+ }
364
+ else {
365
+ vec3.copy(_attractionPoint, _0arc.p1);
366
+ }
367
+ }
368
+ const generatedPoints = cameraAttractionIsOn ?
369
+ generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, this._options.vertexCount, _attractionStrength)
370
+ : evenlySpacedArcPoints(_0arc.p0, _0arc.normal, _0arc.coverAngle, this._options.vertexCount);
371
+ const longLatArr = new Float32Array(2 * this._options.vertexCount);
372
+ for (let i = 0; i < generatedPoints.length; i++) {
373
+ const point = generatedPoints[i];
374
+ vec3.fromUnitVectorToLongLat(longLat, point);
375
+ longLatArr.set([longLat[0] / RADIAN, longLat[1] / RADIAN], i * 2);
376
+ }
377
+ result.push({
378
+ key: key,
379
+ longLatArr: longLatArr,
380
+ height: arcInput.height ?? this._options.defaultHeightFromGroundIn3D,
381
+ msl: arcInput.msl ?? null
382
+ });
383
+ }
384
+ // this.bufferOrchestrator.resetWithCapacity(bufferManagersMap, result.length);
385
+ this.bufferOrchestrator.insertBulk(result, bufferManagersMap, bufferKey);
386
+ }
387
+ _fillbufferManagersMap() {
388
+ const { gl, globe } = this;
389
+ if (!gl || !globe) {
390
+ console.warn("WebGL context or globe is not initialized.");
391
+ return;
392
+ }
393
+ const g2D = globe2Dcoordinates(globe);
394
+ const { flatViewOn, globeViewOn, variativeColorsOn } = this._options;
395
+ this.bufferManagersMap = new Map();
396
+ if (globeViewOn) {
397
+ this.bufferManagersMap.set("position3d", {
398
+ bufferManager: new BufferManager(gl, 3 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
399
+ adaptor: (item) => {
400
+ const { longLatArr, height = this._options.defaultHeightFromGroundIn3D, msl = this._options.isMSL } = item;
401
+ const result = globe3Dcoordinates(globe, longLatArr, height, msl, { paddingCount: 1 });
402
+ return result;
403
+ }
404
+ });
405
+ }
406
+ if (flatViewOn) {
407
+ this.bufferManagersMap.set("position2d", {
408
+ bufferManager: new BufferManager(gl, 2 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
409
+ adaptor: (item) => {
410
+ const { longLatArr } = item;
411
+ return g2D(longLatArr, { paddingCount: 1 });
412
+ }
413
+ });
414
+ }
415
+ if (this._options.variativeColorsOn) {
416
+ const _colorArray = new Float32Array(4 * (this._options.vertexCount + 1)); // TODO: this could cause data races or unexpected overwrites.
417
+ this.bufferManagersMap.set("color", {
418
+ bufferManager: new BufferManager(gl, 4 * (this._options.vertexCount + 1), { bufferType: "STREAM_DRAW", initialCapacity: INITAL_CAPACITY }),
419
+ adaptor: (item) => {
420
+ // Calculate color based on radius
421
+ if (item.color) {
422
+ for (let i = 0; i < this._options.vertexCount; i++) {
423
+ _colorArray.set(item.color, 4 * i); // Fill color for each vertex
424
+ }
425
+ return _colorArray;
426
+ }
427
+ else {
428
+ return _colorArray.fill(-1, 0, 4 * (this._options.vertexCount)); // Fill with -1 if no color is provided
429
+ }
430
+ }
431
+ });
432
+ }
433
+ const bufferObjects = [
434
+ globeViewOn ? "position3d" : null,
435
+ flatViewOn ? "position2d" : null,
436
+ variativeColorsOn ? "color" : null
437
+ ].map((key) => {
438
+ if (!key)
439
+ return null;
440
+ this._coordinaateBufferKeysForUpdate.push(key);
441
+ // @ts-ignore
442
+ const bufferManager = this.bufferManagersMap.get(key).bufferManager;
443
+ // @ts-ignore
444
+ return createBufferAndReadInfo(bufferManager.buffer);
445
+ });
446
+ // @ts-ignore
447
+ this._vao = this.program.createVAO(bufferObjects[0], // position3d
448
+ bufferObjects[1], // position2d
449
+ bufferObjects[2] // color
450
+ );
451
+ }
452
+ __fillColors(subSetIDs) {
453
+ if (this._options.variativeColorsOn === false)
454
+ return;
455
+ const data = [null];
456
+ for (const id of subSetIDs) {
457
+ data[0] = this._arcMap.get(id)[1];
458
+ this.bufferOrchestrator.insertBulk(data, this.bufferManagersMap, ["color"]);
459
+ }
460
+ }
461
+ free() {
462
+ if (this._freed) {
463
+ console.warn("Plugin already freed");
464
+ return;
465
+ }
466
+ if (!this.gl || !this.program) {
467
+ console.warn("WebGL context or program is not initialized.");
468
+ return;
469
+ }
470
+ this._arcUBOHandler?.free();
471
+ this.bufferManagersMap?.forEach((manager) => {
472
+ manager.bufferManager.free();
473
+ });
474
+ CameraUniformBlockTotemCache.release(this.globe);
475
+ LineStripProgramCache.release(this.globe);
476
+ this.gl = null;
477
+ this.globe = null;
478
+ this._arcMap.clear();
479
+ this._coordinaateBufferKeysForUpdate = [];
480
+ }
481
+ }