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.

main.js 1.5KB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Import modules
  2. requirejs(["anders_briegel", "three", "orbitcontrols", "graph"], init);
  3. var controls, renderer, raycaster, scene, selection, camera;
  4. // Clear the whole scene
  5. function makeScene() {
  6. var myScene = new THREE.Scene();
  7. var grid = new THREE.GridHelper(10, 1);
  8. grid.rotation.x = Math.PI / 2;
  9. grid.setColors(0xdddddd, 0xeeeeee);
  10. myScene.add(grid);
  11. return myScene;
  12. }
  13. // Render the current frame to the screen
  14. function render() {
  15. requestAnimationFrame(function() {
  16. renderer.render(scene, camera);
  17. });
  18. }
  19. // Someone resized the window
  20. function onWindowResize(evt) {
  21. camera.aspect = window.innerWidth / window.innerHeight;
  22. camera.updateProjectionMatrix();
  23. renderer.setSize(window.innerWidth, window.innerHeight);
  24. render();
  25. }
  26. function constructDisplay(){
  27. // Renderer
  28. renderer = new THREE.WebGLRenderer();
  29. renderer.setSize(window.innerWidth, window.innerHeight);
  30. renderer.setClearColor(0xffffff, 1);
  31. document.querySelector("body").appendChild(renderer.domElement);
  32. window.addEventListener("resize", onWindowResize, false);
  33. // Camera, controls, raycaster
  34. camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.3, 1000);
  35. controls = new THREE.OrbitControls(camera);
  36. controls.center.set(0, 0, 0);
  37. controls.rotateSpeed = 0.2;
  38. camera.position.set(0, 0, 20);
  39. controls.addEventListener("change", render);
  40. }
  41. // Called on startup
  42. function init() {
  43. constructDisplay();
  44. scene = makeScene();
  45. connectToServer();
  46. render();
  47. }