@pirireis/webglobeplugins 0.14.0-alpha → 0.15.1-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/package.json +1 -1
- package/programs/line-on-globe/linestrip/linestrip.js +1 -1
- package/programs/line-on-globe/paddings/paddings.js +1 -0
- package/range-tools-on-terrain/circle-line-chain/plugin.js +23 -6
- package/range-tools-on-terrain/range-ring/adapters.js +1 -1
- package/semiplugins/lightweight/line-plugin.js +9 -0
- package/semiplugins/shape-on-terrain/arc-plugin.js +10 -1
- package/semiplugins/shape-on-terrain/circle-plugin.js +8 -0
- package/semiplugins/shape-on-terrain/derived/padding-plugin.js +9 -4
- package/semiplugins/shape-on-terrain/one-degree-padding.js +85 -0
- package/util/webglobjectbuilders.js +2 -2
package/package.json
CHANGED
|
@@ -149,7 +149,7 @@ export class LineProgram {
|
|
|
149
149
|
cameraBlockTotem.bind(uniformBindingPoints.camera);
|
|
150
150
|
ubo.bind();
|
|
151
151
|
gl.bindVertexArray(vao);
|
|
152
|
-
drawArrays(gl, gl.POINTS, drawOptions);
|
|
152
|
+
// drawArrays(gl, gl.POINTS, drawOptions);
|
|
153
153
|
drawArrays(gl, gl.LINE_STRIP, drawOptions);
|
|
154
154
|
gl.bindVertexArray(null);
|
|
155
155
|
ubo.unbind();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -124,7 +124,6 @@ export class CircleLineChainPlugin {
|
|
|
124
124
|
// Reconstruct chains
|
|
125
125
|
this._reconstructChains(chainKeys);
|
|
126
126
|
// Update texts
|
|
127
|
-
console.log("insertBulk", chainKeys, textWriterIDs);
|
|
128
127
|
this._updateTexts(chainKeys, textWriterIDs);
|
|
129
128
|
this.globe?.DrawRender();
|
|
130
129
|
}
|
|
@@ -253,6 +252,24 @@ export class CircleLineChainPlugin {
|
|
|
253
252
|
this._updateTexts(chainKeys, textWriterIDs);
|
|
254
253
|
this.globe?.DrawRender();
|
|
255
254
|
}
|
|
255
|
+
setDefaultSemiPluginColor(semiPluginName, color) {
|
|
256
|
+
switch (semiPluginName) {
|
|
257
|
+
case "circleOnTerrain":
|
|
258
|
+
this._semiPluginOptions.circleOnTerrainOptions.defaultColor = color;
|
|
259
|
+
this.circlePlugin?.setDefaultColor(color);
|
|
260
|
+
break;
|
|
261
|
+
case "arcOnTerrain":
|
|
262
|
+
this._semiPluginOptions.arcOnTerrainOptions.defaultColor = color;
|
|
263
|
+
this.arcPlugin?.setDefaultColor(color);
|
|
264
|
+
break;
|
|
265
|
+
case "line":
|
|
266
|
+
this._semiPluginOptions.lineOptions.defaultColor = color;
|
|
267
|
+
this.linePlugin?.setDefaultColor(color);
|
|
268
|
+
break;
|
|
269
|
+
default:
|
|
270
|
+
throw new Error(`Unknown semi-plugin name: ${semiPluginName}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
256
273
|
// IMPLICIT METHODS
|
|
257
274
|
_checktextWritersMap(textWritersMap) {
|
|
258
275
|
if (!(textWritersMap instanceof Map))
|
|
@@ -335,16 +352,16 @@ export class CircleLineChainPlugin {
|
|
|
335
352
|
switch (currentGeometry) {
|
|
336
353
|
case 0: {
|
|
337
354
|
// globe view
|
|
338
|
-
const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
|
|
339
|
-
if (arcOpacity !== 0) {
|
|
340
|
-
this.arcPlugin?.setPluginOpacity(arcOpacity);
|
|
341
|
-
this.arcPlugin?.draw3D();
|
|
342
|
-
}
|
|
343
355
|
const lineOpacity = getOpacity(this._opacities, "globeArc");
|
|
344
356
|
if (lineOpacity !== 0) {
|
|
345
357
|
this.linePlugin?.setPluginOpacity(lineOpacity);
|
|
346
358
|
this.linePlugin?.draw3D();
|
|
347
359
|
}
|
|
360
|
+
const arcOpacity = getOpacity(this._opacities, "globeArcFitsTerrain");
|
|
361
|
+
if (arcOpacity !== 0) {
|
|
362
|
+
this.arcPlugin?.setPluginOpacity(arcOpacity);
|
|
363
|
+
this.arcPlugin?.draw3D();
|
|
364
|
+
}
|
|
348
365
|
break;
|
|
349
366
|
}
|
|
350
367
|
case 1: {
|
|
@@ -81,6 +81,15 @@ export class LinePlugin {
|
|
|
81
81
|
this._options.defaultColor[3] = opacity; // Update the default color's alpha channel
|
|
82
82
|
this.globe?.DrawRender();
|
|
83
83
|
}
|
|
84
|
+
setDefaultColor(color) {
|
|
85
|
+
if (!this.globe || !this.gl) {
|
|
86
|
+
console.warn("Globe or WebGL context is not initialized.");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this._options.defaultColor = color;
|
|
90
|
+
this._uboHandler?.updateSingle("u_color", new Float32Array(color));
|
|
91
|
+
this.globe?.DrawRender();
|
|
92
|
+
}
|
|
84
93
|
// GLOBE INTERACTION METHODS
|
|
85
94
|
draw3D() {
|
|
86
95
|
if (this._freed) {
|
|
@@ -49,7 +49,7 @@ export class ArcOnTerrainPlugin {
|
|
|
49
49
|
defaultColor: defaultColor ? defaultColor : [0.1, 0.1, 1, 1],
|
|
50
50
|
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D ? defaultHeightFromGroundIn3D : 30.0,
|
|
51
51
|
vertexCount: vertexCount ? vertexCount : 70,
|
|
52
|
-
cameraAttractionIsOn: cameraAttractionIsOn ?
|
|
52
|
+
cameraAttractionIsOn: cameraAttractionIsOn ? true : false
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
insertBulk(arcs) {
|
|
@@ -112,6 +112,15 @@ export class ArcOnTerrainPlugin {
|
|
|
112
112
|
this._opacity = opacity;
|
|
113
113
|
this.globe.DrawRender();
|
|
114
114
|
}
|
|
115
|
+
setDefaultColor(color) {
|
|
116
|
+
if (!this.globe || !this.gl) {
|
|
117
|
+
console.warn("Globe or WebGL context is not initialized.");
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this._options.defaultColor = color;
|
|
121
|
+
this._arcUBOHandler?.updateSingle("u_color", new Float32Array(color));
|
|
122
|
+
this.globe.DrawRender();
|
|
123
|
+
}
|
|
115
124
|
setCameraAttraction(isOn) {
|
|
116
125
|
if (!this.globe || !this.gl) {
|
|
117
126
|
console.warn("Globe or WebGL context is not initialized.");
|
|
@@ -177,6 +177,14 @@ export class CircleOnTerrainPlugin {
|
|
|
177
177
|
this._opacity = opacity;
|
|
178
178
|
this.globe.DrawRender();
|
|
179
179
|
}
|
|
180
|
+
setDefaultColor(color) {
|
|
181
|
+
if (!this.globe || !this.gl) {
|
|
182
|
+
console.warn("Globe or WebGL context is not initialized.");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
this._circleUBOHandler?.updateSingle("u_color", new Float32Array(color));
|
|
186
|
+
this.globe.DrawRender();
|
|
187
|
+
}
|
|
180
188
|
// IMPLICIT METHODS
|
|
181
189
|
_buildCircles() {
|
|
182
190
|
// @ts-ignore
|
|
@@ -41,21 +41,25 @@ export const chargerAdaptor = (chargerInput, plugin, padding) => {
|
|
|
41
41
|
export class PaddingPlugin {
|
|
42
42
|
id;
|
|
43
43
|
arcPlugin;
|
|
44
|
+
globe = null;
|
|
44
45
|
_memory = new Map();
|
|
45
46
|
isFreed = false;
|
|
46
|
-
constructor(id) {
|
|
47
|
+
constructor(id, { variativeColorsOn = true, defaultColor = [1, 1, 1, 1], defaultHeightFromGroundIn3D = 30.0, vertexCount = EDGE_COUNT } = {}) {
|
|
47
48
|
this.id = id;
|
|
48
49
|
this.arcPlugin = new ArcOnTerrainPlugin(id, {
|
|
49
50
|
cameraAttractionIsOn: false,
|
|
50
|
-
vertexCount:
|
|
51
|
+
vertexCount: vertexCount,
|
|
52
|
+
variativeColorsOn: variativeColorsOn,
|
|
53
|
+
defaultColor: defaultColor,
|
|
54
|
+
defaultHeightFromGroundIn3D: defaultHeightFromGroundIn3D,
|
|
51
55
|
});
|
|
52
56
|
}
|
|
53
|
-
insertBulk(items
|
|
57
|
+
insertBulk(items) {
|
|
54
58
|
for (const padding of items) {
|
|
55
59
|
this.__delete(padding.key);
|
|
56
60
|
this._memory.set(padding.key, padding);
|
|
57
61
|
}
|
|
58
|
-
const arcInputs = items.flatMap(padding => adapterPadding2Arc(globe, padding));
|
|
62
|
+
const arcInputs = items.flatMap(padding => adapterPadding2Arc(this.globe, padding));
|
|
59
63
|
this.arcPlugin.insertBulk(arcInputs);
|
|
60
64
|
}
|
|
61
65
|
deleteBulk(keys) {
|
|
@@ -82,6 +86,7 @@ export class PaddingPlugin {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
init(globe, gl) {
|
|
89
|
+
this.globe = globe;
|
|
85
90
|
this.arcPlugin.init(globe, gl);
|
|
86
91
|
}
|
|
87
92
|
draw3D() {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// // One Degree Padding
|
|
3
|
+
// /**
|
|
4
|
+
// * 2d coordinates are loaded ones
|
|
5
|
+
// * 3d coordinates are calculated on the fly.
|
|
6
|
+
// *
|
|
7
|
+
// * 2d paddings are fixed size
|
|
8
|
+
// * 3d paddings gets shortened as lod increases
|
|
9
|
+
// *
|
|
10
|
+
// * color buffer is shared and does not change on unless insert or delete
|
|
11
|
+
// * changing color can be done by re inserting
|
|
12
|
+
// *
|
|
13
|
+
// *
|
|
14
|
+
// *
|
|
15
|
+
// */
|
|
16
|
+
// import { Globe, LongLat, Meter, Color } from '../../types';
|
|
17
|
+
// import { BufferManagersMap } from '../../util/account/single-attribute-buffer-management/types';
|
|
18
|
+
// import { BufferManager } from '../../util/account/single-attribute-buffer-management/buffer-manager';
|
|
19
|
+
// import { BufferOrchestrator } from '../../util/acconut/single-attribute-buffer-management/buffer-orchestrator';
|
|
20
|
+
// import { LineStripProgramCache, LineProgram } from '../../programs/line-on-globe/linestrip/linestrip';
|
|
21
|
+
// import { ProgramInterface } from '../../types';
|
|
22
|
+
// export type OneDegreePaddingInput = {
|
|
23
|
+
// key: string;
|
|
24
|
+
// center: LongLat;
|
|
25
|
+
// outerRadius: Meter;
|
|
26
|
+
// color: Color;
|
|
27
|
+
// };
|
|
28
|
+
// const _float32Array = new Float32Array(360 * 3 * 2).fill(NaN);
|
|
29
|
+
// export class Paddings1Degree implements ProgramInterface {
|
|
30
|
+
// id: string;
|
|
31
|
+
// private globe: Globe | null = null;
|
|
32
|
+
// private bufferOrchestrator: BufferOrchestrator;
|
|
33
|
+
// private bufferManagersMap: BufferManagersMap;
|
|
34
|
+
// private lineProgram: LineProgram | null = null;
|
|
35
|
+
// private _LODCoeffecientForPaddingScale: number = 1;
|
|
36
|
+
// private _PaddingSizeRatio = 0.1; // 0.1 means 10% of the padding size is used for 3d padding
|
|
37
|
+
// private _finalPaddingSizeRatio = 0.1; // this._LODCoefficientForPaddingScale * this._PaddingSizeRatio; // final padding size ratio is the product of LOD coefficient and padding size ratio
|
|
38
|
+
// constructor(id: string, { capacity = 1000 } = {}) {
|
|
39
|
+
// this.id = id;
|
|
40
|
+
// this.bufferOrchestrator = new BufferOrchestrator({ capacity });
|
|
41
|
+
// this.bufferManagersMap = new Map();
|
|
42
|
+
// this.lineProgram = null;
|
|
43
|
+
// }
|
|
44
|
+
// init(globe: Globe): void {
|
|
45
|
+
// this.globe = globe;
|
|
46
|
+
// this.lineProgram = LineStripProgramCache.get(globe);
|
|
47
|
+
// }
|
|
48
|
+
// __updateLODCoefficientForPaddingScale(): void {
|
|
49
|
+
// // TODO: call this ones when lod changes or each frame // maybe only on 3d geometry
|
|
50
|
+
// }
|
|
51
|
+
// __fillBufferManagersMap() {
|
|
52
|
+
// const globe = this.globe as Globe;
|
|
53
|
+
// const gl = globe.gl as WebGL2RenderingContext;
|
|
54
|
+
// this.bufferManagersMap.set("position2d", {
|
|
55
|
+
// bufferManager: new BufferManager(gl,
|
|
56
|
+
// 360 * (2 + 1), // plus 1 to cut
|
|
57
|
+
// { bufferType: "STATIC_DRAW", initialCapacity: 10 }),
|
|
58
|
+
// adaptor: (PaddingInput: OneDegreePaddingInput) => {
|
|
59
|
+
// for (let i = 0; i < 360; i++) {
|
|
60
|
+
// let { long, lat } = globe.Math.FindPointByPolar(
|
|
61
|
+
// PaddingInput.center[0], // center long
|
|
62
|
+
// PaddingInput.center[1], // center lat
|
|
63
|
+
// PaddingInput.outerRadius, // outer radius
|
|
64
|
+
// i, // angle
|
|
65
|
+
// )
|
|
66
|
+
// let corrds = globe.api_GetMercator2DPoint(long, lat);
|
|
67
|
+
// // fill the second coordinate with 0
|
|
68
|
+
// _float32Array[i * 3] = corrds[0];
|
|
69
|
+
// _float32Array[i * 3 + 1] = corrds[1];
|
|
70
|
+
// ({ long, lat } = globe.Math.FindPointByPolar(
|
|
71
|
+
// PaddingInput.center[0], // center long
|
|
72
|
+
// PaddingInput.center[1], // center lat
|
|
73
|
+
// PaddingInput.outerRadius * this._finalPaddingSizeRatio, // inner radius
|
|
74
|
+
// i, // angle
|
|
75
|
+
// ));
|
|
76
|
+
// let innerCorrds = globe.api_GetMercator2DPoint(long, lat);
|
|
77
|
+
// // fill the second coordinate with 0
|
|
78
|
+
// _float32Array[i * 3 + 2] = innerCorrds[0];
|
|
79
|
+
// _float32Array[i * 3 + 3] = innerCorrds[1];
|
|
80
|
+
// }
|
|
81
|
+
// return _float32Array;
|
|
82
|
+
// }
|
|
83
|
+
// });
|
|
84
|
+
// // Other methods like draw, insertBulk, deleteBulk, etc. would go here
|
|
85
|
+
// }
|
|
@@ -211,8 +211,8 @@ export function decodeBase64(data) {
|
|
|
211
211
|
* @returns An HTMLImageElement with the image data loaded.
|
|
212
212
|
*/
|
|
213
213
|
export function createImageFromBase64(encodedData) {
|
|
214
|
-
const
|
|
215
|
-
const blob = new Blob([
|
|
214
|
+
const source = decodeBase64(encodedData).buffer;
|
|
215
|
+
const blob = new Blob([source], { type: "image/png" });
|
|
216
216
|
const urlCreator = window.URL || window.webkitURL;
|
|
217
217
|
const imageUrl = urlCreator.createObjectURL(blob);
|
|
218
218
|
const image = new Image();
|