From 11732531d25d78d8316078cca86636b0442f372e Mon Sep 17 00:00:00 2001 From: jwinterm Date: Tue, 14 Jul 2026 12:12:26 -0400 Subject: [PATCH] =?UTF-8?q?fix(render):=20iso=20black=20=E2=80=94=20overri?= =?UTF-8?q?de=20max-height/object-fit=20on=20the=20SP=20canvas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of iso rendering fully black: `.rotdis canvas { max-height:100%; object-fit:contain }` (styling meant for the legacy ROT canvas) also applied to the render-kit canvas. SP only overrode max-width. A canvas TALLER than the host (iso: ~2445px vs ~900px host) got object-fit-shrunk to ~0.37x while the CAMERA translate is computed in buffer space — so the player landed far off-screen (black). Tiled/ascii canvases usually fit the host, so they escaped it. Fix: override max-height:none + object-fit:fill so the buffer maps 1:1 and the camera transform alone controls scale/position. Iso default zoom set to 1.0 (its 84px tiles are large); tiled/ascii keep 1.7. --- html/js/render/spGameRenderer.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/html/js/render/spGameRenderer.js b/html/js/render/spGameRenderer.js index ba29703..76d94d6 100644 --- a/html/js/render/spGameRenderer.js +++ b/html/js/render/spGameRenderer.js @@ -97,8 +97,15 @@ if (SP._renderer && SP._renderer.canvas) { var c = SP._renderer.canvas; c.style.position = 'absolute'; c.style.top = '0'; c.style.left = '0'; - // Beat `.rotdis canvas { max-width:100% !important }` so the camera controls the size. + // Beat the `.rotdis canvas { max-width/height:100%; object-fit:contain }` rules (meant for + // the legacy ROT canvas) so the render-kit buffer maps 1:1 to the element and the CAMERA + // transform is the SOLE controller of scale/position. WITHOUT the max-height/object-fit + // override, a canvas TALLER than the host got object-fit-shrunk and the camera translate — + // computed in buffer space — pushed the player far off-screen (iso went fully BLACK; tiled's + // shorter canvas usually fit the host so it escaped the bug). c.style.setProperty('max-width', 'none', 'important'); + c.style.setProperty('max-height', 'none', 'important'); + c.style.setProperty('object-fit', 'fill', 'important'); c.style.setProperty('image-rendering', 'pixelated', 'important'); } if (!host._rkZoomBound) { @@ -126,7 +133,9 @@ r.canvas.style.top = '0'; return; } - var scale = SP._zoom || 1.7; + // Default zoom is mode-aware: iso tiles are large (84px), so a lower default frames a sensible + // number of them; tiled/ascii cells are small (~24px) so they want more magnification. + var scale = SP._zoom || (r.name === 'iso' ? 1.0 : 1.7); var fp = r.focusPoint; // ROBUSTNESS: if the renderer hasn't reported a focus this frame — a race at game start, or a // camera tick reading a just-(re)created renderer instance before its first render — derive the