freealise commited on
Commit
28281af
1 Parent(s): cd02b36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -356,7 +356,7 @@ with gr.Blocks(css=css) as demo:
356
  var camera = BABYLON.Engine.LastCreatedScene.activeCamera;
357
 
358
  BABYLON.Engine.LastCreatedScene.getNodes()[1].position.z = this.value * Math.cos(camera.alpha) * Math.sin(camera.beta);
359
- BABYLON.Engine.LastCreatedScene.getNodes()[1].position.y = this.value * Math.cos(camera.beta);
360
  BABYLON.Engine.LastCreatedScene.getNodes()[1].position.x = this.value * Math.sin(camera.alpha) * Math.sin(camera.beta);
361
 
362
  this.parentNode.childNodes[2].innerText = this.value;
@@ -404,21 +404,19 @@ with gr.Blocks(css=css) as demo:
404
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
405
  { precision: 1.0 }, (durl) => {
406
  document.getElementById(\"img_out\").onload = function() {
407
- document.getElementById(\"svg_div\").innerHTML = `<svg id=\"svg_out\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
408
- <defs>
409
- <filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
410
- <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + `\" />
411
- </filter>
412
- </defs>
413
- <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 + `\"/>
414
- </svg>`;
415
- alert(document.getElementById(\"svg_div\").innerHTML);
416
-
417
  document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
418
  document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
419
- ctx.drawImage(svg_out, 0, 0);
420
  }
421
- document.getElementById(\"img_out\").src = durl;
 
 
 
 
 
 
 
 
422
  });
423
  } catch(e) { alert(e); }
424
  // https://forum.babylonjs.com/t/best-way-to-save-to-jpeg-snapshots-of-scene/17663/11
 
356
  var camera = BABYLON.Engine.LastCreatedScene.activeCamera;
357
 
358
  BABYLON.Engine.LastCreatedScene.getNodes()[1].position.z = this.value * Math.cos(camera.alpha) * Math.sin(camera.beta);
359
+ BABYLON.Engine.LastCreatedScene.getNodes()[1].position.y = 0;
360
  BABYLON.Engine.LastCreatedScene.getNodes()[1].position.x = this.value * Math.sin(camera.alpha) * Math.sin(camera.beta);
361
 
362
  this.parentNode.childNodes[2].innerText = this.value;
 
404
  BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera,
405
  { precision: 1.0 }, (durl) => {
406
  document.getElementById(\"img_out\").onload = function() {
 
 
 
 
 
 
 
 
 
 
407
  document.getElementById(\"cnv_out\").width = document.getElementById(\"img_out\").width;
408
  document.getElementById(\"cnv_out\").height = document.getElementById(\"img_out\").height;
409
+ ctx.drawImage(img_out, 0, 0);
410
  }
411
+ var svgd = `<svg id=\"svg_out\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">
412
+ <defs>
413
+ <filter id=\"blur\" x=\"0\" y=\"0\" xmlns=\"http://www.w3.org/2000/svg\">
414
+ <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"` + BABYLON.Engine.LastCreatedScene.getNodes()[1].material.pointSize/Math.sqrt(2.0) + `\" />
415
+ </filter>
416
+ </defs>
417
+ <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 + `\"/>
418
+ </svg>`;
419
+ document.getElementById(\"img_out\").src = \"data:image/svg+xml;base64,\" + btoa(svgd);
420
  });
421
  } catch(e) { alert(e); }
422
  // https://forum.babylonjs.com/t/best-way-to-save-to-jpeg-snapshots-of-scene/17663/11