Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -452,6 +452,8 @@ with gr.Blocks(css=css) as demo:
|
|
452 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
453 |
BABYLON.Engine.LastCreatedScene.activeCamera.fov = this.value;
|
454 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.fov;
|
|
|
|
|
455 |
'/><span>0.8</span>""")
|
456 |
camera = gr.HTML(value="""<a href='#' id='reset_cam' onclick='
|
457 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
@@ -463,10 +465,11 @@ with gr.Blocks(css=css) as demo:
|
|
463 |
BABYLON.Engine.LastCreatedScene.activeCamera.radius = 0;
|
464 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById(\"zoom\").value));
|
465 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
|
|
466 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = document.getElementById(\"contrast\").value;
|
467 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure = document.getElementById(\"exposure\").value;
|
468 |
|
469 |
-
document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0)
|
470 |
'>reset camera</a>""")
|
471 |
contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='2.0' min='0' max='2' step='0.001' oninput='
|
472 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
@@ -492,8 +495,7 @@ with gr.Blocks(css=css) as demo:
|
|
492 |
evt.initEvent(\"click\", true, false);
|
493 |
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
494 |
}
|
495 |
-
|
496 |
-
//this.innerText = cntxt;
|
497 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot = true;
|
498 |
|
499 |
BABYLON.Engine.LastCreatedScene.getEngine().onEndFrameObservable.add(function() {
|
@@ -503,22 +505,19 @@ with gr.Blocks(css=css) as demo:
|
|
503 |
BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
|
504 |
{ precision: 1.0 }, (durl) => {
|
505 |
document.getElementById(\"img_out\").onload = function() {
|
506 |
-
|
507 |
-
<defs>
|
508 |
-
<filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
|
509 |
-
<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0)/2.0 + `\" />
|
510 |
-
</filter>
|
511 |
-
</defs>
|
512 |
-
<image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + document.getElementById(\"img_out\").width + `\" height=\"` + document.getElementById(\"img_out\").height + `\" xlink:href=\"` + durl + `\"/>
|
513 |
-
</svg>`;
|
514 |
-
document.getElementById(\"img_out\").onload = function() {
|
515 |
-
document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
|
516 |
-
document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
|
517 |
-
document.getElementById(\"cnv_out\").getContext(\"2d\").drawImage(img_out, 0, 0);
|
518 |
-
}
|
519 |
-
document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
|
520 |
}
|
521 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
}
|
523 |
);
|
524 |
} catch(e) { alert(e); }
|
|
|
452 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/this.value));
|
453 |
BABYLON.Engine.LastCreatedScene.activeCamera.fov = this.value;
|
454 |
this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.fov;
|
455 |
+
|
456 |
+
document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + \"px)\";
|
457 |
'/><span>0.8</span>""")
|
458 |
camera = gr.HTML(value="""<a href='#' id='reset_cam' onclick='
|
459 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
|
|
465 |
BABYLON.Engine.LastCreatedScene.activeCamera.radius = 0;
|
466 |
BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize = Math.ceil(Math.log2(Math.PI/document.getElementById(\"zoom\").value));
|
467 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.samples = 4;
|
468 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.fov = document.getElementById(\"zoom\").value;
|
469 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.contrast = document.getElementById(\"contrast\").value;
|
470 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure = document.getElementById(\"exposure\").value;
|
471 |
|
472 |
+
document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + \"px)\";
|
473 |
'>reset camera</a>""")
|
474 |
contrast = gr.HTML(value="""<label for='contrast'>Contrast</label><input id='contrast' type='range' style='width:256px;height:1em;' value='2.0' min='0' max='2' step='0.001' oninput='
|
475 |
if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
|
|
|
495 |
evt.initEvent(\"click\", true, false);
|
496 |
document.getElementById(\"reset_cam\").dispatchEvent(evt);
|
497 |
}
|
498 |
+
var cnvs = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0]; //.getContext(\"webgl2\");
|
|
|
499 |
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot = true;
|
500 |
|
501 |
BABYLON.Engine.LastCreatedScene.getEngine().onEndFrameObservable.add(function() {
|
|
|
505 |
BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
|
506 |
{ precision: 1.0 }, (durl) => {
|
507 |
document.getElementById(\"img_out\").onload = function() {
|
508 |
+
document.getElementById(\"cnv_out\").getContext(\"2d\").drawImage(img_out, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
}
|
510 |
+
var svgd = `<svg id=\"svg_out\" viewBox=\"0 0 ` + cnvs.width + ` ` + cnvs.height + `\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
|
511 |
+
<defs>
|
512 |
+
<filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
|
513 |
+
<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + `\" />
|
514 |
+
</filter>
|
515 |
+
</defs>
|
516 |
+
<image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + cnvs.width + `\" height=\"` + cnvs.height + `\" xlink:href=\"` + durl + `\"/>
|
517 |
+
</svg>`;
|
518 |
+
document.getElementById(\"cnv_out\").width = cnvs.width;
|
519 |
+
document.getElementById(\"cnv_out\").height = cnvs.height;
|
520 |
+
document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
|
521 |
}
|
522 |
);
|
523 |
} catch(e) { alert(e); }
|