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.

25 lines
771 B

4 years ago
  1. import * as THREE from 'three';
  2. var renderer = new THREE.WebGLRenderer();
  3. renderer.setSize( window.innerWidth, window.innerHeight );
  4. document.body.appendChild( renderer.domElement );
  5. var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 );
  6. camera.position.set( 0, 0, 100 );
  7. camera.lookAt( 0, 0, 0 );
  8. var scene = new THREE.Scene();
  9. var material = new THREE.LineBasicMaterial( { color: 0x0000ff } );
  10. var points = [];
  11. points.push( new THREE.Vector3( - 10, 0, 0 ) );
  12. points.push( new THREE.Vector3( 0, 10, 0 ) );
  13. points.push( new THREE.Vector3( 10, 0, 0 ) );
  14. var geometry = new THREE.BufferGeometry().setFromPoints( points );
  15. var line = new THREE.Line( geometry, material );
  16. scene.add( line );
  17. renderer.render( scene, camera );