Implementing a Cesium globe screenshot functionality

Hi at all,

I'm a GWT SW developer. I'm implementing GWT-Cesium web and I need to implement a screenshot functionality to store it in the server, only including the Cesium area without the rest of GWT components.

thanks a lot
Regards.

Something like this should do the trick:

https://github.com/TerriaJS/terriajs/blob/master/lib/Models/Cesium.js#L368

While Kevin’s code works, there’s no need for it to be asynchronous. You can just manually call render right before toDataURL and everything is fine. Here’s a Sandcastle example that pops up a screenshot in a new window. (You could also simulate a download with a link element if you would rather do that).

var viewer = new Cesium.Viewer(‘cesiumContainer’);

Sandcastle.addToolbarButton(‘Snap’, function(){

viewer.render();

window.open(viewer.canvas.toDataURL(“image/png”));

});

We saw a problem with that approach… on Firefox maybe? It could be an old problem at this point, though. YMMV.