Documentation
    Preparing search index...

    Function polygonGeometry2D

    • An arbitrary polygon filled in the XY plane, facing +Z — §50's "arbitrary polygon" row, built on §52's tessellator.

      const ring = polygonGeometry2D({
      outline: [{ x: -1, y: -1 }, { x: 1, y: -1 }, { x: 1, y: 1 }, { x: -1, y: 1 }],
      holes: [[{ x: -0.4, y: -0.4 }, { x: -0.4, y: 0.4 }, { x: 0.4, y: 0.4 }, { x: 0.4, y: -0.4 }]],
      });

      Concave, holed, either winding: the shape is whatever triangulatePolygon accepts, and everything it refuses (§85 — self-intersections, zero area, a hole outside its outline) this builder refuses with the same error, because it is the same error. See tessellation.ts for the full list and for why a self-intersecting outline is refused rather than approximated.

      Vertex i is outline point i, then the first hole's points, then the second's — the concatenation §52's tessellator indexes. Nothing is inserted, merged, or moved, so a caller animating the outline can rewrite positions in place and keep the index buffer (§52 "index-buffer reuse"). A vertex the tessellator found redundant — one collinear with its neighbours — is still there; it simply appears in no triangle.

      Positions (z = 0) and uvs, no normals — the same choice circleGeometry2D makes and for the same reason: 2D shapes are unlit in the §120 tier, and a (0, 0, 1) repeated per vertex would be dead weight in every upload. Uv is the outline's bounding box normalized to [0, 1]², matching extrudeGeometry's caps, so the same texture lines up on a filled shape and on the front of its extrusion.

      Parameters

      Returns BufferGeometry