added taking 3D board snapshots
This commit is contained in:
parent
3a034e5880
commit
2c6056005c
3 changed files with 23 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
<button id="save">Save</button>
|
||||
<input type="file" id="fileElem" accept="application/json" style="display:none"/>
|
||||
<button id="load">Load</button>
|
||||
<button id="snapshot">Snapshot</button>
|
||||
<br/><br/>
|
||||
<select id="mode">
|
||||
<option value="self-self">Self / Self</option>
|
||||
|
|
|
@ -278,6 +278,19 @@ $(document).ready(function () {
|
|||
});
|
||||
});
|
||||
|
||||
$("#snapshot").on("click",function() {
|
||||
match.viewControl("takeSnapshot")
|
||||
.then((snapshot)=>{
|
||||
var a = document.createElement("a");
|
||||
a.href = snapshot;
|
||||
a.setAttribute("download",gameName+".png");
|
||||
a.click();
|
||||
})
|
||||
.catch((error)=>{
|
||||
console.warn("failed:",error);
|
||||
})
|
||||
});
|
||||
|
||||
// reading file locally
|
||||
var fileElem = $("#fileElem").on("change",function() {
|
||||
var fileReader = new FileReader();
|
||||
|
|
|
@ -2771,6 +2771,15 @@ if(window.JoclyXdViewCleanup)
|
|||
});
|
||||
xdv.removeGadget("panorama");
|
||||
}
|
||||
resolve();
|
||||
break;
|
||||
case "takeSnapshot":
|
||||
if(threeCtx) {
|
||||
var canvas = threeCtx.renderer.domElement;
|
||||
threeCtx.renderer.render( threeCtx.scene, threeCtx.camera );
|
||||
resolve(canvas.toDataURL("image/png"));
|
||||
} else
|
||||
reject(new Error("Snapshot only available on 3D views"));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue