Builtin Library
- ..
- .metadata268 B
- README.md3.2 KB
- init.luau17.7 KB
- readings.module
README.md
geometry.decimate
Reduce a surface's triangle count by quadric-error edge collapse: every point carries the planes of the faces around it, weighted by their area, and the cost of merging the two ends of an edge is that sum evaluated at their midpoint. Each round collapses an independent set of the cheapest edges (none shares a point with another), until the count, the ratio or the error asked for is reached. A collapse that would pinch the surface (the ends share a neighbour beyond the two faces on the edge) is refused, so a closed manifold stays one. A geometry with no triangles is refused.
Inputs
geometry(Surface). The surface whose triangles are reduced.target(String, default "ratio", one of "count", "error", "ratio"). Which target is in force: "count" a triangle budget, "ratio" a share of what came in, "error" a limit on how far a collapse may move the surface.count(Float, default 1000, at least 1). The triangle count to reduce to whentargetis "count".ratio(Float, default 0.5, 0 to 1). The share of the input's triangles to keep whentargetis "ratio".error(Float, default 0.01, at least 0). The area-weighted RMS distance, in metres, a collapse may move the surface by whentargetis "error"; collapses stop when the cheapest left costs more.weld(Float, default 0.00001, above 0). Points this close together are one point while edges are found, which lets a triangle soup decimate as the connected surface it looks like.boundary(String, default "lock", one of "constrain", "free", "lock"). At the border of an open surface: "lock" and "constrain" keep every point of it where it is, "free" lets it erode.sharp(String, default "constrain", one of "constrain", "free", "lock"). Along creases sharper thancrease: "lock" and "constrain" keep their edges, "free" lets them collapse.crease(Float, default 30, 0 to 180). Two faces on an edge that turn by more than this make a crease.group(String, default ""). An attribute naming the part of the surface that may be reduced; points outside it are kept. Left empty, the whole surface may be.class(String, default "primitive", one of "edge", "point", "primitive", "vertex"). The classgrouplives on.promote(String, default "any", one of "all", "any"). How a group on a class other than the point class reaches the points: a point is in the group when "any" or "all" of the elements around it are.threshold(Float, default 0.5). The value a group element has to exceed to be in the group.seam(String, default "lock", one of "free", "lock"). Where the points welded into one disagree on theiruv: "lock" takes no collapse involving such a point, so the seam keeps its texture coordinates; "free" collapses across it.
Outputs
geometry(Geometry). The reduced surface.info(Data).target,targetTriangles,errorLimit(-1 unlesstargetis "error"),triangleCountBefore,triangleCountAfter,exact(the target was met exactly),stoppedBy("target", "error" or "exhausted"),collapses,seamPoints,groupLockedPointsandmaxError.
local lighter = g.geometry.decimate({ geometry = g.mesh.sphere({}), target = "ratio", ratio = 0.25 })