@pirireis/webglobeplugins 1.1.15 → 1.1.16
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 +1 -1
- package/programs/polygon-on-globe/texture-dem-triangles.js +17 -29
- package/semiplugins/shape-on-terrain/terrain-polygon/data/master-worker.js +1 -1
- package/semiplugins/shape-on-terrain/terrain-polygon/data/worker.js +1 -1
- package/semiplugins/shape-on-terrain/terrain-polygon/terrain-polygon.js +2 -0
- package/util/gl-util/buffer/attribute-loader.js +8 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { DemTextureManagerCache, DEM_TEXTURE_BLOCK_STRING } from "../totems/atta
|
|
|
4
4
|
import { cartesian3DToGLPosition, mercatorXYToGLPosition, POLE_BY_PI } from "../../util/shaderfunctions/geometrytransformations";
|
|
5
5
|
import { relativeBBoxPositionRadian } from "../../util/shaderfunctions/geometrytransformations";
|
|
6
6
|
import { drawArrays } from "../../util/gl-util/draw-options/methods";
|
|
7
|
-
import { attributeLoader } from "../../util/gl-util/buffer/attribute-loader";
|
|
7
|
+
import { attributeLoader, resetAttributeDefault, setDefaultAttributeValues } from "../../util/gl-util/buffer/attribute-loader";
|
|
8
8
|
import { WORLD_RADIUS_3D } from "../../Math/constants";
|
|
9
9
|
import { UniformBlockManager } from "../../util/gl-util/uniform-block/manager";
|
|
10
10
|
// const ESCAPE_VALUE = 0.123456;
|
|
@@ -40,7 +40,7 @@ ${DEM_TEXTURE_BLOCK_STRING}
|
|
|
40
40
|
|
|
41
41
|
in vec3 a_position;
|
|
42
42
|
in vec2 a_xy;
|
|
43
|
-
in
|
|
43
|
+
in uint a_index;
|
|
44
44
|
in uvec4 a_color;
|
|
45
45
|
|
|
46
46
|
${styleBlockManager.glslCode()}
|
|
@@ -91,12 +91,10 @@ void main() {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (private_isPickedOn == true){
|
|
94
|
-
if (a_index ==
|
|
94
|
+
if (a_index == private_pickedIndex) {
|
|
95
95
|
v_color = pickedColor;
|
|
96
96
|
}
|
|
97
|
-
v_index =
|
|
98
|
-
} else {
|
|
99
|
-
v_index = 0u;
|
|
97
|
+
v_index = a_index;
|
|
100
98
|
}
|
|
101
99
|
|
|
102
100
|
|
|
@@ -178,7 +176,7 @@ export class TextureDemTriangles {
|
|
|
178
176
|
attributeLoader(this.gl, pos3dBufferInfo, this.locations.attributes.a_position, 3);
|
|
179
177
|
attributeLoader(this.gl, longLatBufferInfo, this.locations.attributes.a_xy, 2);
|
|
180
178
|
attributeLoader(this.gl, indexBufferInfo, this.locations.attributes.a_index, 1, {
|
|
181
|
-
|
|
179
|
+
dataType: "uint16",
|
|
182
180
|
escapeValues: [IndexAttributeEscapeValue],
|
|
183
181
|
});
|
|
184
182
|
attributeLoader(this.gl, variativeColorBuffer, this.locations.attributes.a_color, 4, {
|
|
@@ -233,6 +231,18 @@ export class TextureDemTriangles {
|
|
|
233
231
|
ubo.unbind();
|
|
234
232
|
this.cameraUniformBlock.unbind(uniformBindingPoints.camera);
|
|
235
233
|
}
|
|
234
|
+
setDefaultDefaultAttributeValues() {
|
|
235
|
+
const gl = this.gl;
|
|
236
|
+
setDefaultAttributeValues(gl, this.locations.attributes.a_index, 1, [IndexAttributeEscapeValue], "uint16");
|
|
237
|
+
setDefaultAttributeValues(gl, this.locations.attributes.a_color, 4, [0, 0, 0, 255], "uint8");
|
|
238
|
+
}
|
|
239
|
+
resetDefaultAttributeValues() {
|
|
240
|
+
const gl = this.gl;
|
|
241
|
+
gl.disableVertexAttribArray(this.locations.attributes.a_index);
|
|
242
|
+
resetAttributeDefault(gl, this.locations.attributes.a_index);
|
|
243
|
+
gl.disableVertexAttribArray(this.locations.attributes.a_color);
|
|
244
|
+
resetAttributeDefault(gl, this.locations.attributes.a_color);
|
|
245
|
+
}
|
|
236
246
|
_getUniformBlockOffset(name) {
|
|
237
247
|
// hardcoded offsets based on std140 layout rules
|
|
238
248
|
const offsets = {
|
|
@@ -245,25 +255,3 @@ export class TextureDemTriangles {
|
|
|
245
255
|
return result;
|
|
246
256
|
}
|
|
247
257
|
}
|
|
248
|
-
function drawOnTopBegin(gl) {
|
|
249
|
-
gl.disable(gl.DEPTH_TEST);
|
|
250
|
-
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
251
|
-
// // Use an offset to "nudge" the depth value slightly closer or farther.
|
|
252
|
-
// // Common values are gl.polygonOffset(1.0, 1.0) or gl.polygonOffset(0.RESOLUTION, 0.RESOLUTION)
|
|
253
|
-
// gl.polygonOffset(1.0, 1.0);
|
|
254
|
-
// gl.depthRange(0.0, 0.0001); // Use near 0.01% of depth range
|
|
255
|
-
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
256
|
-
// You will need to experiment with these values!
|
|
257
|
-
// A good starting point is -1.0, -1.0.
|
|
258
|
-
// Negative values "pull" the fragments closer to the camera.
|
|
259
|
-
// gl.polygonOffset(-1.0, -1.0);
|
|
260
|
-
// gl.enable(gl.POLYGON_OFFSET_FILL);
|
|
261
|
-
// gl.polygonOffset(-1.0, -2.0);
|
|
262
|
-
}
|
|
263
|
-
function drawOnTopEnd(gl) {
|
|
264
|
-
gl.enable(gl.DEPTH_TEST);
|
|
265
|
-
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
266
|
-
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
267
|
-
// gl.depthRange(0.0, 1.0); // Restore full depth range
|
|
268
|
-
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
269
|
-
}
|
|
@@ -95,7 +95,7 @@ function mergeAndSendResults() {
|
|
|
95
95
|
indices: new Uint32Array(totalIndices),
|
|
96
96
|
longLats: new Float32Array(totalLongLats),
|
|
97
97
|
realEdgeArcIndices: _arcState && totalRealEdgeArcIndices > 0 ? new Uint32Array(totalRealEdgeArcIndices) : null,
|
|
98
|
-
pickIndices: totalPickIndices > 0 ? new
|
|
98
|
+
pickIndices: totalPickIndices > 0 ? new Uint16Array(totalPickIndices) : null,
|
|
99
99
|
variativeColors: totalVariativeColors > 0 ? new Uint8Array(totalVariativeColors) : null,
|
|
100
100
|
};
|
|
101
101
|
// Sentinel/header (as in master-worker.js)
|
|
@@ -106,7 +106,7 @@ self.onmessage = (event) => {
|
|
|
106
106
|
longLats: new Float32Array((counter / 3) * 2),
|
|
107
107
|
indices: new Uint32Array(indexCounter),
|
|
108
108
|
realEdgeArcIndices: _arcState ? new Uint32Array(totalArcCount) : null,
|
|
109
|
-
pickIndices: _pickableState ? new
|
|
109
|
+
pickIndices: _pickableState ? new Uint16Array(counter / 3) : null,
|
|
110
110
|
variativeColors: _variativeColorsOnState ? new Uint8Array((counter / 3) * 4) : null,
|
|
111
111
|
};
|
|
112
112
|
let currentVertexOffset = 0;
|
|
@@ -377,6 +377,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
377
377
|
gl.disable(gl.DEPTH_TEST);
|
|
378
378
|
gl.enable(gl.BLEND);
|
|
379
379
|
defaultblendfunction(gl);
|
|
380
|
+
this._program.setDefaultDefaultAttributeValues();
|
|
380
381
|
// drawPoints
|
|
381
382
|
if (this._options.showTesselationPoints) {
|
|
382
383
|
this._program.draw(this._vao, this._drawPointsRangeIndexParams, this._uboHandler);
|
|
@@ -401,6 +402,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
401
402
|
this._program.draw(this._vao, this._drawRealEdgeArcs, this._uboForRealEdgeArcs);
|
|
402
403
|
// gl.disable(gl.POLYGON_OFFSET_FILL);
|
|
403
404
|
}
|
|
405
|
+
this._program.resetDefaultAttributeValues();
|
|
404
406
|
gl.enable(gl.DEPTH_TEST);
|
|
405
407
|
}
|
|
406
408
|
free() {
|
|
@@ -70,7 +70,6 @@ const setConstantAttribute = (gl, index, size, values, typeInfo) => {
|
|
|
70
70
|
throw new Error(`Attribute size must be between 1 and 4. Got ${size}.`);
|
|
71
71
|
}
|
|
72
72
|
if (typeInfo.useIntegerPointer) {
|
|
73
|
-
return;
|
|
74
73
|
gl.vertexAttrib4f(index, 0, 0, 0, 1);
|
|
75
74
|
// Integer attributes: WebGL2 ONLY supports vertexAttribI4i/I4ui for constants.
|
|
76
75
|
const intValues = values.map((v) => Math.trunc(v));
|
|
@@ -94,4 +93,11 @@ const setConstantAttribute = (gl, index, size, values, typeInfo) => {
|
|
|
94
93
|
else
|
|
95
94
|
gl.vertexAttrib4f(index, v[0], v[1], v[2], v[3]);
|
|
96
95
|
};
|
|
97
|
-
|
|
96
|
+
function resetAttributeDefault(gl, index) {
|
|
97
|
+
gl.vertexAttrib4f(index, 0, 0, 0, 1);
|
|
98
|
+
}
|
|
99
|
+
function setDefaultAttributeValues(gl, index, size, escapeValues, typeInfo) {
|
|
100
|
+
// gl.disableVertexAttribArray(index);
|
|
101
|
+
setConstantAttribute(gl, index, size, escapeValues, DATA_TYPE_MAP[typeInfo]);
|
|
102
|
+
}
|
|
103
|
+
export { attributeLoader, createBufferAndReadInfo, resetAttributeDefault, setDefaultAttributeValues };
|