create-threenative 0.2.9 → 0.2.12
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/agent-docs/references/assertion-reference.md +109 -3
- package/agent-docs/references/auto-exposure.md +28 -45
- package/agent-docs/references/build-profiles.md +1 -1
- package/agent-docs/references/capability-reference.md +527 -44
- package/agent-docs/references/debug-surface.md +64 -0
- package/agent-docs/references/finding-assets.md +11 -12
- package/agent-docs/references/performance-basics.md +19 -0
- package/agent-docs/references/trace-a-slow-frame.md +21 -0
- package/agent-docs/references/visual-baseline.md +23 -4
- package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
- package/agent-files/.agents/skills/prd-creator/SKILL.md +17 -6
- package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +87 -23
- package/agent-files/.agents/skills/threenative-performance/SKILL.md +12 -11
- package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
- package/agent-files/scripts/reference.mjs +9 -4
- package/capabilities.json +739 -50
- package/dist/index.d.ts +40 -6
- package/dist/index.js +229 -36
- package/dist/quality.d.ts +12 -0
- package/dist/quality.js +166747 -0
- package/dist/threenative.js +60 -44
- package/dist/web-engine-gltf-loader.js +2 -0
- package/dist/web-engine-mesh-bvh-webgpu.js +1 -1
- package/dist/web-engine-mesh-bvh.js +7 -0
- package/dist/web-engine-post-effects.js +645 -19
- package/dist/web-engine-runtime.js +3528 -343
- package/package.json +19 -9
- package/template-assets/assets/bay-PROVENANCE.md +21 -0
- package/template-assets/assets/bay-ground.webp +0 -0
- package/template-assets/assets/bay-metal.webp +0 -0
- package/template-assets/assets/bay-pavement-normal.webp +0 -0
- package/template-assets/assets/bay-pavement.webp +0 -0
- package/template-assets/assets/bay-plaster-normal.webp +0 -0
- package/template-assets/assets/bay-plaster.webp +0 -0
- package/template-assets/assets/bay-wood-normal.webp +0 -0
- package/template-assets/assets/bay-wood.webp +0 -0
- package/template-assets/assets/tex-PROVENANCE.md +25 -0
- package/template-assets/assets/tex-bark-normal.webp +0 -0
- package/template-assets/assets/tex-bark.webp +0 -0
- package/template-assets/assets/tex-birch-bark.webp +0 -0
- package/template-assets/assets/tex-grass.webp +0 -0
- package/template-assets/assets/tex-planks-normal.webp +0 -0
- package/template-assets/assets/tex-planks.webp +0 -0
- package/template-assets/assets/tex-rock-normal.webp +0 -0
- package/template-assets/assets/tex-rock.webp +0 -0
- package/template-assets/assets/tex-roof-tiles-normal.webp +0 -0
- package/template-assets/assets/tex-roof-tiles.webp +0 -0
- package/template-assets/assets/tex-sand-normal.webp +0 -0
- package/template-assets/assets/tex-sand.webp +0 -0
- package/template-assets/assets/tex-stone-wall-normal.webp +0 -0
- package/template-assets/assets/tex-stone-wall.webp +0 -0
- package/template-assets/kitExposure.ts +20 -0
- package/template-assets/patches/three@0.185.1.patch +481 -272
- package/template-assets/quality/biome.json +7 -0
- package/template-assets/quality/eslint.config.js +3 -0
- package/template-assets/realistic-ocean/README.md +113 -0
- package/template-assets/realistic-ocean/install.mjs +56 -0
- package/template-assets/realistic-ocean/src/realisticOcean.ts +151 -0
- package/template-assets/realistic-ocean/src/realisticOceanLifetime.ts +29 -0
- package/template-assets/realistic-ocean/src/render/REALISTIC-OCEAN-LICENSE.txt +25 -0
- package/template-assets/realistic-ocean/src/render/realisticSea.ts +642 -0
- package/template-assets/realistic-ocean/src/render/realisticSeaMaps.ts +311 -0
- package/template-assets/realistic-ocean/src/render/realisticSpectrum.ts +289 -0
- package/templates/AGENTS.md +21 -0
- package/templates/CLAUDE.md +23 -0
- package/templates/action-rpg/.codex/config.toml +6 -2
- package/templates/action-rpg/.cursor/mcp.json +8 -2
- package/templates/action-rpg/.gemini/settings.json +8 -2
- package/templates/action-rpg/.mcp.json +8 -2
- package/templates/action-rpg/.vscode/mcp.json +9 -2
- package/templates/action-rpg/.zed/settings.json +9 -2
- package/templates/action-rpg/AGENTS.md +11 -11
- package/templates/action-rpg/CLAUDE.md +11 -11
- package/templates/action-rpg/opencode.json +10 -2
- package/templates/action-rpg/package.json +17 -11
- package/templates/action-rpg/playtests/combat.playtest.json +6 -0
- package/templates/action-rpg/playtests/inventory.playtest.json +22 -0
- package/templates/action-rpg/playtests/performance.playtest.json +1 -1
- package/templates/action-rpg/playtests/roll.playtest.json +112 -0
- package/templates/action-rpg/playtests/swing.playtest.json +55 -0
- package/templates/action-rpg/playtests/win.playtest.json +4 -4
- package/templates/action-rpg/src/entities/Fighter.ts +44 -4
- package/templates/action-rpg/src/entities/Player.ts +64 -12
- package/templates/action-rpg/src/render/atmosphere.ts +444 -0
- package/templates/action-rpg/src/render/backlightMaterial.ts +49 -18
- package/templates/action-rpg/src/render/clouds.ts +605 -0
- package/templates/action-rpg/src/render/dungeon.ts +8 -6
- package/templates/action-rpg/src/render/exposure.ts +11 -109
- package/templates/action-rpg/src/render/gpuSky.ts +752 -0
- package/templates/action-rpg/src/render/lighting.ts +27 -4
- package/templates/action-rpg/src/render/materialLighting.ts +2 -11
- package/templates/action-rpg/src/render/palette.ts +1 -0
- package/templates/action-rpg/src/render/postprocessing.ts +4 -4
- package/templates/action-rpg/src/render/props.ts +10 -8
- package/templates/action-rpg/src/render/quality.ts +56 -108
- package/templates/action-rpg/src/render/sky.ts +74 -1
- package/templates/action-rpg/src/scenes/Play.ts +16 -12
- package/templates/action-rpg/src/ui/CharacterPanel.tsx +7 -2
- package/templates/action-rpg/src/ui/Hud.tsx +5 -7
- package/templates/action-rpg/src/ui/InventoryPanel.tsx +14 -14
- package/templates/action-rpg/threenative.config.ts +3 -0
- package/templates/adventure/.codex/config.toml +23 -0
- package/templates/adventure/.cursor/mcp.json +38 -0
- package/templates/adventure/.gemini/settings.json +38 -0
- package/templates/adventure/.mcp.json +38 -0
- package/templates/adventure/.vscode/mcp.json +43 -0
- package/templates/adventure/.zed/settings.json +43 -0
- package/templates/adventure/AGENTS.md +60 -0
- package/templates/adventure/CLAUDE.md +62 -0
- package/templates/adventure/index.html +14 -0
- package/templates/adventure/kit.json +8 -0
- package/templates/adventure/native-playtests/survives.playtest.json +52 -0
- package/templates/adventure/opencode.json +49 -0
- package/templates/adventure/package.json +65 -0
- package/templates/adventure/playtests/boss.playtest.json +406 -0
- package/templates/adventure/playtests/combat.playtest.json +342 -0
- package/templates/adventure/playtests/controls.playtest.json +142 -0
- package/templates/adventure/playtests/explore.playtest.json +45 -0
- package/templates/adventure/playtests/flicker.playtest.json +206 -0
- package/templates/adventure/playtests/hearts.playtest.json +171 -0
- package/templates/adventure/playtests/lockon.playtest.json +256 -0
- package/templates/adventure/playtests/look.playtest.json +72 -0
- package/templates/adventure/playtests/move-hollow.playtest.json +106 -0
- package/templates/adventure/playtests/move.playtest.json +84 -0
- package/templates/adventure/playtests/performance.playtest.json +55 -0
- package/templates/adventure/playtests/puzzle.playtest.json +250 -0
- package/templates/adventure/playtests/stride.playtest.json +67 -0
- package/templates/adventure/playtests/survives.playtest.json +171 -0
- package/templates/adventure/playtests/thornback.playtest.json +267 -0
- package/templates/adventure/public/favicon.svg +4 -0
- package/templates/adventure/src/entities/Block.ts +114 -0
- package/templates/adventure/src/entities/Chest.ts +69 -0
- package/templates/adventure/src/entities/Door.ts +81 -0
- package/templates/adventure/src/entities/Dummy.ts +69 -0
- package/templates/adventure/src/entities/Flicker.ts +239 -0
- package/templates/adventure/src/entities/Hero.ts +561 -0
- package/templates/adventure/src/entities/LockOn.ts +180 -0
- package/templates/adventure/src/entities/Mossling.ts +249 -0
- package/templates/adventure/src/entities/Switch.ts +49 -0
- package/templates/adventure/src/entities/Thornback.ts +238 -0
- package/templates/adventure/src/entities/Warden.ts +196 -0
- package/templates/adventure/src/game.ts +65 -0
- package/templates/adventure/src/interact.ts +63 -0
- package/templates/adventure/src/level/Hollow.ts +240 -0
- package/templates/adventure/src/level/Vale.ts +383 -0
- package/templates/adventure/src/main.ts +18 -0
- package/templates/adventure/src/render/camera.ts +416 -0
- package/templates/adventure/src/render/creatures.ts +405 -0
- package/templates/adventure/src/render/effects.ts +333 -0
- package/templates/adventure/src/render/foliage.ts +1072 -0
- package/templates/adventure/src/render/hero.ts +1447 -0
- package/templates/adventure/src/render/kitExposure.ts +20 -0
- package/templates/adventure/src/render/lighting.ts +74 -0
- package/templates/adventure/src/render/loading.ts +332 -0
- package/templates/adventure/src/render/materials.ts +179 -0
- package/templates/adventure/src/render/palette.ts +137 -0
- package/templates/adventure/src/render/postprocessing.ts +70 -0
- package/templates/adventure/src/render/props.ts +383 -0
- package/templates/adventure/src/render/quality.ts +46 -0
- package/templates/adventure/src/render/sky.ts +271 -0
- package/templates/adventure/src/render/surface.ts +259 -0
- package/templates/adventure/src/render/touch-controls.ts +137 -0
- package/templates/adventure/src/scenes/Play.ts +959 -0
- package/templates/adventure/src/state.ts +113 -0
- package/templates/adventure/src/style.css +98 -0
- package/templates/adventure/src/ui/App.tsx +22 -0
- package/templates/adventure/src/ui/GameUi.tsx +20 -0
- package/templates/adventure/src/ui/Hud.tsx +70 -0
- package/templates/adventure/src/ui/Menu.tsx +15 -0
- package/templates/adventure/src/ui/main.tsx +14 -0
- package/templates/adventure/tailwind.config.ts +2 -0
- package/templates/adventure/threenative.config.ts +62 -0
- package/templates/adventure/tsconfig.json +17 -0
- package/templates/adventure/vite.config.ts +49 -0
- package/templates/collectathon/.codex/config.toml +23 -0
- package/templates/collectathon/.cursor/mcp.json +38 -0
- package/templates/collectathon/.gemini/settings.json +38 -0
- package/templates/collectathon/.mcp.json +38 -0
- package/templates/collectathon/.vscode/mcp.json +43 -0
- package/templates/collectathon/.zed/settings.json +43 -0
- package/templates/collectathon/AGENTS.md +58 -0
- package/templates/collectathon/CLAUDE.md +60 -0
- package/templates/collectathon/index.html +14 -0
- package/templates/collectathon/kit.json +8 -0
- package/templates/collectathon/native-playtests/survives.playtest.json +52 -0
- package/templates/collectathon/opencode.json +49 -0
- package/templates/collectathon/package.json +65 -0
- package/templates/collectathon/playtests/acrobatics.playtest.json +238 -0
- package/templates/collectathon/playtests/camera.playtest.json +80 -0
- package/templates/collectathon/playtests/clipped-probe.playtest.json +101 -0
- package/templates/collectathon/playtests/collect.playtest.json +196 -0
- package/templates/collectathon/playtests/combat.playtest.json +246 -0
- package/templates/collectathon/playtests/double-tap-air.playtest.json +198 -0
- package/templates/collectathon/playtests/double-tap.playtest.json +136 -0
- package/templates/collectathon/playtests/effects.playtest.json +124 -0
- package/templates/collectathon/playtests/enemies.playtest.json +295 -0
- package/templates/collectathon/playtests/explore.playtest.json +45 -0
- package/templates/collectathon/playtests/hop-reach.playtest.json +117 -0
- package/templates/collectathon/playtests/jump-chain.playtest.json +274 -0
- package/templates/collectathon/playtests/ledge-angle.playtest.json +107 -0
- package/templates/collectathon/playtests/ledge-too-high.playtest.json +115 -0
- package/templates/collectathon/playtests/ledge.playtest.json +100 -0
- package/templates/collectathon/playtests/look.playtest.json +64 -0
- package/templates/collectathon/playtests/performance.playtest.json +55 -0
- package/templates/collectathon/playtests/stride.playtest.json +111 -0
- package/templates/collectathon/playtests/survives.playtest.json +123 -0
- package/templates/collectathon/playtests/telegraphs.playtest.json +132 -0
- package/templates/collectathon/playtests/thornback.playtest.json +157 -0
- package/templates/collectathon/playtests/wall-kick.playtest.json +206 -0
- package/templates/collectathon/playtests/win.playtest.json +166 -0
- package/templates/collectathon/public/favicon.svg +4 -0
- package/templates/collectathon/src/entities/Hero.ts +915 -0
- package/templates/collectathon/src/entities/Pickup.ts +63 -0
- package/templates/collectathon/src/entities/Walker.ts +248 -0
- package/templates/collectathon/src/game.ts +51 -0
- package/templates/collectathon/src/level/Course.ts +590 -0
- package/templates/collectathon/src/level/terrain.ts +144 -0
- package/templates/collectathon/src/main.ts +14 -0
- package/templates/collectathon/src/playtest-events.ts +15 -0
- package/templates/collectathon/src/render/camera.ts +163 -0
- package/templates/collectathon/src/render/castle.ts +408 -0
- package/templates/collectathon/src/render/effects.ts +284 -0
- package/templates/collectathon/src/render/foliage.ts +744 -0
- package/templates/collectathon/src/render/ground.ts +139 -0
- package/templates/collectathon/src/render/hero.ts +452 -0
- package/templates/collectathon/src/render/kitExposure.ts +20 -0
- package/templates/collectathon/src/render/lighting.ts +65 -0
- package/templates/collectathon/src/render/loading.ts +332 -0
- package/templates/collectathon/src/render/materials.ts +196 -0
- package/templates/collectathon/src/render/palette.ts +82 -0
- package/templates/collectathon/src/render/postprocessing.ts +79 -0
- package/templates/collectathon/src/render/props.ts +218 -0
- package/templates/collectathon/src/render/quality.ts +54 -0
- package/templates/collectathon/src/render/sky.ts +262 -0
- package/templates/collectathon/src/render/surface.ts +269 -0
- package/templates/collectathon/src/render/touch-controls.ts +179 -0
- package/templates/collectathon/src/render/touch-layout.ts +48 -0
- package/templates/collectathon/src/render/water.ts +191 -0
- package/templates/collectathon/src/scenes/Play.ts +481 -0
- package/templates/collectathon/src/state.ts +38 -0
- package/templates/collectathon/src/style.css +106 -0
- package/templates/collectathon/src/ui/App.tsx +22 -0
- package/templates/collectathon/src/ui/GameUi.tsx +20 -0
- package/templates/collectathon/src/ui/Hud.tsx +77 -0
- package/templates/collectathon/src/ui/Menu.tsx +13 -0
- package/templates/collectathon/src/ui/main.tsx +14 -0
- package/templates/collectathon/tailwind.config.ts +2 -0
- package/templates/collectathon/threenative.config.ts +62 -0
- package/templates/collectathon/tsconfig.json +17 -0
- package/templates/collectathon/vite.config.ts +49 -0
- package/templates/kart/.codex/config.toml +23 -0
- package/templates/kart/.cursor/mcp.json +38 -0
- package/templates/kart/.gemini/settings.json +38 -0
- package/templates/kart/.mcp.json +38 -0
- package/templates/kart/.vscode/mcp.json +43 -0
- package/templates/kart/.zed/settings.json +43 -0
- package/templates/kart/AGENTS.md +58 -0
- package/templates/kart/CLAUDE.md +60 -0
- package/templates/kart/index.html +14 -0
- package/templates/kart/kit.json +8 -0
- package/templates/kart/native-playtests/survives.playtest.json +65 -0
- package/templates/kart/opencode.json +49 -0
- package/templates/kart/package.json +64 -0
- package/templates/kart/playtests/drift.playtest.json +226 -0
- package/templates/kart/playtests/explore.playtest.json +45 -0
- package/templates/kart/playtests/hit-stays-above-road.playtest.json +92 -0
- package/templates/kart/playtests/item-key.playtest.json +108 -0
- package/templates/kart/playtests/items.playtest.json +143 -0
- package/templates/kart/playtests/lap-times.playtest.json +138 -0
- package/templates/kart/playtests/laps.playtest.json +149 -0
- package/templates/kart/playtests/performance.playtest.json +57 -0
- package/templates/kart/playtests/race.playtest.json +294 -0
- package/templates/kart/playtests/restart.playtest.json +87 -0
- package/templates/kart/playtests/rocket-start.playtest.json +56 -0
- package/templates/kart/playtests/smooth-drive.playtest.json +101 -0
- package/templates/kart/playtests/surfaces.playtest.json +113 -0
- package/templates/kart/playtests/survives.playtest.json +116 -0
- package/templates/kart/playtests/wall.playtest.json +118 -0
- package/templates/kart/public/favicon.svg +4 -0
- package/templates/kart/src/entities/Driver.ts +123 -0
- package/templates/kart/src/entities/Items.ts +194 -0
- package/templates/kart/src/entities/Kart.ts +517 -0
- package/templates/kart/src/game.ts +45 -0
- package/templates/kart/src/main.ts +14 -0
- package/templates/kart/src/playtest-events.ts +15 -0
- package/templates/kart/src/render/camera.ts +83 -0
- package/templates/kart/src/render/course.ts +579 -0
- package/templates/kart/src/render/effects.ts +266 -0
- package/templates/kart/src/render/items.ts +163 -0
- package/templates/kart/src/render/kart.ts +256 -0
- package/templates/kart/src/render/kitExposure.ts +20 -0
- package/templates/kart/src/render/lighting.ts +58 -0
- package/templates/kart/src/render/loading.ts +332 -0
- package/templates/kart/src/render/materials.ts +119 -0
- package/templates/kart/src/render/palette.ts +74 -0
- package/templates/kart/src/render/postprocessing.ts +79 -0
- package/templates/kart/src/render/quality.ts +54 -0
- package/templates/kart/src/render/skids.ts +86 -0
- package/templates/kart/src/render/sky.ts +105 -0
- package/templates/kart/src/render/touch-controls.ts +168 -0
- package/templates/kart/src/render/touch-layout.ts +48 -0
- package/templates/kart/src/scenes/Race.ts +850 -0
- package/templates/kart/src/state.ts +53 -0
- package/templates/kart/src/style.css +106 -0
- package/templates/kart/src/track/Course.ts +276 -0
- package/templates/kart/src/track/Race.ts +133 -0
- package/templates/kart/src/ui/App.tsx +21 -0
- package/templates/kart/src/ui/GameUi.tsx +20 -0
- package/templates/kart/src/ui/Hud.tsx +172 -0
- package/templates/kart/src/ui/Menu.tsx +13 -0
- package/templates/kart/src/ui/main.tsx +14 -0
- package/templates/kart/tailwind.config.ts +2 -0
- package/templates/kart/threenative.config.ts +62 -0
- package/templates/kart/tsconfig.json +17 -0
- package/templates/kart/vite.config.ts +49 -0
- package/templates/minimal/.codex/config.toml +6 -2
- package/templates/minimal/.cursor/mcp.json +8 -2
- package/templates/minimal/.gemini/settings.json +8 -2
- package/templates/minimal/.mcp.json +8 -2
- package/templates/minimal/.vscode/mcp.json +9 -2
- package/templates/minimal/.zed/settings.json +9 -2
- package/templates/minimal/AGENTS.md +11 -13
- package/templates/minimal/CLAUDE.md +11 -13
- package/templates/minimal/opencode.json +10 -2
- package/templates/minimal/package.json +16 -10
- package/templates/minimal/playtests/camera-wall.playtest.json +36 -0
- package/templates/minimal/playtests/jump.playtest.json +45 -0
- package/templates/minimal/playtests/play.playtest.json +1 -1
- package/templates/minimal/src/game.ts +2 -0
- package/templates/minimal/src/render/atmosphere.ts +444 -0
- package/templates/minimal/src/render/backlightMaterial.ts +49 -18
- package/templates/minimal/src/render/camera.ts +35 -4
- package/templates/minimal/src/render/clouds.ts +605 -0
- package/templates/minimal/src/render/exposure.ts +7 -111
- package/templates/minimal/src/render/gpuSky.ts +752 -0
- package/templates/minimal/src/render/lighting.ts +26 -4
- package/templates/minimal/src/render/materialLighting.ts +2 -10
- package/templates/minimal/src/render/postprocessing.ts +4 -4
- package/templates/minimal/src/render/quality.ts +10 -116
- package/templates/minimal/src/render/sky.ts +73 -1
- package/templates/minimal/src/scenes/Play.ts +18 -7
- package/templates/platformer/.codex/config.toml +6 -2
- package/templates/platformer/.cursor/mcp.json +8 -2
- package/templates/platformer/.gemini/settings.json +8 -2
- package/templates/platformer/.mcp.json +8 -2
- package/templates/platformer/.vscode/mcp.json +9 -2
- package/templates/platformer/.zed/settings.json +9 -2
- package/templates/platformer/AGENTS.md +13 -9
- package/templates/platformer/CLAUDE.md +13 -9
- package/templates/platformer/opencode.json +10 -2
- package/templates/platformer/package.json +17 -11
- package/templates/platformer/playtests/dash-jump.playtest.json +34 -0
- package/templates/platformer/playtests/finish.playtest.json +58 -0
- package/templates/platformer/playtests/idle.playtest.json +44 -0
- package/templates/platformer/playtests/performance.playtest.json +1 -1
- package/templates/platformer/src/entities/Fox.ts +19 -6
- package/templates/platformer/src/game.ts +1 -0
- package/templates/platformer/src/level/Stage.ts +4 -1
- package/templates/platformer/src/render/backlightMaterial.ts +49 -18
- package/templates/platformer/src/render/camera.ts +30 -1
- package/templates/platformer/src/render/exposure.ts +6 -111
- package/templates/platformer/src/render/fox.ts +5 -2
- package/templates/platformer/src/render/kitExposure.ts +20 -0
- package/templates/platformer/src/render/materialLighting.ts +2 -11
- package/templates/platformer/src/render/postprocessing.ts +4 -4
- package/templates/platformer/src/render/props.ts +1 -2
- package/templates/platformer/src/render/quality.ts +10 -118
- package/templates/platformer/src/scenes/Play.ts +31 -15
- package/templates/platformer/src/ui/Menu.tsx +1 -1
- package/templates/puzzle/.codex/config.toml +6 -2
- package/templates/puzzle/.cursor/mcp.json +8 -2
- package/templates/puzzle/.gemini/settings.json +8 -2
- package/templates/puzzle/.mcp.json +8 -2
- package/templates/puzzle/.vscode/mcp.json +9 -2
- package/templates/puzzle/.zed/settings.json +9 -2
- package/templates/puzzle/AGENTS.md +14 -17
- package/templates/puzzle/CLAUDE.md +14 -17
- package/templates/puzzle/opencode.json +10 -2
- package/templates/puzzle/package.json +17 -11
- package/templates/puzzle/playtests/performance.playtest.json +1 -1
- package/templates/puzzle/playtests/replay-keeps-progress.playtest.json +78 -0
- package/templates/puzzle/src/render/backlightMaterial.ts +49 -18
- package/templates/puzzle/src/render/exposure.ts +11 -109
- package/templates/puzzle/src/render/lighting.ts +3 -3
- package/templates/puzzle/src/render/materialLighting.ts +2 -11
- package/templates/puzzle/src/render/palette.ts +1 -1
- package/templates/puzzle/src/render/postprocessing.ts +4 -4
- package/templates/puzzle/src/render/quality.ts +44 -153
- package/templates/puzzle/src/render/vault.ts +18 -6
- package/templates/puzzle/src/scenes/Play.ts +6 -1
- package/templates/puzzle/src/ui/Hud.tsx +8 -43
- package/templates/racing/.codex/config.toml +6 -2
- package/templates/racing/.cursor/mcp.json +8 -2
- package/templates/racing/.gemini/settings.json +8 -2
- package/templates/racing/.mcp.json +8 -2
- package/templates/racing/.vscode/mcp.json +9 -2
- package/templates/racing/.zed/settings.json +9 -2
- package/templates/racing/AGENTS.md +10 -12
- package/templates/racing/CLAUDE.md +10 -12
- package/templates/racing/opencode.json +10 -2
- package/templates/racing/package.json +17 -11
- package/templates/racing/playtests/brake.playtest.json +54 -0
- package/templates/racing/playtests/outcome.playtest.json +19 -0
- package/templates/racing/playtests/performance.playtest.json +1 -1
- package/templates/racing/playtests/stopped-car-is-not-rescued.playtest.json +59 -0
- package/templates/racing/src/entities/RacingCar.ts +12 -3
- package/templates/racing/src/entities/Rival.ts +11 -2
- package/templates/racing/src/render/atmosphere.ts +444 -0
- package/templates/racing/src/render/backlightMaterial.ts +49 -18
- package/templates/racing/src/render/clouds.ts +605 -0
- package/templates/racing/src/render/exposure.ts +6 -111
- package/templates/racing/src/render/gpuSky.ts +752 -0
- package/templates/racing/src/render/kitExposure.ts +20 -0
- package/templates/racing/src/render/lighting.ts +26 -4
- package/templates/racing/src/render/materialLighting.ts +2 -11
- package/templates/racing/src/render/materials.ts +2 -1
- package/templates/racing/src/render/postprocessing.ts +4 -4
- package/templates/racing/src/render/quality.ts +27 -115
- package/templates/racing/src/render/sky.ts +76 -5
- package/templates/racing/src/scenes/Race.ts +53 -42
- package/templates/racing/src/track/TrackSector.ts +5 -2
- package/templates/racing/src/ui/Hud.tsx +12 -7
- package/templates/rain/.codex/config.toml +6 -2
- package/templates/rain/.cursor/mcp.json +8 -2
- package/templates/rain/.gemini/settings.json +8 -2
- package/templates/rain/.mcp.json +8 -2
- package/templates/rain/.vscode/mcp.json +9 -2
- package/templates/rain/.zed/settings.json +9 -2
- package/templates/rain/AGENTS.md +12 -12
- package/templates/rain/CLAUDE.md +12 -12
- package/templates/rain/opencode.json +10 -2
- package/templates/rain/package.json +16 -10
- package/templates/rain/playtests/performance.playtest.json +1 -1
- package/templates/rain/src/game.ts +1 -1
- package/templates/rain/src/render/bloom-shader.ts +1 -1
- package/templates/rain/src/render/clouds-shader.ts +2 -2
- package/templates/rain/src/render/clouds.ts +2 -1
- package/templates/rain/src/render/exposure.ts +11 -109
- package/templates/rain/src/render/post-shader.ts +7 -11
- package/templates/rain/src/render/postprocessing.ts +8 -24
- package/templates/rain/src/render/quality.ts +44 -98
- package/templates/rain/src/render/world-shader.ts +281 -97
- package/templates/rain/src/render/world.ts +82 -2
- package/templates/rain/src/style.css +1 -1
- package/templates/rain/src/ui/GameUi.tsx +6 -2
- package/templates/rain/src/ui/Hud.tsx +1 -1
- package/templates/rain/tools/generate-shaders.mjs +2 -2
- package/templates/rain/tools/tempest-post.frag +4 -6
- package/templates/rain/tools/tempest-world.frag +80 -12
- package/templates/rts/.codex/config.toml +6 -2
- package/templates/rts/.cursor/mcp.json +8 -2
- package/templates/rts/.gemini/settings.json +8 -2
- package/templates/rts/.mcp.json +8 -2
- package/templates/rts/.vscode/mcp.json +9 -2
- package/templates/rts/.zed/settings.json +9 -2
- package/templates/rts/AGENTS.md +15 -16
- package/templates/rts/CLAUDE.md +15 -16
- package/templates/rts/opencode.json +10 -2
- package/templates/rts/package.json +16 -10
- package/templates/rts/playtests/performance.playtest.json +1 -1
- package/templates/rts/playtests/rts-attack.playtest.json +5 -0
- package/templates/rts/playtests/rts-build.playtest.json +20 -1
- package/templates/rts/playtests/rts-orders.playtest.json +1 -1
- package/templates/rts/playtests/rts-pause.playtest.json +112 -0
- package/templates/rts/playtests/rts-train.playtest.json +1 -1
- package/templates/rts/playtests/rts-zoom.playtest.json +81 -0
- package/templates/rts/src/game.ts +29 -7
- package/templates/rts/src/render/army.ts +181 -49
- package/templates/rts/src/render/backlightMaterial.ts +49 -18
- package/templates/rts/src/render/environment.ts +276 -0
- package/templates/rts/src/render/exposure.ts +3 -65
- package/templates/rts/src/render/ground.ts +478 -0
- package/templates/rts/src/render/lighting.ts +62 -11
- package/templates/rts/src/render/materialLighting.ts +2 -11
- package/templates/rts/src/render/materials.ts +47 -118
- package/templates/rts/src/render/palette.ts +30 -13
- package/templates/rts/src/render/picking.ts +18 -0
- package/templates/rts/src/render/postprocessing.ts +4 -4
- package/templates/rts/src/render/quality.ts +64 -85
- package/templates/rts/src/render/resources.ts +21 -22
- package/templates/rts/src/render/sky.ts +9 -12
- package/templates/rts/src/render/terrain.ts +36 -11
- package/templates/rts/src/scenes/Play.ts +373 -38
- package/templates/rts/src/sim/ai.ts +0 -11
- package/templates/rts/src/state.ts +46 -0
- package/templates/rts/src/style.css +1543 -0
- package/templates/rts/src/ui/Commands.tsx +204 -107
- package/templates/rts/src/ui/GameUi.tsx +12 -5
- package/templates/rts/src/ui/Hud.tsx +611 -116
- package/templates/rts/src/ui/Minimap.tsx +103 -37
- package/templates/rts/src/ui/icons.tsx +116 -0
- package/templates/rts/src/ui/labels.ts +73 -0
- package/templates/rts/src/ui/minimapPoint.ts +30 -0
- package/templates/rts/threenative.config.ts +1 -1
- package/templates/runner/.codex/config.toml +6 -2
- package/templates/runner/.cursor/mcp.json +8 -2
- package/templates/runner/.gemini/settings.json +8 -2
- package/templates/runner/.mcp.json +8 -2
- package/templates/runner/.vscode/mcp.json +9 -2
- package/templates/runner/.zed/settings.json +9 -2
- package/templates/runner/AGENTS.md +12 -12
- package/templates/runner/CLAUDE.md +12 -12
- package/templates/runner/opencode.json +10 -2
- package/templates/runner/package.json +17 -11
- package/templates/runner/playtests/near-miss.playtest.json +48 -0
- package/templates/runner/playtests/performance.playtest.json +2 -2
- package/templates/runner/playtests/stride.playtest.json +27 -0
- package/templates/runner/playtests/survives.playtest.json +2 -2
- package/templates/runner/src/conventions.ts +3 -1
- package/templates/runner/src/entities/Runner.ts +11 -5
- package/templates/runner/src/render/atmosphere.ts +444 -0
- package/templates/runner/src/render/backlightMaterial.ts +49 -18
- package/templates/runner/src/render/clouds.ts +605 -0
- package/templates/runner/src/render/exposure.ts +6 -111
- package/templates/runner/src/render/gpuSky.ts +752 -0
- package/templates/runner/src/render/kitExposure.ts +20 -0
- package/templates/runner/src/render/lighting.ts +26 -4
- package/templates/runner/src/render/materialLighting.ts +2 -11
- package/templates/runner/src/render/postprocessing.ts +4 -4
- package/templates/runner/src/render/quality.ts +26 -114
- package/templates/runner/src/render/sky.ts +73 -1
- package/templates/runner/src/scenes/Run.ts +19 -15
- package/templates/runner/src/track.ts +12 -3
- package/templates/sailing/.codex/config.toml +6 -2
- package/templates/sailing/.cursor/mcp.json +8 -2
- package/templates/sailing/.gemini/settings.json +8 -2
- package/templates/sailing/.mcp.json +8 -2
- package/templates/sailing/.vscode/mcp.json +9 -2
- package/templates/sailing/.zed/settings.json +9 -2
- package/templates/sailing/AGENTS.md +10 -11
- package/templates/sailing/CLAUDE.md +10 -11
- package/templates/sailing/opencode.json +10 -2
- package/templates/sailing/package.json +17 -11
- package/templates/sailing/playtests/fail.playtest.json +46 -5
- package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +7 -0
- package/templates/sailing/playtests/performance.playtest.json +1 -1
- package/templates/sailing/src/game.ts +1 -0
- package/templates/sailing/src/render/backlightMaterial.ts +49 -18
- package/templates/sailing/src/render/exposure.ts +6 -111
- package/templates/sailing/src/render/kitExposure.ts +20 -0
- package/templates/sailing/src/render/materialLighting.ts +2 -11
- package/templates/sailing/src/render/ocean.ts +0 -1
- package/templates/sailing/src/render/postprocessing.ts +4 -4
- package/templates/sailing/src/render/quality.ts +31 -138
- package/templates/sailing/src/scenes/Sailing.ts +12 -4
- package/templates/sailing/src/ui/Hud.tsx +6 -2
- package/templates/sailing/src/ui/Menu.tsx +1 -1
- package/templates/shooter/.codex/config.toml +6 -2
- package/templates/shooter/.cursor/mcp.json +8 -2
- package/templates/shooter/.gemini/settings.json +8 -2
- package/templates/shooter/.mcp.json +8 -2
- package/templates/shooter/.vscode/mcp.json +9 -2
- package/templates/shooter/.zed/settings.json +9 -2
- package/templates/shooter/AGENTS.md +13 -12
- package/templates/shooter/CLAUDE.md +13 -12
- package/templates/shooter/index.html +1 -1
- package/templates/shooter/main.html +13 -0
- package/templates/shooter/opencode.json +10 -2
- package/templates/shooter/package.json +17 -11
- package/templates/shooter/playtests/breakable-shatters.playtest.json +6 -0
- package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +6 -0
- package/templates/shooter/playtests/hands-authored-rate.playtest.json +54 -0
- package/templates/shooter/playtests/movement-eases.playtest.json +53 -0
- package/templates/shooter/playtests/performance.playtest.json +3 -3
- package/templates/shooter/playtests/stairs-smooth-the-eye.playtest.json +56 -0
- package/templates/shooter/playtests/weapon-sharp-while-turning.playtest.json +206 -0
- package/templates/shooter/src/entities/Breakables.ts +34 -10
- package/templates/shooter/src/entities/Enemy.ts +176 -54
- package/templates/shooter/src/entities/FpsPlayer.ts +55 -16
- package/templates/shooter/src/entities/Rifle.ts +83 -9
- package/templates/shooter/src/entities/movement.ts +96 -0
- package/templates/shooter/src/render/atmosphere.ts +444 -0
- package/templates/shooter/src/render/backlightMaterial.ts +49 -18
- package/templates/shooter/src/render/camera.ts +3 -1
- package/templates/shooter/src/render/clouds.ts +605 -0
- package/templates/shooter/src/render/exposure.ts +10 -109
- package/templates/shooter/src/render/facade.ts +26 -68
- package/templates/shooter/src/render/gpuSky.ts +752 -0
- package/templates/shooter/src/render/lighting.ts +27 -4
- package/templates/shooter/src/render/materialAssignments.ts +9 -1
- package/templates/shooter/src/render/materialLighting.ts +2 -11
- package/templates/shooter/src/render/occlusion.ts +13 -4
- package/templates/shooter/src/render/palette.ts +1 -0
- package/templates/shooter/src/render/postprocessing.ts +4 -4
- package/templates/shooter/src/render/quality.ts +50 -108
- package/templates/shooter/src/render/scale.ts +0 -11
- package/templates/shooter/src/render/sky.ts +103 -2
- package/templates/shooter/src/render/surface.ts +140 -0
- package/templates/shooter/src/render/town.ts +3 -6
- package/templates/shooter/src/render/townMaterials.ts +95 -42
- package/templates/shooter/src/render/vehicles.ts +2 -0
- package/templates/shooter/src/scenes/Play.ts +83 -23
- package/templates/shooter/src/ui/Hud.tsx +268 -193
- package/templates/shooter/src/worker-page.ts +29 -0
- package/templates/shooter/src/worker.ts +5 -0
- package/templates/shooter/threenative.config.ts +3 -0
- package/templates/shooter/vite.config.ts +2 -0
- package/templates/snow/.codex/config.toml +6 -2
- package/templates/snow/.cursor/mcp.json +8 -2
- package/templates/snow/.gemini/settings.json +8 -2
- package/templates/snow/.mcp.json +8 -2
- package/templates/snow/.vscode/mcp.json +9 -2
- package/templates/snow/.zed/settings.json +9 -2
- package/templates/snow/AGENTS.md +12 -10
- package/templates/snow/CLAUDE.md +12 -10
- package/templates/snow/opencode.json +10 -2
- package/templates/snow/package.json +17 -11
- package/templates/snow/playtests/performance.playtest.json +1 -1
- package/templates/snow/src/render/backlightMaterial.ts +49 -18
- package/templates/snow/src/render/exposure.ts +17 -106
- package/templates/snow/src/render/materialLighting.ts +2 -11
- package/templates/snow/src/render/postprocessing.ts +11 -5
- package/templates/snow/src/render/quality.ts +46 -126
- package/templates/snow/src/render/snowSurface.ts +32 -15
- package/templates/snow/src/scenes/Snow.ts +2 -1
- package/templates/starter/.codex/config.toml +6 -2
- package/templates/starter/.cursor/mcp.json +8 -2
- package/templates/starter/.gemini/settings.json +8 -2
- package/templates/starter/.mcp.json +8 -2
- package/templates/starter/.vscode/mcp.json +9 -2
- package/templates/starter/.zed/settings.json +9 -2
- package/templates/starter/AGENTS.md +18 -14
- package/templates/starter/CLAUDE.md +18 -14
- package/templates/starter/index.html +1 -1
- package/templates/starter/main.html +12 -0
- package/templates/starter/native-playtests/react-hud.playtest.json +1 -0
- package/templates/starter/native-playtests/render-chain.playtest.json +34 -21
- package/templates/starter/opencode.json +10 -2
- package/templates/starter/package.json +17 -11
- package/templates/starter/playtests/play.playtest.json +22 -2
- package/templates/starter/playtests/production-readiness.playtest.json +56 -0
- package/templates/starter/src/entities/Crate.ts +19 -1
- package/templates/starter/src/render/arena.ts +2 -2
- package/templates/starter/src/render/atmosphere.ts +444 -0
- package/templates/starter/src/render/backlightMaterial.ts +49 -18
- package/templates/starter/src/render/camera.ts +28 -0
- package/templates/starter/src/render/clouds.ts +605 -0
- package/templates/starter/src/render/contactShadow.ts +50 -0
- package/templates/starter/src/render/exposure.ts +9 -111
- package/templates/starter/src/render/gpuSky.ts +752 -0
- package/templates/starter/src/render/grade.ts +1 -1
- package/templates/starter/src/render/lighting.ts +34 -6
- package/templates/starter/src/render/materialLighting.ts +2 -11
- package/templates/starter/src/render/postprocessing.ts +53 -34
- package/templates/starter/src/render/quality.ts +18 -147
- package/templates/starter/src/render/sky.ts +90 -40
- package/templates/starter/src/render/temporalAA.ts +1 -1
- package/templates/starter/src/render/temporalAAStage.ts +1 -1
- package/templates/starter/src/render/temporalCurrentFootprint.ts +0 -1
- package/templates/starter/src/render/temporalDetailStage.ts +106 -0
- package/templates/starter/src/render/temporalRejectionCounter.ts +2 -2
- package/templates/starter/src/render/volumetricFogCamera.ts +32 -0
- package/templates/starter/src/render/volumetricFogOptions.ts +7 -0
- package/templates/starter/src/render/volumetricFogTransport.ts +27 -19
- package/templates/starter/src/render/volumetricFogVolume.ts +31 -7
- package/templates/starter/src/scenes/Play.ts +11 -8
- package/templates/starter/src/ui/Hud.tsx +1 -1
- package/templates/starter/src/worker-page.ts +29 -0
- package/templates/starter/src/worker.ts +5 -0
- package/templates/starter/vite.config.ts +2 -0
- package/templates/tower-defense/.codex/config.toml +6 -2
- package/templates/tower-defense/.cursor/mcp.json +8 -2
- package/templates/tower-defense/.gemini/settings.json +8 -2
- package/templates/tower-defense/.mcp.json +8 -2
- package/templates/tower-defense/.vscode/mcp.json +9 -2
- package/templates/tower-defense/.zed/settings.json +9 -2
- package/templates/tower-defense/AGENTS.md +10 -12
- package/templates/tower-defense/CLAUDE.md +10 -12
- package/templates/tower-defense/opencode.json +10 -2
- package/templates/tower-defense/package.json +17 -11
- package/templates/tower-defense/playtests/chill-tint.playtest.json +387 -0
- package/templates/tower-defense/playtests/performance.playtest.json +1 -1
- package/templates/tower-defense/src/enemies/Enemy.ts +9 -0
- package/templates/tower-defense/src/render/backlightMaterial.ts +49 -18
- package/templates/tower-defense/src/render/exposure.ts +11 -109
- package/templates/tower-defense/src/render/lighting.ts +4 -2
- package/templates/tower-defense/src/render/materialLighting.ts +2 -11
- package/templates/tower-defense/src/render/postprocessing.ts +4 -4
- package/templates/tower-defense/src/render/quality.ts +10 -116
- package/templates/tower-defense/src/render/sky.ts +2 -2
- package/templates/tower-defense/src/scenes/Battle.ts +4 -0
- package/template-assets/autoExposure.ts +0 -225
- package/template-assets/exposureGraph.ts +0 -178
- package/template-assets/exposureReadback.ts +0 -79
- package/template-assets/worldEnvironment.ts +0 -1212
- package/templates/action-rpg/src/render/autoExposure.ts +0 -225
- package/templates/action-rpg/src/render/exposureGraph.ts +0 -178
- package/templates/action-rpg/src/render/exposureReadback.ts +0 -79
- package/templates/action-rpg/src/render/worldEnvironment.ts +0 -1212
- package/templates/minimal/src/render/autoExposure.ts +0 -225
- package/templates/minimal/src/render/exposureGraph.ts +0 -178
- package/templates/minimal/src/render/exposureReadback.ts +0 -79
- package/templates/minimal/src/render/worldEnvironment.ts +0 -1212
- package/templates/platformer/src/render/autoExposure.ts +0 -225
- package/templates/platformer/src/render/exposureGraph.ts +0 -178
- package/templates/platformer/src/render/exposureReadback.ts +0 -79
- package/templates/platformer/src/render/worldEnvironment.ts +0 -1212
- package/templates/puzzle/src/render/autoExposure.ts +0 -225
- package/templates/puzzle/src/render/exposureGraph.ts +0 -178
- package/templates/puzzle/src/render/exposureReadback.ts +0 -79
- package/templates/puzzle/src/render/worldEnvironment.ts +0 -1212
- package/templates/racing/src/render/autoExposure.ts +0 -225
- package/templates/racing/src/render/exposureGraph.ts +0 -178
- package/templates/racing/src/render/exposureReadback.ts +0 -79
- package/templates/racing/src/render/worldEnvironment.ts +0 -1212
- package/templates/rain/src/render/autoExposure.ts +0 -225
- package/templates/rain/src/render/exposureGraph.ts +0 -178
- package/templates/rain/src/render/exposureReadback.ts +0 -79
- package/templates/rain/src/render/worldEnvironment.ts +0 -1212
- package/templates/rts/src/render/autoExposure.ts +0 -225
- package/templates/rts/src/render/exposureGraph.ts +0 -178
- package/templates/rts/src/render/exposureReadback.ts +0 -79
- package/templates/rts/src/render/worldEnvironment.ts +0 -1212
- package/templates/runner/src/render/autoExposure.ts +0 -225
- package/templates/runner/src/render/exposureGraph.ts +0 -178
- package/templates/runner/src/render/exposureReadback.ts +0 -79
- package/templates/runner/src/render/worldEnvironment.ts +0 -1212
- package/templates/sailing/src/render/autoExposure.ts +0 -225
- package/templates/sailing/src/render/exposureGraph.ts +0 -178
- package/templates/sailing/src/render/exposureReadback.ts +0 -79
- package/templates/sailing/src/render/worldEnvironment.ts +0 -1212
- package/templates/shooter/src/render/autoExposure.ts +0 -225
- package/templates/shooter/src/render/exposureGraph.ts +0 -178
- package/templates/shooter/src/render/exposureReadback.ts +0 -79
- package/templates/shooter/src/render/worldEnvironment.ts +0 -1212
- package/templates/snow/src/render/autoExposure.ts +0 -225
- package/templates/snow/src/render/exposureGraph.ts +0 -178
- package/templates/snow/src/render/exposureReadback.ts +0 -79
- package/templates/snow/src/render/worldEnvironment.ts +0 -1212
- package/templates/starter/src/render/autoExposure.ts +0 -225
- package/templates/starter/src/render/exposureGraph.ts +0 -178
- package/templates/starter/src/render/exposureReadback.ts +0 -79
- package/templates/starter/src/render/worldEnvironment.ts +0 -1212
- package/templates/tower-defense/src/render/autoExposure.ts +0 -225
- package/templates/tower-defense/src/render/exposureGraph.ts +0 -178
- package/templates/tower-defense/src/render/exposureReadback.ts +0 -79
- package/templates/tower-defense/src/render/worldEnvironment.ts +0 -1212
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type ICtx,
|
|
3
|
+
type IRawInputPointerEdge,
|
|
4
|
+
Scene,
|
|
5
|
+
type SceneFrame,
|
|
6
|
+
getPlatform,
|
|
7
|
+
isMobile,
|
|
8
|
+
lodPixelScale,
|
|
9
|
+
} from "@threenative/core";
|
|
10
|
+
import { Object3D, type OrthographicCamera, type Texture, Vector2, Vector3 } from "three";
|
|
3
11
|
import { onSceneIntent } from "../orders.js";
|
|
4
12
|
import { createArmy } from "../render/army.js";
|
|
5
13
|
import {
|
|
@@ -13,17 +21,25 @@ import {
|
|
|
13
21
|
panSpeed,
|
|
14
22
|
zoomRts,
|
|
15
23
|
} from "../render/camera.js";
|
|
24
|
+
import { createEnvironment } from "../render/environment.js";
|
|
16
25
|
import { type IEnvironmentSample, sampleEnvironment } from "../render/environmentSampling.js";
|
|
17
26
|
import { type ISun, setupLighting } from "../render/lighting.js";
|
|
18
27
|
import { createLoadingScreen } from "../render/loading.js";
|
|
19
28
|
import { createMaterialLighting } from "../render/materialLighting.js";
|
|
20
29
|
import { createUnitModels } from "../render/models.js";
|
|
21
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
DRAG_SLOP,
|
|
32
|
+
type PickTarget,
|
|
33
|
+
dragBoxRect,
|
|
34
|
+
pickEntity,
|
|
35
|
+
unitsInBox,
|
|
36
|
+
} from "../render/picking.js";
|
|
22
37
|
import { setupPost } from "../render/postprocessing.js";
|
|
23
38
|
import { isWebGLFallbackRenderer, materialLightingEnabled } from "../render/quality.js";
|
|
24
39
|
import { createResources } from "../render/resources.js";
|
|
25
40
|
import { setupSky } from "../render/sky.js";
|
|
26
41
|
import { createTerrain } from "../render/terrain.js";
|
|
42
|
+
import { unloadGarrison } from "../sim/combat.js";
|
|
27
43
|
import { Game } from "../sim/game.js";
|
|
28
44
|
import { HALF, WORLD, terrainHeight } from "../sim/terrain.js";
|
|
29
45
|
import {
|
|
@@ -46,8 +62,6 @@ const STEP = SIM_STEP;
|
|
|
46
62
|
/** Never run more than a quarter second of catch-up: a tab that was backgrounded must not spend a
|
|
47
63
|
* second of catch-up stalling the frame it came back on. */
|
|
48
64
|
const MAX_CATCH_UP = 0.25;
|
|
49
|
-
/** A drag shorter than this is a click, not a box. */
|
|
50
|
-
const DRAG_SLOP = 4;
|
|
51
65
|
/** The coarse fog raster the HUD draws: 28 cells over 224 m is one every 8 m. */
|
|
52
66
|
const MINIMAP = 28;
|
|
53
67
|
/** Every order the panel can name, in the order the readout lists them. */
|
|
@@ -69,6 +83,7 @@ const REFUSALS: Readonly<Record<string, string>> = {
|
|
|
69
83
|
attackMove: "Those units cannot advance under fire.",
|
|
70
84
|
garrison: "Select Vanguards and a friendly bunker with free slots.",
|
|
71
85
|
repair: "Select a Surveyor and a completed friendly structure.",
|
|
86
|
+
follow: "Select a Mender and a friendly ground unit.",
|
|
72
87
|
};
|
|
73
88
|
|
|
74
89
|
/** One drag, one canvas pointer. Reused, because a drag is a press, a move and a release. */
|
|
@@ -129,17 +144,38 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
129
144
|
#anchor = new SelectionAnchor();
|
|
130
145
|
#drag: IDrag | undefined;
|
|
131
146
|
#box: number[] = [0, 0, 0, 0];
|
|
147
|
+
/** The pointer position the band's live count was taken at, so a still pointer rescans nothing. */
|
|
148
|
+
#boxAt = new Vector2(Number.NaN, Number.NaN);
|
|
132
149
|
#found: number[] = [];
|
|
133
150
|
#kinds = new Uint8Array(ORDER_KINDS.length);
|
|
134
151
|
#mode = "";
|
|
152
|
+
#edgeScroll = true;
|
|
153
|
+
/** Whether the current notice is a refusal; the toast draws one in the warning style. */
|
|
154
|
+
#noticeError = false;
|
|
135
155
|
#pointerSeen = false;
|
|
136
156
|
#accumulator = 0;
|
|
157
|
+
/** The engine tick the rules clock is fed in, and the camera position before the latest one. */
|
|
158
|
+
#tick = 0;
|
|
159
|
+
#eyeFrom = new Vector3();
|
|
160
|
+
#eye = new Vector3();
|
|
161
|
+
#drawnAt = -1;
|
|
162
|
+
#stopDraw: (() => void) | undefined;
|
|
137
163
|
#minimapDirty = true;
|
|
138
164
|
#publishedStep = -1;
|
|
139
165
|
#notice = "";
|
|
140
166
|
#fogText = "";
|
|
141
167
|
#dots: number[] = [];
|
|
168
|
+
#viewCorners: number[] = [];
|
|
142
169
|
#patch: Partial<GameState> = {};
|
|
170
|
+
/** Game speed the HUD's speed button cycles: 1×, 1.5×, 2×. */
|
|
171
|
+
#speed = 1;
|
|
172
|
+
/** Control groups 1-5, set and recalled from the HUD; `#groupCounts` is what it shows. */
|
|
173
|
+
#groups: number[][] = [[], [], [], [], []];
|
|
174
|
+
#groupCounts: number[] = [0, 0, 0, 0, 0];
|
|
175
|
+
/** Selection signature the roster was last built for, so a click while paused still updates it. */
|
|
176
|
+
#rosterSignature = -1;
|
|
177
|
+
#contacts = new Uint16Array(3);
|
|
178
|
+
#rivals: string[] = ["NO CONTACT", "NO CONTACT"];
|
|
143
179
|
|
|
144
180
|
override async load(ctx: GameCtx): Promise<void> {
|
|
145
181
|
this.#sky = await ctx.assets.texture("sky.jpg");
|
|
@@ -159,7 +195,8 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
159
195
|
// reproducible from the `seed` in src/game.ts.
|
|
160
196
|
const sim = new Game({ seed: Math.floor(ctx.random.range(1, 1_000_000)) });
|
|
161
197
|
this.#sim = sim;
|
|
162
|
-
|
|
198
|
+
// AstraCraft opens on (-66, 57): the same frame beside it (PRD-765 judge round 2).
|
|
199
|
+
const view = createRtsView(-66, 57);
|
|
163
200
|
this.#view = view;
|
|
164
201
|
|
|
165
202
|
setupSky(ctx.scene, this.#sky);
|
|
@@ -190,7 +227,13 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
190
227
|
});
|
|
191
228
|
this.#resources = createResources();
|
|
192
229
|
const world = new Object3D();
|
|
193
|
-
world.add(
|
|
230
|
+
world.add(
|
|
231
|
+
this.#terrain.root,
|
|
232
|
+
createEnvironment(sim).root,
|
|
233
|
+
this.#resources.root,
|
|
234
|
+
this.#army.root,
|
|
235
|
+
this.#anchor.object,
|
|
236
|
+
);
|
|
194
237
|
ctx.add(world);
|
|
195
238
|
ctx.entities.add("selection", this.#anchor);
|
|
196
239
|
applyRtsCamera(camera, view, ctx.viewport.size, STEP);
|
|
@@ -216,19 +259,26 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
216
259
|
);
|
|
217
260
|
}
|
|
218
261
|
|
|
262
|
+
// The army is drawn once per rendered frame, after the frame's last tick, between the rules'
|
|
263
|
+
// last two steps: the rules move units 20 times a second and the screen shows 60.
|
|
264
|
+
this.#eyeFrom.copy(camera.position);
|
|
265
|
+
this.#stopDraw = ctx.beforeRender(() => this.#draw(ctx, sim, camera));
|
|
266
|
+
|
|
219
267
|
return (frameCtx, dt) => {
|
|
220
268
|
loading.update();
|
|
269
|
+
this.#tick = dt;
|
|
270
|
+
this.#eyeFrom.copy(camera.position);
|
|
221
271
|
this.#readInput(frameCtx, dt);
|
|
222
|
-
this.#accumulator = Math.min(this.#accumulator + dt, MAX_CATCH_UP);
|
|
272
|
+
this.#accumulator = Math.min(this.#accumulator + dt * this.#speed, MAX_CATCH_UP);
|
|
223
273
|
while (this.#accumulator >= STEP) {
|
|
274
|
+
this.#army?.step(sim);
|
|
224
275
|
sim.update(STEP);
|
|
225
276
|
this.#accumulator -= STEP;
|
|
226
277
|
}
|
|
227
278
|
this.#drain(sim);
|
|
228
279
|
this.#prune(sim);
|
|
229
280
|
applyRtsCamera(camera, view, frameCtx.viewport.size, dt);
|
|
230
|
-
sun.follow(view.target.x, view.target.z);
|
|
231
|
-
this.#army?.sync(sim, this.#selected, sim.time, dt, camera);
|
|
281
|
+
sun.follow(view.target.x, view.target.z, camera);
|
|
232
282
|
if (this.#minimapDirty) {
|
|
233
283
|
this.#minimapDirty = false;
|
|
234
284
|
this.#terrain?.updateFog(sim);
|
|
@@ -239,7 +289,36 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
239
289
|
};
|
|
240
290
|
}
|
|
241
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Write the army for the frame about to be drawn. The engine draws the camera between its last two
|
|
294
|
+
* ticks (`ctx.alpha`), so the units are drawn at the same moment on the rules' clock, and the bars
|
|
295
|
+
* are snapped against the camera position the frame really uses. A paused game draws the latest
|
|
296
|
+
* state, as the engine does.
|
|
297
|
+
*/
|
|
298
|
+
#draw(ctx: GameCtx, sim: Game, camera: OrthographicCamera): void {
|
|
299
|
+
const now = ctx.frameTime;
|
|
300
|
+
const dt = this.#drawnAt < 0 ? 0 : Math.min(0.1, Math.max(0, (now - this.#drawnAt) / 1000));
|
|
301
|
+
this.#drawnAt = now;
|
|
302
|
+
const alpha = ctx.state.getState().paused ? 1 : ctx.alpha;
|
|
303
|
+
const ahead = this.#accumulator + alpha * this.#tick * this.#speed;
|
|
304
|
+
const blend = Math.min(1, ahead / STEP);
|
|
305
|
+
this.#eye.lerpVectors(this.#eyeFrom, camera.position, alpha);
|
|
306
|
+
this.#army?.sync(
|
|
307
|
+
sim,
|
|
308
|
+
this.#selected,
|
|
309
|
+
sim.time - STEP + blend * STEP,
|
|
310
|
+
dt,
|
|
311
|
+
camera,
|
|
312
|
+
lodPixelScale(camera, ctx.viewport.size.height, 1),
|
|
313
|
+
blend,
|
|
314
|
+
this.#eye,
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
242
318
|
override exit(ctx: GameCtx): void {
|
|
319
|
+
this.#stopDraw?.();
|
|
320
|
+
this.#stopDraw = undefined;
|
|
321
|
+
this.#drawnAt = -1;
|
|
243
322
|
this.#materialLighting?.dispose();
|
|
244
323
|
this.#materialLighting = undefined;
|
|
245
324
|
this.#post?.dispose();
|
|
@@ -277,7 +356,6 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
277
356
|
const sim = this.#sim;
|
|
278
357
|
const view = this.#view;
|
|
279
358
|
if (sim === undefined || view === undefined) return;
|
|
280
|
-
const camera = ctx.camera as OrthographicCamera;
|
|
281
359
|
const size = ctx.viewport.size;
|
|
282
360
|
const raw = ctx.input.raw;
|
|
283
361
|
const keys = raw.keys;
|
|
@@ -291,15 +369,22 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
291
369
|
const at = raw.pointer.position;
|
|
292
370
|
if (at.x !== 0 || at.y !== 0) this.#pointerSeen = true;
|
|
293
371
|
// Edge scroll: the cursor within `EDGE` pixels of the frame pans, but never while it is
|
|
294
|
-
// pressing something — a drag that reached the edge was a drag, not a scroll
|
|
295
|
-
|
|
372
|
+
// pressing something — a drag that reached the edge was a drag, not a scroll — and never once
|
|
373
|
+
// the top bar's toggle has turned it off, which is what the button is for.
|
|
374
|
+
if (
|
|
375
|
+
this.#edgeScroll &&
|
|
376
|
+
this.#pointerSeen &&
|
|
377
|
+
raw.pointer.buttons === 0 &&
|
|
378
|
+
this.#drag === undefined
|
|
379
|
+
) {
|
|
296
380
|
if (at.x < EDGE) panRts(view, -speed, 0);
|
|
297
381
|
else if (at.x > size.width - EDGE) panRts(view, speed, 0);
|
|
298
382
|
else if (at.y < EDGE) panRts(view, 0, -speed);
|
|
299
383
|
else if (at.y > size.height - EDGE) panRts(view, 0, speed);
|
|
300
384
|
}
|
|
385
|
+
// The axis is positive for a scroll up (negative DOM deltaY), which zooms in: a smaller view.
|
|
301
386
|
const zoom = ctx.input.axis("zoom");
|
|
302
|
-
if (zoom !== 0) zoomRts(view, zoom);
|
|
387
|
+
if (zoom !== 0) zoomRts(view, -zoom);
|
|
303
388
|
|
|
304
389
|
if (this.#drag !== undefined) {
|
|
305
390
|
const live = raw.pointers.get(this.#drag.id);
|
|
@@ -308,10 +393,12 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
308
393
|
for (const edges of raw.pointerEdges.values())
|
|
309
394
|
for (const edge of edges) {
|
|
310
395
|
if (edge.type !== "down") {
|
|
311
|
-
this.#release(ctx, edge
|
|
396
|
+
this.#release(ctx, edge, isShifted(keys));
|
|
312
397
|
} else if ((edge.buttons & 2) !== 0) {
|
|
313
398
|
this.#orderAt(ctx, edge.position, isShifted(keys));
|
|
314
|
-
} else {
|
|
399
|
+
} else if (this.#mode === "") {
|
|
400
|
+
// A press while a mode is armed is that order, not a band: the banner says CLICK, and a
|
|
401
|
+
// box drawn under an attack-move is a gesture that cannot do what it looks like.
|
|
315
402
|
this.#drag = { from: edge.position.clone(), id: edge.id, to: edge.position.clone() };
|
|
316
403
|
}
|
|
317
404
|
}
|
|
@@ -323,29 +410,39 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
323
410
|
if (ctx.input.justPressed("moveOrder")) this.#mode = "move";
|
|
324
411
|
if (ctx.input.justPressed("hold")) sim.command(this.#selection, "hold");
|
|
325
412
|
if (ctx.input.justPressed("stopOrder")) sim.command(this.#selection, "stop");
|
|
413
|
+
// The two the quick bar prints a key for, through the same door the buttons use.
|
|
414
|
+
if (ctx.input.justPressed("retreat")) this.#intent("retreat");
|
|
415
|
+
if (ctx.input.justPressed("idle")) this.#intent("idle");
|
|
326
416
|
}
|
|
327
417
|
|
|
328
|
-
|
|
329
|
-
|
|
418
|
+
/** A release: the armed order if there is one, otherwise the band the press opened. */
|
|
419
|
+
#release(ctx: GameCtx, edge: IRawInputPointerEdge, shift: boolean): void {
|
|
330
420
|
const sim = this.#sim;
|
|
331
421
|
const view = this.#view;
|
|
332
|
-
if (
|
|
422
|
+
if (sim === undefined || view === undefined) return;
|
|
423
|
+
if (this.#mode !== "") {
|
|
424
|
+
// A cancel is not a click: a mode survives the pointer leaving, as it does in AstraCraft.
|
|
425
|
+
if (edge.type === "up") this.#orderAt(ctx, edge.position, shift);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const drag = this.#drag;
|
|
429
|
+
if (drag === undefined || drag.id !== edge.id) return;
|
|
333
430
|
this.#drag = undefined;
|
|
334
431
|
const camera = ctx.camera as OrthographicCamera;
|
|
335
432
|
const size = ctx.viewport.size;
|
|
336
|
-
const
|
|
433
|
+
const at = edge.position;
|
|
337
434
|
if (Math.hypot(at.x - drag.from.x, at.y - drag.from.y) <= DRAG_SLOP) {
|
|
338
435
|
const hit = pickEntity(sim, camera, view, size, at.x, at.y);
|
|
339
436
|
if (hit === undefined) {
|
|
340
|
-
if (!
|
|
437
|
+
if (!shift) this.#selectIds([]);
|
|
341
438
|
return;
|
|
342
439
|
}
|
|
343
|
-
this.#toggleSelection(hit,
|
|
440
|
+
this.#toggleSelection(hit, shift);
|
|
344
441
|
return;
|
|
345
442
|
}
|
|
346
443
|
// Shift adds to what is selected; a fresh drag replaces it.
|
|
347
|
-
const keep =
|
|
348
|
-
unitsInBox(sim, camera, view, size, drag.from, drag.to, isAlt(keys), this.#found);
|
|
444
|
+
const keep = shift ? this.#selection.filter((id) => sim.get(id)?.team === 0) : [];
|
|
445
|
+
unitsInBox(sim, camera, view, size, drag.from, drag.to, isAlt(ctx.input.raw.keys), this.#found);
|
|
349
446
|
this.#selectIds(keep.concat(this.#found));
|
|
350
447
|
}
|
|
351
448
|
|
|
@@ -376,9 +473,11 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
376
473
|
const result = sim.build(type, ground.x, ground.z, 0);
|
|
377
474
|
if (!result.ok) {
|
|
378
475
|
this.#notice = result.message ?? "That site cannot be built there.";
|
|
476
|
+
this.#noticeError = true;
|
|
379
477
|
return;
|
|
380
478
|
}
|
|
381
479
|
this.#notice = `${TYPES[type].name} ordered. Its Surveyor must stay on site.`;
|
|
480
|
+
this.#noticeError = false;
|
|
382
481
|
this.#army?.marker(ground.x, ground.z, false);
|
|
383
482
|
this.#mode = "";
|
|
384
483
|
return;
|
|
@@ -386,14 +485,28 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
386
485
|
if (this.#selection.length === 0) return;
|
|
387
486
|
const ground = groundAt(camera, at.x, at.y, ctx.viewport.size);
|
|
388
487
|
if (ground === null) return;
|
|
389
|
-
|
|
488
|
+
this.#orderGround(ground, append, pickEntity(sim, camera, view, ctx.viewport.size, at.x, at.y));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* An order at a ground point, with whatever the cursor could have hit.
|
|
493
|
+
*
|
|
494
|
+
* The right-click on the battlefield and the right-click on the overview land here: the overview
|
|
495
|
+
* has no entity under the mouse (the panel is not the scene), so it passes no hit and the order
|
|
496
|
+
* is the same `#contextual` answer a click on bare ground gives.
|
|
497
|
+
*/
|
|
498
|
+
#orderGround(ground: IPoint, append: boolean, hit?: PickTarget): void {
|
|
499
|
+
const sim = this.#sim;
|
|
500
|
+
if (sim === undefined || this.#selection.length === 0) return;
|
|
390
501
|
const choice = this.#contextual(sim, ground, hit);
|
|
391
502
|
const result = sim.command(this.#selection, choice.kind, choice.target, 0, append);
|
|
392
503
|
if (!result.ok) {
|
|
393
504
|
this.#notice = REFUSALS[choice.kind] ?? "No selected unit can do that.";
|
|
505
|
+
this.#noticeError = true;
|
|
394
506
|
return;
|
|
395
507
|
}
|
|
396
508
|
this.#notice = "";
|
|
509
|
+
this.#noticeError = false;
|
|
397
510
|
this.#army?.marker(
|
|
398
511
|
ground.x,
|
|
399
512
|
ground.z,
|
|
@@ -419,7 +532,8 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
419
532
|
? { kind: "attack", target: { id: hit.id } }
|
|
420
533
|
: { kind: "attackMove", target: ground };
|
|
421
534
|
if (mode === "rally" || mode === "move") return move;
|
|
422
|
-
if (mode === "garrison" || mode === "repair"
|
|
535
|
+
if (mode === "garrison" || mode === "repair" || mode === "follow")
|
|
536
|
+
return { kind: mode, target: { id: hit?.id } };
|
|
423
537
|
if (hit !== undefined && hit.team > 0) return { kind: "attack", target: { id: hit.id } };
|
|
424
538
|
const has = (type: EntityType) => this.#selection.some((id) => sim.get(id)?.type === type);
|
|
425
539
|
if (hit !== undefined && hit.team === 0 && hit.type === "bunker" && has("ranger"))
|
|
@@ -452,9 +566,25 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
452
566
|
case "base":
|
|
453
567
|
this.#focusBase(sim);
|
|
454
568
|
break;
|
|
569
|
+
case "edge":
|
|
570
|
+
this.#edgeScroll = !this.#edgeScroll;
|
|
571
|
+
this.#notice = this.#edgeScroll ? "Edge scrolling enabled." : "Edge scrolling disabled.";
|
|
572
|
+
this.#noticeError = false;
|
|
573
|
+
break;
|
|
455
574
|
case "order":
|
|
456
575
|
this.#mode = value;
|
|
457
576
|
break;
|
|
577
|
+
case "focus": {
|
|
578
|
+
const point = readPoint(payload);
|
|
579
|
+
if (point !== undefined && this.#view !== undefined) focusRts(this.#view, point.x, point.z);
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
case "orderAt": {
|
|
583
|
+
// The overview's right-click: an order at a ground point, with nothing under the cursor.
|
|
584
|
+
const point = readPoint(payload);
|
|
585
|
+
if (point !== undefined) this.#orderGround(point, false);
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
458
588
|
case "place":
|
|
459
589
|
this.#mode = `build:${value}`;
|
|
460
590
|
break;
|
|
@@ -470,6 +600,7 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
470
600
|
this.#notice = result.ok
|
|
471
601
|
? `${TYPES[value as EntityType].name} queued.`
|
|
472
602
|
: (result.message ?? "That cannot be trained here.");
|
|
603
|
+
this.#noticeError = !result.ok;
|
|
473
604
|
break;
|
|
474
605
|
}
|
|
475
606
|
case "cancelTrain": {
|
|
@@ -489,6 +620,76 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
489
620
|
}
|
|
490
621
|
break;
|
|
491
622
|
}
|
|
623
|
+
case "hold":
|
|
624
|
+
case "stop":
|
|
625
|
+
sim.command(this.#selection, intent);
|
|
626
|
+
break;
|
|
627
|
+
case "idle": {
|
|
628
|
+
const idle = sim
|
|
629
|
+
.own()
|
|
630
|
+
.filter((entity) => entity.type === "worker" && entity.order.kind === "idle");
|
|
631
|
+
this.#selectIds(idle.map((entity) => entity.id));
|
|
632
|
+
const first = idle[0];
|
|
633
|
+
if (first !== undefined && this.#view !== undefined) focusRts(this.#view, first.x, first.z);
|
|
634
|
+
this.#notice =
|
|
635
|
+
idle.length > 0
|
|
636
|
+
? `${idle.length} idle Surveyors selected.`
|
|
637
|
+
: "All Surveyors are working.";
|
|
638
|
+
this.#noticeError = false;
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
case "unload": {
|
|
642
|
+
const bunker = this.#primary();
|
|
643
|
+
if (bunker === undefined || bunker.type !== "bunker") break;
|
|
644
|
+
const result = unloadGarrison(sim, bunker.id, 0);
|
|
645
|
+
this.#notice = result.ok
|
|
646
|
+
? `${result.count ?? 0} Vanguards deployed.`
|
|
647
|
+
: (result.message ?? "No infantry inside.");
|
|
648
|
+
this.#noticeError = !result.ok;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
case "builder": {
|
|
652
|
+
// The site's own Surveyor, selected and framed, so a stalled build has a clickable cause.
|
|
653
|
+
const site = this.#primary();
|
|
654
|
+
const builder = site?.builderId == null ? undefined : sim.get(site.builderId);
|
|
655
|
+
if (builder === undefined) {
|
|
656
|
+
this.#notice = "No Surveyor is assigned to this site.";
|
|
657
|
+
this.#noticeError = true;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
this.#selectIds([builder.id]);
|
|
661
|
+
if (this.#view !== undefined) focusRts(this.#view, builder.x, builder.z);
|
|
662
|
+
this.#notice = "";
|
|
663
|
+
this.#noticeError = false;
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
case "select":
|
|
667
|
+
this.#selectIds([Number(value)]);
|
|
668
|
+
break;
|
|
669
|
+
case "group": {
|
|
670
|
+
// "3" recalls group 3 (or sets it while it is empty), "set:3" always sets it.
|
|
671
|
+
const assign = value.startsWith("set:");
|
|
672
|
+
const index = Number(assign ? value.slice(4) : value) - 1;
|
|
673
|
+
const group = this.#groups[index];
|
|
674
|
+
if (group === undefined) break;
|
|
675
|
+
if (assign || group.length === 0)
|
|
676
|
+
this.#groups[index] = this.#selection.filter((id) => sim.get(id)?.team === 0);
|
|
677
|
+
else this.#selectIds(group.filter((id) => sim.get(id) !== undefined));
|
|
678
|
+
break;
|
|
679
|
+
}
|
|
680
|
+
case "speed":
|
|
681
|
+
this.#speed = this.#speed === 1 ? 1.5 : this.#speed === 1.5 ? 2 : 1;
|
|
682
|
+
break;
|
|
683
|
+
case "cancelBuild": {
|
|
684
|
+
const site = this.#primary();
|
|
685
|
+
if (site === undefined || site.team !== 0 || site.built) break;
|
|
686
|
+
const result = sim.cancelBuild(site.id);
|
|
687
|
+
this.#notice = result.ok
|
|
688
|
+
? "Construction cancelled. 75% refunded."
|
|
689
|
+
: (result.message ?? "That site cannot be cancelled.");
|
|
690
|
+
this.#noticeError = !result.ok;
|
|
691
|
+
break;
|
|
692
|
+
}
|
|
492
693
|
default:
|
|
493
694
|
break;
|
|
494
695
|
}
|
|
@@ -534,14 +735,23 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
534
735
|
#drain(sim: Game): void {
|
|
535
736
|
for (const event of sim.drainEvents()) {
|
|
536
737
|
const team = Number(event.team ?? -1);
|
|
537
|
-
if (event.type === "trained" && team === 0)
|
|
538
|
-
|
|
738
|
+
if (event.type === "trained" && team === 0) {
|
|
739
|
+
this.#notice = `${String(event.name)} ready.`;
|
|
740
|
+
this.#noticeError = false;
|
|
741
|
+
} else if (event.type === "complete" && team === 0) {
|
|
539
742
|
this.#notice = `${String(event.name)} online.`;
|
|
540
|
-
|
|
743
|
+
this.#noticeError = false;
|
|
744
|
+
} else if (event.type === "eliminated" && team > 0) {
|
|
541
745
|
this.#notice = `${String(event.name)} command network destroyed.`;
|
|
542
|
-
|
|
746
|
+
this.#noticeError = false;
|
|
747
|
+
} else if (event.type === "constructionLost" && team === 0) {
|
|
748
|
+
// A lost site is bad news; a refunded one is a bill, not a failure, as in the reference.
|
|
543
749
|
this.#notice = `${String(event.name)}: ${String(event.reason)}`;
|
|
544
|
-
|
|
750
|
+
this.#noticeError = Number(event.refund ?? 0) === 0;
|
|
751
|
+
} else if (event.type === "end") {
|
|
752
|
+
this.#notice = "";
|
|
753
|
+
this.#noticeError = false;
|
|
754
|
+
}
|
|
545
755
|
}
|
|
546
756
|
}
|
|
547
757
|
|
|
@@ -559,10 +769,18 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
559
769
|
let teams = 0;
|
|
560
770
|
let x = 0;
|
|
561
771
|
let z = 0;
|
|
772
|
+
let hp = 0;
|
|
773
|
+
let maxHp = 0;
|
|
774
|
+
let airborne = 0;
|
|
775
|
+
let signature = 0;
|
|
562
776
|
for (const id of this.#selection) {
|
|
563
777
|
const entity = sim.get(id);
|
|
564
778
|
if (entity === undefined || entity.garrisonId !== null) continue;
|
|
565
779
|
count += 1;
|
|
780
|
+
hp += Math.ceil(entity.hp);
|
|
781
|
+
maxHp += entity.maxHp;
|
|
782
|
+
if (entity.air) airborne += 1;
|
|
783
|
+
signature = (signature * 31 + id) | 0;
|
|
566
784
|
teams |= 1 << entity.team;
|
|
567
785
|
x += entity.x;
|
|
568
786
|
z += entity.z;
|
|
@@ -585,12 +803,15 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
585
803
|
patch.gathered = sim.gathered;
|
|
586
804
|
patch.gas = Math.floor(sim.resources.gas);
|
|
587
805
|
patch.kills = sim.kills;
|
|
806
|
+
patch.edgeScroll = this.#edgeScroll;
|
|
588
807
|
patch.mode = this.#mode;
|
|
589
808
|
patch.ore = Math.floor(sim.resources.ore);
|
|
590
809
|
patch.primaryBuilt = primary?.built ?? true;
|
|
591
|
-
|
|
810
|
+
// Whole points, rounded up: the readout never shows a fraction or a living unit at 0.
|
|
811
|
+
patch.primaryHp = Math.ceil(primary?.hp ?? 0);
|
|
592
812
|
patch.primaryMaxHp = primary?.maxHp ?? 0;
|
|
593
813
|
patch.primaryProgress = primary?.progress ?? 0;
|
|
814
|
+
patch.primaryGarrison = primary?.garrison.length ?? 0;
|
|
594
815
|
patch.primaryTeam = primary?.team ?? 0;
|
|
595
816
|
patch.primaryType = primary?.type ?? "";
|
|
596
817
|
patch.result = sim.result ?? "";
|
|
@@ -602,19 +823,53 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
602
823
|
patch.simTime = Math.floor(sim.time * 20);
|
|
603
824
|
patch.supplyCap = supply.cap;
|
|
604
825
|
patch.supplyUsed = supply.used;
|
|
826
|
+
patch.groupHp = hp;
|
|
827
|
+
patch.groupMaxHp = maxHp;
|
|
828
|
+
patch.airborne = airborne;
|
|
829
|
+
patch.speed = this.#speed;
|
|
830
|
+
for (let index = 0; index < 5; index += 1)
|
|
831
|
+
this.#groupCounts[index] = this.#groups[index]?.length ?? 0;
|
|
832
|
+
patch.groups = this.#groupCounts;
|
|
833
|
+
const stepped = this.#publishedStep !== Math.floor(sim.time * 20);
|
|
834
|
+
if (stepped || this.#rosterSignature !== signature) {
|
|
835
|
+
this.#rosterSignature = signature;
|
|
836
|
+
this.#roster(sim, patch);
|
|
837
|
+
}
|
|
605
838
|
if (this.#drag === undefined) {
|
|
606
839
|
patch.dragBox = null;
|
|
607
840
|
} else {
|
|
841
|
+
const rect = dragBoxRect(this.#drag.from, this.#drag.to);
|
|
608
842
|
// Mutated in place: the store holds the reference and the bridge clones at the boundary, so
|
|
609
843
|
// a rubber band does not allocate a fresh array on every frame it is being dragged.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
844
|
+
if (rect === null) {
|
|
845
|
+
patch.dragBox = null;
|
|
846
|
+
} else {
|
|
847
|
+
this.#box[0] = rect[0];
|
|
848
|
+
this.#box[1] = rect[1];
|
|
849
|
+
this.#box[2] = rect[2];
|
|
850
|
+
this.#box[3] = rect[3];
|
|
851
|
+
patch.dragBox = this.#box;
|
|
852
|
+
// What a release right now would take, from the scan that release runs: the badge cannot
|
|
853
|
+
// promise a number the selection does not deliver. Only while the pointer is moving.
|
|
854
|
+
const to = this.#drag.to;
|
|
855
|
+
if (this.#boxAt.x !== to.x || this.#boxAt.y !== to.y) {
|
|
856
|
+
this.#boxAt.copy(to);
|
|
857
|
+
patch.dragCount = unitsInBox(
|
|
858
|
+
sim,
|
|
859
|
+
ctx.camera as OrthographicCamera,
|
|
860
|
+
view,
|
|
861
|
+
ctx.viewport.size,
|
|
862
|
+
this.#drag.from,
|
|
863
|
+
to,
|
|
864
|
+
isAlt(ctx.input.raw.keys),
|
|
865
|
+
this.#found,
|
|
866
|
+
).length;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
615
869
|
}
|
|
616
|
-
if (
|
|
870
|
+
if (stepped) {
|
|
617
871
|
this.#publishedStep = Math.floor(sim.time * 20);
|
|
872
|
+
this.#commanders(sim, patch);
|
|
618
873
|
// The fog texture and the overview are rebuilt on the simulation's clock, not the frame's:
|
|
619
874
|
// a fog raster is 784 cells and a contact is a quad, and neither moves faster than the
|
|
620
875
|
// rules that move it.
|
|
@@ -622,13 +877,84 @@ export class Play extends Scene<GameState, undefined> {
|
|
|
622
877
|
patch.minimapDots = this.#dots;
|
|
623
878
|
patch.minimapFog = this.#fogText;
|
|
624
879
|
patch.notice = this.#notice;
|
|
880
|
+
patch.noticeError = this.#noticeError;
|
|
625
881
|
patch.queue = (primary?.queue ?? []).map(
|
|
626
882
|
(item) => `${item.type}:${item.progress.toFixed(2)}`,
|
|
627
883
|
);
|
|
628
884
|
}
|
|
885
|
+
// The view follows the camera every frame, paused or not, but is republished only when it moved.
|
|
886
|
+
if (this.#viewQuad(ctx.camera as OrthographicCamera, ctx.viewport.size))
|
|
887
|
+
patch.minimapView = this.#viewCorners;
|
|
629
888
|
ctx.state.set(patch);
|
|
630
889
|
}
|
|
631
890
|
|
|
891
|
+
/** The selection card's roster (`"<id>:<type>:<hp tenths>"`, first 16) and its distinct types. */
|
|
892
|
+
#roster(sim: Game, patch: Partial<GameState>): void {
|
|
893
|
+
const roster: string[] = [];
|
|
894
|
+
const types: string[] = [];
|
|
895
|
+
for (const id of this.#selection) {
|
|
896
|
+
const entity = sim.get(id);
|
|
897
|
+
if (entity === undefined || entity.garrisonId !== null) continue;
|
|
898
|
+
if (!types.includes(entity.type)) types.push(entity.type);
|
|
899
|
+
if (roster.length < 16)
|
|
900
|
+
roster.push(`${id}:${entity.type}:${Math.ceil((entity.hp / entity.maxHp) * 10)}`);
|
|
901
|
+
}
|
|
902
|
+
patch.roster = roster;
|
|
903
|
+
patch.selectionTypes = types;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/** The objective panel and the rival-commanders panel, on the simulation's clock. */
|
|
907
|
+
#commanders(sim: Game, patch: Partial<GameState>): void {
|
|
908
|
+
const contacts = this.#contacts;
|
|
909
|
+
contacts.fill(0);
|
|
910
|
+
let skyport = false;
|
|
911
|
+
let air = 0;
|
|
912
|
+
let idle = 0;
|
|
913
|
+
for (const entity of sim.entities) {
|
|
914
|
+
if (entity.hp <= 0 || entity.garrisonId !== null) continue;
|
|
915
|
+
if (entity.team > 0) {
|
|
916
|
+
if (sim.visibleAt(entity.x, entity.z))
|
|
917
|
+
contacts[entity.team] = (contacts[entity.team] ?? 0) + 1;
|
|
918
|
+
} else if (entity.type === "starport" && entity.built) skyport = true;
|
|
919
|
+
else if (entity.air) air += 1;
|
|
920
|
+
else if (entity.type === "worker" && entity.order.kind === "idle") idle += 1;
|
|
921
|
+
}
|
|
922
|
+
let defeated = 0;
|
|
923
|
+
for (let team = 1; team <= 2; team += 1) {
|
|
924
|
+
const seen = contacts[team] ?? 0;
|
|
925
|
+
const out = sim.players[team]?.eliminated === true;
|
|
926
|
+
if (out) defeated += 1;
|
|
927
|
+
this.#rivals[team - 1] = out ? "DEFEATED" : seen > 0 ? `${seen} CONTACTS` : "NO CONTACT";
|
|
928
|
+
}
|
|
929
|
+
patch.rivals = this.#rivals;
|
|
930
|
+
patch.defeated = defeated;
|
|
931
|
+
patch.skyport = skyport;
|
|
932
|
+
patch.airWing = air;
|
|
933
|
+
patch.idleWorkers = idle;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* The ground under the frame's four corners, in the minimap's units (tenths of a raster cell):
|
|
938
|
+
* an orthographic camera at a pitch sees a slanted quad of map, not a square. True when it moved.
|
|
939
|
+
*/
|
|
940
|
+
#viewQuad(camera: OrthographicCamera, size: { height: number; width: number }): boolean {
|
|
941
|
+
const scale = (MINIMAP / WORLD) * 10;
|
|
942
|
+
const view: number[] = [];
|
|
943
|
+
for (const [sx, sy] of [
|
|
944
|
+
[0, 0],
|
|
945
|
+
[size.width, 0],
|
|
946
|
+
[size.width, size.height],
|
|
947
|
+
[0, size.height],
|
|
948
|
+
] as const) {
|
|
949
|
+
const ground = groundAt(camera, sx, sy, size);
|
|
950
|
+
if (ground === null) return false;
|
|
951
|
+
view.push(Math.round((ground.x + HALF) * scale), Math.round((ground.z + HALF) * scale));
|
|
952
|
+
}
|
|
953
|
+
if (view.every((value, index) => value === this.#viewCorners[index])) return false;
|
|
954
|
+
this.#viewCorners = view;
|
|
955
|
+
return true;
|
|
956
|
+
}
|
|
957
|
+
|
|
632
958
|
/**
|
|
633
959
|
* The tactical overview: one character per cell of a coarse fog raster, then one quad per
|
|
634
960
|
* contact. Rebuilt on the simulation's clock rather than per frame — a map is a map, and the
|
|
@@ -679,6 +1005,15 @@ function nodeNear(sim: Game, x: number, z: number): IResourceNode | undefined {
|
|
|
679
1005
|
return undefined;
|
|
680
1006
|
}
|
|
681
1007
|
|
|
1008
|
+
/** A `{ x, z }` world point out of an intent payload, or nothing if it is not one. */
|
|
1009
|
+
function readPoint(payload: unknown): IPoint | undefined {
|
|
1010
|
+
if (typeof payload !== "object" || payload === null) return undefined;
|
|
1011
|
+
const { x, z } = payload as { x?: unknown; z?: unknown };
|
|
1012
|
+
return typeof x === "number" && Number.isFinite(x) && typeof z === "number" && Number.isFinite(z)
|
|
1013
|
+
? { x, z }
|
|
1014
|
+
: undefined;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
682
1017
|
function cellIndex(sim: Game, x: number, z: number): number {
|
|
683
1018
|
const ix = Math.floor((x + HALF) / sim.cell);
|
|
684
1019
|
const iz = Math.floor((z + HALF) / sim.cell);
|