@pirireis/webglobeplugins 1.2.5 → 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
- let targetIndex = startY * targetDimensionLength + startX;
218
- for (let y = 0; y < sourceDimensionLength; y++) {
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 - y - 1];
221
- for (let x = 0; x < sourceDimensionLength; x++) {
222
- const value = vertical[x];
223
- // const currentValue = targetMesh[targetIndex];
224
- // TODO: investigate why overlapping values are not the same. cancel parent filling
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
- nearestValuePadding.insert(tile.x, tile.y); // Using original coordinates for padding logic
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
- nearestValuePadding.insert(tileX, tileY);
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
- nearestValuePadding.clamp(mergedMesh, 0, 0, mergeCount, mergeCount);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT",