freealise commited on
Commit
6874d0a
·
verified ·
1 Parent(s): f3e3fe5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -559,7 +559,7 @@ def draw_mask(o, b, v, d, evt: gr.EventData):
559
  return gr.ImageEditor(value=d)
560
 
561
 
562
- load_model="""
563
  async(c, o, p, d, n, m, s)=>{
564
  var intv = setInterval(function(){
565
  if (document.getElementById("model3D").getElementsByTagName("canvas")[0]) {
@@ -571,13 +571,15 @@ async(c, o, p, d, n, m, s)=>{
571
  var now, delta;
572
  const interval = 1000 / 25;
573
  const tolerance = 0.1;
 
 
574
  BABYLON.Engine.LastCreatedScene.getEngine().stopRenderLoop();
575
  BABYLON.Engine.LastCreatedScene.getEngine().runRenderLoop(function () {
576
  now = new Date().getTime();
577
  delta = now - then;
578
  then = now - (delta % interval);
579
  if (delta >= interval - tolerance) {
580
- BABYLON.Engine.LastCreatedScene.activeCamera.target = BABYLON.Engine.LastCreatedScene.activeCamera.getDirection(BABYLON.Engine.LastCreatedScene.activeCamera.rotation);
581
  BABYLON.Engine.LastCreatedScene.render();
582
  }
583
  });
@@ -787,7 +789,8 @@ async(c, o, p, d, n, m, s)=>{
787
  }
788
  var code = document.getElementsByTagName('script');
789
  for (var i=0; i<code.length; i++) {
790
- alert(code[i].innerText);
 
791
  }
792
 
793
  clearInterval(intv);
@@ -796,7 +799,7 @@ async(c, o, p, d, n, m, s)=>{
796
  }
797
  }, 40);
798
  }
799
- """
800
 
801
  js = """
802
  async()=>{
@@ -1256,8 +1259,8 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
1256
 
1257
  with gr.Group():
1258
  camera = gr.HTML(value="""<div style='width:128px;height:128px;border:1px dotted gray;padding:0;margin:0;float:left;clear:none;' id='seek'></div>
1259
- <span style='max-width:50%;float:right;clear:none;'>
1260
- <a href='#' id='reset_cam' style='text-align:right;float:right;clear:none;color:white' onclick='
1261
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
1262
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
1263
  screenshot: true,
@@ -1294,9 +1297,9 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
1294
  evt.initEvent(\"click\", true, false);
1295
  document.getElementById(\"reset_cam\").dispatchEvent(evt);
1296
  }
1297
- BABYLON.Engine.LastCreatedScene.activeCamera.rotation.x = this.value;
1298
- BABYLON.Engine.LastCreatedScene.activeCamera.target = BABYLON.Engine.LastCreatedScene.activeCamera.getDirection(BABYLON.Engine.LastCreatedScene.activeCamera.rotation);
1299
- this.parentNode.childNodes[2].innerText = BABYLON.Engine.LastCreatedScene.activeCamera.rotation.x;
1300
  '/> <span>0.0</span><br/>
1301
  <label for='contrast' style='width:8em'>Contrast</label><input id='contrast' type='range' style='width:128px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
1302
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
 
559
  return gr.ImageEditor(value=d)
560
 
561
 
562
+ load_model="""//Code
563
  async(c, o, p, d, n, m, s)=>{
564
  var intv = setInterval(function(){
565
  if (document.getElementById("model3D").getElementsByTagName("canvas")[0]) {
 
571
  var now, delta;
572
  const interval = 1000 / 25;
573
  const tolerance = 0.1;
574
+ window.parallax = new BABYLON.Vector3(0, 0, 0);
575
+
576
  BABYLON.Engine.LastCreatedScene.getEngine().stopRenderLoop();
577
  BABYLON.Engine.LastCreatedScene.getEngine().runRenderLoop(function () {
578
  now = new Date().getTime();
579
  delta = now - then;
580
  then = now - (delta % interval);
581
  if (delta >= interval - tolerance) {
582
+ BABYLON.Engine.LastCreatedScene.activeCamera.target = BABYLON.Engine.LastCreatedScene.activeCamera.getDirection(parallax);
583
  BABYLON.Engine.LastCreatedScene.render();
584
  }
585
  });
 
789
  }
790
  var code = document.getElementsByTagName('script');
791
  for (var i=0; i<code.length; i++) {
792
+ var cd = code[i].innerText.split('//Code');
793
+ if (cd.length>1) {alert(cd[1]);}
794
  }
795
 
796
  clearInterval(intv);
 
799
  }
800
  }, 40);
801
  }
802
+ //Code"""
803
 
804
  js = """
805
  async()=>{
 
1259
 
1260
  with gr.Group():
1261
  camera = gr.HTML(value="""<div style='width:128px;height:128px;border:1px dotted gray;padding:0;margin:0;float:left;clear:none;' id='seek'></div>
1262
+ <span style='max-width:50%;float:right;clear:none;text-align:right;'>
1263
+ <a href='#' id='reset_cam' style='float:right;clear:none;color:white' onclick='
1264
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
1265
  BABYLON.Engine.LastCreatedScene.activeCamera.metadata = {
1266
  screenshot: true,
 
1297
  evt.initEvent(\"click\", true, false);
1298
  document.getElementById(\"reset_cam\").dispatchEvent(evt);
1299
  }
1300
+ parallax.x = this.value;
1301
+ BABYLON.Engine.LastCreatedScene.activeCamera.target = BABYLON.Engine.LastCreatedScene.activeCamera.getDirection(parallax);
1302
+ this.parentNode.childNodes[2].innerText = parallax.x;
1303
  '/> <span>0.0</span><br/>
1304
  <label for='contrast' style='width:8em'>Contrast</label><input id='contrast' type='range' style='width:128px;height:1em;' value='1.0' min='0' max='2' step='0.001' oninput='
1305
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {