@pirireis/webglobeplugins 1.2.3 → 1.2.5
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
|
@@ -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
|
|
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) {
|
|
@@ -162,7 +167,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
162
167
|
...p,
|
|
163
168
|
geometry: p.geometry.map((g) => ({
|
|
164
169
|
...g,
|
|
165
|
-
vertices: g.vertices.map((v) =>
|
|
170
|
+
vertices: g.vertices.map((v) => roundTo6(v)),
|
|
166
171
|
})),
|
|
167
172
|
}));
|
|
168
173
|
filteredPolygons = this._indexPolygonMap.insertBulk(filteredPolygons);
|
|
@@ -480,11 +485,9 @@ function getGlStates(gl) {
|
|
|
480
485
|
texture2DArray: gl.getParameter(gl.TEXTURE_BINDING_2D_ARRAY),
|
|
481
486
|
};
|
|
482
487
|
}
|
|
483
|
-
function
|
|
484
|
-
// Keep at most
|
|
488
|
+
function roundTo6(n) {
|
|
489
|
+
// Keep at most 6 digits after the decimal (degrees), then quantize to float32
|
|
485
490
|
// to match GPU attribute precision and make identity comparisons stable.
|
|
486
|
-
const rounded = Math.round(n *
|
|
491
|
+
const rounded = Math.round(n * 1e6) / 1e6;
|
|
487
492
|
return rounded;
|
|
488
|
-
// return Math.round(rounded);
|
|
489
|
-
// return Math.fround(n);
|
|
490
493
|
}
|