Log inGet started
World

Anvil Crown

Branchmain
Branchesmain
Commit0c3c8404d1

README.md

geo — outlines, extruded

The small geometry kit the THREATS slice builds its silhouettes with.

ANVIL CROWN is 2.5D: every piece of gameplay lives on the plane z = 0 and the camera looks straight down +Z from one fixed station. So a threat's silhouette is the whole read, and the natural way to author one is to draw a 2D outline and extrude it toward the camera.

local G = require("game.threats.geo")

local rock = renderer.mesh.create(G.prism(G.ngon(11, 1.85, 0.44, seed), 1.0, -1.0, 0.62))

The kit

callwhat it makes
G.ngon(n, r, jitter?, seed?)a regular n-gon, optionally roughened — the same seed always gives the same rock
G.star(points, outer, inner)an n-pointed star, for a burst
G.rect(cx, cy, hw, hh)an axis-aligned rectangle
G.shift(pts, dx, dy) / G.scale(pts, sx, sy?)move or resize an outline without rebuilding it
G.prism(pts, backZ, frontZ, inset?)extrude an outline into a solid with a chamfered front
G.prismAbout(pts, backZ, frontZ, inset, cx, cy)the same, chamfering toward an explicit point — what an off-centre wing or barrel needs
G.merge({ geo, … })weld several pieces into ONE mesh
G.triangles(geo)the triangle count, the number to watch when a pool grows

Outlines are counter-clockwise in XY. +Y is up on screen, -Y is the way the storm falls, and the front (camera-facing) face of a prism sits at the more negative Z.

Two things it does on purpose

The chamfer. inset pulls the near ring in toward the outline's centre, so the front face is a smaller copy of the back one and the sides between them catch light at an angle. Without it a prism reads as a flat card the moment a lightning flash crosses it.

Flat normals. Every triangle carries its own face normal — vertices are duplicated per triangle rather than shared. The result is faceted on purpose: in a shaft lit from within by its own electricity, facets are what make a shape turn as it falls.

G.merge matters more than it looks: attaching a Model component costs about thirty times what creating the entity does, so a threat made of five plates in one material should be one mesh and one entity, not five.