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.

92 lignes
2.1KB

  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. // Someone resized the window
  43. function onWindowResize(evt){
  44. camera.aspect = window.innerWidth / window.innerHeight;
  45. camera.updateProjectionMatrix();
  46. renderer.setSize(window.innerWidth, window.innerHeight);
  47. render();
  48. }
  49. // Called on startup
  50. function init() {
  51. // Measure things, get references
  52. var width = window.innerWidth;
  53. var height = window.innerHeight;
  54. // Renderer
  55. renderer = new THREE.WebGLRenderer({"antialias":true});
  56. renderer.setSize(width, height);
  57. renderer.setClearColor(0xffffff, 1);
  58. document.querySelector("body").appendChild(renderer.domElement);
  59. window.addEventListener("resize", onWindowResize, false);
  60. // Time to load the materials
  61. loadMaterials();
  62. // Camera, controls, raycaster
  63. camera = new THREE.PerspectiveCamera(45, width / height, 0.3, 100);
  64. controls = new THREE.OrbitControls(camera);
  65. // Center the camera
  66. controls.center.set(0, 0, 0);
  67. controls.rotateSpeed = 0.2;
  68. camera.position.set(0, 0, 20);
  69. // Start polling
  70. setInterval(poll, 1000);
  71. // Run
  72. startMainLoop();
  73. }