@pirireis/webglobeplugins 0.17.0 → 1.0.2
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.
- package/Math/{angle-calculation.js → angle-calculation.ts} +18 -14
- package/Math/{arc-cdf-points.js → arc-cdf-points.ts} +329 -272
- package/Math/{arc-generate-points-exponantial.js → arc-generate-points-exponantial.ts} +299 -254
- package/Math/{arc.js → arc.ts} +421 -292
- package/Math/bounds/line-bbox.js +225 -186
- package/Math/{circle-cdf-points.js → circle-cdf-points.ts} +143 -78
- package/Math/{circle.js → circle.ts} +49 -33
- package/Math/{constants.js → constants.ts} +12 -4
- package/Math/contour/{quadtreecontours.js → quadtreecontours.ts} +371 -300
- package/Math/contour/quadtreecontours1.js +336 -298
- package/Math/{finite-line-2d.js → finite-line-2d.ts} +68 -58
- package/Math/haversine.ts +33 -0
- package/Math/index.js +0 -1
- package/Math/juction/{arc-plane.js → arc-plane.ts} +203 -143
- package/Math/juction/{line-sphere.js → line-sphere.ts} +32 -22
- package/Math/juction/{plane-plane.js → plane-plane.ts} +62 -53
- package/Math/{line.js → line.ts} +84 -52
- package/Math/matrix4.ts +0 -0
- package/Math/mesh/mapbox-delaunay.d.ts +74 -0
- package/Math/{methods.js → methods.ts} +182 -107
- package/Math/{plane.js → plane.ts} +92 -56
- package/Math/{quaternion.js → quaternion.ts} +128 -106
- package/Math/roadmap.md +10 -0
- package/Math/templete-shapes/{grid-visually-equal.js → grid-visually-equal.ts} +118 -65
- package/Math/tessellation/constants.ts +1 -0
- package/Math/tessellation/methods.ts +79 -0
- package/Math/tessellation/nearest-value-padding.ts +147 -0
- package/Math/tessellation/roadmap.md +48 -0
- package/Math/tessellation/spherical-triangle-area.ts +127 -0
- package/Math/tessellation/tile-merger.ts +578 -0
- package/Math/tessellation/triangle-tessellation.ts +533 -0
- package/Math/tessellation/types.ts +1 -0
- package/Math/types.ts +68 -0
- package/Math/utils.js +3 -2
- package/Math/{vec3.js → vec3.ts} +227 -151
- package/Math/xyz-tile.ts +26 -0
- package/algorithms/search-binary.js +14 -16
- package/altitude-locator/adaptors.js +0 -1
- package/altitude-locator/keymethod.js +0 -1
- package/altitude-locator/plugin.js +445 -345
- package/altitude-locator/types.js +26 -21
- package/compass-rose/compass-rose-padding-flat.js +274 -230
- package/compass-rose/{compass-text-writer.js → compass-text-writer.ts} +210 -155
- package/compass-rose/index.js +3 -3
- package/{constants.js → constants.ts} +8 -6
- package/heatwave/datamanager.js +168 -149
- package/heatwave/heatwave.js +261 -206
- package/heatwave/index.js +5 -5
- package/heatwave/isobar.js +340 -303
- package/heatwave/{texture-point-sampler.js → texture-point-sampler.ts} +220 -187
- package/investigation-tools/draw/tiles/adapters.ts +133 -0
- package/investigation-tools/draw/tiles/tiles.ts +162 -0
- package/jest.config.js +6 -7
- package/package.json +1 -1
- package/pin/pin-object-array1.js +381 -300
- package/pin/pin-point-totem1.js +77 -60
- package/programs/arrowfield/arrow-field.js +89 -60
- package/programs/arrowfield/logic.js +173 -141
- package/programs/data2legend/density-to-legend.js +86 -68
- package/programs/data2legend/point-to-density-texture.js +84 -67
- package/programs/float2legendwithratio/index.js +3 -2
- package/programs/float2legendwithratio/logic.js +144 -118
- package/programs/float2legendwithratio/object.js +141 -104
- package/programs/helpers/blender.js +73 -58
- package/programs/helpers/{fadeaway.js → fadeaway.ts} +73 -55
- package/programs/index.js +19 -20
- package/programs/line-on-globe/circle-accurate-3d.js +112 -85
- package/programs/line-on-globe/circle-accurate-flat.js +200 -148
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +134 -102
- package/programs/line-on-globe/index.js +0 -1
- package/programs/line-on-globe/lines-color-instanced-flat.js +99 -80
- package/programs/line-on-globe/linestrip/data.ts +29 -0
- package/programs/line-on-globe/linestrip/{linestrip.js → linestrip.ts} +152 -93
- package/programs/line-on-globe/{naive-accurate-flexible.js → naive-accurate-flexible.ts} +175 -126
- package/programs/line-on-globe/util.js +8 -5
- package/programs/picking/pickable-polygon-renderer.js +129 -98
- package/programs/picking/pickable-renderer.js +130 -98
- package/programs/point-on-globe/element-globe-surface-glow.js +122 -93
- package/programs/point-on-globe/element-point-glow.js +114 -80
- package/programs/point-on-globe/square-pixel-point.js +139 -120
- package/programs/polygon-on-globe/roadmap.md +8 -0
- package/programs/polygon-on-globe/texture-dem-triangles.ts +290 -0
- package/programs/{programcache.js → programcache.ts} +134 -126
- package/programs/rings/index.js +1 -1
- package/programs/rings/partial-ring/{piece-of-pie.js → piece-of-pie.ts} +222 -152
- package/programs/totems/camera-totem-attactment-interface.ts +4 -0
- package/programs/totems/{camerauniformblock.js → camerauniformblock.ts} +326 -230
- package/programs/totems/{canvas-webglobe-info.js → canvas-webglobe-info.ts} +147 -132
- package/programs/totems/dem-textures-manager.ts +368 -0
- package/programs/totems/{globe-changes.js → globe-changes.ts} +79 -59
- package/programs/totems/gpu-selection-uniform-block.js +127 -99
- package/programs/totems/{index.js → index.ts} +2 -2
- package/programs/two-d/pixel-padding-for-compass.js +101 -87
- package/programs/util.js +19 -14
- package/programs/vectorfields/logics/{constants.js → constants.ts} +5 -4
- package/programs/vectorfields/logics/drawrectangleparticles.ts +182 -0
- package/programs/vectorfields/logics/index.js +4 -2
- package/programs/vectorfields/logics/particle-ubo.ts +23 -0
- package/programs/vectorfields/logics/{pixelbased.js → pixelbased.ts} +119 -84
- package/programs/vectorfields/logics/ubo.js +57 -51
- package/programs/vectorfields/{pingpongbuffermanager.js → pingpongbuffermanager.ts} +113 -73
- package/publish.bat +62 -0
- package/range-tools-on-terrain/bearing-line/{adapters.js → adapters.ts} +154 -114
- package/range-tools-on-terrain/bearing-line/{plugin.js → plugin.ts} +569 -457
- package/range-tools-on-terrain/bearing-line/types.ts +65 -0
- package/range-tools-on-terrain/circle-line-chain/{adapters.js → adapters.ts} +104 -85
- package/range-tools-on-terrain/circle-line-chain/{chain-list-map.js → chain-list-map.ts} +446 -382
- package/range-tools-on-terrain/circle-line-chain/{plugin.js → plugin.ts} +607 -464
- package/range-tools-on-terrain/circle-line-chain/types.ts +43 -0
- package/range-tools-on-terrain/range-ring/{adapters.js → adapters.ts} +114 -93
- package/range-tools-on-terrain/range-ring/{enum.js → enum.ts} +2 -2
- package/range-tools-on-terrain/range-ring/{plugin.js → plugin.ts} +444 -377
- package/range-tools-on-terrain/range-ring/rangeringangletext.ts +396 -0
- package/range-tools-on-terrain/range-ring/types.ts +30 -0
- package/semiplugins/interface.ts +14 -0
- package/semiplugins/lightweight/{line-plugin.js → line-plugin.ts} +342 -221
- package/semiplugins/lightweight/{piece-of-pie-plugin.js → piece-of-pie-plugin.ts} +275 -200
- package/semiplugins/shape-on-terrain/{arc-plugin.js → arc-plugin.ts} +616 -472
- package/semiplugins/shape-on-terrain/{circle-plugin.js → circle-plugin.ts} +588 -444
- package/semiplugins/shape-on-terrain/goal.md +12 -0
- package/semiplugins/shape-on-terrain/{padding-1-degree.js → padding-1-degree.ts} +713 -539
- package/semiplugins/shape-on-terrain/terrain-polygon/adapters.ts +69 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache-shortcuts.md +20 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache.ts +149 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/index-polygon-map.ts +58 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/manager.ts +4 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +196 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.ts +209 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/polygon-to-triangles.ts +144 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/random.ts +165 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/readme.md +5 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.ts +37 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker-contact.ts +81 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +146 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/notes.md +90 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.ts +265 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/types.ts +69 -0
- package/semiplugins/shell/bbox-renderer/index.ts +2 -0
- package/semiplugins/shell/bbox-renderer/{logic.js → logic.ts} +273 -249
- package/semiplugins/shell/bbox-renderer/object.ts +129 -0
- package/semiplugins/type.ts +8 -0
- package/semiplugins/utility/{container-plugin.js → container-plugin.ts} +126 -94
- package/semiplugins/utility/{object-pass-container-plugin.js → object-pass-container-plugin.ts} +101 -80
- package/shaders/fragment-toy/firework.js +1 -1
- package/shaders/fragment-toy/singularity.js +5 -2
- package/terrain-plugin.mmd +83 -0
- package/tests/Math/arc-sampling-test.js +367 -0
- package/tests/Math/arc-sampling-test.ts +429 -0
- package/tests/Math/arc.test.ts +77 -0
- package/tests/Math/junction/arc-limit.test.ts +7 -0
- package/tests/Math/junction/arc-plane-points.test.ts +196 -0
- package/tests/Math/junction/arc-plane.test.ts +172 -0
- package/tests/Math/junction/line-sphere.test.ts +127 -0
- package/tests/Math/junction/plane-plane.test.ts +91 -0
- package/tests/Math/plane-test.ts +17 -0
- package/tests/Math/plane.test.ts +43 -0
- package/tests/Math/vec3.test.ts +33 -0
- package/tracks/point-heat-map/adaptors/timetracksplugin-format-to-this.js +78 -63
- package/tracks/point-heat-map/index.js +0 -1
- package/tracks/point-heat-map/plugin-webworker.js +148 -121
- package/tracks/point-heat-map/point-to-heat-map-flow.js +150 -121
- package/tracks/point-heat-map/readme.md +15 -0
- package/tracks/point-tracks/key-methods.js +3 -2
- package/tracks/point-tracks/plugin.js +487 -393
- package/tracks/timetracks/adaptors-line-strip.js +79 -65
- package/tracks/timetracks/plugin-line-strip.js +295 -240
- package/tracks/timetracks/program-line-strip.js +495 -411
- package/tracks/timetracks/programpoint-line-strip.js +137 -109
- package/tracks/timetracks/readme.md +1 -0
- package/tsconfig.json +22 -0
- package/types/@pirireis/webglobe.d.ts +102 -0
- package/types/delaunator.d.ts +40 -0
- package/types/earcut.d.ts +11 -0
- package/types/rbush.d.ts +57 -0
- package/types.ts +319 -0
- package/util/account/bufferoffsetmanager.js +209 -176
- package/util/account/create-buffermap-orchastration.ts +85 -0
- package/util/account/index.js +6 -3
- package/util/account/single-attribute-buffer-management/{buffer-manager.js → buffer-manager.ts} +151 -117
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator.js → buffer-orchestrator.ts} +238 -212
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator1.js → buffer-orchestrator1.ts} +184 -159
- package/util/account/single-attribute-buffer-management/{index.js → index.ts} +11 -4
- package/util/account/single-attribute-buffer-management/{object-store.js → object-store.ts} +76 -55
- package/util/account/single-attribute-buffer-management/types.ts +43 -0
- package/util/account/util.js +22 -18
- package/util/algorithms/index.js +0 -1
- package/util/algorithms/search-binary.js +26 -25
- package/util/build-strategy/{static-dynamic.js → static-dynamic.ts} +50 -41
- package/util/check/index.js +0 -1
- package/util/check/typecheck.ts +74 -0
- package/util/{frame-counter-trigger.js → frame-counter-trigger.ts} +99 -84
- package/util/geometry/{index.js → index.ts} +155 -121
- package/util/gl-util/buffer/{attribute-loader.js → attribute-loader.ts} +84 -62
- package/util/gl-util/buffer/{index.js → index.ts} +6 -3
- package/util/gl-util/draw-options/{methods.js → methods.ts} +47 -32
- package/util/gl-util/uniform-block/{manager.js → manager.ts} +232 -190
- package/util/{webglobe/gldefaultstates.js → globe-default-gl-states.ts} +5 -4
- package/util/helper-methods.ts +9 -0
- package/util/index.js +9 -10
- package/util/interpolation/index.js +0 -1
- package/util/interpolation/timetrack/index.js +9 -2
- package/util/interpolation/timetrack/timetrack-interpolator.js +94 -79
- package/util/interpolation/timetrack/web-worker.js +51 -46
- package/util/picking/{fence.js → fence.ts} +47 -41
- package/util/picking/picker-displayer.ts +226 -0
- package/util/programs/draw-from-pixel-coords.js +201 -164
- package/util/programs/{draw-texture-on-canvas.js → draw-texture-on-canvas.ts} +92 -67
- package/util/programs/supersampletotextures.js +130 -97
- package/util/programs/texturetoglobe.js +153 -128
- package/util/shaderfunctions/{geometrytransformations.js → geometrytransformations.ts} +169 -41
- package/util/shaderfunctions/index.js +2 -2
- package/util/shaderfunctions/nodata.js +4 -2
- package/util/shaderfunctions/noisefunctions.js +10 -7
- package/util/{webglobjectbuilders.js → webglobjectbuilders.ts} +446 -358
- package/vectorfield/arrowfield/adaptor.js +11 -11
- package/vectorfield/arrowfield/index.js +3 -3
- package/vectorfield/arrowfield/plugin.js +128 -83
- package/vectorfield/waveparticles/adaptor.js +16 -15
- package/vectorfield/waveparticles/index.js +3 -3
- package/vectorfield/waveparticles/plugin.ts +506 -0
- package/vectorfield/wind/adapters/image-to-fields.ts +74 -0
- package/vectorfield/wind/adapters/types.ts +12 -0
- package/vectorfield/wind/{imagetovectorfieldandmagnitude.js → imagetovectorfieldandmagnitude.ts} +78 -56
- package/vectorfield/wind/index.js +5 -5
- package/vectorfield/wind/plugin-persistant copy.ts +461 -0
- package/vectorfield/wind/plugin-persistant.ts +483 -0
- package/vectorfield/wind/plugin.js +883 -671
- package/vectorfield/wind/vectorfieldimage.js +27 -23
- package/write-text/{context-text-bulk.js → context-text-bulk.ts} +285 -200
- package/write-text/context-text3.ts +252 -0
- package/write-text/{context-text4.js → context-text4.ts} +231 -145
- package/write-text/context-textDELETE.js +125 -94
- package/write-text/objectarraylabels/{index.js → index.ts} +2 -2
- package/write-text/objectarraylabels/objectarraylabels.d.ts +72 -0
- package/write-text/objectarraylabels/objectarraylabels.js +247 -200
- package/Math/matrix4.js +0 -1
- package/Math/tessellation/earcut/adapters.js +0 -37
- package/Math/tessellation/hybrid-triangle-tessellation-meta.js +0 -123
- package/Math/tessellation/methods.js +0 -46
- package/Math/tessellation/shred-input.js +0 -18
- package/Math/tessellation/tile-merger.js +0 -56
- package/Math/tessellation/tiler.js +0 -50
- package/Math/tessellation/triangle-tessellation-meta.js +0 -516
- package/Math/tessellation/triangle-tessellation.js +0 -14
- package/Math/tessellation/types.js +0 -1
- package/Math/tessellation/zoom-catch.js +0 -1
- package/Math/types.js +0 -1
- package/programs/line-on-globe/linestrip/data.js +0 -4
- package/programs/polygon-on-globe/partial-tesselation.js +0 -1
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin-triangle.js +0 -204
- package/programs/polygon-on-globe/texture-dem-triangle-test-plugin.js +0 -118
- package/programs/polygon-on-globe/texture-dem-triangles.js +0 -236
- package/programs/vectorfields/logics/drawrectangleparticles.js +0 -112
- package/programs/vectorfields/logics/ubo-new.js +0 -25
- package/range-tools-on-terrain/bearing-line/types.js +0 -1
- package/range-tools-on-terrain/circle-line-chain/types.js +0 -1
- package/range-tools-on-terrain/range-ring/rangeringangletext.js +0 -331
- package/range-tools-on-terrain/range-ring/types.js +0 -9
- package/semiplugins/interface.js +0 -1
- package/semiplugins/shape-on-terrain/terrain-cover/texture-dem-cover.js +0 -1
- package/semiplugins/shell/bbox-renderer/index.js +0 -2
- package/semiplugins/shell/bbox-renderer/object.js +0 -65
- package/semiplugins/type.js +0 -1
- package/types.js +0 -19
- package/util/account/create-buffermap-orchastration.js +0 -39
- package/util/account/single-attribute-buffer-management/types.js +0 -1
- package/util/check/typecheck.js +0 -66
- package/util/gl-util/uniform-block/types.js +0 -1
- package/util/picking/picker-displayer.js +0 -134
- package/util/webglobe/index.js +0 -2
- package/util/webglobe/rasteroverlay.js +0 -76
- package/vectorfield/waveparticles/plugin.js +0 -290
- package/write-text/attached-text-writer.js +0 -95
- package/write-text/context-text3.js +0 -167
|
@@ -1,472 +1,616 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (this.
|
|
146
|
-
console.warn("
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
for (const { key,
|
|
155
|
-
const arcInput = this._arcMap.get(key);
|
|
156
|
-
if (!arcInput) {
|
|
157
|
-
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
this.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
this.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}
|
|
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
|
+
}
|