@pirireis/webglobeplugins 1.1.19 → 1.1.20
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
|
@@ -18,13 +18,13 @@ const uniformBindingPoints = {
|
|
|
18
18
|
export const IndexAttributeEscapeValue = -1;
|
|
19
19
|
const styleBlockManager = new UniformBlockManager('Style', [
|
|
20
20
|
{ name: "defaultColor", type: "vec4", value: new Float32Array([0.0, 0.0, 0.0, 0.0]) },
|
|
21
|
-
{ name: "
|
|
21
|
+
{ name: "hoverColor", type: "vec4", value: new Float32Array([0, 0, 0, 0]) },
|
|
22
22
|
{ name: "u_pointSize", type: "float", value: new Float32Array([6.0]) },
|
|
23
23
|
{ name: "opacity", type: "float", value: new Float32Array([1.0]) },
|
|
24
24
|
{ name: "private_pickedIndex", type: "uint", value: new Uint32Array([0]) },
|
|
25
25
|
{ name: "private_isPickedOn", type: "bool", value: new Float32Array([0]) },
|
|
26
26
|
{ name: "useDefaultColor", type: "bool", value: new Float32Array([0]) },
|
|
27
|
-
{ name: "
|
|
27
|
+
{ name: "private_changeHoverColor", type: "bool", value: new Float32Array([1]) },
|
|
28
28
|
], uniformBindingPoints.style);
|
|
29
29
|
const vertexShaderSource = `#version 300 es
|
|
30
30
|
#pragma vscode_glsllint_stage : vert
|
|
@@ -92,8 +92,8 @@ void main() {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
if (private_isPickedOn == true){
|
|
95
|
-
if (a_index == private_pickedIndex &&
|
|
96
|
-
v_color =
|
|
95
|
+
if (a_index == private_pickedIndex && private_changeHoverColor == true ) {
|
|
96
|
+
v_color = hoverColor;
|
|
97
97
|
}
|
|
98
98
|
v_index = a_index;
|
|
99
99
|
}
|
|
@@ -15,15 +15,15 @@ export class TerrainPolygonSemiPlugin {
|
|
|
15
15
|
variativeColorsOn: false,
|
|
16
16
|
polygonStyle: {
|
|
17
17
|
defaultColor: [0.5, 0.5, 1, 1],
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
changeColorOnHover: true,
|
|
19
|
+
hoverColor: [1, 0, 0, 1],
|
|
20
20
|
opacity: 1.0,
|
|
21
21
|
useDefaultColor: false,
|
|
22
22
|
},
|
|
23
23
|
edgeStyle: {
|
|
24
24
|
defaultColor: [1, 1, 0, 1],
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
hoverColor: [1, 0, 0, 1],
|
|
26
|
+
changeColorOnHover: true,
|
|
27
27
|
opacity: 1.0,
|
|
28
28
|
useDefaultColor: true,
|
|
29
29
|
},
|
|
@@ -114,8 +114,8 @@ export class TerrainPolygonSemiPlugin {
|
|
|
114
114
|
this._pickIndexBuffer = gl.createBuffer();
|
|
115
115
|
this._pickerDisplayer = new PickerDisplayer(this.globe, "R16UI");
|
|
116
116
|
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
|
|
117
|
-
this._uboHandler.updateSingle("
|
|
118
|
-
this._uboHandler.updateSingle("
|
|
117
|
+
this._uboHandler.updateSingle("hoverColor", new Float32Array(this._options.polygonStyle.hoverColor));
|
|
118
|
+
this._uboHandler.updateSingle("private_changeHoverColor", new Float32Array([this._options.polygonStyle.changeColorOnHover ? 1 : 0]));
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([0.0]));
|
|
@@ -126,7 +126,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
126
126
|
this._uboForRealEdgeArcs.updateSingle("useDefaultColor", new Float32Array([1]));
|
|
127
127
|
this._uboForRealEdgeArcs.updateSingle("opacity", this._effectiveOpacity("edgeArc"));
|
|
128
128
|
this._uboForRealEdgeArcs.updateSingle("private_isPickedOn", new Float32Array([0.0]));
|
|
129
|
-
this._uboForRealEdgeArcs.updateSingle("
|
|
129
|
+
this._uboForRealEdgeArcs.updateSingle("private_changeHoverColor", new Float32Array([this._options.edgeStyle.changeColorOnHover ? 1 : 0]));
|
|
130
130
|
this._drawRealEdgeArcs.elementBuffer = gl.createBuffer();
|
|
131
131
|
}
|
|
132
132
|
if (this._options.variativeColorsOn) {
|
|
@@ -179,32 +179,22 @@ export class TerrainPolygonSemiPlugin {
|
|
|
179
179
|
if (name.startsWith("private_")) {
|
|
180
180
|
throw new Error(`Cannot set private uniform ${name}`);
|
|
181
181
|
}
|
|
182
|
-
const isStyleKey = name === "defaultColor" || name === "
|
|
183
|
-
|
|
184
|
-
if (target === "polygon") {
|
|
185
|
-
targetUBO = this._uboHandler;
|
|
186
|
-
}
|
|
187
|
-
else if (target === "edgeArc") {
|
|
188
|
-
targetUBO = this._uboForRealEdgeArcs;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
console.warn(`Unknown target ${target} for setUniform, must be "polygon" or "edgeArc"`);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
182
|
+
const isStyleKey = name === "defaultColor" || name === "hoverColor" || name === "opacity" || name === "useDefaultColor";
|
|
183
|
+
const ubo = this.__getUBO(target);
|
|
194
184
|
if (isStyleKey) {
|
|
195
185
|
const prev = this._options.polygonStyle[name];
|
|
196
186
|
if (prev === value)
|
|
197
187
|
return;
|
|
198
188
|
this._options.polygonStyle[name] = value;
|
|
199
189
|
if (name === "opacity") {
|
|
200
|
-
|
|
190
|
+
ubo.updateSingle("opacity", this._effectiveOpacity(target));
|
|
201
191
|
}
|
|
202
192
|
else {
|
|
203
|
-
|
|
193
|
+
ubo.updateSingle(name, value);
|
|
204
194
|
}
|
|
205
195
|
}
|
|
206
196
|
else {
|
|
207
|
-
|
|
197
|
+
ubo.updateSingle(name, value);
|
|
208
198
|
}
|
|
209
199
|
this.globe.DrawRender();
|
|
210
200
|
}
|
|
@@ -216,7 +206,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
216
206
|
this._uboForRealEdgeArcs = this._program.createUBO();
|
|
217
207
|
this._uboForRealEdgeArcs.updateSingle("defaultColor", new Float32Array(this._options.edgeStyle.defaultColor));
|
|
218
208
|
this._uboForRealEdgeArcs.updateSingle("useDefaultColor", new Float32Array([this._options.edgeStyle.useDefaultColor ? 1 : 0]));
|
|
219
|
-
this._uboForRealEdgeArcs.updateSingle("
|
|
209
|
+
this._uboForRealEdgeArcs.updateSingle("hoverColor", new Float32Array(this._options.edgeStyle.hoverColor));
|
|
220
210
|
this._uboForRealEdgeArcs.updateSingle("opacity", this._effectiveOpacity("edgeArc"));
|
|
221
211
|
this._drawRealEdgeArcs.elementBuffer = this.globe.gl.createBuffer();
|
|
222
212
|
}
|
|
@@ -231,21 +221,12 @@ export class TerrainPolygonSemiPlugin {
|
|
|
231
221
|
this.globe.DrawRender();
|
|
232
222
|
}
|
|
233
223
|
setUsePickedColorState(state, target = "polygon") {
|
|
234
|
-
let targetUBO;
|
|
235
|
-
if (target === "polygon") {
|
|
236
|
-
targetUBO = this._uboHandler;
|
|
237
|
-
}
|
|
238
|
-
else if (target === "edgeArc") {
|
|
239
|
-
targetUBO = this._uboForRealEdgeArcs;
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
throw new Error(`Unknown target ${target} for setUsePickedColorState, must be "polygon" or "edgeArc"`);
|
|
243
|
-
}
|
|
244
224
|
const oldState = this._options[`${target}Style`].changePickedColor;
|
|
245
225
|
if (oldState === state)
|
|
246
226
|
return;
|
|
247
227
|
this._options[`${target}Style`].changePickedColor = state;
|
|
248
|
-
|
|
228
|
+
const ubo = this.__getUBO(target);
|
|
229
|
+
ubo.updateSingle("private_changeHoverColor", new Float32Array([state ? 1 : 0]));
|
|
249
230
|
this.globe.DrawRender();
|
|
250
231
|
}
|
|
251
232
|
setOpacity(opacity) {
|
|
@@ -256,6 +237,15 @@ export class TerrainPolygonSemiPlugin {
|
|
|
256
237
|
this.globe.DrawRender();
|
|
257
238
|
}
|
|
258
239
|
}
|
|
240
|
+
setChangeColorOnHoverState(state, target = "polygon") {
|
|
241
|
+
const oldState = this._options[`${target}Style`].changeHoverColor;
|
|
242
|
+
if (oldState === state)
|
|
243
|
+
return;
|
|
244
|
+
this._options[`${target}Style`].changeHoverColor = state;
|
|
245
|
+
const ubo = this.__getUBO(target);
|
|
246
|
+
ubo.updateSingle("private_changeHoverColor", new Float32Array([state ? 1 : 0]));
|
|
247
|
+
this.globe.DrawRender();
|
|
248
|
+
}
|
|
259
249
|
setPausePickableState(state) {
|
|
260
250
|
if (this._options.pickable === false) {
|
|
261
251
|
throw new Error("TerrainPolygonSemiPlugin is not pickable. Set pickable option to true on construction to enable picking.");
|
|
@@ -276,7 +266,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
276
266
|
if (oldState === false && state === true) {
|
|
277
267
|
this._pickIndexBuffer = this.globe.gl.createBuffer();
|
|
278
268
|
this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
|
|
279
|
-
this._uboHandler.updateSingle("
|
|
269
|
+
this._uboHandler.updateSingle("hoverColor", new Float32Array(this._options.polygonStyle.hoverColor));
|
|
280
270
|
this._pickerDisplayer = new PickerDisplayer(this.globe, "R32I");
|
|
281
271
|
}
|
|
282
272
|
else if (oldState === true && state === false) {
|
|
@@ -440,6 +430,19 @@ export class TerrainPolygonSemiPlugin {
|
|
|
440
430
|
this.insertBulk(TestRecords.get(recordName));
|
|
441
431
|
}
|
|
442
432
|
}
|
|
433
|
+
__getUBO(target = "polygon") {
|
|
434
|
+
let targetUBO;
|
|
435
|
+
if (target === "polygon") {
|
|
436
|
+
targetUBO = this._uboHandler;
|
|
437
|
+
}
|
|
438
|
+
else if (target === "edgeArc") {
|
|
439
|
+
targetUBO = this._uboForRealEdgeArcs;
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
throw new Error(`unknown target ${target} for __getUBO, must be "polygon" or "edgeArc"`);
|
|
443
|
+
}
|
|
444
|
+
return targetUBO;
|
|
445
|
+
}
|
|
443
446
|
}
|
|
444
447
|
function inputCheck(input) {
|
|
445
448
|
if (!input.geometry || !Array.isArray(input.geometry) || input.geometry.length === 0) {
|