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,19 @@
|
|
|
1
|
+
import type { IPhysicsContext } from "@threenative/physics";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One bit per thing that can touch another thing.
|
|
5
|
+
*
|
|
6
|
+
* Layers are the game's, not the framework's: `interactionGroups` from `@threenative/physics`
|
|
7
|
+
* encodes whichever numbers you put here into a Rapier group. Keep them powers of two and keep
|
|
8
|
+
* the meaning in one place — a mask assembled inline at three call sites is how a crate quietly
|
|
9
|
+
* stops colliding with the ball.
|
|
10
|
+
*/
|
|
11
|
+
export const ROOM_LAYER = 1;
|
|
12
|
+
export const CRATE_LAYER = 2;
|
|
13
|
+
export const BALL_LAYER = 4;
|
|
14
|
+
export const WEIGHT_LAYER = 8;
|
|
15
|
+
|
|
16
|
+
export const CRATE_MASK = ROOM_LAYER | CRATE_LAYER | BALL_LAYER | WEIGHT_LAYER;
|
|
17
|
+
export const BALL_MASK = ROOM_LAYER | CRATE_LAYER | BALL_LAYER | WEIGHT_LAYER;
|
|
18
|
+
|
|
19
|
+
export type PuzzlePhysics = IPhysicsContext;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PerspectiveCamera, Vector3 } from "three";
|
|
2
|
+
|
|
3
|
+
const HEIGHT = 20;
|
|
4
|
+
const BACK = 17;
|
|
5
|
+
/** How far the rig is allowed to lean toward the claw. A puzzle is read by comparing two things
|
|
6
|
+
* that are not moving, so the frame must stay still enough to compare them. */
|
|
7
|
+
const LEAN = 2.4;
|
|
8
|
+
// Biased toward the far half, but not so far that the claw's spawn sits on the bottom edge —
|
|
9
|
+
// which is exactly where the first framing put it.
|
|
10
|
+
const LOOK_AT = { x: 0, y: 0.4, z: 0.6 };
|
|
11
|
+
|
|
12
|
+
export function setupCamera(camera: PerspectiveCamera): void {
|
|
13
|
+
camera.fov = 42;
|
|
14
|
+
camera.near = 0.1;
|
|
15
|
+
camera.far = 120;
|
|
16
|
+
camera.position.set(0, HEIGHT, BACK);
|
|
17
|
+
camera.lookAt(LOOK_AT.x, LOOK_AT.y, LOOK_AT.z);
|
|
18
|
+
camera.updateProjectionMatrix();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A fixed three-quarter rig that leans toward the claw and never leaves the room.
|
|
23
|
+
*
|
|
24
|
+
* The lean is clamped and the look-at target is constant. An earlier version scaled both the
|
|
25
|
+
* position and the target by the claw's position; walking to a wall then swung the whole frame
|
|
26
|
+
* outside the room and tipped the floor plane, which looked like a broken scene and was a broken
|
|
27
|
+
* camera. Damping a bounded offset around a fixed target cannot do that.
|
|
28
|
+
*/
|
|
29
|
+
export function followGripper(camera: PerspectiveCamera, target: Vector3, dt: number): void {
|
|
30
|
+
const blend = Math.min(1, Math.max(0, dt) * 3);
|
|
31
|
+
const wantX = Math.max(-LEAN, Math.min(LEAN, target.x * 0.3));
|
|
32
|
+
const wantZ = BACK + Math.max(-LEAN, Math.min(LEAN, target.z * 0.2));
|
|
33
|
+
camera.position.x += (wantX - camera.position.x) * blend;
|
|
34
|
+
camera.position.z += (wantZ - camera.position.z) * blend;
|
|
35
|
+
camera.position.y = HEIGHT;
|
|
36
|
+
camera.lookAt(LOOK_AT.x, LOOK_AT.y, LOOK_AT.z);
|
|
37
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
* An indoor contraption room lives or dies on contact shadows: the player has to see that a crate
|
|
16
|
+
* is *on* the floor and that the ball is *touching* the ramp, or every physical judgement becomes
|
|
17
|
+
* a guess. So the key is hard, with a tight shadow frustum.
|
|
18
|
+
*
|
|
19
|
+
* It is also nearly overhead, and that was a fix rather than a preference. A key at fifteen
|
|
20
|
+
* degrees off the horizon threw the left wall across half the play area, and the first capture
|
|
21
|
+
* had a black floor on one side and a legible one on the other — the room looked broken. In an
|
|
22
|
+
* interior with walls this tall, the key belongs above the room and the fill has to be strong
|
|
23
|
+
* enough that its shadow still has a readable floor inside it.
|
|
24
|
+
*
|
|
25
|
+
* Returns the key light: `WorldEnvironment`'s godrays stage raymarches against a shadow map, so
|
|
26
|
+
* the scene hands the sun to `setupPost` and a shadowless light is refused by name instead of
|
|
27
|
+
* rendering a black pass.
|
|
28
|
+
*/
|
|
29
|
+
export function setupLighting(scene: Scene, renderer: ShadowRenderer): DirectionalLight {
|
|
30
|
+
renderer.shadowMap.enabled = true;
|
|
31
|
+
renderer.shadowMap.type = PCFSoftShadowMap;
|
|
32
|
+
scene.add(new HemisphereLight(palette.skyLow, palette.floor, 2.4));
|
|
33
|
+
|
|
34
|
+
const key = new DirectionalLight(0xfff2dd, 3);
|
|
35
|
+
key.position.set(-4, 24, 7);
|
|
36
|
+
key.castShadow = true;
|
|
37
|
+
key.shadow.mapSize.set(1024, 1024);
|
|
38
|
+
key.shadow.camera.near = 0.5;
|
|
39
|
+
key.shadow.camera.far = 70;
|
|
40
|
+
key.shadow.camera.left = -18;
|
|
41
|
+
key.shadow.camera.right = 18;
|
|
42
|
+
key.shadow.camera.top = 18;
|
|
43
|
+
key.shadow.camera.bottom = -18;
|
|
44
|
+
key.shadow.normalBias = 0.035;
|
|
45
|
+
scene.add(key);
|
|
46
|
+
|
|
47
|
+
// Cool, from behind and low: it separates the steel and the wall tops from the dark beyond the
|
|
48
|
+
// room without adding a second set of shadows to read.
|
|
49
|
+
const rim = new DirectionalLight(palette.skyLow, 1.3);
|
|
50
|
+
rim.position.set(9, 5, -14);
|
|
51
|
+
scene.add(rim);
|
|
52
|
+
scene.add(new AmbientLight(palette.skyLow, 0.5));
|
|
53
|
+
|
|
54
|
+
return key;
|
|
55
|
+
}
|
|
@@ -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
|
+
/** Puzzle 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,28 @@
|
|
|
1
|
+
import { MeshStandardMaterial } from "three";
|
|
2
|
+
import { palette, surface } from "./palette.js";
|
|
3
|
+
|
|
4
|
+
export function createMaterials() {
|
|
5
|
+
return {
|
|
6
|
+
// Steel is the wall grey read at low roughness and high metalness. A ball that is a different
|
|
7
|
+
// hue from the room reads as a sticker on it; one that is the same grey, polished, reads as
|
|
8
|
+
// a machined part of the same place.
|
|
9
|
+
ball: surface(palette.wall, 0.2, 0.72),
|
|
10
|
+
crate: surface(palette.accent, 0.62),
|
|
11
|
+
floor: surface(palette.floor, 0.95),
|
|
12
|
+
// The goal carries the same accent as the crates and separates from them by being emissive
|
|
13
|
+
// and translucent — a light in the floor rather than a seventh colour in the palette.
|
|
14
|
+
goal: new MeshStandardMaterial({
|
|
15
|
+
color: palette.accent,
|
|
16
|
+
emissive: palette.accent,
|
|
17
|
+
emissiveIntensity: 1.15,
|
|
18
|
+
opacity: 0.55,
|
|
19
|
+
roughness: 0.4,
|
|
20
|
+
transparent: true,
|
|
21
|
+
}),
|
|
22
|
+
shadow: new MeshStandardMaterial({ color: palette.shadow, roughness: 1 }),
|
|
23
|
+
steel: surface(palette.wall, 0.34, 0.55),
|
|
24
|
+
// A half-step above the floor slab, mixed from the two greys the palette already names.
|
|
25
|
+
tile: surface(0x2c3644, 0.93),
|
|
26
|
+
wall: surface(palette.wall, 0.88),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MeshStandardMaterial } from "three";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The room's colours, in one place. Six names, one accent.
|
|
5
|
+
*
|
|
6
|
+
* A contraption room reads by contrast, not by hue: a cool concrete shell, and one warm accent
|
|
7
|
+
* carried by everything the puzzle is *about* — the crates you move and the ring you are aiming
|
|
8
|
+
* for. The ring separates from the crates by being emissive and translucent rather than by being
|
|
9
|
+
* a seventh colour, which is what keeps the frame legible. Change these six numbers and the whole
|
|
10
|
+
* kit follows.
|
|
11
|
+
*/
|
|
12
|
+
export const palette = {
|
|
13
|
+
skyHigh: 0x101a2c,
|
|
14
|
+
skyLow: 0x35526b,
|
|
15
|
+
floor: 0x232c38,
|
|
16
|
+
wall: 0x39434f,
|
|
17
|
+
accent: 0xd08a3c,
|
|
18
|
+
shadow: 0x080d14,
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
const materials = new Map<string, MeshStandardMaterial>();
|
|
22
|
+
|
|
23
|
+
/** One cached standard material per colour and roughness, so a room of crates is one material. */
|
|
24
|
+
export function surface(color: number, roughness = 0.8, metalness = 0.06): MeshStandardMaterial {
|
|
25
|
+
const key = `${color}:${roughness}:${metalness}`;
|
|
26
|
+
const cached = materials.get(key);
|
|
27
|
+
if (cached !== undefined) return cached;
|
|
28
|
+
const material = new MeshStandardMaterial({ color, metalness, roughness });
|
|
29
|
+
materials.set(key, material);
|
|
30
|
+
return material;
|
|
31
|
+
}
|
|
@@ -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
|
+
}
|