Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0KB

  1. var gui = {};
  2. gui.construct = 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.rotateSpeed = 0.2;
  16. gui.camera.position.set(0, 0, 20);
  17. };
  18. // Someone resized the window
  19. gui.onWindowResize = function(evt) {
  20. console.log(gui);
  21. gui.camera.aspect = window.innerWidth / window.innerHeight;
  22. gui.camera.updateProjectionMatrix();
  23. gui.renderer.setSize(window.innerWidth, window.innerHeight);
  24. gui.render();
  25. };
  26. // Render the current frame to the screen
  27. gui.render = function() {
  28. requestAnimationFrame(function() {
  29. gui.renderer.render(gui.scene, gui.camera);
  30. });
  31. };
  32. // Make the extra bits of gui
  33. gui.makeScene = function() {
  34. gui.scene = new THREE.Scene();
  35. var grid = new THREE.GridHelper(10, 1);
  36. grid.rotation.x = Math.PI / 2;
  37. grid.setColors(0xdddddd, 0xeeeeee);
  38. gui.scene.add(grid);
  39. };
  40. // Put an HTML message to the screen
  41. gui.serverMessage = function(msgtext) {
  42. message.innerHTML = msgtext;
  43. message.className = "visible";
  44. };
  45. gui.loop = function() {
  46. gui.controls.update();
  47. requestAnimationFrame(gui.loop);
  48. }
  49. // Try to add a qubit at the current mouse position
  50. gui.addQubitAtMouse = function(event) {
  51. this.raycaster.setFromCamera(mouse, camera);
  52. var intersection = this.raycaster.ray.intersectPlane(this.plane);
  53. intersection.x = Math.round(intersection.x);
  54. intersection.y = Math.round(intersection.y);
  55. abj.add_node(Object.keys(vops).length, {
  56. "position": intersection
  57. });
  58. graph.updateScene();
  59. }