freealise commited on
Commit
812116a
1 Parent(s): ef8a9b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -621,9 +621,13 @@ 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
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = (event.clientX-this.getBoundingClientRect().x-parseInt(this.style.width)/2) * Math.cos(-angle);
626
- BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = (event.clientY-this.getBoundingClientRect().y-parseInt(this.style.height)/2) * Math.sin(-angle);
 
 
 
 
627
  }
628
  } catch(e) {alert(e)}
629
  ' onkeydown='
 
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);
628
+ const r = Math.sqrt(Math.pow(y,2) + Math.pow(x,2));
629
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.z = r * Math.cos(angle_-angle);
630
+ BABYLON.Engine.LastCreatedScene.getNodes()[parseInt(document.getElementById(\"fnum\").getElementsByTagName(\"input\")[0].value)+1].position.x = r * Math.sin(angle_-angle);
631
  }
632
  } catch(e) {alert(e)}
633
  ' onkeydown='