(function (window) { 'use strict'; function define_CesiumDataView() { var CesiumDataView = {}; CesiumDataView.exportImg = function (options) { let canvas = options.viewer.scene.canvas; var image = new Image(); canvas.width=canvas.width/options.level; canvas.height=canvas.height/options.level; options.viewer.render(); image = canvas.toDataURL("image/png"); let link = document.createElement("a"); let blob = dataURLtoBlob(image); let objurl = URL.createObjectURL(blob); link.download = "scene.png"; link.href = objurl; link.click(); } function dataURLtoBlob(dataurl) { let arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new Blob([u8arr], { type: mime }); } return CesiumDataView; } if (typeof (CesiumDataView) === 'undefined') { window.CesiumDataView = define_CesiumDataView(); } else { console.log("CesiumDraw already defined."); } })(window);