create-threenative 0.2.3 → 0.2.5
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
|
@@ -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,17 +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
|
-
//
|
|
371
|
-
//
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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");
|
|
378
476
|
// Every stage here is perspective-camera maths — view-space reconstruction from depth,
|
|
379
477
|
// and a projection matrix inverse. The scene's camera is the one the pass rendered with.
|
|
380
478
|
const view = camera as PerspectiveCamera;
|
|
@@ -382,17 +480,39 @@ export class WorldEnvironment {
|
|
|
382
480
|
const base = target.baseColour?.(scenePass) ?? scenePass.getTextureNode("output");
|
|
383
481
|
const exposed = convertToTexture(base).mul(options.exposure);
|
|
384
482
|
const giDenoise = (node: ChainNode): ChainNode =>
|
|
385
|
-
options.denoiseEnabled ? denoised(denoise(node, depth, normal(), view)) : node;
|
|
483
|
+
options.denoiseEnabled ? denoised(denoise(node, depth(), normal(), view)) : node;
|
|
386
484
|
|
|
485
|
+
let releaseBloom = (): void => {};
|
|
387
486
|
const stages: ChainStage[] = [
|
|
388
487
|
stage({
|
|
389
488
|
name: "ssgi",
|
|
390
489
|
build: (input) => {
|
|
391
|
-
const gi = ssgi(input, depth, normal(), view);
|
|
490
|
+
const gi = ssgi(input, depth(), normal(), view);
|
|
392
491
|
const tier = SSGI_QUALITY[options.ssgiQuality];
|
|
393
492
|
gi.sliceCount.value = tier.sliceCount;
|
|
394
493
|
gi.stepCount.value = tier.stepCount;
|
|
395
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
|
+
}
|
|
396
516
|
|
|
397
517
|
// SSGI writes two targets: AO in a single-channel `RedFormat` texture, and the GI
|
|
398
518
|
// term in an RGB one. Multiplying the beauty pass by the whole AO vec4 therefore
|
|
@@ -412,7 +532,7 @@ export class WorldEnvironment {
|
|
|
412
532
|
stage({
|
|
413
533
|
name: "ambientOcclusion",
|
|
414
534
|
build: (input) => {
|
|
415
|
-
const contact = ao(depth, normal(), view);
|
|
535
|
+
const contact = ao(depth(), normal(), view);
|
|
416
536
|
contact.radius.value = options.gtaoRadius;
|
|
417
537
|
contact.scale.value = options.gtaoScale;
|
|
418
538
|
contact.samples.value = options.gtaoSamples;
|
|
@@ -435,11 +555,19 @@ export class WorldEnvironment {
|
|
|
435
555
|
if (light === undefined) return "godraysEnabled is true but no godraysLight was passed";
|
|
436
556
|
if (light.castShadow !== true)
|
|
437
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`;
|
|
438
566
|
return true;
|
|
439
567
|
},
|
|
440
568
|
build: (input) => {
|
|
441
569
|
const light = target.godraysLight as DirectionalLight;
|
|
442
|
-
const shafts = godrays(depth, view, light);
|
|
570
|
+
const shafts = godrays(depth(), view, light);
|
|
443
571
|
shafts.density.value = options.godraysDensity;
|
|
444
572
|
shafts.maxDensity.value = options.godraysMaxDensity;
|
|
445
573
|
shafts.raymarchSteps.value = options.godraysSteps;
|
|
@@ -450,7 +578,7 @@ export class WorldEnvironment {
|
|
|
450
578
|
// silhouettes the depth term owns. Denoise before the floor: the floor's
|
|
451
579
|
// subtraction amplifies relative noise on near-floor values.
|
|
452
580
|
let shaft: ChainNode = convertToTexture(shafts);
|
|
453
|
-
if (options.denoiseEnabled) shaft = denoised(denoise(shaft, depth, normal(), view));
|
|
581
|
+
if (options.denoiseEnabled) shaft = denoised(denoise(shaft, depth(), normal(), view));
|
|
454
582
|
// Floor, then scale, then tint. The floor is what turns this from a whole-frame
|
|
455
583
|
// brightener into a shaft renderer; the tint by the light's own colour is what
|
|
456
584
|
// stops a warm sun throwing a white beam.
|
|
@@ -476,7 +604,7 @@ export class WorldEnvironment {
|
|
|
476
604
|
// reflections onto a second copy builds two parallel graphs, and the frame comes
|
|
477
605
|
// out as the bare background colour.
|
|
478
606
|
const base = convertToTexture(input);
|
|
479
|
-
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], {
|
|
480
608
|
camera: view,
|
|
481
609
|
metalnessNode: metal().r,
|
|
482
610
|
roughnessNode: rough().g,
|
|
@@ -500,15 +628,33 @@ export class WorldEnvironment {
|
|
|
500
628
|
}),
|
|
501
629
|
stage({
|
|
502
630
|
name: "bloom",
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
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
|
+
},
|
|
512
658
|
}),
|
|
513
659
|
stage({
|
|
514
660
|
name: "vignette",
|
|
@@ -524,6 +670,11 @@ export class WorldEnvironment {
|
|
|
524
670
|
}),
|
|
525
671
|
];
|
|
526
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
|
+
|
|
527
678
|
// A composed base colour with every stage off still has to reach the frame. The chain
|
|
528
679
|
// installs nothing for an empty stage list, so this is the one path that goes direct.
|
|
529
680
|
if (requested.length === 0) {
|
|
@@ -541,11 +692,19 @@ export class WorldEnvironment {
|
|
|
541
692
|
if (renderer.createRenderChain === undefined) throw new Error("RenderChain is unavailable.");
|
|
542
693
|
const chain = renderer.createRenderChain({
|
|
543
694
|
input: exposed,
|
|
544
|
-
request: { stages: requested, tier:
|
|
695
|
+
request: { stages: requested, tier: options.renderChainTier },
|
|
545
696
|
stages,
|
|
697
|
+
worldPass: scenePass,
|
|
546
698
|
});
|
|
547
699
|
this.#reportApplied(chain.applied.stages, chain.applied.dropped);
|
|
548
|
-
return {
|
|
700
|
+
return {
|
|
701
|
+
dropped: chain.applied.dropped,
|
|
702
|
+
stages: chain.applied.stages,
|
|
703
|
+
dispose: () => {
|
|
704
|
+
chain.dispose();
|
|
705
|
+
scenePass.dispose();
|
|
706
|
+
},
|
|
707
|
+
};
|
|
549
708
|
}
|
|
550
709
|
|
|
551
710
|
/**
|
|
@@ -562,7 +721,7 @@ export class WorldEnvironment {
|
|
|
562
721
|
dropped: readonly { name: string; reason: string }[],
|
|
563
722
|
): void {
|
|
564
723
|
const options = this.#options;
|
|
565
|
-
const off: Record<
|
|
724
|
+
const off: Record<string, string> = {
|
|
566
725
|
ambientOcclusion: "gtaoEnabled is false",
|
|
567
726
|
bloom: "bloomEnabled is false",
|
|
568
727
|
godRays: "godraysEnabled is false",
|
|
@@ -570,12 +729,17 @@ export class WorldEnvironment {
|
|
|
570
729
|
ssgi: "ssgiEnabled is false",
|
|
571
730
|
ssr: "ssrEnabled is false",
|
|
572
731
|
vignette: "vignetteAmount is 0",
|
|
732
|
+
kuwahara: "kuwaharaEnabled is false",
|
|
733
|
+
outline: "outlineEnabled is false",
|
|
734
|
+
watercolor: "watercolorEnabled is false",
|
|
573
735
|
};
|
|
574
|
-
const stages =
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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
|
+
});
|
|
579
743
|
console.info(
|
|
580
744
|
`TN_WORLD_ENVIRONMENT:${JSON.stringify({
|
|
581
745
|
denoise: options.denoiseEnabled,
|
|
@@ -588,3 +752,7 @@ export class WorldEnvironment {
|
|
|
588
752
|
);
|
|
589
753
|
}
|
|
590
754
|
}
|
|
755
|
+
|
|
756
|
+
function isChainTier(value: unknown): value is ChainTier {
|
|
757
|
+
return value === "high" || value === "medium" || value === "low" || value === "off";
|
|
758
|
+
}
|
|
@@ -1,16 +1,23 @@
|
|
|
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
|
-
import { Fog,
|
|
9
|
+
import { Fog, type PerspectiveCamera } from "three";
|
|
4
10
|
import { Ship } from "../entities/Ship.js";
|
|
5
11
|
import { followShip, setupCamera } from "../render/camera.js";
|
|
6
12
|
import { setupLighting } from "../render/lighting.js";
|
|
7
13
|
import { createLoadingScreen } from "../render/loading.js";
|
|
8
14
|
import { createMaterials } from "../render/materials.js";
|
|
9
|
-
import {
|
|
15
|
+
import { createOcean, createWaterMesh } from "../render/ocean.js";
|
|
16
|
+
import { palette } from "../render/palette.js";
|
|
10
17
|
import { setupPost } from "../render/postprocessing.js";
|
|
11
18
|
import { createBuoy, createIsland } from "../render/props.js";
|
|
12
19
|
import { setupSky } from "../render/sky.js";
|
|
13
|
-
import {
|
|
20
|
+
import { TouchControls } from "../render/touch-controls.js";
|
|
14
21
|
import type { GameState } from "../state.js";
|
|
15
22
|
|
|
16
23
|
export type GameCtx = ICtx<GameState, IPhysicsContext>;
|
|
@@ -31,19 +38,25 @@ export class Sailing extends Scene<GameState, IPhysicsContext> {
|
|
|
31
38
|
|
|
32
39
|
override enter(ctx: GameCtx): SceneFrame<GameState, IPhysicsContext> {
|
|
33
40
|
setupSky(ctx.scene);
|
|
34
|
-
|
|
41
|
+
// Fog to the horizon colour, and starting far enough out that the island is not eaten. At
|
|
42
|
+
// 30..100 against a dark navy the sea went to slate a boat-length away.
|
|
43
|
+
ctx.scene.fog = new Fog(palette.skyLow, 95, 330);
|
|
35
44
|
const sun = setupLighting(ctx.scene, ctx.renderer.raw as Parameters<typeof setupLighting>[1]);
|
|
36
45
|
setupPost(ctx.renderer, ctx.scene, ctx.camera, { godraysLight: sun, mobile: isMobile() });
|
|
37
46
|
const loading = createLoadingScreen(ctx);
|
|
38
47
|
const camera = ctx.camera as PerspectiveCamera;
|
|
39
48
|
setupCamera(camera);
|
|
49
|
+
ctx.add(camera);
|
|
50
|
+
const showTouchControls = isMobile() && isTouchscreenAvailable();
|
|
51
|
+
const touchControls = showTouchControls
|
|
52
|
+
? ctx.entities.add("touch-controls", new TouchControls(camera))
|
|
53
|
+
: undefined;
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
ctx.add(water);
|
|
55
|
+
// `SpectralOcean` is a compute-driven node: `ctx.add` hands it the renderer and puts its
|
|
56
|
+
// passes in the warmup set. It draws nothing — the mesh and its material are this game's, and
|
|
57
|
+
// both live in `src/render/ocean.ts`.
|
|
58
|
+
const ocean = ctx.add(createOcean());
|
|
59
|
+
ctx.add(createWaterMesh(ocean));
|
|
47
60
|
|
|
48
61
|
const materials = createMaterials();
|
|
49
62
|
ctx.add(createIsland(materials));
|
|
@@ -53,7 +66,7 @@ export class Sailing extends Scene<GameState, IPhysicsContext> {
|
|
|
53
66
|
ctx.add(buoy);
|
|
54
67
|
}
|
|
55
68
|
|
|
56
|
-
const ship = new Ship(ctx,
|
|
69
|
+
const ship = new Ship(ctx, ocean);
|
|
57
70
|
ctx.entities.add("player", ship);
|
|
58
71
|
let elapsed = 0;
|
|
59
72
|
let buoysRounded = 0;
|
|
@@ -64,7 +77,12 @@ export class Sailing extends Scene<GameState, IPhysicsContext> {
|
|
|
64
77
|
status = "lost";
|
|
65
78
|
return;
|
|
66
79
|
}
|
|
67
|
-
ship.update(
|
|
80
|
+
ship.update(
|
|
81
|
+
frameCtx,
|
|
82
|
+
deltaTime,
|
|
83
|
+
wind,
|
|
84
|
+
touchControls?.update(frameCtx.input.raw.pointers, frameCtx.viewport.size),
|
|
85
|
+
);
|
|
68
86
|
const nextBuoy = COURSE_BUOYS[buoysRounded];
|
|
69
87
|
if (nextBuoy === undefined || ship.mesh.position.z > nextBuoy) {
|
|
70
88
|
if (wind <= 0) status = "lost";
|
|
@@ -85,9 +103,13 @@ export class Sailing extends Scene<GameState, IPhysicsContext> {
|
|
|
85
103
|
}
|
|
86
104
|
|
|
87
105
|
elapsed += deltaTime;
|
|
88
|
-
field.setTime(elapsed);
|
|
89
106
|
const wind = Math.max(0, 1 - elapsed / 45);
|
|
107
|
+
ocean.advance(elapsed);
|
|
90
108
|
if (status === "sailing") advanceSailing(frameCtx, deltaTime, wind);
|
|
109
|
+
// Outside the gameplay gate on purpose. Steering and buoy counting stop when the run ends;
|
|
110
|
+
// the hull still has to be placed on a sea that never stops moving, or the boat freezes
|
|
111
|
+
// mid-wave while the water rolls past underneath it.
|
|
112
|
+
ship.updateVisual(deltaTime);
|
|
91
113
|
|
|
92
114
|
const state = frameCtx.state.getState();
|
|
93
115
|
frameCtx.state.set({
|
|
@@ -96,11 +118,16 @@ export class Sailing extends Scene<GameState, IPhysicsContext> {
|
|
|
96
118
|
paused: state.paused,
|
|
97
119
|
shipZ: ship.mesh.position.z,
|
|
98
120
|
status,
|
|
99
|
-
submergedFraction: ship.
|
|
121
|
+
submergedFraction: ship.immersion,
|
|
100
122
|
uiReady: frameCtx.state.getState().uiReady,
|
|
101
123
|
wind,
|
|
102
124
|
});
|
|
103
|
-
|
|
125
|
+
// The **visual**, not the body. `Ship` draws the hull from `ship.visual`, whose y is the sea
|
|
126
|
+
// surface; `ship.mesh` is the physics body, whose y wanders on a throttled height copy and
|
|
127
|
+
// is no longer what anything is drawn at. Following the body pointed the camera somewhere
|
|
128
|
+
// the ship was not: the horizon slid up and down behind a hull that was itself steady, so
|
|
129
|
+
// the ship read as bobbing out of the water and back into it.
|
|
130
|
+
followShip(camera, ship.visual.position);
|
|
104
131
|
};
|
|
105
132
|
}
|
|
106
133
|
}
|
|
@@ -27,6 +27,26 @@ body {
|
|
|
27
27
|
background: #061b2b;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/* Boot failures are a page state, so the generated game owns their presentation. */
|
|
31
|
+
[data-threenative-canvas-error="true"] {
|
|
32
|
+
position: fixed;
|
|
33
|
+
inset: 0;
|
|
34
|
+
z-index: 1000;
|
|
35
|
+
display: grid;
|
|
36
|
+
place-items: center;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
padding: clamp(1.5rem, 8vw, 6rem);
|
|
39
|
+
overflow: auto;
|
|
40
|
+
background: #fff7ed;
|
|
41
|
+
color: var(--color-ink);
|
|
42
|
+
font-family: inherit;
|
|
43
|
+
font-size: clamp(1rem, 2vw, 1.5rem);
|
|
44
|
+
line-height: 1.5;
|
|
45
|
+
text-align: center;
|
|
46
|
+
white-space: pre-wrap;
|
|
47
|
+
overflow-wrap: anywhere;
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
/* The debug surface is framework plumbing; its default presentation is yours to change. */
|
|
31
51
|
[data-threenative-debug-overlay="true"] {
|
|
32
52
|
position: fixed;
|
|
@@ -19,6 +19,7 @@ const config: IThreeNativeConfig = {
|
|
|
19
19
|
title: "__PROJECT_NAME__",
|
|
20
20
|
width: 1280,
|
|
21
21
|
height: 720,
|
|
22
|
+
maximized: false,
|
|
22
23
|
resizable: true,
|
|
23
24
|
},
|
|
24
25
|
bootSplash: { backgroundColor: "#061b2b" },
|
|
@@ -26,8 +27,13 @@ const config: IThreeNativeConfig = {
|
|
|
26
27
|
renderer: {
|
|
27
28
|
preferWebGPU: true,
|
|
28
29
|
resolutionScale: "auto",
|
|
30
|
+
// Multisampling resolves triangle edges. A cutout silhouette — foliage, a fence, hair — is
|
|
31
|
+
// carved inside the triangle by an alpha test, so it resolves through the coverage mask or
|
|
32
|
+
// not at all, which is what this spends the samples above on. It costs no target and no
|
|
33
|
+
// extra pass; set it false for a deliberately hard-edged look. `TN_ALPHA_ANTIALIASING`
|
|
34
|
+
// reports what it did, and says so when a single-sampled surface leaves it nothing to do.
|
|
35
|
+
alphaAntialiasing: true,
|
|
29
36
|
},
|
|
30
|
-
assets: { models: "none", textures: "none" },
|
|
31
37
|
ui: { renderer: "web" },
|
|
32
38
|
};
|
|
33
39
|
|
|
@@ -13,3 +13,7 @@ args = ["./node_modules/@threenative/core/mcp/sculpt.mjs"]
|
|
|
13
13
|
[mcp_servers.threenative-engine]
|
|
14
14
|
command = "node"
|
|
15
15
|
args = ["./node_modules/@threenative/core/mcp/engine.mjs"]
|
|
16
|
+
|
|
17
|
+
[mcp_servers.threenative-blender]
|
|
18
|
+
command = "node"
|
|
19
|
+
args = ["./node_modules/@threenative/core/mcp/blender.mjs"]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
10
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"threenative-sculpt": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": [
|
|
16
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"threenative-engine": {
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"threenative-blender": {
|
|
26
|
+
"command": "node",
|
|
27
|
+
"args": [
|
|
28
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mcpServers": {
|
|
3
|
+
"threenative-assets": {
|
|
4
|
+
"command": "node",
|
|
5
|
+
"args": [
|
|
6
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
7
|
+
],
|
|
8
|
+
"env": {
|
|
9
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
10
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"threenative-sculpt": {
|
|
14
|
+
"command": "node",
|
|
15
|
+
"args": [
|
|
16
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"threenative-engine": {
|
|
20
|
+
"command": "node",
|
|
21
|
+
"args": [
|
|
22
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"threenative-blender": {
|
|
26
|
+
"command": "node",
|
|
27
|
+
"args": [
|
|
28
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|