@pirireis/webglobeplugins 1.0.2 → 1.0.3
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.ts → angle-calculation.js} +14 -18
- package/Math/{arc-cdf-points.ts → arc-cdf-points.js} +272 -329
- package/Math/{arc-generate-points-exponantial.ts → arc-generate-points-exponantial.js} +254 -299
- package/Math/{arc.ts → arc.js} +292 -421
- package/Math/bounds/line-bbox.js +186 -225
- package/Math/{circle-cdf-points.ts → circle-cdf-points.js} +78 -143
- package/Math/{circle.ts → circle.js} +33 -49
- package/Math/{constants.ts → constants.js} +4 -12
- package/Math/contour/{quadtreecontours.ts → quadtreecontours.js} +300 -371
- package/Math/contour/quadtreecontours1.js +298 -336
- package/Math/{finite-line-2d.ts → finite-line-2d.js} +58 -68
- package/Math/{haversine.ts → haversine.js} +22 -33
- package/Math/index.js +1 -0
- package/Math/juction/{arc-plane.ts → arc-plane.js} +143 -203
- package/Math/juction/{line-sphere.ts → line-sphere.js} +22 -32
- package/Math/juction/{plane-plane.ts → plane-plane.js} +53 -62
- package/Math/{line.ts → line.js} +52 -84
- package/Math/matrix4.js +1 -0
- package/Math/{methods.ts → methods.js} +126 -182
- package/Math/{plane.ts → plane.js} +56 -92
- package/Math/{quaternion.ts → quaternion.js} +106 -128
- package/Math/templete-shapes/{grid-visually-equal.ts → grid-visually-equal.js} +65 -118
- package/Math/tessellation/constants.js +1 -0
- package/Math/tessellation/{methods.ts → methods.js} +49 -79
- package/Math/tessellation/{nearest-value-padding.ts → nearest-value-padding.js} +112 -147
- package/Math/tessellation/{spherical-triangle-area.ts → spherical-triangle-area.js} +99 -127
- package/Math/tessellation/{tile-merger.ts → tile-merger.js} +429 -578
- package/Math/tessellation/{triangle-tessellation.ts → triangle-tessellation.js} +386 -533
- package/Math/tessellation/types.js +1 -0
- package/Math/types.js +1 -0
- package/Math/utils.js +2 -3
- package/Math/{vec3.ts → vec3.js} +155 -227
- package/Math/{xyz-tile.ts → xyz-tile.js} +18 -26
- package/algorithms/search-binary.js +16 -14
- package/altitude-locator/adaptors.js +1 -0
- package/altitude-locator/keymethod.js +1 -0
- package/altitude-locator/plugin.js +344 -445
- package/altitude-locator/types.js +21 -26
- package/compass-rose/compass-rose-padding-flat.js +230 -274
- package/compass-rose/{compass-text-writer.ts → compass-text-writer.js} +155 -210
- package/compass-rose/index.js +3 -3
- package/{constants.ts → constants.js} +6 -8
- package/heatwave/datamanager.js +149 -168
- package/heatwave/heatwave.js +206 -261
- package/heatwave/index.js +5 -5
- package/heatwave/isobar.js +303 -340
- package/heatwave/{texture-point-sampler.ts → texture-point-sampler.js} +187 -220
- package/investigation-tools/draw/tiles/adapters.js +67 -0
- package/investigation-tools/draw/tiles/{tiles.ts → tiles.js} +128 -162
- package/jest.config.js +7 -6
- package/package.json +1 -1
- package/pin/pin-object-array1.js +300 -381
- package/pin/pin-point-totem1.js +60 -77
- package/programs/arrowfield/arrow-field.js +60 -89
- package/programs/arrowfield/logic.js +141 -173
- package/programs/data2legend/density-to-legend.js +68 -86
- package/programs/data2legend/point-to-density-texture.js +67 -84
- package/programs/float2legendwithratio/index.js +2 -3
- package/programs/float2legendwithratio/logic.js +118 -144
- package/programs/float2legendwithratio/object.js +104 -141
- package/programs/helpers/blender.js +58 -73
- package/programs/helpers/{fadeaway.ts → fadeaway.js} +60 -73
- package/programs/index.js +20 -19
- package/programs/line-on-globe/circle-accurate-3d.js +85 -112
- package/programs/line-on-globe/circle-accurate-flat.js +148 -200
- package/programs/line-on-globe/degree-padding-around-circle-3d.js +102 -134
- package/programs/line-on-globe/index.js +1 -0
- package/programs/line-on-globe/lines-color-instanced-flat.js +80 -99
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/linestrip/{linestrip.ts → linestrip.js} +93 -152
- package/programs/line-on-globe/{naive-accurate-flexible.ts → naive-accurate-flexible.js} +126 -175
- package/programs/line-on-globe/util.js +5 -8
- package/programs/picking/pickable-polygon-renderer.js +98 -129
- package/programs/picking/pickable-renderer.js +98 -130
- package/programs/point-on-globe/element-globe-surface-glow.js +93 -122
- package/programs/point-on-globe/element-point-glow.js +80 -114
- package/programs/point-on-globe/square-pixel-point.js +121 -139
- package/programs/polygon-on-globe/{texture-dem-triangles.ts → texture-dem-triangles.js} +163 -207
- package/programs/{programcache.ts → programcache.js} +126 -134
- package/programs/rings/index.js +1 -1
- package/programs/rings/partial-ring/{piece-of-pie.ts → piece-of-pie.js} +152 -222
- package/programs/totems/camera-totem-attactment-interface.js +1 -0
- package/programs/totems/{camerauniformblock.ts → camerauniformblock.js} +225 -310
- package/programs/totems/{canvas-webglobe-info.ts → canvas-webglobe-info.js} +132 -147
- package/programs/totems/{dem-textures-manager.ts → dem-textures-manager.js} +257 -360
- package/programs/totems/{globe-changes.ts → globe-changes.js} +59 -79
- package/programs/totems/gpu-selection-uniform-block.js +99 -127
- package/programs/totems/{index.ts → index.js} +2 -2
- package/programs/two-d/pixel-padding-for-compass.js +87 -101
- package/programs/util.js +14 -19
- package/programs/vectorfields/logics/{constants.ts → constants.js} +4 -5
- package/programs/vectorfields/logics/{drawrectangleparticles.ts → drawrectangleparticles.js} +80 -115
- package/programs/vectorfields/logics/index.js +2 -4
- package/programs/vectorfields/logics/particle-ubo.js +16 -0
- package/programs/vectorfields/logics/{pixelbased.ts → pixelbased.js} +86 -115
- package/programs/vectorfields/logics/ubo.js +51 -57
- package/programs/vectorfields/{pingpongbuffermanager.ts → pingpongbuffermanager.js} +99 -113
- package/range-tools-on-terrain/bearing-line/{adapters.ts → adapters.js} +114 -154
- package/range-tools-on-terrain/bearing-line/{plugin.ts → plugin.js} +457 -569
- package/range-tools-on-terrain/bearing-line/types.js +1 -0
- package/range-tools-on-terrain/circle-line-chain/{adapters.ts → adapters.js} +85 -104
- package/range-tools-on-terrain/circle-line-chain/{chain-list-map.ts → chain-list-map.js} +382 -446
- package/range-tools-on-terrain/circle-line-chain/{plugin.ts → plugin.js} +464 -607
- package/range-tools-on-terrain/circle-line-chain/types.js +1 -0
- package/range-tools-on-terrain/range-ring/{adapters.ts → adapters.js} +93 -114
- package/range-tools-on-terrain/range-ring/{enum.ts → enum.js} +2 -2
- package/range-tools-on-terrain/range-ring/{plugin.ts → plugin.js} +377 -444
- package/range-tools-on-terrain/range-ring/rangeringangletext.js +331 -0
- package/range-tools-on-terrain/range-ring/types.js +9 -0
- package/semiplugins/interface.js +1 -0
- package/semiplugins/lightweight/{line-plugin.ts → line-plugin.js} +221 -342
- package/semiplugins/lightweight/{piece-of-pie-plugin.ts → piece-of-pie-plugin.js} +200 -275
- package/semiplugins/shape-on-terrain/{arc-plugin.ts → arc-plugin.js} +481 -616
- package/semiplugins/shape-on-terrain/{circle-plugin.ts → circle-plugin.js} +444 -588
- package/semiplugins/shape-on-terrain/{padding-1-degree.ts → padding-1-degree.js} +539 -713
- package/semiplugins/shape-on-terrain/terrain-polygon/{adapters.ts → adapters.js} +55 -69
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{cache.ts → cache.js} +102 -149
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{index-polygon-map.ts → index-polygon-map.js} +45 -58
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{manager.ts → manager.js} +4 -4
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +177 -196
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{polygon-to-triangles.ts → polygon-to-triangles.js} +100 -144
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{random.ts → random.js} +121 -165
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.js +1 -0
- package/semiplugins/shape-on-terrain/terrain-polygon/data/{worker-contact.ts → worker-contact.js} +63 -81
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +125 -146
- package/semiplugins/shape-on-terrain/terrain-polygon/{terrain-polygon.ts → terrain-polygon.js} +219 -265
- package/semiplugins/shape-on-terrain/terrain-polygon/types.js +8 -0
- package/semiplugins/shell/bbox-renderer/index.js +2 -0
- package/semiplugins/shell/bbox-renderer/{logic.ts → logic.js} +209 -273
- package/semiplugins/shell/bbox-renderer/object.js +75 -0
- package/semiplugins/type.js +1 -0
- package/semiplugins/utility/{container-plugin.ts → container-plugin.js} +94 -126
- package/semiplugins/utility/{object-pass-container-plugin.ts → object-pass-container-plugin.js} +80 -101
- package/shaders/fragment-toy/firework.js +1 -1
- package/shaders/fragment-toy/singularity.js +2 -5
- package/tracks/point-heat-map/adaptors/timetracksplugin-format-to-this.js +63 -78
- package/tracks/point-heat-map/index.js +1 -0
- package/tracks/point-heat-map/plugin-webworker.js +121 -148
- package/tracks/point-heat-map/point-to-heat-map-flow.js +121 -150
- package/tracks/point-tracks/key-methods.js +2 -3
- package/tracks/point-tracks/plugin.js +401 -487
- package/tracks/timetracks/adaptors-line-strip.js +65 -79
- package/tracks/timetracks/plugin-line-strip.js +240 -295
- package/tracks/timetracks/program-line-strip.js +411 -495
- package/tracks/timetracks/programpoint-line-strip.js +109 -137
- package/types.js +19 -0
- package/util/account/bufferoffsetmanager.js +176 -209
- package/util/account/create-buffermap-orchastration.js +39 -0
- package/util/account/index.js +3 -6
- package/util/account/single-attribute-buffer-management/{buffer-manager.ts → buffer-manager.js} +119 -151
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator.ts → buffer-orchestrator.js} +212 -238
- package/util/account/single-attribute-buffer-management/{buffer-orchestrator1.ts → buffer-orchestrator1.js} +159 -184
- package/util/account/single-attribute-buffer-management/{index.ts → index.js} +4 -11
- package/util/account/single-attribute-buffer-management/{object-store.ts → object-store.js} +55 -76
- package/util/account/single-attribute-buffer-management/types.js +1 -0
- package/util/account/util.js +18 -22
- package/util/algorithms/index.js +1 -0
- package/util/algorithms/search-binary.js +25 -26
- package/util/build-strategy/{static-dynamic.ts → static-dynamic.js} +41 -50
- package/util/check/index.js +1 -0
- package/util/check/typecheck.js +66 -0
- package/util/{frame-counter-trigger.ts → frame-counter-trigger.js} +84 -99
- package/util/geometry/{index.ts → index.js} +121 -155
- package/util/gl-util/buffer/{attribute-loader.ts → attribute-loader.js} +62 -84
- package/util/gl-util/buffer/{index.ts → index.js} +3 -6
- package/util/gl-util/draw-options/{methods.ts → methods.js} +32 -47
- package/util/gl-util/uniform-block/{manager.ts → manager.js} +200 -232
- package/util/{globe-default-gl-states.ts → globe-default-gl-states.js} +4 -5
- package/util/{helper-methods.ts → helper-methods.js} +8 -9
- package/util/index.js +10 -9
- package/util/interpolation/index.js +1 -0
- package/util/interpolation/timetrack/index.js +2 -9
- package/util/interpolation/timetrack/timetrack-interpolator.js +79 -94
- package/util/interpolation/timetrack/web-worker.js +46 -51
- package/util/picking/{fence.ts → fence.js} +43 -47
- package/util/picking/{picker-displayer.ts → picker-displayer.js} +176 -226
- package/util/programs/draw-from-pixel-coords.js +164 -201
- package/util/programs/{draw-texture-on-canvas.ts → draw-texture-on-canvas.js} +69 -91
- package/util/programs/supersampletotextures.js +97 -130
- package/util/programs/texturetoglobe.js +128 -153
- package/util/shaderfunctions/{geometrytransformations.ts → geometrytransformations.js} +44 -106
- package/util/shaderfunctions/index.js +2 -2
- package/util/shaderfunctions/nodata.js +2 -4
- package/util/shaderfunctions/noisefunctions.js +7 -10
- package/util/{webglobjectbuilders.ts → webglobjectbuilders.js} +358 -446
- package/vectorfield/arrowfield/adaptor.js +11 -11
- package/vectorfield/arrowfield/index.js +3 -3
- package/vectorfield/arrowfield/plugin.js +83 -128
- package/vectorfield/waveparticles/adaptor.js +15 -16
- package/vectorfield/waveparticles/index.js +3 -3
- package/vectorfield/waveparticles/{plugin.ts → plugin.js} +415 -506
- package/vectorfield/wind/adapters/{image-to-fields.ts → image-to-fields.js} +61 -74
- package/vectorfield/wind/adapters/types.js +1 -0
- package/vectorfield/wind/{imagetovectorfieldandmagnitude.ts → imagetovectorfieldandmagnitude.js} +53 -78
- package/vectorfield/wind/index.js +5 -5
- package/vectorfield/wind/{plugin-persistant copy.ts → plugin-persistant copy.js } +364 -461
- package/vectorfield/wind/{plugin-persistant.ts → plugin-persistant.js} +375 -483
- package/vectorfield/wind/plugin.js +685 -883
- package/vectorfield/wind/vectorfieldimage.js +23 -27
- package/write-text/{context-text-bulk.ts → context-text-bulk.js} +200 -285
- package/write-text/context-text3.js +167 -0
- package/write-text/{context-text4.ts → context-text4.js} +146 -231
- package/write-text/context-textDELETE.js +94 -125
- package/write-text/objectarraylabels/{index.ts → index.js} +2 -2
- package/write-text/objectarraylabels/objectarraylabels.js +200 -247
- package/Math/matrix4.ts +0 -0
- package/Math/mesh/mapbox-delaunay.d.ts +0 -74
- package/Math/roadmap.md +0 -10
- package/Math/tessellation/constants.ts +0 -1
- package/Math/tessellation/roadmap.md +0 -48
- package/Math/tessellation/types.ts +0 -1
- package/Math/types.ts +0 -68
- package/investigation-tools/draw/tiles/adapters.ts +0 -133
- package/programs/line-on-globe/linestrip/data.ts +0 -29
- package/programs/polygon-on-globe/roadmap.md +0 -8
- package/programs/totems/camera-totem-attactment-interface.ts +0 -4
- package/programs/vectorfields/logics/particle-ubo.ts +0 -23
- package/publish.bat +0 -62
- package/range-tools-on-terrain/bearing-line/types.ts +0 -65
- package/range-tools-on-terrain/circle-line-chain/types.ts +0 -43
- package/range-tools-on-terrain/range-ring/rangeringangletext.ts +0 -396
- package/range-tools-on-terrain/range-ring/types.ts +0 -30
- package/semiplugins/interface.ts +0 -14
- package/semiplugins/shape-on-terrain/goal.md +0 -12
- package/semiplugins/shape-on-terrain/terrain-polygon/data/cache-shortcuts.md +0 -20
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.ts +0 -209
- package/semiplugins/shape-on-terrain/terrain-polygon/data/readme.md +0 -5
- package/semiplugins/shape-on-terrain/terrain-polygon/data/types.ts +0 -37
- package/semiplugins/shape-on-terrain/terrain-polygon/notes.md +0 -90
- package/semiplugins/shape-on-terrain/terrain-polygon/types.ts +0 -69
- package/semiplugins/shell/bbox-renderer/index.ts +0 -2
- package/semiplugins/shell/bbox-renderer/object.ts +0 -129
- package/semiplugins/type.ts +0 -8
- package/terrain-plugin.mmd +0 -83
- package/tests/Math/arc-sampling-test.js +0 -367
- package/tests/Math/arc-sampling-test.ts +0 -429
- package/tests/Math/arc.test.ts +0 -77
- package/tests/Math/junction/arc-limit.test.ts +0 -7
- package/tests/Math/junction/arc-plane-points.test.ts +0 -196
- package/tests/Math/junction/arc-plane.test.ts +0 -172
- package/tests/Math/junction/line-sphere.test.ts +0 -127
- package/tests/Math/junction/plane-plane.test.ts +0 -91
- package/tests/Math/plane-test.ts +0 -17
- package/tests/Math/plane.test.ts +0 -43
- package/tests/Math/vec3.test.ts +0 -33
- package/tracks/point-heat-map/readme.md +0 -15
- package/tracks/timetracks/readme.md +0 -1
- package/tsconfig.json +0 -22
- package/types/@pirireis/webglobe.d.ts +0 -102
- package/types/delaunator.d.ts +0 -40
- package/types/earcut.d.ts +0 -11
- package/types/rbush.d.ts +0 -57
- package/types.ts +0 -319
- package/util/account/create-buffermap-orchastration.ts +0 -85
- package/util/account/single-attribute-buffer-management/types.ts +0 -43
- package/util/check/typecheck.ts +0 -74
- package/vectorfield/wind/adapters/types.ts +0 -12
- package/write-text/context-text3.ts +0 -252
- package/write-text/objectarraylabels/objectarraylabels.d.ts +0 -72
|
@@ -1,616 +1,481 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
this._options.
|
|
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
|
-
this.
|
|
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
|
-
this.
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
+
}
|