freealise commited on
Commit
c3096ba
1 Parent(s): bc3b79c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -606,7 +606,7 @@ with gr.Blocks(css=css) as demo:
606
  with gr.Accordion(label="Blur levels", open=False):
607
  blur_in = gr.Textbox(label="Kernel size", show_label=False, value="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1")
608
  with gr.Accordion(label="Locations", open=False):
609
- offset = gr.HTML(value="""<input type='text' id='kbrd' onpointerdown='this.style.color = \"white\";' onpointerup='this.style.color = \"auto\";' onpointermove='
610
  try {
611
  if (this.style.color!=\"auto\" && BABYLON) {
612
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
@@ -621,7 +621,6 @@ with gr.Blocks(css=css) as demo:
621
  const dir = BABYLON.Engine.LastCreatedScene.activeCamera.getForwardRay().direction;
622
  dir.y = 0; dir.normalize();
623
  const angle = BABYLON.Vector3.GetAngleBetweenVectors(dir, BABYLON.Vector3.Forward(), BABYLON.Vector3.Up());
624
- //alert(angle);
625
  const x = event.clientX-this.getBoundingClientRect().x-64;
626
  const y = event.clientY-this.getBoundingClientRect().y-64;
627
  const angle_ = Math.atan2(y, x);
@@ -641,6 +640,9 @@ with gr.Blocks(css=css) as demo:
641
  if (BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion) {
642
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
643
  }
 
 
 
644
  switch(event.key) {
645
  case \"w\":
646
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y += 1;
@@ -651,19 +653,27 @@ with gr.Blocks(css=css) as demo:
651
  this.value = \"w ⬇ x\";
652
  break;
653
  case \"a\":
654
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z -= 1;
 
 
655
  this.value = \"a ⬅ d\";
656
  break;
657
  case \"d\":
658
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z += 1;
 
 
659
  this.value = \"a ➡ d\";
660
  break;
661
  case \"e\":
662
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x -= 1;
 
 
663
  this.value = \"z ↗ e\";
664
  break;
665
  case \"z\":
666
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x += 1;
 
 
667
  this.value = \"z ↙ e\";
668
  break;
669
  case \"s\":
@@ -736,13 +746,14 @@ with gr.Blocks(css=css) as demo:
736
  this.value = \"\";
737
  }
738
  }
739
- ' style='float:left;height:128px;width:128px;user-select:none;touch-action:none;color:auto;background-color:transparent;border:1px solid gray;'/><pre id='keymap' style='float:right'>
 
740
  ` 1 2 3 4 5 6 7 8 9 0 - =
741
  W E T Y I O { }
742
  A-`S´-D F-`G´-H J-`K´-L ; '
743
  Z´ X̀ V´ B̀ M´ `, . /
744
  <a id='move' href='#'>move</a> <a id='rotate' href='#'>rotate</a> <a id='scale' href='#'>scale</a>
745
- </pre>""")
746
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
747
  output_frame.select(fn=select_frame, inputs=[output_mask], outputs=[output_mask, selected])
748
  example_coords = """[
 
606
  with gr.Accordion(label="Blur levels", open=False):
607
  blur_in = gr.Textbox(label="Kernel size", show_label=False, value="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1")
608
  with gr.Accordion(label="Locations", open=False):
609
+ offset = gr.HTML(value="""<div style='text-align:center;width:100%;'><input type='text' id='kbrd' onpointerdown='this.style.color = \"white\";' onpointerup='this.style.color = \"auto\";' onpointermove='
610
  try {
611
  if (this.style.color!=\"auto\" && BABYLON) {
612
  if (!BABYLON.Engine.LastCreatedScene.activeCamera.metadata) {
 
621
  const dir = BABYLON.Engine.LastCreatedScene.activeCamera.getForwardRay().direction;
622
  dir.y = 0; dir.normalize();
623
  const angle = BABYLON.Vector3.GetAngleBetweenVectors(dir, BABYLON.Vector3.Forward(), BABYLON.Vector3.Up());
 
624
  const x = event.clientX-this.getBoundingClientRect().x-64;
625
  const y = event.clientY-this.getBoundingClientRect().y-64;
626
  const angle_ = Math.atan2(y, x);
 
640
  if (BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion) {
641
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].rotationQuaternion = null;
642
  }
643
+ const dir = BABYLON.Engine.LastCreatedScene.activeCamera.getForwardRay().direction;
644
+ dir.y = 0; dir.normalize();
645
+ const angle = BABYLON.Vector3.GetAngleBetweenVectors(dir, BABYLON.Vector3.Forward(), BABYLON.Vector3.Up());
646
  switch(event.key) {
647
  case \"w\":
648
  BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.y += 1;
 
653
  this.value = \"w ⬇ x\";
654
  break;
655
  case \"a\":
656
+ const x = -1; const y = 0;
657
+ const angle_ = Math.atan2(y, x);
658
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z += Math.sin(-angle_-angle);
659
  this.value = \"a ⬅ d\";
660
  break;
661
  case \"d\":
662
+ const x = 1; const y = 0;
663
+ const angle_ = Math.atan2(y, x);
664
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z += Math.sin(-angle_-angle);
665
  this.value = \"a ➡ d\";
666
  break;
667
  case \"e\":
668
+ const x = 0; const y = -1;
669
+ const angle_ = Math.atan2(y, x);
670
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x += Math.cos(-angle_-angle);
671
  this.value = \"z ↗ e\";
672
  break;
673
  case \"z\":
674
+ const x = 0; const y = 1;
675
+ const angle_ = Math.atan2(y, x);
676
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x += Math.cos(-angle_-angle);
677
  this.value = \"z ↙ e\";
678
  break;
679
  case \"s\":
 
746
  this.value = \"\";
747
  }
748
  }
749
+ ' style='height:128px;width:128px;user-select:none;touch-action:none;color:auto;background-color:transparent;border:1px solid gray;'/>
750
+ <pre id='keymap'>
751
  ` 1 2 3 4 5 6 7 8 9 0 - =
752
  W E T Y I O { }
753
  A-`S´-D F-`G´-H J-`K´-L ; '
754
  Z´ X̀ V´ B̀ M´ `, . /
755
  <a id='move' href='#'>move</a> <a id='rotate' href='#'>rotate</a> <a id='scale' href='#'>scale</a>
756
+ </pre></div>""")
757
  selected = gr.Number(elem_id="fnum", value=0, minimum=0, maximum=256, interactive=False)
758
  output_frame.select(fn=select_frame, inputs=[output_mask], outputs=[output_mask, selected])
759
  example_coords = """[