JSAPI Three API Reference
    正在准备搜索索引...

    类 Polygon

    填充多边形(不含描边),可沿Z轴拉伸高度成多边形柱状体

    支持以下功能:

    • 基础多边形填充渲染
    • Z轴拉伸创建3D柱状体
    • 贴地渲染(Ground Primitive)
    • 纹理贴图支持
    • 顶点颜色和高度配置
    // 创建基础多边形
    const polygon = engine.add(new mapvthree.Polygon({
    vertexColors: true,
    extrude: true,
    extrudeValue: 100,
    }));

    // 设置数据源
    let data = mapvthree.GeoJSONDataSource.fromGeoJSON(data);
    data.defineAttribute('color', 'color');
    polygon.dataSource = data;
    // 创建贴地多边形
    const groundPolygon = engine.add(new mapvthree.Polygon({
    isGroundPrimitive: true,
    color: 'rgba(255, 0, 0, 0.5)',
    opacity: 0.8
    }));

    层级

    • GeoMesh
      • Polygon
    索引

    构造函数

    • 创建多边形渲染对象

      参数

      • parameters: {
            border?: boolean;
            borderColor?: string;
            borderOpacity?: number;
            borderWidth?: number;
            clampToGround?: boolean;
            color?: string;
            emissive?: string;
            enableBottomFace?: boolean;
            excludeElements?: any[];
            extrude?: boolean;
            extrudeValue?: number;
            groundTargets?: any[];
            isDynamic?: boolean;
            isGroundPrimitive?: boolean;
            mapScale?: number;
            mapSrc?: string;
            nearScale?: number;
            normalOffset?: number;
            opacity?: number;
            perPositionHeight?: boolean;
            renderOrder?: number;
            vertexColors?: boolean;
            vertexHeights?: boolean;
            zOffset?: number;
        } = {}

        传入参数对象

        • 可选border?: boolean

          是否显示边框

        • 可选borderColor?: string

          边框颜色

        • 可选borderOpacity?: number

          边框透明度

        • 可选borderWidth?: number

          边框线宽(像素)

        • 可选clampToGround?: boolean

          是否贴合三维实体表面

        • 可选color?: string

          填充颜色

        • 可选emissive?: string

          自发光颜色

        • 可选enableBottomFace?: boolean

          是否封闭底面

        • 可选excludeElements?: any[]

          排除的元素列表

        • 可选extrude?: boolean

          是否拉伸,默认否

        • 可选extrudeValue?: number

          拉伸高度,默认100

        • 可选groundTargets?: any[]

          接收对象根节点;省略时自动发现,空数组表示不接收

        • 可选isDynamic?: boolean

          是否需要动态调整数据源,贴地时使用

        • 可选isGroundPrimitive?: boolean

          是否为贴地渲染

        • 可选mapScale?: number

          贴图的缩放大小,仅在使用纹理贴图时有效,默认1

        • 可选mapSrc?: string

          纹理贴图,默认''

        • 可选nearScale?: number

          深度图near值缩放系数

        • 可选normalOffset?: number

          沿法线方向抬升

        • 可选opacity?: number

          整体透明度系数,默认1

        • 可选perPositionHeight?: boolean

          使用顶点高度,若不指定,则即使设置了高度也当0处理, 默认为true

        • 可选renderOrder?: number

          渲染顺序

        • 可选vertexColors?: boolean

          是否通过数据携带颜色配置,默认否

        • 可选vertexHeights?: boolean

          是否通过数据携带高度配置,默认否

        • 可选zOffset?: number

          整体高度抬升

      返回 Polygon

      const polygon = new mapvthree.Polygon({
      extrude: true,
      extrudeValue: 150,
      color: 'rgba(255, 0, 0, 0.8)',
      vertexColors: true,
      opacity: 0.9
      });

    属性

    color: string

    填充颜色

    polygon.color = 'rgba(255, 0, 0, 0.8)';
    
    emissive: string

    自发光颜色

    polygon.emissive = 'rgba(0, 255, 0, 0.5)';
    
    extrude: boolean

    是否拉伸多边形

    polygon.extrude = true;
    
    extrudeValue: number

    拉伸高度值

    polygon.extrudeValue = 200;
    
    isEventEntitySupported: boolean = true

    是否支持返回的事件参数中携带entity实体数据

    isGeoObject: true

    类型为GeoObject的标识

    isMesh: true

    类型为Mesh的标识

    mapScale: number

    贴图的缩放大小,仅在使用纹理贴图时有效

    polygon.mapScale = 2.0;
    
    opacity: number

    整体透明度系数

    polygon.opacity = 0.7;
    
    vertexColors: boolean

    是否通过数据携带颜色配置

    polygon.vertexColors = true;
    

    方法

    • 添加属性重命名

      参数

      • key: string

        原始属性名,该组件的属性名

      • value: string

        重命名后的属性名,数据源的属性名

      返回 void

    • 清空属性重命名

      返回 void

    • 释放资源

      返回 void

    • 视锥剔除测试。

      three r18x 起 WebGLRenderer 把剔除判断从 frustum.intersectsObject(object) 改成了 object.intersectsFrustum(frustum),而 Object3D 的基类实现是空函数(返回 undefined)。 本类只是打了 isMesh 标记、并不继承 three 的 Mesh,所以必须自己实现, 否则在新版 three 下会被判定为「不在视锥内」而永远不渲染。 行为与 three 的 Mesh.intersectsFrustum 一致;Frustum.intersectsObject 在 0.179 与 0.186 中都存在,所以这份实现对两个版本都安全。

      参数

      • frustum: Frustum

        视锥

      返回 boolean

      是否与视锥相交

    • An optional callback that is executed immediately before a 3D object is rendered.

      参数

      • renderer: any
      • scene: any
      • camera: any

      返回 void

      This function is called with the following parameters: renderer, scene, camera, geometry, material, group. Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which define their visual appearance with geometries and materials like instances of Mesh, Line, Points or Sprite. Instances of Object3D, Group or Bone are not renderable and thus this callback is not executed for such objects.

    • 移除属性重命名

      参数

      • key: string

        原始属性名

      返回 void

    访问器

    • get border(): boolean

      是否显示边框

      返回 boolean

    • get borderColor(): string

      边框颜色

      返回 string

    • get borderOpacity(): number

      边框透明度

      返回 number

    • get borderWidth(): number

      边框线宽(像素)

      返回 number

    • get clampToGround(): boolean

      Only move the anchor; flat, rotation and pixel offsets keep their original semantics.

      返回 boolean

    • get dataSource(): DataSource

      对象连接的 DataSource 数据源。

      返回 DataSource

    • set dataSource(dataSource: DataSource): void

      设置object的数据源

      参数

      • dataSource: DataSource

        数据源

      返回 void

    • get mapSrc(): string

      纹理贴图图片路径

      返回 string

      polygon.mapSrc = 'textures/ground.jpg';
      
    • set mapSrc(value: string): void

      设置纹理贴图路径

      参数

      • value: string

        纹理贴图路径

      返回 void

    • get nearScale(): number

      控制near的值,默认5,在一些对深度要求比较高的场景需要调整near的值

      返回 number

      polygon.nearScale = 10; // 提高深度精度
      
    • set nearScale(value: number): void

      设置near缩放值

      参数

      • value: number

        near缩放值

      返回 void

    • get needsUpdate(): boolean

      是否需要更新

      返回 boolean

    • set needsUpdate(value: boolean): void

      设置object是否在下一帧更新

      参数

      • value: boolean

        设置为true,则下一帧渲染前更新该object

      返回 void