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.

71 lines
1.5KB

  1. // IE9
  2. if (typeof console === "undefined") {
  3. var console = {
  4. log: function(logMsg) {}
  5. };
  6. }
  7. var controls, renderer, raycaster, scene, selection, camera;
  8. // Run on startup
  9. window.onload = init;
  10. // Clear the whole scene
  11. function makeScene() {
  12. var myScene = new THREE.Scene();
  13. myScene.add(makeGrid(10, 10, "lightgray"));
  14. return myScene;
  15. }
  16. // Render the current frame to the screen
  17. function render() {
  18. renderer.render(scene, camera);
  19. }
  20. // This is the main control loop
  21. function loopForever() {
  22. controls.update();
  23. requestAnimationFrame(loopForever);
  24. }
  25. // This just organises kickoff
  26. function startMainLoop() {
  27. scene = makeScene();
  28. controls.addEventListener("change", render);
  29. loopForever();
  30. }
  31. // Called on startup
  32. function init() {
  33. // Measure things, get references
  34. var width = window.innerWidth;
  35. var height = window.innerHeight;
  36. // Renderer
  37. renderer = new THREE.WebGLRenderer();
  38. renderer.setSize(width, height);
  39. renderer.setClearColor(0xffffff, 1);
  40. document.querySelector("body").appendChild(renderer.domElement);
  41. // Time to load the materials
  42. loadMaterials();
  43. // Camera, controls, raycaster
  44. camera = new THREE.PerspectiveCamera(45, width / height, 0.3, 100);
  45. controls = new THREE.OrbitControls(camera);
  46. // Center the camera
  47. controls.center.set(0, 0, 0);
  48. controls.rotateSpeed = 0.2;
  49. camera.position.set(0, 0, 20);
  50. // Start polling
  51. setInterval(poll, 1000);
  52. // Run
  53. startMainLoop();
  54. }