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.

83 lignes
1.8KB

  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. var grid1 = makeGrid(10, 10, "lightgray");
  14. grid1.position.z = -5;
  15. myScene.add(grid1);
  16. var grid2 = makeGrid(10, 10, "lightgray");
  17. grid2.rotation.x = Math.PI/2;
  18. grid2.position.y = -5;
  19. myScene.add(grid2);
  20. var grid3 = makeGrid(10, 10, "lightgray");
  21. grid3.rotation.y = Math.PI/2;
  22. grid3.position.x = -5;
  23. myScene.add(grid3);
  24. return myScene;
  25. }
  26. // Render the current frame to the screen
  27. function render() {
  28. renderer.render(scene, camera);
  29. }
  30. // This is the main control loop
  31. function loopForever() {
  32. controls.update();
  33. requestAnimationFrame(loopForever);
  34. }
  35. // This just organises kickoff
  36. function startMainLoop() {
  37. scene = makeScene();
  38. controls.addEventListener("change", render);
  39. poll();
  40. loopForever();
  41. }
  42. // Called on startup
  43. function init() {
  44. // Measure things, get references
  45. var width = window.innerWidth;
  46. var height = window.innerHeight;
  47. // Renderer
  48. renderer = new THREE.WebGLRenderer({"antialias":true});
  49. renderer.setSize(width, height);
  50. renderer.setClearColor(0xffffff, 1);
  51. document.querySelector("body").appendChild(renderer.domElement);
  52. // Time to load the materials
  53. loadMaterials();
  54. // Camera, controls, raycaster
  55. camera = new THREE.PerspectiveCamera(45, width / height, 0.3, 100);
  56. controls = new THREE.OrbitControls(camera);
  57. // Center the camera
  58. controls.center.set(0, 0, 0);
  59. controls.rotateSpeed = 0.2;
  60. camera.position.set(0, 0, 20);
  61. // Start polling
  62. setInterval(poll, 1000);
  63. // Run
  64. startMainLoop();
  65. }