@pirireis/webglobeplugins 1.2.2 → 1.2.4

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.
@@ -260,6 +260,14 @@ function filterEdgePointTriangles(indeces, edgePointIndices) {
260
260
  }
261
261
  return new Uint32Array(result);
262
262
  }
263
+ function roundTo7(n) {
264
+ // Keep at most 7 digits after the decimal (degrees), then quantize to float32
265
+ // to match GPU attribute precision and make identity comparisons stable.
266
+ const rounded = Math.round(n * 1e7) / 1e7;
267
+ return rounded;
268
+ // return Math.round(rounded);
269
+ // return Math.fround(n);
270
+ }
263
271
  // function createArcPointHarvestingMeta(): ArcPointHarvestingMeta {
264
272
  // return {
265
273
  // parallelCutIndices: [],
@@ -288,17 +296,17 @@ export function partialTessellation(triangleMeta, limits, innerCuts, calculateRe
288
296
  */
289
297
  const _f32 = /*@__PURE__*/ new Float32Array(1);
290
298
  const _u32 = /*@__PURE__*/ new Uint32Array(_f32.buffer);
291
- // const float32Bits = (n: number): number => {
292
- // _f32[0] = n;
293
- // return _u32[0];
294
- // };
299
+ const float32Bits = (n) => {
300
+ _f32[0] = n;
301
+ return _u32[0];
302
+ };
295
303
  const addPoint = (longLat, vec3, edgeIndex) => {
296
- const xy = radianToMercatorXY(longLat);
297
- const x = Math.fround(xy[0]);
298
- const y = Math.fround(xy[1]);
299
- // Use float32 bit patterns for an exact, stable key.
300
- const key = `${xy[0].toFixed(8)},${xy[1].toFixed(8)}`;
301
- // const key = `${float32Bits(x)},${float32Bits(y)}`;
304
+ // Triangulate and render in Mercator XY (unscaled) space.
305
+ // De-dupe using float32 bit patterns to exactly match GPU attribute precision.
306
+ const merc = radianToMercatorXY(longLat);
307
+ const x = Math.fround(merc[0]);
308
+ const y = Math.fround(merc[1]);
309
+ const key = `${float32Bits(x)},${float32Bits(y)}`;
302
310
  let index = pointMap.get(key);
303
311
  if (index !== undefined) {
304
312
  if (edgeIndex !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",
@@ -25,6 +25,7 @@ const styleBlockManager = new UniformBlockManager('Style', [
25
25
  { name: "private_isPickedOn", type: "bool", value: new Float32Array([0]) },
26
26
  { name: "useDefaultColor", type: "bool", value: new Float32Array([0]) },
27
27
  { name: "private_changeHoverColor", type: "bool", value: new Float32Array([1]) },
28
+ { name: "useTiltOpacity", type: "bool", value: new Float32Array([1.0]) },
28
29
  ], uniformBindingPoints.style);
29
30
  const vertexShaderSource = `#version 300 es
30
31
  #pragma vscode_glsllint_stage : vert
@@ -99,7 +100,7 @@ void main() {
99
100
  }
100
101
 
101
102
 
102
- v_color.a *= opacity;
103
+ v_color.a *= opacity * (useTiltOpacity ? tilt_opacity : 1.0);
103
104
  gl_PointSize = u_pointSize;
104
105
  }
105
106
  `;
@@ -15,12 +15,18 @@ layout(std140) uniform CameraUniformBlock {
15
15
  float world_tilt; // 4 bytes 168
16
16
  float world_north_angle; // 4 bytes 172
17
17
  vec2 world_center_radian; // 8 bytes 176
18
- float NaN; // padding to 16 bytes 184
18
+ float tilt_opacity; // padding to 16 bytes 184
19
19
  }; // 188 bytes total
20
20
  `;
21
21
  // TODO: Remove NaN
22
22
  const Radian = Math.PI / 180.0;
23
23
  const _0vec3 = [0, 0, 0];
24
+ function tiltOpacity(tiltAngle) {
25
+ const tilt = tiltAngle / 72 * 87;
26
+ // const tiltFactor = Math.min(1, Math.sqrt(1 / Math.tan(Radian * tilt)));
27
+ const tiltFactor = Math.sqrt(Math.cos(Radian * tilt));
28
+ return tiltFactor; // Ensure opacity is not less than 0.1
29
+ }
24
30
  export class CameraUniformBlockTotem {
25
31
  id;
26
32
  description;
@@ -124,6 +130,8 @@ The following is the glsl uniform block: ${CameraUniformBlockString}`;
124
130
  Radian * CenterLat,
125
131
  ]));
126
132
  // this._frustumPlanes = getFrustumPlanes(projection, translate);
133
+ const tilt_opacity = tiltOpacity(Tilt);
134
+ gl.bufferSubData(gl.UNIFORM_BUFFER, 184, new Float32Array([tilt_opacity]));
127
135
  gl.bindBuffer(gl.UNIFORM_BUFFER, null);
128
136
  // isMoved
129
137
  const currentLOD = globe.api_GetCurrentLODWithDecimal();
@@ -19,6 +19,7 @@ export class TerrainPolygonSemiPlugin {
19
19
  hoverColor: [1, 0, 0, 1],
20
20
  opacity: 1.0,
21
21
  useDefaultColor: false,
22
+ useTiltOpacity: true,
22
23
  },
23
24
  edgeStyle: {
24
25
  defaultColor: [1, 1, 0, 1],
@@ -26,6 +27,7 @@ export class TerrainPolygonSemiPlugin {
26
27
  changeColorOnHover: true,
27
28
  opacity: 1.0,
28
29
  useDefaultColor: true,
30
+ useTiltOpacity: true,
29
31
  },
30
32
  // Global opacity multiplier applied on top of style opacities
31
33
  opacity: 1.0,
@@ -115,6 +117,7 @@ export class TerrainPolygonSemiPlugin {
115
117
  this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([1.0]));
116
118
  this._uboHandler.updateSingle("hoverColor", new Float32Array(this._options.polygonStyle.hoverColor));
117
119
  this._uboHandler.updateSingle("private_changeHoverColor", new Float32Array([this._options.polygonStyle.changeColorOnHover ? 1 : 0]));
120
+ this._uboHandler.updateSingle("useTiltOpacity", new Float32Array([this._options.polygonStyle.useTiltOpacity ? 1 : 0]));
118
121
  }
119
122
  else {
120
123
  this._uboHandler.updateSingle("private_isPickedOn", new Float32Array([0.0]));
@@ -126,6 +129,8 @@ export class TerrainPolygonSemiPlugin {
126
129
  this._uboForRealEdgeArcs.updateSingle("opacity", this._effectiveOpacity("edgeArc"));
127
130
  this._uboForRealEdgeArcs.updateSingle("private_isPickedOn", new Float32Array([0.0]));
128
131
  this._uboForRealEdgeArcs.updateSingle("private_changeHoverColor", new Float32Array([this._options.edgeStyle.changeColorOnHover ? 1 : 0]));
132
+ this._uboForRealEdgeArcs.updateSingle("hoverColor", new Float32Array(this._options.edgeStyle.hoverColor));
133
+ this._uboForRealEdgeArcs.updateSingle("useTiltOpacity", new Float32Array([this._options.edgeStyle.useTiltOpacity ? 1 : 0]));
129
134
  this._drawRealEdgeArcs.elementBuffer = gl.createBuffer();
130
135
  }
131
136
  if (this._options.variativeColorsOn) {
@@ -484,6 +489,7 @@ function roundTo7(n) {
484
489
  // Keep at most 7 digits after the decimal (degrees), then quantize to float32
485
490
  // to match GPU attribute precision and make identity comparisons stable.
486
491
  const rounded = Math.round(n * 1e7) / 1e7;
487
- return Math.fround(rounded);
492
+ return rounded;
493
+ // return Math.round(rounded);
488
494
  // return Math.fround(n);
489
495
  }