@pirireis/webglobeplugins 0.6.28-b → 0.6.28-c
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.
|
@@ -145,7 +145,7 @@ export class CircleLineChainPlugin {
|
|
|
145
145
|
'bufferManager': new BufferManager(gl, 1 * _circleFlatEdgeCount, { bufferType, initialCapacity }),
|
|
146
146
|
'adaptor': (item) => {
|
|
147
147
|
if (item.circleProperties?.circleDashAngle) return new Float32Array([item.circleProperties.circleDashAngle / 360]);
|
|
148
|
-
return
|
|
148
|
+
return populateFloat32Array.fillFloat32Array(_circleFlatEdgeCount, item.chainProperties.circleDashAngle / 360);
|
|
149
149
|
}
|
|
150
150
|
}],
|
|
151
151
|
["rgbaCircleMercator", { // 62
|
package/package.json
CHANGED
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { CameraUniformBlockString, CameraUniformBlockTotem } from "../totems";
|
|
2
|
-
import { longLatRadToMercator, longLatRadToCartesian3D, cartesian3DToGLPosition, mercatorXYToGLPosition, POLE } from "../../util/shaderfunctions/geometrytransformations";
|
|
3
|
-
import { createProgram } from "../../util";
|
|
4
|
-
import { noRegisterGlobeProgramCache, globeProgramCache } from "../programcache";
|
|
5
|
-
import BufferOffsetManger from "../../util/account/bufferoffsetmanager";
|
|
6
|
-
import { programCache } from "../rings/distancering/circleflatprogram";
|
|
7
|
-
|
|
8
|
-
const GLOBE_MIDPOINT_COUNT = 100;
|
|
9
|
-
const ITEM_SIZE = 9;
|
|
10
|
-
|
|
11
|
-
const vertexShader = `#version 300 es
|
|
12
|
-
precision highp float;
|
|
13
|
-
${CameraUniformBlockString}
|
|
14
|
-
${longLatRadToMercator}
|
|
15
|
-
${longLatRadToCartesian3D}
|
|
16
|
-
${cartesian3DToGLPosition}
|
|
17
|
-
${mercatorXYToGLPosition}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
in vec2 start_position;
|
|
21
|
-
in vec2 end_position;
|
|
22
|
-
in float dash_ratio;
|
|
23
|
-
in vec4 color;
|
|
24
|
-
in float dash_opacity;
|
|
25
|
-
out vec4 v_color;
|
|
26
|
-
out vec2 v_limp;
|
|
27
|
-
out float interpolation;
|
|
28
|
-
out float v_dash_ratio;
|
|
29
|
-
out float v_dash_opacity;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
void main() {
|
|
33
|
-
vec2 longLat;
|
|
34
|
-
if (is3D) {
|
|
35
|
-
interpolation = float(gl_VertexID) / ${GLOBE_MIDPOINT_COUNT - 1}.0;
|
|
36
|
-
longLat = mix(start_position, end_position, interpolation);
|
|
37
|
-
vec3 cartesian = longLatRadToCartesian3D(longLat);
|
|
38
|
-
gl_Position = cartesian3DToGLPosition(cartesian);
|
|
39
|
-
v_limp = vec2(0.0, 0.0);
|
|
40
|
-
} else {
|
|
41
|
-
interpolation = float(gl_VertexID);
|
|
42
|
-
if (gl_VertexID % 2 == 0) {
|
|
43
|
-
longLat = start_position;
|
|
44
|
-
} else {
|
|
45
|
-
longLat = end_position;
|
|
46
|
-
}
|
|
47
|
-
vec2 mercator = longLatRadToMercator(longLat);
|
|
48
|
-
v_limp = mercator;
|
|
49
|
-
gl_Position = mercatorXYToGLPosition(mercator);
|
|
50
|
-
}
|
|
51
|
-
// if ( gl_VertexID % 2 == 0) {v_color = color;}
|
|
52
|
-
// else {v_color = vec4(0.0, 0.0, 0.0, 0.0);}
|
|
53
|
-
v_color = color;
|
|
54
|
-
v_dash_ratio = dash_ratio;
|
|
55
|
-
v_dash_opacity = dash_opacity;
|
|
56
|
-
}
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
const fragmentShader = `#version 300 es
|
|
60
|
-
${POLE}
|
|
61
|
-
precision highp float;
|
|
62
|
-
uniform float opacity;
|
|
63
|
-
in vec4 v_color;
|
|
64
|
-
out vec4 color;
|
|
65
|
-
in float interpolation;
|
|
66
|
-
in float v_dash_ratio;
|
|
67
|
-
in vec2 v_limp;
|
|
68
|
-
in float v_dash_opacity;
|
|
69
|
-
void main() {
|
|
70
|
-
if (v_limp.x < -POLE || v_limp.x > POLE || v_limp.y < -POLE || v_limp.y > POLE) { discard; }
|
|
71
|
-
color = v_color;
|
|
72
|
-
color.a *= opacity;
|
|
73
|
-
if ( v_dash_ratio >= 1.0 ) { return; }
|
|
74
|
-
if (interpolation > 0.95) { return; }
|
|
75
|
-
if (fract(interpolation / (2.0 * v_dash_ratio)) < 0.5) { color.a *= v_dash_opacity; }
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
class Logic {
|
|
82
|
-
|
|
83
|
-
constructor(globe) {
|
|
84
|
-
this.globe = globe;
|
|
85
|
-
this.gl = globe.gl;
|
|
86
|
-
this.program = createProgram(this.gl, vertexShader, fragmentShader);
|
|
87
|
-
this._lastOpacity = 1.0;
|
|
88
|
-
const { gl, program } = this;
|
|
89
|
-
{
|
|
90
|
-
// assign attribute locations
|
|
91
|
-
gl.bindAttribLocation(program, 0, "start_position");
|
|
92
|
-
gl.bindAttribLocation(program, 1, "end_position");
|
|
93
|
-
gl.bindAttribLocation(program, 2, "dash_ratio");
|
|
94
|
-
gl.bindAttribLocation(program, 3, "color");
|
|
95
|
-
gl.bindAttribLocation(program, 4, "dash_opacity");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
{
|
|
99
|
-
this._opacityLocation = gl.getUniformLocation(program, "opacity");
|
|
100
|
-
const currentProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
101
|
-
gl.useProgram(program);
|
|
102
|
-
gl.uniform1f(this._opacityLocation, this._lastOpacity);
|
|
103
|
-
gl.useProgram(currentProgram);
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.cameraBlockBindingPoint = 0;
|
|
108
|
-
const cameraBlockIndex = this.gl.getUniformBlockIndex(this.program, "CameraUniformBlock");
|
|
109
|
-
this.cameraBlockTotem = globeProgramCache.getProgram(globe, CameraUniformBlockTotem);
|
|
110
|
-
gl.uniformBlockBinding(this.program, cameraBlockIndex, this.cameraBlockBindingPoint);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
draw(vao, length, opacity) {
|
|
117
|
-
const { gl, program, globe, cameraBlockTotem, cameraBlockBindingPoint } = this;
|
|
118
|
-
gl.useProgram(program);
|
|
119
|
-
cameraBlockTotem.bind(cameraBlockBindingPoint);
|
|
120
|
-
gl.bindVertexArray(vao);
|
|
121
|
-
if (opacity !== this._lastOpacity) {
|
|
122
|
-
gl.uniform1f(this._opacityLocation, opacity);
|
|
123
|
-
this._lastOpacity = opacity;
|
|
124
|
-
}
|
|
125
|
-
const drawCount = globe.api_GetCurrentGeometry() === 0 ? GLOBE_MIDPOINT_COUNT : 2;
|
|
126
|
-
// gl.disable(gl.DEPTH_TEST);
|
|
127
|
-
gl.drawArraysInstanced(gl.LINE_STRIP, 0, drawCount, length);
|
|
128
|
-
gl.bindVertexArray(null);
|
|
129
|
-
cameraBlockTotem.unbind(cameraBlockBindingPoint);
|
|
130
|
-
// gl.enable(gl.DEPTH_TEST);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
createBufferManager({ capacity = 10, bufferType = "DYNAMIC_DRAW" } = {}) {
|
|
135
|
-
return new BufferManager(this.globe, { capacity, bufferType });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
//
|
|
141
|
-
createVAO(startPotisionBufferObj, endPositionBufferObj, dashRatioBufferObj, dashOpacityBufferObj, colorBufferObj) {
|
|
142
|
-
const { gl } = this;
|
|
143
|
-
const vao = gl.createVertexArray();
|
|
144
|
-
gl.bindVertexArray(vao);
|
|
145
|
-
{
|
|
146
|
-
const { buffer, stride = 0, offset = 0 } = startPotisionBufferObj;
|
|
147
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
148
|
-
gl.enableVertexAttribArray(0);
|
|
149
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, stride, offset);
|
|
150
|
-
gl.vertexAttribDivisor(0, 1);
|
|
151
|
-
}
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
const { buffer, stride = 0, offset = 0 } = endPositionBufferObj;
|
|
155
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
156
|
-
gl.enableVertexAttribArray(1);
|
|
157
|
-
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, stride, offset);
|
|
158
|
-
gl.vertexAttribDivisor(1, 1);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
const { buffer, stride = 0, offset = 0 } = dashRatioBufferObj;
|
|
163
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
164
|
-
gl.enableVertexAttribArray(2);
|
|
165
|
-
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, stride, offset);
|
|
166
|
-
gl.vertexAttribDivisor(2, 1);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
const { buffer, stride = 0, offset = 0 } = colorBufferObj;
|
|
171
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
172
|
-
gl.enableVertexAttribArray(3);
|
|
173
|
-
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, stride, offset);
|
|
174
|
-
gl.vertexAttribDivisor(3, 1);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
{
|
|
178
|
-
const { buffer, stride = 0, offset = 0 } = dashOpacityBufferObj;
|
|
179
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
180
|
-
gl.enableVertexAttribArray(4);
|
|
181
|
-
gl.vertexAttribPointer(4, 1, gl.FLOAT, false, stride, offset);
|
|
182
|
-
gl.vertexAttribDivisor(4, 1);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
gl.bindVertexArray(null);
|
|
186
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
187
|
-
return vao;
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
free() {
|
|
193
|
-
if (this.isFreed) return;
|
|
194
|
-
programCache.releaseProgram(this.globe, CameraUniformBlockTotem);
|
|
195
|
-
this.gl.deleteProgram(this.program);
|
|
196
|
-
this.isFreed = true;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
class BufferManager extends BufferOffsetManger {
|
|
202
|
-
|
|
203
|
-
constructor(globe, { capacity = 10, bufferType = "DYNAMIC_DRAW", } = {}) {
|
|
204
|
-
super(ITEM_SIZE, { capacity, bufferType });
|
|
205
|
-
this.globe = globe
|
|
206
|
-
this.gl = globe.gl;
|
|
207
|
-
this.buffer = this.gl.createBuffer();
|
|
208
|
-
|
|
209
|
-
const { gl, buffer } = this;
|
|
210
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
211
|
-
gl.bufferData(gl.ARRAY_BUFFER, capacity * ITEM_SIZE * 4, gl[bufferType]);
|
|
212
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
213
|
-
|
|
214
|
-
this.vao = gl.createVertexArray();
|
|
215
|
-
{
|
|
216
|
-
gl.bindVertexArray(this.vao);
|
|
217
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
218
|
-
gl.enableVertexAttribArray(0);
|
|
219
|
-
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, ITEM_SIZE * 4, 0);
|
|
220
|
-
gl.enableVertexAttribArray(1);
|
|
221
|
-
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, ITEM_SIZE * 4, 8);
|
|
222
|
-
gl.enableVertexAttribArray(2);
|
|
223
|
-
gl.vertexAttribPointer(2, 1, gl.FLOAT, false, ITEM_SIZE * 4, 16);
|
|
224
|
-
gl.enableVertexAttribArray(3);
|
|
225
|
-
gl.vertexAttribPointer(3, 4, gl.FLOAT, false, ITEM_SIZE * 4, 20);
|
|
226
|
-
gl.vertexAttribDivisor(0, 1);
|
|
227
|
-
gl.vertexAttribDivisor(1, 1);
|
|
228
|
-
gl.vertexAttribDivisor(2, 1);
|
|
229
|
-
gl.vertexAttribDivisor(3, 1);
|
|
230
|
-
gl.bindVertexArray(null);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
*
|
|
237
|
-
* @param {Array<{key:string, long:number, lat:number, endLong:number, endLat:number, rgba:[4numbers] }} items
|
|
238
|
-
*/
|
|
239
|
-
insertBulk(items) {
|
|
240
|
-
this.autoExtendBuffer(items.length)
|
|
241
|
-
const { gl, buffer, globe } = this;
|
|
242
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
243
|
-
for (let { key, long, lat, endLong, endLat, rgba, dashRatio = 1 } of items) {
|
|
244
|
-
const payload = new Float32Array([
|
|
245
|
-
long,
|
|
246
|
-
lat,
|
|
247
|
-
endLong,
|
|
248
|
-
endLat,
|
|
249
|
-
dashRatio,
|
|
250
|
-
...rgba]);
|
|
251
|
-
|
|
252
|
-
const offset = this.getOffset(key) | this.nextOffset();
|
|
253
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
|
|
254
|
-
this.setOffset(key, offset);
|
|
255
|
-
}
|
|
256
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
257
|
-
globe.DrawRender();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
*
|
|
262
|
-
* @param {Array<{key:string, long:number, lat:number, endLong:number, endLat:number, rgba:[4numbers] }} items
|
|
263
|
-
*/
|
|
264
|
-
updateBulk(items) {
|
|
265
|
-
const { gl, buffer, globe } = this;
|
|
266
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
267
|
-
for (let { key, long, lat, endLong, endLat, rgba, dashRatio = 1 } of items) {
|
|
268
|
-
const payload = new Float32Array([
|
|
269
|
-
long,
|
|
270
|
-
lat,
|
|
271
|
-
endLong,
|
|
272
|
-
endLat,
|
|
273
|
-
dashRatio,
|
|
274
|
-
...rgba]);
|
|
275
|
-
const offset = this.getOffset(key);
|
|
276
|
-
if (offset !== undefined) {
|
|
277
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
|
|
278
|
-
} else {
|
|
279
|
-
console.warn("key not found", key);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
283
|
-
globe.DrawRender();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
*
|
|
288
|
-
* @param {Array<{key:string, long:number, lat:number, endLong:number, endLat:number }} items
|
|
289
|
-
*/
|
|
290
|
-
updateCoordinatesBulk(items) {
|
|
291
|
-
const { gl, buffer, globe } = this;
|
|
292
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
293
|
-
for (let { key, long, lat, endLong, endLat, dashRatio = 1 } of items) {
|
|
294
|
-
const payload = new Float32Array([
|
|
295
|
-
long,
|
|
296
|
-
lat,
|
|
297
|
-
endLong,
|
|
298
|
-
endLat,
|
|
299
|
-
dashRatio]);
|
|
300
|
-
const offset = this.getOffset(key);
|
|
301
|
-
if (offset !== undefined) {
|
|
302
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, payload);
|
|
303
|
-
} else {
|
|
304
|
-
console.warn("key not found", key);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
308
|
-
globe.DrawRender();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
*
|
|
314
|
-
* @param {Array<{key:string, rgba:[4numbers] }} items
|
|
315
|
-
*/
|
|
316
|
-
updateColorBulk(items) {
|
|
317
|
-
const { gl, buffer, globe } = this;
|
|
318
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
319
|
-
for (let { key, rgba } of items) {
|
|
320
|
-
const payload = new Float32Array([...rgba]);
|
|
321
|
-
const offset = this.getOffset(key);
|
|
322
|
-
if (offset !== undefined) {
|
|
323
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset + 20, payload);
|
|
324
|
-
} else {
|
|
325
|
-
console.warn("key not found", key);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
329
|
-
globe.DrawRender();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
*
|
|
335
|
-
* @param {Array<string>} keys
|
|
336
|
-
*/
|
|
337
|
-
deleteBulk(keys) {
|
|
338
|
-
const { gl, buffer, globe } = this;
|
|
339
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
340
|
-
const emptyBlock = new Float32Array(ITEM_SIZE).fill(0);
|
|
341
|
-
for (let key of keys) {
|
|
342
|
-
const offset = this.getOffset(key);
|
|
343
|
-
if (offset !== undefined) {
|
|
344
|
-
this.deleteFromAccount(key);
|
|
345
|
-
gl.bufferSubData(gl.ARRAY_BUFFER, offset, emptyBlock);
|
|
346
|
-
} else {
|
|
347
|
-
console.warn("key not found", key);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
351
|
-
globe.DrawRender();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
export const LineOnGlobeCache = Object.freeze({
|
|
357
|
-
get: (globe) => { return noRegisterGlobeProgramCache.getProgram(globe, Logic) },
|
|
358
|
-
release: (globe) => { return noRegisterGlobeProgramCache.releaseProgram(globe, Logic) }
|
|
359
|
-
});
|
|
360
|
-
|