fix(render): iso black — override max-height/object-fit on the SP canvas

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.
This commit is contained in:
jwinterm
2026-07-14 12:12:26 -04:00
parent b45c0851c5
commit 11732531d2
+11 -2
View File
@@ -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