artLib — geometry helpers shared by Lantern Drift's art modules.
local ArtLib = require("games.lanternDrift.art.artLib")
local geo = ArtLib.lathe({ { 0.2, -0.4 }, { 0.3, 0 }, { 0, 0.45 } }, 32)
build.asset("mesh", "Envelope", function() return geo end)
`lathe` turns a profile of { radius, y } points round the Y axis into the
flat arrays `asset.create("mesh", ...)` takes, with uv u = round (0..1) and
v = up the profile by arc length (0 at the first point, 1 at the last), and
outward normals. `merge` joins several such meshes into one.
lathe(profile: { { number } }, segments: number) → MeshArrays
Turn a {radius, y} profile round Y into mesh arrays (uv.v = arc length up the profile).
| arg | type | description |
|---|
| profile | { { number } } | { {number} } — points bottom to top, each { radius, y } |
| segments | number | number — divisions round the axis |
merge(parts: { { mesh: MeshArrays, offset: { number }?, scale: number? } }) → MeshArrays
Join several mesh arrays into one, each moved by an offset {x, y, z} and a uniform scale.
| arg | type | description |
|---|
| parts | { { mesh: MeshArrays, offset: { number }?, scale: number? } } | { {mesh: MeshArrays, offset: {number}?, scale: number?} } |
computeNormals(positions: { number }, indices: { number }) → void
Smooth vertex normals for an indexed triangle list (area-weighted).
| arg | type | description |
|---|
| positions | { number } | |
| indices | { number } | |
spire(opts: SpireOpts) → MeshArrays
A weathered rock spire as mesh arrays: a noise-displaced turned column built of
tilted strata layers (each its own set-back, with an overhanging lip and an
undercut), chipped facets, cracks and a broken, craggy crown. Standing: base below
the water (y -2.5), top at height. Hanging: a jagged blunt tip at y 0, widening up
to a broad top at height. Width at the gap stays within ~10% of `width`.
| arg | type | description |
|---|
| opts | SpireOpts | SpireOpts |
profile(t: number) → number
| arg | type | description |
|---|
| t | number | |
lean(y: number) → void
| arg | type | description |
|---|
| y | number | |
strata(a: number, y: number) → number
| arg | type | description |
|---|
| a | number | |
| y | number | |
detail(a: number, y: number) → number
| arg | type | description |
|---|
| a | number | |
| y | number | |
addRing(y: number, r: number, uvV: number, jag: number?) → void
jag lifts each vertex of the ring by an angle-dependent, stepped amount (broken crowns and tips)
| arg | type | description |
|---|
| y | number | |
| r | number | |
| uvV | number | |
| jag | number? | |
pine(Q: any, rng: any, opts: { height: number, spread: number }) → any
A twisted Japanese black pine as a quick-geometry Group: a leaning, curving trunk,
a few long branches reaching sideways, and flat cloud pads of needles.
`Q` carries the quick geometry nouns of the calling build (Group, Mesh, TubeGeometry,
CatmullRomCurve3, IcosahedronGeometry, MeshStandardMaterial, Vector3).
| arg | type | description |
|---|
| Q | any | table of nouns |
| rng | any | a Random |
| opts | { height: number, spread: number } | { height: number, spread: number } |
padAt(x: number, y: number, z: number, size: number) → void
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
| size | number | |
⌬ Types
MeshArrays = { positions: { number }, normals: { number }, uvs: { number }, indices: { number } }SpireOpts = {