@pirireis/webglobeplugins 1.2.4 → 1.2.6
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.
|
@@ -214,25 +214,27 @@ function fillFromChildren(targetMesh, targetDimensionLength, childrenMeshes, sou
|
|
|
214
214
|
function moveMeshToMergedMesh(targetMesh, targetDimensionLength, sourceMesh, sourceDimensionLength, startX, startY) {
|
|
215
215
|
// sourceMesh[0][0] is south west corner
|
|
216
216
|
// targetMesh[0][0] is top left corner
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
// startX/startY can be negative (parent fallback near left/top edges). Clamp writes to target bounds.
|
|
218
|
+
const dstX0 = Math.max(0, startX);
|
|
219
|
+
const dstY0 = Math.max(0, startY);
|
|
220
|
+
const dstX1 = Math.min(targetDimensionLength, startX + sourceDimensionLength);
|
|
221
|
+
const dstY1 = Math.min(targetDimensionLength, startY + sourceDimensionLength);
|
|
222
|
+
if (dstX1 <= dstX0 || dstY1 <= dstY0) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
for (let dstY = dstY0; dstY < dstY1; dstY++) {
|
|
226
|
+
const srcY = dstY - startY;
|
|
219
227
|
// Read from bottom to top (source mesh convention)
|
|
220
|
-
const vertical = sourceMesh[sourceDimensionLength -
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// if (!isNaN(value) && value !== 0 && currentValue !== 0) {
|
|
226
|
-
// if (currentValue !== value) {
|
|
227
|
-
// console.warn(`Overlapping values are not the same: currentValue=${currentValue}, newValue=${value}`);
|
|
228
|
-
// }
|
|
229
|
-
// }
|
|
228
|
+
const vertical = sourceMesh[sourceDimensionLength - srcY - 1];
|
|
229
|
+
let targetIndex = dstY * targetDimensionLength + dstX0;
|
|
230
|
+
for (let dstX = dstX0; dstX < dstX1; dstX++) {
|
|
231
|
+
const srcX = dstX - startX;
|
|
232
|
+
const value = vertical[srcX];
|
|
230
233
|
if (isNaN(targetMesh[targetIndex])) {
|
|
231
234
|
targetMesh[targetIndex] = value;
|
|
232
235
|
}
|
|
233
236
|
targetIndex++;
|
|
234
237
|
}
|
|
235
|
-
targetIndex += targetDimensionLength - sourceDimensionLength;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
function limitCheck(limit, limitRange = 12) {
|
|
@@ -314,7 +316,8 @@ function mergeTiles(tilesMetaData, mergeCount = 8, tileDimensionLength = 5, proc
|
|
|
314
316
|
const meshOffsetY = j * (tileDimensionLength - 1);
|
|
315
317
|
if (tile) {
|
|
316
318
|
// 1. Direct Tile Found
|
|
317
|
-
|
|
319
|
+
// Track filled grid slot (relative coordinates)
|
|
320
|
+
nearestValuePadding.insert(i, j);
|
|
318
321
|
moveMeshToMergedMesh(mergedMesh, mergedMeshDimLength, tile.mesh, tileDimensionLength, meshOffsetX, meshOffsetY);
|
|
319
322
|
// Update BBox Limits
|
|
320
323
|
// We simply expand the LL/UR.
|
|
@@ -347,6 +350,8 @@ function mergeTiles(tilesMetaData, mergeCount = 8, tileDimensionLength = 5, proc
|
|
|
347
350
|
const parentKey = keyMethod(parentTileCoord.x, parentTileCoord.y, parentTileCoord.level);
|
|
348
351
|
const parentTile = tilesMetaData.tileMap.get(parentKey);
|
|
349
352
|
if (parentTile) {
|
|
353
|
+
// Track filled grid slot (relative coordinates)
|
|
354
|
+
nearestValuePadding.insert(i, j);
|
|
350
355
|
const populatedMesh = populateTileIntoHigherZoomLevel(parentTile.mesh, tileDimensionLength, tileDimensionLength * 2 - 1);
|
|
351
356
|
// Adjust offset for parent logic
|
|
352
357
|
// If current tile is odd (right/bottom), the parent mesh drawing needs to shift back
|
|
@@ -354,14 +359,6 @@ function mergeTiles(tilesMetaData, mergeCount = 8, tileDimensionLength = 5, proc
|
|
|
354
359
|
const parentDrawOffsetX = meshOffsetX - (tileX % 2) * (tileDimensionLength - 1);
|
|
355
360
|
const parentDrawOffsetY = meshOffsetY - (tileY % 2) * (tileDimensionLength - 1);
|
|
356
361
|
moveMeshToMergedMesh(mergedMesh, mergedMeshDimLength, populatedMesh, tileDimensionLength * 2 - 1, parentDrawOffsetX, parentDrawOffsetY);
|
|
357
|
-
// Padding logic for parents
|
|
358
|
-
const xP = parentTile.x * 2;
|
|
359
|
-
const yP = parentTile.y * 2;
|
|
360
|
-
for (let dx = 0; dx < 2; dx++) {
|
|
361
|
-
for (let dy = 0; dy < 2; dy++) {
|
|
362
|
-
nearestValuePadding.insert(xP + dx, yP + dy);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
362
|
}
|
|
366
363
|
else {
|
|
367
364
|
// 3. Children Tile Fallback
|
|
@@ -383,7 +380,8 @@ function mergeTiles(tilesMetaData, mergeCount = 8, tileDimensionLength = 5, proc
|
|
|
383
380
|
}
|
|
384
381
|
}
|
|
385
382
|
if (anyChildren > 0) {
|
|
386
|
-
|
|
383
|
+
// Track filled grid slot (relative coordinates)
|
|
384
|
+
nearestValuePadding.insert(i, j);
|
|
387
385
|
fillFromChildren(mergedMesh, mergedMeshDimLength, childrenTiles, tileDimensionLength, meshOffsetX, meshOffsetY);
|
|
388
386
|
}
|
|
389
387
|
}
|
|
@@ -406,7 +404,8 @@ function mergeTiles(tilesMetaData, mergeCount = 8, tileDimensionLength = 5, proc
|
|
|
406
404
|
// However, the clamp function usually expects absolute coordinates.
|
|
407
405
|
// Given the new "Grid" approach, the mesh is always locally 0 to mergeCount in valid data.
|
|
408
406
|
// We pass the grid-relative limits to clamp.
|
|
409
|
-
|
|
407
|
+
// grid slots are 0..mergeCount-1
|
|
408
|
+
nearestValuePadding.clamp(mergedMesh, 0, 0, mergeCount - 1, mergeCount - 1);
|
|
410
409
|
nearestValuePadding.clear();
|
|
411
410
|
// Calculate Cover Ratio
|
|
412
411
|
// How much of the mesh grid (mergeCount) is covered by actual data range?
|
package/package.json
CHANGED
|
@@ -167,7 +167,7 @@ export class TerrainPolygonSemiPlugin {
|
|
|
167
167
|
...p,
|
|
168
168
|
geometry: p.geometry.map((g) => ({
|
|
169
169
|
...g,
|
|
170
|
-
vertices: g.vertices.map((v) =>
|
|
170
|
+
vertices: g.vertices.map((v) => roundTo6(v)),
|
|
171
171
|
})),
|
|
172
172
|
}));
|
|
173
173
|
filteredPolygons = this._indexPolygonMap.insertBulk(filteredPolygons);
|
|
@@ -485,11 +485,9 @@ function getGlStates(gl) {
|
|
|
485
485
|
texture2DArray: gl.getParameter(gl.TEXTURE_BINDING_2D_ARRAY),
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
|
-
function
|
|
489
|
-
// Keep at most
|
|
488
|
+
function roundTo6(n) {
|
|
489
|
+
// Keep at most 6 digits after the decimal (degrees), then quantize to float32
|
|
490
490
|
// to match GPU attribute precision and make identity comparisons stable.
|
|
491
|
-
const rounded = Math.round(n *
|
|
491
|
+
const rounded = Math.round(n * 1e6) / 1e6;
|
|
492
492
|
return rounded;
|
|
493
|
-
// return Math.round(rounded);
|
|
494
|
-
// return Math.fround(n);
|
|
495
493
|
}
|