create-threenative 0.2.3 → 0.2.4
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/README.md +53 -2
- package/agent-docs/references/assertion-reference.md +173 -6
- package/agent-docs/references/capability-reference.md +1303 -99
- package/agent-docs/references/capture-the-frame.md +7 -0
- package/agent-docs/references/creating-creatures.md +215 -0
- package/agent-docs/references/ctx-cookbook.md +69 -0
- package/agent-docs/references/debug-surface.md +8 -3
- package/agent-docs/references/dream-loop.md +150 -0
- package/agent-docs/references/finding-assets.md +70 -2
- package/agent-docs/references/sculpt-from-a-reference.md +3 -2
- package/agent-docs/references/trace-a-slow-frame.md +99 -0
- package/agent-docs/references/visual-baseline.md +41 -0
- package/agent-files/.agents/skills/file-engine-bug/SKILL.md +59 -0
- package/agent-files/.agents/skills/prd-creator/SKILL.md +40 -0
- package/agent-files/.agents/skills/threenative-assets/SKILL.md +45 -0
- package/agent-files/.agents/skills/threenative-builder/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +27 -0
- package/agent-files/.agents/skills/threenative-context/SKILL.md +57 -0
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +42 -0
- package/agent-files/.agents/skills/threenative-playtest/SKILL.md +44 -0
- package/agent-files/.agents/skills/threenative-ui/SKILL.md +20 -0
- package/agent-files/.agents/skills/threenative-verifier/SKILL.md +1 -1
- package/agent-files/.agents/skills/threenative-visuals/SKILL.md +41 -0
- package/agent-files/.claude/skills/file-engine-bug/SKILL.md +59 -0
- package/agent-files/.claude/skills/prd-creator/SKILL.md +40 -0
- package/agent-files/.claude/skills/threenative-assets/SKILL.md +45 -0
- package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +27 -0
- package/agent-files/.claude/skills/threenative-context/SKILL.md +57 -0
- package/agent-files/.claude/skills/threenative-performance/SKILL.md +42 -0
- package/agent-files/.claude/skills/threenative-playtest/SKILL.md +44 -0
- package/agent-files/.claude/skills/threenative-ui/SKILL.md +20 -0
- package/agent-files/.claude/skills/threenative-visuals/SKILL.md +41 -0
- package/agent-files/scripts/reference.mjs +705 -0
- package/agent-files/scripts/visual-loop.mjs +382 -0
- package/capabilities.json +1881 -131
- package/dist/index.d.ts +39 -6
- package/dist/index.js +297 -32
- package/dist/threenative.js +822 -105
- package/package.json +30 -5
- package/template-assets/loading.ts +12 -2
- package/template-assets/patches/three@0.185.1.patch +249 -14
- package/template-assets/worldEnvironment.ts +758 -0
- package/templates/action-rpg/.codex/config.toml +4 -0
- package/templates/action-rpg/.cursor/mcp.json +32 -0
- package/templates/action-rpg/.gemini/settings.json +32 -0
- package/templates/action-rpg/.mcp.json +15 -3
- package/templates/action-rpg/.vscode/mcp.json +36 -0
- package/templates/action-rpg/.zed/settings.json +36 -0
- package/templates/action-rpg/AGENTS.md +69 -378
- package/templates/action-rpg/CLAUDE.md +69 -378
- package/templates/action-rpg/opencode.json +41 -0
- package/templates/action-rpg/package.json +7 -7
- package/templates/action-rpg/playtests/combat.playtest.json +9 -0
- package/templates/action-rpg/playtests/performance.playtest.json +24 -7
- package/templates/action-rpg/playtests/survives.playtest.json +27 -0
- package/templates/action-rpg/playtests/touch-controls.playtest.json +42 -0
- package/templates/action-rpg/src/conventions.ts +35 -0
- package/templates/action-rpg/src/entities/Enemy.ts +2 -3
- package/templates/action-rpg/src/entities/Player.ts +20 -3
- package/templates/action-rpg/src/render/camera.ts +7 -2
- package/templates/action-rpg/src/render/lighting.ts +5 -3
- package/templates/action-rpg/src/render/loading.ts +12 -2
- package/templates/action-rpg/src/render/materials.ts +11 -0
- package/templates/action-rpg/src/render/palette.ts +10 -3
- package/templates/action-rpg/src/render/postprocessing.ts +21 -58
- package/templates/action-rpg/src/render/quality.ts +170 -0
- package/templates/action-rpg/src/render/shapes.ts +185 -26
- package/templates/action-rpg/src/render/touch-controls.ts +185 -0
- package/templates/action-rpg/src/render/vfx.ts +257 -0
- package/templates/action-rpg/src/render/worldEnvironment.ts +208 -33
- package/templates/action-rpg/src/scenes/Play.ts +43 -6
- package/templates/action-rpg/src/style.css +20 -0
- package/templates/action-rpg/threenative.config.ts +7 -0
- package/templates/defense/.codex/config.toml +4 -0
- package/templates/defense/.cursor/mcp.json +32 -0
- package/templates/defense/.gemini/settings.json +32 -0
- package/templates/defense/.mcp.json +15 -3
- package/templates/defense/.vscode/mcp.json +36 -0
- package/templates/defense/.zed/settings.json +36 -0
- package/templates/defense/AGENTS.md +62 -385
- package/templates/defense/CLAUDE.md +62 -385
- package/templates/defense/opencode.json +41 -0
- package/templates/defense/package.json +7 -7
- package/templates/defense/playtests/performance.playtest.json +24 -7
- package/templates/defense/playtests/pointer-placement.playtest.json +87 -20
- package/templates/defense/playtests/scan.playtest.json +1 -1
- package/templates/defense/playtests/survive.playtest.json +14 -0
- package/templates/defense/src/attackers/Attacker.ts +4 -4
- package/templates/defense/src/board/Route.ts +22 -8
- package/templates/defense/src/conventions.ts +18 -0
- package/templates/defense/src/entities/Player.ts +11 -3
- package/templates/defense/src/game.ts +2 -3
- package/templates/defense/src/physics.ts +9 -39
- package/templates/defense/src/placement/Buildable.ts +4 -4
- package/templates/defense/src/render/camera.ts +9 -3
- package/templates/defense/src/render/loading.ts +12 -2
- package/templates/defense/src/render/materials.ts +9 -0
- package/templates/defense/src/render/palette.ts +12 -5
- package/templates/defense/src/render/postprocessing.ts +21 -58
- package/templates/defense/src/render/quality.ts +170 -0
- package/templates/defense/src/render/shapes.ts +142 -23
- package/templates/defense/src/render/sky.ts +2 -2
- package/templates/defense/src/render/worldEnvironment.ts +208 -33
- package/templates/defense/src/scenes/Boot.ts +2 -2
- package/templates/defense/src/scenes/Defense.ts +13 -6
- package/templates/defense/src/style.css +20 -0
- package/templates/defense/src/towers/Tower.ts +11 -12
- package/templates/defense/src/towers/targeting.ts +1 -1
- package/templates/defense/src/ui/App.tsx +2 -2
- package/templates/defense/threenative.config.ts +7 -0
- package/templates/minimal/.codex/config.toml +4 -0
- package/templates/minimal/.cursor/mcp.json +32 -0
- package/templates/minimal/.gemini/settings.json +32 -0
- package/templates/minimal/.mcp.json +15 -3
- package/templates/minimal/.vscode/mcp.json +36 -0
- package/templates/minimal/.zed/settings.json +36 -0
- package/templates/minimal/AGENTS.md +76 -485
- package/templates/minimal/CLAUDE.md +76 -485
- package/templates/minimal/opencode.json +41 -0
- package/templates/minimal/package.json +6 -6
- package/templates/minimal/playtests/play.playtest.json +2 -1
- package/templates/minimal/playtests/survives.playtest.json +48 -4
- package/templates/minimal/playtests/touch-controls.playtest.json +42 -0
- package/templates/minimal/src/conventions.ts +18 -0
- package/templates/minimal/src/entities/Player.ts +39 -6
- package/templates/minimal/src/main.ts +14 -4
- package/templates/minimal/src/render/materials.ts +7 -0
- package/templates/minimal/src/render/palette.ts +3 -3
- package/templates/minimal/src/render/postprocessing.ts +17 -56
- package/templates/minimal/src/render/quality.ts +162 -0
- package/templates/minimal/src/render/sky.ts +23 -9
- package/templates/minimal/src/render/touch-controls.ts +165 -0
- package/templates/minimal/src/render/worldEnvironment.ts +208 -33
- package/templates/minimal/src/scenes/Play.ts +47 -11
- package/templates/minimal/src/style.css +20 -0
- package/templates/minimal/threenative.config.ts +7 -0
- package/templates/platformer/.codex/config.toml +4 -0
- package/templates/platformer/.cursor/mcp.json +32 -0
- package/templates/platformer/.gemini/settings.json +32 -0
- package/templates/platformer/.mcp.json +15 -3
- package/templates/platformer/.vscode/mcp.json +36 -0
- package/templates/platformer/.zed/settings.json +36 -0
- package/templates/platformer/AGENTS.md +70 -430
- package/templates/platformer/CLAUDE.md +70 -430
- package/templates/platformer/opencode.json +41 -0
- package/templates/platformer/package.json +7 -7
- package/templates/platformer/playtests/oneway.playtest.json +29 -2
- package/templates/platformer/playtests/performance.playtest.json +2 -1
- package/templates/platformer/playtests/survives.playtest.json +31 -0
- package/templates/platformer/playtests/terminal-loop-fail.playtest.json +3 -0
- package/templates/platformer/playtests/touch-controls-web.playtest.json +15 -4
- package/templates/platformer/src/conventions.ts +18 -0
- package/templates/platformer/src/entities/Character.ts +63 -1
- package/templates/platformer/src/game.ts +3 -1
- package/templates/platformer/src/level/Platform.ts +13 -1
- package/templates/platformer/src/render/lighting.ts +7 -4
- package/templates/platformer/src/render/loading.ts +12 -2
- package/templates/platformer/src/render/palette.ts +4 -1
- package/templates/platformer/src/render/postprocessing.ts +32 -57
- package/templates/platformer/src/render/quality.ts +170 -0
- package/templates/platformer/src/render/worldEnvironment.ts +208 -33
- package/templates/platformer/src/scenes/Level.ts +52 -12
- package/templates/platformer/src/style.css +20 -0
- package/templates/platformer/threenative.config.ts +7 -0
- package/templates/puzzle/.codex/config.toml +19 -0
- package/templates/puzzle/.cursor/mcp.json +32 -0
- package/templates/puzzle/.gemini/settings.json +32 -0
- package/templates/puzzle/.mcp.json +32 -0
- package/templates/puzzle/.vscode/mcp.json +36 -0
- package/templates/puzzle/.zed/settings.json +36 -0
- package/templates/puzzle/AGENTS.md +96 -0
- package/templates/puzzle/CLAUDE.md +98 -0
- package/templates/puzzle/README.md +43 -0
- package/templates/puzzle/index.html +12 -0
- package/templates/puzzle/kit.json +7 -0
- package/templates/puzzle/opencode.json +41 -0
- package/templates/puzzle/package.json +50 -0
- package/templates/puzzle/playtests/carry.playtest.json +71 -0
- package/templates/puzzle/playtests/performance.playtest.json +23 -0
- package/templates/puzzle/playtests/survives.playtest.json +51 -0
- package/templates/puzzle/playtests/swing.playtest.json +38 -0
- package/templates/puzzle/public/favicon.svg +5 -0
- package/templates/puzzle/src/conventions.ts +25 -0
- package/templates/puzzle/src/entities/Ball.ts +70 -0
- package/templates/puzzle/src/entities/Crate.ts +76 -0
- package/templates/puzzle/src/entities/Gripper.ts +69 -0
- package/templates/puzzle/src/entities/Pendulum.ts +89 -0
- package/templates/puzzle/src/game.ts +48 -0
- package/templates/puzzle/src/main.ts +15 -0
- package/templates/puzzle/src/physics.ts +19 -0
- package/templates/puzzle/src/render/camera.ts +37 -0
- package/templates/puzzle/src/render/lighting.ts +55 -0
- package/templates/puzzle/src/render/loading.ts +325 -0
- package/templates/puzzle/src/render/materials.ts +28 -0
- package/templates/puzzle/src/render/palette.ts +31 -0
- package/templates/puzzle/src/render/postprocessing.ts +34 -0
- package/templates/puzzle/src/render/quality.ts +170 -0
- package/templates/puzzle/src/render/shapes.ts +134 -0
- package/templates/puzzle/src/render/sky.ts +16 -0
- package/templates/puzzle/src/render/touch-controls.ts +185 -0
- package/templates/puzzle/src/render/worldEnvironment.ts +758 -0
- package/templates/puzzle/src/room.ts +83 -0
- package/templates/puzzle/src/scenes/Boot.ts +12 -0
- package/templates/puzzle/src/scenes/Puzzle.ts +158 -0
- package/templates/puzzle/src/state.ts +30 -0
- package/templates/puzzle/src/style.css +96 -0
- package/templates/puzzle/src/ui/App.tsx +22 -0
- package/templates/puzzle/src/ui/GameUi.tsx +20 -0
- package/templates/puzzle/src/ui/Hud.tsx +57 -0
- package/templates/puzzle/src/ui/Menu.tsx +7 -0
- package/templates/puzzle/src/ui/main.tsx +14 -0
- package/templates/puzzle/tailwind.config.ts +1 -0
- package/templates/puzzle/threenative.config.ts +49 -0
- package/templates/puzzle/tsconfig.json +17 -0
- package/templates/puzzle/vite.config.ts +38 -0
- package/templates/racing/.codex/config.toml +4 -0
- package/templates/racing/.cursor/mcp.json +32 -0
- package/templates/racing/.gemini/settings.json +32 -0
- package/templates/racing/.mcp.json +15 -3
- package/templates/racing/.vscode/mcp.json +36 -0
- package/templates/racing/.zed/settings.json +36 -0
- package/templates/racing/AGENTS.md +63 -379
- package/templates/racing/CLAUDE.md +63 -379
- package/templates/racing/native-playtests/survives.playtest.json +43 -0
- package/templates/racing/opencode.json +41 -0
- package/templates/racing/package.json +8 -7
- package/templates/racing/playtests/performance.playtest.json +24 -7
- package/templates/racing/playtests/survives.playtest.json +36 -4
- package/templates/racing/playtests/touch-controls.playtest.json +41 -0
- package/templates/racing/src/conventions.ts +6 -0
- package/templates/racing/src/entities/RacingCar.ts +16 -4
- package/templates/racing/src/entities/Rival.ts +5 -2
- package/templates/racing/src/render/camera.ts +7 -4
- package/templates/racing/src/render/lighting.ts +22 -13
- package/templates/racing/src/render/loading.ts +12 -2
- package/templates/racing/src/render/materials.ts +54 -4
- package/templates/racing/src/render/palette.ts +23 -6
- package/templates/racing/src/render/postprocessing.ts +21 -58
- package/templates/racing/src/render/quality.ts +170 -0
- package/templates/racing/src/render/shapes.ts +537 -26
- package/templates/racing/src/render/sky.ts +5 -2
- package/templates/racing/src/render/touch-controls.ts +185 -0
- package/templates/racing/src/render/worldEnvironment.ts +208 -33
- package/templates/racing/src/scenes/Race.ts +17 -2
- package/templates/racing/src/style.css +20 -0
- package/templates/racing/src/track/Track.ts +270 -31
- package/templates/racing/threenative.config.ts +7 -0
- package/templates/runner/.codex/config.toml +19 -0
- package/templates/runner/.cursor/mcp.json +32 -0
- package/templates/runner/.gemini/settings.json +32 -0
- package/templates/runner/.mcp.json +32 -0
- package/templates/runner/.vscode/mcp.json +36 -0
- package/templates/runner/.zed/settings.json +36 -0
- package/templates/runner/AGENTS.md +96 -0
- package/templates/runner/CLAUDE.md +98 -0
- package/templates/runner/README.md +43 -0
- package/templates/runner/index.html +12 -0
- package/templates/runner/kit.json +7 -0
- package/templates/runner/opencode.json +41 -0
- package/templates/runner/package.json +50 -0
- package/templates/runner/playtests/performance.playtest.json +23 -0
- package/templates/runner/playtests/streams.playtest.json +38 -0
- package/templates/runner/playtests/survives.playtest.json +51 -0
- package/templates/runner/public/favicon.svg +5 -0
- package/templates/runner/src/conventions.ts +24 -0
- package/templates/runner/src/entities/Runner.ts +135 -0
- package/templates/runner/src/game.ts +50 -0
- package/templates/runner/src/main.ts +15 -0
- package/templates/runner/src/physics.ts +13 -0
- package/templates/runner/src/render/camera.ts +39 -0
- package/templates/runner/src/render/dust.ts +131 -0
- package/templates/runner/src/render/lighting.ts +57 -0
- package/templates/runner/src/render/loading.ts +325 -0
- package/templates/runner/src/render/materials.ts +27 -0
- package/templates/runner/src/render/palette.ts +30 -0
- package/templates/runner/src/render/postprocessing.ts +34 -0
- package/templates/runner/src/render/quality.ts +170 -0
- package/templates/runner/src/render/shapes.ts +68 -0
- package/templates/runner/src/render/sky.ts +51 -0
- package/templates/runner/src/render/touch-controls.ts +185 -0
- package/templates/runner/src/render/worldEnvironment.ts +758 -0
- package/templates/runner/src/scenes/Boot.ts +12 -0
- package/templates/runner/src/scenes/Run.ts +142 -0
- package/templates/runner/src/state.ts +29 -0
- package/templates/runner/src/style.css +96 -0
- package/templates/runner/src/track.ts +176 -0
- package/templates/runner/src/ui/App.tsx +22 -0
- package/templates/runner/src/ui/GameUi.tsx +20 -0
- package/templates/runner/src/ui/Hud.tsx +55 -0
- package/templates/runner/src/ui/Menu.tsx +7 -0
- package/templates/runner/src/ui/main.tsx +14 -0
- package/templates/runner/tailwind.config.ts +1 -0
- package/templates/runner/threenative.config.ts +49 -0
- package/templates/runner/tsconfig.json +17 -0
- package/templates/runner/vite.config.ts +38 -0
- package/templates/sailing/.codex/config.toml +4 -0
- package/templates/sailing/.cursor/mcp.json +32 -0
- package/templates/sailing/.gemini/settings.json +32 -0
- package/templates/sailing/.mcp.json +15 -3
- package/templates/sailing/.vscode/mcp.json +36 -0
- package/templates/sailing/.zed/settings.json +36 -0
- package/templates/sailing/AGENTS.md +62 -355
- package/templates/sailing/CLAUDE.md +62 -355
- package/templates/sailing/README.md +12 -9
- package/templates/sailing/native-playtests/float.playtest.json +55 -0
- package/templates/sailing/native-playtests/survives.playtest.json +20 -3
- package/templates/sailing/opencode.json +41 -0
- package/templates/sailing/package.json +8 -8
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +75 -0
- package/templates/sailing/playtests/float.playtest.json +59 -0
- package/templates/sailing/playtests/performance.playtest.json +21 -6
- package/templates/sailing/playtests/survives.playtest.json +8 -0
- package/templates/sailing/playtests/touch-controls.playtest.json +48 -0
- package/templates/sailing/src/conventions.ts +8 -0
- package/templates/sailing/src/entities/Ship.ts +150 -13
- package/templates/sailing/src/render/camera.ts +15 -8
- package/templates/sailing/src/render/lighting.ts +10 -5
- package/templates/sailing/src/render/loading.ts +12 -2
- package/templates/sailing/src/render/materials.ts +24 -8
- package/templates/sailing/src/render/ocean.ts +179 -0
- package/templates/sailing/src/render/palette.ts +14 -21
- package/templates/sailing/src/render/postprocessing.ts +23 -22
- package/templates/sailing/src/render/props.ts +584 -34
- package/templates/sailing/src/render/quality.ts +140 -0
- package/templates/sailing/src/render/sky.ts +8 -3
- package/templates/sailing/src/render/touch-controls.ts +142 -0
- package/templates/sailing/src/render/worldEnvironment.ts +206 -38
- package/templates/sailing/src/scenes/Sailing.ts +43 -16
- package/templates/sailing/src/style.css +20 -0
- package/templates/sailing/threenative.config.ts +7 -1
- package/templates/shooter/.codex/config.toml +4 -0
- package/templates/shooter/.cursor/mcp.json +32 -0
- package/templates/shooter/.gemini/settings.json +32 -0
- package/templates/shooter/.mcp.json +15 -3
- package/templates/shooter/.vscode/mcp.json +36 -0
- package/templates/shooter/.zed/settings.json +36 -0
- package/templates/shooter/AGENTS.md +76 -415
- package/templates/shooter/CLAUDE.md +76 -415
- package/templates/shooter/kit.json +2 -2
- package/templates/shooter/opencode.json +41 -0
- package/templates/shooter/package.json +7 -7
- package/templates/shooter/playtests/combat.playtest.json +48 -0
- package/templates/shooter/playtests/input-control.playtest.json +165 -35
- package/templates/shooter/playtests/per-item.playtest.json +3 -3
- package/templates/shooter/playtests/performance.playtest.json +24 -7
- package/templates/shooter/playtests/shooter.playtest.json +13 -7
- package/templates/shooter/playtests/survives.playtest.json +27 -0
- package/templates/shooter/playtests/touch-controls.playtest.json +42 -0
- package/templates/shooter/playtests/weapon-cycle.playtest.json +164 -0
- package/templates/shooter/src/combat/damage.ts +1 -2
- package/templates/shooter/src/conventions.ts +51 -0
- package/templates/shooter/src/entities/Player.ts +235 -18
- package/templates/shooter/src/entities/Target.ts +2 -2
- package/templates/shooter/src/game.ts +13 -4
- package/templates/shooter/src/render/camera.ts +49 -39
- package/templates/shooter/src/render/decals.ts +211 -0
- package/templates/shooter/src/render/lighting.ts +7 -3
- package/templates/shooter/src/render/loading.ts +12 -2
- package/templates/shooter/src/render/materials.ts +56 -3
- package/templates/shooter/src/render/palette.ts +6 -3
- package/templates/shooter/src/render/postprocessing.ts +21 -58
- package/templates/shooter/src/render/quality.ts +170 -0
- package/templates/shooter/src/render/scale.ts +22 -0
- package/templates/shooter/src/render/shapes.ts +343 -62
- package/templates/shooter/src/render/sky.ts +5 -1
- package/templates/shooter/src/render/touch-controls.ts +305 -0
- package/templates/shooter/src/render/ui.css +85 -0
- package/templates/shooter/src/render/ui.ts +19 -3
- package/templates/shooter/src/render/vfx.ts +215 -0
- package/templates/shooter/src/render/worldEnvironment.ts +208 -33
- package/templates/shooter/src/scenes/Play.ts +171 -56
- package/templates/shooter/src/state.ts +5 -0
- package/templates/shooter/src/style.css +20 -0
- package/templates/shooter/src/ui/Crosshair.tsx +25 -0
- package/templates/shooter/src/ui/GameUi.tsx +2 -0
- package/templates/shooter/src/ui/Hud.tsx +7 -1
- package/templates/shooter/src/weapons/Hitscan.ts +3 -4
- package/templates/shooter/src/weapons/Projectile.ts +8 -3
- package/templates/shooter/src/weapons/Viewmodel.ts +275 -0
- package/templates/shooter/threenative.config.ts +7 -0
- package/templates/starter/.codex/config.toml +4 -0
- package/templates/starter/.cursor/mcp.json +32 -0
- package/templates/starter/.gemini/settings.json +32 -0
- package/templates/starter/.mcp.json +15 -3
- package/templates/starter/.vscode/mcp.json +36 -0
- package/templates/starter/.zed/settings.json +36 -0
- package/templates/starter/AGENTS.md +70 -527
- package/templates/starter/CLAUDE.md +70 -527
- package/templates/starter/native-playtests/render-chain.playtest.json +73 -4
- package/templates/starter/opencode.json +41 -0
- package/templates/starter/package.json +7 -7
- package/templates/starter/playtests/boot-failure.playtest.json +45 -0
- package/templates/starter/playtests/look.playtest.json +110 -6
- package/templates/starter/playtests/play.playtest.json +3 -2
- package/templates/starter/playtests/survives.playtest.json +21 -0
- package/templates/starter/playtests/touch-controls.playtest.json +42 -0
- package/templates/starter/src/conventions.ts +18 -0
- package/templates/starter/src/entities/Goal.ts +18 -3
- package/templates/starter/src/entities/Player.ts +72 -9
- package/templates/starter/src/game.ts +2 -0
- package/templates/starter/src/render/adaptiveQuality.ts +195 -0
- package/templates/starter/src/render/camera.ts +1 -1
- package/templates/starter/src/render/coast.ts +199 -0
- package/templates/starter/src/render/hero.ts +88 -0
- package/templates/starter/src/render/implicitSurface.ts +199 -0
- package/templates/starter/src/render/kuwahara.ts +174 -0
- package/templates/starter/src/render/lighting.ts +4 -4
- package/templates/starter/src/render/loading.ts +12 -2
- package/templates/starter/src/render/materials.ts +25 -6
- package/templates/starter/src/render/outline.ts +141 -0
- package/templates/starter/src/render/painterly.ts +86 -0
- package/templates/starter/src/render/palette.ts +15 -6
- package/templates/starter/src/render/postprocessing.ts +87 -36
- package/templates/starter/src/render/quality.ts +185 -0
- package/templates/starter/src/render/rockRidge.ts +198 -0
- package/templates/starter/src/render/rockRidge.worker.ts +77 -0
- package/templates/starter/src/render/scenery.ts +16 -59
- package/templates/starter/src/render/textureLifetime.ts +53 -0
- package/templates/starter/src/render/touch-controls.ts +165 -0
- package/templates/starter/src/render/water.ts +38 -0
- package/templates/starter/src/render/watercolor.ts +85 -0
- package/templates/starter/src/render/worldEnvironment.ts +208 -33
- package/templates/starter/src/scenes/Play.ts +103 -16
- package/templates/starter/src/style.css +27 -7
- package/templates/starter/threenative.config.ts +7 -7
- package/agent-docs/asset-mcp-loop.md +0 -33
- package/agent-docs/ctx-surface.md +0 -69
- package/agent-docs/engine-capabilities.md +0 -4
- package/agent-docs/framework-blocks-you.md +0 -60
- package/agent-docs/look-at-it-and-budget-the-look.md +0 -27
- package/agent-docs/performance-default.md +0 -42
- package/agent-docs/pixel-budget.md +0 -20
- package/agent-docs/playtest-fail-closed.md +0 -23
- package/agent-docs/sculpt-loop.md +0 -16
- package/templates/action-rpg/src/physics.ts +0 -40
- package/templates/defense/public/icon.png +0 -0
- package/templates/minimal/public/icon.png +0 -0
- package/templates/platformer/public/icon.png +0 -0
- package/templates/racing/public/icon.png +0 -0
- package/templates/sailing/public/icon.png +0 -0
- package/templates/sailing/src/render/water-material.ts +0 -14
- package/templates/sailing/src/render/water-shaders.ts +0 -12
- package/templates/sailing/src/render/wave-nodes.ts +0 -10
- package/templates/shooter/public/icon.png +0 -0
- package/templates/shooter/src/physics.ts +0 -49
- package/templates/starter/public/icon.png +0 -0
- /package/{templates/action-rpg/public → template-assets}/icon.png +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CircleGeometry,
|
|
3
|
+
type ColorRepresentation,
|
|
4
|
+
Group,
|
|
5
|
+
MathUtils,
|
|
6
|
+
Mesh,
|
|
7
|
+
MeshBasicMaterial,
|
|
8
|
+
type PerspectiveCamera,
|
|
9
|
+
RingGeometry,
|
|
10
|
+
Vector2,
|
|
11
|
+
} from "three";
|
|
12
|
+
import { palette } from "./palette.js";
|
|
13
|
+
|
|
14
|
+
const MOVE_RADIUS = 72;
|
|
15
|
+
const BUTTON_RADIUS = 58;
|
|
16
|
+
const EDGE = 36;
|
|
17
|
+
|
|
18
|
+
export interface ITouchPointer {
|
|
19
|
+
readonly position: Vector2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ITouchViewport {
|
|
23
|
+
readonly height: number;
|
|
24
|
+
readonly width: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ITouchInput {
|
|
28
|
+
readonly boostPressed: boolean;
|
|
29
|
+
readonly brakePressed: boolean;
|
|
30
|
+
readonly move: Vector2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function overlayMaterial(color: ColorRepresentation, opacity: number): MeshBasicMaterial {
|
|
34
|
+
return new MeshBasicMaterial({
|
|
35
|
+
color,
|
|
36
|
+
depthTest: false,
|
|
37
|
+
depthWrite: false,
|
|
38
|
+
opacity,
|
|
39
|
+
transparent: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ringMesh(radius: number, material: MeshBasicMaterial): Mesh {
|
|
44
|
+
return new Mesh(new RingGeometry(radius - 5, radius, 32), material);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function place(mesh: Mesh, point: Vector2): void {
|
|
48
|
+
mesh.position.set(point.x, point.y, 0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function controlPoint(size: ITouchViewport, name: "boost" | "brake" | "move"): Vector2 {
|
|
52
|
+
if (name === "move") return new Vector2(MOVE_RADIUS + EDGE, size.height - MOVE_RADIUS - EDGE);
|
|
53
|
+
const yOffset = name === "boost" ? BUTTON_RADIUS * 2 + EDGE : 0;
|
|
54
|
+
return new Vector2(
|
|
55
|
+
size.width - BUTTON_RADIUS - EDGE,
|
|
56
|
+
size.height - BUTTON_RADIUS - EDGE - yOffset,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class TouchControls {
|
|
61
|
+
readonly root = new Group();
|
|
62
|
+
readonly object = this.root;
|
|
63
|
+
#camera: PerspectiveCamera;
|
|
64
|
+
#input: { boostPressed: boolean; brakePressed: boolean; move: Vector2 } = {
|
|
65
|
+
boostPressed: false,
|
|
66
|
+
brakePressed: false,
|
|
67
|
+
move: new Vector2(),
|
|
68
|
+
};
|
|
69
|
+
#wasBoost = false;
|
|
70
|
+
#wasBrake = false;
|
|
71
|
+
#moveAnchor = new Vector2();
|
|
72
|
+
#resting = new Vector2();
|
|
73
|
+
#boostCenter = new Vector2();
|
|
74
|
+
#brakeCenter = new Vector2();
|
|
75
|
+
#hasMoveAnchor = false;
|
|
76
|
+
#lastWidth = -1;
|
|
77
|
+
#lastHeight = -1;
|
|
78
|
+
#moveBase: Mesh;
|
|
79
|
+
#moveKnob: Mesh;
|
|
80
|
+
#boost: Mesh;
|
|
81
|
+
#brake: Mesh;
|
|
82
|
+
#idleMaterial: MeshBasicMaterial;
|
|
83
|
+
#activeMaterial: MeshBasicMaterial;
|
|
84
|
+
|
|
85
|
+
constructor(camera: PerspectiveCamera) {
|
|
86
|
+
this.#camera = camera;
|
|
87
|
+
this.#idleMaterial = overlayMaterial(palette.shadow, 0.35);
|
|
88
|
+
this.#activeMaterial = overlayMaterial(palette.accent, 0.62);
|
|
89
|
+
this.#moveBase = ringMesh(MOVE_RADIUS, this.#idleMaterial);
|
|
90
|
+
this.#moveKnob = new Mesh(new CircleGeometry(28, 24), this.#activeMaterial);
|
|
91
|
+
this.#boost = ringMesh(BUTTON_RADIUS, this.#idleMaterial);
|
|
92
|
+
this.#brake = ringMesh(BUTTON_RADIUS, this.#idleMaterial);
|
|
93
|
+
this.root.add(this.#moveBase, this.#moveKnob, this.#boost, this.#brake);
|
|
94
|
+
this.root.renderOrder = 10_001;
|
|
95
|
+
camera.add(this.root);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
update(pointers: ReadonlyMap<number, ITouchPointer>, size: ITouchViewport): ITouchInput {
|
|
99
|
+
this.#ensureLayout(size);
|
|
100
|
+
const boost = this.#at(pointers, this.#boostCenter, BUTTON_RADIUS);
|
|
101
|
+
const brake = this.#at(pointers, this.#brakeCenter, BUTTON_RADIUS);
|
|
102
|
+
let movement: ITouchPointer | undefined;
|
|
103
|
+
for (const pointer of pointers.values()) {
|
|
104
|
+
if (pointer.position.x < size.width * 0.5) {
|
|
105
|
+
movement = pointer;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (movement === undefined) {
|
|
111
|
+
this.#hasMoveAnchor = false;
|
|
112
|
+
this.#input.move.set(0, 0);
|
|
113
|
+
} else {
|
|
114
|
+
if (!this.#hasMoveAnchor) {
|
|
115
|
+
this.#moveAnchor.copy(movement.position);
|
|
116
|
+
this.#hasMoveAnchor = true;
|
|
117
|
+
}
|
|
118
|
+
this.#input.move.set(
|
|
119
|
+
MathUtils.clamp((movement.position.x - this.#moveAnchor.x) / MOVE_RADIUS, -1, 1),
|
|
120
|
+
MathUtils.clamp((this.#moveAnchor.y - movement.position.y) / MOVE_RADIUS, -1, 1),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const center = this.#hasMoveAnchor ? this.#moveAnchor : this.#resting;
|
|
125
|
+
place(
|
|
126
|
+
this.#moveKnob,
|
|
127
|
+
new Vector2(
|
|
128
|
+
center.x + this.#input.move.x * MOVE_RADIUS,
|
|
129
|
+
center.y - this.#input.move.y * MOVE_RADIUS,
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
this.#boost.material = boost ? this.#activeMaterial : this.#idleMaterial;
|
|
133
|
+
this.#brake.material = brake ? this.#activeMaterial : this.#idleMaterial;
|
|
134
|
+
this.#input.boostPressed = boost && !this.#wasBoost;
|
|
135
|
+
this.#input.brakePressed = brake;
|
|
136
|
+
this.#wasBoost = boost;
|
|
137
|
+
this.#wasBrake = brake;
|
|
138
|
+
this.#layout(size);
|
|
139
|
+
return this.#input;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
debug(): Record<string, unknown> {
|
|
143
|
+
return {
|
|
144
|
+
boost: this.#wasBoost,
|
|
145
|
+
brake: this.#wasBrake,
|
|
146
|
+
move: this.#input.move.toArray(),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
dispose(): void {
|
|
151
|
+
this.root.removeFromParent();
|
|
152
|
+
for (const child of this.root.children) {
|
|
153
|
+
if (child instanceof Mesh) child.geometry.dispose();
|
|
154
|
+
}
|
|
155
|
+
this.#idleMaterial.dispose();
|
|
156
|
+
this.#activeMaterial.dispose();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#ensureLayout(size: ITouchViewport): void {
|
|
160
|
+
if (size.width === this.#lastWidth && size.height === this.#lastHeight) return;
|
|
161
|
+
this.#lastWidth = size.width;
|
|
162
|
+
this.#lastHeight = size.height;
|
|
163
|
+
this.#resting.copy(controlPoint(size, "move"));
|
|
164
|
+
this.#boostCenter.copy(controlPoint(size, "boost"));
|
|
165
|
+
this.#brakeCenter.copy(controlPoint(size, "brake"));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#layout(size: ITouchViewport): void {
|
|
169
|
+
const worldHeight = 2 * Math.tan(MathUtils.degToRad(this.#camera.fov / 2));
|
|
170
|
+
const pixels = worldHeight / Math.max(1, size.height);
|
|
171
|
+
this.root.position.set(-(size.width * pixels) / 2, worldHeight / 2, -1);
|
|
172
|
+
this.root.scale.set(pixels, -pixels, 1);
|
|
173
|
+
place(this.#moveBase, this.#hasMoveAnchor ? this.#moveAnchor : this.#resting);
|
|
174
|
+
place(this.#boost, this.#boostCenter);
|
|
175
|
+
place(this.#brake, this.#brakeCenter);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#at(pointers: ReadonlyMap<number, ITouchPointer>, center: Vector2, radius: number): boolean {
|
|
179
|
+
const radiusSquared = radius * radius;
|
|
180
|
+
for (const pointer of pointers.values()) {
|
|
181
|
+
if (pointer.position.distanceToSquared(center) <= radiusSquared) return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -143,6 +143,34 @@ export interface IWorldEnvironmentOptions {
|
|
|
143
143
|
readonly gtaoSamples?: number;
|
|
144
144
|
/** Fraction of display resolution the occlusion is traced at. */
|
|
145
145
|
readonly gtaoResolutionScale?: number;
|
|
146
|
+
/**
|
|
147
|
+
* The fraction of the frame SSGI actually gathers at. Half by default.
|
|
148
|
+
*
|
|
149
|
+
* `GTAONode` and `SSRNode` both carry a `resolutionScale` of their own; **`SSGINode` does not**,
|
|
150
|
+
* and its `setSize` passes width and height straight into its render target with no factor. So
|
|
151
|
+
* screen-space GI — a low-frequency effect every production renderer gathers at half or quarter
|
|
152
|
+
* res — was the only stage in this chain running at full resolution, and it cost accordingly.
|
|
153
|
+
*
|
|
154
|
+
* Measured on a 46,190-instance forest at 1600x900 on an RTX 2080, with the resolution scaler
|
|
155
|
+
* left on auto so the engine's own verdict is part of the result:
|
|
156
|
+
*
|
|
157
|
+
* fps still/walk scale it settled on interior median dead shadow
|
|
158
|
+
* full res 38.0 / 47.2 0.44 704x396 0.0299 19.19%
|
|
159
|
+
* off 60.0 / 60.0 0.61 976x549 0.0987 4.54%
|
|
160
|
+
* half res 59.8 / 60.0 0.72 1152x648 0.0301 18.58%
|
|
161
|
+
*
|
|
162
|
+
* Half res is better than both: it holds the budget like switching SSGI off, keeps the look
|
|
163
|
+
* within noise of full res, and produces the *sharpest* frame of the three — because the budget
|
|
164
|
+
* it hands back is spent by the scaler on pixels rather than on a gather nobody can see at full
|
|
165
|
+
* rate. Full-res SSGI was not buying quality, it was trading it.
|
|
166
|
+
*
|
|
167
|
+
* Fixed without touching three: `setSize` is public and the pass drives the node through it with
|
|
168
|
+
* the full frame size, so the instance is wrapped to hand it a smaller one. The node's own maths
|
|
169
|
+
* reads the `_resolution` uniform that `setSize` writes, so it stays self-consistent, and the
|
|
170
|
+
* result is sampled by UV rather than by texel — which is what makes the upsample free and is
|
|
171
|
+
* exactly the mechanism `GTAONode` uses internally.
|
|
172
|
+
*/
|
|
173
|
+
readonly ssgiResolutionScale?: number;
|
|
146
174
|
/**
|
|
147
175
|
* Contrast-adaptive sharpening (RCAS) over the finished frame.
|
|
148
176
|
*
|
|
@@ -163,6 +191,30 @@ export interface IWorldEnvironmentOptions {
|
|
|
163
191
|
readonly bloomRadius?: number;
|
|
164
192
|
/** Luminance a pixel must exceed before it blooms at all. */
|
|
165
193
|
readonly bloomThreshold?: number;
|
|
194
|
+
/**
|
|
195
|
+
* Which of this kit's authored stages to run.
|
|
196
|
+
*
|
|
197
|
+
* Separate from the graph below, and not for tidiness: the chain has to know whether anything
|
|
198
|
+
* was requested at all before the scene pass exists — with nothing requested it sets an
|
|
199
|
+
* exposure and returns, and no pass is ever built. So the request is a static decision the kit
|
|
200
|
+
* makes from its own config, and only the graph needs the pass.
|
|
201
|
+
*/
|
|
202
|
+
readonly authoredStageNames?: readonly string[];
|
|
203
|
+
/**
|
|
204
|
+
* This kit's own stages, composed after the built-ins.
|
|
205
|
+
*
|
|
206
|
+
* A factory because an authored stage needs the two things only this file can produce: the
|
|
207
|
+
* scene pass's depth texture node, which does not exist until the pass is built, and the
|
|
208
|
+
* resolved tier. It returns the complete graph — including stages left dormant this frame — so
|
|
209
|
+
* that an anchor like `watercolor after kuwahara` keeps naming a stage that exists.
|
|
210
|
+
*
|
|
211
|
+
* Naming specific stages here instead — an `outlineEnabled`, a `kuwaharaRadius` — is what put
|
|
212
|
+
* one kit's look inside the plumbing every kit copies verbatim, which
|
|
213
|
+
* `shared-render-sources.spec.ts` exists to refuse.
|
|
214
|
+
*/
|
|
215
|
+
readonly authoredStages?: (context: IWorldEnvironmentStageContext) => readonly ChainStage[];
|
|
216
|
+
/** Quality tier passed to the measured chain; the quality module owns this value. */
|
|
217
|
+
readonly renderChainTier?: ChainTier;
|
|
166
218
|
readonly tonemapMode?: TonemapMode;
|
|
167
219
|
/**
|
|
168
220
|
* Scene-referred exposure: multiplied into the scene pass **before** the tone curve, so
|
|
@@ -198,12 +250,33 @@ export interface IWorldEnvironmentTarget {
|
|
|
198
250
|
* compiler checks the composition instead of taking a cast's word for it.
|
|
199
251
|
*/
|
|
200
252
|
type ChainNode = Node<"vec4">;
|
|
253
|
+
/**
|
|
254
|
+
* The scene pass's depth texture, as the pass itself types it.
|
|
255
|
+
*
|
|
256
|
+
* Named through `pass()` rather than written out because the addon's return type is the only
|
|
257
|
+
* honest spelling of it, and a hand-written alias here would drift the first time three changes it.
|
|
258
|
+
*/
|
|
259
|
+
export type DepthTextureNode = ReturnType<ReturnType<typeof pass>["getTextureNode"]>;
|
|
260
|
+
type ChainTier = "high" | "medium" | "low" | "off";
|
|
201
261
|
type ChainContext = {
|
|
202
|
-
readonly tier:
|
|
262
|
+
readonly tier: ChainTier;
|
|
203
263
|
};
|
|
204
|
-
|
|
205
|
-
|
|
264
|
+
/**
|
|
265
|
+
* What a kit's `authoredStages` factory is handed. The depth node is the scene pass's, so a
|
|
266
|
+
* stage that reads depth gets the same texture the built-in stages read rather than its own.
|
|
267
|
+
*/
|
|
268
|
+
export interface IWorldEnvironmentStageContext {
|
|
269
|
+
readonly depthNode: DepthTextureNode;
|
|
270
|
+
readonly tier: ChainTier;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export type ChainStage = {
|
|
274
|
+
readonly name: string;
|
|
275
|
+
readonly before?: string;
|
|
276
|
+
readonly after?: string;
|
|
206
277
|
readonly available?: (context: ChainContext) => boolean | string;
|
|
278
|
+
readonly dispose?: () => void;
|
|
279
|
+
readonly minimumTier?: ChainTier;
|
|
207
280
|
/** The chain plumbing is stage-agnostic, so it names the node it carries `unknown`. */
|
|
208
281
|
readonly build: (input: unknown, context: ChainContext) => unknown;
|
|
209
282
|
};
|
|
@@ -218,6 +291,7 @@ type ChainStage = {
|
|
|
218
291
|
*/
|
|
219
292
|
function stage(definition: {
|
|
220
293
|
readonly name: ChainStage["name"];
|
|
294
|
+
readonly dispose?: () => void;
|
|
221
295
|
readonly available?: (context: ChainContext) => boolean | string;
|
|
222
296
|
readonly build: (input: ChainNode, context: ChainContext) => ChainNode;
|
|
223
297
|
}): ChainStage {
|
|
@@ -248,10 +322,12 @@ export type OutputRenderer = {
|
|
|
248
322
|
setOutputNode?: (node: unknown) => void;
|
|
249
323
|
createRenderChain?: (options: {
|
|
250
324
|
input?: unknown;
|
|
325
|
+
worldPass?: unknown;
|
|
251
326
|
request?: { stages?: readonly string[]; tier?: ChainContext["tier"] };
|
|
252
327
|
stages?: readonly ChainStage[];
|
|
253
328
|
}) => {
|
|
254
329
|
applied: { dropped: readonly { name: string; reason: string }[]; stages: readonly string[] };
|
|
330
|
+
dispose(): void;
|
|
255
331
|
};
|
|
256
332
|
};
|
|
257
333
|
|
|
@@ -281,7 +357,17 @@ export class WorldEnvironment {
|
|
|
281
357
|
`Unknown tonemapMode '${String(tonemapMode)}'. Use one of: ${Object.keys(TONEMAP).join(", ")}.`,
|
|
282
358
|
);
|
|
283
359
|
}
|
|
360
|
+
const renderChainTier = options.renderChainTier ?? "high";
|
|
361
|
+
if (!isChainTier(renderChainTier)) {
|
|
362
|
+
throw new Error(
|
|
363
|
+
`Unknown render chain tier '${String(renderChainTier)}'. Use high, medium, low, or off.`,
|
|
364
|
+
);
|
|
365
|
+
}
|
|
284
366
|
this.#options = {
|
|
367
|
+
// A kit with no stages of its own is the common case, so both default to empty rather
|
|
368
|
+
// than to a branch every call site has to remember.
|
|
369
|
+
authoredStageNames: options.authoredStageNames ?? [],
|
|
370
|
+
authoredStages: options.authoredStages ?? (() => []),
|
|
285
371
|
ssgiEnabled: options.ssgiEnabled ?? false,
|
|
286
372
|
ssgiQuality: quality,
|
|
287
373
|
ssgiIntensity: options.ssgiIntensity ?? 1,
|
|
@@ -301,6 +387,7 @@ export class WorldEnvironment {
|
|
|
301
387
|
gtaoScale: options.gtaoScale ?? 1,
|
|
302
388
|
gtaoSamples: options.gtaoSamples ?? 16,
|
|
303
389
|
gtaoResolutionScale: options.gtaoResolutionScale ?? 1,
|
|
390
|
+
ssgiResolutionScale: options.ssgiResolutionScale ?? 0.5,
|
|
304
391
|
sharpenEnabled: options.sharpenEnabled ?? false,
|
|
305
392
|
sharpenStrength: options.sharpenStrength ?? 0.2,
|
|
306
393
|
vignetteAmount: options.vignetteAmount ?? 0,
|
|
@@ -308,6 +395,7 @@ export class WorldEnvironment {
|
|
|
308
395
|
bloomStrength: options.bloomStrength ?? 0.7,
|
|
309
396
|
bloomRadius: options.bloomRadius ?? 0.5,
|
|
310
397
|
bloomThreshold: options.bloomThreshold ?? 0.2,
|
|
398
|
+
renderChainTier,
|
|
311
399
|
tonemapMode,
|
|
312
400
|
exposure: options.exposure ?? 1,
|
|
313
401
|
};
|
|
@@ -325,12 +413,13 @@ export class WorldEnvironment {
|
|
|
325
413
|
): {
|
|
326
414
|
dropped: readonly { name: string; reason: string }[];
|
|
327
415
|
stages: readonly string[];
|
|
416
|
+
dispose?: () => void;
|
|
328
417
|
} {
|
|
329
418
|
const options = this.#options;
|
|
330
419
|
const raw = renderer.raw as { toneMapping?: number; toneMappingExposure?: number };
|
|
331
420
|
raw.toneMapping = TONEMAP[options.tonemapMode];
|
|
332
421
|
|
|
333
|
-
const requested = (
|
|
422
|
+
const requested: string[] = (
|
|
334
423
|
["ssgi", "ambientOcclusion", "godRays", "ssr", "sharpen", "bloom", "vignette"] as const
|
|
335
424
|
).filter(
|
|
336
425
|
(name) =>
|
|
@@ -342,6 +431,7 @@ export class WorldEnvironment {
|
|
|
342
431
|
(name === "bloom" && options.bloomEnabled) ||
|
|
343
432
|
(name === "vignette" && options.vignetteAmount > 0),
|
|
344
433
|
);
|
|
434
|
+
requested.push(...options.authoredStageNames);
|
|
345
435
|
|
|
346
436
|
// With no stage running there is no node graph to install — the renderer's own
|
|
347
437
|
// tone-mapping path renders the frame, and the exposure scalar is live there (measured:
|
|
@@ -364,10 +454,25 @@ export class WorldEnvironment {
|
|
|
364
454
|
if (options.ssgiEnabled || options.ssrEnabled || options.gtaoEnabled) {
|
|
365
455
|
scenePass.setMRT(mrt({ output, normal: normalView, metalness, roughness }));
|
|
366
456
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
457
|
+
// Requested lazily, and this is not a micro-optimisation. **Asking a pass for `normal`,
|
|
458
|
+
// `metalness` or `roughness` is what creates the extra render target.** A tier that runs none
|
|
459
|
+
// of the stages needing them — the mobile look is bloom and the tone curve — must not ask, or
|
|
460
|
+
// the pass carries a colour target no fragment shader writes and WebGPU refuses the pipeline:
|
|
461
|
+
// *"Color target has no corresponding fragment stage output but writeMask … is not zero.
|
|
462
|
+
// While validating targets[1]"*. The frame then comes out **black** while the chain still
|
|
463
|
+
// reports every stage as applied, which is the worst shape a failure can take here.
|
|
464
|
+
const nodes = new Map<string, ReturnType<typeof scenePass.getTextureNode>>();
|
|
465
|
+
const textureNode = (name: string): ReturnType<typeof scenePass.getTextureNode> => {
|
|
466
|
+
const cached = nodes.get(name);
|
|
467
|
+
if (cached !== undefined) return cached;
|
|
468
|
+
const node = scenePass.getTextureNode(name);
|
|
469
|
+
nodes.set(name, node);
|
|
470
|
+
return node;
|
|
471
|
+
};
|
|
472
|
+
const depth = (): ReturnType<typeof scenePass.getTextureNode> => textureNode("depth");
|
|
473
|
+
const normal = (): ReturnType<typeof scenePass.getTextureNode> => textureNode("normal");
|
|
474
|
+
const metal = (): ReturnType<typeof scenePass.getTextureNode> => textureNode("metalness");
|
|
475
|
+
const rough = (): ReturnType<typeof scenePass.getTextureNode> => textureNode("roughness");
|
|
371
476
|
// Every stage here is perspective-camera maths — view-space reconstruction from depth,
|
|
372
477
|
// and a projection matrix inverse. The scene's camera is the one the pass rendered with.
|
|
373
478
|
const view = camera as PerspectiveCamera;
|
|
@@ -375,17 +480,39 @@ export class WorldEnvironment {
|
|
|
375
480
|
const base = target.baseColour?.(scenePass) ?? scenePass.getTextureNode("output");
|
|
376
481
|
const exposed = convertToTexture(base).mul(options.exposure);
|
|
377
482
|
const giDenoise = (node: ChainNode): ChainNode =>
|
|
378
|
-
options.denoiseEnabled ? denoised(denoise(node, depth, normal, view)) : node;
|
|
483
|
+
options.denoiseEnabled ? denoised(denoise(node, depth(), normal(), view)) : node;
|
|
379
484
|
|
|
485
|
+
let releaseBloom = (): void => {};
|
|
380
486
|
const stages: ChainStage[] = [
|
|
381
487
|
stage({
|
|
382
488
|
name: "ssgi",
|
|
383
489
|
build: (input) => {
|
|
384
|
-
const gi = ssgi(input, depth, normal, view);
|
|
490
|
+
const gi = ssgi(input, depth(), normal(), view);
|
|
385
491
|
const tier = SSGI_QUALITY[options.ssgiQuality];
|
|
386
492
|
gi.sliceCount.value = tier.sliceCount;
|
|
387
493
|
gi.stepCount.value = tier.stepCount;
|
|
388
494
|
gi.radius.value = options.ssgiRadius;
|
|
495
|
+
// Gather at a fraction of the frame. See `ssgiResolutionScale` above for why this is a
|
|
496
|
+
// wrapper rather than a property: the node has no scale of its own, and `setSize` is the
|
|
497
|
+
// public seam the pass drives it through. `setSize` is present on the node and absent
|
|
498
|
+
// from its type declarations, so the seam is named here rather than cast away at the call
|
|
499
|
+
// site — if a future three release declares it, or gives the node a `resolutionScale`,
|
|
500
|
+
// this narrows to nothing and the wrapper can go. Guarded at one texel so a zero or a
|
|
501
|
+
// negative cannot ask for an empty target: a 0x0 gather returns black and reads as SSGI
|
|
502
|
+
// simply not working.
|
|
503
|
+
const ssgiScale = options.ssgiResolutionScale;
|
|
504
|
+
const sizedGi = gi as unknown as {
|
|
505
|
+
setSize?: (width: number, height: number) => void;
|
|
506
|
+
};
|
|
507
|
+
const fullGiSize = sizedGi.setSize?.bind(gi);
|
|
508
|
+
if (ssgiScale > 0 && ssgiScale < 1 && fullGiSize !== undefined) {
|
|
509
|
+
sizedGi.setSize = (width: number, height: number): void => {
|
|
510
|
+
fullGiSize(
|
|
511
|
+
Math.max(1, Math.round(width * ssgiScale)),
|
|
512
|
+
Math.max(1, Math.round(height * ssgiScale)),
|
|
513
|
+
);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
389
516
|
|
|
390
517
|
// SSGI writes two targets: AO in a single-channel `RedFormat` texture, and the GI
|
|
391
518
|
// term in an RGB one. Multiplying the beauty pass by the whole AO vec4 therefore
|
|
@@ -405,7 +532,7 @@ export class WorldEnvironment {
|
|
|
405
532
|
stage({
|
|
406
533
|
name: "ambientOcclusion",
|
|
407
534
|
build: (input) => {
|
|
408
|
-
const contact = ao(depth, normal, view);
|
|
535
|
+
const contact = ao(depth(), normal(), view);
|
|
409
536
|
contact.radius.value = options.gtaoRadius;
|
|
410
537
|
contact.scale.value = options.gtaoScale;
|
|
411
538
|
contact.samples.value = options.gtaoSamples;
|
|
@@ -428,11 +555,19 @@ export class WorldEnvironment {
|
|
|
428
555
|
if (light === undefined) return "godraysEnabled is true but no godraysLight was passed";
|
|
429
556
|
if (light.castShadow !== true)
|
|
430
557
|
return `light '${light.name || "sun"}' does not cast shadows`;
|
|
558
|
+
// `castShadow` is a request, not a result: three allocates the shadow map on the first
|
|
559
|
+
// render that needs it, and `GodraysNode` reads `shadow.map.depthTexture` while the
|
|
560
|
+
// graph is built. Without this check that read throws inside TSL, the chain build
|
|
561
|
+
// fails, and *every* stage is lost — the frame comes back ungraded with no SSGI, no
|
|
562
|
+
// SSR and no tonemap, which looks like a scene problem rather than a missing map.
|
|
563
|
+
// Refusing by name keeps the rest of the chain, which is this stage list's contract.
|
|
564
|
+
if (light.shadow?.map == null)
|
|
565
|
+
return `light '${light.name || "sun"}' has no shadow map yet: set renderer.shadowMap.enabled on the raw renderer (ctx.renderer.raw), and build the chain after the first frame has rendered`;
|
|
431
566
|
return true;
|
|
432
567
|
},
|
|
433
568
|
build: (input) => {
|
|
434
569
|
const light = target.godraysLight as DirectionalLight;
|
|
435
|
-
const shafts = godrays(depth, view, light);
|
|
570
|
+
const shafts = godrays(depth(), view, light);
|
|
436
571
|
shafts.density.value = options.godraysDensity;
|
|
437
572
|
shafts.maxDensity.value = options.godraysMaxDensity;
|
|
438
573
|
shafts.raymarchSteps.value = options.godraysSteps;
|
|
@@ -443,7 +578,7 @@ export class WorldEnvironment {
|
|
|
443
578
|
// silhouettes the depth term owns. Denoise before the floor: the floor's
|
|
444
579
|
// subtraction amplifies relative noise on near-floor values.
|
|
445
580
|
let shaft: ChainNode = convertToTexture(shafts);
|
|
446
|
-
if (options.denoiseEnabled) shaft = denoised(denoise(shaft, depth, normal, view));
|
|
581
|
+
if (options.denoiseEnabled) shaft = denoised(denoise(shaft, depth(), normal(), view));
|
|
447
582
|
// Floor, then scale, then tint. The floor is what turns this from a whole-frame
|
|
448
583
|
// brightener into a shaft renderer; the tint by the light's own colour is what
|
|
449
584
|
// stops a warm sun throwing a white beam.
|
|
@@ -469,10 +604,10 @@ export class WorldEnvironment {
|
|
|
469
604
|
// reflections onto a second copy builds two parallel graphs, and the frame comes
|
|
470
605
|
// out as the bare background colour.
|
|
471
606
|
const base = convertToTexture(input);
|
|
472
|
-
const reflections = ssr(base, depth, normal as unknown as Parameters<typeof ssr>[2], {
|
|
607
|
+
const reflections = ssr(base, depth(), normal() as unknown as Parameters<typeof ssr>[2], {
|
|
473
608
|
camera: view,
|
|
474
|
-
metalnessNode: metal.r,
|
|
475
|
-
roughnessNode: rough.g,
|
|
609
|
+
metalnessNode: metal().r,
|
|
610
|
+
roughnessNode: rough().g,
|
|
476
611
|
reflectNonMetals: true,
|
|
477
612
|
});
|
|
478
613
|
reflections.maxDistance.value = options.ssrMaxDistance;
|
|
@@ -493,15 +628,33 @@ export class WorldEnvironment {
|
|
|
493
628
|
}),
|
|
494
629
|
stage({
|
|
495
630
|
name: "bloom",
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
631
|
+
dispose: () => {
|
|
632
|
+
releaseBloom();
|
|
633
|
+
releaseBloom = () => {};
|
|
634
|
+
},
|
|
635
|
+
build: (input) => {
|
|
636
|
+
const texture = convertToTexture(input);
|
|
637
|
+
const effect = bloom(
|
|
638
|
+
texture,
|
|
639
|
+
options.bloomStrength,
|
|
640
|
+
options.bloomRadius,
|
|
641
|
+
options.bloomThreshold,
|
|
642
|
+
);
|
|
643
|
+
releaseBloom = () => {
|
|
644
|
+
effect.dispose();
|
|
645
|
+
// convertToTexture may return its input. Only the newly allocated RTT is ours.
|
|
646
|
+
const scratch = texture as unknown as {
|
|
647
|
+
isRTTNode?: boolean;
|
|
648
|
+
renderTarget: { dispose(): void };
|
|
649
|
+
_quadMesh: { material: { dispose(): void } };
|
|
650
|
+
};
|
|
651
|
+
if (texture !== input && scratch.isRTTNode === true) {
|
|
652
|
+
scratch.renderTarget.dispose();
|
|
653
|
+
scratch._quadMesh.material.dispose();
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
return input.add(effect);
|
|
657
|
+
},
|
|
505
658
|
}),
|
|
506
659
|
stage({
|
|
507
660
|
name: "vignette",
|
|
@@ -517,6 +670,11 @@ export class WorldEnvironment {
|
|
|
517
670
|
}),
|
|
518
671
|
];
|
|
519
672
|
|
|
673
|
+
// The kit's own stages, composed after the built-ins. The factory is called with the two
|
|
674
|
+
// things only this file can produce — the scene pass's depth texture and the resolved tier —
|
|
675
|
+
// and returns the complete authored graph plus the subset to run.
|
|
676
|
+
stages.push(...options.authoredStages({ depthNode: depth(), tier: options.renderChainTier }));
|
|
677
|
+
|
|
520
678
|
// A composed base colour with every stage off still has to reach the frame. The chain
|
|
521
679
|
// installs nothing for an empty stage list, so this is the one path that goes direct.
|
|
522
680
|
if (requested.length === 0) {
|
|
@@ -534,11 +692,19 @@ export class WorldEnvironment {
|
|
|
534
692
|
if (renderer.createRenderChain === undefined) throw new Error("RenderChain is unavailable.");
|
|
535
693
|
const chain = renderer.createRenderChain({
|
|
536
694
|
input: exposed,
|
|
537
|
-
request: { stages: requested, tier:
|
|
695
|
+
request: { stages: requested, tier: options.renderChainTier },
|
|
538
696
|
stages,
|
|
697
|
+
worldPass: scenePass,
|
|
539
698
|
});
|
|
540
699
|
this.#reportApplied(chain.applied.stages, chain.applied.dropped);
|
|
541
|
-
return {
|
|
700
|
+
return {
|
|
701
|
+
dropped: chain.applied.dropped,
|
|
702
|
+
stages: chain.applied.stages,
|
|
703
|
+
dispose: () => {
|
|
704
|
+
chain.dispose();
|
|
705
|
+
scenePass.dispose();
|
|
706
|
+
},
|
|
707
|
+
};
|
|
542
708
|
}
|
|
543
709
|
|
|
544
710
|
/**
|
|
@@ -555,7 +721,7 @@ export class WorldEnvironment {
|
|
|
555
721
|
dropped: readonly { name: string; reason: string }[],
|
|
556
722
|
): void {
|
|
557
723
|
const options = this.#options;
|
|
558
|
-
const off: Record<
|
|
724
|
+
const off: Record<string, string> = {
|
|
559
725
|
ambientOcclusion: "gtaoEnabled is false",
|
|
560
726
|
bloom: "bloomEnabled is false",
|
|
561
727
|
godRays: "godraysEnabled is false",
|
|
@@ -563,12 +729,17 @@ export class WorldEnvironment {
|
|
|
563
729
|
ssgi: "ssgiEnabled is false",
|
|
564
730
|
ssr: "ssrEnabled is false",
|
|
565
731
|
vignette: "vignetteAmount is 0",
|
|
732
|
+
kuwahara: "kuwaharaEnabled is false",
|
|
733
|
+
outline: "outlineEnabled is false",
|
|
734
|
+
watercolor: "watercolorEnabled is false",
|
|
566
735
|
};
|
|
567
|
-
const stages =
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
736
|
+
const stages = Object.keys(off)
|
|
737
|
+
.sort()
|
|
738
|
+
.map((name) => {
|
|
739
|
+
if (applied.includes(name)) return { applied: true, name };
|
|
740
|
+
const refused = dropped.find((entry) => entry.name === name);
|
|
741
|
+
return { applied: false, name, reason: refused?.reason ?? off[name] };
|
|
742
|
+
});
|
|
572
743
|
console.info(
|
|
573
744
|
`TN_WORLD_ENVIRONMENT:${JSON.stringify({
|
|
574
745
|
denoise: options.denoiseEnabled,
|
|
@@ -581,3 +752,7 @@ export class WorldEnvironment {
|
|
|
581
752
|
);
|
|
582
753
|
}
|
|
583
754
|
}
|
|
755
|
+
|
|
756
|
+
function isChainTier(value: unknown): value is ChainTier {
|
|
757
|
+
return value === "high" || value === "medium" || value === "low" || value === "off";
|
|
758
|
+
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ICtx,
|
|
3
|
+
Scene,
|
|
4
|
+
type SceneFrame,
|
|
5
|
+
isMobile,
|
|
6
|
+
isTouchscreenAvailable,
|
|
7
|
+
} from "@threenative/core";
|
|
2
8
|
import type { IPhysicsContext } from "@threenative/physics";
|
|
3
9
|
import { type PerspectiveCamera, Vector3 } from "three";
|
|
4
10
|
import { RACING_FEEL, RacingCar } from "../entities/RacingCar.js";
|
|
@@ -11,6 +17,7 @@ import { createMaterials } from "../render/materials.js";
|
|
|
11
17
|
import { setupPost } from "../render/postprocessing.js";
|
|
12
18
|
import { flag } from "../render/shapes.js";
|
|
13
19
|
import { setupSky } from "../render/sky.js";
|
|
20
|
+
import { TouchControls } from "../render/touch-controls.js";
|
|
14
21
|
import { type GameState, type RaceStatus, resolveRaceStatus } from "../state.js";
|
|
15
22
|
import { Lap } from "../track/Lap.js";
|
|
16
23
|
import { type IRankedRacer, type IRankedRacerScratch, rankRacers } from "../track/Ranking.js";
|
|
@@ -71,6 +78,10 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
71
78
|
const camera = ctx.camera as PerspectiveCamera;
|
|
72
79
|
setupCamera(camera);
|
|
73
80
|
ctx.add(camera);
|
|
81
|
+
const showTouchControls = isMobile() && isTouchscreenAvailable();
|
|
82
|
+
const touchControls = showTouchControls
|
|
83
|
+
? ctx.entities.add("touch-controls", new TouchControls(camera))
|
|
84
|
+
: undefined;
|
|
74
85
|
const track = buildTrack(ctx);
|
|
75
86
|
const car = new RacingCar(ctx, SPAWN);
|
|
76
87
|
const spawnDistance = track.route.project(SPAWN).distanceFromStart % track.route.totalLength;
|
|
@@ -136,7 +147,11 @@ export class Race extends Scene<GameState, IPhysicsContext> {
|
|
|
136
147
|
if (status !== "RACING") return;
|
|
137
148
|
lap.observe(observedPosition, car.mesh.position);
|
|
138
149
|
observedPosition.copy(car.mesh.position);
|
|
139
|
-
car.update(
|
|
150
|
+
car.update(
|
|
151
|
+
frameCtx,
|
|
152
|
+
dt,
|
|
153
|
+
touchControls?.update(frameCtx.input.raw.pointers, frameCtx.viewport.size),
|
|
154
|
+
);
|
|
140
155
|
rival.update(dt);
|
|
141
156
|
sector.update(car.mesh.position, car.forward, dt);
|
|
142
157
|
if (sector.rescue(car)) {
|
|
@@ -42,6 +42,26 @@ body {
|
|
|
42
42
|
background: var(--color-ink);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/* Boot failures are a page state, so the generated game owns their presentation. */
|
|
46
|
+
[data-threenative-canvas-error="true"] {
|
|
47
|
+
position: fixed;
|
|
48
|
+
inset: 0;
|
|
49
|
+
z-index: 1000;
|
|
50
|
+
display: grid;
|
|
51
|
+
place-items: center;
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
padding: clamp(1.5rem, 8vw, 6rem);
|
|
54
|
+
overflow: auto;
|
|
55
|
+
background: #fff7ed;
|
|
56
|
+
color: var(--color-ink);
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
font-size: clamp(1rem, 2vw, 1.5rem);
|
|
59
|
+
line-height: 1.5;
|
|
60
|
+
text-align: center;
|
|
61
|
+
white-space: pre-wrap;
|
|
62
|
+
overflow-wrap: anywhere;
|
|
63
|
+
}
|
|
64
|
+
|
|
45
65
|
/* The debug surface is framework plumbing; its default presentation is yours to change. */
|
|
46
66
|
[data-threenative-debug-overlay="true"] {
|
|
47
67
|
position: fixed;
|