Anders and Briegel in Python
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

56 wiersze
1.5KB

  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. }