threejs绘制多边形
// 创建一个立方体几何体 var cubeGeometry = new THREE.BoxGeometry( 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ); // 创建一个多边形几何体 var polygonGeometry = new THREE.Geometry(); // 创建多边形的顶点数组 var vertices = [ new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0.5, 0, 0 ), new THREE.Vector3( 0.5, 0.5, 0 ), new THREE.Vector3( 0, 0.5, 0 ), new THREE.Vector3( 0.5, 0.5, 0 ), new THREE.Vector3( 0.5, 0.5, 0 ), new THREE.Vector3( 0, 0, 0 ) ]; // 将顶点数组转换为多边形几何体的顶点 var polygon = new THREE.Vector3(); for (var i = 0; i < vertices.length; i++) { polygon.add(vertices[i]); } polygonGeometry.vertices = vertices; // 将多边形几何体添加到场景中 var material = new THREE.MeshBasicMaterial({ color: 0xffffff }); var mesh = new THREE.Mesh(geometry, material); scene.add(mesh);
####################
标签:threejs,多边形,Vector3,0.5,THREE,几何体,var,new From: https://www.cnblogs.com/herd/p/17349900.html