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.

66 lignes
1.6KB

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