feat(utilities): forward render context options through createGame - #692
Merged
Merged
Conversation
createGame now takes an optional options object whose renderContext field is passed to createRenderContext, so games built on createGame can set maxPixelRatio (and the other RenderContextOptions). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012jXdrrhDQTunF1wimhhC5t
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
stormmuller
enabled auto-merge (squash)
October 3, 2026 10:08
…2q1rr # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createGamebuilt its render context withcreateRenderContext(canvas)and took no options. A game set up withcreateGametherefore always rendered at the display's fulldevicePixelRatioand couldn't setmaxPixelRatio. On a 2× display, that means every full-screen pass covers 4× the pixels.This PR adds an optional second argument to
createGame, typed as the new exportedCreateGameOptions. ItsrenderContextfield is forwarded unchanged tocreateRenderContext:Existing calls with one argument behave exactly as before; the render context gets
{}, so all defaults are kept. Defaults follow the repo'sdefault…Optionsconvention.src/utilities/create-game.ts: newCreateGameOptionsinterface andoptionsparameter, forwarded tocreateRenderContextsrc/utilities/create-game.test.ts: tests for the default (no options) and the forwarded optionsecs/game.mdshows the new argument, and the high-DPI section ofrendering/world-units-and-cameras.mdshows how to cap the pixel ratio throughcreateGameCHANGELOG.md: anAddedentry under[Unreleased]Related issue(s)
Fixes defect report 009: "
createGamecan't passRenderContextOptions, so a game can't cap its render resolution".Verification checklist
npm run check-typespasses with 0 errorsnpm testpasses (226 files, 1733 tests)npm run lintpasses with 0 errors (2 existing TODO warnings inmaterial.ts)npm run cspellpasses with 0 errorsnpm run check-exportspassesindex.ts(CreateGameOptionsis exported via the existingexport * from './create-game.js')/documentation-site/docs/docsis updatedcreateGame: no code changes needed, since the change is backward compatible. Rannpm run build, then the docs-sitetypecheckandbuild, and loaded the particles, ecs and text demos in Chromium. All three rendered. The only console errors were external resources that the sandbox's proxy blocked.Changelog
## [Unreleased]inCHANGELOG.md🤖 Generated with Claude Code
https://claude.ai/code/session_012jXdrrhDQTunF1wimhhC5t
Generated by Claude Code