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,131 @@
|
|
|
1
|
+
// Generated for you: ordinary Three.js TSL. `GPUParticles3D` owns the pooling, the dispatch and
|
|
2
|
+
// the lifetime; every appearance choice below — the count, the spawn shape, the launch, the
|
|
3
|
+
// colour ramp, the sprite mask — is this file's, and this file is yours.
|
|
4
|
+
import {
|
|
5
|
+
Fn,
|
|
6
|
+
float,
|
|
7
|
+
fract,
|
|
8
|
+
hash,
|
|
9
|
+
instanceIndex,
|
|
10
|
+
mix,
|
|
11
|
+
smoothstep,
|
|
12
|
+
time,
|
|
13
|
+
uv,
|
|
14
|
+
varying,
|
|
15
|
+
vec2,
|
|
16
|
+
vec3,
|
|
17
|
+
vec4,
|
|
18
|
+
} from "three/tsl";
|
|
19
|
+
import {
|
|
20
|
+
AdditiveBlending,
|
|
21
|
+
type ComputeNode,
|
|
22
|
+
SpriteNodeMaterial,
|
|
23
|
+
type StorageBufferNode,
|
|
24
|
+
} from "three/webgpu";
|
|
25
|
+
import { palette } from "./palette.js";
|
|
26
|
+
|
|
27
|
+
export interface IDustBuffers {
|
|
28
|
+
readonly positions: StorageBufferNode<"vec3">;
|
|
29
|
+
readonly velocities: StorageBufferNode<"vec3">;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IDustOptions {
|
|
33
|
+
readonly amount: number;
|
|
34
|
+
readonly material: SpriteNodeMaterial;
|
|
35
|
+
readonly start: (buffers: IDustBuffers) => ComputeNode;
|
|
36
|
+
readonly process: (buffers: IDustBuffers) => ComputeNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const AMOUNT = 220;
|
|
40
|
+
const LIFETIME = 0.9;
|
|
41
|
+
/** Metres per second the trail drifts backwards. It is the track that moves, so this is small. */
|
|
42
|
+
const DRIFT = 2.6;
|
|
43
|
+
const SPREAD = 0.55;
|
|
44
|
+
|
|
45
|
+
function noise(salt: number) {
|
|
46
|
+
return hash(instanceIndex.add(salt));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Each particle owns a phase offset, so the emitter is continuous rather than a pulsing burst. */
|
|
50
|
+
function phase() {
|
|
51
|
+
return fract(time.div(LIFETIME).add(noise(19)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function spawn() {
|
|
55
|
+
return vec3(
|
|
56
|
+
noise(3).sub(0.5).mul(SPREAD),
|
|
57
|
+
noise(7).mul(0.14),
|
|
58
|
+
noise(11)
|
|
59
|
+
.sub(0.5)
|
|
60
|
+
.mul(SPREAD * 0.5),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function launch() {
|
|
65
|
+
return vec3(
|
|
66
|
+
noise(23).sub(0.5).mul(1.1),
|
|
67
|
+
noise(29).mul(1.4).add(0.2),
|
|
68
|
+
noise(31)
|
|
69
|
+
.mul(DRIFT)
|
|
70
|
+
.add(DRIFT * 0.4),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A soft round puff: no texture, no download, and it fades at both ends of its life. */
|
|
75
|
+
function puff() {
|
|
76
|
+
return float(1).sub(smoothstep(0.06, 0.5, uv().sub(0.5).length()));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The dust the runner throws up.
|
|
81
|
+
*
|
|
82
|
+
* Two colours: the track's own grey at birth and the warm horizon at death, so the trail reads as
|
|
83
|
+
* lit by the same sky the track is. Change the numbers above and the whole feel changes; change
|
|
84
|
+
* `puff` and the grain does.
|
|
85
|
+
*/
|
|
86
|
+
export function createDustTrail(): IDustOptions {
|
|
87
|
+
const material = new SpriteNodeMaterial({
|
|
88
|
+
blending: AdditiveBlending,
|
|
89
|
+
depthWrite: false,
|
|
90
|
+
toneMapped: false,
|
|
91
|
+
transparent: true,
|
|
92
|
+
});
|
|
93
|
+
const life = varying(phase());
|
|
94
|
+
material.scaleNode = vec2(0.42).mul(mix(0.5, 1.5, life));
|
|
95
|
+
const birth = new Array(3)
|
|
96
|
+
.fill(0)
|
|
97
|
+
.map((_, index) => ((palette.rail >> (16 - index * 8)) & 255) / 255);
|
|
98
|
+
const death = new Array(3)
|
|
99
|
+
.fill(0)
|
|
100
|
+
.map((_, index) => ((palette.skyLow >> (16 - index * 8)) & 255) / 255);
|
|
101
|
+
material.colorNode = vec4(
|
|
102
|
+
mix(
|
|
103
|
+
vec3(birth[0] ?? 0, birth[1] ?? 0, birth[2] ?? 0),
|
|
104
|
+
vec3(death[0] ?? 0, death[1] ?? 0, death[2] ?? 0),
|
|
105
|
+
life,
|
|
106
|
+
),
|
|
107
|
+
puff()
|
|
108
|
+
.mul(float(1).sub(smoothstep(0.55, 1, life)))
|
|
109
|
+
.mul(0.55),
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const start = ({ positions, velocities }: IDustBuffers): ComputeNode =>
|
|
113
|
+
Fn(() => {
|
|
114
|
+
positions.element(instanceIndex).assign(spawn());
|
|
115
|
+
velocities.element(instanceIndex).assign(launch());
|
|
116
|
+
})().compute(AMOUNT);
|
|
117
|
+
|
|
118
|
+
const process = ({ positions, velocities }: IDustBuffers): ComputeNode =>
|
|
119
|
+
Fn(() => {
|
|
120
|
+
const velocity = launch();
|
|
121
|
+
const elapsed = phase().mul(LIFETIME);
|
|
122
|
+
positions.element(instanceIndex).assign(
|
|
123
|
+
spawn()
|
|
124
|
+
.add(velocity.mul(elapsed))
|
|
125
|
+
.add(vec3(0, -1.6, 0).mul(elapsed.mul(elapsed))),
|
|
126
|
+
);
|
|
127
|
+
velocities.element(instanceIndex).assign(velocity);
|
|
128
|
+
})().compute(AMOUNT);
|
|
129
|
+
|
|
130
|
+
return { amount: AMOUNT, material, process, start };
|
|
131
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AmbientLight,
|
|
3
|
+
DirectionalLight,
|
|
4
|
+
HemisphereLight,
|
|
5
|
+
PCFSoftShadowMap,
|
|
6
|
+
type Scene,
|
|
7
|
+
} from "three";
|
|
8
|
+
import { palette } from "./palette.js";
|
|
9
|
+
|
|
10
|
+
type ShadowRenderer = { shadowMap: { enabled: boolean; type: number } };
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Key, fill, rim, ambient — named, so each one can be changed on its own.
|
|
14
|
+
*
|
|
15
|
+
* A runner is lit from ahead. The key sits low and down-track so it rakes across the obstacles
|
|
16
|
+
* and gives each one a long shadow reaching back toward the player: at speed that shadow arrives
|
|
17
|
+
* before the block does, and it is the only warning the player gets in time to use.
|
|
18
|
+
*
|
|
19
|
+
* Returns the key light: `WorldEnvironment`'s godrays stage raymarches against a shadow map, so
|
|
20
|
+
* the scene hands the sun to `setupPost` and a shadowless light is refused by name instead of
|
|
21
|
+
* rendering a black pass.
|
|
22
|
+
*/
|
|
23
|
+
export function setupLighting(scene: Scene, renderer: ShadowRenderer): DirectionalLight {
|
|
24
|
+
renderer.shadowMap.enabled = true;
|
|
25
|
+
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
26
|
+
// The sky half is the *rail* grey, not the horizon orange. Taking the horizon colour flooded
|
|
27
|
+
// the road with it and the track stopped being cool at all.
|
|
28
|
+
scene.add(new HemisphereLight(palette.rail, palette.track, 1.2));
|
|
29
|
+
|
|
30
|
+
const key = new DirectionalLight(0xffcf9e, 3.4);
|
|
31
|
+
key.position.set(3, 9, -22);
|
|
32
|
+
key.castShadow = true;
|
|
33
|
+
key.shadow.mapSize.set(1024, 1024);
|
|
34
|
+
key.shadow.camera.near = 0.5;
|
|
35
|
+
key.shadow.camera.far = 90;
|
|
36
|
+
key.shadow.camera.left = -14;
|
|
37
|
+
key.shadow.camera.right = 14;
|
|
38
|
+
key.shadow.camera.top = 14;
|
|
39
|
+
key.shadow.camera.bottom = -14;
|
|
40
|
+
key.shadow.normalBias = 0.03;
|
|
41
|
+
scene.add(key);
|
|
42
|
+
|
|
43
|
+
// A fill from behind the camera, and it is the light the first two captures were missing. With
|
|
44
|
+
// only a key from down-track, everything the player looks at is backlit: the runner came back a
|
|
45
|
+
// dark silhouette against the obstacle it was about to hit, which is the one comparison the
|
|
46
|
+
// game asks the player to make.
|
|
47
|
+
const fill = new DirectionalLight(0xbfd4ff, 1.5);
|
|
48
|
+
fill.position.set(-2, 7, 16);
|
|
49
|
+
scene.add(fill);
|
|
50
|
+
|
|
51
|
+
const rim = new DirectionalLight(palette.accent, 0.7);
|
|
52
|
+
rim.position.set(-8, 4, 6);
|
|
53
|
+
scene.add(rim);
|
|
54
|
+
scene.add(new AmbientLight(palette.skyHigh, 0.6));
|
|
55
|
+
|
|
56
|
+
return key;
|
|
57
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Camera,
|
|
3
|
+
CanvasTexture,
|
|
4
|
+
ClampToEdgeWrapping,
|
|
5
|
+
Mesh,
|
|
6
|
+
MeshBasicMaterial,
|
|
7
|
+
type OrthographicCamera,
|
|
8
|
+
PlaneGeometry,
|
|
9
|
+
type Scene,
|
|
10
|
+
type Texture,
|
|
11
|
+
} from "three";
|
|
12
|
+
import { palette } from "./palette.js";
|
|
13
|
+
|
|
14
|
+
/* BEGIN THREENATIVE LOADING APPEARANCE */
|
|
15
|
+
/** Runner look and composition; edit this generated source to change the screen. */
|
|
16
|
+
export const loading = {
|
|
17
|
+
backgroundColor: palette.skyLow,
|
|
18
|
+
backgroundImage: undefined as string | undefined,
|
|
19
|
+
enabled: true,
|
|
20
|
+
fillImage: undefined as string | undefined,
|
|
21
|
+
logoImage: undefined as string | undefined,
|
|
22
|
+
progressColor: palette.accent,
|
|
23
|
+
showStatus: false,
|
|
24
|
+
trackColor: palette.skyHigh,
|
|
25
|
+
bar: { anchorX: 0.5, anchorY: 0.76, height: 11, maxWidth: 520, minWidth: 1, width: 0.6 },
|
|
26
|
+
} as const;
|
|
27
|
+
/* END THREENATIVE LOADING APPEARANCE */
|
|
28
|
+
|
|
29
|
+
interface ILoadingHost {
|
|
30
|
+
readonly assets?: { texture(path: string): Promise<Texture> };
|
|
31
|
+
readonly camera: Camera;
|
|
32
|
+
readonly canvasLayer: {
|
|
33
|
+
readonly camera: OrthographicCamera;
|
|
34
|
+
readonly scene: Scene;
|
|
35
|
+
opaque: boolean;
|
|
36
|
+
};
|
|
37
|
+
readonly renderer: { compileAsync(scene: Scene, camera: Camera): Promise<void> };
|
|
38
|
+
readonly scene: Scene;
|
|
39
|
+
readonly startup: {
|
|
40
|
+
readonly progress: number;
|
|
41
|
+
readonly warmup?: { readonly status: "complete" | "incomplete" | "unavailable" };
|
|
42
|
+
whenReady(): Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
readonly viewport?: {
|
|
45
|
+
readonly safeArea: { height: number; width: number; x: number; y: number };
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface ILoadingController {
|
|
50
|
+
update(): void;
|
|
51
|
+
finish(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function noOp(layer: ILoadingHost["canvasLayer"]): ILoadingController {
|
|
55
|
+
layer.opaque = false;
|
|
56
|
+
return { finish: () => undefined, update: () => undefined };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function meshFor(
|
|
60
|
+
layer: ILoadingHost["canvasLayer"],
|
|
61
|
+
material: MeshBasicMaterial,
|
|
62
|
+
renderOrder: number,
|
|
63
|
+
): Mesh<PlaneGeometry, MeshBasicMaterial> {
|
|
64
|
+
const mesh = new Mesh(new PlaneGeometry(1, 1), material);
|
|
65
|
+
mesh.frustumCulled = false;
|
|
66
|
+
mesh.renderOrder = renderOrder;
|
|
67
|
+
layer.scene.add(mesh);
|
|
68
|
+
return mesh;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function imageAspect(texture: Texture | null | undefined): number {
|
|
72
|
+
const image = texture?.image as { height?: number; width?: number } | undefined;
|
|
73
|
+
const width = image?.width ?? 1;
|
|
74
|
+
const height = image?.height ?? 1;
|
|
75
|
+
return width > 0 && height > 0 ? width / height : 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function configureTexture(texture: Texture): void {
|
|
79
|
+
texture.wrapS = ClampToEdgeWrapping;
|
|
80
|
+
texture.wrapT = ClampToEdgeWrapping;
|
|
81
|
+
texture.needsUpdate = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function setFillUv(geometry: PlaneGeometry, progress: number, base: readonly number[]): void {
|
|
85
|
+
const uv = geometry.getAttribute("uv");
|
|
86
|
+
for (let index = 0; index < uv.count; index += 1) uv.setX(index, (base[index] ?? 0) * progress);
|
|
87
|
+
uv.needsUpdate = true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function coverUv(
|
|
91
|
+
geometry: PlaneGeometry,
|
|
92
|
+
texture: Texture,
|
|
93
|
+
width: number,
|
|
94
|
+
height: number,
|
|
95
|
+
baseU: readonly number[],
|
|
96
|
+
baseV: readonly number[],
|
|
97
|
+
): void {
|
|
98
|
+
const imageRatio = imageAspect(texture);
|
|
99
|
+
const boxRatio = width / Math.max(1, height);
|
|
100
|
+
const visibleU = imageRatio > boxRatio ? boxRatio / imageRatio : 1;
|
|
101
|
+
const visibleV = imageRatio < boxRatio ? imageRatio / boxRatio : 1;
|
|
102
|
+
const offsetU = (1 - visibleU) / 2;
|
|
103
|
+
const offsetV = (1 - visibleV) / 2;
|
|
104
|
+
const uv = geometry.getAttribute("uv");
|
|
105
|
+
for (let index = 0; index < uv.count; index += 1) {
|
|
106
|
+
uv.setX(index, offsetU + (baseU[index] ?? 0) * visibleU);
|
|
107
|
+
uv.setY(index, offsetV + (baseV[index] ?? 0) * visibleV);
|
|
108
|
+
}
|
|
109
|
+
uv.needsUpdate = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function statusMesh(
|
|
113
|
+
layer: ILoadingHost["canvasLayer"],
|
|
114
|
+
):
|
|
115
|
+
| { mesh: Mesh<PlaneGeometry, MeshBasicMaterial>; texture: Texture; update(value: number): void }
|
|
116
|
+
| undefined {
|
|
117
|
+
if (!loading.showStatus || typeof document === "undefined") return undefined;
|
|
118
|
+
const canvas = document.createElement("canvas");
|
|
119
|
+
canvas.width = 180;
|
|
120
|
+
canvas.height = 48;
|
|
121
|
+
const context = canvas.getContext("2d");
|
|
122
|
+
if (context === null) return undefined;
|
|
123
|
+
const texture = new CanvasTexture(canvas);
|
|
124
|
+
const mesh = meshFor(
|
|
125
|
+
layer,
|
|
126
|
+
new MeshBasicMaterial({ depthTest: false, depthWrite: false, map: texture, transparent: true }),
|
|
127
|
+
4,
|
|
128
|
+
);
|
|
129
|
+
const update = (value: number): void => {
|
|
130
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
131
|
+
context.fillStyle = "#ffffff";
|
|
132
|
+
context.font = "700 20px monospace";
|
|
133
|
+
context.textAlign = "center";
|
|
134
|
+
context.textBaseline = "middle";
|
|
135
|
+
context.fillText(`${Math.round(value * 100)}%`, canvas.width / 2, canvas.height / 2);
|
|
136
|
+
texture.needsUpdate = true;
|
|
137
|
+
};
|
|
138
|
+
update(0);
|
|
139
|
+
return { mesh, texture, update };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function createLoadingScreen(host: ILoadingHost): ILoadingController {
|
|
143
|
+
const layer = host.canvasLayer;
|
|
144
|
+
if (!loading.enabled) return noOp(layer);
|
|
145
|
+
const camera = layer.camera;
|
|
146
|
+
const backdrop = meshFor(
|
|
147
|
+
layer,
|
|
148
|
+
new MeshBasicMaterial({ color: loading.backgroundColor, depthTest: false, depthWrite: false }),
|
|
149
|
+
0,
|
|
150
|
+
);
|
|
151
|
+
const track = meshFor(
|
|
152
|
+
layer,
|
|
153
|
+
new MeshBasicMaterial({ color: loading.trackColor, depthTest: false, depthWrite: false }),
|
|
154
|
+
1,
|
|
155
|
+
);
|
|
156
|
+
const fill = meshFor(
|
|
157
|
+
layer,
|
|
158
|
+
new MeshBasicMaterial({ color: loading.progressColor, depthTest: false, depthWrite: false }),
|
|
159
|
+
2,
|
|
160
|
+
);
|
|
161
|
+
const fillBaseU = Array.from({ length: fill.geometry.getAttribute("uv").count }, (_, index) =>
|
|
162
|
+
fill.geometry.getAttribute("uv").getX(index),
|
|
163
|
+
);
|
|
164
|
+
const fillBaseV = Array.from({ length: fill.geometry.getAttribute("uv").count }, (_, index) =>
|
|
165
|
+
fill.geometry.getAttribute("uv").getY(index),
|
|
166
|
+
);
|
|
167
|
+
const logo =
|
|
168
|
+
loading.logoImage === undefined
|
|
169
|
+
? undefined
|
|
170
|
+
: meshFor(
|
|
171
|
+
layer,
|
|
172
|
+
new MeshBasicMaterial({
|
|
173
|
+
color: 0xffffff,
|
|
174
|
+
depthTest: false,
|
|
175
|
+
depthWrite: false,
|
|
176
|
+
transparent: true,
|
|
177
|
+
}),
|
|
178
|
+
3,
|
|
179
|
+
);
|
|
180
|
+
const status = statusMesh(layer);
|
|
181
|
+
const parts = [
|
|
182
|
+
backdrop,
|
|
183
|
+
track,
|
|
184
|
+
fill,
|
|
185
|
+
...(logo === undefined ? [] : [logo]),
|
|
186
|
+
...(status === undefined ? [] : [status.mesh]),
|
|
187
|
+
];
|
|
188
|
+
const ownedTextures = new Set<Texture>(status === undefined ? [] : [status.texture]);
|
|
189
|
+
let width = 1;
|
|
190
|
+
let height = 1;
|
|
191
|
+
let barWidth = 1;
|
|
192
|
+
let barHeight: number = loading.bar.height;
|
|
193
|
+
let barX = 0;
|
|
194
|
+
let barY = 0;
|
|
195
|
+
let progress = 0;
|
|
196
|
+
let done = false;
|
|
197
|
+
let backdropTexture: Texture | undefined;
|
|
198
|
+
|
|
199
|
+
const layout = (): void => {
|
|
200
|
+
width = Math.max(1, camera.right - camera.left);
|
|
201
|
+
height = Math.max(1, camera.top - camera.bottom);
|
|
202
|
+
const safe = host.viewport?.safeArea ?? { height, width, x: 0, y: 0 };
|
|
203
|
+
const safeWidth = Math.max(1, Math.min(width, safe.width));
|
|
204
|
+
const safeHeight = Math.max(1, Math.min(height, safe.height));
|
|
205
|
+
const safeX = Math.max(0, Math.min(width - safeWidth, safe.x));
|
|
206
|
+
const safeY = Math.max(0, Math.min(height - safeHeight, safe.y));
|
|
207
|
+
barWidth = Math.max(2, Math.min(loading.bar.maxWidth, safeWidth * loading.bar.width));
|
|
208
|
+
barHeight = Math.max(2, Math.min(loading.bar.height, safeHeight * 0.05));
|
|
209
|
+
barX = safeX + safeWidth * loading.bar.anchorX;
|
|
210
|
+
barY = safeY + safeHeight * loading.bar.anchorY;
|
|
211
|
+
const worldX = (screenX: number): number => camera.left + screenX;
|
|
212
|
+
const worldY = (screenY: number): number => camera.top - screenY;
|
|
213
|
+
const visibleWidth = Math.max(loading.bar.minWidth, barWidth * progress);
|
|
214
|
+
backdrop.scale.set(width, height, 1);
|
|
215
|
+
backdrop.position.set(worldX(width / 2), worldY(height / 2), 0);
|
|
216
|
+
track.scale.set(barWidth, barHeight, 1);
|
|
217
|
+
track.position.set(worldX(barX), worldY(barY), 0);
|
|
218
|
+
fill.scale.set(visibleWidth, barHeight, 1);
|
|
219
|
+
fill.position.set(worldX(barX - barWidth / 2 + visibleWidth / 2), worldY(barY), 0);
|
|
220
|
+
if (logo?.visible) {
|
|
221
|
+
const logoWidth = Math.min(safeWidth * 0.42, 280);
|
|
222
|
+
logo.scale.set(
|
|
223
|
+
logoWidth,
|
|
224
|
+
Math.min(logoWidth / imageAspect(logo.material.map), safeHeight * 0.22),
|
|
225
|
+
1,
|
|
226
|
+
);
|
|
227
|
+
logo.position.set(worldX(barX), worldY(Math.max(safeY, barY - safeHeight * 0.2)), 0);
|
|
228
|
+
}
|
|
229
|
+
if (status !== undefined) {
|
|
230
|
+
status.mesh.scale.set(Math.min(180, safeWidth * 0.32), 48, 1);
|
|
231
|
+
status.mesh.position.set(worldX(barX), worldY(Math.min(height, barY + barHeight * 2.5)), 0);
|
|
232
|
+
}
|
|
233
|
+
if (backdropTexture !== undefined)
|
|
234
|
+
coverUv(backdrop.geometry, backdropTexture, width, height, fillBaseU, fillBaseV);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const updateProgress = (value: number): void => {
|
|
238
|
+
const bounded = Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0;
|
|
239
|
+
// A missing or incomplete backend observation cannot prove that all first-use work is done.
|
|
240
|
+
// Keep the bar visibly indeterminate until readiness removes the cover; never turn unknown
|
|
241
|
+
// coverage into a false 100% claim.
|
|
242
|
+
const observationUnknown =
|
|
243
|
+
host.startup.warmup !== undefined && host.startup.warmup.status !== "complete";
|
|
244
|
+
progress = observationUnknown ? Math.min(0.9, bounded) : bounded;
|
|
245
|
+
setFillUv(fill.geometry, progress, fillBaseU);
|
|
246
|
+
status?.update(progress);
|
|
247
|
+
layout();
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const attachTexture = (mesh: Mesh<PlaneGeometry, MeshBasicMaterial>, texture: Texture): void => {
|
|
251
|
+
if (done) return;
|
|
252
|
+
configureTexture(texture);
|
|
253
|
+
mesh.material.map = texture;
|
|
254
|
+
mesh.material.color.set(0xffffff);
|
|
255
|
+
mesh.material.needsUpdate = true;
|
|
256
|
+
ownedTextures.add(texture);
|
|
257
|
+
if (mesh === backdrop) backdropTexture = texture;
|
|
258
|
+
layout();
|
|
259
|
+
updateProgress(progress);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const load = (source: string | undefined, mesh: Mesh<PlaneGeometry, MeshBasicMaterial>): void => {
|
|
263
|
+
if (source === undefined || host.assets === undefined) return;
|
|
264
|
+
void host.assets
|
|
265
|
+
.texture(source)
|
|
266
|
+
.then((texture) => attachTexture(mesh, texture))
|
|
267
|
+
.catch(() => undefined);
|
|
268
|
+
};
|
|
269
|
+
load(loading.backgroundImage, backdrop);
|
|
270
|
+
load(loading.fillImage, fill);
|
|
271
|
+
if (logo !== undefined && loading.logoImage !== undefined && host.assets !== undefined) {
|
|
272
|
+
void host.assets
|
|
273
|
+
.texture(loading.logoImage)
|
|
274
|
+
.then((texture) => {
|
|
275
|
+
if (done) return;
|
|
276
|
+
configureTexture(texture);
|
|
277
|
+
logo.material.map = texture;
|
|
278
|
+
logo.material.needsUpdate = true;
|
|
279
|
+
logo.visible = true;
|
|
280
|
+
ownedTextures.add(texture);
|
|
281
|
+
layout();
|
|
282
|
+
})
|
|
283
|
+
.catch(() => undefined);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
layer.opaque = true;
|
|
287
|
+
layout();
|
|
288
|
+
updateProgress(0);
|
|
289
|
+
|
|
290
|
+
const finish = (): void => {
|
|
291
|
+
if (done) return;
|
|
292
|
+
done = true;
|
|
293
|
+
for (const mesh of parts) {
|
|
294
|
+
mesh.removeFromParent();
|
|
295
|
+
mesh.geometry.dispose();
|
|
296
|
+
mesh.material.dispose();
|
|
297
|
+
}
|
|
298
|
+
for (const texture of ownedTextures) texture.dispose();
|
|
299
|
+
layer.opaque = false;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
void (async () => {
|
|
303
|
+
await host.startup.whenReady();
|
|
304
|
+
if (done) return;
|
|
305
|
+
// Prewarm the world's shaders, but do not wait for them here. `whenReady()` already means the
|
|
306
|
+
// world is safe to show, and compiling a lit, post-processed scene takes far longer than the
|
|
307
|
+
// launch window: hold the screen for it and a playtest — which advances a fixed step as fast
|
|
308
|
+
// as the machine allows — runs an entire scenario behind the launch screen, so every capture
|
|
309
|
+
// photographs the loading bar instead of the game. The prewarm still happens; it no longer
|
|
310
|
+
// decides when the player sees the world.
|
|
311
|
+
try {
|
|
312
|
+
void host.renderer.compileAsync(host.scene, host.camera).catch(() => undefined);
|
|
313
|
+
} catch {
|
|
314
|
+
// A renderer without compileAsync is not a reason to keep the world hidden.
|
|
315
|
+
}
|
|
316
|
+
finish();
|
|
317
|
+
})();
|
|
318
|
+
|
|
319
|
+
return {
|
|
320
|
+
finish,
|
|
321
|
+
update(): void {
|
|
322
|
+
if (!done) updateProgress(host.startup.progress);
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MeshStandardMaterial } from "three";
|
|
2
|
+
import { palette, surface } from "./palette.js";
|
|
3
|
+
|
|
4
|
+
export function createMaterials() {
|
|
5
|
+
return {
|
|
6
|
+
// The obstacle is the only emissive thing in the scene. At speed the player has one glance to
|
|
7
|
+
// read the lane, and a matte block on a dark track does not survive that glance.
|
|
8
|
+
obstacle: new MeshStandardMaterial({
|
|
9
|
+
color: palette.accent,
|
|
10
|
+
emissive: palette.accent,
|
|
11
|
+
// Low, and it was not the first number tried. At 0.75 with the bloom stage on, every
|
|
12
|
+
// obstacle came back a white blob with no readable face — the accent needs to *glow*, not
|
|
13
|
+
// to clip. This reads as lit at speed and still has geometry inside it.
|
|
14
|
+
emissiveIntensity: 0.28,
|
|
15
|
+
metalness: 0.1,
|
|
16
|
+
roughness: 0.45,
|
|
17
|
+
}),
|
|
18
|
+
rail: surface(palette.rail, 0.62, 0.28),
|
|
19
|
+
// Light and neutral, and mixed here rather than named in the palette, because it is not a
|
|
20
|
+
// sixth role — it is the absence of one. The first version made the runner out of `rail` and
|
|
21
|
+
// gave its fin the accent, so the player and the thing that kills the player were the same
|
|
22
|
+
// colour on a dark track. At speed that is unreadable.
|
|
23
|
+
runner: surface(0xdedae8, 0.32, 0.35),
|
|
24
|
+
shadow: new MeshStandardMaterial({ color: palette.shadow, roughness: 1 }),
|
|
25
|
+
track: surface(palette.track, 0.92),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MeshStandardMaterial } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Six names, one accent.
|
|
5
|
+
*
|
|
6
|
+
* A runner is read at speed, from behind, in a fraction of a second: the only thing that has to
|
|
7
|
+
* be unmistakable is *what will kill you*. So the accent belongs to obstacles and to nothing
|
|
8
|
+
* else, the track is a cool dark ribbon, and the horizon is warm so the direction of travel is
|
|
9
|
+
* legible even when the track is empty.
|
|
10
|
+
*/
|
|
11
|
+
export const palette = {
|
|
12
|
+
skyHigh: 0x120c22,
|
|
13
|
+
skyLow: 0xd4623a,
|
|
14
|
+
track: 0x2a2740,
|
|
15
|
+
rail: 0x4a4569,
|
|
16
|
+
accent: 0x64f0d0,
|
|
17
|
+
shadow: 0x07060f,
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
const materials = new Map<string, MeshStandardMaterial>();
|
|
21
|
+
|
|
22
|
+
/** One cached standard material per colour and roughness, so a track of rails is one material. */
|
|
23
|
+
export function surface(color: number, roughness = 0.8, metalness = 0.05): MeshStandardMaterial {
|
|
24
|
+
const key = `${color}:${roughness}:${metalness}`;
|
|
25
|
+
const cached = materials.get(key);
|
|
26
|
+
if (cached !== undefined) return cached;
|
|
27
|
+
const material = new MeshStandardMaterial({ color, metalness, roughness });
|
|
28
|
+
materials.set(key, material);
|
|
29
|
+
return material;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated for you: ordinary Three.js; ThreeNative does not read this file.
|
|
2
|
+
//
|
|
3
|
+
// This file wires two things together and decides nothing itself. `quality.ts`, in this folder,
|
|
4
|
+
// owns which stages run at which tier and records what each one measured. `WorldEnvironment`,
|
|
5
|
+
// also in this folder, builds them and prints `TN_WORLD_ENVIRONMENT` naming every stage as
|
|
6
|
+
// applied or refused **with a reason**, so a stage that silently no-op'd is never mistaken for
|
|
7
|
+
// one you turned off.
|
|
8
|
+
//
|
|
9
|
+
// To make the game cheaper or prettier everywhere, edit `quality.ts`. To force one tier for one
|
|
10
|
+
// run — a desktop that is dropping frames, a capture you want to compare — pass it:
|
|
11
|
+
// `setupPost(renderer, scene, camera, { tier: "low" })`. Overriding does not silence the report:
|
|
12
|
+
// `TN_QUALITY_TIER` names the tier that ran either way.
|
|
13
|
+
import type { Camera, DirectionalLight, Scene } from "three";
|
|
14
|
+
import { type QualityTier, qualityPreset, resolveQualityTier } from "./quality.js";
|
|
15
|
+
import type { OutputRenderer } from "./worldEnvironment.js";
|
|
16
|
+
import { WorldEnvironment } from "./worldEnvironment.js";
|
|
17
|
+
|
|
18
|
+
export function setupPost(
|
|
19
|
+
renderer: OutputRenderer,
|
|
20
|
+
scene: Scene,
|
|
21
|
+
camera: Camera,
|
|
22
|
+
environment: {
|
|
23
|
+
godraysLight?: DirectionalLight;
|
|
24
|
+
mobile?: boolean;
|
|
25
|
+
/** Forces a tier, ignoring `mobile`. An unknown name throws rather than falling back. */
|
|
26
|
+
tier?: QualityTier;
|
|
27
|
+
} = {},
|
|
28
|
+
): void {
|
|
29
|
+
const tier = resolveQualityTier({ mobile: environment.mobile, tier: environment.tier });
|
|
30
|
+
const source = environment.tier === undefined ? "platform" : "override";
|
|
31
|
+
console.info(`TN_QUALITY_TIER ${tier} mobile=${environment.mobile === true} source=${source}`);
|
|
32
|
+
const world = new WorldEnvironment(qualityPreset(tier));
|
|
33
|
+
world.apply(renderer, scene, camera, { godraysLight: environment.godraysLight });
|
|
34
|
+
}
|