import { ClippedVertex } from "@here/harp-geometry/lib/ClipPolygon" ; import { ShapeUtils , Vector2 } from "three" ; /**
 * A class representing a ring of a polygon geometry.
 */ export class Ring { remarks readonly area : number ; remarks readonly winding : boolean ; /**
     * The vertex stride.
     */ readonly vertexStride : number ; param points param textureCoords param extents param hasClipInfo constructor ( readonly points , readonly textureCoords ? , readonly extents = 4 * 1024 , readonly hasClipInfo = false ) { if ( textureCoords !== undefined && textureCoords . length !== points . length ) { throw new Error ( `the array of texture coordinates must have the same number of elements of the array of points` ) ; } this . vertexStride = 2 ; if ( textureCoords !== undefined ) { this . vertexStride = this . vertexStride + 2 ; } this . area = ShapeUtils . area ( this . points ) ; this . winding = this . area < 0 ; } param array param offset toArray ( array = [ ] , offset = 0 ) { this . points . forEach ( ( p , i ) => p . toArray ( array , offset + this . vertexStride * i ) ) ; this . textureCoords ?. forEach ( ( p , i ) => p . toArray ( array , offset + this . vertexStride * i + 2 ) ) ; return array ; } param index isProperEdge ( index ) { const extents = this . extents ; const nextIdx = ( index + 1 ) % this . points . length ; const curr = this . points [ index ] ; const next = this . points [ nextIdx ] ; if ( this . hasClipInfo ) { if ( curr . x !== next . x && curr . y !== next . y ) { return true ; } const currAtEdge = curr . x % this . extents === 0 || curr . y % this . extents === 0 ; if ( ! currAtEdge ) { return true ; } const nextAtEdge = next . x % this . extents === 0 || next . y % this . extents === 0 ; if ( ! nextAtEdge ) { return true ; } const currWasClipped = curr . isClipped === true ; const nextWasClipped = next . isClipped === true ; return ! currWasClipped && ! nextWasClipped ; } return ! ( ( curr . x <= 0 && next . x <= 0 ) || ( curr . x >= extents && next . x >= extents ) || ( curr . y <= 0 && next . y <= 0 ) || ( curr . y >= extents && next . y >= extents ) ) ; } }