@pirireis/webglobeplugins 1.1.18 → 1.1.19

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.
@@ -288,17 +288,17 @@ export function partialTessellation(triangleMeta, limits, innerCuts, calculateRe
288
288
  */
289
289
  const _f32 = /*@__PURE__*/ new Float32Array(1);
290
290
  const _u32 = /*@__PURE__*/ new Uint32Array(_f32.buffer);
291
- const float32Bits = (n) => {
292
- _f32[0] = n;
293
- return _u32[0];
294
- };
291
+ // const float32Bits = (n: number): number => {
292
+ // _f32[0] = n;
293
+ // return _u32[0];
294
+ // };
295
295
  const addPoint = (longLat, vec3, edgeIndex) => {
296
296
  const xy = radianToMercatorXY(longLat);
297
297
  const x = Math.fround(xy[0]);
298
298
  const y = Math.fround(xy[1]);
299
299
  // Use float32 bit patterns for an exact, stable key.
300
- // const key = `${xy[0].toFixed(12)},${xy[1].toFixed(12)}`;
301
- const key = `${float32Bits(x)},${float32Bits(y)}`;
300
+ const key = `${xy[0].toFixed(8)},${xy[1].toFixed(8)}`;
301
+ // const key = `${float32Bits(x)},${float32Bits(y)}`;
302
302
  let index = pointMap.get(key);
303
303
  if (index !== undefined) {
304
304
  if (edgeIndex !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -21,9 +21,10 @@ const styleBlockManager = new UniformBlockManager('Style', [
21
21
  { name: "pickedColor", 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
- { name: "private_isPickedOn", type: "bool", value: new Float32Array([0]) },
25
24
  { name: "private_pickedIndex", type: "uint", value: new Uint32Array([0]) },
25
+ { name: "private_isPickedOn", type: "bool", value: new Float32Array([0]) },
26
26
  { name: "useDefaultColor", type: "bool", value: new Float32Array([0]) },
27
+ { name: "private_changePickedColor", type: "bool", value: new Float32Array([1]) },
27
28
  ], uniformBindingPoints.style);
28
29
  const vertexShaderSource = `#version 300 es
29
30
  #pragma vscode_glsllint_stage : vert
@@ -91,7 +92,7 @@ void main() {
91
92
  }
92
93
 
93
94
  if (private_isPickedOn == true){
94
- if (a_index == private_pickedIndex) {
95
+ if (a_index == private_pickedIndex && private_changePickedColor == true ) {
95
96
  v_color = pickedColor;
96
97
  }
97
98
  v_index = a_index;
@@ -15,6 +15,7 @@ export class TerrainPolygonSemiPlugin {
15
15
  variativeColorsOn: false,
16
16
  polygonStyle: {
17
17
  defaultColor: [0.5, 0.5, 1, 1],
18
+ changePickedColor: true,
18
19
  pickedColor: [1, 0, 0, 1],
19
20
  opacity: 1.0,
20
21
  useDefaultColor: false,
@@ -22,6 +23,7 @@ export class TerrainPolygonSemiPlugin {
22
23
  edgeStyle: {
23
24
  defaultColor: [1, 1, 0, 1],
24
25
  pickedColor: [1, 0, 0, 1],
26
+ changePickedColor: true,
25
27
  opacity: 1.0,
26
28
  useDefaultColor: true,
27
29
  },
@@ -113,6 +115,7 @@ export class TerrainPolygonSemiPlugin {
113
115
  this._pickerDisplayer = new PickerDisplayer(this.globe, "R16UI");
114
116
  this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
115
117
  this._uboHandler.updateSingle("pickedColor", new Float32Array(this._options.polygonStyle.pickedColor));
118
+ this._uboHandler.updateSingle("private_changePickedColor", new Float32Array([this._options.polygonStyle.changePickedColor ? 1 : 0]));
116
119
  }
117
120
  else {
118
121
  this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([0.0]));
@@ -123,6 +126,7 @@ export class TerrainPolygonSemiPlugin {
123
126
  this._uboForRealEdgeArcs.updateSingle("useDefaultColor", new Float32Array([1]));
124
127
  this._uboForRealEdgeArcs.updateSingle("opacity", this._effectiveOpacity("edgeArc"));
125
128
  this._uboForRealEdgeArcs.updateSingle("private_isPickedOn", new Float32Array([0.0]));
129
+ this._uboForRealEdgeArcs.updateSingle("private_changePickedColor", new Float32Array([this._options.edgeStyle.changePickedColor ? 1 : 0]));
126
130
  this._drawRealEdgeArcs.elementBuffer = gl.createBuffer();
127
131
  }
128
132
  if (this._options.variativeColorsOn) {
@@ -226,6 +230,24 @@ export class TerrainPolygonSemiPlugin {
226
230
  this._options.drawEdges = state;
227
231
  this.globe.DrawRender();
228
232
  }
233
+ 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
+ const oldState = this._options[`${target}Style`].changePickedColor;
245
+ if (oldState === state)
246
+ return;
247
+ this._options[`${target}Style`].changePickedColor = state;
248
+ targetUBO.updateSingle("private_changePickedColor", new Float32Array([state ? 1 : 0]));
249
+ this.globe.DrawRender();
250
+ }
229
251
  setOpacity(opacity) {
230
252
  if (this._options.opacity !== opacity) {
231
253
  this._options.opacity = opacity;
@@ -94,10 +94,9 @@ const setConstantAttribute = (gl, index, size, values, typeInfo) => {
94
94
  gl.vertexAttrib4f(index, v[0], v[1], v[2], v[3]);
95
95
  };
96
96
  function resetAttributeDefault(gl, index) {
97
- gl.vertexAttrib4f(index, 1, 0, 0, 1);
97
+ gl.vertexAttrib4f(index, 0, 0, 0, 1);
98
98
  }
99
99
  function setDefaultAttributeValues(gl, index, size, escapeValues, typeInfo) {
100
- // gl.disableVertexAttribArray(index);
101
100
  setConstantAttribute(gl, index, size, escapeValues, DATA_TYPE_MAP[typeInfo]);
102
101
  }
103
102
  export { attributeLoader, createBufferAndReadInfo, resetAttributeDefault, setDefaultAttributeValues };