create-threenative 0.2.15 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-docs/kit-mcp.md +10 -0
- package/agent-docs/kit-router.md +14 -0
- package/agent-docs/kit-stuck.md +7 -0
- package/agent-docs/references/assertion-reference.md +54 -110
- package/agent-docs/references/capability-reference.md +1740 -254
- package/agent-docs/references/conventions.md +299 -0
- package/agent-docs/references/kit-action-rpg.md +40 -0
- package/agent-docs/references/kit-adventure.md +40 -0
- package/agent-docs/references/kit-collectathon.md +38 -0
- package/agent-docs/references/kit-kart.md +31 -0
- package/agent-docs/references/kit-minimal.md +29 -0
- package/agent-docs/references/kit-platformer.md +34 -0
- package/agent-docs/references/kit-puzzle.md +22 -0
- package/agent-docs/references/kit-racing.md +26 -0
- package/agent-docs/references/kit-rain.md +31 -0
- package/agent-docs/references/kit-rts.md +34 -0
- package/agent-docs/references/kit-runner.md +32 -0
- package/agent-docs/references/kit-sailing.md +41 -0
- package/agent-docs/references/kit-shooter.md +33 -0
- package/agent-docs/references/kit-snow.md +33 -0
- package/agent-docs/references/kit-starter.md +55 -0
- package/agent-docs/references/kit-tower-defense.md +27 -0
- package/agent-docs/references/performance-basics.md +8 -4
- package/agent-docs/references/terrain-authoring.md +2 -1
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +3 -2
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +84 -59
- package/agent-files/.claude/hooks/discovery-gate.mjs +125 -0
- package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
- package/agent-files/.claude/settings.json +25 -0
- package/agent-files/.codex/hooks.json +18 -1
- package/dist/index.d.ts +97 -6
- package/dist/index.js +899 -271
- package/dist/terrain-kit.d.ts +7 -0
- package/dist/terrain-kit.js +82 -0
- package/dist/threenative.js +114 -16
- package/dist/web-engine-ccd-ik-solver.js +127 -0
- package/dist/web-engine-gltf-loader.js +71 -20
- package/dist/web-engine-post-effects.js +39 -14
- package/dist/web-engine-runtime.js +10011 -4101
- package/package.json +15 -9
- package/template-assets/clearwater/README.md +1 -1
- package/template-assets/patches/manifest.json +18 -0
- package/template-assets/patches/three@0.187.0.patch +2004 -407
- package/template-assets/terrain/alpine/assets.json +12 -0
- package/template-assets/terrain/alpine/bake.mjs +6 -0
- package/template-assets/terrain/alpine/credits.json +164 -0
- package/template-assets/terrain/alpine/heightmap.r16 +0 -0
- package/template-assets/terrain/alpine/recipe.json +119 -0
- package/template-assets/terrain/alpine/surface.json +53 -0
- package/template-assets/terrain/coastal/assets.json +11 -0
- package/template-assets/terrain/coastal/bake.mjs +6 -0
- package/template-assets/terrain/coastal/credits.json +117 -0
- package/template-assets/terrain/coastal/heightmap.r16 +0 -0
- package/template-assets/terrain/coastal/recipe.json +113 -0
- package/template-assets/terrain/coastal/surface.json +41 -0
- package/template-assets/terrain/desert/assets.json +12 -0
- package/template-assets/terrain/desert/bake.mjs +6 -0
- package/template-assets/terrain/desert/credits.json +164 -0
- package/template-assets/terrain/desert/heightmap.r16 +0 -0
- package/template-assets/terrain/desert/recipe.json +108 -0
- package/template-assets/terrain/desert/surface.json +54 -0
- package/template-assets/terrain/forest/assets.json +65 -0
- package/template-assets/terrain/forest/bake.mjs +8 -0
- package/template-assets/terrain/forest/credits.json +225 -0
- package/template-assets/terrain/forest/heightmap.r16 +0 -0
- package/template-assets/terrain/forest/recipe.json +350 -0
- package/template-assets/terrain/forest/surface.json +79 -0
- package/template-assets/terrain/tundra/assets.json +12 -0
- package/template-assets/terrain/tundra/bake.mjs +6 -0
- package/template-assets/terrain/tundra/credits.json +164 -0
- package/template-assets/terrain/tundra/heightmap.r16 +0 -0
- package/template-assets/terrain/tundra/recipe.json +277 -0
- package/template-assets/terrain/tundra/surface.json +54 -0
- package/templates/action-rpg/AGENTS.md +103 -84
- package/templates/action-rpg/CLAUDE.md +103 -84
- package/templates/action-rpg/kit.json +1 -0
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/playtests/spells.playtest.json +20 -0
- package/templates/action-rpg/src/game.ts +2 -1
- package/templates/action-rpg/src/render/atmosphere.ts +11 -16
- package/templates/action-rpg/src/render/backlightControls.ts +10 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +4 -4
- package/templates/action-rpg/src/render/clouds.ts +13 -0
- package/templates/action-rpg/src/render/gpuSky.ts +4 -7
- package/templates/action-rpg/src/render/materialLighting.ts +5 -5
- package/templates/action-rpg/src/render/quality.ts +10 -33
- package/templates/action-rpg/src/scenes/Play.ts +30 -1
- package/templates/action-rpg/src/style.css +4 -0
- package/templates/action-rpg/src/ui/AbilityBar.tsx +1 -1
- package/templates/action-rpg/threenative.config.ts +0 -3
- package/templates/action-rpg/vite.config.ts +2 -0
- package/templates/adventure/AGENTS.md +92 -44
- package/templates/adventure/CLAUDE.md +92 -44
- package/templates/adventure/kit.json +5 -1
- package/templates/adventure/package.json +7 -7
- package/templates/adventure/src/game.ts +1 -1
- package/templates/adventure/src/style.css +4 -0
- package/templates/adventure/tsconfig.json +1 -1
- package/templates/adventure/vite.config.ts +2 -0
- package/templates/collectathon/AGENTS.md +93 -42
- package/templates/collectathon/CLAUDE.md +93 -42
- package/templates/collectathon/package.json +7 -7
- package/templates/collectathon/src/game.ts +1 -1
- package/templates/collectathon/src/level/Course.ts +55 -9
- package/templates/collectathon/src/level/terrain.ts +27 -6
- package/templates/collectathon/src/main.ts +1 -0
- package/templates/collectathon/src/render/foliage.ts +359 -98
- package/templates/collectathon/src/render/sky.ts +76 -12
- package/templates/collectathon/src/render/water.ts +32 -10
- package/templates/collectathon/src/scenes/Play.ts +18 -5
- package/templates/collectathon/src/style.css +4 -0
- package/templates/collectathon/tsconfig.json +1 -1
- package/templates/collectathon/vite.config.ts +2 -0
- package/templates/kart/AGENTS.md +87 -42
- package/templates/kart/CLAUDE.md +87 -42
- package/templates/kart/package.json +6 -6
- package/templates/kart/src/game.ts +1 -1
- package/templates/kart/src/main.ts +1 -0
- package/templates/kart/src/style.css +4 -0
- package/templates/kart/tsconfig.json +1 -1
- package/templates/kart/vite.config.ts +2 -0
- package/templates/minimal/AGENTS.md +105 -84
- package/templates/minimal/CLAUDE.md +105 -84
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/stands-still.playtest.json +30 -0
- package/templates/minimal/src/game.ts +1 -1
- package/templates/minimal/src/render/atmosphere.ts +11 -16
- package/templates/minimal/src/render/backlightControls.ts +10 -0
- package/templates/minimal/src/render/backlightMaterial.ts +4 -4
- package/templates/minimal/src/render/camera.ts +13 -2
- package/templates/minimal/src/render/clouds.ts +13 -0
- package/templates/minimal/src/render/gpuSky.ts +4 -7
- package/templates/minimal/src/render/lighting.ts +4 -2
- package/templates/minimal/src/render/materialLighting.ts +5 -5
- package/templates/minimal/src/render/materials.ts +10 -0
- package/templates/minimal/src/render/quality.ts +7 -32
- package/templates/minimal/src/scenes/Play.ts +4 -1
- package/templates/minimal/vite.config.ts +7 -1
- package/templates/platformer/AGENTS.md +95 -46
- package/templates/platformer/CLAUDE.md +95 -46
- package/templates/platformer/index.html +1 -1
- package/templates/platformer/main.html +12 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/gamepad-idle.playtest.json +21 -0
- package/templates/platformer/playtests/gamepad.playtest.json +30 -0
- package/templates/platformer/src/entities/Fox.ts +21 -6
- package/templates/platformer/src/game.ts +1 -1
- package/templates/platformer/src/main.ts +1 -0
- package/templates/platformer/src/render/backlightControls.ts +10 -0
- package/templates/platformer/src/render/backlightMaterial.ts +4 -4
- package/templates/platformer/src/render/materialLighting.ts +5 -5
- package/templates/platformer/src/render/quality.ts +7 -32
- package/templates/platformer/src/scenes/Play.ts +2 -1
- package/templates/platformer/src/style.css +4 -0
- package/templates/platformer/src/worker-page.ts +29 -0
- package/templates/platformer/src/worker.ts +5 -0
- package/templates/platformer/tsconfig.json +1 -1
- package/templates/platformer/vite.config.ts +4 -0
- package/templates/puzzle/AGENTS.md +97 -80
- package/templates/puzzle/CLAUDE.md +97 -80
- package/templates/puzzle/package.json +7 -7
- package/templates/puzzle/src/game.ts +1 -1
- package/templates/puzzle/src/render/backlightControls.ts +10 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +4 -4
- package/templates/puzzle/src/render/materialLighting.ts +5 -5
- package/templates/puzzle/src/render/quality.ts +7 -32
- package/templates/puzzle/src/scenes/Play.ts +1 -1
- package/templates/puzzle/src/style.css +4 -0
- package/templates/puzzle/tsconfig.json +1 -1
- package/templates/puzzle/vite.config.ts +2 -0
- package/templates/racing/AGENTS.md +100 -82
- package/templates/racing/CLAUDE.md +100 -82
- package/templates/racing/package.json +7 -7
- package/templates/racing/src/game.ts +1 -1
- package/templates/racing/src/render/atmosphere.ts +11 -16
- package/templates/racing/src/render/backlightControls.ts +10 -0
- package/templates/racing/src/render/backlightMaterial.ts +4 -4
- package/templates/racing/src/render/clouds.ts +13 -0
- package/templates/racing/src/render/gpuSky.ts +4 -7
- package/templates/racing/src/render/materialLighting.ts +5 -5
- package/templates/racing/src/render/quality.ts +7 -32
- package/templates/racing/src/scenes/Race.ts +4 -1
- package/templates/racing/src/style.css +4 -0
- package/templates/racing/tsconfig.json +1 -1
- package/templates/racing/vite.config.ts +2 -0
- package/templates/rain/AGENTS.md +96 -84
- package/templates/rain/CLAUDE.md +96 -84
- package/templates/rain/native-playtests/lightning.playtest.json +85 -10
- package/templates/rain/package.json +6 -6
- package/templates/rain/playtests/reduced-motion.playtest.json +6 -0
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/scenes/Boot.ts +1 -0
- package/templates/rain/src/state.ts +7 -0
- package/templates/rain/src/ui/GameUi.tsx +7 -1
- package/templates/rain/vite.config.ts +6 -0
- package/templates/rts/AGENTS.md +100 -85
- package/templates/rts/CLAUDE.md +100 -85
- package/templates/rts/package.json +6 -6
- package/templates/rts/src/game.ts +1 -1
- package/templates/rts/src/render/backlightControls.ts +10 -0
- package/templates/rts/src/render/backlightMaterial.ts +4 -4
- package/templates/rts/src/render/materialLighting.ts +5 -5
- package/templates/rts/src/render/quality.ts +7 -31
- package/templates/rts/src/scenes/Play.ts +1 -1
- package/templates/rts/src/style.css +4 -0
- package/templates/rts/vite.config.ts +2 -0
- package/templates/runner/AGENTS.md +97 -80
- package/templates/runner/CLAUDE.md +97 -80
- package/templates/runner/package.json +7 -7
- package/templates/runner/playtests/performance.playtest.json +1 -1
- package/templates/runner/src/game.ts +1 -1
- package/templates/runner/src/render/atmosphere.ts +11 -16
- package/templates/runner/src/render/backlightControls.ts +10 -0
- package/templates/runner/src/render/backlightMaterial.ts +4 -4
- package/templates/runner/src/render/clouds.ts +13 -0
- package/templates/runner/src/render/gpuSky.ts +4 -7
- package/templates/runner/src/render/lighting.ts +53 -11
- package/templates/runner/src/render/materialLighting.ts +5 -5
- package/templates/runner/src/render/quality.ts +7 -32
- package/templates/runner/src/scenes/Run.ts +8 -4
- package/templates/runner/src/style.css +4 -0
- package/templates/runner/threenative.config.ts +0 -3
- package/templates/runner/tsconfig.json +1 -1
- package/templates/runner/vite.config.ts +2 -0
- package/templates/sailing/AGENTS.md +96 -79
- package/templates/sailing/CLAUDE.md +96 -79
- package/templates/sailing/package.json +7 -7
- package/templates/sailing/playtests/sails.playtest.json +1 -0
- package/templates/sailing/src/game.ts +1 -1
- package/templates/sailing/src/render/backlightControls.ts +10 -0
- package/templates/sailing/src/render/backlightMaterial.ts +4 -4
- package/templates/sailing/src/render/environmentSetup.ts +1 -1
- package/templates/sailing/src/render/materialLighting.ts +5 -5
- package/templates/sailing/src/render/quality.ts +7 -32
- package/templates/sailing/src/render/sky.ts +4 -0
- package/templates/sailing/src/style.css +5 -0
- package/templates/sailing/threenative.config.ts +0 -3
- package/templates/sailing/vite.config.ts +6 -0
- package/templates/shooter/AGENTS.md +97 -68
- package/templates/shooter/CLAUDE.md +97 -68
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/src/game.ts +3 -2
- package/templates/shooter/src/render/atmosphere.ts +11 -16
- package/templates/shooter/src/render/backlightControls.ts +10 -0
- package/templates/shooter/src/render/backlightMaterial.ts +4 -4
- package/templates/shooter/src/render/clouds.ts +13 -0
- package/templates/shooter/src/render/gpuSky.ts +4 -7
- package/templates/shooter/src/render/materialLighting.ts +5 -5
- package/templates/shooter/src/render/quality.ts +10 -33
- package/templates/shooter/src/scenes/Play.ts +4 -1
- package/templates/shooter/src/style.css +4 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/AGENTS.md +95 -76
- package/templates/snow/CLAUDE.md +95 -76
- package/templates/snow/package.json +7 -7
- package/templates/snow/src/game.ts +1 -1
- package/templates/snow/src/render/backlightControls.ts +10 -0
- package/templates/snow/src/render/backlightMaterial.ts +4 -4
- package/templates/snow/src/render/materialLighting.ts +5 -5
- package/templates/snow/src/render/quality.ts +7 -32
- package/templates/snow/src/style.css +5 -0
- package/templates/snow/threenative.config.ts +0 -3
- package/templates/snow/vite.config.ts +6 -0
- package/templates/starter/AGENTS.md +109 -88
- package/templates/starter/CLAUDE.md +109 -88
- package/templates/starter/native-playtests/render-chain.playtest.json +24 -24
- package/templates/starter/native-playtests/smooth-motion.playtest.json +3 -3
- package/templates/starter/package.json +7 -7
- package/templates/starter/src/entities/Crate.ts +5 -2
- package/templates/starter/src/entities/Player.ts +10 -22
- package/templates/starter/src/game.ts +4 -3
- package/templates/starter/src/render/adaptiveQuality.ts +17 -0
- package/templates/starter/src/render/atmosphere.ts +11 -16
- package/templates/starter/src/render/backlightControls.ts +10 -0
- package/templates/starter/src/render/backlightMaterial.ts +4 -4
- package/templates/starter/src/render/clouds.ts +13 -0
- package/templates/starter/src/render/contactShadow.ts +1 -1
- package/templates/starter/src/render/gpuSky.ts +4 -7
- package/templates/starter/src/render/lighting.ts +54 -4
- package/templates/starter/src/render/materialLighting.ts +5 -5
- package/templates/starter/src/render/postprocessing.ts +11 -10
- package/templates/starter/src/render/quality.ts +14 -1
- package/templates/starter/src/render/temporalAA.ts +8 -7
- package/templates/starter/src/render/temporalAAFrame.ts +30 -9
- package/templates/starter/src/render/temporalAAResolve.ts +15 -1
- package/templates/starter/src/render/temporalClampRelease.ts +183 -0
- package/templates/starter/src/render/temporalHistoryResolve.ts +90 -0
- package/templates/starter/src/render/temporalMoire.ts +190 -0
- package/templates/starter/src/render/temporalResolve.ts +75 -16
- package/templates/starter/src/render/temporalResolveDepth.ts +2 -0
- package/templates/starter/src/scenes/Play.ts +53 -32
- package/templates/starter/src/state.ts +2 -0
- package/templates/starter/src/style.css +4 -0
- package/templates/starter/src/ui/Menu.tsx +5 -1
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/AGENTS.md +97 -81
- package/templates/tower-defense/CLAUDE.md +97 -81
- package/templates/tower-defense/package.json +7 -7
- package/templates/tower-defense/src/game.ts +1 -1
- package/templates/tower-defense/src/render/backlightControls.ts +10 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +4 -4
- package/templates/tower-defense/src/render/materialLighting.ts +5 -5
- package/templates/tower-defense/src/render/quality.ts +7 -32
- package/templates/tower-defense/src/scenes/Battle.ts +1 -1
- package/templates/tower-defense/src/style.css +4 -0
- package/templates/tower-defense/tsconfig.json +1 -1
- package/templates/tower-defense/vite.config.ts +2 -0
- package/capabilities.json +0 -9197
- package/templates/AGENTS.md +0 -21
- package/templates/CLAUDE.md +0 -23
- package/templates/action-rpg/.codex/config.toml +0 -23
- package/templates/action-rpg/.cursor/mcp.json +0 -38
- package/templates/action-rpg/.gemini/settings.json +0 -38
- package/templates/action-rpg/.mcp.json +0 -38
- package/templates/action-rpg/.vscode/mcp.json +0 -43
- package/templates/action-rpg/.zed/settings.json +0 -43
- package/templates/action-rpg/opencode.json +0 -49
- package/templates/action-rpg/src/render/environmentContribution.ts +0 -188
- package/templates/action-rpg/src/render/environmentRadiance.ts +0 -36
- package/templates/action-rpg/src/render/environmentSampleCache.ts +0 -43
- package/templates/action-rpg/src/render/environmentSampling.ts +0 -193
- package/templates/action-rpg/src/render/environmentSnapshot.ts +0 -53
- package/templates/adventure/.codex/config.toml +0 -23
- package/templates/adventure/.cursor/mcp.json +0 -38
- package/templates/adventure/.gemini/settings.json +0 -38
- package/templates/adventure/.mcp.json +0 -38
- package/templates/adventure/.vscode/mcp.json +0 -43
- package/templates/adventure/.zed/settings.json +0 -43
- package/templates/adventure/opencode.json +0 -49
- package/templates/collectathon/.codex/config.toml +0 -23
- package/templates/collectathon/.cursor/mcp.json +0 -38
- package/templates/collectathon/.gemini/settings.json +0 -38
- package/templates/collectathon/.mcp.json +0 -38
- package/templates/collectathon/.vscode/mcp.json +0 -43
- package/templates/collectathon/.zed/settings.json +0 -43
- package/templates/collectathon/opencode.json +0 -49
- package/templates/kart/.codex/config.toml +0 -23
- package/templates/kart/.cursor/mcp.json +0 -38
- package/templates/kart/.gemini/settings.json +0 -38
- package/templates/kart/.mcp.json +0 -38
- package/templates/kart/.vscode/mcp.json +0 -43
- package/templates/kart/.zed/settings.json +0 -43
- package/templates/kart/opencode.json +0 -49
- package/templates/minimal/.codex/config.toml +0 -23
- package/templates/minimal/.cursor/mcp.json +0 -38
- package/templates/minimal/.gemini/settings.json +0 -38
- package/templates/minimal/.mcp.json +0 -38
- package/templates/minimal/.vscode/mcp.json +0 -43
- package/templates/minimal/.zed/settings.json +0 -43
- package/templates/minimal/opencode.json +0 -49
- package/templates/minimal/src/render/environmentContribution.ts +0 -188
- package/templates/minimal/src/render/environmentRadiance.ts +0 -36
- package/templates/minimal/src/render/environmentSampleCache.ts +0 -43
- package/templates/minimal/src/render/environmentSampling.ts +0 -193
- package/templates/minimal/src/render/environmentSnapshot.ts +0 -53
- package/templates/platformer/.codex/config.toml +0 -23
- package/templates/platformer/.cursor/mcp.json +0 -38
- package/templates/platformer/.gemini/settings.json +0 -38
- package/templates/platformer/.mcp.json +0 -38
- package/templates/platformer/.vscode/mcp.json +0 -43
- package/templates/platformer/.zed/settings.json +0 -43
- package/templates/platformer/opencode.json +0 -49
- package/templates/platformer/src/render/environmentContribution.ts +0 -188
- package/templates/platformer/src/render/environmentRadiance.ts +0 -36
- package/templates/platformer/src/render/environmentSampleCache.ts +0 -43
- package/templates/platformer/src/render/environmentSampling.ts +0 -193
- package/templates/platformer/src/render/environmentSnapshot.ts +0 -53
- package/templates/puzzle/.codex/config.toml +0 -23
- package/templates/puzzle/.cursor/mcp.json +0 -38
- package/templates/puzzle/.gemini/settings.json +0 -38
- package/templates/puzzle/.mcp.json +0 -38
- package/templates/puzzle/.vscode/mcp.json +0 -43
- package/templates/puzzle/.zed/settings.json +0 -43
- package/templates/puzzle/opencode.json +0 -49
- package/templates/puzzle/src/render/environmentContribution.ts +0 -188
- package/templates/puzzle/src/render/environmentRadiance.ts +0 -36
- package/templates/puzzle/src/render/environmentSampleCache.ts +0 -43
- package/templates/puzzle/src/render/environmentSampling.ts +0 -193
- package/templates/puzzle/src/render/environmentSnapshot.ts +0 -53
- package/templates/racing/.codex/config.toml +0 -23
- package/templates/racing/.cursor/mcp.json +0 -38
- package/templates/racing/.gemini/settings.json +0 -38
- package/templates/racing/.mcp.json +0 -38
- package/templates/racing/.vscode/mcp.json +0 -43
- package/templates/racing/.zed/settings.json +0 -43
- package/templates/racing/opencode.json +0 -49
- package/templates/racing/src/render/environmentContribution.ts +0 -188
- package/templates/racing/src/render/environmentRadiance.ts +0 -36
- package/templates/racing/src/render/environmentSampleCache.ts +0 -43
- package/templates/racing/src/render/environmentSampling.ts +0 -193
- package/templates/racing/src/render/environmentSnapshot.ts +0 -53
- package/templates/rain/.codex/config.toml +0 -23
- package/templates/rain/.cursor/mcp.json +0 -38
- package/templates/rain/.gemini/settings.json +0 -38
- package/templates/rain/.mcp.json +0 -38
- package/templates/rain/.vscode/mcp.json +0 -43
- package/templates/rain/.zed/settings.json +0 -43
- package/templates/rain/opencode.json +0 -49
- package/templates/rts/.codex/config.toml +0 -23
- package/templates/rts/.cursor/mcp.json +0 -38
- package/templates/rts/.gemini/settings.json +0 -38
- package/templates/rts/.mcp.json +0 -38
- package/templates/rts/.vscode/mcp.json +0 -43
- package/templates/rts/.zed/settings.json +0 -43
- package/templates/rts/opencode.json +0 -49
- package/templates/rts/src/render/environmentContribution.ts +0 -188
- package/templates/rts/src/render/environmentRadiance.ts +0 -36
- package/templates/rts/src/render/environmentSampleCache.ts +0 -43
- package/templates/rts/src/render/environmentSampling.ts +0 -193
- package/templates/rts/src/render/environmentSnapshot.ts +0 -53
- package/templates/runner/.codex/config.toml +0 -23
- package/templates/runner/.cursor/mcp.json +0 -38
- package/templates/runner/.gemini/settings.json +0 -38
- package/templates/runner/.mcp.json +0 -38
- package/templates/runner/.vscode/mcp.json +0 -43
- package/templates/runner/.zed/settings.json +0 -43
- package/templates/runner/README.md +0 -43
- package/templates/runner/opencode.json +0 -49
- package/templates/runner/src/render/environmentContribution.ts +0 -188
- package/templates/runner/src/render/environmentRadiance.ts +0 -36
- package/templates/runner/src/render/environmentSampleCache.ts +0 -43
- package/templates/runner/src/render/environmentSampling.ts +0 -193
- package/templates/runner/src/render/environmentSnapshot.ts +0 -53
- package/templates/sailing/.codex/config.toml +0 -23
- package/templates/sailing/.cursor/mcp.json +0 -38
- package/templates/sailing/.gemini/settings.json +0 -38
- package/templates/sailing/.mcp.json +0 -38
- package/templates/sailing/.vscode/mcp.json +0 -43
- package/templates/sailing/.zed/settings.json +0 -43
- package/templates/sailing/README.md +0 -28
- package/templates/sailing/opencode.json +0 -49
- package/templates/sailing/src/render/environmentContribution.ts +0 -188
- package/templates/sailing/src/render/environmentRadiance.ts +0 -36
- package/templates/sailing/src/render/environmentSampleCache.ts +0 -43
- package/templates/sailing/src/render/environmentSampling.ts +0 -193
- package/templates/sailing/src/render/environmentSnapshot.ts +0 -53
- package/templates/shooter/.codex/config.toml +0 -23
- package/templates/shooter/.cursor/mcp.json +0 -38
- package/templates/shooter/.gemini/settings.json +0 -38
- package/templates/shooter/.mcp.json +0 -38
- package/templates/shooter/.vscode/mcp.json +0 -43
- package/templates/shooter/.zed/settings.json +0 -43
- package/templates/shooter/opencode.json +0 -49
- package/templates/shooter/src/render/environmentContribution.ts +0 -188
- package/templates/shooter/src/render/environmentRadiance.ts +0 -36
- package/templates/shooter/src/render/environmentSampleCache.ts +0 -43
- package/templates/shooter/src/render/environmentSampling.ts +0 -193
- package/templates/shooter/src/render/environmentSnapshot.ts +0 -53
- package/templates/snow/.codex/config.toml +0 -23
- package/templates/snow/.cursor/mcp.json +0 -38
- package/templates/snow/.gemini/settings.json +0 -38
- package/templates/snow/.mcp.json +0 -38
- package/templates/snow/.vscode/mcp.json +0 -43
- package/templates/snow/.zed/settings.json +0 -43
- package/templates/snow/README.md +0 -26
- package/templates/snow/opencode.json +0 -49
- package/templates/snow/src/render/environmentContribution.ts +0 -188
- package/templates/snow/src/render/environmentRadiance.ts +0 -36
- package/templates/snow/src/render/environmentSampleCache.ts +0 -43
- package/templates/snow/src/render/environmentSampling.ts +0 -193
- package/templates/snow/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/.codex/config.toml +0 -23
- package/templates/starter/.cursor/mcp.json +0 -38
- package/templates/starter/.gemini/settings.json +0 -38
- package/templates/starter/.mcp.json +0 -38
- package/templates/starter/.vscode/mcp.json +0 -43
- package/templates/starter/.zed/settings.json +0 -43
- package/templates/starter/opencode.json +0 -49
- package/templates/starter/src/render/environmentContribution.ts +0 -188
- package/templates/starter/src/render/environmentRadiance.ts +0 -36
- package/templates/starter/src/render/environmentSampleCache.ts +0 -43
- package/templates/starter/src/render/environmentSampling.ts +0 -193
- package/templates/starter/src/render/environmentSnapshot.ts +0 -53
- package/templates/starter/src/render/rendererGate.ts +0 -36
- package/templates/tower-defense/.codex/config.toml +0 -23
- package/templates/tower-defense/.cursor/mcp.json +0 -38
- package/templates/tower-defense/.gemini/settings.json +0 -38
- package/templates/tower-defense/.mcp.json +0 -38
- package/templates/tower-defense/.vscode/mcp.json +0 -43
- package/templates/tower-defense/.zed/settings.json +0 -43
- package/templates/tower-defense/README.md +0 -16
- package/templates/tower-defense/opencode.json +0 -49
- package/templates/tower-defense/src/render/environmentContribution.ts +0 -188
- package/templates/tower-defense/src/render/environmentRadiance.ts +0 -36
- package/templates/tower-defense/src/render/environmentSampleCache.ts +0 -43
- package/templates/tower-defense/src/render/environmentSampling.ts +0 -193
- package/templates/tower-defense/src/render/environmentSnapshot.ts +0 -53
|
@@ -92,7 +92,7 @@ const smooth = (from: number, to: number, value: number): number => {
|
|
|
92
92
|
* flatten toward the horizon. Each is lit by where its density climbs: a texel whose deck is
|
|
93
93
|
* denser toward the sun, or above it on screen, is on the cloud's shaded side or its flat base.
|
|
94
94
|
*/
|
|
95
|
-
export function
|
|
95
|
+
export function skyPixels(saturation = 1, width = 2048): Uint8Array {
|
|
96
96
|
// three's PMREM sizes its cube from width / 4 and needs at least 16: keep width >= 64.
|
|
97
97
|
const height = width / 2;
|
|
98
98
|
const data = new Uint8Array(width * height * 4);
|
|
@@ -109,6 +109,14 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
109
109
|
let baseR = 0;
|
|
110
110
|
let baseG = 0;
|
|
111
111
|
let baseB = 0;
|
|
112
|
+
// Each column's azimuth terms, once: the same numbers every row reads.
|
|
113
|
+
const cosAzimuth = new Float64Array(width);
|
|
114
|
+
const sinAzimuth = new Float64Array(width);
|
|
115
|
+
for (let column = 0; column < width; column += 1) {
|
|
116
|
+
const azimuth = (column / width - 0.5) * Math.PI * 2;
|
|
117
|
+
cosAzimuth[column] = Math.cos(azimuth);
|
|
118
|
+
sinAzimuth[column] = Math.sin(azimuth);
|
|
119
|
+
}
|
|
112
120
|
// Pass 1: the deck's density under every cloud-band texel, once (the shading reads neighbours).
|
|
113
121
|
const deck = new Float32Array(width * height);
|
|
114
122
|
const bands = new Float32Array(height);
|
|
@@ -120,8 +128,10 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
120
128
|
// Flattened less than a true deck would be: cumulus heaps stand tall, they are not a sheet.
|
|
121
129
|
const reach = (1 / (Math.tan(elevation) + 0.1)) ** 0.7 * 0.75;
|
|
122
130
|
for (let column = 0; column < width; column += 1) {
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
deck[row * width + column] = density(
|
|
132
|
+
(cosAzimuth[column] as number) * reach,
|
|
133
|
+
(sinAzimuth[column] as number) * reach,
|
|
134
|
+
);
|
|
125
135
|
}
|
|
126
136
|
}
|
|
127
137
|
// The cumulus banks over the far hills, per column: where a bank stands (`cluster`), its heaped
|
|
@@ -142,6 +152,12 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
142
152
|
const step = Math.max(1, Math.round(width / 512));
|
|
143
153
|
const sunAzimuth = Math.atan2(SUN_DIRECTION.z, SUN_DIRECTION.x);
|
|
144
154
|
const sunElevation = Math.asin(SUN_DIRECTION.y);
|
|
155
|
+
// Which way the sun lies from each column, once.
|
|
156
|
+
const sunward = new Int8Array(width);
|
|
157
|
+
for (let column = 0; column < width; column += 1) {
|
|
158
|
+
const azimuth = (column / width - 0.5) * Math.PI * 2;
|
|
159
|
+
sunward[column] = Math.sin(sunAzimuth - azimuth) > 0 ? 1 : -1;
|
|
160
|
+
}
|
|
145
161
|
for (let row = 0; row < height; row += 1) {
|
|
146
162
|
const elevation = (row / (height - 1) - 0.5) * Math.PI;
|
|
147
163
|
const up = Math.sin(elevation);
|
|
@@ -171,9 +187,10 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
171
187
|
);
|
|
172
188
|
for (let column = 0; column < width; column += 1) {
|
|
173
189
|
// three's equirectangular u: azimuth from +X toward +Z, u = 0.5 on +X.
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
const
|
|
190
|
+
const cosA = cosAzimuth[column] as number;
|
|
191
|
+
const sinA = sinAzimuth[column] as number;
|
|
192
|
+
const tx = cosA * cosE;
|
|
193
|
+
const tz = sinA * cosE;
|
|
177
194
|
// The sun's halo: a warm glow round its direction, wider than the disc the lens never sees.
|
|
178
195
|
const sun = Math.max(0, tx * SUN_DIRECTION.x + up * SUN_DIRECTION.y + tz * SUN_DIRECTION.z);
|
|
179
196
|
const halo = 0.6 * sun ** 32 + 0.22 * sun ** 5;
|
|
@@ -183,7 +200,7 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
183
200
|
const d = deck[row * width + column] ?? 0;
|
|
184
201
|
const cover = band > 0 ? smooth(0.43, 0.54, d) * band : 0;
|
|
185
202
|
if (cover > 0.002) {
|
|
186
|
-
const turn =
|
|
203
|
+
const turn = (sunward[column] as number) * step;
|
|
187
204
|
const towardColumn = (column + turn + width) % width;
|
|
188
205
|
// Denser a step toward the sun: the far side of a heap. Denser a step up the sky: its base.
|
|
189
206
|
const toward = (deck[towardRow * width + towardColumn] ?? 0) - d;
|
|
@@ -202,8 +219,7 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
202
219
|
if (elevation > foot && elevation < top + 0.05) {
|
|
203
220
|
// Billowed outline: finer noise lifts and bites the heap's top edge.
|
|
204
221
|
// Elevation moves radially and azimuth round the circle: round puffs, and azimuth wraps.
|
|
205
|
-
const puff = (e: number) =>
|
|
206
|
-
fbm(Math.cos(azimuth) * (14 + e * 15), Math.sin(azimuth) * (14 + e * 15), 3);
|
|
222
|
+
const puff = (e: number) => fbm(cosA * (14 + e * 15), sinA * (14 + e * 15), 3);
|
|
207
223
|
const lump = puff(elevation);
|
|
208
224
|
const below = top + (lump - 0.5) * 0.11 - elevation;
|
|
209
225
|
const inside = smooth(0, 0.02, below) * smooth(foot, foot + 0.012, elevation);
|
|
@@ -225,12 +241,27 @@ export function skyTexture(saturation = 1, width = 2048): DataTexture {
|
|
|
225
241
|
}
|
|
226
242
|
const grey = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
227
243
|
const i = (row * width + column) * 4;
|
|
228
|
-
data[i] =
|
|
229
|
-
data[i + 1] =
|
|
230
|
-
data[i + 2] =
|
|
244
|
+
data[i] = srgbByte(r + (grey - r) * (1 - saturation));
|
|
245
|
+
data[i + 1] = srgbByte(g + (grey - g) * (1 - saturation));
|
|
246
|
+
data[i + 2] = srgbByte(b + (grey - b) * (1 - saturation));
|
|
231
247
|
data[i + 3] = 255;
|
|
232
248
|
}
|
|
233
249
|
}
|
|
250
|
+
return data;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The sky as a texture. `data` is `skyPixels(saturation, width)`; the scene passes the copy it kept
|
|
255
|
+
* from the last run (`ctx.assets.memo`), because painting four million texels costs a run ~0.3 s.
|
|
256
|
+
*/
|
|
257
|
+
export function skyTexture(
|
|
258
|
+
saturation = 1,
|
|
259
|
+
width = 2048,
|
|
260
|
+
data: Uint8Array = skyPixels(saturation, width),
|
|
261
|
+
): DataTexture {
|
|
262
|
+
const height = width / 2;
|
|
263
|
+
if (data.length !== width * height * 4)
|
|
264
|
+
throw new Error(`sky pixels are ${data.length} bytes, expected ${width * height * 4}.`);
|
|
234
265
|
const sky = new DataTexture(data, width, height, RGBAFormat, UnsignedByteType);
|
|
235
266
|
sky.mapping = EquirectangularReflectionMapping;
|
|
236
267
|
sky.colorSpace = SRGBColorSpace;
|
|
@@ -247,6 +278,39 @@ function linearToSrgb(value: number): number {
|
|
|
247
278
|
return v < 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055;
|
|
248
279
|
}
|
|
249
280
|
|
|
281
|
+
/**
|
|
282
|
+
* `Math.round(255 * linearToSrgb(value))` for millions of texels: the byte only steps up as the
|
|
283
|
+
* value grows, so the smallest value of each step, found once, gives the same byte with no power.
|
|
284
|
+
*/
|
|
285
|
+
const SRGB_STEPS = (() => {
|
|
286
|
+
const byte = (value: number) => Math.round(255 * linearToSrgb(value));
|
|
287
|
+
const steps = new Float64Array(256);
|
|
288
|
+
for (let level = 1; level < 256; level += 1) {
|
|
289
|
+
let low = 0;
|
|
290
|
+
let high = 1;
|
|
291
|
+
// Halve until the two ends are adjacent doubles: `high` is then the step's first value.
|
|
292
|
+
for (;;) {
|
|
293
|
+
const middle = low + (high - low) / 2;
|
|
294
|
+
if (middle === low || middle === high) break;
|
|
295
|
+
if (byte(middle) >= level) high = middle;
|
|
296
|
+
else low = middle;
|
|
297
|
+
}
|
|
298
|
+
steps[level] = high;
|
|
299
|
+
}
|
|
300
|
+
return steps;
|
|
301
|
+
})();
|
|
302
|
+
|
|
303
|
+
function srgbByte(value: number): number {
|
|
304
|
+
let low = 0;
|
|
305
|
+
let high = 255;
|
|
306
|
+
while (low < high) {
|
|
307
|
+
const middle = (low + high + 1) >> 1;
|
|
308
|
+
if (value >= (SRGB_STEPS[middle] as number)) low = middle;
|
|
309
|
+
else high = middle - 1;
|
|
310
|
+
}
|
|
311
|
+
return low;
|
|
312
|
+
}
|
|
313
|
+
|
|
250
314
|
/** `fill` is the environment light: by default the sky itself, in this game `skyTexture(0.3, 128)`. */
|
|
251
315
|
export function setupSky(scene: Scene, sky: DataTexture, fill: DataTexture = sky): void {
|
|
252
316
|
scene.background = sky;
|
|
@@ -85,12 +85,39 @@ function depthMap(floor: ISeaFloor): DataTexture {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/** Tiling ripples: periodic value noise, its slope in red/green and its height in alpha. */
|
|
88
|
+
const RIPPLE_SIZE = 256;
|
|
89
|
+
let primedRipples: Uint8Array | undefined;
|
|
90
|
+
/** Hand the ripple pixels back from a store (`ctx.assets.memo`), so `seaMaterial` skips painting them. */
|
|
91
|
+
export function primeRipplePixels(pixels: Uint8Array): void {
|
|
92
|
+
if (pixels.length !== RIPPLE_SIZE * RIPPLE_SIZE * 4)
|
|
93
|
+
throw new Error("ripple pixels do not match RIPPLE_SIZE.");
|
|
94
|
+
primedRipples = pixels;
|
|
95
|
+
}
|
|
88
96
|
function rippleMap(): DataTexture {
|
|
89
|
-
const n =
|
|
97
|
+
const n = RIPPLE_SIZE;
|
|
98
|
+
const map = new DataTexture(primedRipples ?? ripplePixels(), n, n);
|
|
99
|
+
map.wrapS = RepeatWrapping;
|
|
100
|
+
map.wrapT = RepeatWrapping;
|
|
101
|
+
map.magFilter = LinearFilter;
|
|
102
|
+
map.minFilter = LinearMipmapLinearFilter;
|
|
103
|
+
map.generateMipmaps = true;
|
|
104
|
+
map.needsUpdate = true;
|
|
105
|
+
return map;
|
|
106
|
+
}
|
|
107
|
+
/** The sea's ripple normal (RG) and height (A), the same every run: no input, no randomness. */
|
|
108
|
+
export function ripplePixels(): Uint8Array {
|
|
109
|
+
const n = RIPPLE_SIZE;
|
|
90
110
|
const hash = (x: number, z: number): number => {
|
|
91
111
|
const a = Math.sin(x * 127.1 + z * 311.7) * 43758.5453;
|
|
92
112
|
return a - Math.floor(a);
|
|
93
113
|
};
|
|
114
|
+
// Each octave's lattice is k x k whole points, hashed once: a texel reads 64 of them.
|
|
115
|
+
const lattices = new Map<number, Float64Array>();
|
|
116
|
+
for (const k of [8, 16, 32, 64]) {
|
|
117
|
+
const lattice = new Float64Array(k * k);
|
|
118
|
+
for (let x = 0; x < k; x += 1) for (let z = 0; z < k; z += 1) lattice[x * k + z] = hash(x, z);
|
|
119
|
+
lattices.set(k, lattice);
|
|
120
|
+
}
|
|
94
121
|
const noise = (u: number, v: number, k: number): number => {
|
|
95
122
|
const x = u * k;
|
|
96
123
|
const z = v * k;
|
|
@@ -100,7 +127,9 @@ function rippleMap(): DataTexture {
|
|
|
100
127
|
let b = z - j;
|
|
101
128
|
a = a * a * a * (a * (a * 6 - 15) + 10);
|
|
102
129
|
b = b * b * b * (b * (b * 6 - 15) + 10);
|
|
103
|
-
const
|
|
130
|
+
const lattice = lattices.get(k) as Float64Array;
|
|
131
|
+
const h = (hx: number, hz: number): number =>
|
|
132
|
+
lattice[(((hx % k) + k) % k) * k + (((hz % k) + k) % k)] as number;
|
|
104
133
|
return (
|
|
105
134
|
(h(i, j) * (1 - a) + h(i + 1, j) * a) * (1 - b) +
|
|
106
135
|
(h(i, j + 1) * (1 - a) + h(i + 1, j + 1) * a) * b
|
|
@@ -126,14 +155,7 @@ function rippleMap(): DataTexture {
|
|
|
126
155
|
data[at + 3] = height(u, v) * 255;
|
|
127
156
|
}
|
|
128
157
|
}
|
|
129
|
-
|
|
130
|
-
map.wrapS = RepeatWrapping;
|
|
131
|
-
map.wrapT = RepeatWrapping;
|
|
132
|
-
map.magFilter = LinearFilter;
|
|
133
|
-
map.minFilter = LinearMipmapLinearFilter;
|
|
134
|
-
map.generateMipmaps = true;
|
|
135
|
-
map.needsUpdate = true;
|
|
136
|
-
return map;
|
|
158
|
+
return data;
|
|
137
159
|
}
|
|
138
160
|
|
|
139
161
|
export function seaMaterial(floor: ISeaFloor, swell: ISwell): MeshStandardNodeMaterial {
|
|
@@ -25,9 +25,10 @@ import { setupLighting } from "../render/lighting.js";
|
|
|
25
25
|
import { createLoadingScreen } from "../render/loading.js";
|
|
26
26
|
import { postTier, setupPost } from "../render/postprocessing.js";
|
|
27
27
|
import { GRASS_SHARE } from "../render/quality.js";
|
|
28
|
-
import { setupSky, skyTexture } from "../render/sky.js";
|
|
28
|
+
import { setupSky, skyPixels, skyTexture } from "../render/sky.js";
|
|
29
29
|
import { loadSurfaces, updateSurfaceSampling } from "../render/surface.js";
|
|
30
30
|
import { TouchControls } from "../render/touch-controls.js";
|
|
31
|
+
import { primeRipplePixels, ripplePixels } from "../render/water.js";
|
|
31
32
|
import { type GameState, HUD_PILL } from "../state.js";
|
|
32
33
|
|
|
33
34
|
export type { GameCtx };
|
|
@@ -90,16 +91,28 @@ export class Play extends Scene<GameState, IPhysicsContext> {
|
|
|
90
91
|
this.#loading = createLoadingScreen(ctx);
|
|
91
92
|
// The HUD is page UI the cover cannot hide, so it waits for the same readiness.
|
|
92
93
|
void ctx.startup.whenReady().then(() => ctx.state.set({ loaded: true }));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// The sky is the same every run of this build: paint it once, then read the pixels back. A first
|
|
95
|
+
// visit paints it (~600 ms on a laptop) while the surface textures download, not after them.
|
|
96
|
+
const [surfaces, painted] = await Promise.all([
|
|
97
|
+
loadSurfaces(ctx.assets),
|
|
98
|
+
ctx.assets.memo("sky", () => ({
|
|
99
|
+
fill: skyPixels(0.3, 128),
|
|
100
|
+
ripples: ripplePixels(),
|
|
101
|
+
sky: skyPixels(),
|
|
102
|
+
})),
|
|
103
|
+
]);
|
|
104
|
+
primeRipplePixels(painted.ripples);
|
|
105
|
+
this.#sky = skyTexture(1, 2048, painted.sky);
|
|
106
|
+
this.#fill = skyTexture(0.3, 128, painted.fill);
|
|
96
107
|
setupSky(ctx.scene, this.#sky, this.#fill);
|
|
97
108
|
const tier = postTier({
|
|
98
109
|
gpuClass: ctx.renderer.gpuClass?.class,
|
|
99
110
|
mobile: isMobile(),
|
|
100
111
|
software: ctx.renderer.softwareAdapter !== undefined,
|
|
101
112
|
});
|
|
102
|
-
|
|
113
|
+
// The island is the same every run of this build: the first run draws it, a repeat reads it
|
|
114
|
+
// back from `ctx.assets.memo` (~105 ms of the load on a laptop).
|
|
115
|
+
const course = await buildCourse(makeRng(6402), surfaces, GRASS_SHARE[tier], ctx.assets.memo);
|
|
103
116
|
this.#course = course;
|
|
104
117
|
ctx.add(course.group);
|
|
105
118
|
ctx.entities.add("course", { debug: () => course.audit });
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
@source "../index.html";
|
|
4
4
|
@source "./";
|
|
5
|
+
/* `src/render/` is shader and material source: a word in its comments ("blur", "filter",
|
|
6
|
+
"table") became a real utility rule, which is what made a clean HUD look like a native-css
|
|
7
|
+
profile failure. Tailwind scans what it is told to scan. */
|
|
8
|
+
@source not "./render";
|
|
5
9
|
|
|
6
10
|
@theme {
|
|
7
11
|
--color-ink: #1d3a5c;
|
|
@@ -2,6 +2,7 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
2
2
|
import { watchAssets } from "@threenative/assets";
|
|
3
3
|
import react from "@vitejs/plugin-react";
|
|
4
4
|
import {
|
|
5
|
+
createEngineCatalogPlugin,
|
|
5
6
|
createEngineFreshnessPlugin,
|
|
6
7
|
createWebBrandPlugin,
|
|
7
8
|
webRuntimeDecoders,
|
|
@@ -36,6 +37,7 @@ export default defineConfig({
|
|
|
36
37
|
plugins: [
|
|
37
38
|
createEngineFreshnessPlugin(),
|
|
38
39
|
createWebBrandPlugin(),
|
|
40
|
+
createEngineCatalogPlugin(),
|
|
39
41
|
react(),
|
|
40
42
|
tailwindcss(),
|
|
41
43
|
assetsWatchPlugin(),
|
package/templates/kart/AGENTS.md
CHANGED
|
@@ -1,58 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- shared: kit-identity -->
|
|
2
|
+
# AGENTS.md — __PROJECT_NAME__ (Clover Cup, the kart kit)
|
|
2
3
|
|
|
3
|
-
Eight
|
|
4
|
+
Eight karts race three laps of Clover Loop, a figure-8 with a bridge, a jump over a creek and boost pads, with a hop into a power-slide, mini-turbo sparks, item boxes with burrs, acorns and nitro cans, and seven CPU drivers on a rubber band. Routing words: kart-racer, mario-kart, mariokart, mk64, kart. `CLAUDE.md` is a copy of this file.
|
|
5
|
+
<!-- /shared -->
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<!-- shared: kit-router -->
|
|
8
|
+
## Authoring flow
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
Detail for each step: `threenative-capabilities` skill. Do the steps in order. A step with no result records `none: <reason>`. A blank step blocks the next. A hook blocks the first new file under `src/` until step 3 ran for the current prompt (`TN_DISCOVERY_GATE=off` opts out; Codex needs `/hooks` trust).
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
1. **Kit** (new game only): `engine_search_capabilities {situation: "<the whole request>", scope: "request"}` returns the matching starter kit first. This folder is already a kit.
|
|
13
|
+
2. **Mechanics**: per mechanic, `engine_search_references {situation}`, then `engine_reference_detail` on each hit for pinned constants and feel. To see a mechanic move, `engine_watch_reference {query: "<game> <mechanic>"}` returns a contact sheet of real gameplay. Borrow mechanics only: no code, level layouts, character names or art. Cite `file:line`.
|
|
14
|
+
3. **Built-ins**: per mechanic, system or symptom, `engine_search_capabilities {situation, scope: "mechanic"}`; rows answer; `engine_capability_detail` only for omitted symbols. Constraints are binding. `verdict: "none"` means the game writes it in `src/`.
|
|
15
|
+
4. **Plan** (new game, or a change to several systems): `prd-creator` with the kit, references and built-ins. With a user, wait for explicit approval, then implement. With no user (`claude -p`, a script), record the plan and assumptions, then continue.
|
|
16
|
+
5. **Assets**: `asset_search_sources`, the source's search tool, then `asset_download_file`; record source and licence in `CREDITS.md`. Nothing fits: `sculpt_plan`. A rigged GLB: `animation_inspect` (`threenative-assets` skill).
|
|
17
|
+
6. **Build**: gameplay in `src/`, look in `src/render/` (`threenative-context` and `threenative-ui` skills). For parallel work, give each subagent one area and its files, then integrate.
|
|
18
|
+
7. **Prove**: one fail-closed playtest per mechanic, then `pnpm test` (`threenative-playtest` skill). A fresh judge compares a `--browser-recipe webgpu --headed` capture to the reference image (`threenative-visuals` skill; `node_modules/create-threenative/agent-docs/references/dream-loop.md`).
|
|
19
|
+
8. **Report**: the `pnpm dev` URL, `TN_FRAME_BUDGET`, `TN_SCENE_WARNING`, `TN_RENDER_PROJECTION`, and each skipped step with its reason.
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
3. Treat returned constraints as binding. This kit carries no physics package: a kart lives in track space (a place along the course's centre line plus metres right of it), so walls, surfaces, jumps and the lap counter are plain arithmetic on `src/track/Course.ts` and run the same on every target. `@threenative/physics/navigation` is browser-only WASM and the CPUs need none: they follow the centre line on a lane.
|
|
14
|
-
4. If a build, import, device, or blank frame fails, run `npx threenative doctor` and `npx @threenative/playtest doctor`; missing observations are not zero.
|
|
21
|
+
A change to an existing game repeats steps 2-3 for that change, then steps 5-8.
|
|
22
|
+
<!-- /shared -->
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
When an `@threenative/*` API is broken, missing, or does not do what you need, replace only that piece with portable Three.js/plain code. Keep the loop, scenes, input, registry, and playtest bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report what blocked you** (API, expectation, result, replacement); never stall the game.
|
|
24
|
+
<!-- shared: kit-mcp -->
|
|
25
|
+
## MCP servers
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
- `.agents/skills/prd-creator/SKILL.md` / `.claude/skills/prd-creator/SKILL.md` — game plan and approval gate.
|
|
22
|
-
- `.agents/skills/threenative-capabilities/SKILL.md` / `.claude/skills/threenative-capabilities/SKILL.md` — capability search and classic-game mechanics references.
|
|
23
|
-
- `.agents/skills/threenative-playtest/SKILL.md` / `.claude/skills/threenative-playtest/SKILL.md` — diagnosis and proof.
|
|
24
|
-
- `.agents/skills/threenative-assets/SKILL.md` / `.claude/skills/threenative-assets/SKILL.md` — assets and sculpting.
|
|
25
|
-
- `.agents/skills/threenative-visuals/SKILL.md` / `.claude/skills/threenative-visuals/SKILL.md` — captures and look.
|
|
26
|
-
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets; read it first when the game is slow or stutters: `playtest trace`, then the `threenative-devtools` MCP server.
|
|
27
|
-
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI. `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
28
|
-
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro. A game-side `patches/` fix is temporary: once it is settled, it moves into the engine in one PR. Lazy-first: `.agents/skills/ponytail/SKILL.md` / `.claude/skills/ponytail/SKILL.md` — smallest correct change, and its reuse rung is the capability search above. Engine: The owned C++ engine is the default for a new game: the Wasm engine on web and the engine player on desktop. This template runs on it: `threenative.config.ts` names no `engine`. `engine: "threejs"` switches to upstream Three.js only when the user asks for it; it is never a fix for a build error. Android and iOS use the legacy host.
|
|
29
|
-
## Commands and map
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
pnpm dev
|
|
33
|
-
pnpm build
|
|
34
|
-
pnpm build --target desktop
|
|
35
|
-
pnpm test # runs `pnpm check` first: typecheck, ESLint, Biome format
|
|
36
|
-
pnpm typecheck
|
|
37
|
-
```
|
|
27
|
+
`.mcp.json` wires six servers, and a session started in this folder loads them. Their tools can show as deferred: load them with `ToolSearch` `select:` plus the exact names, for example `select:mcp__threenative-engine__engine_search_capabilities,mcp__threenative-engine__engine_capability_detail,mcp__threenative-engine__engine_search_references,mcp__threenative-engine__engine_reference_detail,mcp__threenative-engine__engine_watch_reference`. A session started outside this folder runs `node node_modules/@threenative/core/mcp/call.mjs <server> <tool> '<json>'`; `call.mjs <server>` lists that server's tools.
|
|
38
28
|
|
|
39
|
-
|
|
29
|
+
- `threenative-engine`: before any new mechanic, helper or render stage, and on a slow frame or a wrong image. `engine_search_capabilities`, `engine_capability_detail`, `engine_search_references`, `engine_reference_detail`, `engine_watch_reference`.
|
|
30
|
+
- `threenative-assets`: a texture, HDRI, sound or model. `asset_search_sources`, `asset_download_file`, `audio_search_assets`, `mesh_optimize`.
|
|
31
|
+
- `threenative-sculpt`: a bespoke mesh or character from a reference image. `sculpt_plan`, `sculpt_spec_gate`, `sculpt_compare`, `sculpt_pass_gate`.
|
|
32
|
+
- `threenative-animation`: a rigged GLB with a held prop, foot slide or loop seam. `animation_inspect`, `animation_attach`, `animation_verify`.
|
|
33
|
+
- `threenative-terrain`: any terrain, from words. `terrain_generate`.
|
|
34
|
+
- `threenative-devtools`: after `npx @threenative/playtest trace` names no cause. `performance_start_trace`, `performance_analyze_insight`.
|
|
35
|
+
<!-- /shared -->
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
## This kit
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
<!-- shared: kit-files -->
|
|
40
|
+
Source in `src/`: `entities/`, `game.ts`, `main.ts`, `playtest-events.ts`, `render/`, `scenes/`, `state.ts`, `track/`, `ui/`.
|
|
41
|
+
15 scenarios in `playtests/`; `playtests/survives.playtest.json` is the smoke proof.
|
|
42
|
+
Kit notes: `node_modules/create-threenative/agent-docs/references/kit-kart.md`.
|
|
43
|
+
<!-- /shared -->
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
`KART_FEEL` in `src/entities/Kart.ts` is the one table of metres, seconds and ticks, each cited to its MK64 source; change a number and the pads, jump and walls change meaning. `Kart.step(input, dt)` is the whole model.
|
|
46
|
+
`playtests/explore.playtest.json` drives 7200 ticks of seeded random input; a new key binding joins its `move` or `actions`.
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
<!-- shared: kit-commands -->
|
|
49
|
+
## Commands
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
```sh
|
|
52
|
+
pnpm dev # play in the browser
|
|
53
|
+
pnpm test # typecheck, lint, format, then every playtest
|
|
54
|
+
pnpm build --target desktop # also: web, android, ios
|
|
55
|
+
pnpm studio # open the game in Studio
|
|
56
|
+
npx threenative doctor # build, import, device or blank-frame failure
|
|
57
|
+
npx threenative doctor --fix # refresh agent files
|
|
58
|
+
```
|
|
59
|
+
<!-- /shared -->
|
|
60
|
+
|
|
61
|
+
<!-- shared: kit-conventions -->
|
|
62
|
+
## Conventions
|
|
63
|
+
|
|
64
|
+
Each is on by default with a named override. Detail: `node_modules/create-threenative/agent-docs/references/conventions.md#<id>`.
|
|
65
|
+
|
|
66
|
+
- **Look** `#look`: filmic curve, metered auto exposure. Override: `tonemapMode: "aces"`; `autoExposureEnabled: false` + `exposure`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
67
|
+
- **Ambient occlusion** `#ao-indirect`: darkens indirect light only, not the sun. Override: `gtaoIndirectOnly: false`; `gtaoEnabled: false`. Marker: `TN_WORLD_ENVIRONMENT`.
|
|
68
|
+
- **Quality tier (`src/render/quality.ts`)** `#quality`: GPU class picks `high`, `medium` or `low`. Override: `setupPost(..., { tier: "low" })`. Marker: `TN_QUALITY_TIER`.
|
|
69
|
+
- **Resolution scale** `#resolution`: `"auto"`, 0.85 on mobile-low. Override: numeric `resolutionScale`. Marker: `TN_FRAME_BUDGET`.
|
|
70
|
+
- **Budget real time for the look** `#frame-budget`: frame meter and scene verdict on. Override: `frameBudget: false`. Marker: `TN_FRAME_BUDGET`, `TN_SCENE_WARNING`.
|
|
71
|
+
- **Anti-aliasing** `#aa`: 4x MSAA on `high`, else SMAA. Override: `temporalAA: true`.
|
|
72
|
+
- **World-matrix walk** `#matrix-world`: visible subtrees only. Override: `renderer.matrixWorld: "all"`. Marker: `TN_PROJECTION`.
|
|
73
|
+
- **Projected-pixel cull** `#projected-cull`: under 0.5 px. Override: `minimumProjectedPixels`; `alwaysRender(obj)`. Marker: `TN_RENDER_PROJECTION`.
|
|
74
|
+
- **Physics interpolation** `#interpolation`: on for bodies and `ctx.camera`. Override: `physicsInterpolation: false`. Marker: `TN_PHYSICS_INTERPOLATION`.
|
|
75
|
+
- **Loading** `#loading`: `loadAll` keeps order; `addInSlices` attaches in 8 ms slices. Override: `concurrency`, `sliceSize`, `marker: false`. Marker: `TN_LOAD_ALL`.
|
|
76
|
+
- **Loading curtain** `#startup`: `ctx.startup.hold(label, () => ready)`. Override: reveal on measured readiness only.
|
|
77
|
+
- **Asset cache** `#asset-cache`: on, with idle fill. Override: `assets: { cache: false, backgroundFill: false }`. Marker: `ctx.assets.cache`.
|
|
78
|
+
- **Asset cook** `#asset-cook`: compact, shared images. Override: `compact: false`; `assets.exclude`; `assets.budget`. Marker: `TN_ASSETS_CONFIG`.
|
|
79
|
+
- **Rigged assets** `#rigged`: `.glb` in `assets/`; `AnimationPlayer` drives clips. Override: `ctx.assets.model("hero.glb")` in `Scene.load()`.
|
|
80
|
+
- **Material backlight** `#backlight`: none, as in stock Unreal. Override: `rimGain`; `fillGain`.
|
|
81
|
+
- **Static scenery** `#static`: unwritten transforms stay cheap. Override: `markStatic(root)`; `invalidateStatic(obj)`. Marker: `TN_RENDERLIST_VALIDATE`.
|
|
82
|
+
- **Frame spans** `#spans`: off. Override: `TN_FRAME_SPANS=1`. Marker: `TN_FRAME_SPANS`.
|
|
83
|
+
- **Multiplayer** `#net`: none; unsupported transport rejects. Override: `connect` from `@threenative/core/net` with four limits. Marker: `TN_NET_UNAVAILABLE`.
|
|
84
|
+
- **Desktop window** `#desktop-mode`: CLI, then `display.fullscreen`, then `window.maximized`. Override: `--windowed`; `--maximized`; `--fullscreen`.
|
|
85
|
+
- **CPU priority** `#cpu-priority`: game threads first. Override: `display.priority: "normal"`. Marker: `TN_PROCESS_PRIORITY`.
|
|
86
|
+
- **Terrain** `#terrain`: authored in the game. Override: optional `@threenative/terrain`; `references/terrain-authoring.md`.
|
|
87
|
+
- **Navigation** `#navigation`: none; browser-only WASM. Override: import `@threenative/physics/navigation` on purpose.
|
|
88
|
+
- **Controller** `#gamepad`: W3C standard mapping on every pad, radial dead zone `0.2`, and a button press or a decisive stick move claims which pad is read. Override: `gamepadDeadZone: 0` for raw axes. Marker: `TN_GAMEPAD`.
|
|
89
|
+
- **Scene change** `#scene-change`: `ctx.goto(name)` keeps state. Override: `game.goto(name)` resets state.
|
|
90
|
+
- **Randomness** `#seed`: unseeded. Override: `defineGame({ seed })`.
|
|
91
|
+
- **Engine** `#engine`: owned C++ engine. Override: `engine: "threejs"` only when the user asks. Marker: `TN_NATIVE_ENGINE_UNBOUND`.
|
|
92
|
+
- **Refused imports** `#engine-catalog`: refused `three` imports fail at their line. Override: `createEngineCatalogPlugin({ mode: "warn" })`. Marker: `TN_ENGINE_CATALOG`.
|
|
93
|
+
<!-- /shared -->
|
|
94
|
+
|
|
95
|
+
<!-- shared: kit-stuck -->
|
|
96
|
+
## When the framework blocks you, write plain Three.js
|
|
51
97
|
|
|
52
|
-
|
|
53
|
-
Reference-driven authoring starts at `node_modules/create-threenative/agent-docs/references/dream-loop.md`. Open a capture after visual changes. A scenario with no assertions or missing observations fails. The engine warns you before a human does: `TN_SCENE_WARNING` fires when the GPU used under a third of the frame while the JS render phase ran longer than the display's own period, and names the census behind it — objects considered, draws per pass, triangles per draw, shadow-exempt casters. It is a scene-shape verdict, so answer it by moving the draw and object counts, not the engine: read the bucket census before promising a merge. `npx threenative doctor` repeats the last verdict and the `DEV_MODE=true` chip shows it on screen (it draws the verdict alone — no frame rate, which reads throttled under a compositor or a virtual display; see `agent-docs/references/performance-basics.md`); `TN_FRAME_SPANS=1` adds the render phase's own span tree when you need to know which part costs the milliseconds. The cheapest static object is one whose transform you never write: measured on 1,561 objects, leaving them alone costs 10.10 ms of render phase against 17.45 ms when the game rewrites every transform each frame, because three skips the per-object binding update when nothing changed. So do not touch a transform you do not need to — that is worth ~7 ms where `markStatic(root)`, which additionally composes a never-moving subtree once, measured 0.009 ms. Use it for scenery you are sure of, and `invalidateStatic(object)` to announce a write inside one; it deletes matrix arithmetic, not the walk. `TN_RENDERLIST_VALIDATE=1` recomputes every world matrix the long way each frame and throws on the first that disagrees, which is how you prove a freeze did not leave something stale on screen.
|
|
98
|
+
When an `@threenative/*` API is broken, missing, or does not do what you need, replace only that piece with portable Three.js/plain code. Keep the loop, scenes, input, registry, and playtest bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report what blocked you** (API, expectation, result, replacement); do not stall the game.
|
|
54
99
|
|
|
55
|
-
|
|
100
|
+
## Stuck
|
|
56
101
|
|
|
57
|
-
|
|
58
|
-
|
|
102
|
+
`npx threenative doctor`, then `npx @threenative/playtest doctor`; a missing observation is not zero. A confirmed engine bug: `file-engine-bug` skill. Smallest correct change: `ponytail` skill. Slow frame: `threenative-performance` skill.
|
|
103
|
+
<!-- /shared -->
|