Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mapbox] Fix interleaving when base map has terrain #8111

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading