Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. <script>
  2.  
  3. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  4.  
  5. var camera, scene, renderer;
  6. var geometry, material, mesh;
  7.  
  8. function setup() {
  9.  
  10. var W = window.innerWidth, H = window.innerHeight;
  11. renderer = new THREE.WebGLRenderer();
  12. renderer.setSize( W, H );
  13. document.body.appendChild( renderer.domElement );
  14.  
  15. camera = new THREE.PerspectiveCamera( 50, W/H, 1, 10000 );
  16. camera.position.z = 500;
  17.  
  18. scene = new THREE.Scene();
  19.  
  20.  
  21. var points = [
  22. new THREE.Vector3( -97.58, -73.38, 81 ),
  23. new THREE.Vector3( -28.27, -65.89, 91.31 ),
  24. new THREE.Vector3( 91.44, -66.84, 37.61 ),
  25. new THREE.Vector3( 54.28, 14.81, 69.45 ),
  26. new THREE.Vector3( 15.13, 73.21, 28.95 ),
  27. new THREE.Vector3( -78.62, -31.83, -20.6 ),
  28. new THREE.Vector3( 62.57, -32.77, -12.54 ),
  29. new THREE.Vector3( 25.54, 63.98, -0.82 ),
  30. ];
  31.  
  32. geometry = new THREE.ConvexGeometry( points );
  33. material = new THREE.MeshLambertMaterial({shading: THREE.FlatShading, color: 0x6e6e6e});
  34. mesh = new THREE.Mesh(geometry, material);
  35. mesh.scale.x = mesh.scale.y = mesh.scale.z = 2;
  36. scene.add(mesh);
  37.  
  38. bg = document.body.style;
  39. bg.background = '#ffffff';
  40.  
  41. ambientLight = new THREE.AmbientLight( 0x000000 );
  42. scene.add( ambientLight );
  43.  
  44. hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x000000, 0.2);
  45. scene.add( hemisphereLight );
  46.  
  47. directionalLight = new THREE.DirectionalLight(0xffffff, 0.1);
  48. directionalLight.position.set( 0, 1, 0 );
  49. directionalLight.castShadow = true;
  50. scene.add( directionalLight );
  51.  
  52. spotLight1 = new THREE.SpotLight( 0xffffff, 0.1 );
  53. spotLight1.position.set( 100, 1000, 100 );
  54. spotLight1.castShadow = true;
  55. spotLight1.shadowDarkness = 0.2;
  56. scene.add( spotLight1 );
  57.  
  58. spotLight2 = new THREE.SpotLight( 0xffffff, 0.1 );
  59. spotLight2.position.set( 100, 1000, 100 );
  60. spotLight2.castShadow = true;
  61. spotLight2.shadowDarkness = 0.2;
  62. scene.add( spotLight2 );
  63.  
  64.  
  65.  
  66. }
  67.  
  68. function draw() {
  69.  
  70. requestAnimationFrame( draw );
  71.  
  72. mesh.rotation.x = Date.now() * 0.0005;
  73. mesh.rotation.y = Date.now() * 0.0002;
  74. mesh.rotation.z = Date.now() * 0.0001;
  75.  
  76. renderer.render( scene, camera );
  77.  
  78. }
  79.  
  80. setup();
  81. draw();
  82.  
  83. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement