Constructors

  • Create a 2d cross-section from a set of contours (complex polygons). A boolean union operation (with Positive filling rule by default) is performed to combine overlapping polygons and ensure the resulting CrossSection is free of intersections.

    Parameters

    • contours: Polygons

      A set of closed paths describing zero or more complex polygons.

    • OptionalfillRule: FillRule

      The filling rule used to interpret polygon sub-regions in contours.

    Returns CrossSection

Methods

  • Constructs a manifold by extruding the cross-section along Z-axis.

    Parameters

    • height: number

      Z-extent of extrusion.

    • OptionalnDivisions: number

      Number of extra copies of the crossSection to insert into the shape vertically; especially useful in combination with twistDegrees to avoid interpolation artifacts. Default is none.

    • OptionaltwistDegrees: number

      Amount to twist the top crossSection relative to the bottom, interpolated linearly for the divisions in between.

    • OptionalscaleTop: number | Vec2

      Amount to scale the top (independently in X and Y). If the scale is {0, 0}, a pure cone is formed with only a single vertex at the top. Default {1, 1}.

    • Optionalcenter: boolean

      If true, the extrusion is centered on the z-axis through the origin as opposed to resting on the XY plane as is default.

    Returns Manifold

  • Mirror this CrossSection over the arbitrary axis described by the unit form of the given vector. If the length of the vector is zero, an empty CrossSection is returned. This operation can be chained. Transforms are combined and applied lazily.

    Parameters

    • ax: Vec2

      the axis to be mirrored over

    Returns CrossSection

  • Inflate the contours in CrossSection by the specified delta, handling corners according to the given JoinType.

    Parameters

    • delta: number

      Positive deltas will cause the expansion of outlining contours to expand, and retraction of inner (hole) contours. Negative deltas will have the opposite effect.

    • OptionaljoinType: JoinType

      The join type specifying the treatment of contour joins (corners).

    • OptionalmiterLimit: number

      The maximum distance in multiples of delta that vertices can be offset from their original positions with before squaring is applied, when the join type is Miter (default is 2, which is the minimum allowed). See the Clipper2 MiterLimit page for a visual example.

    • OptionalcircularSegments: number

      Number of segments per 360 degrees of JoinType::Round corners (roughly, the number of vertices that will be added to each contour). Default is calculated by the static Quality defaults according to the radius.

    Returns CrossSection

  • Constructs a manifold by revolving this cross-section around its Y-axis and then setting this as the Z-axis of the resulting manifold. If the contours cross the Y-axis, only the part on the positive X side is used. Geometrically valid input will result in geometrically valid output.

    Parameters

    • OptionalcircularSegments: number

      Number of segments along its diameter. Default is calculated by the static Defaults.

    • OptionalrevolveDegrees: number

    Returns Manifold

  • Remove vertices from the contours in this CrossSection that are less than the specified distance epsilon from an imaginary line that passes through its two adjacent vertices. Near duplicate vertices and collinear points will be removed at lower epsilons, with elimination of line segments becoming increasingly aggressive with larger epsilons.

    It is recommended to apply this function following Offset, in order to clean up any spurious tiny line segments introduced that do not improve quality in any meaningful way. This is particularly important if further offseting operations are to be performed, which would compound the issue.

    Parameters

    • Optionalepsilon: number

      minimum distance vertices must diverge from the hypothetical outline without them in order to be included in the output (default 1e-6)

    Returns CrossSection

  • Transform this CrossSection in space. Stored in column-major order. This operation can be chained. Transforms are combined and applied lazily.

    Parameters

    • m: Mat3

      The affine transformation matrix to apply to all the vertices. The last row is ignored.

    Returns CrossSection

  • Move the vertices of this CrossSection (creating a new one) according to any arbitrary input function, followed by a union operation (with a Positive fill rule) that ensures any introduced intersections are not included in the result.

    Parameters

    • warpFunc: ((vert: Vec2) => void)

      A function that modifies a given vertex position.

        • (vert): void
        • Parameters

          Returns void

    Returns CrossSection

  • Constructs a circle of a given radius.

    Parameters

    • radius: number

      Radius of the circle. Must be positive.

    • OptionalcircularSegments: number

      Number of segments along its diameter. Default is calculated by the static Quality defaults according to the radius.

    Returns CrossSection

  • Create a 2d cross-section from a set of contours (complex polygons). A boolean union operation (with Positive filling rule by default) is performed to combine overlapping polygons and ensure the resulting CrossSection is free of intersections.

    Parameters

    • contours: Polygons

      A set of closed paths describing zero or more complex polygons.

    • OptionalfillRule: FillRule

      The filling rule used to interpret polygon sub-regions in contours.

    Returns CrossSection

  • Constructs a square with the given XY dimensions. By default it is positioned in the first quadrant, touching the origin. If any dimensions in size are negative, or if all are zero, an empty Manifold will be returned.

    Parameters

    • Optionalsize: number | Vec2

      The X, and Y dimensions of the square.

    • Optionalcenter: boolean

      Set to true to shift the center to the origin.

    Returns CrossSection