deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Ability to render deckgl offscreen

Open cschlueter opened this issue 7 years ago • 6 comments

Is it possible to completely render deckgl offscreen?

let map_container = document.createElement("div") 
map_container.setAttribute("width", 1000); // not working
map_container.setAttribute("height", 1000); // not working
...
const deckgl = new deck.DeckGL({
    container: map_container,
...

The issue is that map_container has width=height=0 and deckgl relies on the dimensions of the parent div for the canvas size. It works error free, but you get 0x0 canvas.

Thanks for any tipps!

cschlueter avatar Aug 09 '19 09:08 cschlueter

It works error free, but you get 0x0 canvas.

@cschleuter You have tried to pass in explicit height and width props to Deck?

The @deck.gl/test-utils sub-module renders layers off-screen (and compares the result with "golden" images), so it is possible, e.g.: https://github.com/uber/deck.gl/blob/master/modules/test-utils/src/test-runner.js

ibgreen avatar Aug 09 '19 14:08 ibgreen

Thanks for the pointer @ibgreen, but this seems to not work for me. Running in a "real" browser, deck always seem to attach itself to the document. Pure Deck puts just the canvas at the end of the DOM, and DeckGL as you can see here https://github.com/uber/deck.gl/blob/master/modules/core/bundle/deckgl.js in createCanvas(...) attaches itself into the div. Any other tipps? I'm just interested in an image of the canvas finally displayed to the user. Sure I could run something like you pointed to via node.js and send it down to the client, but my backend is not node js based, and that would be unnecessary overhead.

Btw. the size issue indeed was solved by passing it explicitly, but only works for Deck. Not for DeckGL, where it only seems to be taken over to the css attributers. Weird.

cschlueter avatar Aug 10 '19 20:08 cschlueter

@cschlueter You can attach the div to the document but position it so that it's invisible. kepler.gl does this: https://github.com/keplergl/kepler.gl/blob/6feca0e95a27a97e88a7577579dc4a37a6ae8853/src/components/plot-container.js#L152

Pessimistress avatar Aug 11 '19 01:08 Pessimistress

@Pessimistress thanks, I will try this, a little hacky but if it works I'm fine with it 👍

cschlueter avatar Aug 12 '19 07:08 cschlueter

Just curious, did you try setting the width and height props of Deck? By default they are '100%' therefore dependent on the parent size.

Pessimistress avatar Aug 12 '19 16:08 Pessimistress

Closing assuming this is resolved. Please reopen and comment if there is more updates.

tgorkin avatar Sep 18 '19 23:09 tgorkin