create-threenative 0.2.6 → 0.2.8

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 (756) hide show
  1. package/README.md +5 -3
  2. package/agent-docs/references/build-profiles.md +126 -0
  3. package/agent-docs/references/capability-reference.md +607 -26
  4. package/agent-docs/references/performance-basics.md +8 -5
  5. package/agent-docs/references/sculpt-from-a-reference.md +1 -1
  6. package/agent-docs/references/trace-a-slow-frame.md +1 -1
  7. package/agent-docs/references/visual-baseline.md +8 -4
  8. package/agent-files/.agents/skills/file-engine-bug/SKILL.md +15 -4
  9. package/agent-files/.agents/skills/threenative-assets/SKILL.md +5 -5
  10. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +1 -1
  11. package/agent-files/.agents/skills/threenative-context/SKILL.md +1 -1
  12. package/agent-files/.agents/skills/threenative-performance/SKILL.md +3 -3
  13. package/agent-files/.agents/skills/threenative-playtest/SKILL.md +1 -1
  14. package/agent-files/.agents/skills/threenative-ui/SKILL.md +1 -1
  15. package/agent-files/.agents/skills/threenative-visuals/SKILL.md +4 -4
  16. package/capabilities.json +801 -24
  17. package/dist/index.d.ts +30 -1
  18. package/dist/index.js +300 -56
  19. package/dist/threenative.js +717 -156
  20. package/package.json +6 -6
  21. package/template-assets/assets/mannequin-combat.glb +0 -0
  22. package/template-assets/assets/mannequin.glb +0 -0
  23. package/template-assets/assets/player-viewmodel.glb +0 -0
  24. package/template-assets/assets/sky.jpg +0 -0
  25. package/template-assets/clearwater/README.md +141 -0
  26. package/template-assets/clearwater/install.mjs +50 -0
  27. package/template-assets/clearwater/src/clearwater.ts +180 -0
  28. package/template-assets/clearwater/src/clearwaterDemo.ts +28 -0
  29. package/template-assets/clearwater/src/clearwaterLifetime.ts +28 -0
  30. package/{LICENSE → template-assets/clearwater/src/render/CLEARWATER-LICENSE.txt} +4 -1
  31. package/template-assets/clearwater/src/render/clearwater.ts +278 -0
  32. package/template-assets/clearwater/src/render/clearwaterCaustics.ts +138 -0
  33. package/template-assets/clearwater/src/render/clearwaterDemo.ts +65 -0
  34. package/template-assets/clearwater/src/render/clearwaterOptics.ts +33 -0
  35. package/template-assets/clearwater/src/render/clearwaterOptions.ts +177 -0
  36. package/template-assets/clearwater/src/render/clearwaterPass.ts +51 -0
  37. package/template-assets/patches/three@0.185.1.patch +2101 -138
  38. package/template-assets/worldEnvironment.ts +52 -1
  39. package/templates/action-rpg/AGENTS.md +42 -42
  40. package/templates/action-rpg/CLAUDE.md +42 -42
  41. package/templates/action-rpg/kit.json +1 -1
  42. package/templates/action-rpg/package.json +13 -7
  43. package/templates/action-rpg/playtests/combat.playtest.json +162 -23
  44. package/templates/action-rpg/playtests/performance.playtest.json +4 -3
  45. package/templates/action-rpg/playtests/survives.playtest.json +25 -8
  46. package/templates/action-rpg/src/conventions.ts +24 -18
  47. package/templates/action-rpg/src/entities/Enemy.ts +74 -24
  48. package/templates/action-rpg/src/entities/Fighter.ts +127 -0
  49. package/templates/action-rpg/src/entities/Player.ts +102 -32
  50. package/templates/action-rpg/src/game.ts +3 -3
  51. package/templates/action-rpg/src/render/camera.ts +18 -16
  52. package/templates/action-rpg/src/render/dungeon.ts +192 -0
  53. package/templates/action-rpg/src/render/lighting.ts +45 -28
  54. package/templates/action-rpg/src/render/loading.ts +4 -4
  55. package/templates/action-rpg/src/render/materials.ts +191 -47
  56. package/templates/action-rpg/src/render/palette.ts +14 -13
  57. package/templates/action-rpg/src/render/postprocessing.ts +12 -2
  58. package/templates/action-rpg/src/render/props.ts +117 -0
  59. package/templates/action-rpg/src/render/quality.ts +40 -82
  60. package/templates/action-rpg/src/render/sky.ts +36 -13
  61. package/templates/action-rpg/src/render/touch-controls.ts +1 -1
  62. package/templates/action-rpg/src/render/worldEnvironment.ts +52 -1
  63. package/templates/action-rpg/src/scenes/Play.ts +61 -39
  64. package/templates/action-rpg/src/style.css +9 -7
  65. package/templates/action-rpg/src/ui/AbilityBar.tsx +3 -1
  66. package/templates/action-rpg/src/ui/Hud.tsx +3 -3
  67. package/templates/action-rpg/threenative.config.ts +14 -1
  68. package/templates/action-rpg/vite.config.ts +4 -1
  69. package/templates/minimal/AGENTS.md +10 -10
  70. package/templates/minimal/CLAUDE.md +10 -10
  71. package/templates/minimal/package.json +12 -6
  72. package/templates/minimal/playtests/play.playtest.json +6 -5
  73. package/templates/minimal/playtests/sky.playtest.json +27 -0
  74. package/templates/minimal/src/conventions.ts +6 -3
  75. package/templates/minimal/src/entities/Player.ts +73 -27
  76. package/templates/minimal/src/main.ts +2 -3
  77. package/templates/minimal/src/render/camera.ts +22 -4
  78. package/templates/minimal/src/render/lighting.ts +24 -48
  79. package/templates/minimal/src/render/materials.ts +158 -13
  80. package/templates/minimal/src/render/palette.ts +10 -7
  81. package/templates/minimal/src/render/postprocessing.ts +12 -25
  82. package/templates/minimal/src/render/quality.ts +35 -69
  83. package/templates/minimal/src/render/sky.ts +35 -54
  84. package/templates/minimal/src/render/touch-controls.ts +1 -1
  85. package/templates/minimal/src/render/worldEnvironment.ts +52 -1
  86. package/templates/minimal/src/scenes/Play.ts +121 -111
  87. package/templates/minimal/src/state.ts +0 -4
  88. package/templates/minimal/src/style.css +0 -10
  89. package/templates/minimal/threenative.config.ts +14 -1
  90. package/templates/minimal/vite.config.ts +4 -1
  91. package/templates/platformer/AGENTS.md +18 -56
  92. package/templates/platformer/CLAUDE.md +18 -56
  93. package/templates/platformer/kit.json +2 -2
  94. package/templates/platformer/package.json +13 -9
  95. package/templates/platformer/playtests/buffer.playtest.json +15 -5
  96. package/templates/platformer/playtests/collect.playtest.json +8 -34
  97. package/templates/platformer/playtests/coyote.playtest.json +12 -34
  98. package/templates/platformer/playtests/damage.playtest.json +40 -15
  99. package/templates/platformer/playtests/hud.playtest.json +34 -0
  100. package/templates/platformer/playtests/move.playtest.json +24 -0
  101. package/templates/platformer/playtests/performance.playtest.json +24 -7
  102. package/templates/platformer/playtests/respawn.playtest.json +46 -11
  103. package/templates/platformer/playtests/stomp.playtest.json +49 -12
  104. package/templates/platformer/playtests/survives.playtest.json +3 -19
  105. package/templates/platformer/playtests/world.playtest.json +26 -0
  106. package/templates/platformer/src/entities/Fox.ts +273 -0
  107. package/templates/platformer/src/entities/Pickup.ts +43 -60
  108. package/templates/platformer/src/entities/Walker.ts +88 -0
  109. package/templates/platformer/src/game.ts +11 -8
  110. package/templates/platformer/src/level/Checkpoints.ts +29 -16
  111. package/templates/platformer/src/level/Stage.ts +469 -0
  112. package/templates/platformer/src/render/blocks.ts +94 -0
  113. package/templates/platformer/src/render/camera.ts +28 -3
  114. package/templates/platformer/src/render/fox.ts +196 -0
  115. package/templates/platformer/src/render/lighting.ts +42 -33
  116. package/templates/platformer/src/render/materials.ts +115 -5
  117. package/templates/platformer/src/render/palette.ts +68 -53
  118. package/templates/platformer/src/render/pickups.ts +142 -0
  119. package/templates/platformer/src/render/postprocessing.ts +12 -2
  120. package/templates/platformer/src/render/props.ts +147 -0
  121. package/templates/platformer/src/render/quality.ts +47 -99
  122. package/templates/platformer/src/render/scenery.ts +172 -0
  123. package/templates/platformer/src/render/sky.ts +120 -31
  124. package/templates/platformer/src/render/touch-controls.ts +5 -2
  125. package/templates/platformer/src/render/walkers.ts +96 -0
  126. package/templates/platformer/src/render/waterfall.ts +85 -0
  127. package/templates/platformer/src/render/worldEnvironment.ts +52 -1
  128. package/templates/platformer/src/scenes/Boot.ts +3 -4
  129. package/templates/platformer/src/scenes/Play.ts +362 -0
  130. package/templates/platformer/src/state.ts +16 -14
  131. package/templates/platformer/src/style.css +9 -8
  132. package/templates/platformer/src/ui/Hud.tsx +62 -29
  133. package/templates/platformer/src/ui/Menu.tsx +2 -2
  134. package/templates/platformer/threenative.config.ts +14 -1
  135. package/templates/platformer/vite.config.ts +4 -1
  136. package/templates/puzzle/AGENTS.md +19 -20
  137. package/templates/puzzle/CLAUDE.md +19 -20
  138. package/templates/puzzle/assets/native-proof.glb +0 -0
  139. package/templates/puzzle/assets/native-proof.png +0 -0
  140. package/templates/puzzle/kit.json +1 -1
  141. package/templates/puzzle/package.json +13 -7
  142. package/templates/puzzle/playtests/axis.playtest.json +20 -0
  143. package/templates/puzzle/playtests/blocked.playtest.json +73 -0
  144. package/templates/puzzle/playtests/caused.playtest.json +65 -0
  145. package/templates/puzzle/playtests/lit.playtest.json +74 -0
  146. package/templates/puzzle/playtests/performance.playtest.json +24 -7
  147. package/templates/{starter/playtests/respawn.playtest.json → puzzle/playtests/push.playtest.json} +24 -19
  148. package/templates/puzzle/playtests/replay.playtest.json +81 -0
  149. package/templates/puzzle/playtests/restart.playtest.json +108 -0
  150. package/templates/puzzle/playtests/seal.playtest.json +98 -0
  151. package/templates/puzzle/playtests/settle.playtest.json +100 -0
  152. package/templates/puzzle/playtests/survives.playtest.json +6 -29
  153. package/templates/{starter/playtests/hot-reload.playtest.json → puzzle/playtests/travel.playtest.json} +6 -5
  154. package/templates/puzzle/src/entities/Crate.ts +99 -42
  155. package/templates/puzzle/src/entities/Seal.ts +69 -0
  156. package/templates/puzzle/src/entities/Warden.ts +135 -0
  157. package/templates/puzzle/src/game.ts +15 -11
  158. package/templates/puzzle/src/render/camera.ts +66 -31
  159. package/templates/puzzle/src/render/crateShape.ts +70 -0
  160. package/templates/puzzle/src/render/lighting.ts +41 -41
  161. package/templates/puzzle/src/render/loading.ts +4 -4
  162. package/templates/puzzle/src/render/materials.ts +131 -27
  163. package/templates/puzzle/src/render/palette.ts +19 -29
  164. package/templates/puzzle/src/render/postprocessing.ts +15 -3
  165. package/templates/puzzle/src/render/quality.ts +71 -80
  166. package/templates/puzzle/src/render/shapes.ts +109 -108
  167. package/templates/puzzle/src/render/sky.ts +18 -10
  168. package/templates/puzzle/src/render/touch-controls.ts +8 -51
  169. package/templates/puzzle/src/render/vault.ts +315 -0
  170. package/templates/puzzle/src/render/warden.ts +46 -0
  171. package/templates/puzzle/src/render/worldEnvironment.ts +52 -1
  172. package/templates/puzzle/src/scenes/Play.ts +793 -0
  173. package/templates/puzzle/src/state.ts +55 -24
  174. package/templates/puzzle/src/style.css +7 -8
  175. package/templates/puzzle/src/ui/App.tsx +2 -2
  176. package/templates/puzzle/src/ui/Hud.tsx +92 -40
  177. package/templates/puzzle/src/ui/Menu.tsx +40 -2
  178. package/templates/puzzle/threenative.config.ts +14 -1
  179. package/templates/puzzle/vite.config.ts +4 -1
  180. package/templates/racing/AGENTS.md +19 -20
  181. package/templates/racing/CLAUDE.md +19 -20
  182. package/templates/racing/package.json +13 -7
  183. package/templates/racing/playtests/boost.playtest.json +33 -12
  184. package/templates/racing/playtests/outcome.playtest.json +32 -50
  185. package/templates/racing/playtests/performance.playtest.json +2 -1
  186. package/templates/racing/playtests/ranking.playtest.json +5 -14
  187. package/templates/racing/playtests/rescue.playtest.json +2 -2
  188. package/templates/racing/playtests/reverse.playtest.json +30 -8
  189. package/templates/racing/playtests/shortcut.playtest.json +54 -9
  190. package/templates/racing/playtests/touch-controls.playtest.json +32 -5
  191. package/templates/racing/src/entities/CarBody.ts +327 -0
  192. package/templates/racing/src/entities/LineDriver.ts +220 -0
  193. package/templates/racing/src/entities/RacingCar.ts +150 -89
  194. package/templates/racing/src/entities/Rival.ts +61 -24
  195. package/templates/racing/src/game.ts +5 -0
  196. package/templates/racing/src/render/camera.ts +49 -7
  197. package/templates/racing/src/render/lighting.ts +36 -37
  198. package/templates/racing/src/render/materials.ts +239 -19
  199. package/templates/racing/src/render/palette.ts +19 -21
  200. package/templates/racing/src/render/postprocessing.ts +12 -2
  201. package/templates/racing/src/render/quality.ts +43 -82
  202. package/templates/racing/src/render/shapes.ts +20 -6
  203. package/templates/racing/src/render/sky.ts +47 -39
  204. package/templates/racing/src/render/touch-controls.ts +1 -1
  205. package/templates/racing/src/render/worldEnvironment.ts +52 -1
  206. package/templates/racing/src/scenes/Race.ts +107 -54
  207. package/templates/racing/src/state.ts +2 -0
  208. package/templates/racing/src/track/Checkline.ts +22 -7
  209. package/templates/racing/src/track/Lap.ts +64 -36
  210. package/templates/racing/src/track/Ranking.ts +20 -11
  211. package/templates/racing/src/track/Track.ts +809 -361
  212. package/templates/racing/src/track/TrackSector.ts +40 -11
  213. package/templates/racing/src/track/circuit.ts +477 -0
  214. package/templates/racing/src/track/rescue.ts +16 -4
  215. package/templates/racing/threenative.config.ts +14 -1
  216. package/templates/racing/vite.config.ts +4 -1
  217. package/templates/rain/AGENTS.md +96 -0
  218. package/templates/rain/CLAUDE.md +98 -0
  219. package/templates/rain/assets/rain-loop.wav +0 -0
  220. package/templates/rain/assets/thunder.wav +0 -0
  221. package/templates/rain/assets/wind-loop.wav +0 -0
  222. package/templates/rain/index.html +18 -0
  223. package/templates/rain/kit.json +7 -0
  224. package/templates/rain/native-playtests/boot.playtest.json +13 -0
  225. package/templates/rain/native-playtests/lightning.playtest.json +173 -0
  226. package/templates/rain/package.json +56 -0
  227. package/templates/rain/playtests/auto-lightning-clear.playtest.json +66 -0
  228. package/templates/rain/playtests/auto-lightning.playtest.json +26 -0
  229. package/templates/rain/playtests/automation.playtest.json +133 -0
  230. package/templates/rain/playtests/cinematic.playtest.json +59 -0
  231. package/templates/rain/playtests/flash.playtest.json +27 -0
  232. package/templates/rain/playtests/fly.playtest.json +54 -0
  233. package/templates/rain/playtests/lightning.playtest.json +220 -0
  234. package/templates/rain/playtests/loading.playtest.json +57 -0
  235. package/templates/rain/playtests/paused.playtest.json +59 -0
  236. package/templates/rain/playtests/performance.playtest.json +22 -0
  237. package/templates/rain/playtests/reduced-motion.playtest.json +87 -0
  238. package/templates/rain/playtests/simulation.playtest.json +20 -0
  239. package/templates/rain/playtests/storm.playtest.json +150 -0
  240. package/templates/rain/playtests/survives.playtest.json +58 -0
  241. package/templates/rain/playtests/tiers.playtest.json +179 -0
  242. package/templates/rain/playtests/weather.playtest.json +77 -0
  243. package/templates/rain/public/favicon.svg +5 -0
  244. package/templates/rain/src/audio/storm.ts +314 -0
  245. package/templates/rain/src/game.ts +114 -0
  246. package/templates/rain/src/render/bloom-shader.ts +65 -0
  247. package/templates/rain/src/render/camera.ts +160 -0
  248. package/templates/rain/src/render/clouds-shader.ts +242 -0
  249. package/templates/rain/src/render/clouds.ts +142 -0
  250. package/templates/rain/src/render/lighting.ts +39 -0
  251. package/templates/rain/src/render/lightning.ts +360 -0
  252. package/templates/rain/src/render/loading.ts +327 -0
  253. package/templates/rain/src/render/materials.ts +19 -0
  254. package/templates/rain/src/render/noise-volume.ts +159 -0
  255. package/templates/rain/src/render/palette.ts +18 -0
  256. package/templates/rain/src/render/post-shader.ts +178 -0
  257. package/templates/rain/src/render/postprocessing.ts +226 -0
  258. package/templates/rain/src/render/quality.ts +135 -0
  259. package/templates/rain/src/render/rain.ts +299 -0
  260. package/templates/rain/src/render/sky.ts +28 -0
  261. package/templates/rain/src/render/world-shader.ts +680 -0
  262. package/templates/rain/src/render/world.ts +146 -0
  263. package/templates/{defense → rain}/src/render/worldEnvironment.ts +52 -1
  264. package/templates/rain/src/scenes/Boot.ts +334 -0
  265. package/templates/rain/src/state.ts +257 -0
  266. package/templates/rain/src/style.css +1160 -0
  267. package/templates/rain/src/ui/App.tsx +29 -0
  268. package/templates/rain/src/ui/GameUi.tsx +187 -0
  269. package/templates/rain/src/ui/Hud.tsx +327 -0
  270. package/templates/rain/src/ui/LoadingOverlay.tsx +46 -0
  271. package/templates/rain/src/ui/Menu.tsx +370 -0
  272. package/templates/rain/src/ui/automation.ts +60 -0
  273. package/templates/rain/src/ui/main.tsx +7 -0
  274. package/templates/rain/src/ui/tempest.ts +149 -0
  275. package/templates/rain/tailwind.config.ts +2 -0
  276. package/templates/rain/threenative.config.ts +66 -0
  277. package/templates/rain/tools/generate-shaders.mjs +656 -0
  278. package/templates/rain/tools/make-storm-audio.mjs +387 -0
  279. package/templates/rain/tools/storm-dsp.mjs +177 -0
  280. package/templates/rain/tools/tempest-bloom.frag +10 -0
  281. package/templates/rain/tools/tempest-clouds.frag +86 -0
  282. package/templates/rain/tools/tempest-post.frag +47 -0
  283. package/templates/rain/tools/tempest-world.frag +210 -0
  284. package/templates/rain/tools/verify-noise-volume.mjs +61 -0
  285. package/templates/rain/tsconfig.json +17 -0
  286. package/templates/rain/vite.config.ts +37 -0
  287. package/templates/rts/.codex/config.toml +19 -0
  288. package/templates/rts/.cursor/mcp.json +32 -0
  289. package/templates/rts/.gemini/settings.json +32 -0
  290. package/templates/rts/.mcp.json +32 -0
  291. package/templates/rts/.vscode/mcp.json +36 -0
  292. package/templates/rts/.zed/settings.json +36 -0
  293. package/templates/rts/AGENTS.md +96 -0
  294. package/templates/rts/CLAUDE.md +98 -0
  295. package/templates/rts/kit.json +7 -0
  296. package/templates/rts/opencode.json +41 -0
  297. package/templates/{defense → rts}/package.json +13 -7
  298. package/templates/rts/playtests/performance.playtest.json +41 -0
  299. package/templates/rts/playtests/rts-ai-attack.playtest.json +24 -0
  300. package/templates/rts/playtests/rts-attack.playtest.json +75 -0
  301. package/templates/rts/playtests/rts-build.playtest.json +68 -0
  302. package/templates/rts/playtests/rts-orders.playtest.json +150 -0
  303. package/templates/rts/playtests/rts-train.playtest.json +62 -0
  304. package/templates/rts/playtests/survives.playtest.json +58 -0
  305. package/templates/rts/public/favicon.svg +4 -0
  306. package/templates/rts/src/game.ts +64 -0
  307. package/templates/rts/src/main.ts +15 -0
  308. package/templates/rts/src/orders.ts +22 -0
  309. package/templates/rts/src/render/army.ts +346 -0
  310. package/templates/rts/src/render/camera.ts +123 -0
  311. package/templates/rts/src/render/lighting.ts +61 -0
  312. package/templates/rts/src/render/loading.ts +33 -0
  313. package/templates/rts/src/render/materials.ts +152 -0
  314. package/templates/rts/src/render/models.ts +705 -0
  315. package/templates/rts/src/render/palette.ts +17 -0
  316. package/templates/rts/src/render/picking.ts +93 -0
  317. package/templates/rts/src/render/postprocessing.ts +46 -0
  318. package/templates/rts/src/render/quality.ts +128 -0
  319. package/templates/rts/src/render/resources.ts +141 -0
  320. package/templates/rts/src/render/sky.ts +44 -0
  321. package/templates/rts/src/render/terrain.ts +116 -0
  322. package/templates/rts/src/render/worldEnvironment.ts +809 -0
  323. package/templates/rts/src/scenes/Play.ts +650 -0
  324. package/templates/rts/src/sim/ai.ts +1140 -0
  325. package/templates/rts/src/sim/combat.ts +416 -0
  326. package/templates/rts/src/sim/construction.ts +374 -0
  327. package/templates/rts/src/sim/economy.ts +167 -0
  328. package/templates/rts/src/sim/game.ts +1082 -0
  329. package/templates/rts/src/sim/movement.ts +371 -0
  330. package/templates/rts/src/sim/nav.ts +276 -0
  331. package/templates/rts/src/sim/production.ts +180 -0
  332. package/templates/rts/src/sim/terrain.ts +170 -0
  333. package/templates/rts/src/sim/types.ts +647 -0
  334. package/templates/rts/src/sim/vision.ts +46 -0
  335. package/templates/rts/src/state.ts +100 -0
  336. package/templates/{defense → rts}/src/style.css +21 -8
  337. package/templates/rts/src/ui/App.tsx +21 -0
  338. package/templates/rts/src/ui/Commands.tsx +129 -0
  339. package/templates/rts/src/ui/GameUi.tsx +22 -0
  340. package/templates/rts/src/ui/Hud.tsx +165 -0
  341. package/templates/rts/src/ui/Minimap.tsx +84 -0
  342. package/templates/rts/tailwind.config.ts +2 -0
  343. package/templates/rts/threenative.config.ts +56 -0
  344. package/templates/rts/tsconfig.json +17 -0
  345. package/templates/{defense → rts}/vite.config.ts +4 -1
  346. package/templates/runner/AGENTS.md +6 -10
  347. package/templates/runner/CLAUDE.md +6 -10
  348. package/templates/runner/README.md +3 -3
  349. package/templates/runner/package.json +13 -7
  350. package/templates/runner/playtests/performance.playtest.json +2 -2
  351. package/templates/runner/src/conventions.ts +4 -3
  352. package/templates/runner/src/entities/Runner.ts +54 -7
  353. package/templates/runner/src/game.ts +2 -0
  354. package/templates/runner/src/render/camera.ts +4 -2
  355. package/templates/runner/src/render/dust.ts +5 -2
  356. package/templates/runner/src/render/lighting.ts +41 -45
  357. package/templates/runner/src/render/loading.ts +2 -2
  358. package/templates/runner/src/render/materials.ts +165 -25
  359. package/templates/runner/src/render/palette.ts +17 -28
  360. package/templates/runner/src/render/postprocessing.ts +12 -2
  361. package/templates/runner/src/render/quality.ts +42 -96
  362. package/templates/runner/src/render/shapes.ts +59 -37
  363. package/templates/runner/src/render/sky.ts +32 -41
  364. package/templates/runner/src/render/touch-controls.ts +1 -1
  365. package/templates/runner/src/render/worldEnvironment.ts +52 -1
  366. package/templates/runner/src/scenes/Run.ts +26 -6
  367. package/templates/runner/src/track.ts +6 -1
  368. package/templates/runner/threenative.config.ts +14 -1
  369. package/templates/runner/vite.config.ts +4 -1
  370. package/templates/sailing/AGENTS.md +12 -12
  371. package/templates/sailing/CLAUDE.md +12 -12
  372. package/templates/sailing/assets/ship.glb +0 -0
  373. package/templates/sailing/package.json +13 -7
  374. package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +10 -6
  375. package/templates/sailing/playtests/sails.playtest.json +33 -0
  376. package/templates/sailing/playtests/win.playtest.json +156 -8
  377. package/templates/sailing/src/conventions.ts +29 -2
  378. package/templates/sailing/src/entities/Ship.ts +381 -57
  379. package/templates/sailing/src/game.ts +14 -0
  380. package/templates/sailing/src/render/camera.ts +63 -9
  381. package/templates/sailing/src/render/lighting.ts +49 -27
  382. package/templates/sailing/src/render/materials.ts +50 -15
  383. package/templates/sailing/src/render/ocean.ts +647 -60
  384. package/templates/sailing/src/render/palette.ts +16 -12
  385. package/templates/sailing/src/render/postprocessing.ts +12 -2
  386. package/templates/sailing/src/render/props.ts +316 -442
  387. package/templates/sailing/src/render/quality.ts +14 -4
  388. package/templates/sailing/src/render/sky.ts +116 -23
  389. package/templates/sailing/src/render/worldEnvironment.ts +52 -1
  390. package/templates/sailing/src/scenes/Boot.ts +21 -0
  391. package/templates/sailing/src/scenes/Sailing.ts +173 -39
  392. package/templates/sailing/src/state.ts +6 -0
  393. package/templates/sailing/src/ui/Hud.tsx +41 -9
  394. package/templates/sailing/threenative.config.ts +14 -1
  395. package/templates/sailing/vite.config.ts +4 -1
  396. package/templates/shooter/AGENTS.md +27 -42
  397. package/templates/shooter/CLAUDE.md +27 -42
  398. package/templates/shooter/index.html +1 -0
  399. package/templates/shooter/package.json +13 -7
  400. package/templates/shooter/playtests/aim-alignment.playtest.json +58 -0
  401. package/templates/shooter/playtests/breakable-shatters.playtest.json +62 -0
  402. package/templates/shooter/playtests/bullet-holes.playtest.json +56 -0
  403. package/templates/shooter/playtests/camera-tracks-body-vertically.playtest.json +61 -0
  404. package/templates/shooter/playtests/crouch-lowers-the-eye.playtest.json +41 -0
  405. package/templates/shooter/playtests/death-no-snap.playtest.json +77 -0
  406. package/templates/shooter/playtests/debug-ads.playtest.json +58 -0
  407. package/templates/shooter/playtests/debug-clear.playtest.json +383 -0
  408. package/templates/shooter/playtests/debug-endurance.playtest.json +61 -0
  409. package/templates/shooter/playtests/debug-fire.playtest.json +119 -0
  410. package/templates/shooter/playtests/debug-restart.playtest.json +24 -0
  411. package/templates/shooter/playtests/enemy-body-is-a-body.playtest.json +79 -0
  412. package/templates/shooter/playtests/enemy-death-settles.playtest.json +64 -0
  413. package/templates/shooter/playtests/enemy-flinches-when-hit.playtest.json +75 -0
  414. package/templates/shooter/playtests/enemy-foot-contact.playtest.json +41 -0
  415. package/templates/shooter/playtests/enemy-material-is-not-shared.playtest.json +59 -0
  416. package/templates/shooter/playtests/enemy-reaches-walkway.playtest.json +80 -0
  417. package/templates/shooter/playtests/enemy-rifle-grip.playtest.json +101 -0
  418. package/templates/shooter/playtests/enemy-scale.playtest.json +56 -0
  419. package/templates/shooter/playtests/enemy-stops-without-snapping.playtest.json +486 -0
  420. package/templates/shooter/playtests/enemy-stride-matches-speed.playtest.json +198 -0
  421. package/templates/shooter/playtests/enemy-stride-under-crouch.playtest.json +87 -0
  422. package/templates/shooter/playtests/enemy-uses-crouch-clips.playtest.json +74 -0
  423. package/templates/shooter/playtests/five-soldiers.playtest.json +83 -0
  424. package/templates/shooter/playtests/flash-retires.playtest.json +62 -0
  425. package/templates/shooter/playtests/headshot-hits-head.playtest.json +132 -0
  426. package/templates/shooter/playtests/hold-to-fire.playtest.json +45 -0
  427. package/templates/shooter/playtests/input-control.playtest.json +43 -98
  428. package/templates/shooter/playtests/minimap-state.playtest.json +75 -0
  429. package/templates/shooter/playtests/performance.playtest.json +62 -26
  430. package/templates/{starter/playtests/forward.playtest.json → shooter/playtests/round-clock.playtest.json} +11 -16
  431. package/templates/shooter/playtests/shot-tracks-crosshair.playtest.json +79 -0
  432. package/templates/shooter/playtests/survives.playtest.json +36 -30
  433. package/templates/shooter/playtests/walkway-reachable.playtest.json +67 -0
  434. package/templates/shooter/src/entities/Breakables.ts +412 -0
  435. package/templates/shooter/src/entities/Enemy.ts +2095 -0
  436. package/templates/shooter/src/entities/FpsPlayer.ts +283 -0
  437. package/templates/shooter/src/entities/Rifle.ts +442 -0
  438. package/templates/shooter/src/entities/Target.ts +199 -83
  439. package/templates/shooter/src/entities/TouchControls.ts +276 -0
  440. package/templates/shooter/src/game.ts +75 -41
  441. package/templates/shooter/src/main.ts +0 -1
  442. package/templates/shooter/src/postPhysics.ts +36 -0
  443. package/templates/shooter/src/render/camera.ts +78 -74
  444. package/templates/shooter/src/render/decals.ts +142 -82
  445. package/templates/shooter/src/render/facade.ts +1373 -0
  446. package/templates/shooter/src/render/gunfx.ts +704 -0
  447. package/templates/shooter/src/render/lighting.ts +52 -38
  448. package/templates/shooter/src/render/loading.ts +2 -2
  449. package/templates/shooter/src/render/materials.ts +100 -88
  450. package/templates/shooter/src/render/occlusion.ts +108 -0
  451. package/templates/shooter/src/render/palette.ts +10 -10
  452. package/templates/shooter/src/render/palm.ts +455 -0
  453. package/templates/shooter/src/render/pooled-billboards.ts +144 -0
  454. package/templates/shooter/src/render/postprocessing.ts +15 -3
  455. package/templates/shooter/src/render/quality.ts +40 -82
  456. package/templates/shooter/src/render/scale.ts +148 -15
  457. package/templates/shooter/src/render/shapes.ts +138 -613
  458. package/templates/shooter/src/render/sky.ts +35 -35
  459. package/templates/shooter/src/render/town-schematic.ts +120 -0
  460. package/templates/shooter/src/render/town.ts +986 -0
  461. package/templates/shooter/src/render/townMaterials.ts +160 -0
  462. package/templates/shooter/src/render/vehicles.ts +741 -0
  463. package/templates/shooter/src/render/worldEnvironment.ts +52 -1
  464. package/templates/shooter/src/scenes/Play.ts +727 -650
  465. package/templates/shooter/src/state.ts +26 -41
  466. package/templates/shooter/src/style.css +207 -11
  467. package/templates/shooter/src/surfaces.ts +131 -0
  468. package/templates/shooter/src/ui/App.tsx +9 -10
  469. package/templates/shooter/src/ui/Crosshair.tsx +25 -18
  470. package/templates/shooter/src/ui/GameUi.tsx +6 -9
  471. package/templates/shooter/src/ui/Hud.tsx +428 -39
  472. package/templates/shooter/src/ui/Minimap.tsx +164 -0
  473. package/templates/shooter/src/ui/TouchOverlay.tsx +54 -0
  474. package/templates/shooter/src/ui/main.tsx +2 -3
  475. package/templates/shooter/threenative.config.ts +14 -1
  476. package/templates/shooter/vite.config.ts +4 -1
  477. package/templates/snow/.codex/config.toml +19 -0
  478. package/templates/snow/.cursor/mcp.json +32 -0
  479. package/templates/snow/.gemini/settings.json +32 -0
  480. package/templates/snow/.mcp.json +32 -0
  481. package/templates/snow/.vscode/mcp.json +36 -0
  482. package/templates/snow/.zed/settings.json +36 -0
  483. package/templates/snow/AGENTS.md +88 -0
  484. package/templates/snow/CLAUDE.md +90 -0
  485. package/templates/snow/README.md +26 -0
  486. package/templates/snow/assets/crunch.wav +0 -0
  487. package/templates/snow/assets/wind.wav +0 -0
  488. package/templates/snow/index.html +12 -0
  489. package/templates/snow/kit.json +7 -0
  490. package/templates/snow/native-playtests/snow-physics.playtest.json +150 -0
  491. package/templates/snow/native-playtests/survives.playtest.json +47 -0
  492. package/templates/snow/opencode.json +41 -0
  493. package/templates/snow/package.json +58 -0
  494. package/templates/snow/playtests/footsteps.playtest.json +95 -0
  495. package/templates/{defense → snow}/playtests/performance.playtest.json +4 -7
  496. package/templates/snow/playtests/snow-physics.playtest.json +154 -0
  497. package/templates/{defense → snow}/playtests/survives.playtest.json +26 -6
  498. package/templates/snow/playtests/touch-controls.playtest.json +71 -0
  499. package/templates/snow/playtests/weather.playtest.json +119 -0
  500. package/templates/snow/public/favicon.svg +5 -0
  501. package/templates/snow/src/audio.ts +58 -0
  502. package/templates/snow/src/commands.ts +8 -0
  503. package/templates/snow/src/entities/Explorer.ts +279 -0
  504. package/templates/snow/src/game.ts +69 -0
  505. package/templates/snow/src/main.ts +15 -0
  506. package/templates/snow/src/render/bootPrint.ts +50 -0
  507. package/templates/snow/src/render/camera.ts +84 -0
  508. package/templates/snow/src/render/explorer.ts +321 -0
  509. package/templates/snow/src/render/lighting.ts +50 -0
  510. package/templates/snow/src/render/loading.ts +325 -0
  511. package/templates/snow/src/render/materials.ts +36 -0
  512. package/templates/snow/src/render/palette.ts +17 -0
  513. package/templates/{defense → snow}/src/render/postprocessing.ts +12 -2
  514. package/templates/snow/src/render/props.ts +42 -0
  515. package/templates/{defense → snow}/src/render/quality.ts +37 -72
  516. package/templates/snow/src/render/scenery.ts +244 -0
  517. package/templates/snow/src/render/sky.ts +57 -0
  518. package/templates/snow/src/render/snowSurface.ts +259 -0
  519. package/templates/snow/src/render/touch-controls.ts +143 -0
  520. package/templates/snow/src/render/weather.ts +279 -0
  521. package/templates/snow/src/render/worldEnvironment.ts +809 -0
  522. package/templates/{defense → snow}/src/scenes/Boot.ts +4 -4
  523. package/templates/snow/src/scenes/Snow.ts +635 -0
  524. package/templates/snow/src/state.ts +46 -0
  525. package/templates/snow/src/style.css +143 -0
  526. package/templates/snow/src/terrain.ts +64 -0
  527. package/templates/snow/src/ui/App.tsx +15 -0
  528. package/templates/snow/src/ui/Controls.tsx +322 -0
  529. package/templates/snow/src/ui/GameUi.tsx +354 -0
  530. package/templates/snow/src/ui/icons.tsx +54 -0
  531. package/templates/snow/src/ui/main.tsx +7 -0
  532. package/templates/snow/tailwind.config.ts +2 -0
  533. package/templates/snow/threenative.config.ts +51 -0
  534. package/templates/snow/tsconfig.json +17 -0
  535. package/templates/snow/vite.config.ts +37 -0
  536. package/templates/starter/AGENTS.md +17 -17
  537. package/templates/starter/CLAUDE.md +17 -17
  538. package/templates/starter/native-playtests/render-chain.playtest.json +13 -45
  539. package/templates/starter/package.json +13 -7
  540. package/templates/starter/playtests/play.playtest.json +2 -1
  541. package/templates/starter/playtests/survives.playtest.json +1 -1
  542. package/templates/starter/src/conventions.ts +6 -3
  543. package/templates/starter/src/entities/Goal.ts +35 -42
  544. package/templates/starter/src/entities/Player.ts +99 -16
  545. package/templates/starter/src/render/arena.ts +131 -0
  546. package/templates/starter/src/render/lighting.ts +27 -44
  547. package/templates/starter/src/render/materials.ts +164 -35
  548. package/templates/starter/src/render/palette.ts +16 -16
  549. package/templates/starter/src/render/postprocessing.ts +6 -7
  550. package/templates/starter/src/render/quality.ts +43 -101
  551. package/templates/starter/src/render/shapes.ts +1 -1
  552. package/templates/starter/src/render/sky.ts +39 -45
  553. package/templates/starter/src/render/touch-controls.ts +3 -1
  554. package/templates/starter/src/render/worldEnvironment.ts +52 -1
  555. package/templates/starter/src/scenes/Play.ts +82 -81
  556. package/templates/starter/threenative.config.ts +14 -1
  557. package/templates/starter/vite.config.ts +4 -1
  558. package/templates/tower-defense/.codex/config.toml +19 -0
  559. package/templates/tower-defense/.cursor/mcp.json +32 -0
  560. package/templates/tower-defense/.gemini/settings.json +32 -0
  561. package/templates/tower-defense/.mcp.json +32 -0
  562. package/templates/tower-defense/.vscode/mcp.json +36 -0
  563. package/templates/tower-defense/.zed/settings.json +36 -0
  564. package/templates/{defense → tower-defense}/AGENTS.md +14 -12
  565. package/templates/{defense → tower-defense}/CLAUDE.md +14 -12
  566. package/templates/tower-defense/README.md +16 -0
  567. package/templates/tower-defense/index.html +12 -0
  568. package/templates/tower-defense/kit.json +7 -0
  569. package/templates/tower-defense/opencode.json +41 -0
  570. package/templates/tower-defense/package.json +56 -0
  571. package/templates/tower-defense/playtests/arsenal.playtest.json +214 -0
  572. package/templates/tower-defense/playtests/defeat.playtest.json +85 -0
  573. package/templates/tower-defense/playtests/look.playtest.json +130 -0
  574. package/templates/tower-defense/playtests/performance.playtest.json +77 -0
  575. package/templates/tower-defense/playtests/placement.playtest.json +115 -0
  576. package/templates/{defense → tower-defense}/playtests/pointer-placement.playtest.json +21 -49
  577. package/templates/tower-defense/playtests/strike.playtest.json +98 -0
  578. package/templates/tower-defense/playtests/survives.playtest.json +85 -0
  579. package/templates/tower-defense/playtests/target-priority.playtest.json +177 -0
  580. package/templates/tower-defense/playtests/upgrade-recycle.playtest.json +124 -0
  581. package/templates/tower-defense/playtests/victory.playtest.json +810 -0
  582. package/templates/tower-defense/src/balance.ts +187 -0
  583. package/templates/tower-defense/src/board/Board.ts +100 -0
  584. package/templates/tower-defense/src/board/Route.ts +84 -0
  585. package/templates/tower-defense/src/camera-rig.ts +62 -0
  586. package/templates/tower-defense/src/economy.ts +64 -0
  587. package/templates/tower-defense/src/effects/Effects.ts +284 -0
  588. package/templates/tower-defense/src/enemies/Enemy.ts +198 -0
  589. package/templates/tower-defense/src/game.ts +72 -0
  590. package/templates/tower-defense/src/intents.ts +21 -0
  591. package/templates/tower-defense/src/main.ts +15 -0
  592. package/templates/tower-defense/src/physics.ts +6 -0
  593. package/templates/tower-defense/src/render/camera.ts +38 -0
  594. package/templates/tower-defense/src/render/lighting.ts +42 -0
  595. package/templates/{defense → tower-defense}/src/render/loading.ts +3 -3
  596. package/templates/tower-defense/src/render/materials.ts +103 -0
  597. package/templates/tower-defense/src/render/palette.ts +58 -0
  598. package/templates/tower-defense/src/render/postprocessing.ts +46 -0
  599. package/templates/tower-defense/src/render/quality.ts +128 -0
  600. package/templates/tower-defense/src/render/shapes.ts +550 -0
  601. package/templates/tower-defense/src/render/sky.ts +27 -0
  602. package/templates/tower-defense/src/render/worldEnvironment.ts +809 -0
  603. package/templates/tower-defense/src/scenes/Battle.ts +539 -0
  604. package/templates/{shooter → tower-defense}/src/scenes/Boot.ts +3 -3
  605. package/templates/tower-defense/src/state.ts +88 -0
  606. package/templates/tower-defense/src/style.css +137 -0
  607. package/templates/tower-defense/src/towers/Tower.ts +230 -0
  608. package/templates/tower-defense/src/towers/targeting.ts +97 -0
  609. package/templates/tower-defense/src/ui/Hud.tsx +270 -0
  610. package/templates/tower-defense/src/ui/Menu.tsx +134 -0
  611. package/templates/tower-defense/src/ui/icons.tsx +54 -0
  612. package/templates/tower-defense/src/ui/main.tsx +14 -0
  613. package/templates/tower-defense/src/waves.ts +90 -0
  614. package/templates/{defense → tower-defense}/threenative.config.ts +14 -1
  615. package/templates/tower-defense/vite.config.ts +41 -0
  616. package/agent-files/.claude/skills/file-engine-bug/SKILL.md +0 -59
  617. package/agent-files/.claude/skills/ponytail/SKILL.md +0 -68
  618. package/agent-files/.claude/skills/prd-creator/SKILL.md +0 -40
  619. package/agent-files/.claude/skills/threenative-assets/SKILL.md +0 -53
  620. package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +0 -27
  621. package/agent-files/.claude/skills/threenative-context/SKILL.md +0 -65
  622. package/agent-files/.claude/skills/threenative-performance/SKILL.md +0 -58
  623. package/agent-files/.claude/skills/threenative-playtest/SKILL.md +0 -44
  624. package/agent-files/.claude/skills/threenative-ui/SKILL.md +0 -20
  625. package/agent-files/.claude/skills/threenative-visuals/SKILL.md +0 -41
  626. package/agent-files/AGENT-ROLES.md +0 -26
  627. package/templates/action-rpg/src/render/shapes.ts +0 -269
  628. package/templates/action-rpg/src/render/types.ts +0 -3
  629. package/templates/action-rpg/src/scenes/Boot.ts +0 -12
  630. package/templates/defense/README.md +0 -10
  631. package/templates/defense/kit.json +0 -7
  632. package/templates/defense/playtests/leak.playtest.json +0 -23
  633. package/templates/defense/playtests/placement.playtest.json +0 -40
  634. package/templates/defense/playtests/scan.playtest.json +0 -20
  635. package/templates/defense/playtests/survive.playtest.json +0 -45
  636. package/templates/defense/src/attackers/Attacker.ts +0 -120
  637. package/templates/defense/src/board/Route.ts +0 -94
  638. package/templates/defense/src/conventions.ts +0 -18
  639. package/templates/defense/src/economy.ts +0 -36
  640. package/templates/defense/src/entities/Player.ts +0 -52
  641. package/templates/defense/src/game.ts +0 -51
  642. package/templates/defense/src/physics.ts +0 -13
  643. package/templates/defense/src/placement/Buildable.ts +0 -49
  644. package/templates/defense/src/render/camera.ts +0 -16
  645. package/templates/defense/src/render/lighting.ts +0 -37
  646. package/templates/defense/src/render/materials.ts +0 -22
  647. package/templates/defense/src/render/palette.ts +0 -28
  648. package/templates/defense/src/render/shapes.ts +0 -246
  649. package/templates/defense/src/render/sky.ts +0 -45
  650. package/templates/defense/src/scenes/Defense.ts +0 -231
  651. package/templates/defense/src/state.ts +0 -56
  652. package/templates/defense/src/towers/Tower.ts +0 -95
  653. package/templates/defense/src/towers/targeting.ts +0 -53
  654. package/templates/defense/src/ui/Hud.tsx +0 -62
  655. package/templates/defense/src/ui/Menu.tsx +0 -7
  656. package/templates/defense/src/waves.ts +0 -40
  657. package/templates/minimal/playtests/atmosphere.playtest.json +0 -32
  658. package/templates/minimal/src/render/hud.ts +0 -69
  659. package/templates/platformer/playtests/avoidance.playtest.json +0 -28
  660. package/templates/platformer/playtests/chase.playtest.json +0 -21
  661. package/templates/platformer/playtests/collision-layers.playtest.json +0 -36
  662. package/templates/platformer/playtests/oneway.playtest.json +0 -44
  663. package/templates/platformer/playtests/patrol.playtest.json +0 -13
  664. package/templates/platformer/playtests/physics.playtest.json +0 -14
  665. package/templates/platformer/playtests/stomp-rise.playtest.json +0 -55
  666. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +0 -41
  667. package/templates/platformer/playtests/terminal-loop-win.playtest.json +0 -52
  668. package/templates/platformer/src/conventions.ts +0 -18
  669. package/templates/platformer/src/entities/Character.ts +0 -286
  670. package/templates/platformer/src/entities/Chaser.ts +0 -118
  671. package/templates/platformer/src/entities/Patrol.ts +0 -93
  672. package/templates/platformer/src/level/Platform.ts +0 -46
  673. package/templates/platformer/src/render/rig.ts +0 -60
  674. package/templates/platformer/src/render/terrain.ts +0 -31
  675. package/templates/platformer/src/scenes/Level.ts +0 -241
  676. package/templates/puzzle/README.md +0 -43
  677. package/templates/puzzle/playtests/carry.playtest.json +0 -71
  678. package/templates/puzzle/playtests/swing.playtest.json +0 -38
  679. package/templates/puzzle/src/conventions.ts +0 -25
  680. package/templates/puzzle/src/entities/Ball.ts +0 -70
  681. package/templates/puzzle/src/entities/Gripper.ts +0 -69
  682. package/templates/puzzle/src/entities/Pendulum.ts +0 -89
  683. package/templates/puzzle/src/physics.ts +0 -19
  684. package/templates/puzzle/src/room.ts +0 -83
  685. package/templates/puzzle/src/scenes/Boot.ts +0 -12
  686. package/templates/puzzle/src/scenes/Puzzle.ts +0 -158
  687. package/templates/shooter/playtests/combat.playtest.json +0 -48
  688. package/templates/shooter/playtests/fail.playtest.json +0 -31
  689. package/templates/shooter/playtests/per-item.playtest.json +0 -59
  690. package/templates/shooter/playtests/shooter.playtest.json +0 -99
  691. package/templates/shooter/playtests/touch-controls.playtest.json +0 -42
  692. package/templates/shooter/playtests/weapon-cycle.playtest.json +0 -164
  693. package/templates/shooter/src/combat/damage.ts +0 -40
  694. package/templates/shooter/src/conventions.ts +0 -51
  695. package/templates/shooter/src/entities/Pickup.ts +0 -70
  696. package/templates/shooter/src/entities/Player.ts +0 -310
  697. package/templates/shooter/src/level/SpawnPoints.ts +0 -28
  698. package/templates/shooter/src/playtest-events.ts +0 -15
  699. package/templates/shooter/src/render/touch-controls.ts +0 -305
  700. package/templates/shooter/src/render/types.ts +0 -3
  701. package/templates/shooter/src/render/ui.css +0 -330
  702. package/templates/shooter/src/render/ui.ts +0 -75
  703. package/templates/shooter/src/render/vfx.ts +0 -215
  704. package/templates/shooter/src/ui/Menu.tsx +0 -41
  705. package/templates/shooter/src/waves.ts +0 -50
  706. package/templates/shooter/src/weapons/Hitscan.ts +0 -42
  707. package/templates/shooter/src/weapons/Projectile.ts +0 -92
  708. package/templates/shooter/src/weapons/Viewmodel.ts +0 -275
  709. package/templates/starter/playtests/assets.playtest.json +0 -65
  710. package/templates/starter/playtests/buffer.playtest.json +0 -79
  711. package/templates/starter/playtests/cloth.playtest.json +0 -113
  712. package/templates/starter/playtests/coyote.playtest.json +0 -87
  713. package/templates/starter/playtests/gameover.playtest.json +0 -66
  714. package/templates/starter/playtests/goal.playtest.json +0 -67
  715. package/templates/starter/playtests/look.playtest.json +0 -175
  716. package/templates/starter/playtests/models-baseline.png +0 -0
  717. package/templates/starter/playtests/models.playtest.json +0 -74
  718. package/templates/starter/playtests/monitoring.playtest.json +0 -72
  719. package/templates/starter/playtests/odometer.playtest.json +0 -54
  720. package/templates/starter/playtests/restart.playtest.json +0 -91
  721. package/templates/starter/playtests/seed.playtest.json +0 -54
  722. package/templates/starter/playtests/textures-baseline.png +0 -0
  723. package/templates/starter/playtests/textures.playtest.json +0 -74
  724. package/templates/starter/playtests/touch-controls.playtest.json +0 -42
  725. package/templates/starter/playtests/zoom-pinch.playtest.json +0 -86
  726. package/templates/starter/playtests/zoom-wheel.playtest.json +0 -59
  727. package/templates/starter/src/render/coast.ts +0 -199
  728. package/templates/starter/src/render/hero.ts +0 -88
  729. package/templates/starter/src/render/implicitSurface.ts +0 -199
  730. package/templates/starter/src/render/kuwahara.ts +0 -174
  731. package/templates/starter/src/render/outline.ts +0 -141
  732. package/templates/starter/src/render/painterly.ts +0 -86
  733. package/templates/starter/src/render/rockRidge.ts +0 -198
  734. package/templates/starter/src/render/rockRidge.worker.ts +0 -77
  735. package/templates/starter/src/render/scenery.ts +0 -40
  736. package/templates/starter/src/render/textureLifetime.ts +0 -53
  737. package/templates/starter/src/render/water.ts +0 -38
  738. package/templates/starter/src/render/watercolor.ts +0 -85
  739. /package/templates/{starter → puzzle}/playtests/boot-failure.playtest.json +0 -0
  740. /package/templates/{starter → puzzle}/playtests/pause.playtest.json +0 -0
  741. /package/templates/{defense → rain}/.codex/config.toml +0 -0
  742. /package/templates/{defense → rain}/.cursor/mcp.json +0 -0
  743. /package/templates/{defense → rain}/.gemini/settings.json +0 -0
  744. /package/templates/{defense → rain}/.mcp.json +0 -0
  745. /package/templates/{defense → rain}/.vscode/mcp.json +0 -0
  746. /package/templates/{defense → rain}/.zed/settings.json +0 -0
  747. /package/templates/{defense → rain}/opencode.json +0 -0
  748. /package/templates/{defense → rain}/src/main.ts +0 -0
  749. /package/templates/{defense → rts}/index.html +0 -0
  750. /package/templates/{defense → rts}/src/ui/main.tsx +0 -0
  751. /package/templates/{defense → tower-defense}/public/favicon.svg +0 -0
  752. /package/templates/{defense → tower-defense}/src/playtest-events.ts +0 -0
  753. /package/templates/{defense → tower-defense}/src/ui/App.tsx +0 -0
  754. /package/templates/{defense → tower-defense}/src/ui/GameUi.tsx +0 -0
  755. /package/templates/{defense → tower-defense}/tailwind.config.ts +0 -0
  756. /package/templates/{defense → tower-defense}/tsconfig.json +0 -0
@@ -0,0 +1,1373 @@
1
+ // Bayview's building faces. `town.ts` owns where the blocks stand; this file
2
+ // owns what a wall looks like once you are standing in front of it.
3
+ //
4
+ // The reference frames are not white boxes with blue rectangles painted on
5
+ // them. Every opening is a hole with thickness: a near-black reveal sunk into
6
+ // the wall, a proud stone surround (jambs, lintel, sill) around it, and the
7
+ // leaf sitting well back behind that surround so the sun cuts a hard line down
8
+ // one jamb. Three extra boxes per opening buy all of it, and the shadow in the
9
+ // reveal is most of the effect — a door drawn flush on the plaster reads as a
10
+ // decal from every angle a player can reach.
11
+ //
12
+ // Four rules this file lives under:
13
+ //
14
+ // 1. `CanvasTexture` samples BLACK under `WebGPURenderer`, so nothing here is
15
+ // ever painted procedurally. Corrugated roller doors are modelled as real
16
+ // ribs, the painted dado is a real proud band, and variety comes from
17
+ // alternating palette entries.
18
+ // 2. Determinism: every placement is driven by `hash(seed)`, never
19
+ // `Math.random()`, so a replay renders identically.
20
+ // 3. Budget: facade detail multiplies by ~50 lane faces. Every piece is
21
+ // accumulated into a `FacadeBatch` and merged into ONE mesh per material at
22
+ // the end, so the whole town's joinery costs tens of draw calls rather than
23
+ // the ~900 individual meshes it would otherwise be.
24
+ // 4. Dressing never gets a collider. The batch's meshes go into `hittable`
25
+ // (a bullet stops on a door, as before) but no `TownCollider` is emitted
26
+ // for any of it — a proud window sill must never be something a player
27
+ // snags on.
28
+ //
29
+ // The one thing here that is not dressing is `addArchGateway`: the round-headed
30
+ // passages through a building are the most identity-bearing piece of
31
+ // architecture in the reference set, so those are real solids with real
32
+ // colliders on their piers and on the mass over the opening.
33
+ import {
34
+ BoxGeometry,
35
+ type BufferGeometry,
36
+ CylinderGeometry,
37
+ ExtrudeGeometry,
38
+ Float32BufferAttribute,
39
+ type Group,
40
+ type Material,
41
+ Matrix4,
42
+ Mesh,
43
+ MeshStandardMaterial,
44
+ Path,
45
+ Shape,
46
+ ShapeGeometry,
47
+ } from "three";
48
+ import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
49
+ import { worldGridUVs } from "./materials.js";
50
+ import { roundedBox } from "./shapes.js";
51
+ import type { TownCollider } from "./town.js";
52
+ import type { TownMaterials } from "./townMaterials.js";
53
+
54
+ export type Face = "n" | "s" | "e" | "w";
55
+
56
+ export const FACE_NORMAL: Record<Face, readonly [number, number]> = {
57
+ n: [0, -1],
58
+ s: [0, 1],
59
+ e: [1, 0],
60
+ w: [-1, 0],
61
+ };
62
+ export const FACE_INDEX: Record<Face, number> = { n: 0, s: 1, e: 2, w: 3 };
63
+
64
+ /** Deterministic layout hash: identical across runs, so replays match. */
65
+ const hash = (n: number): number => {
66
+ const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;
67
+ return s - Math.floor(s);
68
+ };
69
+
70
+ /**
71
+ * The part of a building this file needs. Structurally satisfied by `town.ts`'s
72
+ * `BuildingSpec`, which carries the layout fields as well.
73
+ */
74
+ export type FacadeSpec = {
75
+ readonly x: readonly [number, number];
76
+ readonly z: readonly [number, number];
77
+ readonly h: number;
78
+ readonly brick?: boolean;
79
+ readonly tank?: boolean;
80
+ readonly mast?: boolean;
81
+ readonly ac?: boolean;
82
+ readonly top?: { readonly i: number; readonly h: number };
83
+ };
84
+
85
+ /** Ground-floor door leaf, and the standard window light. */
86
+ export const DOOR = { w: 1.18, h: 2.35, d: 0.07 };
87
+ export const WINDOW = { w: 0.92, h: 1.3 };
88
+
89
+ /** How far a surround stands proud of the plaster: this is the shadow line. */
90
+ const RELIEF = 0.22;
91
+ /** Width of a jamb batten either side of an opening. */
92
+ const JAMB = 0.15;
93
+ /** Depth of the reveal panel's front face; everything that fills an opening
94
+ * sits in front of this and behind `RELIEF`, so it is genuinely recessed. */
95
+ const REVEAL_FACE = 0.07;
96
+ /** Floor-to-floor height, so upper windows line up storey by storey. */
97
+ const STOREY = 3.05;
98
+
99
+ /**
100
+ * `townMaterials.ts` is owned elsewhere; a corrugated-steel material may or may
101
+ * not exist there yet. Read it through this widening so the code compiles
102
+ * either way and picks the real thing up the moment it lands.
103
+ */
104
+ type WithRoller = TownMaterials & { readonly rollerSteel?: Material };
105
+
106
+ /**
107
+ * Materials that belong to the facade rather than to the town's surfaces:
108
+ * untextured, palette-driven, and built per scene so a `ctx.goto` rebuild never
109
+ * hands the new scene a disposed material.
110
+ */
111
+ type FacadeMaterials = {
112
+ /** Near-black interior of every reveal; this is what sells the depth. */
113
+ readonly reveal: Material;
114
+ /** Wrought iron: balusters, window grilles, drainpipes, lamp brackets. */
115
+ readonly iron: Material;
116
+ /** The bulb inside a wall lamp. */
117
+ readonly lampGlow: Material;
118
+ /** Painted blue-grey dado along the foot of a lane wall. */
119
+ readonly dado: Material;
120
+ /** Weathered timber: double doors, awning frames, header boards. */
121
+ readonly timber: Material;
122
+ /** Sun-bleached stone: sills, steps, coping courses. */
123
+ readonly stone: Material;
124
+ /** Corrugated roller shutters — the town's own steel when it exists. */
125
+ readonly roller: Material;
126
+ /** Window glass: dark, but a mirror of the sky rather than a hole. */
127
+ readonly glass: Material;
128
+ };
129
+
130
+ function createFacadeMaterials(materials: TownMaterials): FacadeMaterials {
131
+ return {
132
+ // Not pure black: a dead-black hole reads as a missing polygon. This sits
133
+ // roughly two stops under the deepest plaster shadow, which is where an
134
+ // unlit room behind an unglazed opening actually lands.
135
+ reveal: new MeshStandardMaterial({ color: 0x322b24, roughness: 0.96 }),
136
+ // Dark enough to read as ironwork against whitewash, light enough that a
137
+ // downpipe does not become a black bar down the middle of a wall.
138
+ iron: new MeshStandardMaterial({ color: 0x484e55, roughness: 0.5, metalness: 0.45 }),
139
+ lampGlow: new MeshStandardMaterial({
140
+ color: 0xffe6b8,
141
+ emissive: 0xffbe62,
142
+ emissiveIntensity: 1.9,
143
+ roughness: 0.35,
144
+ }),
145
+ // The dado is painted render, not plastic: it reads `dadoBand` from
146
+ // townMaterials, world-projected off the same field as the wall behind it.
147
+ dado: materials.dadoBand,
148
+ timber: new MeshStandardMaterial({ color: 0x6d4c33, roughness: 0.82, metalness: 0.03 }),
149
+ stone: new MeshStandardMaterial({ color: 0xded6c4, roughness: 0.9, metalness: 0.01 }),
150
+ roller: (materials as WithRoller).rollerSteel ?? materials.shutter,
151
+ // An unglazed opening renders as a flat black rectangle, which reads as a
152
+ // hole punched in card rather than as a window. Low roughness and some
153
+ // metalness make the pane pick up the sky gradient instead, so the opening
154
+ // has a value inside it even in full shade.
155
+ glass: new MeshStandardMaterial({
156
+ color: 0x2f4250,
157
+ roughness: 0.16,
158
+ metalness: 0.55,
159
+ }),
160
+ };
161
+ }
162
+
163
+ /**
164
+ * Accumulates every facade piece by material and merges each bucket into a
165
+ * single mesh. ~900 small meshes collapse into ~30 draw calls; the cost is that
166
+ * a merged mesh is town-wide and so never frustum-culled, which is the right
167
+ * trade at this triangle count — draw calls are the budget here, not triangles.
168
+ */
169
+ class FacadeBatch {
170
+ private readonly solid = new Map<Material, BufferGeometry[]>();
171
+ private readonly loose = new Map<Material, BufferGeometry[]>();
172
+
173
+ /** `hit` puts the piece in the raycast set: doors stop bullets, trim does not. */
174
+ push(material: Material, geometry: BufferGeometry, hit: boolean): void {
175
+ const bucket = hit ? this.solid : this.loose;
176
+ const existing = bucket.get(material);
177
+ if (existing === undefined) bucket.set(material, [geometry]);
178
+ else existing.push(geometry);
179
+ }
180
+
181
+ flush(group: Group, hittable: Mesh[]): void {
182
+ for (const [material, geometries] of this.solid) {
183
+ const mesh = merge(material, geometries, "facade-solid");
184
+ if (mesh === undefined) continue;
185
+ group.add(mesh);
186
+ hittable.push(mesh);
187
+ }
188
+ for (const [material, geometries] of this.loose) {
189
+ const mesh = merge(material, geometries, "facade-trim");
190
+ if (mesh === undefined) continue;
191
+ group.add(mesh);
192
+ }
193
+ this.solid.clear();
194
+ this.loose.clear();
195
+ }
196
+ }
197
+
198
+ function merge(
199
+ material: Material,
200
+ geometries: readonly BufferGeometry[],
201
+ name: string,
202
+ ): Mesh | undefined {
203
+ if (geometries.length === 0) return undefined;
204
+ // The grid is world-projected, and every piece in this bucket has already been transformed
205
+ // into world space by `put`, so the merged result is where `worldGridUVs` can be honest:
206
+ // one grid tile is one metre on every wall, trim and shutter in the town, however the face
207
+ // was authored and however big the building is.
208
+ const geometry = worldGridUVs(mergeGeometries(geometries as BufferGeometry[], false));
209
+ for (const source of geometries) source.dispose();
210
+ const mesh = new Mesh(geometry, material);
211
+ mesh.name = name;
212
+ mesh.castShadow = true;
213
+ mesh.receiveShadow = true;
214
+ return mesh;
215
+ }
216
+
217
+ /**
218
+ * Merging demands identical attribute sets, and the sources disagree:
219
+ * `roundedBox` deletes its UVs, `ExtrudeGeometry` comes out non-indexed. Bring
220
+ * everything to the same shape — UV-carrying and non-indexed — before it goes
221
+ * into a bucket. The UVs are placeholders: `worldGridUVs` rewrites them from world
222
+ * position once the whole bucket is merged.
223
+ */
224
+ function normalised(source: BufferGeometry): BufferGeometry {
225
+ const geometry = source.clone();
226
+ if (!geometry.hasAttribute("uv")) {
227
+ const count = geometry.getAttribute("position").count;
228
+ geometry.setAttribute("uv", new Float32BufferAttribute(new Float32Array(count * 2), 2));
229
+ }
230
+ return geometry.index === null ? geometry : geometry.toNonIndexed();
231
+ }
232
+
233
+ export type Facade = {
234
+ readonly group: Group;
235
+ readonly hittable: Mesh[];
236
+ readonly colliders: TownCollider[];
237
+ readonly materials: TownMaterials;
238
+ readonly extra: FacadeMaterials;
239
+ readonly batch: FacadeBatch;
240
+ /** Every block in town, so a face can be tested for being on show. */
241
+ readonly blocks: readonly FacadeSpec[];
242
+ };
243
+
244
+ export function createFacade(
245
+ group: Group,
246
+ hittable: Mesh[],
247
+ colliders: TownCollider[],
248
+ materials: TownMaterials,
249
+ blocks: readonly FacadeSpec[],
250
+ ): Facade {
251
+ return {
252
+ group,
253
+ hittable,
254
+ colliders,
255
+ materials,
256
+ extra: createFacadeMaterials(materials),
257
+ batch: new FacadeBatch(),
258
+ blocks,
259
+ };
260
+ }
261
+
262
+ /** Half the playable deck; a face out here looks out of the world. See TOWN_HALF. */
263
+ const MAP_HALF = 42;
264
+
265
+ /**
266
+ * Which faces of a block a player can actually see.
267
+ *
268
+ * The hand-written `j:` lists in `town.ts` name the faces someone judged to be
269
+ * lane-facing, and they miss several walls that a player stands right next to —
270
+ * the whole east side of the T-spawn courtyard was a blank white box because of
271
+ * one absent letter. Rather than second-guess that data, this derives the
272
+ * answer: a face is on show unless a neighbouring block abuts it along most of
273
+ * its length and stands tall enough to bury it, or unless it faces off the edge
274
+ * of the map. The `j:` list is unioned in, so nothing that was dressed before
275
+ * stops being dressed.
276
+ */
277
+ export function visibleFaces(facade: Facade, spec: FacadeSpec, declared: readonly Face[]): Face[] {
278
+ const faces: Face[] = [];
279
+ for (const face of ["n", "s", "e", "w"] as const) {
280
+ if (declared.includes(face)) {
281
+ faces.push(face);
282
+ continue;
283
+ }
284
+ const [nx, nz] = FACE_NORMAL[face];
285
+ const onX = nx !== 0;
286
+ const plane = onX ? (nx < 0 ? spec.x[0] : spec.x[1]) : nz < 0 ? spec.z[0] : spec.z[1];
287
+ if (Math.abs(plane) >= MAP_HALF - 0.01) continue;
288
+ const from = onX ? spec.z[0] : spec.x[0];
289
+ const to = onX ? spec.z[1] : spec.x[1];
290
+ let buried = 0;
291
+ for (const other of facade.blocks) {
292
+ if (other === spec) continue;
293
+ // Only a block whose own opposing face sits on this plane can bury it.
294
+ const meeting = onX ? (nx < 0 ? other.x[1] : other.x[0]) : nz < 0 ? other.z[1] : other.z[0];
295
+ if (Math.abs(meeting - plane) > 0.06) continue;
296
+ // A neighbour barely more than half this height still leaves wall on show.
297
+ if (other.h < spec.h * 0.6) continue;
298
+ const low = Math.max(from, onX ? other.z[0] : other.x[0]);
299
+ const high = Math.min(to, onX ? other.z[1] : other.x[1]);
300
+ if (high - low > 0.05) buried += high - low;
301
+ }
302
+ if (buried < (to - from) * 0.6) faces.push(face);
303
+ }
304
+ return faces;
305
+ }
306
+
307
+ /** Merge everything collected so far. Call once, at the end of `buildTown`. */
308
+ export function finishFacade(facade: Facade): void {
309
+ facade.batch.flush(facade.group, facade.hittable);
310
+ }
311
+
312
+ // ---------------------------------------------------------------------------
313
+ // Face-local placement
314
+ // ---------------------------------------------------------------------------
315
+
316
+ /**
317
+ * A frame pinned to one building face: local +x runs along the wall, +y is up,
318
+ * +z points out of the wall into the street, and the origin sits on the wall
319
+ * surface at street level. Every opening below is authored in these coordinates
320
+ * and never has to know which compass face it landed on.
321
+ */
322
+ type Wall = {
323
+ readonly matrix: Matrix4;
324
+ /** Face width in metres. */
325
+ readonly span: number;
326
+ readonly seed: number;
327
+ readonly facade: Facade;
328
+ };
329
+
330
+ function wallOf(facade: Facade, spec: FacadeSpec, face: Face, seed: number): Wall {
331
+ const [x0, x1] = spec.x;
332
+ const [z0, z1] = spec.z;
333
+ const [nx, nz] = FACE_NORMAL[face];
334
+ const onX = nx !== 0;
335
+ const px = onX ? (nx < 0 ? x0 : x1) : (x0 + x1) / 2;
336
+ const pz = onX ? (z0 + z1) / 2 : nz < 0 ? z0 : z1;
337
+ const matrix = new Matrix4().makeRotationY(Math.atan2(nx, nz));
338
+ matrix.setPosition(px, 0, pz);
339
+ return { matrix, span: onX ? z1 - z0 : x1 - x0, seed, facade };
340
+ }
341
+
342
+ /** The same wall, lifted to a setback storey's floor. */
343
+ function raise(wall: Wall, y: number): Wall {
344
+ return { ...wall, matrix: new Matrix4().setPosition(0, y, 0).multiply(wall.matrix) };
345
+ }
346
+
347
+ type PutOptions = {
348
+ /** In the raycast set — bullets stop here. Trim and mouldings should not be. */
349
+ readonly hit?: boolean;
350
+ /** Roll about the face normal, for a shutter hanging off its hinge. */
351
+ readonly roll?: number;
352
+ /** Pitch about the wall's own horizontal, for an awning's fall. */
353
+ readonly pitch?: number;
354
+ /** Corner radius; only worth paying for on pieces big enough to read. */
355
+ readonly soft?: number;
356
+ };
357
+
358
+ function place(at: readonly [number, number, number], options: PutOptions): Matrix4 {
359
+ const local = new Matrix4().makeRotationZ(options.roll ?? 0);
360
+ if (options.pitch !== undefined) {
361
+ local.multiply(new Matrix4().makeRotationX(options.pitch));
362
+ }
363
+ local.setPosition(at[0], at[1], at[2]);
364
+ return local;
365
+ }
366
+
367
+ /** One box in wall-local coordinates. */
368
+ function put(
369
+ wall: Wall,
370
+ material: Material,
371
+ size: readonly [number, number, number],
372
+ at: readonly [number, number, number],
373
+ options: PutOptions = {},
374
+ ): void {
375
+ const source =
376
+ options.soft === undefined
377
+ ? new BoxGeometry(size[0], size[1], size[2])
378
+ : roundedBox(size[0], size[1], size[2], options.soft, 2);
379
+ const geometry = normalised(source);
380
+ // `roundedBox` hands back a cached geometry shared with every other caller;
381
+ // only the throwaway boxes are ours to dispose.
382
+ if (options.soft === undefined) source.dispose();
383
+ geometry.applyMatrix4(place(at, options).premultiply(wall.matrix));
384
+ wall.facade.batch.push(material, geometry, options.hit ?? false);
385
+ }
386
+
387
+ /** One cylinder in wall-local coordinates, axis along local +y unless pitched. */
388
+ function putTube(
389
+ wall: Wall,
390
+ material: Material,
391
+ radius: number,
392
+ length: number,
393
+ at: readonly [number, number, number],
394
+ segments = 6,
395
+ pitch = 0,
396
+ ): void {
397
+ const source = new CylinderGeometry(radius, radius, length, segments, 1);
398
+ const geometry = normalised(source);
399
+ source.dispose();
400
+ geometry.applyMatrix4(place(at, { pitch }).premultiply(wall.matrix));
401
+ wall.facade.batch.push(material, geometry, false);
402
+ }
403
+
404
+ // ---------------------------------------------------------------------------
405
+ // The opening: a reveal, a surround, and whatever fills it
406
+ // ---------------------------------------------------------------------------
407
+
408
+ type OpeningOptions = {
409
+ /** Stone sill course under the opening — windows have one, doors do not. */
410
+ readonly sill?: boolean;
411
+ /** Extra depth for the head, so a lintel over a wide opening reads heavier. */
412
+ readonly lintel?: number;
413
+ };
414
+
415
+ /**
416
+ * The boxes that turn a painted rectangle into a hole: a near-black reveal
417
+ * panel oversized past the opening on every side, then jambs and a head
418
+ * standing `RELIEF` proud of the plaster so the sun throws a hard line down one
419
+ * side. Everything that fills an opening goes in front of the reveal face and
420
+ * behind the surround's front, which is what makes it read as set back.
421
+ */
422
+ function addOpening(
423
+ wall: Wall,
424
+ cx: number,
425
+ sillY: number,
426
+ w: number,
427
+ h: number,
428
+ options: OpeningOptions = {},
429
+ ): void {
430
+ const { extra, materials } = wall.facade;
431
+ const trim = materials.plasterTrim;
432
+
433
+ // Reveal: the dark box the opening looks into. Oversized so a hairline of
434
+ // shadow survives at the edges even when the surround is foreshortened.
435
+ put(wall, extra.reveal, [w + 0.09, h + 0.09, REVEAL_FACE], [cx, sillY + h / 2, REVEAL_FACE / 2]);
436
+
437
+ // Jambs either side, standing proud.
438
+ for (const side of [-1, 1]) {
439
+ put(
440
+ wall,
441
+ trim,
442
+ [JAMB, h + 0.16, RELIEF],
443
+ [cx + side * (w / 2 + JAMB / 2 + 0.02), sillY + h / 2 + 0.02, RELIEF / 2],
444
+ );
445
+ }
446
+
447
+ // Head: a lintel across the top, slightly deeper than the jambs so it reads
448
+ // as bearing on them, plus a thin dark course under it for the shadow gap.
449
+ const headDepth = RELIEF + (options.lintel ?? 0.03);
450
+ put(wall, trim, [w + JAMB * 2 + 0.22, 0.19, headDepth], [cx, sillY + h + 0.155, headDepth / 2]);
451
+ put(wall, extra.reveal, [w + 0.09, 0.05, 0.13], [cx, sillY + h + 0.04, 0.065]);
452
+
453
+ if (options.sill === true) {
454
+ // A stone sill projects further than anything else on the wall: it is the
455
+ // horizontal that catches the key light and separates storey from storey.
456
+ const depth = RELIEF + 0.08;
457
+ put(
458
+ wall,
459
+ extra.stone,
460
+ [w + JAMB * 2 + 0.34, 0.12, depth],
461
+ [cx, sillY - 0.06, depth / 2 - 0.01],
462
+ );
463
+ put(wall, trim, [w + JAMB * 2 + 0.2, 0.08, 0.07], [cx, sillY - 0.16, 0.035]);
464
+ }
465
+ }
466
+
467
+ /** Panelled leaves inside an opening: one or two, timber or painted. */
468
+ function addLeaves(
469
+ wall: Wall,
470
+ material: Material,
471
+ cx: number,
472
+ sillY: number,
473
+ w: number,
474
+ h: number,
475
+ leaves: number,
476
+ ): void {
477
+ const { extra } = wall.facade;
478
+ const leafW = (w - (leaves - 1) * 0.04) / leaves;
479
+ const front = 0.075;
480
+ const faceZ = front + DOOR.d / 2;
481
+ for (let leaf = 0; leaf < leaves; leaf += 1) {
482
+ const lx = cx - w / 2 + leafW / 2 + leaf * (leafW + 0.04);
483
+ put(wall, material, [leafW, h, DOOR.d], [lx, sillY + h / 2, front], { hit: true, soft: 0.025 });
484
+ // Raised panels, not sunken black ones. A dark plate on a door reads as a
485
+ // hole straight through it; a panel standing 12 mm proud of the leaf with a
486
+ // shadow line under its head reads as joinery, and costs the same two boxes.
487
+ for (const share of [0.26, 0.73]) {
488
+ put(wall, material, [leafW - 0.2, h * 0.29, 0.014], [lx, sillY + h * share, faceZ + 0.005]);
489
+ put(
490
+ wall,
491
+ extra.reveal,
492
+ [leafW - 0.2, 0.022, 0.016],
493
+ [lx, sillY + h * share + h * 0.145, faceZ + 0.004],
494
+ );
495
+ }
496
+ put(wall, material, [leafW, 0.09, DOOR.d + 0.02], [lx, sillY + h * 0.49, front]);
497
+ // Handle on the meeting stile.
498
+ const inward = leaves === 1 ? 1 : leaf === 0 ? 1 : -1;
499
+ putTube(
500
+ wall,
501
+ extra.iron,
502
+ 0.028,
503
+ 0.12,
504
+ [lx + inward * (leafW / 2 - 0.12), sillY + h * 0.46, faceZ + 0.06],
505
+ 6,
506
+ Math.PI / 2,
507
+ );
508
+ }
509
+ }
510
+
511
+ /** Corrugated roller shutter: real ribs, because a painted one samples black. */
512
+ function addRoller(wall: Wall, cx: number, w: number, h: number): void {
513
+ const { extra, materials } = wall.facade;
514
+ const ribs = Math.max(11, Math.round(w / 0.19));
515
+ const ribW = w / ribs;
516
+ for (let rib = 0; rib < ribs; rib += 1) {
517
+ const proud = rib % 2 === 1;
518
+ put(
519
+ wall,
520
+ extra.roller,
521
+ [ribW * 1.02, h, proud ? 0.09 : 0.05],
522
+ [cx - w / 2 + ribW * (rib + 0.5), h / 2, proud ? 0.09 : 0.075],
523
+ { hit: true },
524
+ );
525
+ }
526
+ // Roller housing above the opening, and the closing rail at the floor.
527
+ put(wall, materials.steelPost, [w + 0.16, 0.24, 0.2], [cx, h + 0.14, 0.11], { soft: 0.05 });
528
+ put(wall, materials.steelPost, [w + 0.04, 0.1, 0.14], [cx, 0.05, 0.09]);
529
+ }
530
+
531
+ /**
532
+ * The sash inside an opening: a painted frame, a mullion, a transom and four
533
+ * panes. Without it the reveal is just a black rectangle — this is the single
534
+ * biggest difference between a window and a hole in the reference frames.
535
+ */
536
+ function addSash(wall: Wall, cx: number, sillY: number, w: number, h: number): void {
537
+ const { extra, materials } = wall.facade;
538
+ // Three boxes, not seven: the reveal already oversizes the opening by 45 mm
539
+ // on every side, so that dark border reads as the outer frame and a modelled
540
+ // one would be hidden behind the jambs. Multiplied by ~700 windows, the four
541
+ // boxes it saves are worth more than the frame nobody can see.
542
+ const front = 0.075;
543
+ put(wall, extra.glass, [w - 0.06, h - 0.06, 0.03], [cx, sillY + h / 2, front]);
544
+ put(wall, materials.shutter, [0.05, h - 0.04, 0.05], [cx, sillY + h / 2, front + 0.014]);
545
+ put(wall, materials.shutter, [w - 0.06, 0.05, 0.05], [cx, sillY + h * 0.52, front + 0.014]);
546
+ }
547
+
548
+ type WindowKind = "shuttersOpen" | "shuttersShut" | "dark" | "grille" | "broken";
549
+
550
+ function windowKind(seed: number): WindowKind {
551
+ const roll = hash(seed);
552
+ if (roll < 0.32) return "shuttersOpen";
553
+ if (roll < 0.53) return "shuttersShut";
554
+ if (roll < 0.74) return "dark";
555
+ if (roll < 0.9) return "grille";
556
+ return "broken";
557
+ }
558
+
559
+ /**
560
+ * A window: sill, lintel, and one of five deterministic fills. The dark ones
561
+ * matter as much as the shuttered ones — the reference facades are mostly
562
+ * unglazed holes, and a wall of identical blue shutters reads as wallpaper.
563
+ */
564
+ function addWindow(wall: Wall, cx: number, sillY: number, seed: number): void {
565
+ const { extra, materials } = wall.facade;
566
+ const w = WINDOW.w;
567
+ const h = WINDOW.h;
568
+ addOpening(wall, cx, sillY, w, h, { sill: true });
569
+
570
+ const kind = windowKind(seed);
571
+ const leafW = w / 2 - 0.02;
572
+ // Everything except a genuinely empty opening is glazed.
573
+ if (kind !== "dark") addSash(wall, cx, sillY, w, h);
574
+ switch (kind) {
575
+ case "shuttersOpen":
576
+ case "broken": {
577
+ // Folded flat against the wall outside the jambs, where they throw their
578
+ // own shadow across the plaster.
579
+ const foldX = w / 2 + JAMB + leafW / 2 + 0.03;
580
+ const hanging = kind === "broken";
581
+ for (const side of [-1, 1]) {
582
+ if (hanging && side > 0 && hash(seed + 3) > 0.5) continue; // one gone entirely
583
+ const roll = hanging && side < 0 ? side * 0.17 : 0;
584
+ put(
585
+ wall,
586
+ materials.shutter,
587
+ [leafW, h * 0.98, 0.05],
588
+ [cx + side * foldX, sillY + h / 2, 0.105],
589
+ {
590
+ hit: true,
591
+ roll,
592
+ },
593
+ );
594
+ for (const share of [0.32, 0.68]) {
595
+ put(
596
+ wall,
597
+ extra.reveal,
598
+ [leafW - 0.08, 0.022, 0.012],
599
+ [cx + side * foldX, sillY + h * share, 0.136],
600
+ { roll },
601
+ );
602
+ }
603
+ }
604
+ break;
605
+ }
606
+ case "shuttersShut":
607
+ for (const side of [-1, 1]) {
608
+ const lx = cx + side * (leafW / 2 + 0.015);
609
+ put(wall, materials.shutter, [leafW, h * 0.98, 0.05], [lx, sillY + h / 2, 0.105], {
610
+ hit: true,
611
+ });
612
+ for (const share of [0.28, 0.52, 0.76]) {
613
+ put(wall, extra.reveal, [leafW - 0.07, 0.022, 0.012], [lx, sillY + h * share, 0.136]);
614
+ }
615
+ }
616
+ break;
617
+ case "grille":
618
+ for (let bar = 0; bar < 4; bar += 1) {
619
+ putTube(wall, extra.iron, 0.017, h - 0.06, [
620
+ cx - w / 2 + (w * (bar + 0.5)) / 4,
621
+ sillY + h / 2,
622
+ 0.1,
623
+ ]);
624
+ }
625
+ put(wall, extra.iron, [w - 0.04, 0.028, 0.028], [cx, sillY + h * 0.55, 0.1]);
626
+ break;
627
+ case "dark":
628
+ // Deliberately unglazed, the way half the openings in the references are:
629
+ // a broken-out frame around a dark room, with the sash gone.
630
+ for (const side of [-1, 1]) {
631
+ put(
632
+ wall,
633
+ materials.shutter,
634
+ [0.06, h, 0.05],
635
+ [cx + side * (w / 2 - 0.03), sillY + h / 2, 0.085],
636
+ );
637
+ }
638
+ put(wall, materials.shutter, [w, 0.055, 0.05], [cx, sillY + h - 0.03, 0.085]);
639
+ put(wall, extra.stone, [w, 0.05, 0.06], [cx, sillY + 0.02, 0.09]);
640
+ break;
641
+ }
642
+ }
643
+
644
+ /** A door: reveal, surround, a stone step out into the lane, and its leaves. */
645
+ function addDoor(wall: Wall, cx: number, seed: number): void {
646
+ const { extra, materials } = wall.facade;
647
+ const wide = hash(seed + 61) > 0.62;
648
+ const w = wide ? DOOR.w * 1.7 : DOOR.w;
649
+ const h = wide ? DOOR.h * 1.06 : DOOR.h;
650
+ addOpening(wall, cx, 0.05, w, h, { lintel: 0.05 });
651
+
652
+ // Two shallow stone steps ground the door in the street.
653
+ put(wall, extra.stone, [w + 0.7, 0.11, 0.5], [cx, 0.055, 0.22]);
654
+ put(wall, extra.stone, [w + 0.42, 0.06, 0.32], [cx, 0.14, 0.15]);
655
+
656
+ const timber = hash(seed + 23) > 0.62;
657
+ addLeaves(
658
+ wall,
659
+ timber ? extra.timber : materials.doorBlue,
660
+ cx,
661
+ 0.05,
662
+ w,
663
+ h,
664
+ wide || hash(seed + 29) > 0.45 ? 2 : 1,
665
+ );
666
+
667
+ // A fanlight over some doors: a small dark light under the lintel.
668
+ if (hash(seed + 31) > 0.6) {
669
+ put(wall, extra.reveal, [w - 0.12, 0.26, 0.04], [cx, h + 0.03, REVEAL_FACE / 2]);
670
+ put(wall, materials.shutter, [w - 0.12, 0.035, 0.05], [cx, h + 0.03, 0.09]);
671
+ }
672
+ }
673
+
674
+ /**
675
+ * Wall lamp: a bent iron bracket, a shade and a bulb. The CONNECTOR and CATWALK
676
+ * reference frames both have one, and at this scale it costs four boxes for a
677
+ * warm point of interest in a wall of white.
678
+ */
679
+ function addWallLamp(wall: Wall, cx: number, y: number): void {
680
+ const { extra } = wall.facade;
681
+ put(wall, extra.iron, [0.05, 0.05, 0.3], [cx, y, 0.15]);
682
+ put(wall, extra.iron, [0.05, 0.18, 0.05], [cx, y - 0.09, 0.27]);
683
+ put(wall, extra.iron, [0.28, 0.07, 0.28], [cx, y - 0.21, 0.27], { soft: 0.03 });
684
+ put(wall, extra.lampGlow, [0.16, 0.16, 0.16], [cx, y - 0.3, 0.27], { soft: 0.06 });
685
+ }
686
+
687
+ /** Cast-iron downpipe from a hopper at the parapet to a gully at the pavement. */
688
+ function addDrainpipe(wall: Wall, cx: number, height: number): void {
689
+ const { extra } = wall.facade;
690
+ putTube(wall, extra.iron, 0.055, height - 0.25, [cx, (height - 0.25) / 2, 0.085], 6);
691
+ for (const y of [0.9, height * 0.55, height - 0.85]) {
692
+ put(wall, extra.iron, [0.17, 0.05, 0.05], [cx, y, 0.055]);
693
+ }
694
+ put(wall, extra.iron, [0.21, 0.26, 0.17], [cx, height - 0.2, 0.09], { soft: 0.03 });
695
+ }
696
+
697
+ /** Air-con box on a bracket, the way every upper wall in the references has one. */
698
+ function addWallUnit(wall: Wall, cx: number, y: number): void {
699
+ const { extra, materials } = wall.facade;
700
+ put(wall, materials.steelPost, [0.72, 0.5, 0.34], [cx, y, 0.2], { soft: 0.04 });
701
+ for (let slat = 0; slat < 4; slat += 1) {
702
+ put(wall, extra.reveal, [0.6, 0.03, 0.02], [cx, y - 0.16 + slat * 0.1, 0.375]);
703
+ }
704
+ for (const side of [-1, 1]) {
705
+ put(wall, extra.iron, [0.05, 0.05, 0.2], [cx + side * 0.3, y - 0.28, 0.11]);
706
+ }
707
+ }
708
+
709
+ /** Satellite dish: a tilted disc on a short arm, cheap and very legible. */
710
+ function addDish(wall: Wall, cx: number, y: number): void {
711
+ const { extra, materials } = wall.facade;
712
+ put(wall, extra.iron, [0.05, 0.05, 0.26], [cx, y, 0.13]);
713
+ putTube(wall, materials.plasterTrim, 0.3, 0.06, [cx, y + 0.08, 0.3], 12, Math.PI / 2 - 0.5);
714
+ put(wall, extra.iron, [0.04, 0.17, 0.04], [cx, y + 0.02, 0.43]);
715
+ }
716
+
717
+ /**
718
+ * Painted dado along the foot of a lane wall. Every ground-level wall in the
719
+ * CT SPAWN and T MAIN frames carries one, and it is the single cheapest thing
720
+ * that stops a white block reading as a white block. `gap` leaves a stretch
721
+ * unpainted, for a wall with a passage through it.
722
+ */
723
+ function addDado(wall: Wall, span: number, gap?: readonly [number, number]): void {
724
+ const { extra } = wall.facade;
725
+ const height = 1.22 + hash(wall.seed + 91) * 0.16;
726
+ const runs: readonly (readonly [number, number])[] =
727
+ gap === undefined
728
+ ? [[-span / 2 + 0.03, span / 2 - 0.03]]
729
+ : [
730
+ [-span / 2 + 0.03, gap[0]],
731
+ [gap[1], span / 2 - 0.03],
732
+ ];
733
+ for (const [from, to] of runs) {
734
+ const width = to - from;
735
+ if (width < 0.2) continue;
736
+ put(wall, extra.dado, [width, height, 0.035], [(from + to) / 2, height / 2, 0.018]);
737
+ // Capping batten: a hard line where paint meets plaster, with a shadow
738
+ // under it. Without this the band reads as a flat sticker.
739
+ put(wall, extra.stone, [width, 0.07, 0.06], [(from + to) / 2, height + 0.02, 0.03]);
740
+ }
741
+ }
742
+
743
+ // ---------------------------------------------------------------------------
744
+ // Arches
745
+ // ---------------------------------------------------------------------------
746
+
747
+ /**
748
+ * A round-headed arch outline: straight jambs to the springing line, then a
749
+ * semicircular head. Closed at the base, so an outer outline with an inner one
750
+ * punched out of it yields two proud jambs plus the arch band — an archivolt —
751
+ * in a single extrusion.
752
+ */
753
+ function archOutline(radius: number, springing: number, into: Shape | Path): void {
754
+ into.moveTo(-radius, 0);
755
+ into.lineTo(-radius, springing);
756
+ into.absarc(0, springing, radius, Math.PI, 0, true);
757
+ into.lineTo(radius, 0);
758
+ into.closePath();
759
+ }
760
+
761
+ function archShape(radius: number, springing: number): Shape {
762
+ const shape = new Shape();
763
+ archOutline(radius, springing, shape);
764
+ return shape;
765
+ }
766
+
767
+ function archHole(radius: number, springing: number): Path {
768
+ const path = new Path();
769
+ archOutline(radius, springing, path);
770
+ return path;
771
+ }
772
+
773
+ /** The proud moulded band that follows an arch's jambs and head. */
774
+ function addArchivolt(
775
+ wall: Wall,
776
+ cx: number,
777
+ radius: number,
778
+ springing: number,
779
+ width: number,
780
+ depth: number,
781
+ material: Material,
782
+ ): void {
783
+ const band = archShape(radius + width, springing);
784
+ band.holes.push(archHole(radius, springing));
785
+ const ring = normalised(
786
+ new ExtrudeGeometry(band, { depth, bevelEnabled: false, curveSegments: 14 }),
787
+ );
788
+ ring.applyMatrix4(new Matrix4().setPosition(cx, 0, 0).premultiply(wall.matrix));
789
+ wall.facade.batch.push(material, ring, false);
790
+ }
791
+
792
+ /**
793
+ * A blind arched recess in a wall: the arcade motif without touching
794
+ * navigation. Reads as an arched passage from any distance a player stands at,
795
+ * and costs one shape, one ring and two boxes.
796
+ */
797
+ function addArchNiche(wall: Wall, cx: number, width: number, height: number): void {
798
+ const { extra, materials } = wall.facade;
799
+ const radius = width / 2;
800
+ const springing = Math.max(0.7, height - radius);
801
+
802
+ const back = normalised(new ShapeGeometry(archShape(radius, springing), 14));
803
+ back.applyMatrix4(new Matrix4().setPosition(cx, 0, 0.05).premultiply(wall.matrix));
804
+ wall.facade.batch.push(extra.reveal, back, false);
805
+
806
+ addArchivolt(wall, cx, radius, springing, 0.17, RELIEF, materials.plasterTrim);
807
+ put(wall, extra.stone, [0.3, 0.34, RELIEF + 0.05], [cx, springing + radius - 0.02, RELIEF / 2]);
808
+ put(wall, extra.stone, [width + 0.3, 0.09, 0.5], [cx, 0.045, 0.22]);
809
+ }
810
+
811
+ export type ArchGateway = {
812
+ readonly x: readonly [number, number];
813
+ readonly z: readonly [number, number];
814
+ readonly height: number;
815
+ /** Axis the wall face spans: "x" for a wall seen from ±z, "z" for ±x. */
816
+ readonly along: "x" | "z";
817
+ readonly openWidth: number;
818
+ readonly openHeight: number;
819
+ };
820
+
821
+ /**
822
+ * A real round-headed passage through a building — the CONNECTOR frame, and the
823
+ * single most identity-bearing thing in the reference set. Unlike everything
824
+ * else in this file it is a solid: the two piers and the mass over the opening
825
+ * get colliders, the opening itself does not, so a player and a soldier both
826
+ * walk straight through it. The extrusion's hole walls become the intrados, so
827
+ * the passage is genuinely vaulted rather than a hole in a card.
828
+ */
829
+ export function addArchGateway(facade: Facade, options: ArchGateway): void {
830
+ const { materials, extra } = facade;
831
+ const [x0, x1] = options.x;
832
+ const [z0, z1] = options.z;
833
+ const cx = (x0 + x1) / 2;
834
+ const cz = (z0 + z1) / 2;
835
+ const alongX = options.along === "x";
836
+ const span = alongX ? x1 - x0 : z1 - z0;
837
+ const thickness = alongX ? z1 - z0 : x1 - x0;
838
+ const height = options.height;
839
+ const radius = options.openWidth / 2;
840
+ const springing = options.openHeight - radius;
841
+
842
+ const wallShape = new Shape();
843
+ wallShape.moveTo(-span / 2, 0);
844
+ wallShape.lineTo(span / 2, 0);
845
+ wallShape.lineTo(span / 2, height);
846
+ wallShape.lineTo(-span / 2, height);
847
+ wallShape.closePath();
848
+ wallShape.holes.push(archHole(radius, springing));
849
+ const pierced = new ExtrudeGeometry(wallShape, {
850
+ depth: thickness,
851
+ bevelEnabled: false,
852
+ curveSegments: 16,
853
+ });
854
+ // ExtrudeGeometry lays UVs out in world metres; the plaster variants tile
855
+ // every 5 m, so scale them to match the buildings either side.
856
+ const uv = pierced.getAttribute("uv");
857
+ for (let index = 0; index < uv.count; index += 1) {
858
+ uv.setXY(index, uv.getX(index) * 0.2, uv.getY(index) * 0.2);
859
+ }
860
+ uv.needsUpdate = true;
861
+ const frame = new Matrix4().makeRotationY(alongX ? 0 : Math.PI / 2);
862
+ frame.setPosition(alongX ? cx : x0, 0, alongX ? z0 : cz);
863
+ pierced.applyMatrix4(frame);
864
+ const mesh = new Mesh(pierced, materials.plaster(5));
865
+ mesh.name = "arch-gateway";
866
+ mesh.castShadow = true;
867
+ mesh.receiveShadow = true;
868
+ facade.group.add(mesh);
869
+ facade.hittable.push(mesh);
870
+
871
+ // Colliders: the two piers full height, and the mass over the opening from
872
+ // the crown up. Nothing across the passage itself.
873
+ if (alongX) {
874
+ facade.colliders.push({ min: [x0, 0, z0], max: [cx - radius, height, z1] });
875
+ facade.colliders.push({ min: [cx + radius, 0, z0], max: [x1, height, z1] });
876
+ facade.colliders.push({
877
+ min: [cx - radius, options.openHeight, z0],
878
+ max: [cx + radius, height, z1],
879
+ });
880
+ } else {
881
+ facade.colliders.push({ min: [x0, 0, z0], max: [x1, height, cz - radius] });
882
+ facade.colliders.push({ min: [x0, 0, cz + radius], max: [x1, height, z1] });
883
+ facade.colliders.push({
884
+ min: [x0, options.openHeight, cz - radius],
885
+ max: [x1, height, cz + radius],
886
+ });
887
+ }
888
+
889
+ // Dress both faces: archivolt, keystone, coping course, a lamp on one pier
890
+ // and the dado carried across the piers but not across the passage.
891
+ const spec: FacadeSpec = { x: options.x, z: options.z, h: height };
892
+ const faces = alongX ? (["n", "s"] as const) : (["e", "w"] as const);
893
+ for (const face of faces) {
894
+ const wall = wallOf(facade, spec, face, Math.round(cx * 7 + cz * 13) + FACE_INDEX[face]);
895
+ addArchivolt(wall, 0, radius, springing, 0.2, 0.15, materials.plasterTrim);
896
+ put(wall, extra.stone, [0.38, 0.44, 0.24], [0, springing + radius - 0.05, 0.12]);
897
+ put(wall, materials.plasterTrim, [span + 0.2, 0.36, 0.22], [0, height - 0.18, 0.1]);
898
+ put(wall, extra.stone, [span + 0.5, 0.12, 0.34], [0, height + 0.06, 0.15]);
899
+ addWallLamp(wall, -span / 2 + 0.6, options.openHeight - 0.4);
900
+ addDado(wall, span, [-radius - 0.05, radius + 0.05]);
901
+ }
902
+ }
903
+
904
+ /**
905
+ * Where the arched passages go.
906
+ *
907
+ * Both sit in lanes that are already flanked by buildings on either side, and
908
+ * both were placed against `town.ts`'s five patrol routes rather than by eye:
909
+ * no route segment enters either footprint, and the nearest route to an arch
910
+ * pier passes 1.1 m clear of it. That constraint is the reason there are two
911
+ * rather than five — the connector proper is crossed diagonally by the mid
912
+ * defender's loop with under 20 cm to spare, so it takes a blind arch instead.
913
+ *
914
+ * Each footprint is inset 4 cm from its neighbouring building so no two faces
915
+ * end up coplanar; that neighbour's own joinery then falls inside the arch's
916
+ * pier, hidden rather than fighting for the same pixels.
917
+ */
918
+ export const BAYVIEW_ARCHES: readonly ArchGateway[] = [
919
+ // South corridor, the T-spawn ↔ outside-long artery: fills the 6 m gap
920
+ // between the two x 15…30 blocks, so the lane runs through a real arch.
921
+ {
922
+ x: [19.2, 21.8],
923
+ z: [26.04, 31.96],
924
+ height: 6,
925
+ along: "z",
926
+ openWidth: 3.9,
927
+ openHeight: 4,
928
+ },
929
+ // Outside long, north end: spans the 7 m waterfront lane between the B-site
930
+ // block and the east perimeter. The waterfront rover walks through the
931
+ // opening 1.1 m clear of the east pier.
932
+ {
933
+ x: [30.04, 36.96],
934
+ z: [21.5, 24.1],
935
+ height: 6,
936
+ along: "x",
937
+ openWidth: 4.4,
938
+ openHeight: 4.4,
939
+ },
940
+ ];
941
+
942
+ // ---------------------------------------------------------------------------
943
+ // The whole face
944
+ // ---------------------------------------------------------------------------
945
+
946
+ /**
947
+ * Everything a lane-facing wall gets: a painted dado, ground-floor doors and
948
+ * roller shutters, storey-by-storey windows on their sills, a balcony, an
949
+ * awning, a lamp, a drainpipe and the odd air-con box or dish. Placement runs
950
+ * off a fixed coordinate hash, so replays render identically.
951
+ */
952
+ export function addDoorsAndShutters(
953
+ facade: Facade,
954
+ spec: FacadeSpec,
955
+ face: Face,
956
+ seed: number,
957
+ ): void {
958
+ const wall = wallOf(facade, spec, face, seed);
959
+ const span = wall.span;
960
+ if (span < 3.4) return;
961
+ const half = span / 2;
962
+ const margin = 1.4;
963
+ const usable = span - margin * 2;
964
+
965
+ if (hash(seed + 91) > 0.34) addDado(wall, span);
966
+
967
+ // --- ground floor ---------------------------------------------------------
968
+ const taken: { x: number; w: number }[] = [];
969
+ const clear = (x: number, w: number): boolean =>
970
+ taken.every((other) => Math.abs(other.x - x) > (other.w + w) / 2 + 0.7);
971
+
972
+ // A roller/garage shutter on the wider faces: the blue corrugated doors that
973
+ // dominate CT SPAWN and T MAIN.
974
+ if (span >= 8.5 && hash(seed + 5) > 0.42) {
975
+ const rollerW = 2.7;
976
+ const rollerH = Math.min(3.05, spec.h - 1.6);
977
+ const rx = -half + 1.8 + (span - 3.6 - rollerW) * (0.15 + hash(seed + 9) * 0.55);
978
+ addOpening(wall, rx, 0.03, rollerW, rollerH, { lintel: 0.09 });
979
+ addRoller(wall, rx, rollerW, rollerH);
980
+ if (hash(seed + 11) > 0.5) {
981
+ // Flat steel canopy on two braces, as over the garages in the reference.
982
+ put(wall, facade.materials.steelPost, [rollerW + 0.8, 0.07, 0.8], [rx, rollerH + 0.55, 0.42]);
983
+ for (const side of [-1, 1]) {
984
+ put(
985
+ wall,
986
+ facade.extra.iron,
987
+ [0.05, 0.5, 0.05],
988
+ [rx + side * (rollerW / 2 + 0.22), rollerH + 0.3, 0.6],
989
+ { roll: side * 0.6 },
990
+ );
991
+ }
992
+ }
993
+ taken.push({ x: rx, w: rollerW + 0.6 });
994
+ }
995
+
996
+ const doors = span >= 12 ? 3 : span >= 7 && hash(seed) > 0.3 ? 2 : 1;
997
+ for (let index = 0; index < doors; index += 1) {
998
+ const dx = -half + margin + usable * ((index + 0.25 + hash(seed + index * 3) * 0.5) / doors);
999
+ if (!clear(dx, DOOR.w * 1.7)) continue;
1000
+ addDoor(wall, dx, seed + index * 17);
1001
+ taken.push({ x: dx, w: DOOR.w * 1.7 });
1002
+ if (index === 0 && hash(seed + 41) > 0.5) addAwning(wall, dx, seed);
1003
+ else if (hash(seed + 43) > 0.5) addWallLamp(wall, dx + 1.05, DOOR.h + 0.75);
1004
+ }
1005
+
1006
+ // Small ground-floor lights between the doors. Their sills clear the dado's
1007
+ // capping batten, or the batten would run straight across the opening.
1008
+ const lights = span >= 11 ? 3 : span >= 6.5 ? 1 : 0;
1009
+ for (let light = 0; light < lights; light += 1) {
1010
+ const gx =
1011
+ -half + margin + usable * ((light + 0.35 + hash(seed + 19 + light * 7) * 0.3) / lights);
1012
+ if (!clear(gx, WINDOW.w + JAMB * 2)) continue;
1013
+ addWindow(wall, gx, 1.6, seed + 200 + light * 23);
1014
+ taken.push({ x: gx, w: WINDOW.w + JAMB * 2 });
1015
+ }
1016
+
1017
+ // A blind arch on the taller, longer faces: the arcade motif, everywhere.
1018
+ if (span >= 9 && spec.h >= 6 && hash(seed + 47) > 0.5) {
1019
+ const ax = -half + 2.2 + (span - 4.4 - 2.9) * hash(seed + 49);
1020
+ if (clear(ax, 2.9)) {
1021
+ addArchNiche(wall, ax, 2.5, 3.3);
1022
+ taken.push({ x: ax, w: 2.9 });
1023
+ }
1024
+ }
1025
+
1026
+ // --- upper storeys --------------------------------------------------------
1027
+ const storeys = Math.max(1, Math.floor((spec.h - 1.4) / STOREY));
1028
+ const perStorey = Math.max(1, Math.min(6, Math.round(span / 3.4)));
1029
+ let balconied = false;
1030
+ let banded = false;
1031
+ for (let storey = 1; storey <= storeys; storey += 1) {
1032
+ const floorY = storey * STOREY - 0.35;
1033
+ // A 5 m block does not fit a 3.05 m storey plus a sill plus a head, and
1034
+ // dropping its window band left several walls blank from dado to parapet.
1035
+ // Where the grid does not fit, hang the band off the roofline instead.
1036
+ const gridded = floorY + 0.8 + WINDOW.h + 0.35 <= spec.h;
1037
+ const sillY = gridded ? floorY + 0.8 : spec.h - WINDOW.h - 0.95;
1038
+ if (!gridded && (storey > 1 || sillY < 2.2)) break;
1039
+ banded = true;
1040
+ for (let index = 0; index < perStorey; index += 1) {
1041
+ const slot = -half + margin + (usable * (index + 0.5)) / perStorey;
1042
+ const jitter = (hash(seed + storey * 71 + index * 13) - 0.5) * 0.5;
1043
+ const cx = Math.max(-half + 1, Math.min(half - 1, slot + jitter));
1044
+ const here = seed * 3 + storey * 101 + index * 37;
1045
+
1046
+ // One window per face becomes a balcony door, with its balcony under it.
1047
+ if (!balconied && storey === 1 && spec.h >= 6 && span >= 5 && hash(here + 13) > 0.55) {
1048
+ addOpening(wall, cx, floorY, DOOR.w, 2.05, { lintel: 0.04 });
1049
+ addLeaves(wall, facade.materials.doorBlue, cx, floorY, DOOR.w, 2.05, 2);
1050
+ addBalcony(wall, cx, floorY - 0.07);
1051
+ balconied = true;
1052
+ continue;
1053
+ }
1054
+ addWindow(wall, cx, sillY, here);
1055
+ }
1056
+ if (!gridded) break;
1057
+ }
1058
+ void banded;
1059
+
1060
+ // --- fittings -------------------------------------------------------------
1061
+ if (span >= 4.5) addDrainpipe(wall, hash(seed + 53) > 0.5 ? -half + 0.34 : half - 0.34, spec.h);
1062
+ if (spec.ac === true || hash(seed + 59) > 0.68) {
1063
+ addWallUnit(wall, -half + margin + usable * (0.2 + hash(seed + 63) * 0.6), spec.h - 1.5);
1064
+ }
1065
+ if (spec.h >= 6 && hash(seed + 67) > 0.72) {
1066
+ addDish(wall, -half + margin + usable * (0.15 + hash(seed + 71) * 0.7), spec.h - 0.9);
1067
+ }
1068
+ }
1069
+
1070
+ /**
1071
+ * Canvas on a frame: a header board, a sloping deck in five bands so a striped
1072
+ * one really alternates, two iron struts, a front bar and a scalloped valance
1073
+ * hanging off it. Never a painted texture.
1074
+ */
1075
+ function addAwning(wall: Wall, cx: number, seed: number): void {
1076
+ const { extra, materials } = wall.facade;
1077
+ const width = 2.3;
1078
+ const reach = 1.2;
1079
+ const drop = 0.42;
1080
+ const top = DOOR.h + 0.68;
1081
+ const striped = hash(seed + 57) > 0.45;
1082
+ const slope = Math.hypot(reach, drop);
1083
+ const pitch = Math.atan2(drop, reach);
1084
+ const midY = top - drop / 2;
1085
+ const midZ = reach / 2 + 0.06;
1086
+
1087
+ put(wall, extra.timber, [width + 0.16, 0.15, 0.1], [cx, top + 0.06, 0.06]);
1088
+
1089
+ const bands = 5;
1090
+ const bandW = width / bands;
1091
+ for (let band = 0; band < bands; band += 1) {
1092
+ const material = striped && band % 2 === 1 ? materials.awningStripe : materials.awningCanvas;
1093
+ // Bands overlap slightly so no gap opens along the fall, and alternate
1094
+ // bands sit 3 mm apart in depth so the overlapping side faces are never
1095
+ // coplanar — from directly under an awning they dither if they are.
1096
+ put(
1097
+ wall,
1098
+ material,
1099
+ [bandW + 0.02, 0.05, slope],
1100
+ [cx - width / 2 + bandW * (band + 0.5), midY, midZ + (band % 2) * 0.003],
1101
+ { pitch },
1102
+ );
1103
+ }
1104
+ // Iron struts under the canvas, back to the wall.
1105
+ for (const side of [-1, 1]) {
1106
+ put(
1107
+ wall,
1108
+ extra.iron,
1109
+ [0.05, 0.05, slope],
1110
+ [cx + side * (width / 2 - 0.08), midY - 0.06, midZ],
1111
+ {
1112
+ pitch,
1113
+ },
1114
+ );
1115
+ }
1116
+ // Front bar and the valance hanging from it, scalloped by alternating drop.
1117
+ put(wall, extra.timber, [width + 0.12, 0.08, 0.08], [cx, top - drop, reach + 0.06]);
1118
+ const scallops = 7;
1119
+ for (let index = 0; index < scallops; index += 1) {
1120
+ const material = striped && index % 2 === 1 ? materials.awningStripe : materials.awningCanvas;
1121
+ const depth = index % 2 === 0 ? 0.26 : 0.18;
1122
+ put(
1123
+ wall,
1124
+ material,
1125
+ [width / scallops - 0.015, depth, 0.035],
1126
+ [
1127
+ cx - width / 2 + (width * (index + 0.5)) / scallops,
1128
+ top - drop - depth / 2 - 0.04,
1129
+ reach + 0.06,
1130
+ ],
1131
+ );
1132
+ }
1133
+ }
1134
+
1135
+ /**
1136
+ * Iron balcony: a stone slab on two corbels, thin balusters between a bottom
1137
+ * rail and a top rail, and heavier newels at the corners. The reference
1138
+ * balconies read as bars against a bright wall, so the bars stay thin and there
1139
+ * are enough of them to hold the line.
1140
+ */
1141
+ function addBalcony(wall: Wall, cx: number, y: number): void {
1142
+ const { extra, materials } = wall.facade;
1143
+ const width = 2.4;
1144
+ const reach = 0.92;
1145
+ const railH = 0.94;
1146
+ const railZ = reach - 0.07;
1147
+
1148
+ put(wall, extra.stone, [width, 0.12, reach], [cx, y, reach / 2], { soft: 0.03 });
1149
+ put(wall, materials.plasterTrim, [width + 0.14, 0.06, reach + 0.07], [cx, y + 0.08, reach / 2]);
1150
+ for (const side of [-1, 1]) {
1151
+ put(
1152
+ wall,
1153
+ materials.plasterTrim,
1154
+ [0.17, 0.32, 0.44],
1155
+ [cx + side * (width / 2 - 0.18), y - 0.22, 0.22],
1156
+ );
1157
+ }
1158
+
1159
+ const bars = 11;
1160
+ for (let bar = 0; bar < bars; bar += 1) {
1161
+ const bx = cx - width / 2 + 0.1 + ((width - 0.2) * bar) / (bars - 1);
1162
+ putTube(wall, extra.iron, 0.02, railH, [bx, y + railH / 2 + 0.07, railZ]);
1163
+ }
1164
+ for (const side of [-1, 1]) {
1165
+ const nx = cx + side * (width / 2 - 0.05);
1166
+ putTube(wall, extra.iron, 0.033, railH, [nx, y + railH / 2 + 0.07, railZ]);
1167
+ put(wall, extra.iron, [0.045, railH, reach - 0.12], [nx, y + railH / 2 + 0.07, reach / 2]);
1168
+ }
1169
+ put(wall, extra.iron, [width - 0.04, 0.055, 0.055], [cx, y + railH + 0.07, railZ]);
1170
+ put(wall, extra.iron, [width - 0.04, 0.04, 0.04], [cx, y + 0.26, railZ]);
1171
+ }
1172
+
1173
+ // ---------------------------------------------------------------------------
1174
+ // Roofline
1175
+ // ---------------------------------------------------------------------------
1176
+
1177
+ /**
1178
+ * Parapet, coping course and the rooftop clutter that makes the skyline. The
1179
+ * parapet is what a player actually sees of a roof from the street, so it gets
1180
+ * a proper coping stone and a dark course under it; the clutter is only worth
1181
+ * its triangles where it breaks the skyline, which means the tanks and masts
1182
+ * stand tall and the flat things stay flat.
1183
+ */
1184
+ export function addRoofLife(facade: Facade, spec: FacadeSpec, index: number): void {
1185
+ const { materials, extra, batch } = facade;
1186
+ const [x0, x1] = spec.x;
1187
+ const [z0, z1] = spec.z;
1188
+ const w = x1 - x0;
1189
+ const d = z1 - z0;
1190
+ const cx = (x0 + x1) / 2;
1191
+ const cz = (z0 + z1) / 2;
1192
+ const trim = spec.brick === true ? materials.brickTrim : materials.plasterTrim;
1193
+
1194
+ const box = (
1195
+ material: Material,
1196
+ size: readonly [number, number, number],
1197
+ at: readonly [number, number, number],
1198
+ hit = false,
1199
+ soft?: number,
1200
+ ): void => {
1201
+ const source =
1202
+ soft === undefined
1203
+ ? new BoxGeometry(size[0], size[1], size[2])
1204
+ : roundedBox(size[0], size[1], size[2], soft, 2);
1205
+ const geometry = normalised(source);
1206
+ if (soft === undefined) source.dispose();
1207
+ geometry.applyMatrix4(new Matrix4().setPosition(at[0], at[1], at[2]));
1208
+ batch.push(material, geometry, hit);
1209
+ };
1210
+ const cyl = (
1211
+ material: Material,
1212
+ radius: number,
1213
+ length: number,
1214
+ at: readonly [number, number, number],
1215
+ segments = 8,
1216
+ hit = false,
1217
+ ): void => {
1218
+ const source = new CylinderGeometry(radius, radius, length, segments, 1);
1219
+ const geometry = normalised(source);
1220
+ source.dispose();
1221
+ geometry.applyMatrix4(new Matrix4().setPosition(at[0], at[1], at[2]));
1222
+ batch.push(material, geometry, hit);
1223
+ };
1224
+
1225
+ /** Parapet, coping and shadow course around one roof plane. */
1226
+ const parapet = (
1227
+ px0: number,
1228
+ px1: number,
1229
+ pz0: number,
1230
+ pz1: number,
1231
+ y: number,
1232
+ height: number,
1233
+ ): void => {
1234
+ const pw = px1 - px0;
1235
+ const pd = pz1 - pz0;
1236
+ const mx = (px0 + px1) / 2;
1237
+ const mz = (pz0 + pz1) / 2;
1238
+ const t = 0.2;
1239
+ box(trim, [pw + t * 2, height, t], [mx, y + height / 2, pz0 - t / 2], true);
1240
+ box(trim, [pw + t * 2, height, t], [mx, y + height / 2, pz1 + t / 2], true);
1241
+ box(trim, [t, height, pd], [px0 - t / 2, y + height / 2, mz], true);
1242
+ box(trim, [t, height, pd], [px1 + t / 2, y + height / 2, mz], true);
1243
+ // Coping: wider than the parapet, so it draws a line along the whole top.
1244
+ const c = 0.36;
1245
+ box(extra.stone, [pw + c * 2, 0.11, c], [mx, y + height + 0.055, pz0 - t / 2]);
1246
+ box(extra.stone, [pw + c * 2, 0.11, c], [mx, y + height + 0.055, pz1 + t / 2]);
1247
+ box(extra.stone, [c, 0.11, pd + c], [px0 - t / 2, y + height + 0.055, mz]);
1248
+ box(extra.stone, [c, 0.11, pd + c], [px1 + t / 2, y + height + 0.055, mz]);
1249
+ // Dark course just under the coping.
1250
+ const s = 0.28;
1251
+ box(extra.reveal, [pw + s * 2, 0.05, s], [mx, y + height - 0.1, pz0 - t / 2]);
1252
+ box(extra.reveal, [pw + s * 2, 0.05, s], [mx, y + height - 0.1, pz1 + t / 2]);
1253
+ box(extra.reveal, [s, 0.05, pd + s], [px0 - t / 2, y + height - 0.1, mz]);
1254
+ box(extra.reveal, [s, 0.05, pd + s], [px1 + t / 2, y + height - 0.1, mz]);
1255
+ };
1256
+
1257
+ parapet(x0, x1, z0, z1, spec.h, 0.62);
1258
+
1259
+ let by = spec.h;
1260
+ let bx0 = x0 + 1.2;
1261
+ let bx1 = x1 - 1.2;
1262
+ let bz0 = z0 + 1.2;
1263
+ let bz1 = z1 - 1.2;
1264
+ if (spec.top !== undefined) {
1265
+ const i = spec.top.i;
1266
+ box(trim, [w - i * 2, spec.top.h, d - i * 2], [cx, spec.h + spec.top.h / 2, cz], true);
1267
+ by = spec.h + spec.top.h;
1268
+ bx0 = x0 + i + 0.9;
1269
+ bx1 = x1 - i - 0.9;
1270
+ bz0 = z0 + i + 0.9;
1271
+ bz1 = z1 - i - 0.9;
1272
+ if (hash(index * 53 + 3) > 0.4) parapet(x0 + i, x1 - i, z0 + i, z1 - i, by, 0.44);
1273
+
1274
+ // The setback storey is the piece of a building that reads highest on the
1275
+ // skyline; blank, it is a white brick sitting on a white block. Give it a
1276
+ // window band on the faces the hash picks.
1277
+ const setback: FacadeSpec = {
1278
+ x: [x0 + i, x1 - i],
1279
+ z: [z0 + i, z1 - i],
1280
+ h: spec.top.h,
1281
+ brick: spec.brick,
1282
+ };
1283
+ for (const face of ["n", "s", "e", "w"] as const) {
1284
+ const wall = raise(wallOf(facade, setback, face, index * 23 + FACE_INDEX[face]), spec.h);
1285
+ if (wall.span < 3.2) continue;
1286
+ if (hash(index * 29 + FACE_INDEX[face] * 7) < 0.4) continue;
1287
+ const lights = Math.max(1, Math.min(3, Math.floor(wall.span / 3)));
1288
+ for (let light = 0; light < lights; light += 1) {
1289
+ addWindow(
1290
+ wall,
1291
+ -wall.span / 2 + (wall.span * (light + 0.5)) / lights,
1292
+ 0.55,
1293
+ index * 131 + FACE_INDEX[face] * 11 + light * 5,
1294
+ );
1295
+ }
1296
+ }
1297
+ }
1298
+
1299
+ const zw = bx1 - bx0;
1300
+ const zd = bz1 - bz0;
1301
+ if (zw < 1.6 || zd < 1.6) return;
1302
+
1303
+ type Clutter = "tank" | "mast" | "ac" | "vents" | "skylight";
1304
+ const candidates: { kind: Clutter; gate: number }[] = [];
1305
+ if (spec.tank === true) candidates.push({ kind: "tank", gate: 0 });
1306
+ if (spec.mast === true) candidates.push({ kind: "mast", gate: 0 });
1307
+ candidates.push(
1308
+ { kind: "ac", gate: 0.25 },
1309
+ { kind: "vents", gate: 0.45 },
1310
+ { kind: "skylight", gate: 0.62 },
1311
+ { kind: "ac", gate: 0.78 },
1312
+ );
1313
+ const picked = candidates.filter((c, i) => hash(index * 31 + i * 17) >= c.gate);
1314
+ const chosen = picked.length >= 2 ? picked : candidates.slice(0, Math.min(2, candidates.length));
1315
+
1316
+ chosen.forEach((c, slot) => {
1317
+ const qx = slot % 2;
1318
+ const qz = Math.floor(slot / 2) % 2;
1319
+ const px = bx0 + ((qx + 0.28 + hash(index * 13 + slot * 7) * 0.44) * zw) / 2;
1320
+ const pz = bz0 + ((qz + 0.28 + hash(index * 19 + slot * 11) * 0.44) * zd) / 2;
1321
+ switch (c.kind) {
1322
+ case "tank": {
1323
+ // Stands well clear of the parapet on purpose: from the street this is
1324
+ // most of what says "roof" instead of "flat white top".
1325
+ for (const lx of [-0.46, 0.46]) {
1326
+ for (const lz of [-0.46, 0.46]) {
1327
+ cyl(materials.steelPost, 0.05, 0.95, [px + lx, by + 0.475, pz + lz], 5);
1328
+ }
1329
+ }
1330
+ cyl(materials.tankDark, 0.84, 1.36, [px, by + 1.63, pz], 14, true);
1331
+ cyl(materials.steelPost, 0.88, 0.1, [px, by + 2.35, pz], 14);
1332
+ cyl(materials.steelPost, 0.045, 1.5, [px + 0.84, by + 0.75, pz], 5);
1333
+ break;
1334
+ }
1335
+ case "mast": {
1336
+ const height = 3.1 + hash(index * 7) * 1.4;
1337
+ cyl(materials.steelMast, 0.045, height, [px, by + height / 2, pz], 5, true);
1338
+ const across = hash(index * 23) > 0.5;
1339
+ for (const [share, arm] of [
1340
+ [0.62, 1.25],
1341
+ [0.78, 0.95],
1342
+ [0.9, 0.62],
1343
+ ] as const) {
1344
+ box(materials.steelMast, across ? [arm, 0.04, 0.04] : [0.04, 0.04, arm], [
1345
+ px,
1346
+ by + height * share,
1347
+ pz,
1348
+ ]);
1349
+ }
1350
+ break;
1351
+ }
1352
+ case "ac":
1353
+ box(materials.steelPost, [0.68, 0.5, 0.5], [px, by + 0.25, pz], true, 0.05);
1354
+ box(extra.reveal, [0.56, 0.36, 0.03], [px, by + 0.26, pz + 0.26]);
1355
+ break;
1356
+ case "vents":
1357
+ cyl(materials.steelPost, 0.09, 0.7, [px, by + 0.35, pz], 6);
1358
+ cyl(materials.tankDark, 0.13, 0.08, [px, by + 0.72, pz], 6);
1359
+ cyl(
1360
+ materials.steelPost,
1361
+ 0.09,
1362
+ 0.5,
1363
+ [px + 0.38 * (hash(index + slot) > 0.5 ? 1 : -1), by + 0.25, pz + 0.32],
1364
+ 6,
1365
+ );
1366
+ break;
1367
+ case "skylight":
1368
+ box(materials.steelPost, [0.98, 0.14, 0.74], [px, by + 0.07, pz]);
1369
+ box(extra.reveal, [0.8, 0.05, 0.58], [px, by + 0.16, pz]);
1370
+ break;
1371
+ }
1372
+ });
1373
+ }