Skip to content

Commit

Permalink
Fix for z-offset in v2 tiles and z-offset flickering in v1 and v2 til…
Browse files Browse the repository at this point in the history
…es (internal-1430)
  • Loading branch information
jtorresfabra authored and mourner committed May 22, 2024
1 parent d6c8bb8 commit a430303
Show file tree
Hide file tree
Showing 8 changed files with 733 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 3d-style/data/bucket/tiled_3d_model_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ class Tiled3dModelBucket implements Bucket {
if (x < meshAabb.min[0] || y < meshAabb.min[1] || x > meshAabb.max[0] || y > meshAabb.max[1]) continue;

assert(mesh.heightmap);
const xCell = ((x - meshAabb.min[0]) / (meshAabb.max[0] - meshAabb.min[0]) * HEIGHTMAP_DIM) | 0;
const yCell = ((y - meshAabb.min[1]) / (meshAabb.max[1] - meshAabb.min[1]) * HEIGHTMAP_DIM) | 0;
const xCell = ((x - mesh.aabb.min[0]) / (mesh.aabb.max[0] - mesh.aabb.min[0]) * HEIGHTMAP_DIM) | 0;
const yCell = ((y - mesh.aabb.min[1]) / (mesh.aabb.max[1] - mesh.aabb.min[1]) * HEIGHTMAP_DIM) | 0;
const heightmapIndex = Math.min(HEIGHTMAP_DIM - 1, yCell) * HEIGHTMAP_DIM + Math.min(HEIGHTMAP_DIM - 1, xCell);

tmpVertex[2] = mesh.heightmap[heightmapIndex];
Expand Down
2 changes: 1 addition & 1 deletion src/source/building_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class BuildingIndex {
const heightData = b.getHeightAtTileCoord(tileX, tileY);
if (!heightData || heightData.hidden) continue;
if (heightData.height === undefined && availableHeight !== undefined) return Math.min(heightData.maxHeight, availableHeight) * heightData.verticalScale;
return (heightData.height || 0) * heightData.verticalScale;
return heightData.height ? heightData.height * heightData.verticalScale : Number.NEGATIVE_INFINITY;
}
// If we couldn't find a bucket, return Number.NEGATIVE_INFINITY. If a layer got hidden since previous frame, place symbols on ground.
return this.layersGotHidden ? 0 : Number.NEGATIVE_INFINITY;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a430303

Please sign in to comment.