@pirireis/webglobeplugins 0.11.1-alpha → 0.13.0-alpha
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/arc-cdf-points.js +252 -0
- package/Math/{arc-generate-points.js → arc-generate-points copy.js } +4 -0
- package/Math/arc-generate-points-exponantial.js +254 -0
- package/Math/arc.js +5 -5
- package/Math/circle-cdf-points.js +247 -0
- package/Math/circle.js +39 -0
- package/Math/methods.js +13 -3
- package/Math/vec3.js +3 -3
- package/package.json +1 -1
- package/programs/line-on-globe/circle-accurate.js +176 -175
- package/programs/line-on-globe/circle.js +166 -164
- package/programs/line-on-globe/linestrip/data.js +4 -0
- package/programs/line-on-globe/{linestrip.js → linestrip/linestrip.js} +38 -39
- package/programs/line-on-globe/to-the-surface.js +111 -109
- package/programs/rings/distancering/circleflatprogram.js +116 -120
- package/programs/rings/distancering/circlepaddingfreeangleprogram.js +1 -1
- package/programs/rings/distancering/circlepaddysharedbuffer.js +368 -354
- package/programs/rings/distancering/index.js +6 -5
- package/programs/rings/distancering/paddyflatprogram.js +127 -136
- package/programs/rings/distancering/paddyflatprogram2d.js +129 -138
- package/programs/rings/distancering/paddyflatprogram3d.js +128 -136
- package/programs/totems/camerauniformblock.js +35 -8
- package/programs/totems/canvas-webglobe-info.js +55 -20
- package/programs/totems/{camerauniformblock copy.js → canvas-webglobe-info1.js} +11 -76
- package/programs/vectorfields/logics/pixelbased.js +4 -20
- package/shape-on-terrain/arc/naive/plugin.js +249 -288
- package/shape-on-terrain/circle/plugin.js +284 -0
- package/shape-on-terrain/type.js +1 -0
- package/util/account/index.js +2 -2
- package/util/account/single-attribute-buffer-management/buffer-manager.js +2 -3
- package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +2 -2
- package/util/build-strategy/general-strategy.js +62 -0
- package/util/build-strategy/static-dynamic.js +31 -0
- package/util/gl-util/draw-options/types.js +1 -1
- package/globe-types.js +0 -1
- package/programs/interface.js +0 -1
- package/programs/rings/distancering/shader.js +0 -1
- package/programs/totems/camerauniformblock1.js +0 -171
|
@@ -34,7 +34,7 @@ vec2 read_value(const vec2 uv) {
|
|
|
34
34
|
return value;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
vec2 lookup_wind(const vec2 uv) {
|
|
37
|
+
vec2 lookup_wind(const vec2 uv) {
|
|
38
38
|
// return texture(vector_field, uv).rg; // lower-res hardware filtering
|
|
39
39
|
vec2 res = vec2(textureSize(vector_field, 0));
|
|
40
40
|
vec2 px = 1.0 / res;
|
|
@@ -49,23 +49,7 @@ vec2 lookup_wind(const vec2 uv) { // gerek kalmayabilir. sampler linear methodu
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
// return texture(vector_field, uv).rg; // lower-res hardware filtering
|
|
54
|
-
vec2 res = vec2(textureSize(vector_field, 0));
|
|
55
|
-
if (res.x == escape_value || res.y == escape_value){ return vec2(0.0);}
|
|
56
|
-
vec2 px = 1.0 / res;
|
|
57
|
-
vec2 vc = (floor(uv * res)) * px;
|
|
58
|
-
vec2 f = fract(uv * res);
|
|
59
|
-
vec2 tl = texture(vector_field, vc).rg;
|
|
60
|
-
vec2 tr = texture(vector_field, vc + vec2(px.x, 0)).rg;
|
|
61
|
-
vec2 bl = texture(vector_field, vc + vec2(0, px.y)).rg;
|
|
62
|
-
vec2 br = texture(vector_field, vc + px).rg;
|
|
63
|
-
if (tl.x == 0.0 && tl.y == 0.0){ return vec2(0.0);}
|
|
64
|
-
if (tr.x == 0.0 && tr.y == 0.0){ return vec2(0.0);}
|
|
65
|
-
if (bl.x == 0.0 && bl.y == 0.0){ return vec2(0.0);}
|
|
66
|
-
if (br.x == 0.0 && br.y == 0.0){ return vec2(0.0);}
|
|
67
|
-
return mix(mix(tl, tr, f.x), mix(bl, br, f.x), f.y);
|
|
68
|
-
}
|
|
52
|
+
|
|
69
53
|
|
|
70
54
|
|
|
71
55
|
vec2 random_position(vec2 st){
|
|
@@ -80,11 +64,11 @@ void main(){
|
|
|
80
64
|
return;
|
|
81
65
|
}
|
|
82
66
|
float random_value = random(in_position + random_seed);
|
|
83
|
-
if (random_value < drop_rate){
|
|
67
|
+
if (random_value < drop_rate){
|
|
84
68
|
out_position = random_position(in_position);
|
|
85
69
|
return;
|
|
86
70
|
}
|
|
87
|
-
out_position = in_position
|
|
71
|
+
out_position = in_position + (vec / draw_texture_size) * range;
|
|
88
72
|
}
|
|
89
73
|
`;
|
|
90
74
|
const fragmentShaderSource = `#version 300 es
|
|
@@ -1,289 +1,250 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// import "../../../programs/interface";
|
|
4
|
-
// import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
|
|
1
|
+
import { LineStripProgramCache } from "../../../programs/line-on-globe/linestrip/linestrip";
|
|
2
|
+
import { createBufferAndReadInfo } from '../../../util/gl-util/buffer/attribute-loader';
|
|
5
3
|
// import { populateFloat32Array } from "../../../util/jshelpers/data-filler";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// first: 0,
|
|
254
|
-
// count: this._testOrchestrator.length * (VERTEX_COUNT + 1)
|
|
255
|
-
// },
|
|
256
|
-
// indexes: null
|
|
257
|
-
// }
|
|
258
|
-
// program.draw(
|
|
259
|
-
// this._vaoAllTest,
|
|
260
|
-
// drawOptionTest,
|
|
261
|
-
// this._opacity,
|
|
262
|
-
// this._ubohandlerAllTest
|
|
263
|
-
// );
|
|
264
|
-
// const drawOptions = {
|
|
265
|
-
// drawRange: {
|
|
266
|
-
// first: 0,
|
|
267
|
-
// count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
|
|
268
|
-
// },
|
|
269
|
-
// indexes: null
|
|
270
|
-
// }
|
|
271
|
-
// program.draw(
|
|
272
|
-
// this._vao,
|
|
273
|
-
// drawOptions,
|
|
274
|
-
// this._opacity,
|
|
275
|
-
// this._arcUBOHandler
|
|
276
|
-
// );
|
|
277
|
-
// gl.enable(gl.DEPTH_TEST);
|
|
278
|
-
// }
|
|
279
|
-
// _checkIfCorrupted() {
|
|
280
|
-
// for (const [key, arc] of this._arcMap) {
|
|
281
|
-
// if (!arc.p0.equals(arc.p1)) {
|
|
282
|
-
// continue; // valid arc
|
|
283
|
-
// }
|
|
284
|
-
// console.warn(`Arc with key ${key} is corrupted: p0 and p1 are the same point.`);
|
|
285
|
-
// // this._arcMap.delete(key);
|
|
286
|
-
// // this._arcMapTest.delete(key);
|
|
287
|
-
// }
|
|
288
|
-
// }
|
|
289
|
-
// }
|
|
4
|
+
import { BufferManager, BufferOrchestrator } from "../../../util/account/single-attribute-buffer-management/index";
|
|
5
|
+
import { globe3Dcoordinates, globe2Dcoordinates, RADIANS } from "../../../Math/methods";
|
|
6
|
+
import { generateArcPoints } from "../../../Math/arc-cdf-points";
|
|
7
|
+
import { StaticDynamicState, StaticDynamicStrategy } from "../../../util/build-strategy/static-dynamic";
|
|
8
|
+
import * as vec3 from "../../../Math/vec3";
|
|
9
|
+
import * as arc from "../../../Math/arc";
|
|
10
|
+
import { CameraUniformBlockTotemCache } from "../../../programs/totems/camerauniformblock";
|
|
11
|
+
import { WORLD_RADIUS_3D } from "../../../Math/constants";
|
|
12
|
+
const VERTEX_COUNT = 70;
|
|
13
|
+
const INITAL_CAPACITY = 10;
|
|
14
|
+
const _attractionPoint = [0, 0, 0];
|
|
15
|
+
const _start = [0, 0, 0];
|
|
16
|
+
const _end = [0, 0, 0];
|
|
17
|
+
const _0arc = arc.create([1, 0, 0], [0, 1, 0]); // zero arc for intersection tests
|
|
18
|
+
const _colorArray = new Float32Array(4); // For color buffer
|
|
19
|
+
export class NaiveLineOnTerrainPlugin {
|
|
20
|
+
id;
|
|
21
|
+
program = null;
|
|
22
|
+
bufferManagerMap = null;
|
|
23
|
+
_bufferOrchestrator = new BufferOrchestrator({ capacity: INITAL_CAPACITY });
|
|
24
|
+
_opacity = 1;
|
|
25
|
+
_arcUBOHandler = null;
|
|
26
|
+
_vao = null;
|
|
27
|
+
globe = null;
|
|
28
|
+
gl = null;
|
|
29
|
+
_arcMap;
|
|
30
|
+
_cameraUniformBlock = null;
|
|
31
|
+
_staticDynamicStrategy = null;
|
|
32
|
+
_styleOptions = {
|
|
33
|
+
variativeColorsOn: false,
|
|
34
|
+
defaultColor: [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
35
|
+
defaultHeightFromGroundIn3D: 30.0 // Default height from ground in
|
|
36
|
+
};
|
|
37
|
+
constructor(id, drawStyleOptions = null) {
|
|
38
|
+
this.id = id;
|
|
39
|
+
this._arcMap = new Map();
|
|
40
|
+
if (drawStyleOptions) {
|
|
41
|
+
this._styleOptions = drawStyleOptions;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
insertArcFromLongLat(key, startPoint, endPoint, height = null) {
|
|
45
|
+
if (this._arcMap.has(key)) {
|
|
46
|
+
this._arcMap.delete(key);
|
|
47
|
+
}
|
|
48
|
+
vec3.fromLongLatToUnitVector(_start, [startPoint.long * RADIANS, startPoint.lat * RADIANS]);
|
|
49
|
+
vec3.fromLongLatToUnitVector(_end, [endPoint.long * RADIANS, endPoint.lat * RADIANS]);
|
|
50
|
+
const _arc = arc.create(_start, _end);
|
|
51
|
+
this._arcMap.set(key, [_arc, height]);
|
|
52
|
+
// TODO: insert into buffer if NOT DYNAMIC state
|
|
53
|
+
if (this._staticDynamicStrategy?.getState() !== StaticDynamicState.DYNAMIC) {
|
|
54
|
+
this.__buildStaticArcs([key]);
|
|
55
|
+
}
|
|
56
|
+
this.globe.DrawRender();
|
|
57
|
+
}
|
|
58
|
+
deleteArcs(keys) {
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
if (this._arcMap.has(key)) {
|
|
61
|
+
this._arcMap.delete(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// DELETE FROM BUFFER IF not DYNAMIC state
|
|
65
|
+
this.globe.DrawRender();
|
|
66
|
+
}
|
|
67
|
+
init(globe, gl) {
|
|
68
|
+
this.globe = globe;
|
|
69
|
+
this.gl = gl;
|
|
70
|
+
this.program = LineStripProgramCache.get(globe);
|
|
71
|
+
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8); // Initialize static-dynamic strategy with a transition level of 8
|
|
72
|
+
const g2D = globe2Dcoordinates(globe);
|
|
73
|
+
this._cameraUniformBlock = CameraUniformBlockTotemCache.get(globe);
|
|
74
|
+
this._staticDynamicStrategy = new StaticDynamicStrategy(globe, 8); // Initialize static-dynamic strategy with a transition level of 8
|
|
75
|
+
this.bufferManagerMap = new Map([
|
|
76
|
+
["position3d", {
|
|
77
|
+
bufferManager: new BufferManager(gl, 3 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
78
|
+
adaptor: (item) => {
|
|
79
|
+
const { longLatArr, height = this._styleOptions.defaultHeightFromGroundIn3D } = item;
|
|
80
|
+
const result = globe3Dcoordinates(globe, height)(longLatArr, { paddingCount: 1 });
|
|
81
|
+
// console.log("result", result);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
}],
|
|
85
|
+
["position2d", {
|
|
86
|
+
bufferManager: new BufferManager(gl, 2 * (VERTEX_COUNT + 1), { bufferType: "DYNAMIC_DRAW", initialCapacity: INITAL_CAPACITY }),
|
|
87
|
+
adaptor: (item) => {
|
|
88
|
+
const { longLatArr } = item;
|
|
89
|
+
return g2D(longLatArr, { paddingCount: 1 });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
]);
|
|
94
|
+
if (this._styleOptions.variativeColorsOn) {
|
|
95
|
+
this.bufferManagerMap.set("color", {
|
|
96
|
+
bufferManager: new BufferManager(gl, 4, { initialCapacity: INITAL_CAPACITY }),
|
|
97
|
+
adaptor: (item) => {
|
|
98
|
+
const { radius } = item;
|
|
99
|
+
// Calculate color based on radius
|
|
100
|
+
if (item.color) {
|
|
101
|
+
_colorArray.set(item.color);
|
|
102
|
+
return _colorArray;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return this._styleOptions.defaultColor;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
this._bufferOrchestrator = new BufferOrchestrator();
|
|
111
|
+
this._arcUBOHandler = this.program.createUBO();
|
|
112
|
+
this._arcUBOHandler.update(new Map([
|
|
113
|
+
["u_color", new Float32Array([1, 0, 0, 1])],
|
|
114
|
+
]));
|
|
115
|
+
this._vao = this.program.createVAO(createBufferAndReadInfo(this.bufferManagerMap.get("position3d")?.bufferManager.buffer), createBufferAndReadInfo(this.bufferManagerMap.get("position2d")?.bufferManager.buffer), null);
|
|
116
|
+
}
|
|
117
|
+
draw3D() {
|
|
118
|
+
// Drawing logic here
|
|
119
|
+
if (!this.globe || !this.gl) {
|
|
120
|
+
console.warn("Globe or WebGL context is not initialized.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this._staticDynamicStrategy?.updateState();
|
|
124
|
+
this._buildArcs(); // can be async
|
|
125
|
+
const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
126
|
+
if (!gl || !program || !_bufferOrchestrator || !_vao || !_arcUBOHandler) {
|
|
127
|
+
console.warn("WebGL context, program, or buffer orchestrator is not initialized.");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
gl.disable(gl.DEPTH_TEST);
|
|
131
|
+
const drawOptions = {
|
|
132
|
+
drawRange: {
|
|
133
|
+
first: 0,
|
|
134
|
+
count: _bufferOrchestrator.length * (VERTEX_COUNT + 1)
|
|
135
|
+
},
|
|
136
|
+
indexes: null
|
|
137
|
+
};
|
|
138
|
+
program.draw(_vao, drawOptions, this._opacity, _arcUBOHandler);
|
|
139
|
+
gl.enable(gl.DEPTH_TEST);
|
|
140
|
+
}
|
|
141
|
+
_buildArcs() {
|
|
142
|
+
const state = this._staticDynamicStrategy?.getState();
|
|
143
|
+
if (state === StaticDynamicState.TO_STATIC) {
|
|
144
|
+
this.__buildStaticArcs();
|
|
145
|
+
}
|
|
146
|
+
else if (state === StaticDynamicState.DYNAMIC) {
|
|
147
|
+
this.__buildArcs();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
__buildStaticArcs(keys = []) {
|
|
151
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap, _bufferOrchestrator } = this;
|
|
152
|
+
if (!globe || !_cameraUniformBlock || !bufferManagerMap || !_bufferOrchestrator) {
|
|
153
|
+
console.warn("Globe or camera uniform block is not initialized.");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const longLat = [0, 0];
|
|
157
|
+
const _attractionStrength = 0;
|
|
158
|
+
const longLatArr = new Float32Array(2 * VERTEX_COUNT);
|
|
159
|
+
const data = [{
|
|
160
|
+
key: "staticArcs",
|
|
161
|
+
longLatArr: longLatArr,
|
|
162
|
+
height: null
|
|
163
|
+
}];
|
|
164
|
+
if (keys.length == 0) {
|
|
165
|
+
for (const [key, [arcInstance, height]] of _arcMap) {
|
|
166
|
+
arc.copy(_0arc, arcInstance);
|
|
167
|
+
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
168
|
+
for (let i = 0; i < generatedPoints.length; i++) {
|
|
169
|
+
const point = generatedPoints[i];
|
|
170
|
+
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
171
|
+
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
172
|
+
}
|
|
173
|
+
data[0].key = key;
|
|
174
|
+
data[0].height = height;
|
|
175
|
+
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
for (let key of keys) {
|
|
180
|
+
if (!_arcMap.has(key)) {
|
|
181
|
+
console.warn(`Arc with key ${key} not found in arcMap.`);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const [arcInstance, height] = _arcMap.get(key);
|
|
185
|
+
arc.copy(_0arc, arcInstance);
|
|
186
|
+
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
187
|
+
for (let i = 0; i < generatedPoints.length; i++) {
|
|
188
|
+
const point = generatedPoints[i];
|
|
189
|
+
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
190
|
+
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
191
|
+
}
|
|
192
|
+
data[0].key = key;
|
|
193
|
+
data[0].height = height;
|
|
194
|
+
this._bufferOrchestrator.insertBulk(data, bufferManagerMap);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
__buildArcs() {
|
|
199
|
+
const { globe, _arcMap, _cameraUniformBlock, bufferManagerMap } = this;
|
|
200
|
+
if (!globe || !_cameraUniformBlock || !bufferManagerMap) {
|
|
201
|
+
console.warn("Globe or camera uniform block is not initialized.");
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const lookAtPosition = _cameraUniformBlock.getLookAtVector();
|
|
205
|
+
const cameraPosition = _cameraUniformBlock.getCameraVector();
|
|
206
|
+
vec3.divideScalar(cameraPosition, cameraPosition, WORLD_RADIUS_3D);
|
|
207
|
+
vec3.add(cameraPosition, cameraPosition, lookAtPosition);
|
|
208
|
+
// vec3.normalize(cameraPosition, cameraPosition);
|
|
209
|
+
vec3.divideScalar(cameraPosition, cameraPosition, 2);
|
|
210
|
+
// vec3.multiplyScalar(cameraPosition, cameraPosition, 1.3);
|
|
211
|
+
const _attractionStrength = (() => {
|
|
212
|
+
const lod = globe.api_GetCurrentLODWithDecimal();
|
|
213
|
+
if (lod < 11) {
|
|
214
|
+
return 1;
|
|
215
|
+
}
|
|
216
|
+
return lod * (lod - 8.5);
|
|
217
|
+
})();
|
|
218
|
+
console.log("Attraction strength: ", _attractionStrength);
|
|
219
|
+
const result = [];
|
|
220
|
+
const longLat = [0, 0];
|
|
221
|
+
for (const [key, [arcInstance, height]] of _arcMap) {
|
|
222
|
+
arc.copy(_0arc, arcInstance);
|
|
223
|
+
const isOnArc = arc.closestPoint(_attractionPoint, _0arc, cameraPosition);
|
|
224
|
+
if (!isOnArc) {
|
|
225
|
+
if (vec3.distanceSquared(cameraPosition, _0arc.p0) < vec3.distanceSquared(cameraPosition, _0arc.p1)) {
|
|
226
|
+
vec3.copy(_attractionPoint, _0arc.p0);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
vec3.copy(_attractionPoint, _0arc.p1);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const generatedPoints = generateArcPoints(_0arc.p0, _0arc.p1, _0arc.normal, _attractionPoint, VERTEX_COUNT, _attractionStrength);
|
|
233
|
+
const longLatArr = new Float32Array(2 * VERTEX_COUNT);
|
|
234
|
+
for (let i = 0; i < generatedPoints.length; i++) {
|
|
235
|
+
const point = generatedPoints[i];
|
|
236
|
+
vec3.fromUnitVectorToLongLat(longLat, point);
|
|
237
|
+
longLatArr.set([longLat[0] / RADIANS, longLat[1] / RADIANS], i * 2);
|
|
238
|
+
}
|
|
239
|
+
result.push({
|
|
240
|
+
key: key,
|
|
241
|
+
longLatArr: longLatArr,
|
|
242
|
+
height: height
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
this._bufferOrchestrator.resetWithCapacity(bufferManagerMap, result.length);
|
|
246
|
+
this._bufferOrchestrator.insertBulk(result, bufferManagerMap);
|
|
247
|
+
}
|
|
248
|
+
_buildStaticArc() {
|
|
249
|
+
}
|
|
250
|
+
}
|