3D-City Model
    Preparing search index...

    PolygonDrawing – Interactive drawing class for creating filled polygons in Cesium scenes.

    Extends Drawing to support:

    • User placement of 3 or more points (with an optional maximum)
    • Live rendering of both the polyline outline and the polygon area fill as Cesium entities
    • Color controls for outline and area
    • Interactive show/hide, update, and cleanup of all involved entities

    The Cesium Viewer or host application context.

    Optional initial point array (vertices).

    Maximum points/vertices allowed (optional).

    Fill color for points/polygon.

    Start with first point placed.

    Fired when a vertex is moved.

    const poly = new PolygonDrawing(viewer, {
    color: Cesium.Color.CYAN.withAlpha(0.3),
    maxPoints: 5
    });

    // After user finished
    console.log('Polygon coordinates:', poly.cartesians);

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructor for a PolygonDrawing instance.

      Parameters

      • app: any

        Cesium viewer or scene host.

      • Optionaloptions: {
            addPoint?: boolean;
            color?: any;
            maxPoints?: number;
            onMoveCallback?: Function;
            points?: Cartesian3[];
        } = {}
        • OptionaladdPoint?: boolean

          Start with one point.

        • Optionalcolor?: any

          Polygon fill and point color.

        • OptionalmaxPoints?: number

          (Optional) max number of polygon vertices.

        • OptionalonMoveCallback?: Function

          Callback for vertex move.

        • Optionalpoints?: Cartesian3[]

          Initial array of Cartesian3 points.

      Returns PolygonDrawing

    Properties

    app: any
    destroyed: undefined | boolean
    id: any
    line: any

    Cesium polyline entity for polygon outline.

    onFinishCallback: any
    onMoveCallback: any
    onSetCallback: any
    point: undefined | PointEntity
    pointSet: PointSet3D
    polygon: any

    Cesium polygon entity for area fill.

    Accessors

    • get cartesians(): Cartesian3[]

      Access the current array of point positions.

      Returns Cartesian3[]

    • set cartesians(value: Cartesian3[]): void

      Parameters

      • value: Cartesian3[]

      Returns void

    Methods

    • Add another interactive 3D point to the drawing. Triggers relevant callbacks when placement is complete or limit is reached.

      Returns void

    • Render the dynamic outline (closed polyline) and area (polygon) in the scene. Creates entities only once; positions are kept reactive with CallbackProperty.

      Returns void

    • Finalize the polygon only if it has at least 3 vertices. Handles cases for unlimited points (deletes last temp), and sets finished=true.

      Returns boolean

      True if polygon is valid (3+ points), false otherwise.