Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="three.min.js"></script>
- </head>
- <body>
- <script>
- var width = window.innerWidth;
- var height = window.innerHeight;
- var camera = new THREE.PerspectiveCamera(90, width/height);
- camera.position.z = 200;
- var scene = new THREE.Scene;
- scene.add(camera);
- var geometry = new THREE.BufferGeometry;
- var numVertices = 4;
- var numSegments = numVertices - 1;
- geometry.attributes = {
- position: {
- itemSize: 3,
- array: new Float32Array(numVertices * 3),
- numItems: numVertices * 3
- },
- color: {
- itemSize: 3,
- array: new Float32Array(numVertices * 3),
- numItems: numVertices * 3
- }
- };
- var colors = geometry.attributes.color.array;
- var positions = geometry.attributes.position.array;
- positions[0 + 0] = 5;
- positions[0 + 1] = 5;
- positions[0 + 2] = 5;
- positions[3 + 0] = 100;
- positions[3 + 1] = 20;
- positions[3 + 2] = 60;
- positions[6 + 0] = 100;
- positions[6 + 1] = 50;
- positions[6 + 2] = 60;
- positions[9 + 0] = 50;
- positions[9 + 1] = 50;
- positions[9 + 2] = 50;
- for (var i = 0; i < numVertices; ++i) {
- colors[3 * i + 0] = 0xFF;
- colors[3 * i + 1] = 0;
- colors[3 * i + 2] = 0;
- }
- var material = new THREE.LineBasicMaterial({
- linewidth: 19,
- color: new THREE.Color(0xff0000)
- });
- var line = new THREE.Line(geometry, material);
- scene.add(line);
- var renderer = new THREE.WebGLRenderer({antialias: true});
- renderer.setSize(width, height);
- document.body.appendChild(renderer.domElement);
- renderer.render(scene, camera);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement