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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user