create-threenative 0.2.3 → 0.2.4

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 (447) hide show
  1. package/README.md +53 -2
  2. package/agent-docs/references/assertion-reference.md +173 -6
  3. package/agent-docs/references/capability-reference.md +1303 -99
  4. package/agent-docs/references/capture-the-frame.md +7 -0
  5. package/agent-docs/references/creating-creatures.md +215 -0
  6. package/agent-docs/references/ctx-cookbook.md +69 -0
  7. package/agent-docs/references/debug-surface.md +8 -3
  8. package/agent-docs/references/dream-loop.md +150 -0
  9. package/agent-docs/references/finding-assets.md +70 -2
  10. package/agent-docs/references/sculpt-from-a-reference.md +3 -2
  11. package/agent-docs/references/trace-a-slow-frame.md +99 -0
  12. package/agent-docs/references/visual-baseline.md +41 -0
  13. package/agent-files/.agents/skills/file-engine-bug/SKILL.md +59 -0
  14. package/agent-files/.agents/skills/prd-creator/SKILL.md +40 -0
  15. package/agent-files/.agents/skills/threenative-assets/SKILL.md +45 -0
  16. package/agent-files/.agents/skills/threenative-builder/SKILL.md +1 -1
  17. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +27 -0
  18. package/agent-files/.agents/skills/threenative-context/SKILL.md +57 -0
  19. package/agent-files/.agents/skills/threenative-performance/SKILL.md +42 -0
  20. package/agent-files/.agents/skills/threenative-playtest/SKILL.md +44 -0
  21. package/agent-files/.agents/skills/threenative-ui/SKILL.md +20 -0
  22. package/agent-files/.agents/skills/threenative-verifier/SKILL.md +1 -1
  23. package/agent-files/.agents/skills/threenative-visuals/SKILL.md +41 -0
  24. package/agent-files/.claude/skills/file-engine-bug/SKILL.md +59 -0
  25. package/agent-files/.claude/skills/prd-creator/SKILL.md +40 -0
  26. package/agent-files/.claude/skills/threenative-assets/SKILL.md +45 -0
  27. package/agent-files/.claude/skills/threenative-capabilities/SKILL.md +27 -0
  28. package/agent-files/.claude/skills/threenative-context/SKILL.md +57 -0
  29. package/agent-files/.claude/skills/threenative-performance/SKILL.md +42 -0
  30. package/agent-files/.claude/skills/threenative-playtest/SKILL.md +44 -0
  31. package/agent-files/.claude/skills/threenative-ui/SKILL.md +20 -0
  32. package/agent-files/.claude/skills/threenative-visuals/SKILL.md +41 -0
  33. package/agent-files/scripts/reference.mjs +705 -0
  34. package/agent-files/scripts/visual-loop.mjs +382 -0
  35. package/capabilities.json +1881 -131
  36. package/dist/index.d.ts +39 -6
  37. package/dist/index.js +297 -32
  38. package/dist/threenative.js +822 -105
  39. package/package.json +30 -5
  40. package/template-assets/loading.ts +12 -2
  41. package/template-assets/patches/three@0.185.1.patch +249 -14
  42. package/template-assets/worldEnvironment.ts +758 -0
  43. package/templates/action-rpg/.codex/config.toml +4 -0
  44. package/templates/action-rpg/.cursor/mcp.json +32 -0
  45. package/templates/action-rpg/.gemini/settings.json +32 -0
  46. package/templates/action-rpg/.mcp.json +15 -3
  47. package/templates/action-rpg/.vscode/mcp.json +36 -0
  48. package/templates/action-rpg/.zed/settings.json +36 -0
  49. package/templates/action-rpg/AGENTS.md +69 -378
  50. package/templates/action-rpg/CLAUDE.md +69 -378
  51. package/templates/action-rpg/opencode.json +41 -0
  52. package/templates/action-rpg/package.json +7 -7
  53. package/templates/action-rpg/playtests/combat.playtest.json +9 -0
  54. package/templates/action-rpg/playtests/performance.playtest.json +24 -7
  55. package/templates/action-rpg/playtests/survives.playtest.json +27 -0
  56. package/templates/action-rpg/playtests/touch-controls.playtest.json +42 -0
  57. package/templates/action-rpg/src/conventions.ts +35 -0
  58. package/templates/action-rpg/src/entities/Enemy.ts +2 -3
  59. package/templates/action-rpg/src/entities/Player.ts +20 -3
  60. package/templates/action-rpg/src/render/camera.ts +7 -2
  61. package/templates/action-rpg/src/render/lighting.ts +5 -3
  62. package/templates/action-rpg/src/render/loading.ts +12 -2
  63. package/templates/action-rpg/src/render/materials.ts +11 -0
  64. package/templates/action-rpg/src/render/palette.ts +10 -3
  65. package/templates/action-rpg/src/render/postprocessing.ts +21 -58
  66. package/templates/action-rpg/src/render/quality.ts +170 -0
  67. package/templates/action-rpg/src/render/shapes.ts +185 -26
  68. package/templates/action-rpg/src/render/touch-controls.ts +185 -0
  69. package/templates/action-rpg/src/render/vfx.ts +257 -0
  70. package/templates/action-rpg/src/render/worldEnvironment.ts +208 -33
  71. package/templates/action-rpg/src/scenes/Play.ts +43 -6
  72. package/templates/action-rpg/src/style.css +20 -0
  73. package/templates/action-rpg/threenative.config.ts +7 -0
  74. package/templates/defense/.codex/config.toml +4 -0
  75. package/templates/defense/.cursor/mcp.json +32 -0
  76. package/templates/defense/.gemini/settings.json +32 -0
  77. package/templates/defense/.mcp.json +15 -3
  78. package/templates/defense/.vscode/mcp.json +36 -0
  79. package/templates/defense/.zed/settings.json +36 -0
  80. package/templates/defense/AGENTS.md +62 -385
  81. package/templates/defense/CLAUDE.md +62 -385
  82. package/templates/defense/opencode.json +41 -0
  83. package/templates/defense/package.json +7 -7
  84. package/templates/defense/playtests/performance.playtest.json +24 -7
  85. package/templates/defense/playtests/pointer-placement.playtest.json +87 -20
  86. package/templates/defense/playtests/scan.playtest.json +1 -1
  87. package/templates/defense/playtests/survive.playtest.json +14 -0
  88. package/templates/defense/src/attackers/Attacker.ts +4 -4
  89. package/templates/defense/src/board/Route.ts +22 -8
  90. package/templates/defense/src/conventions.ts +18 -0
  91. package/templates/defense/src/entities/Player.ts +11 -3
  92. package/templates/defense/src/game.ts +2 -3
  93. package/templates/defense/src/physics.ts +9 -39
  94. package/templates/defense/src/placement/Buildable.ts +4 -4
  95. package/templates/defense/src/render/camera.ts +9 -3
  96. package/templates/defense/src/render/loading.ts +12 -2
  97. package/templates/defense/src/render/materials.ts +9 -0
  98. package/templates/defense/src/render/palette.ts +12 -5
  99. package/templates/defense/src/render/postprocessing.ts +21 -58
  100. package/templates/defense/src/render/quality.ts +170 -0
  101. package/templates/defense/src/render/shapes.ts +142 -23
  102. package/templates/defense/src/render/sky.ts +2 -2
  103. package/templates/defense/src/render/worldEnvironment.ts +208 -33
  104. package/templates/defense/src/scenes/Boot.ts +2 -2
  105. package/templates/defense/src/scenes/Defense.ts +13 -6
  106. package/templates/defense/src/style.css +20 -0
  107. package/templates/defense/src/towers/Tower.ts +11 -12
  108. package/templates/defense/src/towers/targeting.ts +1 -1
  109. package/templates/defense/src/ui/App.tsx +2 -2
  110. package/templates/defense/threenative.config.ts +7 -0
  111. package/templates/minimal/.codex/config.toml +4 -0
  112. package/templates/minimal/.cursor/mcp.json +32 -0
  113. package/templates/minimal/.gemini/settings.json +32 -0
  114. package/templates/minimal/.mcp.json +15 -3
  115. package/templates/minimal/.vscode/mcp.json +36 -0
  116. package/templates/minimal/.zed/settings.json +36 -0
  117. package/templates/minimal/AGENTS.md +76 -485
  118. package/templates/minimal/CLAUDE.md +76 -485
  119. package/templates/minimal/opencode.json +41 -0
  120. package/templates/minimal/package.json +6 -6
  121. package/templates/minimal/playtests/play.playtest.json +2 -1
  122. package/templates/minimal/playtests/survives.playtest.json +48 -4
  123. package/templates/minimal/playtests/touch-controls.playtest.json +42 -0
  124. package/templates/minimal/src/conventions.ts +18 -0
  125. package/templates/minimal/src/entities/Player.ts +39 -6
  126. package/templates/minimal/src/main.ts +14 -4
  127. package/templates/minimal/src/render/materials.ts +7 -0
  128. package/templates/minimal/src/render/palette.ts +3 -3
  129. package/templates/minimal/src/render/postprocessing.ts +17 -56
  130. package/templates/minimal/src/render/quality.ts +162 -0
  131. package/templates/minimal/src/render/sky.ts +23 -9
  132. package/templates/minimal/src/render/touch-controls.ts +165 -0
  133. package/templates/minimal/src/render/worldEnvironment.ts +208 -33
  134. package/templates/minimal/src/scenes/Play.ts +47 -11
  135. package/templates/minimal/src/style.css +20 -0
  136. package/templates/minimal/threenative.config.ts +7 -0
  137. package/templates/platformer/.codex/config.toml +4 -0
  138. package/templates/platformer/.cursor/mcp.json +32 -0
  139. package/templates/platformer/.gemini/settings.json +32 -0
  140. package/templates/platformer/.mcp.json +15 -3
  141. package/templates/platformer/.vscode/mcp.json +36 -0
  142. package/templates/platformer/.zed/settings.json +36 -0
  143. package/templates/platformer/AGENTS.md +70 -430
  144. package/templates/platformer/CLAUDE.md +70 -430
  145. package/templates/platformer/opencode.json +41 -0
  146. package/templates/platformer/package.json +7 -7
  147. package/templates/platformer/playtests/oneway.playtest.json +29 -2
  148. package/templates/platformer/playtests/performance.playtest.json +2 -1
  149. package/templates/platformer/playtests/survives.playtest.json +31 -0
  150. package/templates/platformer/playtests/terminal-loop-fail.playtest.json +3 -0
  151. package/templates/platformer/playtests/touch-controls-web.playtest.json +15 -4
  152. package/templates/platformer/src/conventions.ts +18 -0
  153. package/templates/platformer/src/entities/Character.ts +63 -1
  154. package/templates/platformer/src/game.ts +3 -1
  155. package/templates/platformer/src/level/Platform.ts +13 -1
  156. package/templates/platformer/src/render/lighting.ts +7 -4
  157. package/templates/platformer/src/render/loading.ts +12 -2
  158. package/templates/platformer/src/render/palette.ts +4 -1
  159. package/templates/platformer/src/render/postprocessing.ts +32 -57
  160. package/templates/platformer/src/render/quality.ts +170 -0
  161. package/templates/platformer/src/render/worldEnvironment.ts +208 -33
  162. package/templates/platformer/src/scenes/Level.ts +52 -12
  163. package/templates/platformer/src/style.css +20 -0
  164. package/templates/platformer/threenative.config.ts +7 -0
  165. package/templates/puzzle/.codex/config.toml +19 -0
  166. package/templates/puzzle/.cursor/mcp.json +32 -0
  167. package/templates/puzzle/.gemini/settings.json +32 -0
  168. package/templates/puzzle/.mcp.json +32 -0
  169. package/templates/puzzle/.vscode/mcp.json +36 -0
  170. package/templates/puzzle/.zed/settings.json +36 -0
  171. package/templates/puzzle/AGENTS.md +96 -0
  172. package/templates/puzzle/CLAUDE.md +98 -0
  173. package/templates/puzzle/README.md +43 -0
  174. package/templates/puzzle/index.html +12 -0
  175. package/templates/puzzle/kit.json +7 -0
  176. package/templates/puzzle/opencode.json +41 -0
  177. package/templates/puzzle/package.json +50 -0
  178. package/templates/puzzle/playtests/carry.playtest.json +71 -0
  179. package/templates/puzzle/playtests/performance.playtest.json +23 -0
  180. package/templates/puzzle/playtests/survives.playtest.json +51 -0
  181. package/templates/puzzle/playtests/swing.playtest.json +38 -0
  182. package/templates/puzzle/public/favicon.svg +5 -0
  183. package/templates/puzzle/src/conventions.ts +25 -0
  184. package/templates/puzzle/src/entities/Ball.ts +70 -0
  185. package/templates/puzzle/src/entities/Crate.ts +76 -0
  186. package/templates/puzzle/src/entities/Gripper.ts +69 -0
  187. package/templates/puzzle/src/entities/Pendulum.ts +89 -0
  188. package/templates/puzzle/src/game.ts +48 -0
  189. package/templates/puzzle/src/main.ts +15 -0
  190. package/templates/puzzle/src/physics.ts +19 -0
  191. package/templates/puzzle/src/render/camera.ts +37 -0
  192. package/templates/puzzle/src/render/lighting.ts +55 -0
  193. package/templates/puzzle/src/render/loading.ts +325 -0
  194. package/templates/puzzle/src/render/materials.ts +28 -0
  195. package/templates/puzzle/src/render/palette.ts +31 -0
  196. package/templates/puzzle/src/render/postprocessing.ts +34 -0
  197. package/templates/puzzle/src/render/quality.ts +170 -0
  198. package/templates/puzzle/src/render/shapes.ts +134 -0
  199. package/templates/puzzle/src/render/sky.ts +16 -0
  200. package/templates/puzzle/src/render/touch-controls.ts +185 -0
  201. package/templates/puzzle/src/render/worldEnvironment.ts +758 -0
  202. package/templates/puzzle/src/room.ts +83 -0
  203. package/templates/puzzle/src/scenes/Boot.ts +12 -0
  204. package/templates/puzzle/src/scenes/Puzzle.ts +158 -0
  205. package/templates/puzzle/src/state.ts +30 -0
  206. package/templates/puzzle/src/style.css +96 -0
  207. package/templates/puzzle/src/ui/App.tsx +22 -0
  208. package/templates/puzzle/src/ui/GameUi.tsx +20 -0
  209. package/templates/puzzle/src/ui/Hud.tsx +57 -0
  210. package/templates/puzzle/src/ui/Menu.tsx +7 -0
  211. package/templates/puzzle/src/ui/main.tsx +14 -0
  212. package/templates/puzzle/tailwind.config.ts +1 -0
  213. package/templates/puzzle/threenative.config.ts +49 -0
  214. package/templates/puzzle/tsconfig.json +17 -0
  215. package/templates/puzzle/vite.config.ts +38 -0
  216. package/templates/racing/.codex/config.toml +4 -0
  217. package/templates/racing/.cursor/mcp.json +32 -0
  218. package/templates/racing/.gemini/settings.json +32 -0
  219. package/templates/racing/.mcp.json +15 -3
  220. package/templates/racing/.vscode/mcp.json +36 -0
  221. package/templates/racing/.zed/settings.json +36 -0
  222. package/templates/racing/AGENTS.md +63 -379
  223. package/templates/racing/CLAUDE.md +63 -379
  224. package/templates/racing/native-playtests/survives.playtest.json +43 -0
  225. package/templates/racing/opencode.json +41 -0
  226. package/templates/racing/package.json +8 -7
  227. package/templates/racing/playtests/performance.playtest.json +24 -7
  228. package/templates/racing/playtests/survives.playtest.json +36 -4
  229. package/templates/racing/playtests/touch-controls.playtest.json +41 -0
  230. package/templates/racing/src/conventions.ts +6 -0
  231. package/templates/racing/src/entities/RacingCar.ts +16 -4
  232. package/templates/racing/src/entities/Rival.ts +5 -2
  233. package/templates/racing/src/render/camera.ts +7 -4
  234. package/templates/racing/src/render/lighting.ts +22 -13
  235. package/templates/racing/src/render/loading.ts +12 -2
  236. package/templates/racing/src/render/materials.ts +54 -4
  237. package/templates/racing/src/render/palette.ts +23 -6
  238. package/templates/racing/src/render/postprocessing.ts +21 -58
  239. package/templates/racing/src/render/quality.ts +170 -0
  240. package/templates/racing/src/render/shapes.ts +537 -26
  241. package/templates/racing/src/render/sky.ts +5 -2
  242. package/templates/racing/src/render/touch-controls.ts +185 -0
  243. package/templates/racing/src/render/worldEnvironment.ts +208 -33
  244. package/templates/racing/src/scenes/Race.ts +17 -2
  245. package/templates/racing/src/style.css +20 -0
  246. package/templates/racing/src/track/Track.ts +270 -31
  247. package/templates/racing/threenative.config.ts +7 -0
  248. package/templates/runner/.codex/config.toml +19 -0
  249. package/templates/runner/.cursor/mcp.json +32 -0
  250. package/templates/runner/.gemini/settings.json +32 -0
  251. package/templates/runner/.mcp.json +32 -0
  252. package/templates/runner/.vscode/mcp.json +36 -0
  253. package/templates/runner/.zed/settings.json +36 -0
  254. package/templates/runner/AGENTS.md +96 -0
  255. package/templates/runner/CLAUDE.md +98 -0
  256. package/templates/runner/README.md +43 -0
  257. package/templates/runner/index.html +12 -0
  258. package/templates/runner/kit.json +7 -0
  259. package/templates/runner/opencode.json +41 -0
  260. package/templates/runner/package.json +50 -0
  261. package/templates/runner/playtests/performance.playtest.json +23 -0
  262. package/templates/runner/playtests/streams.playtest.json +38 -0
  263. package/templates/runner/playtests/survives.playtest.json +51 -0
  264. package/templates/runner/public/favicon.svg +5 -0
  265. package/templates/runner/src/conventions.ts +24 -0
  266. package/templates/runner/src/entities/Runner.ts +135 -0
  267. package/templates/runner/src/game.ts +50 -0
  268. package/templates/runner/src/main.ts +15 -0
  269. package/templates/runner/src/physics.ts +13 -0
  270. package/templates/runner/src/render/camera.ts +39 -0
  271. package/templates/runner/src/render/dust.ts +131 -0
  272. package/templates/runner/src/render/lighting.ts +57 -0
  273. package/templates/runner/src/render/loading.ts +325 -0
  274. package/templates/runner/src/render/materials.ts +27 -0
  275. package/templates/runner/src/render/palette.ts +30 -0
  276. package/templates/runner/src/render/postprocessing.ts +34 -0
  277. package/templates/runner/src/render/quality.ts +170 -0
  278. package/templates/runner/src/render/shapes.ts +68 -0
  279. package/templates/runner/src/render/sky.ts +51 -0
  280. package/templates/runner/src/render/touch-controls.ts +185 -0
  281. package/templates/runner/src/render/worldEnvironment.ts +758 -0
  282. package/templates/runner/src/scenes/Boot.ts +12 -0
  283. package/templates/runner/src/scenes/Run.ts +142 -0
  284. package/templates/runner/src/state.ts +29 -0
  285. package/templates/runner/src/style.css +96 -0
  286. package/templates/runner/src/track.ts +176 -0
  287. package/templates/runner/src/ui/App.tsx +22 -0
  288. package/templates/runner/src/ui/GameUi.tsx +20 -0
  289. package/templates/runner/src/ui/Hud.tsx +55 -0
  290. package/templates/runner/src/ui/Menu.tsx +7 -0
  291. package/templates/runner/src/ui/main.tsx +14 -0
  292. package/templates/runner/tailwind.config.ts +1 -0
  293. package/templates/runner/threenative.config.ts +49 -0
  294. package/templates/runner/tsconfig.json +17 -0
  295. package/templates/runner/vite.config.ts +38 -0
  296. package/templates/sailing/.codex/config.toml +4 -0
  297. package/templates/sailing/.cursor/mcp.json +32 -0
  298. package/templates/sailing/.gemini/settings.json +32 -0
  299. package/templates/sailing/.mcp.json +15 -3
  300. package/templates/sailing/.vscode/mcp.json +36 -0
  301. package/templates/sailing/.zed/settings.json +36 -0
  302. package/templates/sailing/AGENTS.md +62 -355
  303. package/templates/sailing/CLAUDE.md +62 -355
  304. package/templates/sailing/README.md +12 -9
  305. package/templates/sailing/native-playtests/float.playtest.json +55 -0
  306. package/templates/sailing/native-playtests/survives.playtest.json +20 -3
  307. package/templates/sailing/opencode.json +41 -0
  308. package/templates/sailing/package.json +8 -8
  309. package/templates/sailing/playtests/float-after-the-run-ends.playtest.json +75 -0
  310. package/templates/sailing/playtests/float.playtest.json +59 -0
  311. package/templates/sailing/playtests/performance.playtest.json +21 -6
  312. package/templates/sailing/playtests/survives.playtest.json +8 -0
  313. package/templates/sailing/playtests/touch-controls.playtest.json +48 -0
  314. package/templates/sailing/src/conventions.ts +8 -0
  315. package/templates/sailing/src/entities/Ship.ts +150 -13
  316. package/templates/sailing/src/render/camera.ts +15 -8
  317. package/templates/sailing/src/render/lighting.ts +10 -5
  318. package/templates/sailing/src/render/loading.ts +12 -2
  319. package/templates/sailing/src/render/materials.ts +24 -8
  320. package/templates/sailing/src/render/ocean.ts +179 -0
  321. package/templates/sailing/src/render/palette.ts +14 -21
  322. package/templates/sailing/src/render/postprocessing.ts +23 -22
  323. package/templates/sailing/src/render/props.ts +584 -34
  324. package/templates/sailing/src/render/quality.ts +140 -0
  325. package/templates/sailing/src/render/sky.ts +8 -3
  326. package/templates/sailing/src/render/touch-controls.ts +142 -0
  327. package/templates/sailing/src/render/worldEnvironment.ts +206 -38
  328. package/templates/sailing/src/scenes/Sailing.ts +43 -16
  329. package/templates/sailing/src/style.css +20 -0
  330. package/templates/sailing/threenative.config.ts +7 -1
  331. package/templates/shooter/.codex/config.toml +4 -0
  332. package/templates/shooter/.cursor/mcp.json +32 -0
  333. package/templates/shooter/.gemini/settings.json +32 -0
  334. package/templates/shooter/.mcp.json +15 -3
  335. package/templates/shooter/.vscode/mcp.json +36 -0
  336. package/templates/shooter/.zed/settings.json +36 -0
  337. package/templates/shooter/AGENTS.md +76 -415
  338. package/templates/shooter/CLAUDE.md +76 -415
  339. package/templates/shooter/kit.json +2 -2
  340. package/templates/shooter/opencode.json +41 -0
  341. package/templates/shooter/package.json +7 -7
  342. package/templates/shooter/playtests/combat.playtest.json +48 -0
  343. package/templates/shooter/playtests/input-control.playtest.json +165 -35
  344. package/templates/shooter/playtests/per-item.playtest.json +3 -3
  345. package/templates/shooter/playtests/performance.playtest.json +24 -7
  346. package/templates/shooter/playtests/shooter.playtest.json +13 -7
  347. package/templates/shooter/playtests/survives.playtest.json +27 -0
  348. package/templates/shooter/playtests/touch-controls.playtest.json +42 -0
  349. package/templates/shooter/playtests/weapon-cycle.playtest.json +164 -0
  350. package/templates/shooter/src/combat/damage.ts +1 -2
  351. package/templates/shooter/src/conventions.ts +51 -0
  352. package/templates/shooter/src/entities/Player.ts +235 -18
  353. package/templates/shooter/src/entities/Target.ts +2 -2
  354. package/templates/shooter/src/game.ts +13 -4
  355. package/templates/shooter/src/render/camera.ts +49 -39
  356. package/templates/shooter/src/render/decals.ts +211 -0
  357. package/templates/shooter/src/render/lighting.ts +7 -3
  358. package/templates/shooter/src/render/loading.ts +12 -2
  359. package/templates/shooter/src/render/materials.ts +56 -3
  360. package/templates/shooter/src/render/palette.ts +6 -3
  361. package/templates/shooter/src/render/postprocessing.ts +21 -58
  362. package/templates/shooter/src/render/quality.ts +170 -0
  363. package/templates/shooter/src/render/scale.ts +22 -0
  364. package/templates/shooter/src/render/shapes.ts +343 -62
  365. package/templates/shooter/src/render/sky.ts +5 -1
  366. package/templates/shooter/src/render/touch-controls.ts +305 -0
  367. package/templates/shooter/src/render/ui.css +85 -0
  368. package/templates/shooter/src/render/ui.ts +19 -3
  369. package/templates/shooter/src/render/vfx.ts +215 -0
  370. package/templates/shooter/src/render/worldEnvironment.ts +208 -33
  371. package/templates/shooter/src/scenes/Play.ts +171 -56
  372. package/templates/shooter/src/state.ts +5 -0
  373. package/templates/shooter/src/style.css +20 -0
  374. package/templates/shooter/src/ui/Crosshair.tsx +25 -0
  375. package/templates/shooter/src/ui/GameUi.tsx +2 -0
  376. package/templates/shooter/src/ui/Hud.tsx +7 -1
  377. package/templates/shooter/src/weapons/Hitscan.ts +3 -4
  378. package/templates/shooter/src/weapons/Projectile.ts +8 -3
  379. package/templates/shooter/src/weapons/Viewmodel.ts +275 -0
  380. package/templates/shooter/threenative.config.ts +7 -0
  381. package/templates/starter/.codex/config.toml +4 -0
  382. package/templates/starter/.cursor/mcp.json +32 -0
  383. package/templates/starter/.gemini/settings.json +32 -0
  384. package/templates/starter/.mcp.json +15 -3
  385. package/templates/starter/.vscode/mcp.json +36 -0
  386. package/templates/starter/.zed/settings.json +36 -0
  387. package/templates/starter/AGENTS.md +70 -527
  388. package/templates/starter/CLAUDE.md +70 -527
  389. package/templates/starter/native-playtests/render-chain.playtest.json +73 -4
  390. package/templates/starter/opencode.json +41 -0
  391. package/templates/starter/package.json +7 -7
  392. package/templates/starter/playtests/boot-failure.playtest.json +45 -0
  393. package/templates/starter/playtests/look.playtest.json +110 -6
  394. package/templates/starter/playtests/play.playtest.json +3 -2
  395. package/templates/starter/playtests/survives.playtest.json +21 -0
  396. package/templates/starter/playtests/touch-controls.playtest.json +42 -0
  397. package/templates/starter/src/conventions.ts +18 -0
  398. package/templates/starter/src/entities/Goal.ts +18 -3
  399. package/templates/starter/src/entities/Player.ts +72 -9
  400. package/templates/starter/src/game.ts +2 -0
  401. package/templates/starter/src/render/adaptiveQuality.ts +195 -0
  402. package/templates/starter/src/render/camera.ts +1 -1
  403. package/templates/starter/src/render/coast.ts +199 -0
  404. package/templates/starter/src/render/hero.ts +88 -0
  405. package/templates/starter/src/render/implicitSurface.ts +199 -0
  406. package/templates/starter/src/render/kuwahara.ts +174 -0
  407. package/templates/starter/src/render/lighting.ts +4 -4
  408. package/templates/starter/src/render/loading.ts +12 -2
  409. package/templates/starter/src/render/materials.ts +25 -6
  410. package/templates/starter/src/render/outline.ts +141 -0
  411. package/templates/starter/src/render/painterly.ts +86 -0
  412. package/templates/starter/src/render/palette.ts +15 -6
  413. package/templates/starter/src/render/postprocessing.ts +87 -36
  414. package/templates/starter/src/render/quality.ts +185 -0
  415. package/templates/starter/src/render/rockRidge.ts +198 -0
  416. package/templates/starter/src/render/rockRidge.worker.ts +77 -0
  417. package/templates/starter/src/render/scenery.ts +16 -59
  418. package/templates/starter/src/render/textureLifetime.ts +53 -0
  419. package/templates/starter/src/render/touch-controls.ts +165 -0
  420. package/templates/starter/src/render/water.ts +38 -0
  421. package/templates/starter/src/render/watercolor.ts +85 -0
  422. package/templates/starter/src/render/worldEnvironment.ts +208 -33
  423. package/templates/starter/src/scenes/Play.ts +103 -16
  424. package/templates/starter/src/style.css +27 -7
  425. package/templates/starter/threenative.config.ts +7 -7
  426. package/agent-docs/asset-mcp-loop.md +0 -33
  427. package/agent-docs/ctx-surface.md +0 -69
  428. package/agent-docs/engine-capabilities.md +0 -4
  429. package/agent-docs/framework-blocks-you.md +0 -60
  430. package/agent-docs/look-at-it-and-budget-the-look.md +0 -27
  431. package/agent-docs/performance-default.md +0 -42
  432. package/agent-docs/pixel-budget.md +0 -20
  433. package/agent-docs/playtest-fail-closed.md +0 -23
  434. package/agent-docs/sculpt-loop.md +0 -16
  435. package/templates/action-rpg/src/physics.ts +0 -40
  436. package/templates/defense/public/icon.png +0 -0
  437. package/templates/minimal/public/icon.png +0 -0
  438. package/templates/platformer/public/icon.png +0 -0
  439. package/templates/racing/public/icon.png +0 -0
  440. package/templates/sailing/public/icon.png +0 -0
  441. package/templates/sailing/src/render/water-material.ts +0 -14
  442. package/templates/sailing/src/render/water-shaders.ts +0 -12
  443. package/templates/sailing/src/render/wave-nodes.ts +0 -10
  444. package/templates/shooter/public/icon.png +0 -0
  445. package/templates/shooter/src/physics.ts +0 -49
  446. package/templates/starter/public/icon.png +0 -0
  447. /package/{templates/action-rpg/public → template-assets}/icon.png +0 -0
@@ -1,22 +1,39 @@
1
1
  {
2
2
  "acceptanceId": "prd-194-performance-racing",
3
- "artifacts": { "screenshots": "after" },
3
+ "artifacts": {
4
+ "screenshots": "after"
5
+ },
4
6
  "assert": {
5
7
  "performance": {
6
- "maxDrawCalls": 195,
8
+ "maxDrawCalls": 330,
7
9
  "maxFrameMsP95": 33,
8
- "maxTriangles": 4800
10
+ "maxTriangles": 105000,
11
+ "minFps": 30
9
12
  },
10
- "renderChain": { "tier": "high" }
13
+ "renderChain": {
14
+ "tier": "high"
15
+ }
11
16
  },
12
17
  "name": "production-performance",
13
18
  "schemaVersion": 1,
14
19
  "steps": [
15
- { "kind": "input", "press": "ArrowUp", "holdTicks": 60, "release": true },
16
- { "kind": "wait", "waitTicks": 600, "release": true }
20
+ {
21
+ "kind": "input",
22
+ "press": "ArrowUp",
23
+ "holdTicks": 60,
24
+ "release": true
25
+ },
26
+ {
27
+ "kind": "wait",
28
+ "waitTicks": 600,
29
+ "release": true
30
+ }
17
31
  ],
18
32
  "subject": "player",
19
33
  "target": "web",
20
- "viewport": { "height": 1080, "width": 1920 },
34
+ "viewport": {
35
+ "height": 1080,
36
+ "width": 1920
37
+ },
21
38
  "warmupFrames": 60
22
39
  }
@@ -2,12 +2,26 @@
2
2
  "name": "survives",
3
3
  "target": "web",
4
4
  "schemaVersion": 1,
5
- "viewport": { "width": 1280, "height": 720 },
5
+ "viewport": {
6
+ "width": 1280,
7
+ "height": 720
8
+ },
6
9
  "warmupFrames": 10,
7
10
  "subject": "player",
8
11
  "steps": [
9
- { "kind": "input", "label": "move", "press": "ArrowUp", "holdTicks": 60, "release": true },
10
- { "kind": "wait", "label": "settle", "waitTicks": 10, "release": true }
12
+ {
13
+ "kind": "input",
14
+ "label": "move",
15
+ "press": "ArrowUp",
16
+ "holdTicks": 60,
17
+ "release": true
18
+ },
19
+ {
20
+ "kind": "wait",
21
+ "label": "settle",
22
+ "waitTicks": 10,
23
+ "release": true
24
+ }
11
25
  ],
12
26
  "assert": {
13
27
  "diagnostics": {
@@ -16,7 +30,25 @@
16
30
  "noRuntimeDiagnostics": true,
17
31
  "runtimeReady": true
18
32
  },
19
- "movement": { "entity": "player", "minDistance": 0.5 },
33
+ "components": [
34
+ {
35
+ "allowTrivial": "The vehicle is authored at its real 4.4 m length and normalised down to the conventional 3 m, so the retained factor is below one; either side of one proves normaliseToMetres ran in the generated car.",
36
+ "component": "normaliseFactor",
37
+ "entity": "player",
38
+ "lte": 0.99
39
+ }
40
+ ],
41
+ "movement": {
42
+ "entity": "player",
43
+ "minDistance": 0.5
44
+ },
45
+ "visibility": [
46
+ {
47
+ "entity": "touch-controls",
48
+ "present": false,
49
+ "allowTrivial": "Desktop keyboard lanes intentionally omit touch controls while movement proves the scene is active."
50
+ }
51
+ ],
20
52
  "visual": [
21
53
  {
22
54
  "region": {
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "racing-touch-controls",
3
+ "schemaVersion": 1,
4
+ "target": "web",
5
+ "viewport": { "width": 1280, "height": 720 },
6
+ "warmupFrames": 10,
7
+ "subject": "player",
8
+ "steps": [
9
+ {
10
+ "kind": "input",
11
+ "label": "throttle-anchor",
12
+ "pointers": [{ "id": 7, "x": 0.18, "y": 0.75 }],
13
+ "holdTicks": 2,
14
+ "release": false
15
+ },
16
+ {
17
+ "kind": "input",
18
+ "label": "throttle-forward",
19
+ "pointers": [{ "id": 7, "x": 0.18, "y": 0.55 }],
20
+ "holdTicks": 90,
21
+ "release": true
22
+ },
23
+ { "kind": "wait", "label": "settled", "waitTicks": 10, "release": true }
24
+ ],
25
+ "assert": {
26
+ "diagnostics": {
27
+ "noConsoleErrors": true,
28
+ "noNetworkErrors": true,
29
+ "noRuntimeDiagnostics": true,
30
+ "runtimeReady": true
31
+ },
32
+ "resources": [{ "id": "state", "path": "speed", "gte": 0.1, "changed": true }],
33
+ "visibility": [
34
+ {
35
+ "entity": "touch-controls",
36
+ "present": true,
37
+ "allowTrivial": "Touch-primary lanes keep the authored controls visible while state assertions prove they are live."
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1,6 @@
1
+ import { normaliseToMetres } from "@threenative/core";
2
+ import type { Group } from "three";
3
+
4
+ export function prepareVehicleConventions(model: Group): number {
5
+ return normaliseToMetres(model, { axis: "longest", metres: 3 });
6
+ }
@@ -1,9 +1,11 @@
1
1
  import type { ICtx } from "@threenative/core";
2
2
  import { CharacterBody3D, CollisionShape3D, type IPhysicsContext } from "@threenative/physics";
3
3
  import { Group, Vector3 } from "three";
4
+ import { prepareVehicleConventions } from "../conventions.js";
4
5
  import { Boost } from "../kart/boost.js";
5
6
  import { createMaterials } from "../render/materials.js";
6
7
  import { vehicle } from "../render/shapes.js";
8
+ import type { ITouchInput } from "../render/touch-controls.js";
7
9
  import type { GameState } from "../state.js";
8
10
 
9
11
  type GameCtx = ICtx<GameState, IPhysicsContext>;
@@ -26,12 +28,15 @@ export class RacingCar {
26
28
  readonly boost = new Boost();
27
29
  #speed = 0;
28
30
  #heading = 0;
31
+ #normaliseFactor: number;
29
32
  #topSpeed = 0;
30
33
 
31
34
  constructor(ctx: GameCtx, spawn: Vector3) {
32
35
  this.mesh.position.copy(spawn);
33
36
  this.mesh.castShadow = true;
34
- this.mesh.add(vehicle(createMaterials()));
37
+ const visual = vehicle(createMaterials());
38
+ this.#normaliseFactor = prepareVehicleConventions(visual);
39
+ this.mesh.add(visual);
35
40
  ctx.add(this.mesh);
36
41
  this.body = new CharacterBody3D({
37
42
  autostep: { maxHeight: 0.25, minWidth: 0.2 },
@@ -46,17 +51,23 @@ export class RacingCar {
46
51
  });
47
52
  }
48
53
 
49
- update(ctx: GameCtx, dt: number): void {
54
+ update(ctx: GameCtx, dt: number, touch?: ITouchInput): void {
50
55
  this.boost.update(dt);
51
- if (ctx.input.justPressed("boost")) this.boost.activate();
56
+ if (ctx.input.justPressed("boost") || touch?.boostPressed === true) this.boost.activate();
52
57
  const move = ctx.input.vector("move");
58
+ if (touch !== undefined) {
59
+ move.x += touch.move.x;
60
+ move.y += touch.move.y;
61
+ move.clampLength(0, 1);
62
+ }
53
63
  const throttle = move.y;
54
64
  const target =
55
65
  throttle * RACING_FEEL.maxSpeed * (this.boost.active ? this.boost.multiplier : 1);
56
66
  const rate =
57
67
  Math.abs(target) > Math.abs(this.#speed) ? RACING_FEEL.acceleration : RACING_FEEL.drag;
58
68
  this.#speed = approach(this.#speed, target, rate * dt);
59
- if (ctx.input.pressed("brake")) this.#speed = approach(this.#speed, 0, RACING_FEEL.brake * dt);
69
+ if (ctx.input.pressed("brake") || touch?.brakePressed === true)
70
+ this.#speed = approach(this.#speed, 0, RACING_FEEL.brake * dt);
60
71
  const steering =
61
72
  move.x * (Math.min(1, Math.abs(this.#speed) / RACING_FEEL.maxSpeed) * 0.65 + 0.35);
62
73
  this.#heading += steering * RACING_FEEL.turnRate * dt * (this.#speed < 0 ? -1 : 1);
@@ -95,6 +106,7 @@ export class RacingCar {
95
106
  return {
96
107
  boostActive: this.boost.active,
97
108
  heading: this.#heading,
109
+ normaliseFactor: this.#normaliseFactor,
98
110
  position: this.mesh.position.toArray(),
99
111
  speed: this.speed,
100
112
  topSpeed: this.#topSpeed,
@@ -14,8 +14,11 @@ export class Rival {
14
14
  startDistance: number,
15
15
  ) {
16
16
  this.#distance = startDistance;
17
- const visual = vehicle(createMaterials());
18
- visual.scale.setScalar(0.92);
17
+ // Same sculpt, different livery. The rival was indistinguishable from the player in the first
18
+ // frame because both cars asked for the same material set.
19
+ const materials = createMaterials();
20
+ const visual = vehicle({ ...materials, body: materials.rivalBody });
21
+ visual.scale.setScalar(0.96);
19
22
  this.mesh.add(visual);
20
23
  }
21
24
 
@@ -1,11 +1,14 @@
1
1
  import { MathUtils, type PerspectiveCamera, Vector3 } from "three";
2
2
 
3
- const SCRATCH_UP = new Vector3(0, 5.8, 0);
3
+ // Chase height and distance. At 5.8 up and 8.5 back the camera looked down on the roof, which is
4
+ // the one angle from which every car in the world reads as a rectangle; 3.3 and 7.4 put the eye
5
+ // near the rear wing where the wedge, the arches and the flank are all in view.
6
+ const SCRATCH_UP = new Vector3(0, 3.0, 0);
4
7
 
5
8
  export function setupCamera(camera: PerspectiveCamera): void {
6
9
  camera.fov = 56;
7
10
  camera.near = 0.1;
8
- camera.far = 180;
11
+ camera.far = 340;
9
12
  camera.updateProjectionMatrix();
10
13
  }
11
14
 
@@ -20,11 +23,11 @@ export function chaseCamera(
20
23
  heading: Vector3,
21
24
  dt: number,
22
25
  ): void {
23
- behind.copy(heading).setY(0).normalize().multiplyScalar(-8.5);
26
+ behind.copy(heading).setY(0).normalize().multiplyScalar(-6.6);
24
27
  desired.copy(target).add(behind).add(SCRATCH_UP);
25
28
  if (dt >= 1) camera.position.copy(desired);
26
29
  else camera.position.lerp(desired, 1 - Math.exp(-dt / 0.2));
27
- camera.lookAt(target.x, target.y + 0.65, target.z);
30
+ camera.lookAt(target.x, target.y + 1.15, target.z);
28
31
  }
29
32
 
30
33
  export function cameraRoll(camera: PerspectiveCamera, heading: Vector3): void {
@@ -12,26 +12,35 @@ type ShadowRenderer = { shadowMap: { enabled: boolean; type: number } };
12
12
  // Returns the key light: `WorldEnvironment`'s godrays stage raymarches against a shadow map, so
13
13
  // the scene hands the sun to `setupPost` and a shadowless light is refused by name instead of
14
14
  // rendering a black pass.
15
+ //
16
+ // The sun is **near-white**, not the accent colour. Tinting the key light yellow was how the first
17
+ // version of this file made a green infield go olive and a grey road go brown: a strongly coloured
18
+ // key contaminates every surface at once, and no per-material tweak can undo it. Colour belongs in
19
+ // the materials; the sun's job is direction and contrast.
15
20
  export function setupLighting(scene: Scene, renderer: ShadowRenderer): DirectionalLight {
16
21
  renderer.shadowMap.enabled = true;
17
22
  renderer.shadowMap.type = PCFSoftShadowMap;
18
- scene.add(new HemisphereLight(palette.skyLow, palette.shadow, 1.3));
19
- const key = new DirectionalLight(palette.accent, 3.1);
20
- key.position.set(-12, 18, -8);
23
+ // Sky above, grass bounce below. The ground term is what stops undersides going to slate.
24
+ scene.add(new HemisphereLight(palette.skyLow, palette.field, 1.1));
25
+ const key = new DirectionalLight(0xfff4e2, 2.9);
26
+ key.position.set(-16, 26, -12);
21
27
  key.castShadow = true;
22
- key.shadow.mapSize.set(1024, 1024);
28
+ key.shadow.mapSize.set(2048, 2048);
23
29
  key.shadow.camera.near = 0.5;
24
- key.shadow.camera.far = 90;
25
- key.shadow.camera.left = -45;
26
- key.shadow.camera.right = 45;
27
- key.shadow.camera.top = 45;
28
- key.shadow.camera.bottom = -45;
29
- key.shadow.normalBias = 0.04;
30
+ key.shadow.camera.far = 120;
31
+ key.shadow.camera.left = -55;
32
+ key.shadow.camera.right = 55;
33
+ key.shadow.camera.top = 55;
34
+ key.shadow.camera.bottom = -55;
35
+ key.shadow.bias = -0.0004;
36
+ key.shadow.normalBias = 0.03;
30
37
  scene.add(key);
31
- const rim = new DirectionalLight(palette.skyLow, 1.15);
32
- rim.position.set(14, 6, 20);
38
+ // A cool fill from the opposite side, so shadow faces separate from each other rather than all
39
+ // collapsing to one flat tone.
40
+ const rim = new DirectionalLight(palette.skyLow, 0.85);
41
+ rim.position.set(18, 9, 22);
33
42
  scene.add(rim);
34
- scene.add(new AmbientLight(palette.shadow, 0.22));
43
+ scene.add(new AmbientLight(palette.shadow, 0.55));
35
44
 
36
45
  return key;
37
46
  }
@@ -36,7 +36,11 @@ interface ILoadingHost {
36
36
  };
37
37
  readonly renderer: { compileAsync(scene: Scene, camera: Camera): Promise<void> };
38
38
  readonly scene: Scene;
39
- readonly startup: { readonly progress: number; whenReady(): Promise<void> };
39
+ readonly startup: {
40
+ readonly progress: number;
41
+ readonly warmup?: { readonly status: "complete" | "incomplete" | "unavailable" };
42
+ whenReady(): Promise<void>;
43
+ };
40
44
  readonly viewport?: {
41
45
  readonly safeArea: { height: number; width: number; x: number; y: number };
42
46
  };
@@ -231,7 +235,13 @@ export function createLoadingScreen(host: ILoadingHost): ILoadingController {
231
235
  };
232
236
 
233
237
  const updateProgress = (value: number): void => {
234
- progress = Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0;
238
+ const bounded = Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0;
239
+ // A missing or incomplete backend observation cannot prove that all first-use work is done.
240
+ // Keep the bar visibly indeterminate until readiness removes the cover; never turn unknown
241
+ // coverage into a false 100% claim.
242
+ const observationUnknown =
243
+ host.startup.warmup !== undefined && host.startup.warmup.status !== "complete";
244
+ progress = observationUnknown ? Math.min(0.9, bounded) : bounded;
235
245
  setFillUv(fill.geometry, progress, fillBaseU);
236
246
  status?.update(progress);
237
247
  layout();
@@ -1,15 +1,65 @@
1
+ // Generated for you: the car's livery and the circuit's surfaces. ThreeNative does not read this
2
+ // file, and nothing in `shapes.ts` names a colour — it only names these slots. Re-livery the car,
3
+ // or repaint the circuit, entirely from here.
1
4
  import { MeshStandardMaterial } from "three";
2
5
  import { palette, toon } from "./palette.js";
3
6
 
4
7
  export function createMaterials() {
5
8
  return {
9
+ /** Boost chevrons and the kerb's yellow stripe. */
6
10
  boost: toon(palette.accent, 0.4),
7
11
  curb: toon(0xf3f0dc, 0.55),
12
+ /** The kerb's red stripe, and the paint on the pit wall. */
13
+ kerbAlt: toon(0xe8443a, 0.55),
8
14
  field: toon(palette.field, 0.95),
9
- road: toon(palette.road, 0.9),
15
+ /** Dry grass on the run-off, so the two greens read as two surfaces. */
16
+ runoff: toon(0x8a9b52, 0.98),
17
+ road: toon(palette.road, 0.86),
10
18
  shadow: new MeshStandardMaterial({ color: palette.shadow, roughness: 1 }),
11
- tire: new MeshStandardMaterial({ color: 0x111820, roughness: 0.92 }),
12
- vehicle: toon(0xd95050, 0.38),
13
- glass: new MeshStandardMaterial({ color: 0x9ee7f2, roughness: 0.18, metalness: 0.25 }),
19
+ tire: new MeshStandardMaterial({ color: 0x1a1d22, roughness: 0.94 }),
20
+
21
+ /** The car. `body` is the one a game is most likely to change. */
22
+ body: new MeshStandardMaterial({ color: 0xd93a3a, metalness: 0.18, roughness: 0.3 }),
23
+ /** Kept as an alias so a game that already referred to the old slot still compiles. */
24
+ vehicle: new MeshStandardMaterial({ color: 0xd93a3a, metalness: 0.18, roughness: 0.3 }),
25
+ rivalBody: new MeshStandardMaterial({ color: 0x2f6fd0, metalness: 0.18, roughness: 0.3 }),
26
+ glass: new MeshStandardMaterial({
27
+ color: 0x3f5a70,
28
+ metalness: 0.55,
29
+ roughness: 0.1,
30
+ }),
31
+ // Not black. At 0x23262b every aero part on the car went to the same void and the tail read as a
32
+ // hole; a lit dark grey still says "carbon" and keeps its own form.
33
+ carbon: new MeshStandardMaterial({ color: 0x3a3f47, metalness: 0.24, roughness: 0.46 }),
34
+ wing: new MeshStandardMaterial({ color: 0x2b2f36, metalness: 0.3, roughness: 0.4 }),
35
+ alloy: new MeshStandardMaterial({ color: 0xb9c0c8, metalness: 0.86, roughness: 0.26 }),
36
+ livery: new MeshStandardMaterial({ color: 0xf6f3ea, metalness: 0.05, roughness: 0.42 }),
37
+ /** A shade darker than the body, so the arch lip is a line and not more bodywork. */
38
+ archLip: new MeshStandardMaterial({ color: 0x7d2323, metalness: 0.3, roughness: 0.4 }),
39
+ /** Spoke gaps: what the eye reads as the hole between spokes. */
40
+ hubDark: new MeshStandardMaterial({ color: 0x30343a, metalness: 0.5, roughness: 0.4 }),
41
+ headlamp: new MeshStandardMaterial({
42
+ color: 0xfff6de,
43
+ emissive: 0xfff0c8,
44
+ emissiveIntensity: 0.9,
45
+ roughness: 0.3,
46
+ }),
47
+ // Dim on purpose. At 2.2 the bar plus the bloom stage flared over the whole tail and the car's
48
+ // rear became one orange smear — the emissive was brighter than the sun.
49
+ taillamp: new MeshStandardMaterial({
50
+ color: 0xd93a34,
51
+ emissive: 0xff2a1c,
52
+ emissiveIntensity: 0.75,
53
+ roughness: 0.34,
54
+ }),
55
+
56
+ /** Trackside furniture. */
57
+ structure: toon(0xd8dbe0, 0.7),
58
+ crowd: toon(0x3d4a63, 0.9),
59
+ trunk: toon(0x6b4a33, 0.9),
60
+ canopy: toon(0x3f7a44, 0.92),
61
+ /** The hills past the treeline. */
62
+ distant: toon(0x4a6f57, 0.98),
63
+ hoardingBoard: toon(0x2f6fd0, 0.6),
14
64
  };
15
65
  }
@@ -1,14 +1,31 @@
1
+ // Generated for you: every colour the race uses, in one place. ThreeNative does not read this file.
2
+ //
3
+ // These are afternoon-daylight values on purpose. The first version of this palette used a
4
+ // near-black road (`0x202936`) lit by a strongly yellow key light, and the blind score of the first
5
+ // frame called it a black strip in a swamp: the tarmac never came up off the shadow floor and the
6
+ // grass went olive. Tarmac is a *mid* grey — brighter than intuition says — and grass only reads as
7
+ // grass when the sun on it is close to white.
1
8
  import { BoxGeometry, Group, Mesh, MeshStandardMaterial } from "three";
2
9
 
3
10
  export const palette = {
4
- skyHigh: 0x102d56,
5
- skyLow: 0x78b8c8,
6
- road: 0x202936,
7
- field: 0x173a35,
8
- accent: 0xffcf4a,
9
- shadow: 0x07111d,
11
+ /** Zenith. Deep enough to give the dome a gradient worth having. */
12
+ skyHigh: 0x2c6cae,
13
+ /** Horizon haze, and the fog colour, so distance dissolves into the sky instead of into grey. */
14
+ skyLow: 0xbcd6e4,
15
+ /** Tarmac. Mid grey with a blue cast; anything darker eats the car's own shadow. */
16
+ road: 0x51565f,
17
+ /** Freshly cut infield. */
18
+ field: 0x5c8f45,
19
+ /** Kerbing, race numbers, boost chevrons. */
20
+ accent: 0xffc233,
21
+ /** Ambient fill and the underside of everything. Not black — black flattens. */
22
+ shadow: 0x35414f,
10
23
  } as const;
11
24
 
25
+ // The circuit's other surfaces are shades of the six roles above rather than roles of their own:
26
+ // the palette stays six named colours, and anything derived belongs beside the material that uses
27
+ // it. `materials.ts` owns them.
28
+
12
29
  const materials = new Map<string, MeshStandardMaterial>();
13
30
 
14
31
  export function toon(color: number, roughness = 0.72): MeshStandardMaterial {
@@ -1,71 +1,34 @@
1
- // Generated for you. This is ordinary Three.js — edit or delete it freely.
2
- // ThreeNative does not read this file.
1
+ // Generated for you: ordinary Three.js; ThreeNative does not read this file.
3
2
  //
4
- // `WorldEnvironment`, in this folder, builds the lighting chain: which stages run, in what
5
- // order, and an honest report of what happened. It prints `TN_WORLD_ENVIRONMENT` naming every
6
- // stage as applied or refused **with a reason**, so a stage that silently no-op'd is never
7
- // mistaken for one you turned off. It decides no colour and no strength — every value below is
8
- // an argument, and they are yours.
3
+ // This file wires two things together and decides nothing itself. `quality.ts`, in this folder,
4
+ // owns which stages run at which tier and records what each one measured. `WorldEnvironment`,
5
+ // also in this folder, builds them and prints `TN_WORLD_ENVIRONMENT` naming every stage as
6
+ // applied or refused **with a reason**, so a stage that silently no-op'd is never mistaken for
7
+ // one you turned off.
9
8
  //
10
- // SSGI and SSR are the expensive pair, so they ship on for desktop and off for mobile. That
11
- // split is the shipped default, not a ceiling: turn either on for mobile by adding it to
12
- // `mobilePreset` and read the frame cost back out of `TN_FRAME_BUDGET`. What each stage costs,
13
- // and the one-line enable for the ones that ship off everywhere (godrays, contact AO,
14
- // vignette), is in `agent-docs/visual-baseline.md`.
9
+ // To make the game cheaper or prettier everywhere, edit `quality.ts`. To force one tier for one
10
+ // run — a desktop that is dropping frames, a capture you want to compare — pass it:
11
+ // `setupPost(renderer, scene, camera, { tier: "low" })`. Overriding does not silence the report:
12
+ // `TN_QUALITY_TIER` names the tier that ran either way.
15
13
  import type { Camera, DirectionalLight, Scene } from "three";
14
+ import { type QualityTier, qualityPreset, resolveQualityTier } from "./quality.js";
16
15
  import type { OutputRenderer } from "./worldEnvironment.js";
17
16
  import { WorldEnvironment } from "./worldEnvironment.js";
18
17
 
19
- // Scene-referred exposure: multiplied into the pass before the tone curve, so the gather, the
20
- // reflections and the bloom threshold all see the same exposed image.
21
- const exposure = 1.18;
22
-
23
- // Unchanged from this template's previous chain — strength, radius and threshold are a look
24
- // decision that was already tuned to this scene's palette.
25
- const glow = {
26
- bloomEnabled: true,
27
- bloomRadius: 0.5,
28
- bloomStrength: 0.35,
29
- bloomThreshold: 0.2,
30
- } as const;
31
-
32
- const desktopPreset = {
33
- ...glow,
34
- denoiseEnabled: true,
35
- exposure,
36
- ssgiEnabled: true,
37
- // Room scale, not contact scale: about two thirds of the 45-unit shadow extent
38
- // `lighting.ts` lights — a long track: the gather radius is wide because the scene is, and the road is the one surface worth reflecting.
39
- ssgiRadius: 30,
40
- ssgiQuality: "medium",
41
- ssrEnabled: true,
42
- // `SSRNode` defaults this to **1 world unit**, which on a scene this size reads as
43
- // "reflections are on and do nothing" — the ray dies a metre from where it started.
44
- ssrMaxDistance: 75,
45
- // A reflection carries almost no high-frequency detail, so half resolution costs a quarter
46
- // of the rays and is very hard to see in the result.
47
- ssrResolutionScale: 0.5,
48
- // RCAS puts back the micro-detail the half-resolution reflection and the denoiser take out.
49
- // The same cause everywhere, so the same value everywhere: **0 is maximum sharpening and 2
50
- // is none** — it is a radius, not a gain.
51
- sharpenEnabled: true,
52
- sharpenStrength: 0.3,
53
- tonemapMode: "aces",
54
- } as const;
55
-
56
- // No SSGI, no SSR, and therefore nothing for the sharpener to put back.
57
- const mobilePreset = {
58
- ...glow,
59
- exposure,
60
- tonemapMode: "aces",
61
- } as const;
62
-
63
18
  export function setupPost(
64
19
  renderer: OutputRenderer,
65
20
  scene: Scene,
66
21
  camera: Camera,
67
- environment: { godraysLight?: DirectionalLight; mobile?: boolean } = {},
22
+ environment: {
23
+ godraysLight?: DirectionalLight;
24
+ mobile?: boolean;
25
+ /** Forces a tier, ignoring `mobile`. An unknown name throws rather than falling back. */
26
+ tier?: QualityTier;
27
+ } = {},
68
28
  ): void {
69
- const world = new WorldEnvironment(environment.mobile === true ? mobilePreset : desktopPreset);
29
+ const tier = resolveQualityTier({ mobile: environment.mobile, tier: environment.tier });
30
+ const source = environment.tier === undefined ? "platform" : "override";
31
+ console.info(`TN_QUALITY_TIER ${tier} mobile=${environment.mobile === true} source=${source}`);
32
+ const world = new WorldEnvironment(qualityPreset(tier));
70
33
  world.apply(renderer, scene, camera, { godraysLight: environment.godraysLight });
71
34
  }