Threejs绘制多边形

Threejs绘制多边形,使用THREE.Shape()

function createPolygon(){
    var group = new THREE.Group();

    var rectLength = 120, rectWidth = 40;

    var rectShape = new THREE.Shape();
    rectShape.moveTo( 10, 10 ,0);
    rectShape.lineTo( 10, 20,0 );
    rectShape.lineTo( 15, 25,0 );
    rectShape.lineTo( 20,25, 0 );
    rectShape.lineTo( 30, 20,0 );
    rectShape.lineTo( 30, 10,0 );
    rectShape.lineTo( 10, 10,0 );
    var geometry2 = new THREE.ShapeGeometry( rectShape);
    var material2 = new THREE.MeshBasicMaterial( { color: 0xff0000, side: THREE.DoubleSide } );
    var mesh2 = new THREE.Mesh( geometry2, material2 ) ;
    group.add(mesh2);

    return group;
}

 

 

 

########################

posted @ 2021-11-17 08:06  西北逍遥  阅读(1186)  评论(0编辑  收藏  举报