Skip to content

Simplify wave.html to standalone preview; add SVG export pipeline#2

Open
jdunk4 wants to merge 5 commits into
mainfrom
claude/nft-manifest-continuation-REGPE
Open

Simplify wave.html to standalone preview; add SVG export pipeline#2
jdunk4 wants to merge 5 commits into
mainfrom
claude/nft-manifest-continuation-REGPE

Conversation

@jdunk4
Copy link
Copy Markdown
Owner

@jdunk4 jdunk4 commented May 10, 2026

Summary

This PR strips wave.html down to a minimal standalone preview page for Endless Glyphs mazes, removing all game UI chrome (title screen, HUD, overlays, SSO, armory). It also introduces an offline batch export pipeline for generating and compressing the 1024 wave SVGs that will be stored on-chain and surfaced via NFT metadata.

Key Changes

wave.html Refactor

  • Removed: ~560 lines of title screen markup (mode cards, profile panel, SSO buttons, armory overlay, incoming call screen, rotate prompt, loading screen)
  • Removed: All HUD elements (score display, player panel, weapon UI, pause menu, chapter/wave counters)
  • Removed: Meta tags for app installation (apple-mobile-web-app, manifest, orientation locks)
  • Kept: Minimal <head> with theme color and favicon; single <div id="game"> mount point for Three.js canvas
  • Added: Inline <style> block with baseline CSS (black fullscreen, canvas sizing) so the preview works without relying on styles.css game layout rules

New SVG Export Scripts

  • scripts/export-maze-svgs.mjs: Generates all 1024 Endless Glyphs wave SVGs offline using the same generateMaze() + renderMazeSVG() pipeline as the in-game preview. Outputs self-contained SVG files to nft-build/svgs/. Supports --start, --end, --out, and --quiet flags for batch control.
  • scripts/compress-svgs.mjs: DEFLATE-compresses each SVG (RFC 1951 raw format, no gzip wrapper) for on-chain storage via Solidity inflate(). Produces .bin files in nft-build/svgs.deflate/. Also generates gzip variants for comparison. Reports compression ratios and per-wave statistics.

New SVG Renderer Module

  • src/mazeSvg.js: Pure function renderMazeSVG(maze, accent) that converts maze data to a self-contained SVG string. Renders walls, mining blocks, chapter-specific hazards (lasers, spikes, springs, arrows, warps), singularities, glyphs, and spawn point. No DOM or globals—safe to run in Node.js. Includes hazardForChapter() helper documenting the 50-wave color bands and their hazard assignments.

wave-engine.js Camera Update

  • Added updateCamera(dt) function that switches between top-down (for Endless Glyphs preview) and chase camera (fallback). Respects S.endlessTopDown flag set by endlessGlyphs.js to position camera at (0, 92, 12) for full maze visibility.
  • Imported CAMERA_OFFSET from scene.js for consistency.

Build Configuration

  • Added npm run export-svgs and npm run compress-svgs scripts to package.json
  • Updated .gitignore to exclude nft-build/ directory (generated artifacts)

Implementation Details

  • The export scripts use pure ESM with no browser globals or three.js dependency—they only consume mazeGenerator, glyphsSpectrum, mazeSvg, and state.js
  • Standalone-EG mode is enabled by setting S.endlessGlyphs = true and S.endlessChapterMode = false in the export script, matching the gate used in mazeGenerator.js for hazard distribution
  • SVG output uses raw DEFLATE (no zlib/gzip wrapper) to minimize on-chain storage overhead (18B per wave × 1024 = 18.4 KB saved)
  • The wave preview now renders with the same top-down framing as the main game's Endless Glyphs mode, ensuring visual consistency between the preview and the NFT metadata image

https://claude.ai/code/session_01F7dnKPcAUk9EBq7QKC3mz2

claude added 5 commits May 10, 2026 00:21
Pre-mint task #1 from NFT_MANIFEST.md. Bundles the same maze
generation + top-down SVG renderer the in-page wave preview uses
into a Node CLI so we can produce the source-of-truth SVG bytes
for on-chain (SSTORE2) storage and per-NFT metadata in one shot.

- src/mazeSvg.js: extracted pure SVG renderer (renderMazeSVG +
  hazardForChapter), no DOM / no globals — safe for Node and for
  the browser preview to share.
- scripts/export-maze-svgs.mjs: ESM CLI with --start/--end/--out;
  defaults to 1..1024 → dist/svgs/{N}.svg. Sets the same standalone
  EG flags wavePreview uses (S.endlessGlyphs=true,
  endlessChapterMode=false) before generateMaze so the standalone
  hazard distribution kicks in. Reports per-50 progress, total
  bytes, max wave size, and slow-wave timings.
- package.json: `npm run export-svgs` script.
- .gitignore: ignore dist/ (vite build output + SVG batch).

wavePreview.js untouched — its inlined renderer stays as-is for
this commit; can migrate to the shared module in a follow-up if we
want one source of truth.

Smoke-tested 1..5 and 1020..1024: ~11–14 KB per SVG, valid markup,
no crashes at the upper bound.
Strip every DOM block the wave-preview path doesn't render: title /
sign-in / SSO / mode-cards / armory / HUD / inventory / boss-bar /
wave-banner / objective / mobile controls / keyboard-hint cheatsheet
/ gameover / phone-ring / glyphs-player-modal / matrix rain backdrop.
All shared-module DOM queries against these IDs (#title, #loading,
#hud-top, #matrix-dive, #initiate-protocol, #hyperdrive-overlay) are
already null-guarded in endlessGlyphs.js, so removing the elements
is a no-op for the runtime.

Keep: importmap, the __WAVE_PREVIEW_MODE flag, #game canvas slot,
the wave-engine.js script tag. Inline the minimal CSS the page needs
so styles.css's title-screen/HUD rules don't fight the canvas mount.

Built clean — index.html bundle unchanged, dist/wave.html drops from
~40 KB to 2.24 KB.
`npm run compress-svgs` reads nft-build/svgs/{N}.svg and writes
nft-build/svgs.deflate/{N}.bin — raw DEFLATE bytes (RFC 1951, no
gzip/zlib wrapper) sized for an on-chain inflate() call inside
GlyphsNFT.sol's tokenURI. Also reports a gzip variant for comparison
since the gzip wrapper is 18B/file × 1024 = 18.4 KB of pure overhead
we don't want to pay on-chain.

Also move the SVG export default from dist/svgs to nft-build/svgs
since `vite build` empties dist/, which wipes the SVGs between an
export run and the contract pipeline. nft-build/ is gitignored
(large generated artifact, regenerated on demand).
Pre-existing bug in the slim wave-engine entry: main.js's updateCamera()
was the only place that read S.endlessTopDown and lerped the camera to
(0, 92, 12) — the high vantage point that frames the whole maze.
wave-engine.js's render loop never ported that logic, so wave.html?wave=N
played from the chase camera (CAMERA_OFFSET, low angle) and most of the
maze was cropped out of frame.

Mirror main.js:updateCamera here. Top-down branch when S.endlessTopDown
is true; chase fallback so the camera doesn't strand between waves
(victory dissolve resets the flag). +500B in the wave bundle.
Camera fix from b6e489f isn't visibly applying for the user. Add a
one-shot console.log on first top-down activation and on first chase
fallback so we can tell which branch is firing. Will revert once the
underlying issue is found.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
meebit-shooter 615add1 Commit Preview URL

Branch Preview URL
May 10 2026, 12:54 AM

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.

2 participants