@pirireis/webglobeplugins 0.15.12-alpha → 0.15.14-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
CHANGED
|
@@ -34,13 +34,16 @@ export class BearingLinePlugin {
|
|
|
34
34
|
_memory = new Map();
|
|
35
35
|
_semiPluginsOptions = {
|
|
36
36
|
circleOnTerrainOptions: {
|
|
37
|
-
defaultColor: [
|
|
37
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
38
38
|
defaultHeightFromGroundIn3D: 30.0,
|
|
39
39
|
variativeColorsOn: false,
|
|
40
40
|
},
|
|
41
41
|
arcOnTerrainOptions: {
|
|
42
42
|
defaultHeightFromGroundIn3D: 30.0,
|
|
43
43
|
variativeColorsOn: false,
|
|
44
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
45
|
+
globeViewOn: true,
|
|
46
|
+
flatViewOn: false,
|
|
44
47
|
},
|
|
45
48
|
lineOptions: {
|
|
46
49
|
flatViewOn: true,
|
|
@@ -50,11 +53,30 @@ export class BearingLinePlugin {
|
|
|
50
53
|
},
|
|
51
54
|
pieceOfPieOptions: {
|
|
52
55
|
defaultColor: [1, 1, 1, 0.5],
|
|
53
|
-
defaultHeightFromGroundIn3D: 30.0,
|
|
54
56
|
variativeColorsOn: false,
|
|
57
|
+
defaultHeightFromGroundIn3D: 1000.0,
|
|
55
58
|
}
|
|
56
59
|
};
|
|
57
|
-
constructor(id, { textWritersMap, textDataPreAdaptor, opacities, drawOptions,
|
|
60
|
+
constructor(id, { textWritersMap, textDataPreAdaptor, opacities, drawOptions, circleOnTerrainOptions = {
|
|
61
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
62
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
63
|
+
variativeColorsOn: false,
|
|
64
|
+
}, arcOnTerrainOptions = {
|
|
65
|
+
globeViewOn: true,
|
|
66
|
+
flatViewOn: false,
|
|
67
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
68
|
+
defaultHeightFromGroundIn3D: 30.0,
|
|
69
|
+
variativeColorsOn: false,
|
|
70
|
+
}, lineOptions = {
|
|
71
|
+
flatViewOn: true,
|
|
72
|
+
globeViewOn: false,
|
|
73
|
+
variativeColorsOn: false,
|
|
74
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
75
|
+
}, pieceOfPieOptions = {
|
|
76
|
+
defaultColor: [1, 1, 1, 0.5],
|
|
77
|
+
variativeColorsOn: false,
|
|
78
|
+
defaultHeightFromGroundIn3D: 1000.0,
|
|
79
|
+
} } = {}) {
|
|
58
80
|
this.id = id;
|
|
59
81
|
if (!(textWritersMap instanceof Map))
|
|
60
82
|
throw new Error("textWritersMap is not an instance of Map");
|
|
@@ -62,28 +84,49 @@ export class BearingLinePlugin {
|
|
|
62
84
|
if (!(v instanceof ContextTextWriter3))
|
|
63
85
|
throw new Error("textWritersMap element is not an instance of ContextTextWriter3");
|
|
64
86
|
});
|
|
87
|
+
if (circleOnTerrainOptions) {
|
|
88
|
+
this._semiPluginsOptions.circleOnTerrainOptions = {
|
|
89
|
+
...this._semiPluginsOptions.circleOnTerrainOptions,
|
|
90
|
+
...circleOnTerrainOptions
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (arcOnTerrainOptions) {
|
|
94
|
+
this._semiPluginsOptions.arcOnTerrainOptions = {
|
|
95
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
96
|
+
...arcOnTerrainOptions
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (lineOptions) {
|
|
100
|
+
this._semiPluginsOptions.lineOptions = {
|
|
101
|
+
...this._semiPluginsOptions.lineOptions,
|
|
102
|
+
...lineOptions
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (pieceOfPieOptions)
|
|
106
|
+
this._semiPluginsOptions.pieceOfPieOptions = {
|
|
107
|
+
...this._semiPluginsOptions.pieceOfPieOptions,
|
|
108
|
+
...pieceOfPieOptions
|
|
109
|
+
};
|
|
65
110
|
this._textWritersMap = textWritersMap || new Map();
|
|
66
111
|
this._textWritersMap.forEach((writer) => writer.setKeyAdaptor((item) => item.key));
|
|
67
112
|
this._textDataPreAdaptor = textDataPreAdaptor || ((item) => item);
|
|
68
|
-
this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle"
|
|
69
|
-
variativeColorsOn: true,
|
|
70
|
-
});
|
|
113
|
+
this.circlePlugin = new CircleOnTerrainPlugin(id + "_circle");
|
|
71
114
|
this.arcPlugin = new ArcOnTerrainPlugin(id + "_arc", {
|
|
72
|
-
|
|
115
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
73
116
|
});
|
|
74
117
|
this.arcPluginBL = new ArcOnTerrainPlugin(id + "_arcBL", {
|
|
75
|
-
|
|
118
|
+
...this._semiPluginsOptions.arcOnTerrainOptions,
|
|
76
119
|
});
|
|
77
120
|
this.pieceOfPiePlugin = new PieceOfPiePlugin(id + "_pieceOfPie", {
|
|
78
121
|
bufferType: "DYNAMIC_DRAW",
|
|
122
|
+
...this._semiPluginsOptions.pieceOfPieOptions
|
|
79
123
|
});
|
|
80
124
|
this.linePlugin = new LinePlugin(id + "_line", {
|
|
81
|
-
variativeColorsOn: true,
|
|
82
125
|
bufferType: "DYNAMIC_DRAW",
|
|
126
|
+
...this._semiPluginsOptions.lineOptions
|
|
83
127
|
});
|
|
84
128
|
this.linePluginBL = new LinePlugin(id + "_lineBL", {
|
|
85
|
-
|
|
86
|
-
bufferType: "DYNAMIC_DRAW",
|
|
129
|
+
...this._semiPluginsOptions.lineOptions // flatViewOn: true,
|
|
87
130
|
});
|
|
88
131
|
if (opacities) {
|
|
89
132
|
this._opacities = {
|
|
@@ -105,6 +148,15 @@ export class BearingLinePlugin {
|
|
|
105
148
|
if (!this.globe) {
|
|
106
149
|
throw new Error("Globe is not set, cannot set default semi plugin color.");
|
|
107
150
|
}
|
|
151
|
+
if (semiPluginName === "ALL") {
|
|
152
|
+
this.circlePlugin.setDefaultColor(color);
|
|
153
|
+
this.arcPlugin.setDefaultColor(color);
|
|
154
|
+
this.arcPluginBL.setDefaultColor(color);
|
|
155
|
+
this.linePlugin.setDefaultColor(color);
|
|
156
|
+
this.linePluginBL.setDefaultColor(color);
|
|
157
|
+
this.pieceOfPiePlugin.setDefaultColor(color);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
108
160
|
switch (semiPluginName) {
|
|
109
161
|
case "circleOnTerrain":
|
|
110
162
|
this.circlePlugin.setDefaultColor(color);
|
|
@@ -19,13 +19,19 @@ export class PieceOfPiePlugin {
|
|
|
19
19
|
_pluginOptions = {
|
|
20
20
|
bufferType: "STATIC_DRAW",
|
|
21
21
|
initialCapacity: INITIAL_CAPACITY,
|
|
22
|
-
|
|
22
|
+
opacity: 1.0, // Default opacity is 1.0
|
|
23
|
+
defaultHeightFromGroundIn3D: 0, // Default altitude is ground level
|
|
24
|
+
defaultColor: [1, 1, 1, 1], // Default color is white with full opacity
|
|
25
|
+
variativeColorsOn: false, // Default is to not use variative colors
|
|
23
26
|
};
|
|
24
|
-
constructor(id, options =
|
|
27
|
+
constructor(id, options = null) {
|
|
25
28
|
this.id = id;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
if (options) {
|
|
30
|
+
this._pluginOptions = {
|
|
31
|
+
...this._pluginOptions,
|
|
32
|
+
...options
|
|
33
|
+
};
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
insertBulk(items) {
|
|
31
37
|
this.bufferOrchestrator.insertBulk(items, this.bufferManagersMap);
|
|
@@ -71,7 +77,7 @@ export class PieceOfPiePlugin {
|
|
|
71
77
|
}],
|
|
72
78
|
["centerCoords3d", {
|
|
73
79
|
bufferManager: new BufferManager(gl, 3, { bufferType, initialCapacity }),
|
|
74
|
-
adaptor: (item) => sphereCoord(item.center[0], item.center[1], globe, (item.altitude ?? this._pluginOptions.
|
|
80
|
+
adaptor: (item) => sphereCoord(item.center[0], item.center[1], globe, (item.altitude ?? this._pluginOptions.defaultHeightFromGroundIn3D) / 1000)
|
|
75
81
|
}],
|
|
76
82
|
["startAngle2d", {
|
|
77
83
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
@@ -113,21 +119,22 @@ export class PieceOfPiePlugin {
|
|
|
113
119
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
114
120
|
adaptor: (item) => new Float32Array([item.fillingMode ?? 0])
|
|
115
121
|
}],
|
|
116
|
-
["rgba", {
|
|
117
|
-
bufferManager: new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
118
|
-
adaptor: (item) => {
|
|
119
|
-
if (!item.color || item.color.length === 0) {
|
|
120
|
-
return new Float32Array([1, 1, 1, 1]); // Default color if none provided
|
|
121
|
-
}
|
|
122
|
-
return new Float32Array(item.color);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
122
|
["radius", {
|
|
127
123
|
bufferManager: new BufferManager(gl, 1, { bufferType, initialCapacity }),
|
|
128
124
|
adaptor: (item) => new Float32Array([item.radius])
|
|
129
125
|
}],
|
|
130
126
|
]);
|
|
127
|
+
if (this._pluginOptions.variativeColorsOn) {
|
|
128
|
+
bufferManagersMap.set("rgba", {
|
|
129
|
+
bufferManager: new BufferManager(gl, 4, { bufferType, initialCapacity }),
|
|
130
|
+
adaptor: (item) => {
|
|
131
|
+
if (!item.color || item.color.length === 0) {
|
|
132
|
+
return new Float32Array([1, 1, 1, 1]); // Default color if none provided
|
|
133
|
+
}
|
|
134
|
+
return new Float32Array(item.color);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
131
138
|
this.bufferManagersMap = bufferManagersMap;
|
|
132
139
|
}
|
|
133
140
|
init(globe, gl) {
|
|
@@ -146,6 +153,9 @@ export class PieceOfPiePlugin {
|
|
|
146
153
|
'rgba',
|
|
147
154
|
'radius',
|
|
148
155
|
'fillingMode'].map((name) => {
|
|
156
|
+
if (!this.bufferManagersMap?.has(name)) {
|
|
157
|
+
return null; // this make vao with default attribute value with no buffer bound to it
|
|
158
|
+
}
|
|
149
159
|
const buffer = this.bufferManagersMap?.get(name)?.bufferManager.buffer;
|
|
150
160
|
return {
|
|
151
161
|
buffer: buffer,
|
|
@@ -153,6 +163,9 @@ export class PieceOfPiePlugin {
|
|
|
153
163
|
offset: 0,
|
|
154
164
|
};
|
|
155
165
|
}));
|
|
166
|
+
this._uboHandler = this.program.createUBO();
|
|
167
|
+
this._uboHandler.updateSingle("u_color", new Float32Array(this._pluginOptions.defaultColor));
|
|
168
|
+
this._uboHandler.updateSingle("u_opacity", new Float32Array([this._pluginOptions.opacity ?? 1.0])); // Default opacity is 1.0
|
|
156
169
|
}
|
|
157
170
|
draw3D() {
|
|
158
171
|
if (!this.gl || !this.program || !this.vao || !this.globe) {
|
|
@@ -38,8 +38,8 @@ export class ArcOnTerrainPlugin {
|
|
|
38
38
|
variativeColorsOn = false, defaultColor = [0.1, 0.1, 1, 1], // Default color in RGBA format
|
|
39
39
|
defaultHeightFromGroundIn3D = 30.0, // Default height from ground in
|
|
40
40
|
vertexCount = 70, // Number of vertices per arc
|
|
41
|
-
cameraAttractionIsOn = true // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
42
|
-
|
|
41
|
+
cameraAttractionIsOn = true, // If true, camera attraction is enabled else evenly distributed arc points are used
|
|
42
|
+
bufferType = "STREAM_DRAW" } = {}) {
|
|
43
43
|
this.id = id;
|
|
44
44
|
this._arcMap = new Map();
|
|
45
45
|
this._options = {
|
|
@@ -49,7 +49,8 @@ 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 ? true : false
|
|
52
|
+
cameraAttractionIsOn: cameraAttractionIsOn ? true : false,
|
|
53
|
+
bufferType: bufferType ? bufferType : "STREAM_DRAW"
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
insertBulk(arcs) {
|
|
@@ -148,6 +149,7 @@ export class ArcOnTerrainPlugin {
|
|
|
148
149
|
console.warn("Globe or WebGL context is not initialized.");
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
152
|
+
const globe = this.globe;
|
|
151
153
|
this._staticDynamicStrategy?.updateState();
|
|
152
154
|
this._buildArcs(); // can be async
|
|
153
155
|
const { gl, program, _bufferOrchestrator, _vao, _arcUBOHandler, } = this;
|
|
@@ -156,6 +158,9 @@ export class ArcOnTerrainPlugin {
|
|
|
156
158
|
return;
|
|
157
159
|
}
|
|
158
160
|
gl.disable(gl.DEPTH_TEST);
|
|
161
|
+
const currentGeometry = globe.api_GetCurrentGeometry();
|
|
162
|
+
if ((currentGeometry === 0 && !this._options.globeViewOn) || (currentGeometry === 1 && !this._options.flatViewOn))
|
|
163
|
+
return;
|
|
159
164
|
const drawOptions = {
|
|
160
165
|
drawRange: {
|
|
161
166
|
first: 0,
|