Anders and Briegel in Python
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

78 rindas
1.9KB

  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 grid = new THREE.GridHelper(20, 2);
  14. graph = new graph_model();
  15. myScene.add(graph.object);
  16. grid.rotation.x = Math.PI/2;
  17. grid.setColors(0xdddddd, 0xeeeeee);
  18. myScene.add(grid);
  19. return myScene;
  20. }
  21. // Render the current frame to the screen
  22. function render() {
  23. requestAnimationFrame(function () {
  24. renderer.render(scene, camera);
  25. });
  26. }
  27. // Someone resized the window
  28. function onWindowResize(evt){
  29. camera.aspect = window.innerWidth / window.innerHeight;
  30. camera.updateProjectionMatrix();
  31. renderer.setSize(window.innerWidth, window.innerHeight);
  32. render();
  33. }
  34. // Called on startup
  35. function init() {
  36. // Measure things, get references
  37. var width = window.innerWidth;
  38. var height = window.innerHeight;
  39. // Renderer
  40. renderer = new THREE.WebGLRenderer({"antialias":true});
  41. renderer.setSize(width, height);
  42. renderer.setClearColor(0xffffff, 1);
  43. document.querySelector("body").appendChild(renderer.domElement);
  44. window.addEventListener("resize", onWindowResize, false);
  45. renderer.domElement.addEventListener("click", function (evt) {
  46. add_node(0);
  47. });
  48. // Time to load the materials
  49. loadMaterials();
  50. // Camera, controls, raycaster
  51. camera = new THREE.PerspectiveCamera(45, width / height, 0.3, 100);
  52. controls = new THREE.OrbitControls(camera);
  53. // Center the camera
  54. // TODO: frustrum
  55. controls.center.set(0, 0, 0);
  56. controls.rotateSpeed = 0.2;
  57. camera.position.set(0, 0, 40);
  58. // Run
  59. scene = makeScene();
  60. controls.addEventListener("change", render);
  61. connect_to_server();
  62. render();
  63. }