melowntech / vts-browser-js

JavaScript WebGL 3D map rendering engine
BSD 2-Clause "Simplified" License
218 stars 42 forks source link

Screenshot #202

Closed jrjdavidson closed 3 years ago

jrjdavidson commented 3 years ago

I noticed there is a function to generate a screenshot(shift+p in inspector) .. I want to add a button that will save a screenshot of the map and all the geodata on top. Any chance you can point me in the right direction?

thanks

davidmtech commented 3 years ago

There is a function for saving screen shots:

renderer.saveScreenshot(output, filename, filetype);

e.g: renderer.saveScreenshot('file', 'screenshot.png', 'png');

But important prerequisite is to initialize browser with browser option rendererAllowScreenshots : true. This option sets WebGL into mode where WebGL screen pixels are accessible. Otherwise you will receive empty screenshot. This option can lead to worse performance so it is not enabled by default.

https://github.com/melowntech/vts-browser-js/wiki/VTS-Browser-API#advanced-options

jrjdavidson commented 3 years ago

Works great, thanks!