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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!-- Generated mirror of AGENTS.md. Do not edit; edit AGENTS.md. -->
|
|
2
|
+
|
|
3
|
+
# AGENTS.md — __PROJECT_NAME__ runner
|
|
4
|
+
|
|
5
|
+
Instructions for the AI agent in this game. `CLAUDE.md` mirrors this file; edit `AGENTS.md`.
|
|
6
|
+
|
|
7
|
+
## Ownership
|
|
8
|
+
|
|
9
|
+
ThreeNative owns bootstrap, renderer, fixed-step loop, input, loading, physics bindings, and the state bridge. This repository owns the track, the runner, the obstacles, the dust, the HUD and the
|
|
10
|
+
look; `src/game.ts` is portable and React mounts only from `src/main.ts`.
|
|
11
|
+
|
|
12
|
+
## Start every change
|
|
13
|
+
|
|
14
|
+
1. **Critical planning gate:** invoke `threenative-capabilities` before `prd-creator`. Search
|
|
15
|
+
`engine_search_capabilities` for the full request and each concrete mechanic, inspect relevant
|
|
16
|
+
matches with `engine_capability_detail`, and record a capability or no-match for the plan.
|
|
17
|
+
2. Then invoke `prd-creator`. Draft the plan around those capabilities and binding constraints,
|
|
18
|
+
direct the user to review it, and wait for explicit approval plus an instruction to implement it.
|
|
19
|
+
3. Treat returned constraints as binding. No navmesh is imported, so this kit runs on every
|
|
20
|
+
target; `@threenative/physics/navigation` would make it web and desktop only. `GPUParticles3D`
|
|
21
|
+
is WebGPU-only and the dust depends on it.
|
|
22
|
+
4. If a build, import, device, or blank frame fails, run `npx threenative doctor` and
|
|
23
|
+
`npx @threenative/playtest doctor`; missing observations are not zero.
|
|
24
|
+
For *"a bullet passes through a wall"*, `RigidBody3D` defaults to continuous collision; `continuousCollision` is the named per-body override, and `body.continuousCollision` reports the effective setting on web/native.
|
|
25
|
+
|
|
26
|
+
## When the framework blocks you, write plain Three.js
|
|
27
|
+
|
|
28
|
+
When an `@threenative/*` API is broken, missing, or does not do what you need, replace only that
|
|
29
|
+
piece with portable Three.js/plain code. Keep the loop, scenes, input, registry, and playtest
|
|
30
|
+
bridge; avoid DOM globals, dynamic `import()`, and raw physics handles. **Report what blocked you**
|
|
31
|
+
(API, expectation, result, replacement); never stall the game.
|
|
32
|
+
|
|
33
|
+
## Workflow skills
|
|
34
|
+
|
|
35
|
+
- `.agents/skills/prd-creator/SKILL.md` / `.claude/skills/prd-creator/SKILL.md` — game plan and approval gate.
|
|
36
|
+
- `.agents/skills/threenative-capabilities/SKILL.md` / `.claude/skills/threenative-capabilities/SKILL.md` — capability search.
|
|
37
|
+
- `.agents/skills/threenative-playtest/SKILL.md` / `.claude/skills/threenative-playtest/SKILL.md` — diagnosis and proof.
|
|
38
|
+
- `.agents/skills/threenative-assets/SKILL.md` / `.claude/skills/threenative-assets/SKILL.md` — assets and sculpting.
|
|
39
|
+
- `.agents/skills/threenative-visuals/SKILL.md` / `.claude/skills/threenative-visuals/SKILL.md` — captures and look.
|
|
40
|
+
- `.agents/skills/threenative-performance/SKILL.md` / `.claude/skills/threenative-performance/SKILL.md` — measured budgets.
|
|
41
|
+
- `.agents/skills/threenative-ui/SKILL.md` / `.claude/skills/threenative-ui/SKILL.md` — native-safe UI.
|
|
42
|
+
- `.agents/skills/threenative-context/SKILL.md` / `.claude/skills/threenative-context/SKILL.md` — portable ctx APIs.
|
|
43
|
+
- Confirmed framework bugs: use `file-engine-bug` in `.agents/skills/` or `.claude/skills/` after a minimal repro.
|
|
44
|
+
|
|
45
|
+
## Commands and map
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pnpm dev
|
|
49
|
+
pnpm build
|
|
50
|
+
pnpm build --target desktop
|
|
51
|
+
pnpm test
|
|
52
|
+
pnpm typecheck
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`src/track.ts` is a ring of six chunks **moved and rewritten**, never rebuilt: each chunk's
|
|
56
|
+
obstacle `InstancedMesh` is built once at a fixed slot count and its matrices rewritten on
|
|
57
|
+
recycle. The obstacle *bodies* are the exception — disposed and recreated, because `RigidBody3D`
|
|
58
|
+
cannot reposition a fixed body. The runner is not a rigid body — a lane snap and a jump
|
|
59
|
+
arc feel worse in a solver — but the collision is real: `src/entities/Runner.ts` carries an
|
|
60
|
+
`Area3D` masked to the obstacle layer and listens for `bodyEntered`, so a hit is an overlap the
|
|
61
|
+
engine reports rather than a hand-maintained distance check. Gravity is zero in `src/game.ts` on purpose;
|
|
62
|
+
nothing falls. The track comes from `ctx.random`, so `defineGame({ seed })` **is** the level.
|
|
63
|
+
Register entities with `ctx.entities`; the React HUD reads `GameState`, never an entity. Keep `playtests/survives.playtest.json` as smoke proof, and `streams` honest
|
|
64
|
+
when chunk recycling changes.
|
|
65
|
+
|
|
66
|
+
## Portable authoring contracts
|
|
67
|
+
|
|
68
|
+
Leave `assets` absent: the cook selects target-decodable passes, with `models.sharedImages: true` deduplicating images. `sharedImages: false` embeds duplicate copies; `models: "none"` / `textures: "none"` / `audio: "none"` skip those passes and report uncooked bytes. Android/iOS currently skip compression and model dedupe. `assets.exclude` defaults to `[]`; source-relative globs (for example `["unused/**"]`) omit matching files and report saved bytes. `assets.budget` accepts `{ uncooked?: number | "none", total?: number | "none" }`, default `{ uncooked: 64_000_000, total: "none" }`: only bytes left uncooked where cooking was possible count toward `uncooked`. A number sets that ceiling; `"none"` disables both gates. Either disabled gate still reports bytes. Automatic texture cooking retains unaligned source images unchanged and reports `block-size`; those bytes still count toward the uncooked budget. An explicit compression codec override must satisfy four-pixel block alignment; `codec: "none"` opts out. Cooking never silently resizes an image to fix alignment.
|
|
69
|
+
|
|
70
|
+
Relative look capture: a binding with `pointerRelative: true` captures the canvas on click by default; set `captureOnClick: false` and call `ctx.input.captureMouse()` from your own gesture to opt out. Desktop mode precedence is CLI (`--windowed`, `--maximized`, `--fullscreen`) over `display.fullscreen` over `window.maximized`; with both false, `window.width`/`height` size the normal window.
|
|
71
|
+
Scenes use `load`, `enter`, `update`, `exit`, `render`; physics nodes are Godot-named and disposable. Generated conventions call `GroundSnap` for floor contact and `normaliseToMetres` for authored model scale.
|
|
72
|
+
The camera reads the runner **after** the step through `afterPhysics` — in the frame function that
|
|
73
|
+
is 0.4 m of lag at 26 m/s. `CameraShake` returns an offset; `src/render/camera.ts` adds it.
|
|
74
|
+
`input.vector("move").y` is +up, so forward uses one explicit `-move.y` conversion. Rigged assets: put a `.glb` in `assets/`, await `ctx.assets.model("hero.glb")` in `Scene.load()`, then drive
|
|
75
|
+
`AnimationPlayer` beside its entity. `ctx.goto(name)` rebuilds without resetting game state; from
|
|
76
|
+
a frame function `goto` and then `return`; `ctx.state.set({ /* copy this game's initial-state shape */ })`
|
|
77
|
+
is a partial patch. `game.goto("<scene-name>")` also rebuilds the scene, but it resets the game's
|
|
78
|
+
state. Seeded randomness is deterministic only when `defineGame({ seed })` is configured.
|
|
79
|
+
|
|
80
|
+
When an animation looks wrong, measure it before rewriting it. `clipPoseError` scores a
|
|
81
|
+
retargeted clip against its source per bone in degrees — whole quaternions relative to each rig's
|
|
82
|
+
own bind pose, so the two rigs' bind conventions cancel and a limb rolled about its own axis is
|
|
83
|
+
caught where a bone-direction check reads zero. `clipTrackBindings` names tracks that bind nothing
|
|
84
|
+
(the `<bone>.undefined` failure that plays the bind pose instead of the animation),
|
|
85
|
+
`clipBoneCoverage` names bones the clip does not drive and which therefore keep the previous
|
|
86
|
+
clip's pose, and `boneContact` reports in metres whether a named bone reaches the prop it is
|
|
87
|
+
supposed to be touching. Two loading conventions come from `@threenative/core`, not from your own loops: `loadAll(items, load)` fetches six at a time and returns results **in the input's order** (a pool that pushes returns completion order, so a positional pick lands a different asset every load), and `addInSlices(objects, (object) => ctx.add(object))` attaches 256 per presented frame so hundreds of objects never land in one long frame; override `concurrency`/`sliceSize`, pass `while: () => alive` to stop a torn-down scene without throwing, and `marker: false` silences `TN_LOAD_ALL`/`TN_ADD_SLICES` but never the measurement.
|
|
88
|
+
|
|
89
|
+
## Budget real time for the look — see `agent-docs/dream-loop.md`
|
|
90
|
+
|
|
91
|
+
Edit `src/render/` directly; `postprocessing.ts` reports stages but decides no game colour. Quality
|
|
92
|
+
tiers live in `src/render/quality.ts`: `low`, `medium`, `high`; `isMobile()` chooses `low`, otherwise
|
|
93
|
+
`high`; override with `setupPost(..., { tier: "low" })`. Unknown tiers throw and `TN_QUALITY_TIER`
|
|
94
|
+
reports the source. A scenario with no assertions or missing observations fails; open a real capture.
|
|
95
|
+
|
|
96
|
+
Recipes shipped in the project: `agent-docs/assertion-reference.md`, `agent-docs/capability-reference.md`, `agent-docs/capture-the-frame.md`, `agent-docs/creating-creatures.md`, `agent-docs/ctx-cookbook.md`, `agent-docs/debug-surface.md`, `agent-docs/finding-assets.md`, `agent-docs/gameplay-recipes.md`, `agent-docs/menu-screens.md`, `agent-docs/mobile-memory-budget.md`, `agent-docs/sculpt-from-a-reference.md`, `agent-docs/trace-a-slow-frame.md`, `agent-docs/visual-baseline.md`, and `agent-docs/webview-ui.md`.
|
|
97
|
+
## Optional multiplayer transport
|
|
98
|
+
For online play only, import `connect` from `@threenative/core/net` with an HTTPS URL and nonempty identity credential; configure `connectTimeoutMs`, `maxReliableMessageBytes`, `maxQueuedReliableBytes`, and `maxQueuedDatagrams` (10s/65,536/1 MiB/256), use `reliable-ordered` for ordered reliable messages and bounded `unreliable` datagrams that may drop, and keep serialization, replication, prediction, interpolation, snapshots and rejoin in this game's `src/` and server. There is no fallback: unsupported WebTransport/native rejects with `TN_NET_UNAVAILABLE`; reference Go server: `packages/runtime-native/examples/webtransport/server`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Runner starter kit
|
|
2
|
+
|
|
3
|
+
Three lanes and a track that builds itself ahead of you. Obstacles end the run; passing one
|
|
4
|
+
close shakes the camera. The track is a ring of six chunks that get moved and rebuilt, so a
|
|
5
|
+
ten-minute run costs what a ten-second one does.
|
|
6
|
+
|
|
7
|
+
Nothing here is downloaded. Every shape is a box, capsule or cylinder built in
|
|
8
|
+
`src/render/shapes.ts`, and the dust is a TSL particle surface in `src/render/dust.ts` — no
|
|
9
|
+
texture, no asset licence, nothing to fetch.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm dev # play it
|
|
13
|
+
pnpm test # the committed scenarios, in a real browser
|
|
14
|
+
pnpm build # web
|
|
15
|
+
pnpm build --target desktop
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Controls
|
|
19
|
+
|
|
20
|
+
| Input | Does |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `A` / `D`, or arrows | change lane |
|
|
23
|
+
| `Space` | jump |
|
|
24
|
+
| `R` | run again |
|
|
25
|
+
|
|
26
|
+
On a touch device two lane buttons and a thumbstick appear; flick the stick up to jump.
|
|
27
|
+
|
|
28
|
+
## What each piece is
|
|
29
|
+
|
|
30
|
+
| File | Owns |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `src/track.ts` | the chunk ring — build, recycle, and the obstacle bodies |
|
|
33
|
+
| `src/entities/Runner.ts` | the lane snap, the jump arc, and the `Area3D` that detects a hit |
|
|
34
|
+
| `src/render/dust.ts` | the trail: a game-authored TSL surface handed to `GPUParticles3D` |
|
|
35
|
+
| `src/render/camera.ts` | the chase rig, and where the shake is added |
|
|
36
|
+
| `src/render/` | everything that decides how it looks. Yours to rewrite. |
|
|
37
|
+
|
|
38
|
+
## Where to take it
|
|
39
|
+
|
|
40
|
+
The track is `RESIDENT_CHUNKS` slices and one `build` method. Add a second obstacle height that
|
|
41
|
+
has to be jumped rather than dodged, a pickup lane, a speed gate, or a second seed that swaps the
|
|
42
|
+
palette every kilometre. `defineGame({ seed })` is the level — change it and the whole track
|
|
43
|
+
changes, deterministically.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>__PROJECT_NAME__</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://opencode.ai/config.json",
|
|
3
|
+
"mcp": {
|
|
4
|
+
"threenative-assets": {
|
|
5
|
+
"type": "local",
|
|
6
|
+
"command": [
|
|
7
|
+
"node",
|
|
8
|
+
"./node_modules/@threenative/core/mcp/assets.mjs"
|
|
9
|
+
],
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"environment": {
|
|
12
|
+
"ASSET_DOWNLOAD_DIR": "./public/assets",
|
|
13
|
+
"AUDIO_DOWNLOAD_DIR": "./public/audio"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"threenative-sculpt": {
|
|
17
|
+
"type": "local",
|
|
18
|
+
"command": [
|
|
19
|
+
"node",
|
|
20
|
+
"./node_modules/@threenative/core/mcp/sculpt.mjs"
|
|
21
|
+
],
|
|
22
|
+
"enabled": true
|
|
23
|
+
},
|
|
24
|
+
"threenative-engine": {
|
|
25
|
+
"type": "local",
|
|
26
|
+
"command": [
|
|
27
|
+
"node",
|
|
28
|
+
"./node_modules/@threenative/core/mcp/engine.mjs"
|
|
29
|
+
],
|
|
30
|
+
"enabled": true
|
|
31
|
+
},
|
|
32
|
+
"threenative-blender": {
|
|
33
|
+
"type": "local",
|
|
34
|
+
"command": [
|
|
35
|
+
"node",
|
|
36
|
+
"./node_modules/@threenative/core/mcp/blender.mjs"
|
|
37
|
+
],
|
|
38
|
+
"enabled": true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"private": true,
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "threenative build",
|
|
9
|
+
"build:web": "threenative build --target web",
|
|
10
|
+
"build:desktop": "threenative build --target desktop",
|
|
11
|
+
"build:android": "threenative build --target android",
|
|
12
|
+
"build:ios": "threenative build --target ios",
|
|
13
|
+
"pretest": "playwright install chromium",
|
|
14
|
+
"test": "vite build && threenative-playtest --scenario \"playtests/*.playtest.json\" --browser-recipe webgpu --headed --server-command \"pnpm dev --host 127.0.0.1 --port $PORT --strictPort\"",
|
|
15
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@threenative/core": "0.3.2",
|
|
19
|
+
"@threenative/physics": "0.3.2",
|
|
20
|
+
"@threenative/ui": "0.3.2",
|
|
21
|
+
"react": "19.2.0",
|
|
22
|
+
"react-dom": "19.2.0",
|
|
23
|
+
"three": "0.185.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@gltf-transform/cli": "4.4.2",
|
|
27
|
+
"@tailwindcss/vite": "4.3.3",
|
|
28
|
+
"@threenative/assets": "0.3.2",
|
|
29
|
+
"@threenative/playtest": "0.3.2",
|
|
30
|
+
"@types/react": "19.2.0",
|
|
31
|
+
"@types/react-dom": "19.2.0",
|
|
32
|
+
"@types/three": "0.185.3",
|
|
33
|
+
"@vitejs/plugin-react": "6.0.5",
|
|
34
|
+
"create-threenative": "0.2.5",
|
|
35
|
+
"esbuild": "0.27.0",
|
|
36
|
+
"playwright": "1.62.1",
|
|
37
|
+
"tailwindcss": "4.3.3",
|
|
38
|
+
"typescript": "5.9.3",
|
|
39
|
+
"vite": "8.2.0"
|
|
40
|
+
},
|
|
41
|
+
"optionalDependencies": {
|
|
42
|
+
"@threenative/runtime-native": "0.3.2"
|
|
43
|
+
},
|
|
44
|
+
"pnpm": {
|
|
45
|
+
"onlyBuiltDependencies": ["@threenative/core", "@threenative/runtime-native"],
|
|
46
|
+
"patchedDependencies": {
|
|
47
|
+
"three@0.185.1": "patches/three@0.185.1.patch"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"acceptanceId": "runner-production-performance",
|
|
3
|
+
"artifacts": { "screenshots": "after" },
|
|
4
|
+
"assert": {
|
|
5
|
+
"performance": {
|
|
6
|
+
"maxDrawCalls": 145,
|
|
7
|
+
"maxFrameMsP95": 33,
|
|
8
|
+
"maxTriangles": 26000,
|
|
9
|
+
"minFps": 30
|
|
10
|
+
},
|
|
11
|
+
"renderChain": { "tier": "high" }
|
|
12
|
+
},
|
|
13
|
+
"name": "production-performance",
|
|
14
|
+
"schemaVersion": 1,
|
|
15
|
+
"steps": [
|
|
16
|
+
{ "kind": "input", "press": "KeyA", "holdTicks": 6, "release": true },
|
|
17
|
+
{ "kind": "wait", "waitTicks": 600, "release": true }
|
|
18
|
+
],
|
|
19
|
+
"subject": "player",
|
|
20
|
+
"target": "web",
|
|
21
|
+
"viewport": { "height": 1080, "width": 1920 },
|
|
22
|
+
"warmupFrames": 60
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "streams",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 40,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "wait", "label": "run-a-while", "waitTicks": 300, "release": true },
|
|
10
|
+
{ "kind": "input", "label": "lane-left", "press": "KeyA", "holdTicks": 6, "release": true },
|
|
11
|
+
{ "kind": "wait", "label": "settle", "waitTicks": 60, "release": true }
|
|
12
|
+
],
|
|
13
|
+
"assert": {
|
|
14
|
+
"diagnostics": {
|
|
15
|
+
"noConsoleErrors": true,
|
|
16
|
+
"noNetworkErrors": true,
|
|
17
|
+
"noRuntimeDiagnostics": true,
|
|
18
|
+
"runtimeReady": true
|
|
19
|
+
},
|
|
20
|
+
"resources": [
|
|
21
|
+
{
|
|
22
|
+
"id": "GameState",
|
|
23
|
+
"path": "chunks",
|
|
24
|
+
"gte": 7
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"changed": true,
|
|
28
|
+
"id": "GameState",
|
|
29
|
+
"path": "distance"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"movement": {
|
|
33
|
+
"entity": "player",
|
|
34
|
+
"minDistance": 20,
|
|
35
|
+
"minAxisDelta": { "axis": "-z", "min": 20 }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "survives",
|
|
3
|
+
"target": "web",
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"viewport": { "width": 1280, "height": 720 },
|
|
6
|
+
"warmupFrames": 40,
|
|
7
|
+
"subject": "player",
|
|
8
|
+
"steps": [
|
|
9
|
+
{ "kind": "input", "label": "move", "press": "ArrowUp", "holdTicks": 60, "release": true },
|
|
10
|
+
{ "kind": "wait", "label": "settle", "waitTicks": 10, "release": true }
|
|
11
|
+
],
|
|
12
|
+
"assert": {
|
|
13
|
+
"diagnostics": {
|
|
14
|
+
"noConsoleErrors": true,
|
|
15
|
+
"noNetworkErrors": true,
|
|
16
|
+
"noRuntimeDiagnostics": true,
|
|
17
|
+
"runtimeReady": true
|
|
18
|
+
},
|
|
19
|
+
"components": [
|
|
20
|
+
{
|
|
21
|
+
"allowTrivial": "GroundSnap settles the runner on the track before this observation; the finite near-zero clearance is the generated call-site proof.",
|
|
22
|
+
"component": "groundClearance",
|
|
23
|
+
"entity": "player",
|
|
24
|
+
"lte": 0.01
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"movement": {
|
|
28
|
+
"entity": "player",
|
|
29
|
+
"minDistance": 0.5,
|
|
30
|
+
"minAxisDelta": { "axis": "-z", "min": 0.5 }
|
|
31
|
+
},
|
|
32
|
+
"visibility": [
|
|
33
|
+
{
|
|
34
|
+
"entity": "touch-controls",
|
|
35
|
+
"present": false,
|
|
36
|
+
"allowTrivial": "Desktop keyboard lanes intentionally omit touch controls while movement proves the scene is active."
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"visual": [
|
|
40
|
+
{
|
|
41
|
+
"region": {
|
|
42
|
+
"x": 0,
|
|
43
|
+
"y": 0,
|
|
44
|
+
"width": 1280,
|
|
45
|
+
"height": 720,
|
|
46
|
+
"minNonblankPixelRatio": 0.01
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GroundSnap, normaliseToMetres } from "@threenative/core";
|
|
2
|
+
import type { Group } from "three";
|
|
3
|
+
|
|
4
|
+
export interface IRunnerConventions {
|
|
5
|
+
readonly applyGrounding: (surfaceY: number, dt: number) => void;
|
|
6
|
+
readonly groundSnap: GroundSnap;
|
|
7
|
+
readonly normaliseFactor: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* One metre is one metre, and the runner's feet meet the track — including mid-jump.
|
|
12
|
+
*
|
|
13
|
+
* `GroundSnap` takes the surface height as an argument, so a jump is a *surface that moved*
|
|
14
|
+
* rather than an exception to grounding. That is what keeps the landing exact at any frame rate.
|
|
15
|
+
*/
|
|
16
|
+
export function prepareRunnerConventions(model: Group): IRunnerConventions {
|
|
17
|
+
const normaliseFactor = normaliseToMetres(model, { axis: "height", metres: 1.6 });
|
|
18
|
+
const groundSnap = new GroundSnap(model);
|
|
19
|
+
return {
|
|
20
|
+
applyGrounding: (surfaceY, dt) => groundSnap.apply(model, surfaceY, dt),
|
|
21
|
+
groundSnap,
|
|
22
|
+
normaliseFactor,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ICtx } from "@threenative/core";
|
|
2
|
+
import { Area3D, CollisionShape3D } from "@threenative/physics";
|
|
3
|
+
import { type Group, MathUtils } from "three";
|
|
4
|
+
import { type IRunnerConventions, prepareRunnerConventions } from "../conventions.js";
|
|
5
|
+
import { OBSTACLE_LAYER, type RunnerPhysics } from "../physics.js";
|
|
6
|
+
import { runner as runnerMesh } from "../render/shapes.js";
|
|
7
|
+
import type { ITouchInput } from "../render/touch-controls.js";
|
|
8
|
+
import type { GameState } from "../state.js";
|
|
9
|
+
import { LANE_X } from "../track.js";
|
|
10
|
+
|
|
11
|
+
type GameCtx = ICtx<GameState, RunnerPhysics>;
|
|
12
|
+
|
|
13
|
+
const LANE_BLEND = 12;
|
|
14
|
+
const JUMP_SPEED = 7.2;
|
|
15
|
+
const GRAVITY = -19;
|
|
16
|
+
/** Within this many metres of an obstacle's centre and still alive: a near miss. */
|
|
17
|
+
const NEAR_MISS = 1.5;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The player.
|
|
21
|
+
*
|
|
22
|
+
* Not a rigid body: a runner's feel is a lane snap and a fixed jump arc, and handing either to a
|
|
23
|
+
* solver makes both worse. What *is* physics is the collision — the runner carries an `Area3D`
|
|
24
|
+
* that scans the obstacle layer, so a hit is an overlap the engine reports rather than a distance
|
|
25
|
+
* check this file would have to keep in sync with the obstacle geometry.
|
|
26
|
+
*/
|
|
27
|
+
export class Runner {
|
|
28
|
+
readonly mesh: Group;
|
|
29
|
+
readonly tags = ["player", "runner"];
|
|
30
|
+
readonly hitbox: Area3D;
|
|
31
|
+
#conventions: IRunnerConventions;
|
|
32
|
+
#lane = 1;
|
|
33
|
+
#height = 0;
|
|
34
|
+
#vertical = 0;
|
|
35
|
+
#crashed = false;
|
|
36
|
+
#nearMisses = 0;
|
|
37
|
+
|
|
38
|
+
constructor(ctx: GameCtx) {
|
|
39
|
+
this.mesh = runnerMesh();
|
|
40
|
+
this.mesh.name = "player";
|
|
41
|
+
this.#conventions = prepareRunnerConventions(this.mesh);
|
|
42
|
+
ctx.add(this.mesh);
|
|
43
|
+
this.hitbox = new Area3D({
|
|
44
|
+
collisionLayer: 0,
|
|
45
|
+
collisionMask: OBSTACLE_LAYER,
|
|
46
|
+
entity: "runner-hitbox",
|
|
47
|
+
physics: ctx.physics,
|
|
48
|
+
position: { x: 0, y: 0.7, z: 0 },
|
|
49
|
+
shape: CollisionShape3D.box(0.7, 1.3, 0.7),
|
|
50
|
+
});
|
|
51
|
+
this.hitbox.on("bodyEntered", () => {
|
|
52
|
+
this.#crashed = true;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get lane(): number {
|
|
57
|
+
return this.#lane;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get crashed(): boolean {
|
|
61
|
+
return this.#crashed;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get airborne(): boolean {
|
|
65
|
+
return this.#height > 0.01;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get nearMisses(): number {
|
|
69
|
+
return this.#nearMisses;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Counts one near miss. The scene owns *what* counts as near; this owns the tally. */
|
|
73
|
+
recordNearMiss(): void {
|
|
74
|
+
this.#nearMisses += 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
update(ctx: GameCtx, dt: number, distance: number, touch?: ITouchInput): void {
|
|
78
|
+
if (this.#crashed) return;
|
|
79
|
+
const move = ctx.input.vector("move");
|
|
80
|
+
// The stick is a lane *change*, not an axis: holding right must move one lane, not slide
|
|
81
|
+
// continuously across three. `#steering` is that edge, and it is why a held thumb behaves
|
|
82
|
+
// like a tapped key.
|
|
83
|
+
const steer = move.x + (touch?.move.x ?? 0);
|
|
84
|
+
if (touch?.leftPressed === true) this.#lane -= 1;
|
|
85
|
+
if (touch?.rightPressed === true) this.#lane += 1;
|
|
86
|
+
if (Math.abs(steer) > 0.6 && !this.#steering) {
|
|
87
|
+
this.#lane += steer > 0 ? 1 : -1;
|
|
88
|
+
this.#steering = true;
|
|
89
|
+
}
|
|
90
|
+
if (Math.abs(steer) <= 0.4) this.#steering = false;
|
|
91
|
+
this.#lane = MathUtils.clamp(this.#lane, 0, LANE_X.length - 1);
|
|
92
|
+
|
|
93
|
+
const stickJump = (touch?.move.y ?? 0) > 0.65;
|
|
94
|
+
if ((ctx.input.justPressed("jump") || stickJump) && !this.airborne) this.#vertical = JUMP_SPEED;
|
|
95
|
+
this.#height = Math.max(0, this.#height + this.#vertical * dt);
|
|
96
|
+
this.#vertical = this.#height > 0 ? this.#vertical + GRAVITY * dt : 0;
|
|
97
|
+
|
|
98
|
+
const targetX = LANE_X[this.#lane] ?? 0;
|
|
99
|
+
const blend = Math.min(1, Math.max(0, dt) * LANE_BLEND);
|
|
100
|
+
this.mesh.position.x += (targetX - this.mesh.position.x) * blend;
|
|
101
|
+
this.mesh.position.z = -distance;
|
|
102
|
+
this.mesh.rotation.z = (targetX - this.mesh.position.x) * 0.35;
|
|
103
|
+
this.#conventions.applyGrounding(this.#height, dt);
|
|
104
|
+
this.hitbox.setPosition({
|
|
105
|
+
x: this.mesh.position.x,
|
|
106
|
+
y: this.#height + 0.7,
|
|
107
|
+
z: this.mesh.position.z,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** True when the runner is beside, rather than on top of, an obstacle at `x` on this stretch. */
|
|
112
|
+
isNearMiss(obstacleX: number): boolean {
|
|
113
|
+
const gap = Math.abs(obstacleX - this.mesh.position.x);
|
|
114
|
+
return gap > 0.85 && gap < NEAR_MISS;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
debug(): Record<string, unknown> {
|
|
118
|
+
return {
|
|
119
|
+
airborne: this.airborne,
|
|
120
|
+
crashed: this.#crashed,
|
|
121
|
+
groundClearance: this.#conventions.groundSnap.clearance,
|
|
122
|
+
lane: this.#lane,
|
|
123
|
+
nearMisses: this.#nearMisses,
|
|
124
|
+
normaliseFactor: this.#conventions.normaliseFactor,
|
|
125
|
+
position: this.mesh.position.toArray(),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
dispose(): void {
|
|
130
|
+
this.hitbox.dispose();
|
|
131
|
+
this.mesh.removeFromParent();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#steering = false;
|
|
135
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineGame } from "@threenative/core";
|
|
2
|
+
import { playtest } from "@threenative/core/playtest";
|
|
3
|
+
import { rapier } from "@threenative/physics";
|
|
4
|
+
import config from "../threenative.config.js";
|
|
5
|
+
import type { RunnerPhysics } from "./physics.js";
|
|
6
|
+
import { Boot } from "./scenes/Boot.js";
|
|
7
|
+
import { Run } from "./scenes/Run.js";
|
|
8
|
+
import type { GameState } from "./state.js";
|
|
9
|
+
|
|
10
|
+
const game = defineGame<GameState, RunnerPhysics>({
|
|
11
|
+
input: {
|
|
12
|
+
move: {
|
|
13
|
+
down: ["ArrowDown", "KeyS"],
|
|
14
|
+
left: ["ArrowLeft", "KeyA"],
|
|
15
|
+
right: ["ArrowRight", "KeyD"],
|
|
16
|
+
up: ["ArrowUp", "KeyW"],
|
|
17
|
+
},
|
|
18
|
+
jump: { keys: ["Space"] },
|
|
19
|
+
restart: { keys: ["KeyR"] },
|
|
20
|
+
},
|
|
21
|
+
// Gravity is zero on purpose: nothing in this game falls. The jump is an authored arc in
|
|
22
|
+
// `Runner`, and the only physics the runner needs is the overlap query its `Area3D` performs.
|
|
23
|
+
plugins: [rapier({ gravity: { x: 0, y: 0, z: 0 } }), playtest()],
|
|
24
|
+
display: config.display,
|
|
25
|
+
render: config.renderer,
|
|
26
|
+
scenes: { boot: Boot, run: Run },
|
|
27
|
+
// The track is built from `ctx.random`, so this seed is the level. Change it for a new one.
|
|
28
|
+
seed: 77_412,
|
|
29
|
+
start: "boot",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export default game;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* What the UI can ask the game to do.
|
|
36
|
+
*
|
|
37
|
+
* Intents are one-way and named by the game: the UI sends `restart`, `pause` or `resume` and the
|
|
38
|
+
* game decides what each means. Nothing comes back this way — the UI reads the game's published
|
|
39
|
+
* state instead, which keeps one source of truth on the side that owns the simulation.
|
|
40
|
+
*/
|
|
41
|
+
game.ui.onIntent((intent) => {
|
|
42
|
+
if (intent === "restart") void game.goto("run");
|
|
43
|
+
if (intent === "pause") game.pause();
|
|
44
|
+
if (intent === "resume") game.resume();
|
|
45
|
+
game.state.set({
|
|
46
|
+
uiReady: game.ui.connected,
|
|
47
|
+
...(intent === "pause" || intent === "resume" ? { paused: intent === "pause" } : {}),
|
|
48
|
+
});
|
|
49
|
+
game.state.flush();
|
|
50
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { acceptHotUpdate } from "@threenative/core/hot";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import game from "./game.js";
|
|
5
|
+
import { App } from "./ui/App.js";
|
|
6
|
+
import "./style.css";
|
|
7
|
+
|
|
8
|
+
import.meta.hot?.accept();
|
|
9
|
+
acceptHotUpdate(game, import.meta.hot);
|
|
10
|
+
const root = document.getElementById("root");
|
|
11
|
+
if (root === null) throw new Error("Missing #root element.");
|
|
12
|
+
const appRoot = root as typeof root & { __threenativeRoot?: ReturnType<typeof createRoot> };
|
|
13
|
+
const reactRoot = appRoot.__threenativeRoot ?? createRoot(appRoot);
|
|
14
|
+
appRoot.__threenativeRoot = reactRoot;
|
|
15
|
+
reactRoot.render(createElement(App, { game }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IPhysicsContext } from "@threenative/physics";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One bit per thing that can touch another thing.
|
|
5
|
+
*
|
|
6
|
+
* The runner itself is not a body — it is a transform the game moves, carrying an `Area3D` that
|
|
7
|
+
* scans for obstacles. Obstacles are fixed bodies that collide with nothing and are only ever
|
|
8
|
+
* *detected*, which is why they cost a layer and no solver work.
|
|
9
|
+
*/
|
|
10
|
+
export const TRACK_LAYER = 1;
|
|
11
|
+
export const OBSTACLE_LAYER = 2;
|
|
12
|
+
|
|
13
|
+
export type RunnerPhysics = IPhysicsContext;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PerspectiveCamera, Vector3 } from "three";
|
|
2
|
+
|
|
3
|
+
const HEIGHT = 3;
|
|
4
|
+
const BACK = 6.4;
|
|
5
|
+
const LOOK_AHEAD = 22;
|
|
6
|
+
/** How high up the track the rig aims. Lower means more road and less sky in the frame. */
|
|
7
|
+
const LOOK_HEIGHT = -0.2;
|
|
8
|
+
|
|
9
|
+
export function setupCamera(camera: PerspectiveCamera): void {
|
|
10
|
+
camera.fov = 62;
|
|
11
|
+
camera.near = 0.1;
|
|
12
|
+
camera.far = 220;
|
|
13
|
+
camera.position.set(0, HEIGHT, BACK);
|
|
14
|
+
camera.lookAt(0, LOOK_HEIGHT, -LOOK_AHEAD);
|
|
15
|
+
camera.updateProjectionMatrix();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A chase rig that leads the runner rather than tracking it exactly.
|
|
20
|
+
*
|
|
21
|
+
* The lateral lag is deliberate: a camera locked to the lane makes a lane change invisible,
|
|
22
|
+
* because the runner never moves on screen. Lagging it is what turns the change into motion.
|
|
23
|
+
*
|
|
24
|
+
* `offset` is the shake, supplied by the scene from `CameraShake.update`. It is added here and
|
|
25
|
+
* nowhere else, so the rig has one place that decides where the camera is.
|
|
26
|
+
*/
|
|
27
|
+
export function chaseRunner(
|
|
28
|
+
camera: PerspectiveCamera,
|
|
29
|
+
target: Vector3,
|
|
30
|
+
dt: number,
|
|
31
|
+
offset: { readonly x: number; readonly y: number; readonly z: number },
|
|
32
|
+
): void {
|
|
33
|
+
const blend = Math.min(1, Math.max(0, dt) * 6);
|
|
34
|
+
camera.position.x += (target.x * 0.55 - camera.position.x) * blend;
|
|
35
|
+
camera.position.y = HEIGHT + offset.y;
|
|
36
|
+
camera.position.z = target.z + BACK;
|
|
37
|
+
camera.position.x += offset.x;
|
|
38
|
+
camera.lookAt(target.x * 0.35, LOOK_HEIGHT, target.z - LOOK_AHEAD);
|
|
39
|
+
}
|