feat: add outdoor snapping, terrain types and procedural textures

This commit is contained in:
jhartworks committed 2026-11-16 13:02:18 +01:00
1 parent 992c3e18f2
commit d8cf076019
30 files changed
+2251 -1549

No files matched your search

+6
View File
@@ -10,6 +10,7 @@ import { ALWAYS, pushPrism, shade, triangulate, type GeoBuffer, type LineBuffer
import { counterClockwise, pushBeam, pushPost } from "./beams.ts";
import { gateLayout, gatesOnEdge } from "./gates.ts";
import { LOOKS } from "./looks.ts";
import { OUTDOOR_MATERIAL } from "./textures.ts";
/** The height of the visible surface of an area (for the lighting layer), at its high edge. */
export function outdoorSurface(floor: Floor, area: OutdoorArea): number {
@@ -191,6 +192,8 @@ export function outdoorOpacity(area: OutdoorArea): number {
* into `buf`; the outlines always stay solid.
*/
export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, ghosts?: Map<number, GeoBuffer>, makeBuffer?: () => GeoBuffer): void {
// The shared wall shader also serves floors without outdoor areas: supply a neutral ID there.
buf.surface ??= Array(buf.p.length / 3).fill(0);
const ground = groundLevel(floor);
const areas = floor.outdoor ?? [];
areas.forEach((area, index) => {
@@ -205,6 +208,8 @@ export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, gho
if (!ghosts.has(opacity)) ghosts.set(opacity, makeBuffer());
target = ghosts.get(opacity)!;
}
target.surface ??= Array(target.p.length / 3).fill(0);
const firstVertex = target.p.length / 3;
const context: Context = {
buf: target,
lines,
@@ -223,5 +228,6 @@ export function pushOutdoor(buf: GeoBuffer, lines: LineBuffer, floor: Floor, gho
else if (area.type === "fence") buildFence(context);
else if (area.type === "pergola") buildPergola(context);
else buildBlock(context, areas, index);
target.surface.fill(OUTDOOR_MATERIAL[area.type], firstVertex);
});
}