@developerz.ai/ts23d 0.0.0-stage → 0.1.0

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 (524) hide show
  1. package/.claude/agents/bug-hunter.md +21 -0
  2. package/.claude/agents/docs-author.md +13 -0
  3. package/.claude/agents/dx-auditor.md +14 -0
  4. package/.claude/agents/primitive-author.md +22 -0
  5. package/.claude/agents/recipe-author.md +36 -0
  6. package/.claude/agents/visual-reviewer.md +23 -0
  7. package/.claude/commands/feature.md +28 -0
  8. package/.claude/commands/new-recipe.md +19 -0
  9. package/.claude/commands/release.md +14 -0
  10. package/.claude/commands/verify.md +9 -0
  11. package/.claude/skills/author-recipe/SKILL.md +93 -0
  12. package/CHANGELOG.md +79 -0
  13. package/CLAUDE.md +85 -0
  14. package/LICENSE +21 -0
  15. package/README.md +380 -2
  16. package/dist/chunk-11v28977.js +1575 -0
  17. package/dist/chunk-11v28977.js.map +30 -0
  18. package/dist/chunk-1ypfs7ga.js +3571 -0
  19. package/dist/chunk-1ypfs7ga.js.map +42 -0
  20. package/dist/chunk-4ddzsqtc.js +464 -0
  21. package/dist/chunk-4ddzsqtc.js.map +19 -0
  22. package/dist/chunk-a8fxakcj.js +19 -0
  23. package/dist/chunk-a8fxakcj.js.map +11 -0
  24. package/dist/chunk-gcyp9b4d.js +755 -0
  25. package/dist/chunk-gcyp9b4d.js.map +22 -0
  26. package/dist/chunk-kgvbpqqw.js +44 -0
  27. package/dist/chunk-kgvbpqqw.js.map +10 -0
  28. package/dist/chunk-kvcep7ft.js +1919 -0
  29. package/dist/chunk-kvcep7ft.js.map +43 -0
  30. package/dist/chunk-ravbb06q.js +89 -0
  31. package/dist/chunk-ravbb06q.js.map +11 -0
  32. package/dist/chunk-w1zyhj40.js +1031 -0
  33. package/dist/chunk-w1zyhj40.js.map +21 -0
  34. package/dist/chunk-wtqhq529.js +2532 -0
  35. package/dist/chunk-wtqhq529.js.map +43 -0
  36. package/dist/chunk-xnt2sdhf.js +836 -0
  37. package/dist/chunk-xnt2sdhf.js.map +17 -0
  38. package/dist/cli/args.d.ts +24 -0
  39. package/dist/cli/bin.d.ts +2 -0
  40. package/dist/cli/bin.js +307 -0
  41. package/dist/cli/bin.js.map +14 -0
  42. package/dist/cli/load.d.ts +2 -0
  43. package/dist/cli/manifest.d.ts +49 -0
  44. package/dist/cli/render-cmds.d.ts +12 -0
  45. package/dist/cli/run.d.ts +1 -0
  46. package/dist/core/asset.d.ts +10 -0
  47. package/dist/core/definition.d.ts +148 -0
  48. package/dist/core/errors.d.ts +17 -0
  49. package/dist/core/family.d.ts +23 -0
  50. package/dist/core/index.d.ts +9 -0
  51. package/dist/core/index.js +69 -0
  52. package/dist/core/index.js.map +9 -0
  53. package/dist/core/mesh.d.ts +35 -0
  54. package/dist/core/part.d.ts +114 -0
  55. package/dist/core/png.d.ts +1 -0
  56. package/dist/core/rng.d.ts +12 -0
  57. package/dist/core/transform.d.ts +20 -0
  58. package/dist/core/vec.d.ts +11 -0
  59. package/dist/core/world.d.ts +16 -0
  60. package/dist/export/bin-writer.d.ts +16 -0
  61. package/dist/export/container.d.ts +3 -0
  62. package/dist/export/glb.d.ts +38 -0
  63. package/dist/export/index.d.ts +4 -0
  64. package/dist/export/index.js +26 -0
  65. package/dist/export/index.js.map +9 -0
  66. package/dist/export/lights.d.ts +8 -0
  67. package/dist/export/materials.d.ts +23 -0
  68. package/dist/export/merge-pivots.d.ts +6 -0
  69. package/dist/export/metadata.d.ts +19 -0
  70. package/dist/export/motion.d.ts +9 -0
  71. package/dist/export/optimize-parts.d.ts +26 -0
  72. package/dist/export/primitive.d.ts +3 -0
  73. package/dist/export/tangents.d.ts +2 -0
  74. package/dist/export/textures.d.ts +22 -0
  75. package/dist/export/version.d.ts +2 -0
  76. package/dist/grammar/index.d.ts +2 -0
  77. package/dist/grammar/index.js +16 -0
  78. package/dist/grammar/index.js.map +9 -0
  79. package/dist/grammar/split.d.ts +21 -0
  80. package/dist/grammar/whyte.d.ts +5 -0
  81. package/dist/index.d.ts +11 -0
  82. package/dist/index.js +411 -0
  83. package/dist/index.js.map +9 -0
  84. package/dist/kinds/building.d.ts +44 -0
  85. package/dist/kinds/faces.d.ts +27 -0
  86. package/dist/kinds/head-armour.d.ts +9 -0
  87. package/dist/kinds/head-beard.d.ts +6 -0
  88. package/dist/kinds/head-bust.d.ts +4 -0
  89. package/dist/kinds/head-extras.d.ts +15 -0
  90. package/dist/kinds/head-face.d.ts +6 -0
  91. package/dist/kinds/head-geom.d.ts +7 -0
  92. package/dist/kinds/head-hair.d.ts +4 -0
  93. package/dist/kinds/head-layout.d.ts +29 -0
  94. package/dist/kinds/head-mesh.d.ts +27 -0
  95. package/dist/kinds/head-params.d.ts +108 -0
  96. package/dist/kinds/head-presets.d.ts +19 -0
  97. package/dist/kinds/head-rim.d.ts +10 -0
  98. package/dist/kinds/head.d.ts +39 -0
  99. package/dist/kinds/hull-lines.d.ts +65 -0
  100. package/dist/kinds/hull-skin.d.ts +6 -0
  101. package/dist/kinds/hull.d.ts +14 -0
  102. package/dist/kinds/index.d.ts +16 -0
  103. package/dist/kinds/index.js +78 -0
  104. package/dist/kinds/index.js.map +9 -0
  105. package/dist/kinds/mass.d.ts +15 -0
  106. package/dist/kinds/openings.d.ts +30 -0
  107. package/dist/kinds/planned.d.ts +6 -0
  108. package/dist/kinds/roof-chimney.d.ts +16 -0
  109. package/dist/kinds/roof-shape.d.ts +64 -0
  110. package/dist/kinds/roof.d.ts +31 -0
  111. package/dist/kinds/vegetation-fronds.d.ts +15 -0
  112. package/dist/kinds/vegetation-impostor.d.ts +9 -0
  113. package/dist/kinds/vegetation-leaves.d.ts +15 -0
  114. package/dist/kinds/vegetation-mesh.d.ts +21 -0
  115. package/dist/kinds/vegetation-params.d.ts +90 -0
  116. package/dist/kinds/vegetation-presets.d.ts +20 -0
  117. package/dist/kinds/vegetation-skeleton.d.ts +20 -0
  118. package/dist/kinds/vegetation.d.ts +42 -0
  119. package/dist/kinds/vehicle.d.ts +42 -0
  120. package/dist/material/generator.d.ts +4 -0
  121. package/dist/material/index.d.ts +4 -0
  122. package/dist/material/index.js +38 -0
  123. package/dist/material/index.js.map +9 -0
  124. package/dist/material/paint/bond.d.ts +3 -0
  125. package/dist/material/paint/canvas.d.ts +32 -0
  126. package/dist/material/paint/cell.d.ts +4 -0
  127. package/dist/material/paint/cells-round.d.ts +5 -0
  128. package/dist/material/paint/cells.d.ts +7 -0
  129. package/dist/material/paint/compose.d.ts +5 -0
  130. package/dist/material/paint/concrete.d.ts +3 -0
  131. package/dist/material/paint/courses.d.ts +31 -0
  132. package/dist/material/paint/decode-png.d.ts +6 -0
  133. package/dist/material/paint/default-sheet.d.ts +2 -0
  134. package/dist/material/paint/foliage-broad.d.ts +5 -0
  135. package/dist/material/paint/foliage-common.d.ts +35 -0
  136. package/dist/material/paint/foliage-compound.d.ts +4 -0
  137. package/dist/material/paint/foliage-conifer.d.ts +5 -0
  138. package/dist/material/paint/foliage-raster.d.ts +26 -0
  139. package/dist/material/paint/foliage.d.ts +3 -0
  140. package/dist/material/paint/masks.d.ts +3 -0
  141. package/dist/material/paint/noise.d.ts +9 -0
  142. package/dist/material/paint/normal.d.ts +8 -0
  143. package/dist/material/paint/orm.d.ts +8 -0
  144. package/dist/material/paint/planks.d.ts +3 -0
  145. package/dist/material/paint/plates.d.ts +3 -0
  146. package/dist/material/paint/shapes.d.ts +8 -0
  147. package/dist/material/paint/slate.d.ts +3 -0
  148. package/dist/material/paint/stamp.d.ts +3 -0
  149. package/dist/material/paint/strip.d.ts +3 -0
  150. package/dist/material/paint/surface.d.ts +5 -0
  151. package/dist/material/paint/types.d.ts +35 -0
  152. package/dist/material/paint/validate.d.ts +3 -0
  153. package/dist/material/palette.d.ts +12 -0
  154. package/dist/material/shader-godot.d.ts +2 -0
  155. package/dist/material/shader-three.d.ts +2 -0
  156. package/dist/material/shader.d.ts +46 -0
  157. package/dist/material/trim-sheet.d.ts +22 -0
  158. package/dist/neural/generator.d.ts +25 -0
  159. package/dist/neural/images.d.ts +17 -0
  160. package/dist/neural/index.d.ts +2 -0
  161. package/dist/neural/index.js +14 -0
  162. package/dist/neural/index.js.map +9 -0
  163. package/dist/passes/bake-ao.d.ts +17 -0
  164. package/dist/passes/grime.d.ts +15 -0
  165. package/dist/passes/index.d.ts +6 -0
  166. package/dist/passes/index.js +22 -0
  167. package/dist/passes/index.js.map +9 -0
  168. package/dist/passes/livery.d.ts +19 -0
  169. package/dist/passes/optimize-cache.d.ts +15 -0
  170. package/dist/passes/optimize-weld.d.ts +15 -0
  171. package/dist/passes/optimize.d.ts +28 -0
  172. package/dist/passes/ray-grid.d.ts +23 -0
  173. package/dist/passes/weighted-normals.d.ts +8 -0
  174. package/dist/primitives/beam.d.ts +17 -0
  175. package/dist/primitives/bevel-box.d.ts +13 -0
  176. package/dist/primitives/box.d.ts +16 -0
  177. package/dist/primitives/cell.d.ts +20 -0
  178. package/dist/primitives/check.d.ts +12 -0
  179. package/dist/primitives/closed.d.ts +11 -0
  180. package/dist/primitives/erosion.d.ts +22 -0
  181. package/dist/primitives/font-5x7.d.ts +3 -0
  182. package/dist/primitives/heightfield.d.ts +16 -0
  183. package/dist/primitives/index.d.ts +23 -0
  184. package/dist/primitives/index.js +81 -0
  185. package/dist/primitives/index.js.map +9 -0
  186. package/dist/primitives/lathe-facets.d.ts +8 -0
  187. package/dist/primitives/lathe.d.ts +26 -0
  188. package/dist/primitives/lattice.d.ts +30 -0
  189. package/dist/primitives/loft.d.ts +15 -0
  190. package/dist/primitives/mc-table.d.ts +2 -0
  191. package/dist/primitives/member.d.ts +19 -0
  192. package/dist/primitives/noise.d.ts +34 -0
  193. package/dist/primitives/planar.d.ts +10 -0
  194. package/dist/primitives/prism.d.ts +13 -0
  195. package/dist/primitives/sculpt-edit.d.ts +56 -0
  196. package/dist/primitives/sculpt-tree.d.ts +23 -0
  197. package/dist/primitives/sculpt.d.ts +27 -0
  198. package/dist/primitives/sdf-grid.d.ts +17 -0
  199. package/dist/primitives/sdf-ops.d.ts +37 -0
  200. package/dist/primitives/sdf.d.ts +21 -0
  201. package/dist/primitives/strip-uv.d.ts +11 -0
  202. package/dist/primitives/surface-nets.d.ts +7 -0
  203. package/dist/primitives/sweep.d.ts +19 -0
  204. package/dist/primitives/terrain-color.d.ts +30 -0
  205. package/dist/primitives/terrain-grid.d.ts +36 -0
  206. package/dist/primitives/text-layout.d.ts +22 -0
  207. package/dist/primitives/text.d.ts +27 -0
  208. package/dist/primitives/tiled.d.ts +22 -0
  209. package/dist/primitives/transport.d.ts +17 -0
  210. package/dist/primitives/triangulate.d.ts +2 -0
  211. package/dist/primitives/value-noise.d.ts +10 -0
  212. package/dist/qa/checks.d.ts +11 -0
  213. package/dist/qa/clash.d.ts +2 -0
  214. package/dist/qa/floating.d.ts +5 -0
  215. package/dist/qa/gates.d.ts +12 -0
  216. package/dist/qa/geometry.d.ts +21 -0
  217. package/dist/qa/index.d.ts +12 -0
  218. package/dist/qa/index.js +78 -0
  219. package/dist/qa/index.js.map +9 -0
  220. package/dist/qa/inside.d.ts +12 -0
  221. package/dist/qa/inspect.d.ts +18 -0
  222. package/dist/qa/lods.d.ts +12 -0
  223. package/dist/qa/measures.d.ts +4 -0
  224. package/dist/qa/occlusion.d.ts +3 -0
  225. package/dist/qa/sanity.d.ts +7 -0
  226. package/dist/qa/types.d.ts +12 -0
  227. package/dist/render/beauty.d.ts +40 -0
  228. package/dist/render/camera.d.ts +33 -0
  229. package/dist/render/depth-map.d.ts +38 -0
  230. package/dist/render/font.d.ts +1 -0
  231. package/dist/render/ground.d.ts +13 -0
  232. package/dist/render/index.d.ts +10 -0
  233. package/dist/render/index.js +47 -0
  234. package/dist/render/index.js.map +9 -0
  235. package/dist/render/lighting.d.ts +20 -0
  236. package/dist/render/lod-strip.d.ts +5 -0
  237. package/dist/render/metrics.d.ts +37 -0
  238. package/dist/render/options.d.ts +28 -0
  239. package/dist/render/photo-match.d.ts +19 -0
  240. package/dist/render/raster.d.ts +25 -0
  241. package/dist/render/resolve.d.ts +11 -0
  242. package/dist/render/review-prompt.d.ts +2 -0
  243. package/dist/render/review-warnings.d.ts +34 -0
  244. package/dist/render/review.d.ts +24 -0
  245. package/dist/render/scene.d.ts +18 -0
  246. package/dist/render/shade.d.ts +22 -0
  247. package/dist/render/sheet.d.ts +15 -0
  248. package/dist/render/texture.d.ts +15 -0
  249. package/dist/render/thumbnail.d.ts +8 -0
  250. package/dist/render/vis-buffer.d.ts +18 -0
  251. package/dist/testing/assert.d.ts +21 -0
  252. package/dist/testing/compiled.d.ts +15 -0
  253. package/dist/testing/hash.d.ts +1 -0
  254. package/dist/testing/index.d.ts +4 -0
  255. package/dist/testing/index.js +134 -0
  256. package/dist/testing/index.js.map +13 -0
  257. package/dist/testing/snapshot.d.ts +13 -0
  258. package/docs/README.md +52 -0
  259. package/docs/architecture/README.md +68 -0
  260. package/docs/architecture/adding-a-kind.md +44 -0
  261. package/docs/architecture/adding-a-primitive.md +49 -0
  262. package/docs/architecture/errors.md +47 -0
  263. package/docs/architecture/glb-production.md +214 -0
  264. package/docs/architecture/gltf-capabilities.md +80 -0
  265. package/docs/decisions/001-recipe-compiler-over-ai-meshes.md +27 -0
  266. package/docs/decisions/002-typescript-not-json.md +22 -0
  267. package/docs/decisions/003-shared-trim-sheet.md +21 -0
  268. package/docs/decisions/004-z-up-metres.md +21 -0
  269. package/docs/decisions/005-zero-runtime-deps.md +21 -0
  270. package/docs/decisions/006-single-package-subpath-exports.md +20 -0
  271. package/docs/decisions/007-cpu-contact-sheets.md +21 -0
  272. package/docs/decisions/008-surface-materials.md +21 -0
  273. package/docs/decisions/009-gltf-front-axis.md +21 -0
  274. package/docs/decisions/README.md +15 -0
  275. package/docs/idea/01-vision.md +117 -0
  276. package/docs/idea/02-dsl.md +343 -0
  277. package/docs/idea/03-ir.md +97 -0
  278. package/docs/idea/04-materials.md +114 -0
  279. package/docs/idea/05-agent-loop.md +141 -0
  280. package/docs/idea/06-qa.md +101 -0
  281. package/docs/idea/07-what-fits.md +45 -0
  282. package/docs/idea/08-neural-adapters.md +78 -0
  283. package/docs/idea/09-kinds.md +105 -0
  284. package/docs/landscape.md +49 -0
  285. package/docs/plans/roadmap.md +127 -0
  286. package/examples/build-with-bun.ts +41 -0
  287. package/llms.txt +47 -0
  288. package/package.json +99 -4
  289. package/recipes/README.md +38 -0
  290. package/recipes/asteroid/README.md +46 -0
  291. package/recipes/asteroid/asteroid.ts +336 -0
  292. package/recipes/boulders/README.md +28 -0
  293. package/recipes/boulders/boulders.ts +117 -0
  294. package/recipes/boxcar/README.md +46 -0
  295. package/recipes/boxcar/boxcar.ts +916 -0
  296. package/recipes/cargo_container_scifi/README.md +52 -0
  297. package/recipes/cargo_container_scifi/cargo_container_scifi.ts +461 -0
  298. package/recipes/dropship/README.md +84 -0
  299. package/recipes/dropship/dropship.ts +1144 -0
  300. package/recipes/eiffel_tower/README.md +110 -0
  301. package/recipes/eiffel_tower/eiffel_tower.ts +781 -0
  302. package/recipes/goblin_head/README.md +62 -0
  303. package/recipes/goblin_head/goblin_head.ts +36 -0
  304. package/recipes/human_head/README.md +64 -0
  305. package/recipes/human_head/human_head.ts +37 -0
  306. package/recipes/loco_440/README.md +32 -0
  307. package/recipes/loco_440/loco_440.ts +1404 -0
  308. package/recipes/material_swatches/README.md +21 -0
  309. package/recipes/material_swatches/material_swatches.ts +183 -0
  310. package/recipes/mountain_range/README.md +45 -0
  311. package/recipes/mountain_range/mountain_range.ts +128 -0
  312. package/recipes/oak/README.md +30 -0
  313. package/recipes/oak/oak.ts +19 -0
  314. package/recipes/orc_head/README.md +66 -0
  315. package/recipes/orc_head/orc_head.ts +39 -0
  316. package/recipes/palm/README.md +30 -0
  317. package/recipes/palm/palm.ts +19 -0
  318. package/recipes/pine/README.md +29 -0
  319. package/recipes/pine/pine.ts +19 -0
  320. package/recipes/signal_gantry/README.md +36 -0
  321. package/recipes/signal_gantry/signal_gantry.ts +522 -0
  322. package/recipes/station_halt/README.md +39 -0
  323. package/recipes/station_halt/station_halt.ts +722 -0
  324. package/recipes/t34/README.md +44 -0
  325. package/recipes/t34/t34.ts +1068 -0
  326. package/recipes/tiger_1/README.md +75 -0
  327. package/recipes/tiger_1/tiger_1.ts +1370 -0
  328. package/recipes/water_tower/README.md +40 -0
  329. package/recipes/water_tower/water_tower.ts +542 -0
  330. package/src/cli/args.ts +112 -0
  331. package/src/cli/bin.ts +7 -0
  332. package/src/cli/load.ts +17 -0
  333. package/src/cli/manifest.ts +89 -0
  334. package/src/cli/render-cmds.ts +66 -0
  335. package/src/cli/run.ts +168 -0
  336. package/src/core/asset.ts +128 -0
  337. package/src/core/definition.ts +149 -0
  338. package/src/core/errors.ts +45 -0
  339. package/src/core/family.ts +50 -0
  340. package/src/core/index.ts +66 -0
  341. package/src/core/mesh.ts +114 -0
  342. package/src/core/part.ts +130 -0
  343. package/src/core/png.ts +49 -0
  344. package/src/core/rng.ts +49 -0
  345. package/src/core/transform.ts +90 -0
  346. package/src/core/vec.ts +26 -0
  347. package/src/core/world.ts +80 -0
  348. package/src/export/bin-writer.ts +79 -0
  349. package/src/export/container.ts +35 -0
  350. package/src/export/glb.ts +200 -0
  351. package/src/export/index.ts +18 -0
  352. package/src/export/lights.ts +49 -0
  353. package/src/export/materials.ts +126 -0
  354. package/src/export/merge-pivots.ts +146 -0
  355. package/src/export/metadata.ts +59 -0
  356. package/src/export/motion.ts +70 -0
  357. package/src/export/optimize-parts.ts +80 -0
  358. package/src/export/primitive.ts +35 -0
  359. package/src/export/tangents.ts +75 -0
  360. package/src/export/textures.ts +88 -0
  361. package/src/export/version.ts +6 -0
  362. package/src/grammar/index.ts +4 -0
  363. package/src/grammar/split.ts +87 -0
  364. package/src/grammar/whyte.ts +20 -0
  365. package/src/index.ts +14 -0
  366. package/src/kinds/building.ts +153 -0
  367. package/src/kinds/faces.ts +138 -0
  368. package/src/kinds/head-armour.ts +151 -0
  369. package/src/kinds/head-beard.ts +133 -0
  370. package/src/kinds/head-bust.ts +221 -0
  371. package/src/kinds/head-extras.ts +150 -0
  372. package/src/kinds/head-face.ts +222 -0
  373. package/src/kinds/head-geom.ts +31 -0
  374. package/src/kinds/head-hair.ts +152 -0
  375. package/src/kinds/head-layout.ts +63 -0
  376. package/src/kinds/head-mesh.ts +157 -0
  377. package/src/kinds/head-params.ts +153 -0
  378. package/src/kinds/head-presets.ts +152 -0
  379. package/src/kinds/head-rim.ts +128 -0
  380. package/src/kinds/head.ts +171 -0
  381. package/src/kinds/hull-lines.ts +160 -0
  382. package/src/kinds/hull-skin.ts +83 -0
  383. package/src/kinds/hull.ts +209 -0
  384. package/src/kinds/index.ts +63 -0
  385. package/src/kinds/mass.ts +110 -0
  386. package/src/kinds/openings.ts +141 -0
  387. package/src/kinds/planned.ts +12 -0
  388. package/src/kinds/roof-chimney.ts +100 -0
  389. package/src/kinds/roof-shape.ts +230 -0
  390. package/src/kinds/roof.ts +250 -0
  391. package/src/kinds/vegetation-fronds.ts +126 -0
  392. package/src/kinds/vegetation-impostor.ts +118 -0
  393. package/src/kinds/vegetation-leaves.ts +168 -0
  394. package/src/kinds/vegetation-mesh.ts +174 -0
  395. package/src/kinds/vegetation-params.ts +147 -0
  396. package/src/kinds/vegetation-presets.ts +184 -0
  397. package/src/kinds/vegetation-skeleton.ts +168 -0
  398. package/src/kinds/vegetation.ts +199 -0
  399. package/src/kinds/vehicle.ts +144 -0
  400. package/src/material/generator.ts +56 -0
  401. package/src/material/index.ts +29 -0
  402. package/src/material/paint/bond.ts +60 -0
  403. package/src/material/paint/canvas.ts +91 -0
  404. package/src/material/paint/cell.ts +39 -0
  405. package/src/material/paint/cells-round.ts +119 -0
  406. package/src/material/paint/cells.ts +111 -0
  407. package/src/material/paint/compose.ts +53 -0
  408. package/src/material/paint/concrete.ts +62 -0
  409. package/src/material/paint/courses.ts +85 -0
  410. package/src/material/paint/decode-png.ts +100 -0
  411. package/src/material/paint/default-sheet.ts +61 -0
  412. package/src/material/paint/foliage-broad.ts +126 -0
  413. package/src/material/paint/foliage-common.ts +93 -0
  414. package/src/material/paint/foliage-compound.ts +135 -0
  415. package/src/material/paint/foliage-conifer.ts +143 -0
  416. package/src/material/paint/foliage-raster.ts +196 -0
  417. package/src/material/paint/foliage.ts +23 -0
  418. package/src/material/paint/masks.ts +44 -0
  419. package/src/material/paint/noise.ts +52 -0
  420. package/src/material/paint/normal.ts +52 -0
  421. package/src/material/paint/orm.ts +95 -0
  422. package/src/material/paint/planks.ts +56 -0
  423. package/src/material/paint/plates.ts +72 -0
  424. package/src/material/paint/shapes.ts +28 -0
  425. package/src/material/paint/slate.ts +52 -0
  426. package/src/material/paint/stamp.ts +40 -0
  427. package/src/material/paint/strip.ts +42 -0
  428. package/src/material/paint/surface.ts +60 -0
  429. package/src/material/paint/types.ts +51 -0
  430. package/src/material/paint/validate.ts +58 -0
  431. package/src/material/palette.ts +43 -0
  432. package/src/material/shader-godot.ts +77 -0
  433. package/src/material/shader-three.ts +103 -0
  434. package/src/material/shader.ts +100 -0
  435. package/src/material/trim-sheet.ts +100 -0
  436. package/src/neural/generator.ts +37 -0
  437. package/src/neural/images.ts +27 -0
  438. package/src/neural/index.ts +10 -0
  439. package/src/passes/bake-ao.ts +183 -0
  440. package/src/passes/grime.ts +37 -0
  441. package/src/passes/index.ts +8 -0
  442. package/src/passes/livery.ts +66 -0
  443. package/src/passes/optimize-cache.ts +175 -0
  444. package/src/passes/optimize-weld.ts +147 -0
  445. package/src/passes/optimize.ts +85 -0
  446. package/src/passes/ray-grid.ts +237 -0
  447. package/src/passes/weighted-normals.ts +125 -0
  448. package/src/primitives/beam.ts +60 -0
  449. package/src/primitives/bevel-box.ts +140 -0
  450. package/src/primitives/box.ts +90 -0
  451. package/src/primitives/cell.ts +115 -0
  452. package/src/primitives/check.ts +49 -0
  453. package/src/primitives/closed.ts +74 -0
  454. package/src/primitives/erosion.ts +183 -0
  455. package/src/primitives/font-5x7.ts +117 -0
  456. package/src/primitives/heightfield.ts +101 -0
  457. package/src/primitives/index.ts +56 -0
  458. package/src/primitives/lathe-facets.ts +45 -0
  459. package/src/primitives/lathe.ts +174 -0
  460. package/src/primitives/lattice.ts +131 -0
  461. package/src/primitives/loft.ts +174 -0
  462. package/src/primitives/mc-table.ts +41 -0
  463. package/src/primitives/member.ts +130 -0
  464. package/src/primitives/noise.ts +157 -0
  465. package/src/primitives/planar.ts +55 -0
  466. package/src/primitives/prism.ts +85 -0
  467. package/src/primitives/sculpt-edit.ts +212 -0
  468. package/src/primitives/sculpt-tree.ts +226 -0
  469. package/src/primitives/sculpt.ts +80 -0
  470. package/src/primitives/sdf-grid.ts +131 -0
  471. package/src/primitives/sdf-ops.ts +145 -0
  472. package/src/primitives/sdf.ts +83 -0
  473. package/src/primitives/strip-uv.ts +26 -0
  474. package/src/primitives/surface-nets.ts +161 -0
  475. package/src/primitives/sweep.ts +162 -0
  476. package/src/primitives/terrain-color.ts +85 -0
  477. package/src/primitives/terrain-grid.ts +137 -0
  478. package/src/primitives/text-layout.ts +85 -0
  479. package/src/primitives/text.ts +197 -0
  480. package/src/primitives/tiled.ts +93 -0
  481. package/src/primitives/transport.ts +85 -0
  482. package/src/primitives/triangulate.ts +42 -0
  483. package/src/primitives/value-noise.ts +62 -0
  484. package/src/qa/checks.ts +110 -0
  485. package/src/qa/clash.ts +177 -0
  486. package/src/qa/floating.ts +63 -0
  487. package/src/qa/gates.ts +126 -0
  488. package/src/qa/geometry.ts +187 -0
  489. package/src/qa/index.ts +28 -0
  490. package/src/qa/inside.ts +114 -0
  491. package/src/qa/inspect.ts +107 -0
  492. package/src/qa/lods.ts +97 -0
  493. package/src/qa/measures.ts +67 -0
  494. package/src/qa/occlusion.ts +166 -0
  495. package/src/qa/sanity.ts +137 -0
  496. package/src/qa/types.ts +17 -0
  497. package/src/render/beauty.ts +115 -0
  498. package/src/render/camera.ts +142 -0
  499. package/src/render/depth-map.ts +191 -0
  500. package/src/render/font.ts +76 -0
  501. package/src/render/ground.ts +87 -0
  502. package/src/render/index.ts +34 -0
  503. package/src/render/lighting.ts +95 -0
  504. package/src/render/lod-strip.ts +34 -0
  505. package/src/render/metrics.ts +147 -0
  506. package/src/render/options.ts +81 -0
  507. package/src/render/photo-match.ts +28 -0
  508. package/src/render/raster.ts +143 -0
  509. package/src/render/resolve.ts +109 -0
  510. package/src/render/review-prompt.ts +59 -0
  511. package/src/render/review-warnings.ts +92 -0
  512. package/src/render/review.ts +103 -0
  513. package/src/render/scene.ts +119 -0
  514. package/src/render/shade.ts +199 -0
  515. package/src/render/sheet.ts +88 -0
  516. package/src/render/texture.ts +97 -0
  517. package/src/render/thumbnail.ts +75 -0
  518. package/src/render/vis-buffer.ts +119 -0
  519. package/src/testing/assert.ts +115 -0
  520. package/src/testing/compiled.ts +31 -0
  521. package/src/testing/hash.ts +14 -0
  522. package/src/testing/index.ts +14 -0
  523. package/src/testing/snapshot.ts +37 -0
  524. package/src/types/gltf-validator.d.ts +13 -0
@@ -0,0 +1,916 @@
1
+ // USRA 50-ton single-sheathed boxcar (1918, spec 1001-B): 40 ft 6 in inside, 41 ft 3 in body,
2
+ // 13 ft 3 in over the running board, on cast side-frame trucks with 33 in wheels. Rail top z = 0,
3
+ // +X = the A end, car centred on x = 0. A family: the livery (road name, marks, number, colour) is
4
+ // the variant; the steel-framed body, trucks and gear are one build. Dossier: ./README.md.
5
+
6
+ import {
7
+ beam,
8
+ box,
9
+ clear,
10
+ cylinder,
11
+ defineFamily,
12
+ grime,
13
+ hex,
14
+ type Lod,
15
+ lathe,
16
+ type Mesh,
17
+ merge,
18
+ noOverlap,
19
+ place,
20
+ prism,
21
+ symmetric,
22
+ text,
23
+ tiled,
24
+ type Vec3,
25
+ } from '@developerz.ai/ts23d';
26
+
27
+ // ---------------------------------------------------------------- dimensions (metres)
28
+ const GAUGE = 1.435;
29
+ const WHEEL_R = 0.419; // 33 in
30
+ const FLANGE = 0.025;
31
+ const TREAD_W = 0.14;
32
+ const WHEEL_Y = GAUGE / 2 + 0.036; // tread centre over the rail head
33
+ const WB = 1.676; // 5 ft 6 in
34
+ const TC = 9.37; // truck centres (photo-scaled)
35
+ const BODY_L = 12.573; // 41 ft 3 in
36
+ const XB = BODY_L / 2;
37
+ const SHEATH_Y = 1.33; // outer face of the boards
38
+ const FRAME_Y = 1.4; // outer face of the steel posts / braces
39
+ const FLOOR_Z = 1.16;
40
+ const EAVE_Z = 3.8;
41
+ const RIDGE_Z = 3.92;
42
+ const WALK_TOP = 4.039; // 13 ft 3 in
43
+ const COUPLER_Z = 0.876; // 34½ in
44
+ const DOOR_W = 1.83;
45
+ const DOOR_Z0 = 1.15;
46
+ const DOOR_Z1 = 3.64;
47
+ const JOURNAL_Y = 0.925; // axle end = journal box inner face
48
+
49
+ const steel = hex('#34302b');
50
+ const iron = hex('#1d1c1b');
51
+ const wheelC = hex('#2a2826');
52
+ const walk = hex('#5d4c3b');
53
+
54
+ interface Params {
55
+ /** Large road name left of the door. */
56
+ readonly road: string;
57
+ /** Reporting marks under it. */
58
+ readonly marks: string;
59
+ readonly number: string;
60
+ readonly paint: Vec3;
61
+ readonly letter: Vec3;
62
+ }
63
+
64
+ // ---------------------------------------------------------------- helpers
65
+ /** Axis-aligned box from two corners (any order). */
66
+ function bx(
67
+ x0: number,
68
+ x1: number,
69
+ y0: number,
70
+ y1: number,
71
+ z0: number,
72
+ z1: number,
73
+ color: Vec3,
74
+ strip: 'plain' | 'iron' | 'wood' = 'iron',
75
+ bevel = 0,
76
+ ): Mesh {
77
+ const [a, b] = [Math.min(x0, x1), Math.max(x0, x1)];
78
+ const [c, d] = [Math.min(y0, y1), Math.max(y0, y1)];
79
+ const [e, f] = [Math.min(z0, z1), Math.max(z0, z1)];
80
+ const small = Math.min(b - a, d - c, f - e);
81
+ return box({
82
+ size: [b - a, d - c, f - e],
83
+ at: [(a + b) / 2, (c + d) / 2, e],
84
+ color,
85
+ strip,
86
+ ...(bevel > 0 && bevel < small / 2 ? { bevel } : {}),
87
+ });
88
+ }
89
+
90
+ const rod = (from: Vec3, to: Vec3, w: number, color: Vec3 = iron, segments = 0): Mesh =>
91
+ beam({ from, to, width: w, color, strip: 'iron', ...(segments ? { segments } : {}) });
92
+
93
+ // ---------------------------------------------------------------- running gear
94
+ /** One wheel's tread disc (exactly 33 in) at lateral y, outer face toward ±y. */
95
+ function tread(lod: Lod, y: number): Mesh {
96
+ if (lod === 2)
97
+ return cylinder({
98
+ radius: WHEEL_R,
99
+ length: TREAD_W,
100
+ segments: 6,
101
+ axis: 'y',
102
+ at: [0, y, 0],
103
+ color: wheelC,
104
+ });
105
+ const s = Math.sign(y);
106
+ const segs = [24, 14, 8][lod] ?? 8;
107
+ return lathe({
108
+ profile: [
109
+ [0, y - s * (TREAD_W / 2)],
110
+ [WHEEL_R, y - s * (TREAD_W / 2)],
111
+ [WHEEL_R, y + s * (TREAD_W / 2)],
112
+ [0, y + s * (TREAD_W / 2)],
113
+ ],
114
+ segments: segs,
115
+ axis: 'y',
116
+ color: wheelC,
117
+ strip: 'iron',
118
+ });
119
+ }
120
+
121
+ /** Axle, flanges and hubs (spins with the treads). */
122
+ function wheelset(lod: Lod): Mesh {
123
+ if (lod === 2) {
124
+ // Axle + a hub boss sharing each tread's outer face, so the set touches its wheels.
125
+ const hub = (s: number): Mesh =>
126
+ cylinder({
127
+ radius: 0.12,
128
+ length: 0.05,
129
+ segments: 6,
130
+ axis: 'y',
131
+ at: [0, s * (WHEEL_Y + TREAD_W / 2 + 0.025), 0],
132
+ color: wheelC,
133
+ });
134
+ const shaft = cylinder({
135
+ radius: 0.075,
136
+ length: JOURNAL_Y * 2,
137
+ segments: 4,
138
+ axis: 'y',
139
+ color: wheelC,
140
+ });
141
+ return merge([shaft, hub(1), hub(-1)]);
142
+ }
143
+ const segs = [24, 14, 8][lod] ?? 8;
144
+ const parts: Mesh[] = [
145
+ cylinder({
146
+ radius: 0.075,
147
+ length: JOURNAL_Y * 2,
148
+ segments: Math.max(6, segs / 2),
149
+ axis: 'y',
150
+ color: wheelC,
151
+ }),
152
+ ];
153
+ for (const s of [1, -1]) {
154
+ const yi = s * (WHEEL_Y - TREAD_W / 2);
155
+ parts.push(
156
+ lathe({
157
+ profile: [
158
+ [WHEEL_R - 0.02, yi - s * 0.03],
159
+ [WHEEL_R + FLANGE, yi - s * 0.025],
160
+ [WHEEL_R + FLANGE, yi - s * 0.002],
161
+ [WHEEL_R - 0.02, yi - s * 0.002],
162
+ ],
163
+ segments: segs,
164
+ axis: 'y',
165
+ color: wheelC,
166
+ caps: false,
167
+ }),
168
+ );
169
+ if (lod === 0) {
170
+ // Ribbed back: radial ribs on the inner face, and the outer hub boss.
171
+ const yo = s * (WHEEL_Y + TREAD_W / 2);
172
+ parts.push(
173
+ cylinder({
174
+ radius: 0.12,
175
+ length: 0.05,
176
+ segments: 12,
177
+ axis: 'y',
178
+ at: [0, yo + s * 0.02, 0],
179
+ color: wheelC,
180
+ }),
181
+ );
182
+ for (let k = 0; k < 6; k++) {
183
+ const a = (k / 6) * Math.PI * 2;
184
+ parts.push(
185
+ rod(
186
+ [Math.cos(a) * 0.13, yi - s * 0.015, Math.sin(a) * 0.13],
187
+ [Math.cos(a) * (WHEEL_R - 0.05), yi - s * 0.015, Math.sin(a) * (WHEEL_R - 0.05)],
188
+ 0.03,
189
+ wheelC,
190
+ ),
191
+ );
192
+ }
193
+ }
194
+ }
195
+ return merge(parts);
196
+ }
197
+
198
+ /** Cast side-frame truck around x = 0 (local): frames, journal boxes, springs, bolster, brakes. */
199
+ function truckFrame(lod: Lod, bevel: number): Mesh {
200
+ if (lod === 2) {
201
+ // Far: one side-frame block per side over the journal boxes, the bolster and centre plate.
202
+ const far: Mesh[] = [bx(-0.15, 0.15, -(JOURNAL_Y + 0.12), JOURNAL_Y + 0.12, 0.33, 0.6, steel)];
203
+ for (const s of [-1, 1])
204
+ far.push(
205
+ bx(
206
+ -WB / 2 - 0.16,
207
+ WB / 2 + 0.16,
208
+ s * JOURNAL_Y,
209
+ s * (JOURNAL_Y + 0.16),
210
+ WHEEL_R - 0.09,
211
+ WHEEL_R + 0.2,
212
+ steel,
213
+ ),
214
+ );
215
+ far.push(cylinder({ radius: 0.2, length: 0.04, segments: 6, at: [0, 0, 0.62], color: steel }));
216
+ return merge(far);
217
+ }
218
+ const r = WHEEL_R;
219
+ const ax = [-WB / 2, WB / 2] as const;
220
+ const zt = r + 0.14;
221
+ const zb = r - 0.26;
222
+ const out: Mesh[] = [];
223
+ for (const s of [-1, 1]) {
224
+ const y = s * (JOURNAL_Y + 0.08);
225
+ for (const a of ax) {
226
+ out.push(
227
+ bx(
228
+ a - 0.13,
229
+ a + 0.13,
230
+ s * JOURNAL_Y,
231
+ s * (JOURNAL_Y + 0.17),
232
+ r - 0.09,
233
+ r + 0.12,
234
+ steel,
235
+ 'iron',
236
+ bevel,
237
+ ),
238
+ );
239
+ if (lod === 0)
240
+ out.push(
241
+ bx(
242
+ a - 0.1,
243
+ a + 0.1,
244
+ s * (JOURNAL_Y + 0.17),
245
+ s * (JOURNAL_Y + 0.18),
246
+ r - 0.06,
247
+ r + 0.09,
248
+ steel,
249
+ ),
250
+ ); // lid
251
+ }
252
+ out.push(
253
+ bx(ax[0] - 0.16, ax[1] + 0.16, y - 0.06, y + 0.06, r + 0.12, zt + 0.07, steel, 'iron', bevel),
254
+ ); // top member
255
+ if (lod < 2) {
256
+ const p: [number, number][] = [
257
+ [ax[0] + 0.1, r - 0.08],
258
+ [-0.34, zb],
259
+ [0.34, zb],
260
+ [ax[1] - 0.1, r - 0.08],
261
+ ];
262
+ for (let k = 0; k < 3; k++) {
263
+ const pa: [number, number] = p[k] ?? [0, 0];
264
+ const pb: [number, number] = p[k + 1] ?? [0, 0];
265
+ out.push(rod([pa[0], y, pa[1]], [pb[0], y, pb[1]], 0.08, steel));
266
+ }
267
+ for (const d of [-1, 1])
268
+ out.push(rod([d * 0.34, y, zb], [d * 0.62, y, zt + 0.02], 0.06, steel)); // cast window struts
269
+ const coilSegs = lod === 0 ? 10 : 6;
270
+ for (const d of [-0.11, 0, 0.11]) {
271
+ out.push(
272
+ cylinder({
273
+ radius: 0.05,
274
+ length: 0.17,
275
+ segments: coilSegs,
276
+ at: [d, y, zb + 0.125],
277
+ color: iron,
278
+ }),
279
+ );
280
+ if (lod === 0)
281
+ for (let k = 0; k < 4; k++)
282
+ out.push(
283
+ cylinder({
284
+ radius: 0.056,
285
+ length: 0.012,
286
+ segments: coilSegs,
287
+ at: [d, y, zb + 0.06 + k * 0.042],
288
+ color: iron,
289
+ }),
290
+ );
291
+ }
292
+ } else out.push(bx(-0.4, 0.4, y - 0.05, y + 0.05, zb, zt, steel));
293
+ for (const d of [-1, 1])
294
+ out.push(
295
+ bx(d * 0.27 - 0.035, d * 0.27 + 0.035, y - 0.06, y + 0.06, zb - 0.02, zt + 0.02, steel),
296
+ );
297
+ out.push(bx(-0.2, 0.2, y - 0.06, y + 0.06, zb - 0.04, zb + 0.04, steel)); // spring seat
298
+ }
299
+ // Bolster on the spring nests, centre plate up to the car's body bolster.
300
+ out.push(
301
+ bx(-0.15, 0.15, -(JOURNAL_Y + 0.12), JOURNAL_Y + 0.12, zb + 0.21, 0.6, steel, 'iron', bevel),
302
+ );
303
+ out.push(
304
+ cylinder({
305
+ radius: 0.2,
306
+ length: 0.04,
307
+ segments: [12, 8, 6][lod] ?? 6,
308
+ at: [0, 0, 0.62],
309
+ color: steel,
310
+ }),
311
+ );
312
+ if (lod < 2)
313
+ out.push(bx(-0.12, 0.12, -(JOURNAL_Y + 0.08), JOURNAL_Y + 0.08, zb - 0.06, zb - 0.03, steel)); // spring plank
314
+ if (lod === 0) {
315
+ // Brake heads and shoes inboard of each axle, just outside the flange circle, on a beam.
316
+ for (const a of ax) {
317
+ const d = -Math.sign(a);
318
+ const xs = a + d * (r + FLANGE + 0.015);
319
+ for (const s of [-1, 1])
320
+ out.push(
321
+ bx(
322
+ xs,
323
+ xs + d * 0.07,
324
+ s * (WHEEL_Y - 0.06),
325
+ s * (WHEEL_Y + 0.06),
326
+ r - 0.16,
327
+ r + 0.12,
328
+ iron,
329
+ ),
330
+ );
331
+ out.push(
332
+ bx(
333
+ xs + d * 0.02,
334
+ xs + d * 0.06,
335
+ -(WHEEL_Y - 0.06),
336
+ WHEEL_Y - 0.06,
337
+ r - 0.04,
338
+ r + 0.02,
339
+ iron,
340
+ ),
341
+ );
342
+ for (const s of [-1, 1])
343
+ out.push(
344
+ bx(
345
+ xs + d * 0.03,
346
+ xs + d * 0.05,
347
+ s * (JOURNAL_Y + 0.02),
348
+ s * (WHEEL_Y + 0.06),
349
+ r - 0.02,
350
+ r + 0.0,
351
+ iron,
352
+ ),
353
+ ); // hanger to the frame
354
+ }
355
+ }
356
+ return merge(out);
357
+ }
358
+
359
+ // ---------------------------------------------------------------- the car
360
+ const usra = defineFamily({
361
+ kind: 'vehicle',
362
+ tags: ['railroad', 'freight', 'usra', '1918', 'rolling-stock'],
363
+ license: 'CC0-1.0',
364
+ sources: [
365
+ 'https://bostonmaine.squarespace.com/box_71000_series',
366
+ 'https://commons.wikimedia.org/wiki/File:Military_Administration_-_Transportation_-_Rail_-_Construction_-_50_TON_SINGLE_SHEATHED_BOX_CAR_being_constructed_for_U.S._Railroad_Administration_by_the_Bettendorff_Co.,_Bettendorff,_Iowa_-_NARA_-_45502055.jpg',
367
+ 'https://en.wikipedia.org/wiki/USRA_standard',
368
+ 'https://www.nasg.org/Gallery/reports/scale/cars/modeltype/StrucksAndrews.php',
369
+ 'https://kadee.com/553-ho-scale-andrews-1898-self-centering-trucks-with-33-ribbed-back-wheels-metal-fully-sprung',
370
+ 'https://rapidotrains.com/ho-scale/freight-car/usra-ss-boxcar.html',
371
+ ],
372
+ real: {
373
+ length: 13.4,
374
+ width: 2.896,
375
+ height: 4.039,
376
+ measures: [
377
+ {
378
+ label: 'body length (41 ft 3 in)',
379
+ value: BODY_L,
380
+ axis: 'x',
381
+ parts: ['body'],
382
+ source: 'B&M ORER table',
383
+ },
384
+ {
385
+ label: 'wheel diameter (33 in)',
386
+ value: 0.838,
387
+ axis: 'z',
388
+ parts: ['axle_a_0_wheel_l'],
389
+ source: 'Kadee Andrews 33 in',
390
+ },
391
+ {
392
+ label: 'truck wheelbase (5 ft 6 in)',
393
+ value: WB,
394
+ axis: 'x',
395
+ between: ['axle_a_0', 'axle_a_1'],
396
+ source: 'NASG Andrews',
397
+ },
398
+ {
399
+ label: 'door width (≈ 6 ft)',
400
+ value: 1.83,
401
+ axis: 'x',
402
+ parts: ['door_l'],
403
+ tolerance: 0.05,
404
+ source: 'NARA photo, scaled',
405
+ },
406
+ {
407
+ label: 'gauge-side wheel spacing',
408
+ value: WHEEL_Y * 2,
409
+ axis: 'y',
410
+ between: ['axle_a_0_wheel_l', 'axle_a_0_wheel_r'],
411
+ source: 'standard gauge 1.435 m + rail head',
412
+ },
413
+ ],
414
+ },
415
+ budget: { triangles: [17400, 7100, 1150] },
416
+ checks: [
417
+ noOverlap('axle_*_wheel_*'),
418
+ clear('axle_*', 'underframe', 0.01),
419
+ symmetric('_wheel_l', '_wheel_r', 'y'),
420
+ ],
421
+ defaults: {
422
+ road: 'CLINCHFIELD',
423
+ marks: 'C.C.& O.',
424
+ number: '8024',
425
+ paint: hex('#84402d'),
426
+ letter: hex('#e8e2d2'),
427
+ } as Params,
428
+ build(ctx, p) {
429
+ const lod = ctx.lod;
430
+ const bevel = ctx.pick([0.012, 0.006, 0]);
431
+ const paint = p.paint;
432
+ const paintDark: Vec3 = [paint[0] * 0.78, paint[1] * 0.78, paint[2] * 0.78];
433
+ const dirt = (m: Mesh): Mesh => grime(m, { ground: 1.3, groundStrength: 0.35 });
434
+
435
+ // Trucks and spinning axles.
436
+ for (const [t, x] of [
437
+ ['a', TC / 2],
438
+ ['b', -TC / 2],
439
+ ] as const) {
440
+ ctx.group(`truck_${t}`, { at: [x, 0, 0] });
441
+ ctx.part(`truck_${t}_frame`, dirt(truckFrame(lod, bevel)), { parent: `truck_${t}` });
442
+ [-WB / 2, WB / 2].forEach((ax, i) => {
443
+ const name = `axle_${t}_${i}`;
444
+ ctx.group(name, {
445
+ parent: `truck_${t}`,
446
+ at: [ax, 0, WHEEL_R],
447
+ motion: { kind: 'spin', axis: [0, 1, 0], rps: 1.5 },
448
+ });
449
+ ctx.part(`${name}_set`, wheelset(lod), { parent: name });
450
+ ctx.part(`${name}_wheel_l`, tread(lod, WHEEL_Y), { parent: name });
451
+ ctx.part(`${name}_wheel_r`, tread(lod, -WHEEL_Y), { parent: name });
452
+ });
453
+ }
454
+
455
+ // Underframe: straight centre sill, side sills, end sills, body bolsters, crossbearers, floor.
456
+ const uf: Mesh[] = [
457
+ bx(-XB - 0.04, XB + 0.04, -0.2, 0.2, 0.72, 1.1, steel, 'iron', bevel),
458
+ bx(-XB, XB, -SHEATH_Y + 0.02, SHEATH_Y - 0.02, 1.1, FLOOR_Z, walk, 'wood'),
459
+ ];
460
+ for (const s of [-1, 1])
461
+ uf.push(bx(-XB, XB, s * SHEATH_Y, s * (FRAME_Y - 0.01), 0.95, 1.18, steel, 'iron', bevel));
462
+ for (const d of [-1, 1]) {
463
+ uf.push(bx(d * XB, d * (XB + 0.05), -FRAME_Y, FRAME_Y, 0.74, 1.18, steel, 'iron', bevel)); // end sill / striker
464
+ uf.push(
465
+ bx(d * (TC / 2) - 0.2, d * (TC / 2) + 0.2, -1.25, 1.25, 0.64, 1.1, steel, 'iron', bevel),
466
+ ); // body bolster
467
+ if (lod < 2)
468
+ for (const x of [1.6, 3.0])
469
+ uf.push(bx(d * x - 0.08, d * x + 0.08, -1.3, 1.3, 0.8, 1.1, steel)); // crossbearers
470
+ }
471
+ ctx.part('underframe', dirt(merge(uf)));
472
+
473
+ // Body: vertical boards between steel frame members; steel ends.
474
+ const bodyM: Mesh[] = [];
475
+ const boardsZ0 = 1.18;
476
+ for (const s of [-1, 1]) {
477
+ // Boards face out: u = up, v = along (planks run along U → vertical boards).
478
+ const v: Vec3 = [s < 0 ? BODY_L : -BODY_L, 0, 0];
479
+ bodyM.push(
480
+ tiled({
481
+ origin: [s < 0 ? -XB : XB, s * SHEATH_Y, boardsZ0],
482
+ u: [0, 0, EAVE_Z - boardsZ0],
483
+ v,
484
+ color: paint,
485
+ strip: lod === 2 ? 'plain' : 'wood',
486
+ vMetres: lod === 2 ? BODY_L : 0.6,
487
+ }),
488
+ );
489
+ // Inner sheathing face (the boards have thickness at the door and ends).
490
+ bodyM.push(
491
+ bx(
492
+ -XB,
493
+ XB,
494
+ s * (SHEATH_Y - 0.045),
495
+ s * (SHEATH_Y - 0.002),
496
+ boardsZ0,
497
+ EAVE_Z,
498
+ paintDark,
499
+ 'plain',
500
+ ),
501
+ );
502
+ }
503
+ for (const d of [-1, 1])
504
+ bodyM.push(bx(d * (XB - 0.05), d * XB, -SHEATH_Y, SHEATH_Y, 1.0, EAVE_Z, paint, 'iron'));
505
+ ctx.part('body', merge(bodyM));
506
+
507
+ // Outside steel framing: posts, diagonal braces leaning toward the door, top plate, end ribs.
508
+ const fr: Mesh[] = [];
509
+ const panel = (XB - DOOR_W / 2 - 0.08) / 4;
510
+ const posts = [0, 1, 2, 3, 4].map((i) => XB - i * panel);
511
+ const postW = 0.09;
512
+ for (const s of [-1, 1]) {
513
+ const y0 = s * SHEATH_Y;
514
+ const y1 = s * FRAME_Y;
515
+ for (const d of [-1, 1]) {
516
+ for (const px of lod === 2 ? [] : posts) {
517
+ const x = d * px;
518
+ fr.push(bx(x - postW / 2, x + postW / 2, y0, y1, 1.0, EAVE_Z, paint, 'iron'));
519
+ }
520
+ // Door posts.
521
+ fr.push(
522
+ bx(d * (DOOR_W / 2 + 0.01), d * (DOOR_W / 2 + 0.1), y0, y1, 1.0, EAVE_Z, paint, 'iron'),
523
+ );
524
+ if (lod < 2)
525
+ for (let i = 0; i < 4; i++) {
526
+ const xa = d * ((posts[i] ?? 0) - postW / 2);
527
+ const xb = d * ((posts[i + 1] ?? DOOR_W / 2) + postW / 2);
528
+ const ym = s * (SHEATH_Y + 0.035);
529
+ fr.push(
530
+ beam({
531
+ from: [xa, ym, 1.22],
532
+ to: [xb, ym, EAVE_Z - 0.12],
533
+ width: 0.075,
534
+ height: 0.06,
535
+ color: paint,
536
+ strip: 'iron',
537
+ up: [0, s, 0],
538
+ }),
539
+ );
540
+ }
541
+ }
542
+ fr.push(bx(-XB, XB, y0, s * (FRAME_Y + 0.01), EAVE_Z - 0.16, EAVE_Z, paint, 'iron', bevel)); // side plate
543
+ if (lod === 0) {
544
+ // Rivet heads where braces meet posts and sills.
545
+ const rivet = cylinder({
546
+ radius: 0.014,
547
+ length: 0.012,
548
+ segments: 6,
549
+ axis: 'y',
550
+ color: paint,
551
+ });
552
+ const pts: Vec3[] = [];
553
+ for (const d of [-1, 1])
554
+ for (const px of posts)
555
+ for (const z of [1.08, 1.26, EAVE_Z - 0.2, EAVE_Z - 0.08])
556
+ pts.push([d * px, s * (FRAME_Y + 0.003), z]);
557
+ fr.push(merge(pts.map((at) => place(rivet, { at }))));
558
+ }
559
+ }
560
+ // Ends: corner angles, pressed ribs (LOD0/1).
561
+ for (const d of [-1, 1]) {
562
+ for (const s of [-1, 1])
563
+ fr.push(
564
+ bx(
565
+ d * (XB - 0.06),
566
+ d * (XB + 0.03),
567
+ s * (SHEATH_Y - 0.05),
568
+ s * FRAME_Y,
569
+ 1.0,
570
+ EAVE_Z,
571
+ paint,
572
+ 'iron',
573
+ ),
574
+ );
575
+ if (lod < 2)
576
+ for (let k = 0; k < (lod === 0 ? 8 : 4); k++) {
577
+ const z = 1.35 + ((EAVE_Z - 1.55) * (k + 0.5)) / (lod === 0 ? 8 : 4);
578
+ fr.push(
579
+ bx(
580
+ d * XB,
581
+ d * (XB + 0.035),
582
+ -(SHEATH_Y - 0.12),
583
+ SHEATH_Y - 0.12,
584
+ z - 0.05,
585
+ z + 0.05,
586
+ paint,
587
+ 'iron',
588
+ ),
589
+ );
590
+ }
591
+ }
592
+ ctx.part('body_framing', dirt(merge(fr)));
593
+
594
+ // Roof: low steel gable with seam caps; running board on saddles; laterals at the corners.
595
+ const roofOv = 0.04;
596
+ const roofProfile: [number, number][] = [
597
+ [-(FRAME_Y + roofOv), EAVE_Z - 0.03],
598
+ [FRAME_Y + roofOv, EAVE_Z - 0.03],
599
+ [FRAME_Y + roofOv, EAVE_Z],
600
+ [0, RIDGE_Z],
601
+ [-(FRAME_Y + roofOv), EAVE_Z],
602
+ ];
603
+ const roofM: Mesh[] = [
604
+ prism({
605
+ profile: roofProfile,
606
+ depth: BODY_L + 0.1,
607
+ plane: 'yz',
608
+ color: paintDark,
609
+ strip: 'iron',
610
+ }),
611
+ ];
612
+ if (lod === 0) {
613
+ const seams = 20;
614
+ for (let i = 1; i < seams; i++) {
615
+ const x = -XB + (BODY_L * i) / seams;
616
+ for (const s of [-1, 1])
617
+ roofM.push(
618
+ rod(
619
+ [x, s * (FRAME_Y + roofOv), EAVE_Z + 0.012],
620
+ [x, 0, RIDGE_Z + 0.012],
621
+ 0.035,
622
+ paintDark,
623
+ ),
624
+ );
625
+ }
626
+ }
627
+ ctx.part('roof', merge(roofM));
628
+
629
+ const walkM: Mesh[] = [
630
+ bx(-XB - 0.12, XB + 0.12, -0.255, 0.255, WALK_TOP - 0.045, WALK_TOP, walk, 'wood'),
631
+ ];
632
+ const saddles = lod === 2 ? 3 : 11;
633
+ for (let i = 0; i < saddles; i++) {
634
+ const x = -XB + 0.3 + ((BODY_L - 0.6) * i) / (saddles - 1);
635
+ walkM.push(bx(x - 0.05, x + 0.05, -0.2, 0.2, RIDGE_Z - 0.03, WALK_TOP - 0.045, walk, 'wood'));
636
+ }
637
+ if (lod < 2)
638
+ for (const d of [-1, 1]) {
639
+ // Lateral board toward the ladder corner (A end on −Y, B end on +Y).
640
+ const s = -d;
641
+ walkM.push(
642
+ bx(
643
+ d * (XB - 0.62),
644
+ d * (XB - 0.12),
645
+ s * 0.255,
646
+ s * (FRAME_Y - 0.05),
647
+ WALK_TOP - 0.045,
648
+ WALK_TOP,
649
+ walk,
650
+ 'wood',
651
+ ),
652
+ );
653
+ walkM.push(
654
+ bx(
655
+ d * (XB - 0.42),
656
+ d * (XB - 0.32),
657
+ s * 0.4,
658
+ s * (FRAME_Y - 0.15),
659
+ EAVE_Z,
660
+ WALK_TOP - 0.045,
661
+ walk,
662
+ 'wood',
663
+ ),
664
+ );
665
+ }
666
+ ctx.part('running_board', merge(walkM));
667
+
668
+ // Sliding doors, hung on a bottom track and held by a top guide; slide along X.
669
+ const doorTrack: Mesh[] = [];
670
+ for (const [side, s] of [
671
+ ['l', 1],
672
+ ['r', -1],
673
+ ] as const) {
674
+ const y0 = s * (FRAME_Y + 0.005);
675
+ const y1 = s * (FRAME_Y + 0.05);
676
+ const dm: Mesh[] = [
677
+ tiled({
678
+ origin: [s > 0 ? DOOR_W / 2 : -DOOR_W / 2, y1, DOOR_Z0],
679
+ u: [0, 0, DOOR_Z1 - DOOR_Z0],
680
+ v: [s > 0 ? -DOOR_W : DOOR_W, 0, 0],
681
+ color: paint,
682
+ strip: lod === 2 ? 'plain' : 'wood',
683
+ }),
684
+ bx(-DOOR_W / 2, DOOR_W / 2, y0, y1 - s * 0.003, DOOR_Z0, DOOR_Z1, paintDark, 'plain'),
685
+ ];
686
+ if (lod < 2) {
687
+ for (const z of [DOOR_Z0, (DOOR_Z0 + DOOR_Z1) / 2 - 0.05, DOOR_Z1 - 0.1])
688
+ dm.push(bx(-DOOR_W / 2, DOOR_W / 2, y1, y1 + s * 0.015, z, z + 0.1, paint, 'iron')); // steel straps
689
+ for (const x of [-DOOR_W / 2, DOOR_W / 2 - 0.08])
690
+ dm.push(bx(x, x + 0.08, y1, y1 + s * 0.015, DOOR_Z0, DOOR_Z1, paint, 'iron'));
691
+ }
692
+ if (lod === 0) dm.push(bx(-0.75, -0.65, y1 + s * 0.015, y1 + s * 0.06, 2.0, 2.2, iron)); // handle / latch
693
+ ctx.part(`door_${side}`, dirt(merge(dm)), {
694
+ motion: { kind: 'slide', offset: [-(DOOR_W + 0.05), 0, 0], hz: 0.25, oneWay: true },
695
+ });
696
+ // Track below the door, guide above, long enough for its one-way travel toward −X.
697
+ doorTrack.push(
698
+ bx(
699
+ -(DOOR_W * 1.5 + 0.1), // the door opens toward −X
700
+ DOOR_W / 2 + 0.1,
701
+ s * FRAME_Y,
702
+ s * (FRAME_Y + 0.07),
703
+ 1.08,
704
+ DOOR_Z0 - 0.025,
705
+ iron,
706
+ ),
707
+ );
708
+ doorTrack.push(
709
+ bx(
710
+ -(DOOR_W * 1.5 + 0.1),
711
+ DOOR_W / 2 + 0.1,
712
+ s * (FRAME_Y + 0.01),
713
+ s * (FRAME_Y + 0.08),
714
+ DOOR_Z1 + 0.025,
715
+ DOOR_Z1 + 0.09,
716
+ iron,
717
+ ),
718
+ );
719
+ }
720
+ if (lod < 2) ctx.part('door_track', merge(doorTrack));
721
+
722
+ // Knuckle couplers on the centre sill, MCB height.
723
+ for (const [c, d] of [
724
+ ['a', 1],
725
+ ['b', -1],
726
+ ] as const) {
727
+ const cm: Mesh[] = [
728
+ bx(
729
+ d * (XB + 0.05),
730
+ d * 6.56,
731
+ -0.08,
732
+ 0.08,
733
+ COUPLER_Z - 0.07,
734
+ COUPLER_Z + 0.07,
735
+ iron,
736
+ 'iron',
737
+ bevel,
738
+ ),
739
+ bx(d * 6.5, d * 6.7, -0.17, 0.12, COUPLER_Z - 0.13, COUPLER_Z + 0.13, iron, 'iron', bevel),
740
+ ];
741
+ if (lod < 2) cm.push(bx(d * 6.6, d * 6.7, 0.12, 0.2, COUPLER_Z - 0.1, COUPLER_Z + 0.1, iron)); // knuckle
742
+ if (lod === 0) {
743
+ // Uncoupling lever across the end sill, and the air hose hanging below.
744
+ cm.push(
745
+ rod(
746
+ [d * (XB + 0.08), -0.08, COUPLER_Z + 0.12],
747
+ [d * (XB + 0.08), -1.3, COUPLER_Z + 0.2],
748
+ 0.025,
749
+ ),
750
+ );
751
+ cm.push(rod([d * (XB + 0.1), 0.3, 0.8], [d * (XB + 0.22), 0.3, 0.55], 0.05, iron, 6));
752
+ }
753
+ ctx.part(`coupler_${c}`, merge(cm));
754
+ }
755
+
756
+ // Safety appliances: grab-iron ladders at diagonally opposite corners, end ladders, steps.
757
+ if (lod < 2) {
758
+ const lad: Mesh[] = [];
759
+ const grab = (a: Vec3, b: Vec3, n: Vec3): void => {
760
+ const off = 0.07;
761
+ const pa: Vec3 = [a[0] + n[0] * off, a[1] + n[1] * off, a[2]];
762
+ const pb: Vec3 = [b[0] + n[0] * off, b[1] + n[1] * off, b[2]];
763
+ lad.push(rod(pa, pb, 0.022, iron, lod === 0 ? 6 : 0));
764
+ if (lod === 0) {
765
+ lad.push(rod(a, pa, 0.02, iron));
766
+ lad.push(rod(b, pb, 0.02, iron));
767
+ }
768
+ };
769
+ for (const d of [-1, 1]) {
770
+ const s = -d; // A end ladder on −Y, B end on +Y
771
+ const xe = d * (XB - 0.05);
772
+ for (let k = 0; k < 7; k++) {
773
+ const z = 1.45 + k * 0.38;
774
+ grab([xe - d * 0.5, s * FRAME_Y, z], [xe - d * 0.05, s * FRAME_Y, z], [0, s, 0]);
775
+ grab([d * (XB + 0.035), s * 0.62, z], [d * (XB + 0.035), s * 1.12, z], [d, 0, 0]);
776
+ }
777
+ // Stirrup steps under the corners (both sides).
778
+ for (const ss of [-1, 1]) {
779
+ const x = d * (XB - 0.3);
780
+ const y = ss * (FRAME_Y - 0.03);
781
+ lad.push(rod([x - 0.18, y, 0.95], [x - 0.18, y, 0.55], 0.03));
782
+ lad.push(rod([x + 0.18, y, 0.95], [x + 0.18, y, 0.55], 0.03));
783
+ lad.push(rod([x - 0.18, y, 0.56], [x + 0.18, y, 0.56], 0.04));
784
+ }
785
+ }
786
+ ctx.part('ladders', merge(lad));
787
+ }
788
+
789
+ // Hand brake: vertical staff on the B end, horizontal wheel at roof level.
790
+ const bm: Mesh[] = [
791
+ rod(
792
+ [-(XB + 0.13), -0.85, 0.85],
793
+ [-(XB + 0.13), -0.85, WALK_TOP - 0.06],
794
+ 0.035,
795
+ iron,
796
+ lod === 2 ? 0 : 6,
797
+ ),
798
+ ];
799
+ for (const z of [1.0, 2.3, EAVE_Z - 0.1])
800
+ bm.push(bx(-XB, -(XB + 0.15), -0.89, -0.81, z, z + 0.05, iron));
801
+ const wheelSegs = [16, 10, 6][lod] ?? 6;
802
+ bm.push(
803
+ lathe({
804
+ profile: [
805
+ [0.17, WALK_TOP - 0.06],
806
+ [0.205, WALK_TOP - 0.06],
807
+ [0.205, WALK_TOP - 0.035],
808
+ [0.17, WALK_TOP - 0.035],
809
+ [0.17, WALK_TOP - 0.06],
810
+ ],
811
+ segments: wheelSegs,
812
+ color: iron,
813
+ at: [-(XB + 0.13), -0.85, 0],
814
+ }),
815
+ );
816
+ if (lod < 2)
817
+ for (let k = 0; k < 4; k++) {
818
+ const a = (k / 4) * Math.PI * 2 + 0.4;
819
+ bm.push(
820
+ rod(
821
+ [-(XB + 0.13), -0.85, WALK_TOP - 0.05],
822
+ [-(XB + 0.13) + Math.cos(a) * 0.18, -0.85 + Math.sin(a) * 0.18, WALK_TOP - 0.05],
823
+ 0.025,
824
+ ),
825
+ );
826
+ }
827
+ if (lod < 2) ctx.part('brake', merge(bm));
828
+
829
+ // Air brake: reservoir, cylinder, triple valve, train line (hidden under the car beyond LOD0).
830
+ if (lod === 0) {
831
+ const ab: Mesh[] = [
832
+ cylinder({
833
+ radius: 0.2,
834
+ length: 1.1,
835
+ segments: 12,
836
+ axis: 'x',
837
+ at: [-0.9, 0.55, 0.9],
838
+ color: iron,
839
+ }),
840
+ cylinder({
841
+ radius: 0.16,
842
+ length: 0.5,
843
+ segments: 12,
844
+ axis: 'x',
845
+ at: [0.4, -0.5, 0.92],
846
+ color: iron,
847
+ }),
848
+ bx(-0.25, -0.05, 0.2, 0.42, 0.85, 1.1, iron),
849
+ rod([-0.35, 0.55, 1.08], [-0.35, 0.2, 1.08], 0.05, iron),
850
+ rod([-1.45, 0.55, 0.9], [-1.45, 0.2, 0.9], 0.04, iron),
851
+ rod([0.15, -0.5, 1.0], [0.15, -0.2, 1.0], 0.04, iron),
852
+ rod([-XB, 0.3, 0.84], [XB, 0.3, 0.84], 0.035, iron, 6),
853
+ rod([0.65, -0.5, 0.92], [1.8, -0.1, 0.8], 0.04, iron),
854
+ ];
855
+ // Hanger straps up to the centre sill for the reservoir / train line.
856
+ for (const x of [-1.3, -0.5]) ab.push(bx(x - 0.03, x + 0.03, 0.2, 0.75, 1.08, 1.1, iron));
857
+ for (const x of [-4.0, -2.0, 2.0, 4.0])
858
+ ab.push(bx(x - 0.03, x + 0.03, 0.2, 0.33, 0.82, 1.1, iron));
859
+ ctx.part('air_brake', merge(ab));
860
+ }
861
+
862
+ // Livery: road name left of the door, marks + number under it (both sides, read left→right).
863
+ if (lod < 2) {
864
+ const lm: Mesh[] = [];
865
+ /** |y| of the painted surface at x on a side: post faces or boards. */
866
+ const face = (x: number): number => {
867
+ const ax = Math.abs(x);
868
+ if (posts.some((q) => Math.abs(ax - q) <= postW / 2)) return FRAME_Y;
869
+ if (ax >= DOOR_W / 2 + 0.01 && ax <= DOOR_W / 2 + 0.1) return FRAME_Y;
870
+ // Braces cross over the paint (they read as the brace in front of the lettering); a
871
+ // stroke painted on a diagonal brace face jumps sideways in parallax and garbles the word.
872
+ return SHEATH_Y;
873
+ };
874
+ for (const s of [-1, 1]) {
875
+ const dirX = s < 0 ? 1 : -1; // read left → right for a viewer on that side
876
+ const xl = -dirX * (XB + DOOR_W / 2) * 0.5; // centre of the left half
877
+ const put = (str: string, cx: number, base: number, h: number, maxWidth?: number): void => {
878
+ lm.push(
879
+ text(str, {
880
+ origin: [cx, s * SHEATH_Y, base],
881
+ along: [dirX, 0, 0],
882
+ up: [0, 0, 1],
883
+ height: h,
884
+ color: p.letter,
885
+ align: 'centre',
886
+ font: 'block',
887
+ ...(maxWidth ? { maxWidth } : {}),
888
+ // Painted over the proud posts and braces as on the real car.
889
+ surface: (u) => face(cx + dirX * u) - SHEATH_Y,
890
+ }),
891
+ );
892
+ };
893
+ put(p.road, xl, 3.0, 0.42, XB - DOOR_W / 2 - 0.5);
894
+ put(p.marks, xl, 2.43, 0.24);
895
+ put(p.number, xl, 1.92, 0.36);
896
+ if (lod === 0) {
897
+ put(p.marks, -xl, 3.29, 0.12);
898
+ put(p.number, -xl, 3.09, 0.12);
899
+ }
900
+ }
901
+ ctx.part('lettering', merge(lm));
902
+ }
903
+ },
904
+ });
905
+
906
+ export const boxcar = usra.variant({
907
+ name: 'boxcar',
908
+ description:
909
+ 'USRA 50-ton single-sheathed 40 ft boxcar (1918), Clinchfield C.C.& O. 8024: wood sheathing in outside steel framing, sliding doors, cast trucks with spinning axles.',
910
+ });
911
+
912
+ export const boxcar_nw = usra.variant({
913
+ name: 'boxcar_nw',
914
+ description: 'USRA single-sheathed boxcar in Norfolk & Western lettering, oxide red.',
915
+ params: { road: 'NORFOLK & WESTERN', marks: 'N.& W.', number: '42574', paint: hex('#74382a') },
916
+ });