Polygon
大约 2 分钟
Polygon
Polygon 多边形平面,继承自内置PointsBase对象,拥有一切Thing属性及方法。
构造器
new VT.Polygon({
    // 点位数组 [[x, y, z], [x, y, z]...]
    points: [],
    // 多边形参数
    polygon: {
        // 材质
        material: {    
            // 填充色                
            color: "#708090",
            // 透明度
            opacity: 0.5,
            // 面
            side: 2,
        }
    },
    // 描边参数
    line: {
        // 材质
        material: {                    
            // 是否虚线
            dashed: false,
            // 虚线比例
            dashScale: 1,
            // 虚线大小
            dashSize: 1,
            // 虚线偏移
            dashOffset: 1,
            // 间隔大小
            gapSize: 1,
            // 透明度
            opacity: 1.0,
            // 线宽
            linewidth: 0.01,
            // 是否采用世界单位,如果采用世界单位,linewidth单位为米
            worldUnits: false,
        }
    },
})
属性成员
type
- 类型:
{String}物体类型Polygon, 不可改 
isPolygon
- 类型:
{Boolean}是否为Polygon,不可更改,默认为true 
needPoints
- 类型:
{Boolean}是否需要控制点,不可更改,默认为true 
line
- 类型:
{Line2}Line2对象,Line2 
length
- 类型:
{Number}线长度 
points
- 类型:
{Array}点位数组 
area
- 类型:
{Number}面积 
centeriod
- 类型:
{Array}[x, y] 质心 
方法
updatePolygon
- updatePolygon(polygon)
 - 类型:
{Function} - 参数: 
- polygon 
{Object}多边形参数 
 - polygon 
 - 返回:无
 
{
    // 材质
    material: {    
        // 填充色                
        color: "#708090",
        // 透明度
        opacity: 0.5,
        // 面
        side: 2,
    }
}
updateLine
- updateLine(line)
 - 类型:
{Function} - 参数: 
- line 
{Object}线参数 
 - line 
 - 返回:无
 
{
    // 材质
    material: {                    
        // 是否虚线
        dashed: false,
        // 虚线比例
        dashScale: 1,
        // 虚线大小
        dashSize: 1,
        // 虚线偏移
        dashOffset: 1,
        // 间隔大小
        gapSize: 1,
        // 透明度
        opacity: 1.0,
        // 线宽
        linewidth: 0.01,
        // 是否采用世界单位,如果采用世界单位,linewidth单位为米
        worldUnits: false,
    }
}
updatePoints
更新点位置
- updatePoints(points)
 - 类型:
{Function} - 参数: 
- points 
{Array}点位置 [[x, y, z], [x, y, z]...] 
 - points 
 - 返回:无
 
addPoint
添加点
- addPoint(point)
 - 类型:
{Function} - 参数: 
- point 
{THREE.Vector3 | Array}点位置 
 - point 
 - 返回:无
 
polygon.addPoint([1, 2, 1]);
addPoints
添加点
- addPoints(points)
 - 类型:
{Function} - 参数: 
- points 
{Array}点位置数组 [[x, y, z], [x, y, z]...] 
 - points 
 - 返回:无