创建正方形平面:Shape
var squareShape = new THREE.Shape();
squareShape.moveTo( 0, 0 );
squareShape.lineTo( 0, sqLength );
squareShape.lineTo( sqLength, sqLength );
squareShape.lineTo( sqLength, 0 );
squareShape.lineTo( 0, 0 );
var geometry = new THREE.ShapeBufferGeometry( shape );
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( ) );
创建正方形平面:BufferGeometry 版本
var vertices = new Float32Array( [
// 三角形1 - 三个顶点
-10 ,10, 0,
-10 ,-10, 0,
10 , -10, 0,
// 三角形2 - 三个顶点
10 , -10, 0,
10, 10, 0,
-10 ,10, 0
] );
var geometry = new THREE.BufferGeometry();
//增加坐标点,坐标点是X,Y,Z的布局,可以自己任意设置
geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
//材质
var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
var mesh = new THREE.Mesh( geometry, material );