freealise commited on
Commit
bb61f71
1 Parent(s): 029effe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -365,14 +365,20 @@ with gr.Blocks(css=css) as demo:
365
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
366
  '/><span>1.0</span>""")
367
  canvas = gr.HTML(value="""<a href='#' onclick='
 
 
 
 
 
 
368
  var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
369
  this.innerText = cntxt;
370
- window.screenshot = true;
371
 
372
  BABYLON.Engine.LastCreatedScene.getEngine().onEndFrameObservable.add(function () {
373
  alert(\"begin\");
374
- if (window.screenshot === true) {
375
- window.screenshot = false;
 
376
  Tools.CreateScreenshotUsingRenderTarget(
377
  BABYLON.Engine.LastCreatedScene.getEngine(),
378
  BABYLON.Engine.LastCreatedScene.activeCamera,
 
365
  this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.metadata.pipeline.imageProcessing.exposure;
366
  '/><span>1.0</span>""")
367
  canvas = gr.HTML(value="""<a href='#' onclick='
368
+ if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
369
+ BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
370
+ screenshot: true,
371
+ pipeline: new BABYLON.DefaultRenderingPipeline(\"default\", true, BABYLON.Engine.LastCreatedScene, [BABYLON.Engine.LastCreatedScene.activeCamera])
372
+ }
373
+ }
374
  var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
375
  this.innerText = cntxt;
 
376
 
377
  BABYLON.Engine.LastCreatedScene.getEngine().onEndFrameObservable.add(function () {
378
  alert(\"begin\");
379
+ if (BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot === true) {
380
+ BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot = false;
381
+ alert(\"do\");
382
  Tools.CreateScreenshotUsingRenderTarget(
383
  BABYLON.Engine.LastCreatedScene.getEngine(),
384
  BABYLON.Engine.LastCreatedScene.activeCamera,