Repository navigation
fix: grid3d's pygbag page starts in 3D and keeps the 2D view safe, for 0.5.1 - #82
Merged
Merged
Conversation
…r 0.5.1 The browser page now starts in 3D, as a desktop Grid3DView game does, and the problems found in a game's run of the 0.5.0 template are fixed. - 3D by default: the relay's scripts and engine are loaded at once, alongside pygbag. The starting view is taken from ?view=2d / ?view=3d in the address (not remembered), else the player's last choice on the button (localStorage, every access in try/catch; a stored 2D wins), else the game's default: the button's data-default-view, "3d" unless the game builds with templatePath(defaultView="2d"). - The 2D canvas is hidden only once the game has sent the 3D view something to draw, and the relay canvas stays invisible (and lets presses through) until then, so pygbag's loading and tap-to-start screens stay usable while 3D loads. - If 3D can't start (no WebGL 2, a file missing, too big, the engine failed), 2D stays, the button reads "3D unavailable" and a note under it says why in plain words (Strata's failure codes are translated). Strata's own loading/failure overlay is hidden; it covered the 2D game. - The relay's three scripts (about 58 KB) are no longer in the page's markup; they are injected, in order, when 3D is wanted, so a page starting in 2D fetches nothing of the 3D view. Graphik3D.wanted() (wants3D()) turns true only once they are in. - The page is kept from scrolling (overflow: hidden on html and body), so a phone's browser can no longer widen it to fit pygbag's 50000-pixel measuring element and push the 2D/3D button off screen; the relay canvas is sized 100% rather than 100vw. - pygbag's two viewport tags, the second of which replaced the first's width=device-width, are merged into one. - Graphik3D.area() and grid3d.web.buttonArea() give the button's (x, y, width, height) in CSS pixels, so a game's HUD can keep its text out from under it. Template content checks and tests for templatePath(defaultView), buttonArea() and parseArea() are added; the version is 0.5.1 and the README's browser section describes the above. drafted by Claude on behalf of Daniel Stephenson Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYNeuoCqxFpUXrFhxnTg89
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.
The browser page made by
grid3d.web.templatePath()now starts in 3D, as a desktopGrid3DViewgame does. Problems found in a game's run of the 0.5.0 template are also fixed. The version is bumped to 0.5.1.3D by default
?view=2dor?view=3din the address (for testing and sharing; not remembered).localStorage. Every storage access is wrapped in try/catch, and a stored 2D wins over the default.data-default-view. It is3dunless the game is built withtemplatePath(defaultView="2d"), which writes a 2D-first copy of the template.networkare translated. The note stays until 10 seconds after the player's next press or key, or until it is tapped.Fixes
strata-loader.js,strata-kit.jsandgrid-relay.js(about 58 KB) were in the page's markup. They are now injected, in order, only when 3D is wanted, so a page that starts in 2D downloads nothing of the 3D view.Graphik3D.wanted()(wants3D()) turns true only once they are in, soGrid3DWebView.open()never runs before the relay exists.overflow: hiddenonhtmlandbody), so a phone's browser can't widen it to fit pygbag's 50000-pixel measuring element. The relay canvas is sized100%instead of100vw.width=device-width, are merged into one.Graphik3D.area()andgrid3d.web.buttonArea()give the button's(x, y, width, height)in CSS pixels, the units of the web view's labels and panels. A game can then keep its HUD text out from under the button. A game-side layout was chosen over moving the button: no corner is free in every game, and the game knows its own layout.Sizes (ophidian's build, files fetched by the default page; gzip at the default level)
?view=2dor a remembered 2D)Testing
pytest: 319 passed, 2 skipped. The new tests cover the template's contents (scripts injected in order rather than in the markup, the starting-view order, storage in try/catch, 2D hidden only once 3D is fed, the failure note, the Strata overlay hidden, one viewport tag, no scrolling, no Jinja delimiters in graphik's part),templatePath(defaultView),buttonArea()andparseArea().?view=2dstarts in 2D and fetches no relay file, and its button still loads 3D. Withgrid-relay-scene.wasmorgrid-relay.jsblocked, the page falls back to 2D, shows the reason, and the game keeps running. The 0.5.0 template fails five of these checks.drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code