Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -376,15 +376,17 @@ with gr.Blocks(css=css) as demo:
|
|
376 |
}
|
377 |
var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
|
378 |
this.innerText = cntxt;
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
|
|
|
|
388 |
'/>webgl2</a><br/><img src='' id='img_out'/>""")
|
389 |
render = gr.Button("Render")
|
390 |
|
|
|
376 |
}
|
377 |
var cntxt = document.getElementsByClassName(\"model3D\")[0].getElementsByTagName(\"canvas\")[0].getContext(\"webgl2\");
|
378 |
this.innerText = cntxt;
|
379 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot = true;
|
380 |
+
|
381 |
+
BABYLON.Engine.LastCreatedScene.getEngine().onEndFrameObservable.add(function() {
|
382 |
+
if (BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot === true) {
|
383 |
+
BABYLON.Engine.LastCreatedScene.activeCamera.metadata.screenshot = false;
|
384 |
+
try {
|
385 |
+
BABYLON.Tools.CreateScreenshotUsingRenderTarget(BABYLON.Engine.LastCreatedScene.getEngine(), BABYLON.Engine.LastCreatedScene.activeCamera, { width: 310 }, (durl) => { document.getElementById(\"img_out\").src = durl; });
|
386 |
+
} catch(e) { alert(e); }
|
387 |
+
// https://forum.babylonjs.com/t/best-way-to-save-to-jpeg-snapshots-of-scene/17663/11
|
388 |
+
}
|
389 |
+
});
|
390 |
'/>webgl2</a><br/><img src='' id='img_out'/>""")
|
391 |
render = gr.Button("Render")
|
392 |
|