feat(tile): render tiles with the mesh generator

Replace the per-shape tile geometries with @tts/mesh extrusion, honoring
the tile type and stretch aspect ratio. Add extrudeShapeParts so the
caps carry the texture while the walls are solid white, matching TTS
tinting. Fix bottom-face UVs to mirror horizontally and make wall UVs
inherit the front mapping independent of z.
This commit is contained in:
2026-08-08 14:21:53 +08:00
parent 14f83f476c
commit d554d6bde1
11 changed files with 246 additions and 45 deletions
+16
View File
@@ -72,6 +72,22 @@ describe('capFaces', () => {
expect(uvs[5]).toBeCloseTo(1, 5);
});
it('bottom face UVs are a left/right flip of the top face', () => {
const face = capFaces(rectShape(2, 2), 1);
const outlineCount = 4;
// Top face: outline point i maps to ((x-minX)/spanX, (y-minY)/spanY).
// Bottom face mirrors U (1 - u) but keeps V, so the texture reads
// correctly from underneath.
for (let i = 0; i < outlineCount; i++) {
const topU = face.uvs[i * 2]!;
const topV = face.uvs[i * 2 + 1]!;
const bottomU = face.uvs[(outlineCount + i) * 2]!;
const bottomV = face.uvs[(outlineCount + i) * 2 + 1]!;
expect(bottomU).toBeCloseTo(1 - topU, 5);
expect(bottomV).toBeCloseTo(topV, 5);
}
});
it('top face triangles are CCW (positive area)', () => {
const face = capFaces(rectShape(2, 2), 1);
const topIndices = face.indices.slice(0, 6);