Shapes
A small geometry kit: enough to build a made thing out of profiles and paths.
Shapes
A small geometry kit: enough to build a made thing out of profiles and paths.
A builder collects positions, UVs and triangles. The generators append to
one — a surface of revolution, a torus, a tube swept along a path, a box —
and finish accumulates a normal per vertex from the faces that use it and
returns the flat arrays a mesh is created from. A whole prop goes into ONE
builder, so the seams between its parts stay hard: the parts share no vertices,
so the normal accumulation never crosses from one to the next.
local S = require("game.facer.Shapes")
local b = S.builder()
S.lathe(b, { { r = 0.4, y = 0 }, { r = 0.3, y = 1.2 } }, { segments = 24 })
S.torus(b, 0.42, 0.03, { 0, 0.05, 0 })
S.mesh("my_thing", b, "game/facer")
| call | what it adds |
|---|---|
lathe(b, profile, opts) | a surface of revolution around Y. A profile row is { r, y } and may carry dx / dz to push that row alone off the axis. fold ripples the radius so cloth hangs in folds rather than reading as a cone; capTop / capBottom close the ends. |
torus(b, major, minor, offset, majorSeg, minorSeg, squash) | a ring in the XZ plane. squash scales the tube on Y alone, which turns a round bead into a flat band. |
tube(b, path, radii, segments) | a solid tube swept along a path, with a radius per point. |
box(b, center, half, yaw) | an axis-aligned box turned about Y — one corner set per face, so every edge stays hard. |
rotateX(b, angle) / scaleAll(b, …) | turn or scale everything already in the builder. |
finish(b) | the geometry: positions, indices, normals, uvs. |
mesh(name, b, folder, rebuild) | register the geometry as a mesh, or re-write an existing one's geometry in place. Returns the name. |
Triangles are wound so their front face turns counter-clockwise to a viewer, which is the side a material draws.
Scoped to this part · feeds back into the world's score.