create-threenative 0.2.10 → 0.2.13

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.
Files changed (737) hide show
  1. package/agent-docs/references/assertion-reference.md +109 -3
  2. package/agent-docs/references/auto-exposure.md +28 -45
  3. package/agent-docs/references/build-profiles.md +1 -1
  4. package/agent-docs/references/capability-reference.md +527 -44
  5. package/agent-docs/references/debug-surface.md +64 -0
  6. package/agent-docs/references/finding-assets.md +11 -12
  7. package/agent-docs/references/performance-basics.md +19 -0
  8. package/agent-docs/references/trace-a-slow-frame.md +21 -0
  9. package/agent-docs/references/visual-baseline.md +23 -4
  10. package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
  11. package/agent-files/.agents/skills/prd-creator/SKILL.md +17 -6
  12. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +87 -23
  13. package/agent-files/.agents/skills/threenative-performance/SKILL.md +12 -11
  14. package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
  15. package/agent-files/scripts/reference.mjs +9 -4
  16. package/capabilities.json +739 -50
  17. package/dist/index.d.ts +40 -6
  18. package/dist/index.js +227 -34
  19. package/dist/quality.d.ts +12 -0
  20. package/dist/quality.js +166747 -0
  21. package/dist/threenative.js +60 -44
  22. package/dist/web-engine-gltf-loader.js +2 -0
  23. package/dist/web-engine-mesh-bvh-webgpu.js +1 -1
  24. package/dist/web-engine-mesh-bvh.js +7 -0
  25. package/dist/web-engine-post-effects.js +645 -19
  26. package/dist/web-engine-runtime.js +3528 -343
  27. package/package.json +19 -9
  28. package/template-assets/assets/bay-PROVENANCE.md +21 -0
  29. package/template-assets/assets/bay-ground.webp +0 -0
  30. package/template-assets/assets/bay-metal.webp +0 -0
  31. package/template-assets/assets/bay-pavement-normal.webp +0 -0
  32. package/template-assets/assets/bay-pavement.webp +0 -0
  33. package/template-assets/assets/bay-plaster-normal.webp +0 -0
  34. package/template-assets/assets/bay-plaster.webp +0 -0
  35. package/template-assets/assets/bay-wood-normal.webp +0 -0
  36. package/template-assets/assets/bay-wood.webp +0 -0
  37. package/template-assets/assets/tex-PROVENANCE.md +25 -0
  38. package/template-assets/assets/tex-bark-normal.webp +0 -0
  39. package/template-assets/assets/tex-bark.webp +0 -0
  40. package/template-assets/assets/tex-birch-bark.webp +0 -0
  41. package/template-assets/assets/tex-grass.webp +0 -0
  42. package/template-assets/assets/tex-planks-normal.webp +0 -0
  43. package/template-assets/assets/tex-planks.webp +0 -0
  44. package/template-assets/assets/tex-rock-normal.webp +0 -0
  45. package/template-assets/assets/tex-rock.webp +0 -0
  46. package/template-assets/assets/tex-roof-tiles-normal.webp +0 -0
  47. package/template-assets/assets/tex-roof-tiles.webp +0 -0
  48. package/template-assets/assets/tex-sand-normal.webp +0 -0
  49. package/template-assets/assets/tex-sand.webp +0 -0
  50. package/template-assets/assets/tex-stone-wall-normal.webp +0 -0
  51. package/template-assets/assets/tex-stone-wall.webp +0 -0
  52. package/template-assets/kitExposure.ts +20 -0
  53. package/template-assets/patches/three@0.185.1.patch +481 -272
  54. package/template-assets/quality/biome.json +7 -0
  55. package/template-assets/quality/eslint.config.js +3 -0
  56. package/template-assets/realistic-ocean/README.md +113 -0
  57. package/template-assets/realistic-ocean/install.mjs +56 -0
  58. package/template-assets/realistic-ocean/src/realisticOcean.ts +151 -0
  59. package/template-assets/realistic-ocean/src/realisticOceanLifetime.ts +29 -0
  60. package/template-assets/realistic-ocean/src/render/REALISTIC-OCEAN-LICENSE.txt +25 -0
  61. package/template-assets/realistic-ocean/src/render/realisticSea.ts +642 -0
  62. package/template-assets/realistic-ocean/src/render/realisticSeaMaps.ts +311 -0
  63. package/template-assets/realistic-ocean/src/render/realisticSpectrum.ts +289 -0
  64. package/templates/AGENTS.md +21 -0
  65. package/templates/CLAUDE.md +23 -0
  66. package/templates/action-rpg/.codex/config.toml +6 -2
  67. package/templates/action-rpg/.cursor/mcp.json +8 -2
  68. package/templates/action-rpg/.gemini/settings.json +8 -2
  69. package/templates/action-rpg/.mcp.json +8 -2
  70. package/templates/action-rpg/.vscode/mcp.json +9 -2
  71. package/templates/action-rpg/.zed/settings.json +9 -2
  72. package/templates/action-rpg/AGENTS.md +11 -11
  73. package/templates/action-rpg/CLAUDE.md +11 -11
  74. package/templates/action-rpg/opencode.json +10 -2
  75. package/templates/action-rpg/package.json +15 -10
  76. package/templates/action-rpg/playtests/combat.playtest.json +6 -0
  77. package/templates/action-rpg/playtests/inventory.playtest.json +22 -0
  78. package/templates/action-rpg/playtests/performance.playtest.json +1 -1
  79. package/templates/action-rpg/playtests/roll.playtest.json +112 -0
  80. package/templates/action-rpg/playtests/swing.playtest.json +55 -0
  81. package/templates/action-rpg/playtests/win.playtest.json +4 -4
  82. package/templates/action-rpg/src/entities/Fighter.ts +44 -4
  83. package/templates/action-rpg/src/entities/Player.ts +64 -12
  84. package/templates/action-rpg/src/render/atmosphere.ts +444 -0
  85. package/templates/action-rpg/src/render/backlightMaterial.ts +49 -18
  86. package/templates/action-rpg/src/render/clouds.ts +605 -0
  87. package/templates/action-rpg/src/render/dungeon.ts +8 -6
  88. package/templates/action-rpg/src/render/exposure.ts +11 -109
  89. package/templates/action-rpg/src/render/gpuSky.ts +752 -0
  90. package/templates/action-rpg/src/render/lighting.ts +27 -4
  91. package/templates/action-rpg/src/render/materialLighting.ts +2 -11
  92. package/templates/action-rpg/src/render/palette.ts +1 -0
  93. package/templates/action-rpg/src/render/postprocessing.ts +4 -4
  94. package/templates/action-rpg/src/render/props.ts +10 -8
  95. package/templates/action-rpg/src/render/quality.ts +56 -108
  96. package/templates/action-rpg/src/render/sky.ts +74 -1
  97. package/templates/action-rpg/src/scenes/Play.ts +16 -12
  98. package/templates/action-rpg/src/ui/CharacterPanel.tsx +7 -2
  99. package/templates/action-rpg/src/ui/Hud.tsx +5 -7
  100. package/templates/action-rpg/src/ui/InventoryPanel.tsx +14 -14
  101. package/templates/action-rpg/threenative.config.ts +3 -0
  102. package/templates/adventure/.codex/config.toml +23 -0
  103. package/templates/adventure/.cursor/mcp.json +38 -0
  104. package/templates/adventure/.gemini/settings.json +38 -0
  105. package/templates/adventure/.mcp.json +38 -0
  106. package/templates/adventure/.vscode/mcp.json +43 -0
  107. package/templates/adventure/.zed/settings.json +43 -0
  108. package/templates/adventure/AGENTS.md +60 -0
  109. package/templates/adventure/CLAUDE.md +62 -0
  110. package/templates/adventure/index.html +14 -0
  111. package/templates/adventure/kit.json +8 -0
  112. package/templates/adventure/native-playtests/survives.playtest.json +52 -0
  113. package/templates/adventure/opencode.json +49 -0
  114. package/templates/adventure/package.json +65 -0
  115. package/templates/adventure/playtests/boss.playtest.json +406 -0
  116. package/templates/adventure/playtests/combat.playtest.json +342 -0
  117. package/templates/adventure/playtests/controls.playtest.json +142 -0
  118. package/templates/adventure/playtests/explore.playtest.json +45 -0
  119. package/templates/adventure/playtests/flicker.playtest.json +206 -0
  120. package/templates/adventure/playtests/hearts.playtest.json +171 -0
  121. package/templates/adventure/playtests/lockon.playtest.json +256 -0
  122. package/templates/adventure/playtests/look.playtest.json +72 -0
  123. package/templates/adventure/playtests/move-hollow.playtest.json +106 -0
  124. package/templates/adventure/playtests/move.playtest.json +84 -0
  125. package/templates/adventure/playtests/performance.playtest.json +55 -0
  126. package/templates/adventure/playtests/puzzle.playtest.json +250 -0
  127. package/templates/adventure/playtests/stride.playtest.json +67 -0
  128. package/templates/adventure/playtests/survives.playtest.json +171 -0
  129. package/templates/adventure/playtests/thornback.playtest.json +267 -0
  130. package/templates/adventure/public/favicon.svg +4 -0
  131. package/templates/adventure/src/entities/Block.ts +114 -0
  132. package/templates/adventure/src/entities/Chest.ts +69 -0
  133. package/templates/adventure/src/entities/Door.ts +81 -0
  134. package/templates/adventure/src/entities/Dummy.ts +69 -0
  135. package/templates/adventure/src/entities/Flicker.ts +239 -0
  136. package/templates/adventure/src/entities/Hero.ts +561 -0
  137. package/templates/adventure/src/entities/LockOn.ts +180 -0
  138. package/templates/adventure/src/entities/Mossling.ts +249 -0
  139. package/templates/adventure/src/entities/Switch.ts +49 -0
  140. package/templates/adventure/src/entities/Thornback.ts +238 -0
  141. package/templates/adventure/src/entities/Warden.ts +196 -0
  142. package/templates/adventure/src/game.ts +65 -0
  143. package/templates/adventure/src/interact.ts +63 -0
  144. package/templates/adventure/src/level/Hollow.ts +240 -0
  145. package/templates/adventure/src/level/Vale.ts +383 -0
  146. package/templates/adventure/src/main.ts +18 -0
  147. package/templates/adventure/src/render/camera.ts +416 -0
  148. package/templates/adventure/src/render/creatures.ts +405 -0
  149. package/templates/adventure/src/render/effects.ts +333 -0
  150. package/templates/adventure/src/render/foliage.ts +1072 -0
  151. package/templates/adventure/src/render/hero.ts +1447 -0
  152. package/templates/adventure/src/render/kitExposure.ts +20 -0
  153. package/templates/adventure/src/render/lighting.ts +74 -0
  154. package/templates/adventure/src/render/loading.ts +332 -0
  155. package/templates/adventure/src/render/materials.ts +179 -0
  156. package/templates/adventure/src/render/palette.ts +137 -0
  157. package/templates/adventure/src/render/postprocessing.ts +70 -0
  158. package/templates/adventure/src/render/props.ts +383 -0
  159. package/templates/adventure/src/render/quality.ts +46 -0
  160. package/templates/adventure/src/render/sky.ts +271 -0
  161. package/templates/adventure/src/render/surface.ts +259 -0
  162. package/templates/adventure/src/render/touch-controls.ts +137 -0
  163. package/templates/adventure/src/scenes/Play.ts +959 -0
  164. package/templates/adventure/src/state.ts +113 -0
  165. package/templates/adventure/src/style.css +98 -0
  166. package/templates/adventure/src/ui/App.tsx +22 -0
  167. package/templates/adventure/src/ui/GameUi.tsx +20 -0
  168. package/templates/adventure/src/ui/Hud.tsx +70 -0
  169. package/templates/adventure/src/ui/Menu.tsx +15 -0
  170. package/templates/adventure/src/ui/main.tsx +14 -0
  171. package/templates/adventure/tailwind.config.ts +2 -0
  172. package/templates/adventure/threenative.config.ts +62 -0
  173. package/templates/adventure/tsconfig.json +17 -0
  174. package/templates/adventure/vite.config.ts +49 -0
  175. package/templates/collectathon/.codex/config.toml +23 -0
  176. package/templates/collectathon/.cursor/mcp.json +38 -0
  177. package/templates/collectathon/.gemini/settings.json +38 -0
  178. package/templates/collectathon/.mcp.json +38 -0
  179. package/templates/collectathon/.vscode/mcp.json +43 -0
  180. package/templates/collectathon/.zed/settings.json +43 -0
  181. package/templates/collectathon/AGENTS.md +58 -0
  182. package/templates/collectathon/CLAUDE.md +60 -0
  183. package/templates/collectathon/index.html +14 -0
  184. package/templates/collectathon/kit.json +8 -0
  185. package/templates/collectathon/native-playtests/survives.playtest.json +52 -0
  186. package/templates/collectathon/opencode.json +49 -0
  187. package/templates/collectathon/package.json +65 -0
  188. package/templates/collectathon/playtests/acrobatics.playtest.json +238 -0
  189. package/templates/collectathon/playtests/camera.playtest.json +80 -0
  190. package/templates/collectathon/playtests/clipped-probe.playtest.json +101 -0
  191. package/templates/collectathon/playtests/collect.playtest.json +196 -0
  192. package/templates/collectathon/playtests/combat.playtest.json +246 -0
  193. package/templates/collectathon/playtests/double-tap-air.playtest.json +198 -0
  194. package/templates/collectathon/playtests/double-tap.playtest.json +136 -0
  195. package/templates/collectathon/playtests/effects.playtest.json +124 -0
  196. package/templates/collectathon/playtests/enemies.playtest.json +295 -0
  197. package/templates/collectathon/playtests/explore.playtest.json +45 -0
  198. package/templates/collectathon/playtests/hop-reach.playtest.json +117 -0
  199. package/templates/collectathon/playtests/jump-chain.playtest.json +274 -0
  200. package/templates/collectathon/playtests/ledge-angle.playtest.json +107 -0
  201. package/templates/collectathon/playtests/ledge-too-high.playtest.json +115 -0
  202. package/templates/collectathon/playtests/ledge.playtest.json +100 -0
  203. package/templates/collectathon/playtests/look.playtest.json +64 -0
  204. package/templates/collectathon/playtests/performance.playtest.json +55 -0
  205. package/templates/collectathon/playtests/stride.playtest.json +111 -0
  206. package/templates/collectathon/playtests/survives.playtest.json +123 -0
  207. package/templates/collectathon/playtests/telegraphs.playtest.json +132 -0
  208. package/templates/collectathon/playtests/thornback.playtest.json +157 -0
  209. package/templates/collectathon/playtests/wall-kick.playtest.json +206 -0
  210. package/templates/collectathon/playtests/win.playtest.json +166 -0
  211. package/templates/collectathon/public/favicon.svg +4 -0
  212. package/templates/collectathon/src/entities/Hero.ts +915 -0
  213. package/templates/collectathon/src/entities/Pickup.ts +63 -0
  214. package/templates/collectathon/src/entities/Walker.ts +248 -0
  215. package/templates/collectathon/src/game.ts +51 -0
  216. package/templates/collectathon/src/level/Course.ts +590 -0
  217. package/templates/collectathon/src/level/terrain.ts +144 -0
  218. package/templates/collectathon/src/main.ts +14 -0
  219. package/templates/collectathon/src/playtest-events.ts +15 -0
  220. package/templates/collectathon/src/render/camera.ts +163 -0
  221. package/templates/collectathon/src/render/castle.ts +408 -0
  222. package/templates/collectathon/src/render/effects.ts +284 -0
  223. package/templates/collectathon/src/render/foliage.ts +744 -0
  224. package/templates/collectathon/src/render/ground.ts +139 -0
  225. package/templates/collectathon/src/render/hero.ts +452 -0
  226. package/templates/collectathon/src/render/kitExposure.ts +20 -0
  227. package/templates/collectathon/src/render/lighting.ts +65 -0
  228. package/templates/collectathon/src/render/loading.ts +332 -0
  229. package/templates/collectathon/src/render/materials.ts +196 -0
  230. package/templates/collectathon/src/render/palette.ts +82 -0
  231. package/templates/collectathon/src/render/postprocessing.ts +79 -0
  232. package/templates/collectathon/src/render/props.ts +218 -0
  233. package/templates/collectathon/src/render/quality.ts +54 -0
  234. package/templates/collectathon/src/render/sky.ts +262 -0
  235. package/templates/collectathon/src/render/surface.ts +269 -0
  236. package/templates/collectathon/src/render/touch-controls.ts +179 -0
  237. package/templates/collectathon/src/render/touch-layout.ts +48 -0
  238. package/templates/collectathon/src/render/water.ts +191 -0
  239. package/templates/collectathon/src/scenes/Play.ts +481 -0
  240. package/templates/collectathon/src/state.ts +38 -0
  241. package/templates/collectathon/src/style.css +106 -0
  242. package/templates/collectathon/src/ui/App.tsx +22 -0
  243. package/templates/collectathon/src/ui/GameUi.tsx +20 -0
  244. package/templates/collectathon/src/ui/Hud.tsx +77 -0
  245. package/templates/collectathon/src/ui/Menu.tsx +13 -0
  246. package/templates/collectathon/src/ui/main.tsx +14 -0
  247. package/templates/collectathon/tailwind.config.ts +2 -0
  248. package/templates/collectathon/threenative.config.ts +62 -0
  249. package/templates/collectathon/tsconfig.json +17 -0
  250. package/templates/collectathon/vite.config.ts +49 -0
  251. package/templates/kart/.codex/config.toml +23 -0
  252. package/templates/kart/.cursor/mcp.json +38 -0
  253. package/templates/kart/.gemini/settings.json +38 -0
  254. package/templates/kart/.mcp.json +38 -0
  255. package/templates/kart/.vscode/mcp.json +43 -0
  256. package/templates/kart/.zed/settings.json +43 -0
  257. package/templates/kart/AGENTS.md +58 -0
  258. package/templates/kart/CLAUDE.md +60 -0
  259. package/templates/kart/index.html +14 -0
  260. package/templates/kart/kit.json +8 -0
  261. package/templates/kart/native-playtests/survives.playtest.json +65 -0
  262. package/templates/kart/opencode.json +49 -0
  263. package/templates/kart/package.json +64 -0
  264. package/templates/kart/playtests/drift.playtest.json +226 -0
  265. package/templates/kart/playtests/explore.playtest.json +45 -0
  266. package/templates/kart/playtests/hit-stays-above-road.playtest.json +92 -0
  267. package/templates/kart/playtests/item-key.playtest.json +108 -0
  268. package/templates/kart/playtests/items.playtest.json +143 -0
  269. package/templates/kart/playtests/lap-times.playtest.json +138 -0
  270. package/templates/kart/playtests/laps.playtest.json +149 -0
  271. package/templates/kart/playtests/performance.playtest.json +57 -0
  272. package/templates/kart/playtests/race.playtest.json +294 -0
  273. package/templates/kart/playtests/restart.playtest.json +87 -0
  274. package/templates/kart/playtests/rocket-start.playtest.json +56 -0
  275. package/templates/kart/playtests/smooth-drive.playtest.json +101 -0
  276. package/templates/kart/playtests/surfaces.playtest.json +113 -0
  277. package/templates/kart/playtests/survives.playtest.json +116 -0
  278. package/templates/kart/playtests/wall.playtest.json +118 -0
  279. package/templates/kart/public/favicon.svg +4 -0
  280. package/templates/kart/src/entities/Driver.ts +123 -0
  281. package/templates/kart/src/entities/Items.ts +194 -0
  282. package/templates/kart/src/entities/Kart.ts +517 -0
  283. package/templates/kart/src/game.ts +45 -0
  284. package/templates/kart/src/main.ts +14 -0
  285. package/templates/kart/src/playtest-events.ts +15 -0
  286. package/templates/kart/src/render/camera.ts +83 -0
  287. package/templates/kart/src/render/course.ts +579 -0
  288. package/templates/kart/src/render/effects.ts +266 -0
  289. package/templates/kart/src/render/items.ts +163 -0
  290. package/templates/kart/src/render/kart.ts +256 -0
  291. package/templates/kart/src/render/kitExposure.ts +20 -0
  292. package/templates/kart/src/render/lighting.ts +58 -0
  293. package/templates/kart/src/render/loading.ts +332 -0
  294. package/templates/kart/src/render/materials.ts +119 -0
  295. package/templates/kart/src/render/palette.ts +74 -0
  296. package/templates/kart/src/render/postprocessing.ts +79 -0
  297. package/templates/kart/src/render/quality.ts +54 -0
  298. package/templates/kart/src/render/skids.ts +86 -0
  299. package/templates/kart/src/render/sky.ts +105 -0
  300. package/templates/kart/src/render/touch-controls.ts +168 -0
  301. package/templates/kart/src/render/touch-layout.ts +48 -0
  302. package/templates/kart/src/scenes/Race.ts +850 -0
  303. package/templates/kart/src/state.ts +53 -0
  304. package/templates/kart/src/style.css +106 -0
  305. package/templates/kart/src/track/Course.ts +276 -0
  306. package/templates/kart/src/track/Race.ts +133 -0
  307. package/templates/kart/src/ui/App.tsx +21 -0
  308. package/templates/kart/src/ui/GameUi.tsx +20 -0
  309. package/templates/kart/src/ui/Hud.tsx +172 -0
  310. package/templates/kart/src/ui/Menu.tsx +13 -0
  311. package/templates/kart/src/ui/main.tsx +14 -0
  312. package/templates/kart/tailwind.config.ts +2 -0
  313. package/templates/kart/threenative.config.ts +62 -0
  314. package/templates/kart/tsconfig.json +17 -0
  315. package/templates/kart/vite.config.ts +49 -0
  316. package/templates/minimal/.codex/config.toml +6 -2
  317. package/templates/minimal/.cursor/mcp.json +8 -2
  318. package/templates/minimal/.gemini/settings.json +8 -2
  319. package/templates/minimal/.mcp.json +8 -2
  320. package/templates/minimal/.vscode/mcp.json +9 -2
  321. package/templates/minimal/.zed/settings.json +9 -2
  322. package/templates/minimal/AGENTS.md +11 -13
  323. package/templates/minimal/CLAUDE.md +11 -13
  324. package/templates/minimal/opencode.json +10 -2
  325. package/templates/minimal/package.json +14 -9
  326. package/templates/minimal/playtests/camera-wall.playtest.json +36 -0
  327. package/templates/minimal/playtests/jump.playtest.json +45 -0
  328. package/templates/minimal/playtests/play.playtest.json +1 -1
  329. package/templates/minimal/src/game.ts +2 -0
  330. package/templates/minimal/src/render/atmosphere.ts +444 -0
  331. package/templates/minimal/src/render/backlightMaterial.ts +49 -18
  332. package/templates/minimal/src/render/camera.ts +35 -4
  333. package/templates/minimal/src/render/clouds.ts +605 -0
  334. package/templates/minimal/src/render/exposure.ts +7 -111
  335. package/templates/minimal/src/render/gpuSky.ts +752 -0
  336. package/templates/minimal/src/render/lighting.ts +26 -4
  337. package/templates/minimal/src/render/materialLighting.ts +2 -10
  338. package/templates/minimal/src/render/postprocessing.ts +4 -4
  339. package/templates/minimal/src/render/quality.ts +10 -116
  340. package/templates/minimal/src/render/sky.ts +73 -1
  341. package/templates/minimal/src/scenes/Play.ts +18 -7
  342. package/templates/platformer/.codex/config.toml +6 -2
  343. package/templates/platformer/.cursor/mcp.json +8 -2
  344. package/templates/platformer/.gemini/settings.json +8 -2
  345. package/templates/platformer/.mcp.json +8 -2
  346. package/templates/platformer/.vscode/mcp.json +9 -2
  347. package/templates/platformer/.zed/settings.json +9 -2
  348. package/templates/platformer/AGENTS.md +13 -9
  349. package/templates/platformer/CLAUDE.md +13 -9
  350. package/templates/platformer/opencode.json +10 -2
  351. package/templates/platformer/package.json +15 -10
  352. package/templates/platformer/playtests/dash-jump.playtest.json +34 -0
  353. package/templates/platformer/playtests/finish.playtest.json +58 -0
  354. package/templates/platformer/playtests/idle.playtest.json +44 -0
  355. package/templates/platformer/playtests/performance.playtest.json +1 -1
  356. package/templates/platformer/src/entities/Fox.ts +19 -6
  357. package/templates/platformer/src/game.ts +1 -0
  358. package/templates/platformer/src/level/Stage.ts +4 -1
  359. package/templates/platformer/src/render/backlightMaterial.ts +49 -18
  360. package/templates/platformer/src/render/camera.ts +30 -1
  361. package/templates/platformer/src/render/exposure.ts +6 -111
  362. package/templates/platformer/src/render/fox.ts +5 -2
  363. package/templates/platformer/src/render/kitExposure.ts +20 -0
  364. package/templates/platformer/src/render/materialLighting.ts +2 -11
  365. package/templates/platformer/src/render/postprocessing.ts +4 -4
  366. package/templates/platformer/src/render/props.ts +1 -2
  367. package/templates/platformer/src/render/quality.ts +10 -118
  368. package/templates/platformer/src/scenes/Play.ts +31 -15
  369. package/templates/platformer/src/ui/Menu.tsx +1 -1
  370. package/templates/puzzle/.codex/config.toml +6 -2
  371. package/templates/puzzle/.cursor/mcp.json +8 -2
  372. package/templates/puzzle/.gemini/settings.json +8 -2
  373. package/templates/puzzle/.mcp.json +8 -2
  374. package/templates/puzzle/.vscode/mcp.json +9 -2
  375. package/templates/puzzle/.zed/settings.json +9 -2
  376. package/templates/puzzle/AGENTS.md +14 -17
  377. package/templates/puzzle/CLAUDE.md +14 -17
  378. package/templates/puzzle/opencode.json +10 -2
  379. package/templates/puzzle/package.json +15 -10
  380. package/templates/puzzle/playtests/performance.playtest.json +1 -1
  381. package/templates/puzzle/playtests/replay-keeps-progress.playtest.json +78 -0
  382. package/templates/puzzle/src/render/backlightMaterial.ts +49 -18
  383. package/templates/puzzle/src/render/exposure.ts +11 -109
  384. package/templates/puzzle/src/render/lighting.ts +3 -3
  385. package/templates/puzzle/src/render/materialLighting.ts +2 -11
  386. package/templates/puzzle/src/render/palette.ts +1 -1
  387. package/templates/puzzle/src/render/postprocessing.ts +4 -4
  388. package/templates/puzzle/src/render/quality.ts +44 -153
  389. package/templates/puzzle/src/render/vault.ts +18 -6
  390. package/templates/puzzle/src/scenes/Play.ts +6 -1
  391. package/templates/puzzle/src/ui/Hud.tsx +8 -43
  392. package/templates/racing/.codex/config.toml +6 -2
  393. package/templates/racing/.cursor/mcp.json +8 -2
  394. package/templates/racing/.gemini/settings.json +8 -2
  395. package/templates/racing/.mcp.json +8 -2
  396. package/templates/racing/.vscode/mcp.json +9 -2
  397. package/templates/racing/.zed/settings.json +9 -2
  398. package/templates/racing/AGENTS.md +10 -12
  399. package/templates/racing/CLAUDE.md +10 -12
  400. package/templates/racing/opencode.json +10 -2
  401. package/templates/racing/package.json +15 -10
  402. package/templates/racing/playtests/brake.playtest.json +54 -0
  403. package/templates/racing/playtests/outcome.playtest.json +19 -0
  404. package/templates/racing/playtests/performance.playtest.json +1 -1
  405. package/templates/racing/playtests/stopped-car-is-not-rescued.playtest.json +59 -0
  406. package/templates/racing/src/entities/RacingCar.ts +12 -3
  407. package/templates/racing/src/entities/Rival.ts +11 -2
  408. package/templates/racing/src/render/atmosphere.ts +444 -0
  409. package/templates/racing/src/render/backlightMaterial.ts +49 -18
  410. package/templates/racing/src/render/clouds.ts +605 -0
  411. package/templates/racing/src/render/exposure.ts +6 -111
  412. package/templates/racing/src/render/gpuSky.ts +752 -0
  413. package/templates/racing/src/render/kitExposure.ts +20 -0
  414. package/templates/racing/src/render/lighting.ts +26 -4
  415. package/templates/racing/src/render/materialLighting.ts +2 -11
  416. package/templates/racing/src/render/materials.ts +2 -1
  417. package/templates/racing/src/render/postprocessing.ts +4 -4
  418. package/templates/racing/src/render/quality.ts +27 -115
  419. package/templates/racing/src/render/sky.ts +72 -1
  420. package/templates/racing/src/scenes/Race.ts +9 -7
  421. package/templates/racing/src/track/TrackSector.ts +5 -2
  422. package/templates/racing/src/ui/Hud.tsx +12 -7
  423. package/templates/rain/.codex/config.toml +6 -2
  424. package/templates/rain/.cursor/mcp.json +8 -2
  425. package/templates/rain/.gemini/settings.json +8 -2
  426. package/templates/rain/.mcp.json +8 -2
  427. package/templates/rain/.vscode/mcp.json +9 -2
  428. package/templates/rain/.zed/settings.json +9 -2
  429. package/templates/rain/AGENTS.md +12 -12
  430. package/templates/rain/CLAUDE.md +12 -12
  431. package/templates/rain/opencode.json +10 -2
  432. package/templates/rain/package.json +14 -9
  433. package/templates/rain/playtests/performance.playtest.json +1 -1
  434. package/templates/rain/src/game.ts +1 -1
  435. package/templates/rain/src/render/bloom-shader.ts +1 -1
  436. package/templates/rain/src/render/clouds-shader.ts +2 -2
  437. package/templates/rain/src/render/clouds.ts +2 -1
  438. package/templates/rain/src/render/exposure.ts +11 -109
  439. package/templates/rain/src/render/post-shader.ts +7 -11
  440. package/templates/rain/src/render/postprocessing.ts +8 -24
  441. package/templates/rain/src/render/quality.ts +44 -98
  442. package/templates/rain/src/render/world-shader.ts +281 -97
  443. package/templates/rain/src/render/world.ts +82 -2
  444. package/templates/rain/src/style.css +1 -1
  445. package/templates/rain/src/ui/GameUi.tsx +6 -2
  446. package/templates/rain/src/ui/Hud.tsx +1 -1
  447. package/templates/rain/tools/generate-shaders.mjs +2 -2
  448. package/templates/rain/tools/tempest-post.frag +4 -6
  449. package/templates/rain/tools/tempest-world.frag +80 -12
  450. package/templates/rts/.codex/config.toml +6 -2
  451. package/templates/rts/.cursor/mcp.json +8 -2
  452. package/templates/rts/.gemini/settings.json +8 -2
  453. package/templates/rts/.mcp.json +8 -2
  454. package/templates/rts/.vscode/mcp.json +9 -2
  455. package/templates/rts/.zed/settings.json +9 -2
  456. package/templates/rts/AGENTS.md +15 -16
  457. package/templates/rts/CLAUDE.md +15 -16
  458. package/templates/rts/opencode.json +10 -2
  459. package/templates/rts/package.json +14 -9
  460. package/templates/rts/playtests/performance.playtest.json +1 -1
  461. package/templates/rts/playtests/rts-attack.playtest.json +5 -0
  462. package/templates/rts/playtests/rts-build.playtest.json +20 -1
  463. package/templates/rts/playtests/rts-orders.playtest.json +1 -1
  464. package/templates/rts/playtests/rts-pause.playtest.json +112 -0
  465. package/templates/rts/playtests/rts-train.playtest.json +1 -1
  466. package/templates/rts/playtests/rts-zoom.playtest.json +81 -0
  467. package/templates/rts/src/game.ts +29 -7
  468. package/templates/rts/src/render/army.ts +181 -49
  469. package/templates/rts/src/render/backlightMaterial.ts +49 -18
  470. package/templates/rts/src/render/environment.ts +276 -0
  471. package/templates/rts/src/render/exposure.ts +3 -65
  472. package/templates/rts/src/render/ground.ts +478 -0
  473. package/templates/rts/src/render/lighting.ts +62 -11
  474. package/templates/rts/src/render/materialLighting.ts +2 -11
  475. package/templates/rts/src/render/materials.ts +47 -118
  476. package/templates/rts/src/render/palette.ts +30 -13
  477. package/templates/rts/src/render/picking.ts +18 -0
  478. package/templates/rts/src/render/postprocessing.ts +4 -4
  479. package/templates/rts/src/render/quality.ts +64 -85
  480. package/templates/rts/src/render/resources.ts +21 -22
  481. package/templates/rts/src/render/sky.ts +9 -12
  482. package/templates/rts/src/render/terrain.ts +36 -11
  483. package/templates/rts/src/scenes/Play.ts +373 -38
  484. package/templates/rts/src/sim/ai.ts +0 -11
  485. package/templates/rts/src/state.ts +46 -0
  486. package/templates/rts/src/style.css +1543 -0
  487. package/templates/rts/src/ui/Commands.tsx +204 -107
  488. package/templates/rts/src/ui/GameUi.tsx +12 -5
  489. package/templates/rts/src/ui/Hud.tsx +611 -116
  490. package/templates/rts/src/ui/Minimap.tsx +103 -37
  491. package/templates/rts/src/ui/icons.tsx +116 -0
  492. package/templates/rts/src/ui/labels.ts +73 -0
  493. package/templates/rts/src/ui/minimapPoint.ts +30 -0
  494. package/templates/rts/threenative.config.ts +1 -1
  495. package/templates/runner/.codex/config.toml +6 -2
  496. package/templates/runner/.cursor/mcp.json +8 -2
  497. package/templates/runner/.gemini/settings.json +8 -2
  498. package/templates/runner/.mcp.json +8 -2
  499. package/templates/runner/.vscode/mcp.json +9 -2
  500. package/templates/runner/.zed/settings.json +9 -2
  501. package/templates/runner/AGENTS.md +12 -12
  502. package/templates/runner/CLAUDE.md +12 -12
  503. package/templates/runner/opencode.json +10 -2
  504. package/templates/runner/package.json +15 -10
  505. package/templates/runner/playtests/near-miss.playtest.json +48 -0
  506. package/templates/runner/playtests/performance.playtest.json +2 -2
  507. package/templates/runner/playtests/stride.playtest.json +27 -0
  508. package/templates/runner/playtests/survives.playtest.json +2 -2
  509. package/templates/runner/src/conventions.ts +3 -1
  510. package/templates/runner/src/entities/Runner.ts +11 -5
  511. package/templates/runner/src/render/atmosphere.ts +444 -0
  512. package/templates/runner/src/render/backlightMaterial.ts +49 -18
  513. package/templates/runner/src/render/clouds.ts +605 -0
  514. package/templates/runner/src/render/exposure.ts +6 -111
  515. package/templates/runner/src/render/gpuSky.ts +752 -0
  516. package/templates/runner/src/render/kitExposure.ts +20 -0
  517. package/templates/runner/src/render/lighting.ts +26 -4
  518. package/templates/runner/src/render/materialLighting.ts +2 -11
  519. package/templates/runner/src/render/postprocessing.ts +4 -4
  520. package/templates/runner/src/render/quality.ts +26 -114
  521. package/templates/runner/src/render/sky.ts +73 -1
  522. package/templates/runner/src/scenes/Run.ts +19 -15
  523. package/templates/runner/src/track.ts +12 -3
  524. package/templates/sailing/.codex/config.toml +6 -2
  525. package/templates/sailing/.cursor/mcp.json +8 -2
  526. package/templates/sailing/.gemini/settings.json +8 -2
  527. package/templates/sailing/.mcp.json +8 -2
  528. package/templates/sailing/.vscode/mcp.json +9 -2
  529. package/templates/sailing/.zed/settings.json +9 -2
  530. package/templates/sailing/AGENTS.md +10 -11
  531. package/templates/sailing/CLAUDE.md +10 -11
  532. package/templates/sailing/opencode.json +10 -2
  533. package/templates/sailing/package.json +15 -10
  534. package/templates/sailing/playtests/fail.playtest.json +46 -5
  535. package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +7 -0
  536. package/templates/sailing/playtests/performance.playtest.json +1 -1
  537. package/templates/sailing/src/game.ts +1 -0
  538. package/templates/sailing/src/render/backlightMaterial.ts +49 -18
  539. package/templates/sailing/src/render/exposure.ts +6 -111
  540. package/templates/sailing/src/render/kitExposure.ts +20 -0
  541. package/templates/sailing/src/render/materialLighting.ts +2 -11
  542. package/templates/sailing/src/render/ocean.ts +0 -1
  543. package/templates/sailing/src/render/postprocessing.ts +4 -4
  544. package/templates/sailing/src/render/quality.ts +31 -138
  545. package/templates/sailing/src/scenes/Sailing.ts +12 -4
  546. package/templates/sailing/src/ui/Hud.tsx +6 -2
  547. package/templates/sailing/src/ui/Menu.tsx +1 -1
  548. package/templates/shooter/.codex/config.toml +6 -2
  549. package/templates/shooter/.cursor/mcp.json +8 -2
  550. package/templates/shooter/.gemini/settings.json +8 -2
  551. package/templates/shooter/.mcp.json +8 -2
  552. package/templates/shooter/.vscode/mcp.json +9 -2
  553. package/templates/shooter/.zed/settings.json +9 -2
  554. package/templates/shooter/AGENTS.md +13 -12
  555. package/templates/shooter/CLAUDE.md +13 -12
  556. package/templates/shooter/index.html +1 -1
  557. package/templates/shooter/main.html +13 -0
  558. package/templates/shooter/opencode.json +10 -2
  559. package/templates/shooter/package.json +15 -10
  560. package/templates/shooter/playtests/breakable-shatters.playtest.json +6 -0
  561. package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +6 -0
  562. package/templates/shooter/playtests/hands-authored-rate.playtest.json +54 -0
  563. package/templates/shooter/playtests/movement-eases.playtest.json +53 -0
  564. package/templates/shooter/playtests/performance.playtest.json +3 -3
  565. package/templates/shooter/playtests/stairs-smooth-the-eye.playtest.json +56 -0
  566. package/templates/shooter/playtests/weapon-sharp-while-turning.playtest.json +206 -0
  567. package/templates/shooter/src/entities/Breakables.ts +34 -10
  568. package/templates/shooter/src/entities/Enemy.ts +176 -54
  569. package/templates/shooter/src/entities/FpsPlayer.ts +55 -16
  570. package/templates/shooter/src/entities/Rifle.ts +83 -9
  571. package/templates/shooter/src/entities/movement.ts +96 -0
  572. package/templates/shooter/src/render/atmosphere.ts +444 -0
  573. package/templates/shooter/src/render/backlightMaterial.ts +49 -18
  574. package/templates/shooter/src/render/camera.ts +3 -1
  575. package/templates/shooter/src/render/clouds.ts +605 -0
  576. package/templates/shooter/src/render/exposure.ts +10 -109
  577. package/templates/shooter/src/render/facade.ts +26 -68
  578. package/templates/shooter/src/render/gpuSky.ts +752 -0
  579. package/templates/shooter/src/render/lighting.ts +27 -4
  580. package/templates/shooter/src/render/materialAssignments.ts +9 -1
  581. package/templates/shooter/src/render/materialLighting.ts +2 -11
  582. package/templates/shooter/src/render/occlusion.ts +13 -4
  583. package/templates/shooter/src/render/palette.ts +1 -0
  584. package/templates/shooter/src/render/postprocessing.ts +4 -4
  585. package/templates/shooter/src/render/quality.ts +50 -108
  586. package/templates/shooter/src/render/scale.ts +0 -11
  587. package/templates/shooter/src/render/sky.ts +103 -2
  588. package/templates/shooter/src/render/surface.ts +140 -0
  589. package/templates/shooter/src/render/town.ts +3 -6
  590. package/templates/shooter/src/render/townMaterials.ts +95 -42
  591. package/templates/shooter/src/render/vehicles.ts +2 -0
  592. package/templates/shooter/src/scenes/Play.ts +83 -23
  593. package/templates/shooter/src/ui/Hud.tsx +268 -193
  594. package/templates/shooter/src/worker-page.ts +29 -0
  595. package/templates/shooter/src/worker.ts +5 -0
  596. package/templates/shooter/threenative.config.ts +3 -0
  597. package/templates/shooter/vite.config.ts +2 -0
  598. package/templates/snow/.codex/config.toml +6 -2
  599. package/templates/snow/.cursor/mcp.json +8 -2
  600. package/templates/snow/.gemini/settings.json +8 -2
  601. package/templates/snow/.mcp.json +8 -2
  602. package/templates/snow/.vscode/mcp.json +9 -2
  603. package/templates/snow/.zed/settings.json +9 -2
  604. package/templates/snow/AGENTS.md +12 -10
  605. package/templates/snow/CLAUDE.md +12 -10
  606. package/templates/snow/opencode.json +10 -2
  607. package/templates/snow/package.json +15 -10
  608. package/templates/snow/playtests/performance.playtest.json +1 -1
  609. package/templates/snow/src/render/backlightMaterial.ts +49 -18
  610. package/templates/snow/src/render/exposure.ts +17 -106
  611. package/templates/snow/src/render/materialLighting.ts +2 -11
  612. package/templates/snow/src/render/postprocessing.ts +11 -5
  613. package/templates/snow/src/render/quality.ts +46 -126
  614. package/templates/snow/src/render/snowSurface.ts +32 -15
  615. package/templates/snow/src/scenes/Snow.ts +2 -1
  616. package/templates/starter/.codex/config.toml +6 -2
  617. package/templates/starter/.cursor/mcp.json +8 -2
  618. package/templates/starter/.gemini/settings.json +8 -2
  619. package/templates/starter/.mcp.json +8 -2
  620. package/templates/starter/.vscode/mcp.json +9 -2
  621. package/templates/starter/.zed/settings.json +9 -2
  622. package/templates/starter/AGENTS.md +18 -14
  623. package/templates/starter/CLAUDE.md +18 -14
  624. package/templates/starter/index.html +1 -1
  625. package/templates/starter/main.html +12 -0
  626. package/templates/starter/native-playtests/react-hud.playtest.json +1 -0
  627. package/templates/starter/native-playtests/render-chain.playtest.json +34 -21
  628. package/templates/starter/opencode.json +10 -2
  629. package/templates/starter/package.json +15 -10
  630. package/templates/starter/playtests/play.playtest.json +22 -2
  631. package/templates/starter/playtests/production-readiness.playtest.json +14 -0
  632. package/templates/starter/src/entities/Crate.ts +19 -1
  633. package/templates/starter/src/render/arena.ts +2 -2
  634. package/templates/starter/src/render/atmosphere.ts +444 -0
  635. package/templates/starter/src/render/backlightMaterial.ts +49 -18
  636. package/templates/starter/src/render/camera.ts +28 -0
  637. package/templates/starter/src/render/clouds.ts +605 -0
  638. package/templates/starter/src/render/contactShadow.ts +50 -0
  639. package/templates/starter/src/render/exposure.ts +9 -111
  640. package/templates/starter/src/render/gpuSky.ts +752 -0
  641. package/templates/starter/src/render/grade.ts +1 -1
  642. package/templates/starter/src/render/lighting.ts +34 -6
  643. package/templates/starter/src/render/materialLighting.ts +2 -11
  644. package/templates/starter/src/render/postprocessing.ts +27 -14
  645. package/templates/starter/src/render/quality.ts +18 -147
  646. package/templates/starter/src/render/sky.ts +90 -40
  647. package/templates/starter/src/render/temporalAA.ts +1 -1
  648. package/templates/starter/src/render/temporalAAStage.ts +1 -1
  649. package/templates/starter/src/render/temporalCurrentFootprint.ts +0 -1
  650. package/templates/starter/src/render/temporalDetailStage.ts +106 -0
  651. package/templates/starter/src/render/temporalRejectionCounter.ts +2 -2
  652. package/templates/starter/src/render/volumetricFogCamera.ts +32 -0
  653. package/templates/starter/src/render/volumetricFogOptions.ts +7 -0
  654. package/templates/starter/src/render/volumetricFogTransport.ts +27 -19
  655. package/templates/starter/src/render/volumetricFogVolume.ts +31 -7
  656. package/templates/starter/src/scenes/Play.ts +11 -8
  657. package/templates/starter/src/ui/Hud.tsx +1 -1
  658. package/templates/starter/src/worker-page.ts +29 -0
  659. package/templates/starter/src/worker.ts +5 -0
  660. package/templates/starter/vite.config.ts +2 -0
  661. package/templates/tower-defense/.codex/config.toml +6 -2
  662. package/templates/tower-defense/.cursor/mcp.json +8 -2
  663. package/templates/tower-defense/.gemini/settings.json +8 -2
  664. package/templates/tower-defense/.mcp.json +8 -2
  665. package/templates/tower-defense/.vscode/mcp.json +9 -2
  666. package/templates/tower-defense/.zed/settings.json +9 -2
  667. package/templates/tower-defense/AGENTS.md +10 -12
  668. package/templates/tower-defense/CLAUDE.md +10 -12
  669. package/templates/tower-defense/opencode.json +10 -2
  670. package/templates/tower-defense/package.json +15 -10
  671. package/templates/tower-defense/playtests/chill-tint.playtest.json +387 -0
  672. package/templates/tower-defense/playtests/performance.playtest.json +1 -1
  673. package/templates/tower-defense/src/enemies/Enemy.ts +9 -0
  674. package/templates/tower-defense/src/render/backlightMaterial.ts +49 -18
  675. package/templates/tower-defense/src/render/exposure.ts +11 -109
  676. package/templates/tower-defense/src/render/lighting.ts +4 -2
  677. package/templates/tower-defense/src/render/materialLighting.ts +2 -11
  678. package/templates/tower-defense/src/render/postprocessing.ts +4 -4
  679. package/templates/tower-defense/src/render/quality.ts +10 -116
  680. package/templates/tower-defense/src/render/sky.ts +2 -2
  681. package/templates/tower-defense/src/scenes/Battle.ts +4 -0
  682. package/template-assets/autoExposure.ts +0 -225
  683. package/template-assets/exposureGraph.ts +0 -178
  684. package/template-assets/exposureReadback.ts +0 -79
  685. package/template-assets/worldEnvironment.ts +0 -1212
  686. package/templates/action-rpg/src/render/autoExposure.ts +0 -225
  687. package/templates/action-rpg/src/render/exposureGraph.ts +0 -178
  688. package/templates/action-rpg/src/render/exposureReadback.ts +0 -79
  689. package/templates/action-rpg/src/render/worldEnvironment.ts +0 -1212
  690. package/templates/minimal/src/render/autoExposure.ts +0 -225
  691. package/templates/minimal/src/render/exposureGraph.ts +0 -178
  692. package/templates/minimal/src/render/exposureReadback.ts +0 -79
  693. package/templates/minimal/src/render/worldEnvironment.ts +0 -1212
  694. package/templates/platformer/src/render/autoExposure.ts +0 -225
  695. package/templates/platformer/src/render/exposureGraph.ts +0 -178
  696. package/templates/platformer/src/render/exposureReadback.ts +0 -79
  697. package/templates/platformer/src/render/worldEnvironment.ts +0 -1212
  698. package/templates/puzzle/src/render/autoExposure.ts +0 -225
  699. package/templates/puzzle/src/render/exposureGraph.ts +0 -178
  700. package/templates/puzzle/src/render/exposureReadback.ts +0 -79
  701. package/templates/puzzle/src/render/worldEnvironment.ts +0 -1212
  702. package/templates/racing/src/render/autoExposure.ts +0 -225
  703. package/templates/racing/src/render/exposureGraph.ts +0 -178
  704. package/templates/racing/src/render/exposureReadback.ts +0 -79
  705. package/templates/racing/src/render/worldEnvironment.ts +0 -1212
  706. package/templates/rain/src/render/autoExposure.ts +0 -225
  707. package/templates/rain/src/render/exposureGraph.ts +0 -178
  708. package/templates/rain/src/render/exposureReadback.ts +0 -79
  709. package/templates/rain/src/render/worldEnvironment.ts +0 -1212
  710. package/templates/rts/src/render/autoExposure.ts +0 -225
  711. package/templates/rts/src/render/exposureGraph.ts +0 -178
  712. package/templates/rts/src/render/exposureReadback.ts +0 -79
  713. package/templates/rts/src/render/worldEnvironment.ts +0 -1212
  714. package/templates/runner/src/render/autoExposure.ts +0 -225
  715. package/templates/runner/src/render/exposureGraph.ts +0 -178
  716. package/templates/runner/src/render/exposureReadback.ts +0 -79
  717. package/templates/runner/src/render/worldEnvironment.ts +0 -1212
  718. package/templates/sailing/src/render/autoExposure.ts +0 -225
  719. package/templates/sailing/src/render/exposureGraph.ts +0 -178
  720. package/templates/sailing/src/render/exposureReadback.ts +0 -79
  721. package/templates/sailing/src/render/worldEnvironment.ts +0 -1212
  722. package/templates/shooter/src/render/autoExposure.ts +0 -225
  723. package/templates/shooter/src/render/exposureGraph.ts +0 -178
  724. package/templates/shooter/src/render/exposureReadback.ts +0 -79
  725. package/templates/shooter/src/render/worldEnvironment.ts +0 -1212
  726. package/templates/snow/src/render/autoExposure.ts +0 -225
  727. package/templates/snow/src/render/exposureGraph.ts +0 -178
  728. package/templates/snow/src/render/exposureReadback.ts +0 -79
  729. package/templates/snow/src/render/worldEnvironment.ts +0 -1212
  730. package/templates/starter/src/render/autoExposure.ts +0 -225
  731. package/templates/starter/src/render/exposureGraph.ts +0 -178
  732. package/templates/starter/src/render/exposureReadback.ts +0 -79
  733. package/templates/starter/src/render/worldEnvironment.ts +0 -1212
  734. package/templates/tower-defense/src/render/autoExposure.ts +0 -225
  735. package/templates/tower-defense/src/render/exposureGraph.ts +0 -178
  736. package/templates/tower-defense/src/render/exposureReadback.ts +0 -79
  737. package/templates/tower-defense/src/render/worldEnvironment.ts +0 -1212
@@ -1,5 +1,13 @@
1
- import { type ICtx, Scene, type SceneFrame, getPlatform, isMobile } from "@threenative/core";
2
- import { Object3D, type OrthographicCamera, type Texture, type Vector2 } from "three";
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 { type PickTarget, pickEntity, unitsInBox } from "../render/picking.js";
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
- const view = createRtsView(-70, 58);
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(this.#terrain.root, this.#resources.root, this.#army.root, this.#anchor.object);
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
- if (this.#pointerSeen && raw.pointer.buttons === 0 && this.#drag === undefined) {
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.id, edge.position);
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
- #release(ctx: GameCtx, id: number, at: Vector2): void {
329
- const drag = this.#drag;
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 (drag === undefined || drag.id !== id || sim === undefined || view === undefined) return;
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 keys = ctx.input.raw.keys;
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 (!isShifted(keys)) this.#selectIds([]);
437
+ if (!shift) this.#selectIds([]);
341
438
  return;
342
439
  }
343
- this.#toggleSelection(hit, isShifted(keys));
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 = isShifted(keys) ? this.#selection.filter((id) => sim.get(id)?.team === 0) : [];
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
- const hit = pickEntity(sim, camera, view, ctx.viewport.size, at.x, at.y);
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") return { kind: mode, target: { id: hit?.id } };
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) this.#notice = `${String(event.name)} ready.`;
538
- else if (event.type === "complete" && team === 0)
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
- else if (event.type === "eliminated" && team > 0)
743
+ this.#noticeError = false;
744
+ } else if (event.type === "eliminated" && team > 0) {
541
745
  this.#notice = `${String(event.name)} command network destroyed.`;
542
- else if (event.type === "constructionLost" && team === 0)
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
- else if (event.type === "end") this.#notice = "";
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
- patch.primaryHp = primary?.hp ?? 0;
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
- this.#box[0] = Math.min(this.#drag.from.x, this.#drag.to.x);
611
- this.#box[1] = Math.min(this.#drag.from.y, this.#drag.to.y);
612
- this.#box[2] = Math.abs(this.#drag.to.x - this.#drag.from.x);
613
- this.#box[3] = Math.abs(this.#drag.to.y - this.#drag.from.y);
614
- patch.dragBox = this.#box;
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 (this.#publishedStep !== Math.floor(sim.time * 20)) {
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);