HOW WANDER IS BUILT · LAYER 4 OF 7
Faces, roofs, far tiles and the atlas.
A chunk of heights becomes triangles once. For every cell, a top face at its height and a side face wherever a neighbour is lower (the border ring supplies the neighbour on the chunk's edge). Each vertex carries ten floats: position, normal, colour and a flag that tells the shader what the face is (ground, water, leaf, emissive). Water is one flat sheet at the water line. Props (trees, reeds, rocks, decks, the city's lamp posts) are small boxes and quads added to the same buffer. Roofs are never placed; they are read: a rectangle of rock or snow two to eight cells a side at one height gets a pitched roof, a spire when it is two by two, traced past the chunk's edge so a house on the edge gets one roof, not two halves. The light cone's lace is kept as spans per cell and drawn as boxes with bottoms. Far tiles get the same treatment at a stride, with the near boxes cut away so the detailed chunks show through.
const M = WanderMesh; // mesh.js, the pure builders lifted out of gl.js (SIMesh in the kit)
const parts = M.buildChunk(c); // c from inst.chunk(ci, cj): an array of parts, each {v: Float32Array, i: Uint16Array, count}
let tris = 0; for (const p of parts) tris += p.count/3;
console.log(parts.length, "parts,", tris, "triangles; a vertex is 10 floats:", Array.from(parts[0].v.slice(0, 10)).map(v => +v.toFixed(2)).join(" "));
const far = M.buildChunk(c, 2); // the same chunk at a coarser level of detail for the middle distance
const tileParts = M.buildBlocks(W.tile(inst, 4, 256, 0, 0, [])); // the horizon tile as blocks
console.log("far", far.reduce((n, p) => n + p.count/3, 0), "tile", tileParts.reduce((n, p) => n + p.count/3, 0));
console.log("roofs read from the ground:", c.roofs.length, "bounds", M.boundsOf(c));The Python twin sitoolz.mesh builds the same buffers from the same chunk and the fixture fixtures/mesh.json checks the vertex and index hashes on both sides. Card: mesh.md.
← A window is a chunk A mesh is a view →
How Wander is built · by Lars Rocha · every layer stands on a law in sitoolz, written twice and checked against one fixture.