Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

94 lignes
2.7KB

  1. var gui = {};
  2. gui.prepare = function() {
  3. gui.renderer = new THREE.WebGLRenderer({
  4. "antialias": true
  5. });
  6. gui.renderer.setSize(window.innerWidth, window.innerHeight);
  7. gui.renderer.setClearColor(0xffffff, 1);
  8. document.querySelector("body").appendChild(gui.renderer.domElement);
  9. window.addEventListener("resize", gui.onWindowResize, false);
  10. gui.makeScene();
  11. gui.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.3, 1000);
  12. gui.controls = new THREE.OrbitControls(gui.camera);
  13. gui.controls.addEventListener("change", gui.render);
  14. gui.controls.center.set(0, 0, 0);
  15. gui.controls.target.set(0, 0, 0);
  16. gui.controls.rotateSpeed = 0.2;
  17. gui.controls.userPanSpeed = 0.1;
  18. gui.camera.position.set(0, 0, 10);
  19. };
  20. // Someone resized the window
  21. gui.onWindowResize = function(evt) {
  22. console.log(gui);
  23. gui.camera.aspect = window.innerWidth / window.innerHeight;
  24. gui.camera.updateProjectionMatrix();
  25. gui.renderer.setSize(window.innerWidth, window.innerHeight);
  26. gui.render();
  27. };
  28. // Render the current frame to the screen
  29. gui.render = function() {
  30. requestAnimationFrame(function() {
  31. gui.renderer.render(gui.scene, gui.camera);
  32. });
  33. };
  34. // Make the extra bits of gui
  35. gui.makeScene = function() {
  36. gui.scene = new THREE.Scene();
  37. var grid = new THREE.GridHelper(10, 1);
  38. grid.rotation.x = Math.PI / 2;
  39. grid.setColors(0xdddddd, 0xeeeeee);
  40. gui.scene.add(grid);
  41. };
  42. // Put an HTML message to the screen
  43. gui.serverMessage = function(msgtext) {
  44. if (msgtext) {
  45. server_info.innerHTML = msgtext;
  46. server_info.className = "visible";
  47. } else {
  48. server_info.innerHTML = "";
  49. server_info.className = "hidden";
  50. }
  51. };
  52. gui.nodeMessage = function(msgtext) {
  53. node_info.innerHTML = msgtext;
  54. node_info.className = "visible";
  55. };
  56. gui.hideNodeMessage = function(){
  57. node_info.className = "hidden";
  58. };
  59. // Set the position of the info popup
  60. gui.setInfoPosition = function(position){
  61. w = node_info.offsetWidth;
  62. h = node_info.offsetHeight;
  63. node_info.style.left = position.x - w/2 + "px";
  64. node_info.style.top = position.y - h -10 + "px";
  65. };
  66. // The main loop
  67. gui.loop = function() {
  68. gui.controls.update();
  69. requestAnimationFrame(gui.loop);
  70. };
  71. // Try to add a qubit at the current mouse position
  72. gui.addQubitAtMouse = function(event) {
  73. this.raycaster.setFromCamera(mouse, camera);
  74. var intersection = this.raycaster.ray.intersectPlane(this.plane);
  75. intersection.x = Math.round(intersection.x);
  76. intersection.y = Math.round(intersection.y);
  77. abj.add_node(Object.keys(vops).length, {
  78. "position": intersection
  79. });
  80. graph.update();
  81. };