Skip to content

KBE3D / KBCore / Cesium / PolygonGeometry

类: PolygonGeometry

A description of a polygon on the ellipsoid. The polygon is defined by a polygon hierarchy. Polygon geometry can be rendered with both Primitive and GroundPrimitive.

示例

ts
// 1. create a polygon from points
const polygon = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -72.0, 40.0,
      -70.0, 35.0,
      -75.0, 30.0,
      -70.0, 30.0,
      -68.0, 40.0
    ])
  )
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygon);

// 2. create a nested polygon with holes
const polygonWithHole = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -109.0, 30.0,
      -95.0, 30.0,
      -95.0, 40.0,
      -109.0, 40.0
    ]),
    [new Cesium.PolygonHierarchy(
      Cesium.Cartesian3.fromDegreesArray([
        -107.0, 31.0,
        -107.0, 39.0,
        -97.0, 39.0,
        -97.0, 31.0
      ]),
      [new Cesium.PolygonHierarchy(
        Cesium.Cartesian3.fromDegreesArray([
          -105.0, 33.0,
          -99.0, 33.0,
          -99.0, 37.0,
          -105.0, 37.0
        ]),
        [new Cesium.PolygonHierarchy(
          Cesium.Cartesian3.fromDegreesArray([
            -103.0, 34.0,
            -101.0, 34.0,
            -101.0, 36.0,
            -103.0, 36.0
          ])
        )]
      )]
    )]
  )
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygonWithHole);

// 3. create extruded polygon
const extrudedPolygon = new Cesium.PolygonGeometry({
  polygonHierarchy : new Cesium.PolygonHierarchy(
    Cesium.Cartesian3.fromDegreesArray([
      -72.0, 40.0,
      -70.0, 35.0,
      -75.0, 30.0,
      -70.0, 30.0,
      -68.0, 40.0
    ])
  ),
  extrudedHeight: 300000
});
const geometry = Cesium.PolygonGeometry.createGeometry(extrudedPolygon);

参数

Object with the following properties:

参数

A polygon hierarchy that can include holes.

参数

The distance in meters between the polygon and the ellipsoid surface.

参数

The distance in meters between the polygon's extruded face and the ellipsoid surface.

参数

The vertex attributes to be computed.

参数

The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise.

参数

The ellipsoid to be used as a reference.

参数

The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.

参数

Use the height of options.positions for each position instead of using options.height to determine the height.

参数

When false, leaves off the top of an extruded polygon open.

参数

When false, leaves off the bottom of an extruded polygon open.

参数

The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.

参数

Texture coordinates as a PolygonHierarchy of Cartesian2 points. Has no effect for ground primitives.

属性

packedLength

packedLength: number

The number of elements used to pack the object into an array.

方法

fromPositions()

static fromPositions(options: { positions: Cartesian3[]; height?: number; extrudedHeight?: number; vertexFormat?: VertexFormat; stRotation?: number; ellipsoid?: Ellipsoid; granularity?: number; perPositionHeight?: boolean; closeTop?: boolean; closeBottom?: boolean; arcType?: ArcType; textureCoordinates?: PolygonHierarchy; }): PolygonGeometry

A description of a polygon from an array of positions. Polygon geometry can be rendered with both Primitive and GroundPrimitive.

参数

options

Object with the following properties:

positions

Cartesian3[]

An array of positions that defined the corner points of the polygon.

height?

number

The height of the polygon.

extrudedHeight?

number

The height of the polygon extrusion.

vertexFormat?

VertexFormat

The vertex attributes to be computed.

stRotation?

number

The rotation of the texture coordinates, in radians. A positive rotation is counter-clockwise.

ellipsoid?

Ellipsoid

The ellipsoid to be used as a reference.

granularity?

number

The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.

perPositionHeight?

boolean

Use the height of options.positions for each position instead of using options.height to determine the height.

closeTop?

boolean

When false, leaves off the top of an extruded polygon open.

closeBottom?

boolean

When false, leaves off the bottom of an extruded polygon open.

arcType?

ArcType

The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.

textureCoordinates?

PolygonHierarchy

Texture coordinates as a PolygonHierarchy of Cartesian2 points. Has no effect for ground primitives.

返回

PolygonGeometry

示例

ts
// create a polygon from points
const polygon = Cesium.PolygonGeometry.fromPositions({
  positions : Cesium.Cartesian3.fromDegreesArray([
    -72.0, 40.0,
    -70.0, 35.0,
    -75.0, 30.0,
    -70.0, 30.0,
    -68.0, 40.0
  ])
});
const geometry = Cesium.PolygonGeometry.createGeometry(polygon);

pack()

static pack(value: PolygonGeometry, array: number[], startingIndex?: number): number[]

Stores the provided instance into the provided array.

参数

value

PolygonGeometry

The value to pack.

array

number[]

The array to pack into.

startingIndex?

number

The index into the array at which to start packing the elements.

返回

number[]

The array that was packed into


unpack()

static unpack(array: number[], startingIndex?: number, result?: PolygonGeometry): PolygonGeometry

Retrieves an instance from a packed array.

参数

array

number[]

The packed array.

startingIndex?

number

The starting index of the element to be unpacked.

result?

PolygonGeometry

The object into which to store the result.

返回

PolygonGeometry

The modified result parameter or a new PolygonGeometry instance if one was not provided.


computeRectangleFromPositions()

static computeRectangleFromPositions(positions: Cartesian3[], ellipsoid?: Ellipsoid, arcType?: ArcType, result?: Rectangle): Rectangle

Computes a rectangle which encloses the polygon defined by the list of positions, including cases over the international date line and the poles.

参数

positions

Cartesian3[]

A linear ring defining the outer boundary of the polygon.

ellipsoid?

Ellipsoid

The ellipsoid to be used as a reference.

arcType?

ArcType

The type of line the polygon edges must follow. Valid options are ArcType.GEODESIC and ArcType.RHUMB.

result?

Rectangle

An object in which to store the result.

返回

Rectangle

The result rectangle


createGeometry()

static createGeometry(polygonGeometry: PolygonGeometry): Geometry | undefined

Computes the geometric representation of a polygon, including its vertices, indices, and a bounding sphere.

参数

polygonGeometry

PolygonGeometry

A description of the polygon.

返回

Geometry | undefined

The computed vertices and indices.

构造函数

构造函数

new PolygonGeometry(options: { polygonHierarchy: PolygonHierarchy; height?: number; extrudedHeight?: number; vertexFormat?: VertexFormat; stRotation?: number; ellipsoid?: Ellipsoid; granularity?: number; perPositionHeight?: boolean; closeTop?: boolean; closeBottom?: boolean; arcType?: ArcType; textureCoordinates?: PolygonHierarchy; }): PolygonGeometry

参数

options
polygonHierarchy

PolygonHierarchy

height?

number

extrudedHeight?

number

vertexFormat?

VertexFormat

stRotation?

number

ellipsoid?

Ellipsoid

granularity?

number

perPositionHeight?

boolean

closeTop?

boolean

closeBottom?

boolean

arcType?

ArcType

textureCoordinates?

PolygonHierarchy

返回

PolygonGeometry

KBE3D @3.0.0 Copyright © 2024-present KBE3D