Advertisement
Guest User

Untitled

a guest
Feb 1st, 2013
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3.     <script src="three.min.js"></script>
  4. </head>
  5. <body>
  6.     <script>
  7.     var width = window.innerWidth;
  8.     var height = window.innerHeight;
  9.     var camera = new THREE.PerspectiveCamera(90, width/height);
  10.     camera.position.z = 200;
  11.  
  12.     var scene = new THREE.Scene;
  13.     scene.add(camera);
  14.  
  15.     var geometry = new THREE.BufferGeometry;
  16.     var numVertices = 4;
  17.     var numSegments = numVertices - 1;
  18.     geometry.attributes = {
  19.         position: {
  20.             itemSize: 3,
  21.             array: new Float32Array(numVertices * 3),
  22.             numItems: numVertices * 3
  23.         },
  24.         color: {
  25.             itemSize: 3,
  26.             array: new Float32Array(numVertices * 3),
  27.             numItems: numVertices * 3
  28.         }
  29.     };
  30.  
  31.     var colors = geometry.attributes.color.array;
  32.     var positions = geometry.attributes.position.array;
  33.  
  34.     positions[0 + 0] = 5;
  35.     positions[0 + 1] = 5;
  36.     positions[0 + 2] = 5;
  37.  
  38.     positions[3 + 0] = 100;
  39.     positions[3 + 1] = 20;
  40.     positions[3 + 2] = 60;
  41.  
  42.     positions[6 + 0] = 100;
  43.     positions[6 + 1] = 50;
  44.     positions[6 + 2] = 60;
  45.  
  46.     positions[9 + 0] = 50;
  47.     positions[9 + 1] = 50;
  48.     positions[9 + 2] = 50;
  49.  
  50.     for (var i = 0; i < numVertices; ++i) {
  51.         colors[3 * i + 0] = 0xFF;
  52.         colors[3 * i + 1] = 0;
  53.         colors[3 * i + 2] = 0;
  54.     }
  55.  
  56.     var material = new THREE.LineBasicMaterial({
  57.         linewidth: 19,
  58.         color: new THREE.Color(0xff0000)
  59.     });
  60.  
  61.     var line = new THREE.Line(geometry, material);
  62.  
  63.     scene.add(line);
  64.  
  65.     var renderer = new THREE.WebGLRenderer({antialias: true});
  66.     renderer.setSize(width, height);
  67.     document.body.appendChild(renderer.domElement);
  68.  
  69.     renderer.render(scene, camera);
  70.     </script>
  71. </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement