|
|
@ -2,25 +2,15 @@ import * as THREE from 'three'; |
|
|
|
|
|
|
|
var renderer = new THREE.WebGLRenderer(); |
|
|
|
renderer.setSize( window.innerWidth, window.innerHeight ); |
|
|
|
renderer.setClearColor(0xb9d3ff, 1); //设置背景颜色
|
|
|
|
document.body.appendChild( renderer.domElement ); |
|
|
|
|
|
|
|
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 500 ); |
|
|
|
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 ); |
|
|
|
camera.position.set( 0, 0, 100 ); |
|
|
|
camera.lookAt( 0, 0, 0 ); |
|
|
|
|
|
|
|
var scene = new THREE.Scene(); |
|
|
|
|
|
|
|
var material = new THREE.LineBasicMaterial( { color: 0x0000ff } ); |
|
|
|
|
|
|
|
var points = []; |
|
|
|
points.push( new THREE.Vector3( - 10, 0, 0 ) ); |
|
|
|
points.push( new THREE.Vector3( 0, 10, 0 ) ); |
|
|
|
points.push( new THREE.Vector3( 10, 0, 0 ) ); |
|
|
|
|
|
|
|
var geometry = new THREE.BufferGeometry().setFromPoints( points ); |
|
|
|
|
|
|
|
var line = new THREE.Line( geometry, material ); |
|
|
|
|
|
|
|
|
|
|
|
scene.add( line ); |
|
|
|
renderer.render( scene, camera ); |