Skip to content

Refactor/engine canvas size - #78

Merged
ramonmello merged 9 commits into
mainfrom
refactor/engine-canvas-size
Aug 8, 2026
Merged

ramonmello merged 9 commits into
mainfrom
refactor/engine-canvas-size

Conversation

@ramonmello

Copy link
Copy Markdown
Owner

No description provided.

ramonmello and others added 9 commits May 23, 2026 16:40
The CMS integration was already fully commented out at the call sites,
leaving the client, adapters, mappers and preview pages unreferenced.
Removing them frees next.config.ts from the /admin rewrite, so the app
can build with `output: "export"` and be published straight to Pages.
The context fetched /shaders/*.glsl at init, so the engine only worked
when the host app served those files from its public folder. Shipping
the sources as constants makes initWebGLContext synchronous and lets a
consumer override them through Manager.setShaders.
Covers World, Entity, MessageBus, the physics/collision/particle systems
and BaseGame before the architecture refactor. The tests pin down current
behaviour, including the quirks worth fixing later, so the next phases
have a safety net.
Deploy only triggers on the prod branch, which lags behind main, so
nothing verified the workspace on the way in.
The third positional argument is mass, not angular velocity, so every
asteroid got a near-zero mass and none of them rotated.
…ndow

The context read `window.innerWidth/innerHeight` and registered a `resize`
listener it never removed, so every new context piled up another listener
holding the old one alive, and `GameConfig.canvasWidth/canvasHeight` were dead
fields nobody read.

Sizing now goes through a `CanvasSizeSource`: `elementCanvasSize` (default)
follows the canvas element's own layout box with a `ResizeObserver`, and
`fixedCanvasSize` pins the drawing buffer. `WebGLContext.dispose()` tears the
subscription down, `clearWebGLContext` calls it, and `Manager` builds a fixed
source when the game declares both canvas dimensions.

A guard test fails the suite if any engine module reaches for a host global
again.

Closes #59

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`inset-0` leaves a replaced element at its intrinsic size, so the canvas was
only viewport-sized because the engine kept writing `window.innerWidth` into
its width attribute. Now that the engine sizes the drawing buffer from the
layout box, the page has to declare that box: `w-screen h-screen`.

Asteroids drops its 800x600 default for the same reason — the canvas covers the
page, so the context should follow the element instead of a fixed size.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ramonmello
ramonmello merged commit a78cdb8 into main Aug 8, 2026
1 check failed
@ramonmello
ramonmello deleted the refactor/engine-canvas-size branch August 8, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant