Skip to content

Commit

Permalink
[mapbox] Fix interleaving when base map has terrain (#8111)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Sep 13, 2023
1 parent 247e9ef commit e9a8403
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions modules/core/src/viewports/web-mercator-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export type WebMercatorViewportOptions = {
nearZMultiplier?: number;
/** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1.01` */
farZMultiplier?: number;
/** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */
nearZ?: number;
/** Optionally override the far plane position. `farZMultiplier` is ignored if `farZ` is supplied. */
farZ?: number;
/** Render multiple copies of the world */
repeat?: boolean;
/** Internal use */
Expand Down Expand Up @@ -115,6 +119,8 @@ export default class WebMercatorViewport extends Viewport {
bearing = 0,
nearZMultiplier = 0.1,
farZMultiplier = 1.01,
nearZ,
farZ,
orthographic = false,
projectionMatrix,

Expand Down Expand Up @@ -165,6 +171,13 @@ export default class WebMercatorViewport extends Viewport {
nearZMultiplier,
farZMultiplier
});

if (Number.isFinite(nearZ)) {
projectionParameters.near = nearZ;
}
if (Number.isFinite(farZ)) {
projectionParameters.far = farZ;
}
}

// The uncentered matrix allows us two move the center addition to the
Expand Down
6 changes: 5 additions & 1 deletion modules/mapbox/src/deck-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ function getViewport(deck: Deck, map: Map, useMapboxProjection = true): WebMerca
? // match mapbox-gl@>=1.3.0's projection matrix
0.02
: // use deck.gl's own default
0.1
0.1,
// @ts-expect-error Mapbox specific - extract near plane position
nearZ: map.transform._nearZ / map.transform.height,
// @ts-expect-error Mapbox specific - extract far plane position
farZ: map.transform._farZ / map.transform.height
});
}

Expand Down

0 comments on commit e9a8403

Please sign in to comment.