question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interleaving DeckGL layers with a base map

See original GitHub issue

Hello, this is just a continuation #4529. After successfully integrating harp.gl’s map with deck.gl, I was experimenting with things and found my Icon Layer laid on top of the buildings of the map.

Normally in mapbox this could be solved by using the mapboxLayer and adding the icon layer beneath the building layer but harp.gl doesn’t provide that sort of functionality.

In essence deckgl is just drawing to an overlay canvas which is laid on top of the base canvas (harpgl’s map in this case) if I understood correct. Is there any way to inform the overlay canvas of the depth buffer of the base canvas so everything renders correctly?

An example screen. the red circles show where the icon should be behind the buildings. testt

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:61

github_iconTop GitHub Comments

3reactions
gallickgunnercommented, Sep 27, 2020

Yep you got it. The icon layer renders as billboards, i.e. all icons are drawn facing the camera at the depth of their anchor.

To draw them in real 3D you need each icon’s rectangle in the world space instead of the clip space. You may switch to the SimpleMeshLayer with texture, or you can subclass the IconLayer and modify its billboard: false mode.

Edit: looks like the original issue (depth matching with harp.gl) is solved? We can move the icon rendering discussion to a different thread.

Hmm, I’ll try that. And yes I think this was the main issue all along. So depth matching with harp.gl works already, I guess. There might be issues with far plane mismatching which give those yellowish/blue planes but more or less they can be avoided or tweaked.

I’ll open a new thread regarding icon rendering when I’m back on this. Thanks for the continued support, appreciate it.

2reactions
gallickgunnercommented, Sep 24, 2020

So you can’t call mapView.updateCameras() because that gets overriden later during mapView.render(). You need to update the clipPlanesEvaluator:

  getClipPlaneEvaluator(viewState) {
    const viewport = new WebMercatorViewport(viewState);
    const height = viewport.height;
    let {near, far} = viewport.projectionProps;
    near *= height * viewport.metersPerPixel;
    far *= height * viewport.metersPerPixel;
    return new FixedClipPlanesEvaluator(near, far - near);
  }

  onViewStateChange = ( { viewState } ) => {
    const coords = new GeoCoordinates( viewState.latitude, viewState.longitude );
    this.mapView.lookAt( coords, MapViewUtils.calculateDistanceFromZoomLevel( { focalLength: this.mapView.focalLength }, viewState.zoom + 1 ), viewState.pitch, viewState.bearing );
    this.mapView.zoomLevel = viewState.zoom + 1;
    this.mapView.clipPlanesEvaluator = this.getClipPlaneEvaluator(viewState);
  
    this.setState( { viewState } );
  }

I tried setting clipPlanesEvaluator during MapView’s initialization. It doesn’t crash but it doesn’t render either. There might be a bug in harp?

I tried your snippet and it’s working on my end. Not getting any error or rendering issue. Tried logging the far value both on the deckgl side and inside MapView.js and it prints the same value too.

image

The only problem remaining is the original one, icons being blocked by buildings when they should be in front. There is also a whitish plane coming from the top at certaing angles, maybe another near/far plane mismanagment between the 2 apis I guess.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Base Maps - deck.gl
Interleaved : Deck renders into the WebGL context of the base map. This allows for occlusion between deck.gl layers and the base map's...
Read more >
Interleaving deck.gl with Mapbox Layers | WebGL visualization
WebGL-based visualization examples using deck.gl.
Read more >
Using with Google Maps Platform - deck.gl
Deck.gl has interleaved and overlaid support for Google Maps with the @deck.gl/google-maps module. It allows you to construct a Deck instance and apply...
Read more >
Using with Mapbox - deck.gl
Using deck.gl layers interleaved with Mapbox layers in the same WebGL context, using either the MapboxOverlay or MapboxLayer from the @deck.gl/mapbox module.
Read more >
MapboxOverlay - deck.gl
interleaved (Boolean) - If false , a dedicated deck.gl canvas is added on top of the base map. If true , deck.gl layers...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found