create-threenative 0.2.15 → 0.2.18

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 (488) hide show
  1. package/agent-docs/kit-mcp.md +10 -0
  2. package/agent-docs/kit-router.md +14 -0
  3. package/agent-docs/kit-stuck.md +7 -0
  4. package/agent-docs/references/assertion-reference.md +54 -110
  5. package/agent-docs/references/capability-reference.md +1740 -254
  6. package/agent-docs/references/conventions.md +299 -0
  7. package/agent-docs/references/kit-action-rpg.md +40 -0
  8. package/agent-docs/references/kit-adventure.md +40 -0
  9. package/agent-docs/references/kit-collectathon.md +38 -0
  10. package/agent-docs/references/kit-kart.md +31 -0
  11. package/agent-docs/references/kit-minimal.md +29 -0
  12. package/agent-docs/references/kit-platformer.md +34 -0
  13. package/agent-docs/references/kit-puzzle.md +22 -0
  14. package/agent-docs/references/kit-racing.md +26 -0
  15. package/agent-docs/references/kit-rain.md +31 -0
  16. package/agent-docs/references/kit-rts.md +34 -0
  17. package/agent-docs/references/kit-runner.md +32 -0
  18. package/agent-docs/references/kit-sailing.md +41 -0
  19. package/agent-docs/references/kit-shooter.md +33 -0
  20. package/agent-docs/references/kit-snow.md +33 -0
  21. package/agent-docs/references/kit-starter.md +55 -0
  22. package/agent-docs/references/kit-tower-defense.md +27 -0
  23. package/agent-docs/references/performance-basics.md +8 -4
  24. package/agent-docs/references/terrain-authoring.md +2 -1
  25. package/agent-files/.agents/skills/ponytail/SKILL.md +1 -1
  26. package/agent-files/.agents/skills/prd-creator/SKILL.md +3 -2
  27. package/agent-files/.agents/skills/threenative-capabilities/SKILL.md +84 -59
  28. package/agent-files/.claude/hooks/discovery-gate.mjs +125 -0
  29. package/agent-files/.claude/hooks/ponytail-context.mjs +1 -1
  30. package/agent-files/.claude/settings.json +25 -0
  31. package/agent-files/.codex/hooks.json +18 -1
  32. package/dist/index.d.ts +97 -6
  33. package/dist/index.js +899 -271
  34. package/dist/terrain-kit.d.ts +7 -0
  35. package/dist/terrain-kit.js +82 -0
  36. package/dist/threenative.js +114 -16
  37. package/dist/web-engine-ccd-ik-solver.js +127 -0
  38. package/dist/web-engine-gltf-loader.js +71 -20
  39. package/dist/web-engine-post-effects.js +39 -14
  40. package/dist/web-engine-runtime.js +10011 -4101
  41. package/package.json +15 -9
  42. package/template-assets/clearwater/README.md +1 -1
  43. package/template-assets/patches/manifest.json +18 -0
  44. package/template-assets/patches/three@0.187.0.patch +2004 -407
  45. package/template-assets/terrain/alpine/assets.json +12 -0
  46. package/template-assets/terrain/alpine/bake.mjs +6 -0
  47. package/template-assets/terrain/alpine/credits.json +164 -0
  48. package/template-assets/terrain/alpine/heightmap.r16 +0 -0
  49. package/template-assets/terrain/alpine/recipe.json +119 -0
  50. package/template-assets/terrain/alpine/surface.json +53 -0
  51. package/template-assets/terrain/coastal/assets.json +11 -0
  52. package/template-assets/terrain/coastal/bake.mjs +6 -0
  53. package/template-assets/terrain/coastal/credits.json +117 -0
  54. package/template-assets/terrain/coastal/heightmap.r16 +0 -0
  55. package/template-assets/terrain/coastal/recipe.json +113 -0
  56. package/template-assets/terrain/coastal/surface.json +41 -0
  57. package/template-assets/terrain/desert/assets.json +12 -0
  58. package/template-assets/terrain/desert/bake.mjs +6 -0
  59. package/template-assets/terrain/desert/credits.json +164 -0
  60. package/template-assets/terrain/desert/heightmap.r16 +0 -0
  61. package/template-assets/terrain/desert/recipe.json +108 -0
  62. package/template-assets/terrain/desert/surface.json +54 -0
  63. package/template-assets/terrain/forest/assets.json +65 -0
  64. package/template-assets/terrain/forest/bake.mjs +8 -0
  65. package/template-assets/terrain/forest/credits.json +225 -0
  66. package/template-assets/terrain/forest/heightmap.r16 +0 -0
  67. package/template-assets/terrain/forest/recipe.json +350 -0
  68. package/template-assets/terrain/forest/surface.json +79 -0
  69. package/template-assets/terrain/tundra/assets.json +12 -0
  70. package/template-assets/terrain/tundra/bake.mjs +6 -0
  71. package/template-assets/terrain/tundra/credits.json +164 -0
  72. package/template-assets/terrain/tundra/heightmap.r16 +0 -0
  73. package/template-assets/terrain/tundra/recipe.json +277 -0
  74. package/template-assets/terrain/tundra/surface.json +54 -0
  75. package/templates/action-rpg/AGENTS.md +103 -84
  76. package/templates/action-rpg/CLAUDE.md +103 -84
  77. package/templates/action-rpg/kit.json +1 -0
  78. package/templates/action-rpg/package.json +7 -7
  79. package/templates/action-rpg/playtests/spells.playtest.json +20 -0
  80. package/templates/action-rpg/src/game.ts +2 -1
  81. package/templates/action-rpg/src/render/atmosphere.ts +11 -16
  82. package/templates/action-rpg/src/render/backlightControls.ts +10 -0
  83. package/templates/action-rpg/src/render/backlightMaterial.ts +4 -4
  84. package/templates/action-rpg/src/render/clouds.ts +13 -0
  85. package/templates/action-rpg/src/render/gpuSky.ts +4 -7
  86. package/templates/action-rpg/src/render/materialLighting.ts +5 -5
  87. package/templates/action-rpg/src/render/quality.ts +10 -33
  88. package/templates/action-rpg/src/scenes/Play.ts +30 -1
  89. package/templates/action-rpg/src/style.css +4 -0
  90. package/templates/action-rpg/src/ui/AbilityBar.tsx +1 -1
  91. package/templates/action-rpg/threenative.config.ts +0 -3
  92. package/templates/action-rpg/vite.config.ts +2 -0
  93. package/templates/adventure/AGENTS.md +92 -44
  94. package/templates/adventure/CLAUDE.md +92 -44
  95. package/templates/adventure/kit.json +5 -1
  96. package/templates/adventure/package.json +7 -7
  97. package/templates/adventure/src/game.ts +1 -1
  98. package/templates/adventure/src/style.css +4 -0
  99. package/templates/adventure/tsconfig.json +1 -1
  100. package/templates/adventure/vite.config.ts +2 -0
  101. package/templates/collectathon/AGENTS.md +93 -42
  102. package/templates/collectathon/CLAUDE.md +93 -42
  103. package/templates/collectathon/package.json +7 -7
  104. package/templates/collectathon/src/game.ts +1 -1
  105. package/templates/collectathon/src/level/Course.ts +55 -9
  106. package/templates/collectathon/src/level/terrain.ts +27 -6
  107. package/templates/collectathon/src/main.ts +1 -0
  108. package/templates/collectathon/src/render/foliage.ts +359 -98
  109. package/templates/collectathon/src/render/sky.ts +76 -12
  110. package/templates/collectathon/src/render/water.ts +32 -10
  111. package/templates/collectathon/src/scenes/Play.ts +18 -5
  112. package/templates/collectathon/src/style.css +4 -0
  113. package/templates/collectathon/tsconfig.json +1 -1
  114. package/templates/collectathon/vite.config.ts +2 -0
  115. package/templates/kart/AGENTS.md +87 -42
  116. package/templates/kart/CLAUDE.md +87 -42
  117. package/templates/kart/package.json +6 -6
  118. package/templates/kart/src/game.ts +1 -1
  119. package/templates/kart/src/main.ts +1 -0
  120. package/templates/kart/src/style.css +4 -0
  121. package/templates/kart/tsconfig.json +1 -1
  122. package/templates/kart/vite.config.ts +2 -0
  123. package/templates/minimal/AGENTS.md +105 -84
  124. package/templates/minimal/CLAUDE.md +105 -84
  125. package/templates/minimal/package.json +6 -6
  126. package/templates/minimal/playtests/stands-still.playtest.json +30 -0
  127. package/templates/minimal/src/game.ts +1 -1
  128. package/templates/minimal/src/render/atmosphere.ts +11 -16
  129. package/templates/minimal/src/render/backlightControls.ts +10 -0
  130. package/templates/minimal/src/render/backlightMaterial.ts +4 -4
  131. package/templates/minimal/src/render/camera.ts +13 -2
  132. package/templates/minimal/src/render/clouds.ts +13 -0
  133. package/templates/minimal/src/render/gpuSky.ts +4 -7
  134. package/templates/minimal/src/render/lighting.ts +4 -2
  135. package/templates/minimal/src/render/materialLighting.ts +5 -5
  136. package/templates/minimal/src/render/materials.ts +10 -0
  137. package/templates/minimal/src/render/quality.ts +7 -32
  138. package/templates/minimal/src/scenes/Play.ts +4 -1
  139. package/templates/minimal/vite.config.ts +7 -1
  140. package/templates/platformer/AGENTS.md +95 -46
  141. package/templates/platformer/CLAUDE.md +95 -46
  142. package/templates/platformer/index.html +1 -1
  143. package/templates/platformer/main.html +12 -0
  144. package/templates/platformer/package.json +7 -7
  145. package/templates/platformer/playtests/gamepad-idle.playtest.json +21 -0
  146. package/templates/platformer/playtests/gamepad.playtest.json +30 -0
  147. package/templates/platformer/src/entities/Fox.ts +21 -6
  148. package/templates/platformer/src/game.ts +1 -1
  149. package/templates/platformer/src/main.ts +1 -0
  150. package/templates/platformer/src/render/backlightControls.ts +10 -0
  151. package/templates/platformer/src/render/backlightMaterial.ts +4 -4
  152. package/templates/platformer/src/render/materialLighting.ts +5 -5
  153. package/templates/platformer/src/render/quality.ts +7 -32
  154. package/templates/platformer/src/scenes/Play.ts +2 -1
  155. package/templates/platformer/src/style.css +4 -0
  156. package/templates/platformer/src/worker-page.ts +29 -0
  157. package/templates/platformer/src/worker.ts +5 -0
  158. package/templates/platformer/tsconfig.json +1 -1
  159. package/templates/platformer/vite.config.ts +4 -0
  160. package/templates/puzzle/AGENTS.md +97 -80
  161. package/templates/puzzle/CLAUDE.md +97 -80
  162. package/templates/puzzle/package.json +7 -7
  163. package/templates/puzzle/src/game.ts +1 -1
  164. package/templates/puzzle/src/render/backlightControls.ts +10 -0
  165. package/templates/puzzle/src/render/backlightMaterial.ts +4 -4
  166. package/templates/puzzle/src/render/materialLighting.ts +5 -5
  167. package/templates/puzzle/src/render/quality.ts +7 -32
  168. package/templates/puzzle/src/scenes/Play.ts +1 -1
  169. package/templates/puzzle/src/style.css +4 -0
  170. package/templates/puzzle/tsconfig.json +1 -1
  171. package/templates/puzzle/vite.config.ts +2 -0
  172. package/templates/racing/AGENTS.md +100 -82
  173. package/templates/racing/CLAUDE.md +100 -82
  174. package/templates/racing/package.json +7 -7
  175. package/templates/racing/src/game.ts +1 -1
  176. package/templates/racing/src/render/atmosphere.ts +11 -16
  177. package/templates/racing/src/render/backlightControls.ts +10 -0
  178. package/templates/racing/src/render/backlightMaterial.ts +4 -4
  179. package/templates/racing/src/render/clouds.ts +13 -0
  180. package/templates/racing/src/render/gpuSky.ts +4 -7
  181. package/templates/racing/src/render/materialLighting.ts +5 -5
  182. package/templates/racing/src/render/quality.ts +7 -32
  183. package/templates/racing/src/scenes/Race.ts +4 -1
  184. package/templates/racing/src/style.css +4 -0
  185. package/templates/racing/tsconfig.json +1 -1
  186. package/templates/racing/vite.config.ts +2 -0
  187. package/templates/rain/AGENTS.md +96 -84
  188. package/templates/rain/CLAUDE.md +96 -84
  189. package/templates/rain/native-playtests/lightning.playtest.json +85 -10
  190. package/templates/rain/package.json +6 -6
  191. package/templates/rain/playtests/reduced-motion.playtest.json +6 -0
  192. package/templates/rain/src/game.ts +1 -1
  193. package/templates/rain/src/scenes/Boot.ts +1 -0
  194. package/templates/rain/src/state.ts +7 -0
  195. package/templates/rain/src/ui/GameUi.tsx +7 -1
  196. package/templates/rain/vite.config.ts +6 -0
  197. package/templates/rts/AGENTS.md +100 -85
  198. package/templates/rts/CLAUDE.md +100 -85
  199. package/templates/rts/package.json +6 -6
  200. package/templates/rts/src/game.ts +1 -1
  201. package/templates/rts/src/render/backlightControls.ts +10 -0
  202. package/templates/rts/src/render/backlightMaterial.ts +4 -4
  203. package/templates/rts/src/render/materialLighting.ts +5 -5
  204. package/templates/rts/src/render/quality.ts +7 -31
  205. package/templates/rts/src/scenes/Play.ts +1 -1
  206. package/templates/rts/src/style.css +4 -0
  207. package/templates/rts/vite.config.ts +2 -0
  208. package/templates/runner/AGENTS.md +97 -80
  209. package/templates/runner/CLAUDE.md +97 -80
  210. package/templates/runner/package.json +7 -7
  211. package/templates/runner/playtests/performance.playtest.json +1 -1
  212. package/templates/runner/src/game.ts +1 -1
  213. package/templates/runner/src/render/atmosphere.ts +11 -16
  214. package/templates/runner/src/render/backlightControls.ts +10 -0
  215. package/templates/runner/src/render/backlightMaterial.ts +4 -4
  216. package/templates/runner/src/render/clouds.ts +13 -0
  217. package/templates/runner/src/render/gpuSky.ts +4 -7
  218. package/templates/runner/src/render/lighting.ts +53 -11
  219. package/templates/runner/src/render/materialLighting.ts +5 -5
  220. package/templates/runner/src/render/quality.ts +7 -32
  221. package/templates/runner/src/scenes/Run.ts +8 -4
  222. package/templates/runner/src/style.css +4 -0
  223. package/templates/runner/threenative.config.ts +0 -3
  224. package/templates/runner/tsconfig.json +1 -1
  225. package/templates/runner/vite.config.ts +2 -0
  226. package/templates/sailing/AGENTS.md +96 -79
  227. package/templates/sailing/CLAUDE.md +96 -79
  228. package/templates/sailing/package.json +7 -7
  229. package/templates/sailing/playtests/sails.playtest.json +1 -0
  230. package/templates/sailing/src/game.ts +1 -1
  231. package/templates/sailing/src/render/backlightControls.ts +10 -0
  232. package/templates/sailing/src/render/backlightMaterial.ts +4 -4
  233. package/templates/sailing/src/render/environmentSetup.ts +1 -1
  234. package/templates/sailing/src/render/materialLighting.ts +5 -5
  235. package/templates/sailing/src/render/quality.ts +7 -32
  236. package/templates/sailing/src/render/sky.ts +4 -0
  237. package/templates/sailing/src/style.css +5 -0
  238. package/templates/sailing/threenative.config.ts +0 -3
  239. package/templates/sailing/vite.config.ts +6 -0
  240. package/templates/shooter/AGENTS.md +97 -68
  241. package/templates/shooter/CLAUDE.md +97 -68
  242. package/templates/shooter/package.json +7 -7
  243. package/templates/shooter/src/game.ts +3 -2
  244. package/templates/shooter/src/render/atmosphere.ts +11 -16
  245. package/templates/shooter/src/render/backlightControls.ts +10 -0
  246. package/templates/shooter/src/render/backlightMaterial.ts +4 -4
  247. package/templates/shooter/src/render/clouds.ts +13 -0
  248. package/templates/shooter/src/render/gpuSky.ts +4 -7
  249. package/templates/shooter/src/render/materialLighting.ts +5 -5
  250. package/templates/shooter/src/render/quality.ts +10 -33
  251. package/templates/shooter/src/scenes/Play.ts +4 -1
  252. package/templates/shooter/src/style.css +4 -0
  253. package/templates/shooter/vite.config.ts +2 -0
  254. package/templates/snow/AGENTS.md +95 -76
  255. package/templates/snow/CLAUDE.md +95 -76
  256. package/templates/snow/package.json +7 -7
  257. package/templates/snow/src/game.ts +1 -1
  258. package/templates/snow/src/render/backlightControls.ts +10 -0
  259. package/templates/snow/src/render/backlightMaterial.ts +4 -4
  260. package/templates/snow/src/render/materialLighting.ts +5 -5
  261. package/templates/snow/src/render/quality.ts +7 -32
  262. package/templates/snow/src/style.css +5 -0
  263. package/templates/snow/threenative.config.ts +0 -3
  264. package/templates/snow/vite.config.ts +6 -0
  265. package/templates/starter/AGENTS.md +109 -88
  266. package/templates/starter/CLAUDE.md +109 -88
  267. package/templates/starter/native-playtests/render-chain.playtest.json +24 -24
  268. package/templates/starter/native-playtests/smooth-motion.playtest.json +3 -3
  269. package/templates/starter/package.json +7 -7
  270. package/templates/starter/src/entities/Crate.ts +5 -2
  271. package/templates/starter/src/entities/Player.ts +10 -22
  272. package/templates/starter/src/game.ts +4 -3
  273. package/templates/starter/src/render/adaptiveQuality.ts +17 -0
  274. package/templates/starter/src/render/atmosphere.ts +11 -16
  275. package/templates/starter/src/render/backlightControls.ts +10 -0
  276. package/templates/starter/src/render/backlightMaterial.ts +4 -4
  277. package/templates/starter/src/render/clouds.ts +13 -0
  278. package/templates/starter/src/render/contactShadow.ts +1 -1
  279. package/templates/starter/src/render/gpuSky.ts +4 -7
  280. package/templates/starter/src/render/lighting.ts +54 -4
  281. package/templates/starter/src/render/materialLighting.ts +5 -5
  282. package/templates/starter/src/render/postprocessing.ts +11 -10
  283. package/templates/starter/src/render/quality.ts +14 -1
  284. package/templates/starter/src/render/temporalAA.ts +8 -7
  285. package/templates/starter/src/render/temporalAAFrame.ts +30 -9
  286. package/templates/starter/src/render/temporalAAResolve.ts +15 -1
  287. package/templates/starter/src/render/temporalClampRelease.ts +183 -0
  288. package/templates/starter/src/render/temporalHistoryResolve.ts +90 -0
  289. package/templates/starter/src/render/temporalMoire.ts +190 -0
  290. package/templates/starter/src/render/temporalResolve.ts +75 -16
  291. package/templates/starter/src/render/temporalResolveDepth.ts +2 -0
  292. package/templates/starter/src/scenes/Play.ts +53 -32
  293. package/templates/starter/src/state.ts +2 -0
  294. package/templates/starter/src/style.css +4 -0
  295. package/templates/starter/src/ui/Menu.tsx +5 -1
  296. package/templates/starter/vite.config.ts +2 -0
  297. package/templates/tower-defense/AGENTS.md +97 -81
  298. package/templates/tower-defense/CLAUDE.md +97 -81
  299. package/templates/tower-defense/package.json +7 -7
  300. package/templates/tower-defense/src/game.ts +1 -1
  301. package/templates/tower-defense/src/render/backlightControls.ts +10 -0
  302. package/templates/tower-defense/src/render/backlightMaterial.ts +4 -4
  303. package/templates/tower-defense/src/render/materialLighting.ts +5 -5
  304. package/templates/tower-defense/src/render/quality.ts +7 -32
  305. package/templates/tower-defense/src/scenes/Battle.ts +1 -1
  306. package/templates/tower-defense/src/style.css +4 -0
  307. package/templates/tower-defense/tsconfig.json +1 -1
  308. package/templates/tower-defense/vite.config.ts +2 -0
  309. package/capabilities.json +0 -9197
  310. package/templates/AGENTS.md +0 -21
  311. package/templates/CLAUDE.md +0 -23
  312. package/templates/action-rpg/.codex/config.toml +0 -23
  313. package/templates/action-rpg/.cursor/mcp.json +0 -38
  314. package/templates/action-rpg/.gemini/settings.json +0 -38
  315. package/templates/action-rpg/.mcp.json +0 -38
  316. package/templates/action-rpg/.vscode/mcp.json +0 -43
  317. package/templates/action-rpg/.zed/settings.json +0 -43
  318. package/templates/action-rpg/opencode.json +0 -49
  319. package/templates/action-rpg/src/render/environmentContribution.ts +0 -188
  320. package/templates/action-rpg/src/render/environmentRadiance.ts +0 -36
  321. package/templates/action-rpg/src/render/environmentSampleCache.ts +0 -43
  322. package/templates/action-rpg/src/render/environmentSampling.ts +0 -193
  323. package/templates/action-rpg/src/render/environmentSnapshot.ts +0 -53
  324. package/templates/adventure/.codex/config.toml +0 -23
  325. package/templates/adventure/.cursor/mcp.json +0 -38
  326. package/templates/adventure/.gemini/settings.json +0 -38
  327. package/templates/adventure/.mcp.json +0 -38
  328. package/templates/adventure/.vscode/mcp.json +0 -43
  329. package/templates/adventure/.zed/settings.json +0 -43
  330. package/templates/adventure/opencode.json +0 -49
  331. package/templates/collectathon/.codex/config.toml +0 -23
  332. package/templates/collectathon/.cursor/mcp.json +0 -38
  333. package/templates/collectathon/.gemini/settings.json +0 -38
  334. package/templates/collectathon/.mcp.json +0 -38
  335. package/templates/collectathon/.vscode/mcp.json +0 -43
  336. package/templates/collectathon/.zed/settings.json +0 -43
  337. package/templates/collectathon/opencode.json +0 -49
  338. package/templates/kart/.codex/config.toml +0 -23
  339. package/templates/kart/.cursor/mcp.json +0 -38
  340. package/templates/kart/.gemini/settings.json +0 -38
  341. package/templates/kart/.mcp.json +0 -38
  342. package/templates/kart/.vscode/mcp.json +0 -43
  343. package/templates/kart/.zed/settings.json +0 -43
  344. package/templates/kart/opencode.json +0 -49
  345. package/templates/minimal/.codex/config.toml +0 -23
  346. package/templates/minimal/.cursor/mcp.json +0 -38
  347. package/templates/minimal/.gemini/settings.json +0 -38
  348. package/templates/minimal/.mcp.json +0 -38
  349. package/templates/minimal/.vscode/mcp.json +0 -43
  350. package/templates/minimal/.zed/settings.json +0 -43
  351. package/templates/minimal/opencode.json +0 -49
  352. package/templates/minimal/src/render/environmentContribution.ts +0 -188
  353. package/templates/minimal/src/render/environmentRadiance.ts +0 -36
  354. package/templates/minimal/src/render/environmentSampleCache.ts +0 -43
  355. package/templates/minimal/src/render/environmentSampling.ts +0 -193
  356. package/templates/minimal/src/render/environmentSnapshot.ts +0 -53
  357. package/templates/platformer/.codex/config.toml +0 -23
  358. package/templates/platformer/.cursor/mcp.json +0 -38
  359. package/templates/platformer/.gemini/settings.json +0 -38
  360. package/templates/platformer/.mcp.json +0 -38
  361. package/templates/platformer/.vscode/mcp.json +0 -43
  362. package/templates/platformer/.zed/settings.json +0 -43
  363. package/templates/platformer/opencode.json +0 -49
  364. package/templates/platformer/src/render/environmentContribution.ts +0 -188
  365. package/templates/platformer/src/render/environmentRadiance.ts +0 -36
  366. package/templates/platformer/src/render/environmentSampleCache.ts +0 -43
  367. package/templates/platformer/src/render/environmentSampling.ts +0 -193
  368. package/templates/platformer/src/render/environmentSnapshot.ts +0 -53
  369. package/templates/puzzle/.codex/config.toml +0 -23
  370. package/templates/puzzle/.cursor/mcp.json +0 -38
  371. package/templates/puzzle/.gemini/settings.json +0 -38
  372. package/templates/puzzle/.mcp.json +0 -38
  373. package/templates/puzzle/.vscode/mcp.json +0 -43
  374. package/templates/puzzle/.zed/settings.json +0 -43
  375. package/templates/puzzle/opencode.json +0 -49
  376. package/templates/puzzle/src/render/environmentContribution.ts +0 -188
  377. package/templates/puzzle/src/render/environmentRadiance.ts +0 -36
  378. package/templates/puzzle/src/render/environmentSampleCache.ts +0 -43
  379. package/templates/puzzle/src/render/environmentSampling.ts +0 -193
  380. package/templates/puzzle/src/render/environmentSnapshot.ts +0 -53
  381. package/templates/racing/.codex/config.toml +0 -23
  382. package/templates/racing/.cursor/mcp.json +0 -38
  383. package/templates/racing/.gemini/settings.json +0 -38
  384. package/templates/racing/.mcp.json +0 -38
  385. package/templates/racing/.vscode/mcp.json +0 -43
  386. package/templates/racing/.zed/settings.json +0 -43
  387. package/templates/racing/opencode.json +0 -49
  388. package/templates/racing/src/render/environmentContribution.ts +0 -188
  389. package/templates/racing/src/render/environmentRadiance.ts +0 -36
  390. package/templates/racing/src/render/environmentSampleCache.ts +0 -43
  391. package/templates/racing/src/render/environmentSampling.ts +0 -193
  392. package/templates/racing/src/render/environmentSnapshot.ts +0 -53
  393. package/templates/rain/.codex/config.toml +0 -23
  394. package/templates/rain/.cursor/mcp.json +0 -38
  395. package/templates/rain/.gemini/settings.json +0 -38
  396. package/templates/rain/.mcp.json +0 -38
  397. package/templates/rain/.vscode/mcp.json +0 -43
  398. package/templates/rain/.zed/settings.json +0 -43
  399. package/templates/rain/opencode.json +0 -49
  400. package/templates/rts/.codex/config.toml +0 -23
  401. package/templates/rts/.cursor/mcp.json +0 -38
  402. package/templates/rts/.gemini/settings.json +0 -38
  403. package/templates/rts/.mcp.json +0 -38
  404. package/templates/rts/.vscode/mcp.json +0 -43
  405. package/templates/rts/.zed/settings.json +0 -43
  406. package/templates/rts/opencode.json +0 -49
  407. package/templates/rts/src/render/environmentContribution.ts +0 -188
  408. package/templates/rts/src/render/environmentRadiance.ts +0 -36
  409. package/templates/rts/src/render/environmentSampleCache.ts +0 -43
  410. package/templates/rts/src/render/environmentSampling.ts +0 -193
  411. package/templates/rts/src/render/environmentSnapshot.ts +0 -53
  412. package/templates/runner/.codex/config.toml +0 -23
  413. package/templates/runner/.cursor/mcp.json +0 -38
  414. package/templates/runner/.gemini/settings.json +0 -38
  415. package/templates/runner/.mcp.json +0 -38
  416. package/templates/runner/.vscode/mcp.json +0 -43
  417. package/templates/runner/.zed/settings.json +0 -43
  418. package/templates/runner/README.md +0 -43
  419. package/templates/runner/opencode.json +0 -49
  420. package/templates/runner/src/render/environmentContribution.ts +0 -188
  421. package/templates/runner/src/render/environmentRadiance.ts +0 -36
  422. package/templates/runner/src/render/environmentSampleCache.ts +0 -43
  423. package/templates/runner/src/render/environmentSampling.ts +0 -193
  424. package/templates/runner/src/render/environmentSnapshot.ts +0 -53
  425. package/templates/sailing/.codex/config.toml +0 -23
  426. package/templates/sailing/.cursor/mcp.json +0 -38
  427. package/templates/sailing/.gemini/settings.json +0 -38
  428. package/templates/sailing/.mcp.json +0 -38
  429. package/templates/sailing/.vscode/mcp.json +0 -43
  430. package/templates/sailing/.zed/settings.json +0 -43
  431. package/templates/sailing/README.md +0 -28
  432. package/templates/sailing/opencode.json +0 -49
  433. package/templates/sailing/src/render/environmentContribution.ts +0 -188
  434. package/templates/sailing/src/render/environmentRadiance.ts +0 -36
  435. package/templates/sailing/src/render/environmentSampleCache.ts +0 -43
  436. package/templates/sailing/src/render/environmentSampling.ts +0 -193
  437. package/templates/sailing/src/render/environmentSnapshot.ts +0 -53
  438. package/templates/shooter/.codex/config.toml +0 -23
  439. package/templates/shooter/.cursor/mcp.json +0 -38
  440. package/templates/shooter/.gemini/settings.json +0 -38
  441. package/templates/shooter/.mcp.json +0 -38
  442. package/templates/shooter/.vscode/mcp.json +0 -43
  443. package/templates/shooter/.zed/settings.json +0 -43
  444. package/templates/shooter/opencode.json +0 -49
  445. package/templates/shooter/src/render/environmentContribution.ts +0 -188
  446. package/templates/shooter/src/render/environmentRadiance.ts +0 -36
  447. package/templates/shooter/src/render/environmentSampleCache.ts +0 -43
  448. package/templates/shooter/src/render/environmentSampling.ts +0 -193
  449. package/templates/shooter/src/render/environmentSnapshot.ts +0 -53
  450. package/templates/snow/.codex/config.toml +0 -23
  451. package/templates/snow/.cursor/mcp.json +0 -38
  452. package/templates/snow/.gemini/settings.json +0 -38
  453. package/templates/snow/.mcp.json +0 -38
  454. package/templates/snow/.vscode/mcp.json +0 -43
  455. package/templates/snow/.zed/settings.json +0 -43
  456. package/templates/snow/README.md +0 -26
  457. package/templates/snow/opencode.json +0 -49
  458. package/templates/snow/src/render/environmentContribution.ts +0 -188
  459. package/templates/snow/src/render/environmentRadiance.ts +0 -36
  460. package/templates/snow/src/render/environmentSampleCache.ts +0 -43
  461. package/templates/snow/src/render/environmentSampling.ts +0 -193
  462. package/templates/snow/src/render/environmentSnapshot.ts +0 -53
  463. package/templates/starter/.codex/config.toml +0 -23
  464. package/templates/starter/.cursor/mcp.json +0 -38
  465. package/templates/starter/.gemini/settings.json +0 -38
  466. package/templates/starter/.mcp.json +0 -38
  467. package/templates/starter/.vscode/mcp.json +0 -43
  468. package/templates/starter/.zed/settings.json +0 -43
  469. package/templates/starter/opencode.json +0 -49
  470. package/templates/starter/src/render/environmentContribution.ts +0 -188
  471. package/templates/starter/src/render/environmentRadiance.ts +0 -36
  472. package/templates/starter/src/render/environmentSampleCache.ts +0 -43
  473. package/templates/starter/src/render/environmentSampling.ts +0 -193
  474. package/templates/starter/src/render/environmentSnapshot.ts +0 -53
  475. package/templates/starter/src/render/rendererGate.ts +0 -36
  476. package/templates/tower-defense/.codex/config.toml +0 -23
  477. package/templates/tower-defense/.cursor/mcp.json +0 -38
  478. package/templates/tower-defense/.gemini/settings.json +0 -38
  479. package/templates/tower-defense/.mcp.json +0 -38
  480. package/templates/tower-defense/.vscode/mcp.json +0 -43
  481. package/templates/tower-defense/.zed/settings.json +0 -43
  482. package/templates/tower-defense/README.md +0 -16
  483. package/templates/tower-defense/opencode.json +0 -49
  484. package/templates/tower-defense/src/render/environmentContribution.ts +0 -188
  485. package/templates/tower-defense/src/render/environmentRadiance.ts +0 -36
  486. package/templates/tower-defense/src/render/environmentSampleCache.ts +0 -43
  487. package/templates/tower-defense/src/render/environmentSampling.ts +0 -193
  488. package/templates/tower-defense/src/render/environmentSnapshot.ts +0 -53
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copies one packaged terrain kit into a new game-owned folder.
3
+ * It checks the name, the packaged inputs and the target before it writes.
4
+ */
5
+ declare function copyTerrainKit(kit: string, targetPath: string, templatesRoot?: string): Promise<void>;
6
+
7
+ export { copyTerrainKit };
@@ -0,0 +1,82 @@
1
+ import { createRequire } from 'node:module';
2
+ import { lstat, readFile, mkdir, writeFile } from 'fs/promises';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ createRequire(import.meta.url);
7
+ var KITS = ["alpine", "coastal", "desert", "forest", "tundra"];
8
+ var COPIED = [
9
+ "assets.json",
10
+ "bake.mjs",
11
+ "credits.json",
12
+ "heightmap.r16",
13
+ "recipe.json",
14
+ "surface.json"
15
+ ];
16
+ var DEFAULT_TEMPLATES_ROOT = path.resolve(
17
+ path.dirname(fileURLToPath(import.meta.url)),
18
+ "../templates"
19
+ );
20
+ async function assertNoSymlinkAncestor(target) {
21
+ let dir = path.dirname(path.resolve(target));
22
+ for (; ; ) {
23
+ const info = await lstat(dir).catch((error) => {
24
+ if (error.code === "ENOENT") return null;
25
+ throw error;
26
+ });
27
+ if (info?.isSymbolicLink()) {
28
+ throw new Error(
29
+ `TN_TERRAIN_KIT_SYMLINK: A parent folder is a symlink: ${dir}. Choose a target path with real parent folders.`
30
+ );
31
+ }
32
+ if (info !== null) return;
33
+ const parent = path.dirname(dir);
34
+ if (parent === dir) return;
35
+ dir = parent;
36
+ }
37
+ }
38
+ async function copyTerrainKit(kit, targetPath, templatesRoot = DEFAULT_TEMPLATES_ROOT) {
39
+ const target = path.resolve(targetPath);
40
+ if (!KITS.includes(kit)) {
41
+ throw new Error(
42
+ `TN_TERRAIN_KIT_NAME: "${kit}" is not a packaged terrain kit. Use one of: ${KITS.join(", ")}.`
43
+ );
44
+ }
45
+ const sourceDir = path.join(path.resolve(templatesRoot, "..", "template-assets", "terrain"), kit);
46
+ const sourceStat = await lstat(sourceDir).catch(() => null);
47
+ if (!sourceStat)
48
+ throw new Error(
49
+ `TN_TERRAIN_KIT_UNKNOWN: The packaged folder for "${kit}" is missing: ${sourceDir}.`
50
+ );
51
+ if (!sourceStat.isDirectory()) {
52
+ throw new Error(
53
+ `TN_TERRAIN_KIT_SOURCE: The packaged folder is not a real directory: ${sourceDir}.`
54
+ );
55
+ }
56
+ const bytes = /* @__PURE__ */ new Map();
57
+ for (const file of COPIED) {
58
+ const source = path.join(sourceDir, file);
59
+ if (!(await lstat(source).catch(() => null))?.isFile()) {
60
+ throw new Error(
61
+ `TN_TERRAIN_KIT_SOURCE: The packaged input is missing or not a regular file: ${source}.`
62
+ );
63
+ }
64
+ bytes.set(file, await readFile(source));
65
+ }
66
+ const targetStat = await lstat(target).catch(() => null);
67
+ if (targetStat?.isSymbolicLink()) {
68
+ throw new Error(
69
+ `TN_TERRAIN_KIT_SYMLINK: The target is a symlink. Choose a real folder: ${target}.`
70
+ );
71
+ }
72
+ if (targetStat)
73
+ throw new Error(
74
+ `TN_TERRAIN_KIT_EXISTS: The target already exists. Choose a new folder: ${target}.`
75
+ );
76
+ await assertNoSymlinkAncestor(target);
77
+ await mkdir(path.dirname(target), { recursive: true });
78
+ await mkdir(target);
79
+ for (const [file, data] of bytes) await writeFile(path.join(target, file), data, { flag: "wx" });
80
+ }
81
+
82
+ export { copyTerrainKit };
@@ -13,6 +13,7 @@ import { compileAssets, parsePng, parseAudioConfig } from '@threenative/assets';
13
13
  import { read, VK_FORMAT_ASTC_4x4_UNORM_BLOCK, VK_FORMAT_ASTC_4x4_SRGB_BLOCK, KHR_SUPERCOMPRESSION_NONE, KHR_DF_MODEL_ASTC, KHR_DF_TRANSFER_SRGB, KHR_DF_TRANSFER_LINEAR } from 'ktx-parse';
14
14
  import { brotliCompressSync, constants as constants$1, gzipSync } from 'zlib';
15
15
  import { platform, homedir } from 'os';
16
+ import { fixAuthoringLayer, authoringLayerStatus } from './index.js';
16
17
 
17
18
  createRequire(import.meta.url);
18
19
  var BUILD_REPORT_SUFFIX = ".build-report.json";
@@ -184,6 +185,13 @@ function positiveInteger(value, fallback, code, label) {
184
185
  }
185
186
  return value;
186
187
  }
188
+ function priorityValue(value) {
189
+ if (value === void 0) return "game";
190
+ if (value !== "game" && value !== "normal") {
191
+ fail("TN_CONFIG_PRIORITY_INVALID", 'display.priority must be "game" or "normal".');
192
+ }
193
+ return value;
194
+ }
187
195
  function maxFpsValue(value) {
188
196
  if (value === void 0) return 60;
189
197
  if (!Number.isSafeInteger(value) || value < 0 || value > 1e3) {
@@ -285,6 +293,10 @@ function resolveEsbuild(cwd) {
285
293
  }
286
294
  }
287
295
  }
296
+ var configLoadSequence = 0;
297
+ function configTempName(cwd, pid, now, sequence) {
298
+ return path5.join(cwd, `.threenative.config.${pid}.${now}.${sequence}.mjs`);
299
+ }
288
300
  async function importConfig(cwd) {
289
301
  const sourcePath = path5.join(cwd, CONFIG_FILE);
290
302
  try {
@@ -347,7 +359,8 @@ async function importConfig(cwd) {
347
359
  error instanceof Error ? error.message : String(error)
348
360
  );
349
361
  }
350
- const compiledPath = path5.join(cwd, `.threenative.config.${process.pid}.${Date.now()}.mjs`);
362
+ configLoadSequence += 1;
363
+ const compiledPath = configTempName(cwd, process.pid, Date.now(), configLoadSequence);
351
364
  try {
352
365
  await writeFile(compiledPath, code, "utf8");
353
366
  } catch (error) {
@@ -622,7 +635,13 @@ async function validateIconVariants(raw, cwd) {
622
635
  }
623
636
  function validateDisplay(raw) {
624
637
  const display = assertRecord(raw, "display");
625
- assertKeys(display, "display", ["orientation", "fullscreen", "keepScreenOn", "maxFps"]);
638
+ assertKeys(display, "display", [
639
+ "orientation",
640
+ "fullscreen",
641
+ "keepScreenOn",
642
+ "priority",
643
+ "maxFps"
644
+ ]);
626
645
  const orientation = display.orientation === void 0 ? "landscape" : display.orientation;
627
646
  if (typeof orientation !== "string" || !ORIENTATIONS.includes(orientation)) {
628
647
  fail(
@@ -644,6 +663,7 @@ function validateDisplay(raw) {
644
663
  "TN_CONFIG_KEEP_SCREEN_ON_INVALID",
645
664
  "display.keepScreenOn"
646
665
  ),
666
+ priority: priorityValue(display.priority),
647
667
  maxFps: maxFpsValue(display.maxFps)
648
668
  };
649
669
  }
@@ -1713,8 +1733,8 @@ function describeNativeCssFindings(findings) {
1713
1733
  (f) => ` ${f.file}:${f.line}:${f.column}${f.authored === void 0 ? "" : ` authored ${f.authored}`} ${f.what} \u2014 ${f.why}`
1714
1734
  ).join("\n");
1715
1735
  }
1716
- function webRuntimeDecoders(config) {
1717
- return config.engine === "threejs" ? { ktx2: true, meshopt: true } : { ktx2: false, meshopt: false };
1736
+ function webRuntimeDecoders(_config) {
1737
+ return { ktx2: true, meshopt: true };
1718
1738
  }
1719
1739
 
1720
1740
  // src/build.ts
@@ -2371,7 +2391,7 @@ async function buildWeb(cwd, viteArgs = [], profile) {
2371
2391
  config: config.assets,
2372
2392
  cwd,
2373
2393
  platform: "web",
2374
- runtimeDecoders: webRuntimeDecoders(config),
2394
+ runtimeDecoders: webRuntimeDecoders(),
2375
2395
  ...config.engine !== "threejs" && { runtimeIdentity: "web:native-engine" }
2376
2396
  });
2377
2397
  const assets = assetRoot(cwd, config);
@@ -2686,6 +2706,8 @@ async function buildEngineDesktop(cwd, config, entry) {
2686
2706
  String(config.window.height),
2687
2707
  "--title",
2688
2708
  config.window.title,
2709
+ "--priority",
2710
+ config.display.priority,
2689
2711
  "--output",
2690
2712
  output
2691
2713
  ]);
@@ -3223,6 +3245,12 @@ var MCP_SERVERS = Object.freeze({
3223
3245
  command: "node",
3224
3246
  args: Object.freeze(["./node_modules/@threenative/core/mcp/engine.mjs"])
3225
3247
  }),
3248
+ // Cooks a starter terrain kit into a world.glb. The server lives in the optional
3249
+ // `@threenative/terrain` package, which the shim resolves from the project at launch.
3250
+ "threenative-terrain": Object.freeze({
3251
+ command: "node",
3252
+ args: Object.freeze(["./node_modules/@threenative/core/mcp/terrain.mjs"])
3253
+ }),
3226
3254
  // Inspects, attaches, edits and verifies character animation. Every operation is a build-time
3227
3255
  // edit of one GLB, so a game that animates nothing pays for nothing.
3228
3256
  "threenative-animation": Object.freeze({
@@ -3239,10 +3267,11 @@ var MCP_SERVERS = Object.freeze({
3239
3267
  })
3240
3268
  });
3241
3269
  var MCP_PACKAGES = Object.freeze({
3242
- assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.15.0" }),
3270
+ assets: Object.freeze({ name: "threenative-asset-mcp", version: "0.16.0" }),
3271
+ terrain: Object.freeze({ name: "@threenative/terrain", version: "0.1.9" }),
3243
3272
  sculpt: Object.freeze({ name: "threenative-sculpt-mcp", version: "0.2.2" }),
3244
- engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.11" }),
3245
- animation: Object.freeze({ name: "threenative-animation-mcp", version: "0.1.3" }),
3273
+ engine: Object.freeze({ name: "threenative-engine-mcp", version: "0.2.13" }),
3274
+ animation: Object.freeze({ name: "threenative-animation-mcp", version: "0.1.10" }),
3246
3275
  // `args` fixes the launch for every host. The Chrome flags are `WEBGPU_BROWSER_ARGS` from
3247
3276
  // `@threenative/playtest`, so a DevTools trace profiles the same adapter a playtest does and not
3248
3277
  // SwiftShader. An isolated profile keeps the user's own Chrome profile out, and the two opt-outs
@@ -3355,7 +3384,12 @@ var MCP_HOSTS = Object.freeze([
3355
3384
  Object.freeze({ id: "zed", label: "Zed", file: ".zed/settings.json", format: "zed" })
3356
3385
  ]);
3357
3386
 
3387
+ // ../core/src/version.ts
3388
+ var CORE_VERSION = "0.3.13";
3389
+
3358
3390
  // src/mcp-servers.ts
3391
+ var CORE_PACKAGE_NAME = "@threenative/core";
3392
+ var CORE_PACKAGE_VERSION = CORE_VERSION;
3359
3393
  function serverEntryPath(server) {
3360
3394
  const entry = server.args[0];
3361
3395
  if (entry === void 0) {
@@ -3401,12 +3435,11 @@ function requiredAndroidSdkFromRoot(root) {
3401
3435
  return DEFAULT_ANDROID_COMPILE_SDK;
3402
3436
  }
3403
3437
  }
3404
- var CORE_PACKAGE_NAME = "@threenative/core";
3405
- var CORE_PACKAGE_VERSION = "0.3.11";
3406
3438
  var CORE_RESOLVED_SERVERS = /* @__PURE__ */ new Set([
3407
3439
  "threenative-engine",
3408
3440
  "threenative-animation"
3409
3441
  ]);
3442
+ var OPTIONAL_ADDON_SERVERS = /* @__PURE__ */ new Set(["threenative-terrain"]);
3410
3443
  var MCP_SERVER_SPECS = Object.entries(MCP_SERVERS).map(
3411
3444
  ([configName, server]) => {
3412
3445
  const resolvesToCore = CORE_RESOLVED_SERVERS.has(configName);
@@ -3420,6 +3453,7 @@ var MCP_SERVER_SPECS = Object.entries(MCP_SERVERS).map(
3420
3453
  return {
3421
3454
  configName,
3422
3455
  expectedArgs: serverEntryPath(server),
3456
+ optional: OPTIONAL_ADDON_SERVERS.has(configName),
3423
3457
  packageName: resolvesToCore ? CORE_PACKAGE_NAME : declared.name,
3424
3458
  version: resolvesToCore ? CORE_PACKAGE_VERSION : declared.version
3425
3459
  };
@@ -3679,6 +3713,14 @@ function mcpServerCheck(snapshot, spec, value, file) {
3679
3713
  };
3680
3714
  }
3681
3715
  const packageDirectory = resolvePackageDirectory(snapshot, spec.packageName);
3716
+ if (packageDirectory === void 0 && spec.optional) {
3717
+ return {
3718
+ detail: `${spec.configName} is optional and ${spec.packageName} is not installed in this project`,
3719
+ fix: `Run: npm i -D ${spec.packageName}`,
3720
+ name,
3721
+ status: "warn"
3722
+ };
3723
+ }
3682
3724
  if (packageDirectory === void 0) {
3683
3725
  return {
3684
3726
  detail: `${spec.configName} is reachable by npx only: ${spec.packageName}@${spec.version} is not installed (npx --yes ${spec.packageName}@${spec.version})`,
@@ -3718,7 +3760,7 @@ function probeMcpServer(projectRoot, spec) {
3718
3760
  method: "initialize",
3719
3761
  params: {
3720
3762
  capabilities: {},
3721
- clientInfo: { name: "threenative-doctor", version: "0.3.11" },
3763
+ clientInfo: { name: "threenative-doctor", version: CORE_PACKAGE_VERSION },
3722
3764
  protocolVersion: "2025-06-18"
3723
3765
  }
3724
3766
  });
@@ -4727,6 +4769,7 @@ function diagnoseProject(snapshot, options = {}) {
4727
4769
  },
4728
4770
  sceneShapeCheck(snapshot),
4729
4771
  ...capabilitySearchChecks(snapshot),
4772
+ ...snapshot.authoringLayer === void 0 ? [] : [authoringLayerCheck(snapshot.authoringLayer)],
4730
4773
  editorActivationCheck(snapshot),
4731
4774
  ...blender === void 0 ? [] : [blender]
4732
4775
  ];
@@ -4736,6 +4779,22 @@ function diagnoseProject(snapshot, options = {}) {
4736
4779
  });
4737
4780
  return { checks: scoped, pass: scoped.every(({ status }) => status !== "fail") };
4738
4781
  }
4782
+ var AUTHORING_LAYER_FIX = "After 'pnpm up --latest create-threenative', run 'pnpm exec threenative doctor --fix'; add --force to overwrite files this game edited.";
4783
+ function authoringLayerCheck(layer) {
4784
+ const name = "authoring layer";
4785
+ if (layer.problem !== void 0)
4786
+ return { detail: layer.problem, fix: AUTHORING_LAYER_FIX, name, status: "warn" };
4787
+ const where = `installed create-threenative ${layer.installed} (${layer.kit} kit)`;
4788
+ if (layer.stamped === layer.installed && layer.stale.length === 0)
4789
+ return { detail: `stamp matches ${where}`, name, status: "ok" };
4790
+ const count = `${layer.stale.length} stale file${layer.stale.length === 1 ? "" : "s"}`;
4791
+ return {
4792
+ detail: `stamp ${layer.stamped ?? "absent"}, ${where}: ${count}`,
4793
+ fix: AUTHORING_LAYER_FIX,
4794
+ name,
4795
+ status: "warn"
4796
+ };
4797
+ }
4739
4798
  async function collectFiles(root, relative = "", depth = 0) {
4740
4799
  if (depth > 3) return [];
4741
4800
  const absolute = path5.join(root, relative);
@@ -4791,15 +4850,25 @@ async function readProject(root) {
4791
4850
  const runtimeVersion = installedVersions.get(RUNTIME_PACKAGE);
4792
4851
  const runtimeManifestUrl = runtimeRoot === void 0 || runtimeVersion === void 0 ? void 0 : await runtimeReleaseManifestUrl(runtimeRoot, runtimeVersion);
4793
4852
  const playtestRunnerPath = resolveBinaryFrom(projectRoot, PLAYTEST_BINARY);
4853
+ const authoringLayer = await authoringLayerStatus(projectRoot).catch(
4854
+ (error) => ({
4855
+ installed: "unknown",
4856
+ problem: error instanceof Error ? error.message : String(error),
4857
+ stale: []
4858
+ })
4859
+ );
4794
4860
  const mcpServerHealth = /* @__PURE__ */ new Map();
4795
4861
  if (SHAPE_VERIFIABLE_HOSTS.some(({ file }) => files.has(file))) {
4796
4862
  for (const spec of MCP_SERVER_SPECS) {
4863
+ if (spec.optional && resolvePackageDirectoryFrom(projectRoot, spec.packageName) === void 0)
4864
+ continue;
4797
4865
  if (existsSync(path5.resolve(projectRoot, spec.expectedArgs))) {
4798
4866
  mcpServerHealth.set(spec.configName, probeMcpServer(projectRoot, spec));
4799
4867
  }
4800
4868
  }
4801
4869
  }
4802
4870
  return {
4871
+ authoringLayer,
4803
4872
  config,
4804
4873
  files,
4805
4874
  installedVersions,
@@ -4857,7 +4926,7 @@ async function readTypeScriptConfig(root) {
4857
4926
  function formatDoctorReport(report) {
4858
4927
  const symbols = { fail: "\u2717", ok: "\u2713", warn: "!" };
4859
4928
  const isBaseline = (name) => ["package.json", "dependencies", "versions"].includes(name);
4860
- const isCraft = (name) => name.startsWith("capability search");
4929
+ const isCraft = (name) => name.startsWith("capability search") || name === "authoring layer";
4861
4930
  const isTest = (name) => name === "playtest" || name === "playtests";
4862
4931
  const groups = [
4863
4932
  ["Baseline", isBaseline],
@@ -4881,8 +4950,6 @@ function formatDoctorReport(report) {
4881
4950
  return `${lines.join("\n")}
4882
4951
  `;
4883
4952
  }
4884
-
4885
- // src/threenative.ts
4886
4953
  var DOCTOR_TARGETS = ["web", "desktop", "android", "ios"];
4887
4954
  var DOCTOR_MODES = ["debug", "release"];
4888
4955
  function cliHelp(command) {
@@ -4890,7 +4957,7 @@ function cliHelp(command) {
4890
4957
  if (command === "doctor") {
4891
4958
  return `${[
4892
4959
  "Usage: threenative doctor [--target web|desktop|android|ios] [--mode debug|release]",
4893
- " [--text] [--capture <path>]",
4960
+ " [--text] [--capture <path>] [--fix [--force]]",
4894
4961
  "",
4895
4962
  "Checks this project against what the build and the native host assume about it:",
4896
4963
  "installed and version-matched @threenative packages, a portable entry that",
@@ -4907,6 +4974,11 @@ function cliHelp(command) {
4907
4974
  " need once PRD-212 ships it, so a green report here is a forecast, not a release.",
4908
4975
  "Prints JSON by default; --text prints the same report for a person.",
4909
4976
  "--capture forwards a browser census JSON or native TN_PIPELINE_EVENT log to the playtest doctor.",
4977
+ "--fix rewrites this game's authoring layer (AGENTS.md, CLAUDE.md, skills, hooks, MCP configs)",
4978
+ " from the installed create-threenative, then checks again. To update an existing game:",
4979
+ " 'pnpm up --latest create-threenative @threenative/*', then 'pnpm exec threenative doctor --fix'.",
4980
+ " A file this game edited is kept and listed, and the run exits 1 (TN_AUTHORING_LAYER_EDITED);",
4981
+ " --force overwrites it. Git is the undo. .threenative/agent-files.json records what was written.",
4910
4982
  "Exits 0 when nothing failed, 1 when a check failed."
4911
4983
  ].join("\n")}
4912
4984
  `;
@@ -4931,6 +5003,8 @@ ${cliHelp()}`);
4931
5003
  }
4932
5004
  async function runDoctorCommand(argv, cwd = process.cwd()) {
4933
5005
  let capturePath;
5006
+ let fix = false;
5007
+ let force = false;
4934
5008
  let mode;
4935
5009
  let target;
4936
5010
  const valueFor = (flag, value) => {
@@ -4941,6 +5015,11 @@ async function runDoctorCommand(argv, cwd = process.cwd()) {
4941
5015
  for (let index = 0; index < argv.length; index += 1) {
4942
5016
  const flag = argv[index];
4943
5017
  if (flag === "--text") continue;
5018
+ if (flag === "--fix" || flag === "--force") {
5019
+ if (flag === "--fix") fix = true;
5020
+ else force = true;
5021
+ continue;
5022
+ }
4944
5023
  if (flag === "--capture") {
4945
5024
  capturePath = valueFor(flag, argv[index + 1]);
4946
5025
  index += 1;
@@ -4966,12 +5045,31 @@ async function runDoctorCommand(argv, cwd = process.cwd()) {
4966
5045
  }
4967
5046
  if (mode !== void 0 && target === void 0)
4968
5047
  throw new Error("doctor: '--mode' requires '--target'.");
5048
+ if (force && !fix) throw new Error("doctor: '--force' requires '--fix'.");
5049
+ let kept = 0;
5050
+ if (fix) {
5051
+ const result = await fixAuthoringLayer(cwd, { force });
5052
+ const lines = [
5053
+ ...result.written.map((file) => `wrote ${file}`),
5054
+ ...result.deleted.map((file) => `deleted ${file}`),
5055
+ ...result.kept.map((file) => `kept ${file}`)
5056
+ ];
5057
+ kept = result.kept.length;
5058
+ if (kept > 0)
5059
+ lines.push(
5060
+ `TN_AUTHORING_LAYER_EDITED: kept ${kept} file${kept === 1 ? "" : "s"} this game edited; rerun with --force to overwrite (git is the undo).`
5061
+ );
5062
+ process.stderr.write(
5063
+ lines.length === 0 ? "authoring layer already current\n" : `${lines.join("\n")}
5064
+ `
5065
+ );
5066
+ }
4969
5067
  const report = diagnoseProject(await readProject(cwd), { capturePath, mode, target });
4970
5068
  process.stdout.write(
4971
5069
  argv.includes("--text") ? formatDoctorReport(report) : `${JSON.stringify(report, null, 2)}
4972
5070
  `
4973
5071
  );
4974
- return report.pass ? 0 : 1;
5072
+ return report.pass && kept === 0 ? 0 : 1;
4975
5073
  }
4976
5074
  async function main(argv = process.argv.slice(2)) {
4977
5075
  if (argv.includes("--help") || argv.includes("-h")) {
@@ -0,0 +1,127 @@
1
+ import { Quaternion, Vector3 } from 'three';
2
+
3
+ // ../three-native/src/addons/ccd-ik-solver.ts
4
+ var modulo = (n, m) => (n % m + m) % m;
5
+ var CCDIKSolver = class {
6
+ constructor(mesh, iks = []) {
7
+ this.mesh = mesh;
8
+ this.iks = iks;
9
+ this.#initialQuaternions = iks.map((ik) => ik.links.map(() => new Quaternion()));
10
+ this.#valid();
11
+ }
12
+ mesh;
13
+ iks;
14
+ #quaternion = new Quaternion();
15
+ #targetPos = new Vector3();
16
+ #targetVec = new Vector3();
17
+ #effectorPos = new Vector3();
18
+ #effectorVec = new Vector3();
19
+ #linkPos = new Vector3();
20
+ #invLinkQ = new Quaternion();
21
+ #linkScale = new Vector3();
22
+ #axis = new Vector3();
23
+ #vector = new Vector3();
24
+ #center = new Vector3();
25
+ #workingQuaternion = new Quaternion();
26
+ #initialQuaternions;
27
+ update(globalBlendFactor = 1) {
28
+ for (const ik of this.iks) this.updateOne(ik, globalBlendFactor);
29
+ return this;
30
+ }
31
+ updateOne(ik, overrideBlend = 1) {
32
+ const chainBlend = ik.blendFactor ?? overrideBlend;
33
+ const bones = this.mesh.skeleton.bones;
34
+ const initialQuaternions = this.#initialQuaternions[this.iks.indexOf(ik)] ?? [];
35
+ const effector = bones[ik.effector];
36
+ const target = bones[ik.target];
37
+ this.#targetPos.setFromMatrixPosition(target.matrixWorld);
38
+ const links = ik.links;
39
+ if (chainBlend < 1)
40
+ for (const [j, link] of links.entries())
41
+ initialQuaternions[j]?.copy(bones[link.index].quaternion);
42
+ for (let i = 0; i < (ik.iteration ?? 1); i++) if (!this.#iterate(ik, bones, effector)) break;
43
+ if (chainBlend < 1) this.#blend(links, bones, initialQuaternions, chainBlend);
44
+ return this;
45
+ }
46
+ createHelper() {
47
+ throw new Error(
48
+ "TN_NATIVE_UNSUPPORTED_CCDIKHELPER: CCDIKSolver.createHelper needs three's CCDIKHelper, which the engine does not bind; draw the chain from skeleton.bones instead."
49
+ );
50
+ }
51
+ // One pass over the chain; false when no link turned, which ends the solve.
52
+ #iterate(ik, bones, effector) {
53
+ let rotated = false;
54
+ for (const entry of ik.links) {
55
+ if (entry.enabled === false) break;
56
+ if (this.#rotateLink(ik, entry, bones[entry.index], effector)) rotated = true;
57
+ }
58
+ return rotated;
59
+ }
60
+ // A chain blend under 1 slerps each link from its pose before the solve toward the solved pose.
61
+ #blend(links, bones, initial, chainBlend) {
62
+ for (const [j, entry] of links.entries()) {
63
+ const link = bones[entry.index];
64
+ this.#workingQuaternion.copy(initial[j]).slerp(link.quaternion, chainBlend);
65
+ link.quaternion.copy(this.#workingQuaternion);
66
+ link.updateMatrixWorld(true);
67
+ }
68
+ }
69
+ // One CCD step on one link: rotate it so the effector points at the target. False when the angle
70
+ // is too small to turn, which three skips to prevent bone vibration.
71
+ #rotateLink(ik, entry, link, effector) {
72
+ link.matrixWorld.decompose(this.#linkPos, this.#invLinkQ, this.#linkScale);
73
+ this.#invLinkQ.invert();
74
+ this.#effectorPos.setFromMatrixPosition(effector.matrixWorld);
75
+ this.#effectorVec.subVectors(this.#effectorPos, this.#linkPos).applyQuaternion(this.#invLinkQ).normalize();
76
+ this.#targetVec.subVectors(this.#targetPos, this.#linkPos).applyQuaternion(this.#invLinkQ).normalize();
77
+ let angle = Math.acos(Math.min(1, Math.max(-1, this.#targetVec.dot(this.#effectorVec))));
78
+ if (angle < 1e-5) return false;
79
+ if (ik.minAngle !== void 0 && angle < ik.minAngle) angle = ik.minAngle;
80
+ if (ik.maxAngle !== void 0 && angle > ik.maxAngle) angle = ik.maxAngle;
81
+ this.#axis.crossVectors(this.#effectorVec, this.#targetVec).normalize();
82
+ this.#quaternion.setFromAxisAngle(this.#axis, angle);
83
+ link.quaternion.multiply(this.#quaternion);
84
+ this.#limit(entry, link);
85
+ link.updateMatrixWorld(true);
86
+ return true;
87
+ }
88
+ // three's link limits: a hinge axis, then Euler angle bounds.
89
+ #limit(entry, link) {
90
+ const { limitation, rotationMin, rotationMax } = entry;
91
+ if (limitation !== void 0) {
92
+ const q = link.quaternion;
93
+ const c = Math.min(q.w, 1);
94
+ const dot = q.x * limitation.x + q.y * limitation.y + q.z * limitation.z;
95
+ const c2 = (dot < 0 ? -1 : 1) * Math.sqrt(1 - c * c);
96
+ q.set(limitation.x * c2, limitation.y * c2, limitation.z * c2, c);
97
+ }
98
+ if (rotationMin !== void 0 || rotationMax !== void 0) {
99
+ const v = this.#vector.setFromEuler(link.rotation);
100
+ if (rotationMin !== void 0 && rotationMax !== void 0) {
101
+ const c = this.#center.addVectors(rotationMin, rotationMax).multiplyScalar(0.5);
102
+ v.x = c.x + modulo(v.x - c.x + Math.PI, 2 * Math.PI) - Math.PI;
103
+ v.y = c.y + modulo(v.y - c.y + Math.PI, 2 * Math.PI) - Math.PI;
104
+ v.z = c.z + modulo(v.z - c.z + Math.PI, 2 * Math.PI) - Math.PI;
105
+ }
106
+ if (rotationMin !== void 0) v.max(rotationMin);
107
+ if (rotationMax !== void 0) v.min(rotationMax);
108
+ link.rotation.setFromVector3(v);
109
+ }
110
+ }
111
+ #valid() {
112
+ const bones = this.mesh.skeleton.bones;
113
+ for (const ik of this.iks) {
114
+ let child = bones[ik.effector];
115
+ for (const entry of ik.links) {
116
+ const parent = bones[entry.index];
117
+ if (child.parent !== parent)
118
+ console.warn(
119
+ `THREE.CCDIKSolver: bone ${child.name} is not the child of bone ${parent.name}`
120
+ );
121
+ child = parent;
122
+ }
123
+ }
124
+ }
125
+ };
126
+
127
+ export { CCDIKSolver };