From e1cc87afa3aa74b2c6ba4f923345f7ddfd5ae04b Mon Sep 17 00:00:00 2001 From: duckietm Date: Fri, 24 Apr 2026 13:55:18 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20Fix=20background=20clipping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/src/renderer/RoomSpriteCanvas.ts | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/packages/room/src/renderer/RoomSpriteCanvas.ts b/packages/room/src/renderer/RoomSpriteCanvas.ts index 19a4b67..e1f1b09 100644 --- a/packages/room/src/renderer/RoomSpriteCanvas.ts +++ b/packages/room/src/renderer/RoomSpriteCanvas.ts @@ -378,49 +378,20 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas let leftIdx = 0; let rightIdx = 0; + let maxY = hull[0].y; for(let i = 1; i < hull.length; i++) { if(hull[i].x < hull[leftIdx].x) leftIdx = i; if(hull[i].x > hull[rightIdx].x) rightIdx = i; + if(hull[i].y > maxY) maxY = hull[i].y; } - const n = hull.length; - - // Collect arc going CCW: leftIdx → rightIdx via increasing indices - const arcCCW: { x: number; y: number }[] = []; - let idx = leftIdx; - - while(idx !== rightIdx) - { - arcCCW.push(hull[idx]); - idx = (idx + 1) % n; - } - - arcCCW.push(hull[rightIdx]); - - // Collect arc going CW: leftIdx → rightIdx via decreasing indices - const arcCW: { x: number; y: number }[] = []; - idx = leftIdx; - - while(idx !== rightIdx) - { - arcCW.push(hull[idx]); - idx = (idx - 1 + n) % n; - } - - arcCW.push(hull[rightIdx]); - - // Bottom arc = the arc with larger average Y (floor/front tiles) - const avgCCW = arcCCW.reduce((s, p) => s + p.y, 0) / arcCCW.length; - const avgCW = arcCW.reduce((s, p) => s + p.y, 0) / arcCW.length; - const bottomArc = avgCCW >= avgCW ? arcCCW : arcCW; - - // Build polygon: extend upward far above walls, then trace bottom boundary return [ - { x: hull[leftIdx].x, y: -extension }, - { x: hull[rightIdx].x, y: -extension }, - ...bottomArc.slice().reverse() + { x: hull[leftIdx].x - extension, y: -extension }, + { x: hull[rightIdx].x + extension, y: -extension }, + { x: hull[rightIdx].x + extension, y: maxY + extension }, + { x: hull[leftIdx].x - extension, y: maxY + extension } ]; }