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.

43 lines
1.6KB

  1. define(["message"], function() {
  2. return {
  3. construct: function() {
  4. this.renderer = new THREE.WebGLRenderer();
  5. this.renderer.setSize(window.innerWidth, window.innerHeight);
  6. this.renderer.setClearColor(0xffffff, 1);
  7. document.querySelector("body").appendChild(this.renderer.domElement);
  8. window.addEventListener("resize", this.onWindowResize, false);
  9. this.makeScene();
  10. this.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.3, 1000);
  11. this.controls = new THREE.OrbitControls(this.camera);
  12. this.controls.center.set(0, 0, 0);
  13. this.controls.rotateSpeed = 0.2;
  14. this.camera.position.set(0, 0, 20);
  15. this.controls.addEventListener("change", this.render);
  16. },
  17. // Someone resized the window
  18. onWindowResize: function(evt) {
  19. this.camera.aspect = window.innerWidth / window.innerHeight;
  20. this.camera.updateProjectionMatrix();
  21. this.renderer.setSize(window.innerWidth, window.innerHeight);
  22. this.render();
  23. },
  24. // Render the current frame to the screen
  25. render: function() {
  26. this.renderer.render(this.scene, this.camera);
  27. },
  28. // Make the extra bits of gui
  29. makeScene: function() {
  30. this.scene = new THREE.Scene();
  31. var grid = new THREE.GridHelper(10, 1);
  32. grid.rotation.x = Math.PI / 2;
  33. grid.setColors(0xdddddd, 0xeeeeee);
  34. this.scene.add(grid);
  35. }
  36. };
  37. });