freealise commited on
Commit
7ac500f
1 Parent(s): 369cda2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -453,7 +453,7 @@ with gr.Blocks(css=css) as demo:
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) {
@@ -469,7 +469,7 @@ with gr.Blocks(css=css) as demo:
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.getElementById(\"model3D\").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) {
@@ -504,20 +504,21 @@ with gr.Blocks(css=css) as demo:
504
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
505
  { precision: 1.0 }, (durl) => {
506
  var cnvs = document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0]; //.getContext(\"webgl2\");
 
507
  document.getElementById(\"img_out\").onload = function() {
508
- document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
509
- document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
510
- document.getElementById(\"cnv_out\").getContext(\"2d\").drawImage(img_out, 0, 0);
511
  }
512
  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\">
513
  <defs>
514
  <filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
515
- <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + `\" />
516
  </filter>
517
  </defs>
518
  <image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + cnvs.width + `\" height=\"` + cnvs.height + `\" xlink:href=\"` + durl + `\"/>
519
  </svg>`;
520
- document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
 
 
521
  }
522
  );
523
  } catch(e) { alert(e); }
 
453
  BABYLON.Engine.LastCreatedScene.activeCamera.fov = this.value;
454
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.fov;
455
 
456
+ document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/2.0*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) {
 
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.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0].style.filter = \"blur(\" + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/2.0*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) {
 
504
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
505
  { precision: 1.0 }, (durl) => {
506
  var cnvs = document.getElementById(\"model3D\").getElementsByTagName(\"canvas\")[0]; //.getContext(\"webgl2\");
507
+ var ctxt = document.getElementById(\"cnv_out\").getContext(\"2d\");
508
  document.getElementById(\"img_out\").onload = function() {
509
+ ctxt.drawImage(img_out, 0, 0);
 
 
510
  }
511
  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\">
512
  <defs>
513
  <filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
514
+ <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/2.0*Math.sqrt(2.0) + `\" />
515
  </filter>
516
  </defs>
517
  <image filter=\"url(#blur)\" id=\"svg_img\" x=\"0\" y=\"0\" width=\"` + cnvs.width + `\" height=\"` + cnvs.height + `\" xlink:href=\"` + durl + `\"/>
518
  </svg>`;
519
+ document.getElementById(\"cnv_out\").width = cnvs.width;
520
+ document.getElementById(\"cnv_out\").height = cnvs.height;
521
+ document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
522
  }
523
  );
524
  } catch(e) { alert(e); }