roamwright 0.20.1 → 0.54.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 (516) hide show
  1. package/.prettierrc.yaml +12 -0
  2. package/CONTRIBUTING.md +19 -14
  3. package/README.md +35 -16
  4. package/examples/animals.html +49 -0
  5. package/examples/animals.js +209 -0
  6. package/examples/crowds.html +50 -0
  7. package/examples/crowds.js +268 -0
  8. package/examples/effects.html +53 -0
  9. package/examples/effects.js +343 -0
  10. package/examples/figure-motion.html +55 -0
  11. package/examples/figure-motion.js +265 -0
  12. package/examples/figure.html +49 -0
  13. package/examples/figure.js +238 -0
  14. package/examples/fliers.html +53 -0
  15. package/examples/fliers.js +292 -0
  16. package/examples/fortification.html +54 -0
  17. package/examples/fortification.js +288 -0
  18. package/examples/house-kit.html +48 -0
  19. package/examples/house-kit.js +175 -0
  20. package/examples/index.html +26 -16
  21. package/examples/island.html +48 -0
  22. package/examples/island.js +134 -52
  23. package/examples/land.html +54 -0
  24. package/examples/land.js +392 -0
  25. package/examples/props-and-plants.html +53 -0
  26. package/examples/props-and-plants.js +275 -0
  27. package/examples/rooms.html +48 -0
  28. package/examples/rooms.js +242 -0
  29. package/examples/ships.html +51 -0
  30. package/examples/ships.js +235 -0
  31. package/examples/showcase.css +320 -0
  32. package/examples/small-world-land.js +151 -0
  33. package/examples/small-world-life.js +160 -0
  34. package/examples/small-world-town.js +127 -0
  35. package/examples/small-world.html +57 -0
  36. package/examples/small-world.js +226 -0
  37. package/examples/soundscape.html +138 -0
  38. package/examples/soundscape.js +467 -0
  39. package/examples/stage-kits.js +300 -0
  40. package/examples/stage.js +374 -0
  41. package/examples/towns.html +50 -0
  42. package/examples/towns.js +325 -0
  43. package/examples/viaduct-camera.js +8 -4
  44. package/examples/viaduct-landscape.js +28 -17
  45. package/examples/viaduct.html +45 -43
  46. package/examples/viaduct.js +68 -92
  47. package/geometry/animal-camel-body.js +410 -0
  48. package/geometry/animal-camel-head.js +118 -0
  49. package/geometry/animal-canine-body.js +361 -0
  50. package/geometry/animal-canine-breeds.js +316 -0
  51. package/geometry/animal-canine-head.js +337 -0
  52. package/geometry/animal-cattle-body.js +391 -0
  53. package/geometry/animal-cattle-coat.js +42 -0
  54. package/geometry/animal-cattle-head.js +152 -0
  55. package/geometry/animal-hen.js +248 -0
  56. package/geometry/animal-horse-body.js +446 -0
  57. package/geometry/animal-horse-bridle.js +171 -0
  58. package/geometry/animal-horse-coat.js +68 -0
  59. package/geometry/animal-horse-face.js +162 -0
  60. package/geometry/animal-horse-hair.js +304 -0
  61. package/geometry/animal-horse-head.js +133 -0
  62. package/geometry/animal-horse-tack.js +157 -0
  63. package/geometry/animal-options.js +59 -0
  64. package/geometry/animal-shapes.js +21 -0
  65. package/geometry/animal-skin.js +390 -0
  66. package/geometry/builder-cells.js +10 -2
  67. package/geometry/builder-frame.js +2 -1
  68. package/geometry/builder.js +15 -4
  69. package/geometry/card-emblem.js +437 -0
  70. package/geometry/catenary-canvas.js +396 -0
  71. package/geometry/cloth-folds.js +143 -0
  72. package/geometry/crawl-shapes.js +71 -0
  73. package/geometry/creased-sheet.js +7 -2
  74. package/geometry/crowd-dress.js +315 -0
  75. package/geometry/crowd-far.js +174 -0
  76. package/geometry/crowd-look.js +42 -0
  77. package/geometry/crowd-weld.js +218 -0
  78. package/geometry/ear.js +9 -4
  79. package/geometry/erosion.js +7 -4
  80. package/geometry/face-grid.js +26 -6
  81. package/geometry/field-map.js +59 -0
  82. package/geometry/figure-arms.js +339 -0
  83. package/geometry/figure-beard.js +250 -0
  84. package/geometry/figure-body.js +297 -0
  85. package/geometry/figure-bow.js +105 -0
  86. package/geometry/figure-cloak.js +189 -0
  87. package/geometry/figure-clothes.js +337 -0
  88. package/geometry/figure-face-grids.js +75 -0
  89. package/geometry/figure-gear.js +446 -0
  90. package/geometry/figure-hair-far.js +151 -0
  91. package/geometry/figure-hair-hangs.js +108 -0
  92. package/geometry/figure-hair-patch.js +66 -0
  93. package/geometry/figure-hair.js +320 -0
  94. package/geometry/figure-hands.js +321 -0
  95. package/geometry/figure-head-features.js +280 -0
  96. package/geometry/figure-head.js +375 -0
  97. package/geometry/figure-headwear.js +223 -0
  98. package/geometry/figure-legs.js +231 -0
  99. package/geometry/figure-limbs.js +39 -0
  100. package/geometry/figure-sculpt.js +82 -0
  101. package/geometry/figure-skin.js +97 -0
  102. package/geometry/figure-skirts.js +303 -0
  103. package/geometry/figure-trunk.js +411 -0
  104. package/geometry/flier-corvid-body.js +322 -0
  105. package/geometry/flier-corvid-wings.js +154 -0
  106. package/geometry/flier-long-body.js +195 -0
  107. package/geometry/flier-shapes.js +219 -0
  108. package/geometry/flier-soaring-bird.js +84 -0
  109. package/geometry/foliage.js +177 -4
  110. package/geometry/fort-city-walls.js +479 -0
  111. package/geometry/fort-gate-approach.js +233 -0
  112. package/geometry/fort-great-walls.js +280 -0
  113. package/geometry/fort-keep.js +297 -0
  114. package/geometry/fort-parts.js +261 -0
  115. package/geometry/fort-polyline.js +261 -0
  116. package/geometry/fort-portal.js +96 -0
  117. package/geometry/fort-ring-wall.js +267 -0
  118. package/geometry/fort-seawall.js +104 -0
  119. package/geometry/fort-terrace-gates.js +323 -0
  120. package/geometry/fort-terrace-plan.js +250 -0
  121. package/geometry/fort-terrace-wall.js +345 -0
  122. package/geometry/garment-tags.js +11 -3
  123. package/geometry/grid-gather.js +69 -0
  124. package/geometry/grid-sample.js +185 -0
  125. package/geometry/hair-gathers.js +19 -4
  126. package/geometry/hair-locks.js +1 -1
  127. package/geometry/hair-patch.js +6 -2
  128. package/geometry/hair-shell.js +14 -2
  129. package/geometry/head-presets.js +103 -0
  130. package/geometry/head-profile.js +13 -2
  131. package/geometry/head-shape.js +51 -23
  132. package/geometry/heightfield.js +26 -9
  133. package/geometry/horizon-angles.js +166 -0
  134. package/geometry/house-kit-body.js +195 -0
  135. package/geometry/house-kit-courtyard-parts.js +340 -0
  136. package/geometry/house-kit-courtyard-roof.js +223 -0
  137. package/geometry/house-kit-courtyard.js +409 -0
  138. package/geometry/house-kit-cut.js +29 -0
  139. package/geometry/house-kit-extras.js +192 -0
  140. package/geometry/house-kit-forms.js +298 -0
  141. package/geometry/house-kit-frame.js +74 -0
  142. package/geometry/house-kit-marks.js +93 -0
  143. package/geometry/house-kit-openings.js +193 -0
  144. package/geometry/house-kit-palette.js +54 -0
  145. package/geometry/house-kit-pool.js +71 -0
  146. package/geometry/house-kit-roofs.js +151 -0
  147. package/geometry/house-kit.js +202 -0
  148. package/geometry/instances.js +4 -4
  149. package/geometry/lamp-wash.js +65 -0
  150. package/geometry/land-clearings.js +83 -0
  151. package/geometry/land-ditches.js +290 -0
  152. package/geometry/land-dry-basin.js +327 -0
  153. package/geometry/land-dunes.js +150 -0
  154. package/geometry/land-earthworks.js +432 -0
  155. package/geometry/land-edge.js +292 -0
  156. package/geometry/land-mound-faces.js +349 -0
  157. package/geometry/land-near-relief.js +102 -0
  158. package/geometry/land-sheet.js +220 -0
  159. package/geometry/land-town-ground.js +256 -0
  160. package/geometry/land-waters.js +228 -0
  161. package/geometry/land-wildness.js +123 -0
  162. package/geometry/lathed-vessel.js +293 -0
  163. package/geometry/outline-grid.js +5 -4
  164. package/geometry/outline-segments.js +74 -0
  165. package/geometry/part-ranges.js +35 -0
  166. package/geometry/path-field.js +35 -1
  167. package/geometry/planked-floor.js +149 -0
  168. package/geometry/plant-broadleaf.js +268 -0
  169. package/geometry/plant-shrub.js +198 -0
  170. package/geometry/plant-tints.js +80 -0
  171. package/geometry/plant-trees.js +453 -0
  172. package/geometry/plant-tussock.js +107 -0
  173. package/geometry/primitives.js +65 -23
  174. package/geometry/prop-battlefield.js +69 -0
  175. package/geometry/prop-camp.js +175 -0
  176. package/geometry/prop-door.js +26 -0
  177. package/geometry/prop-harbour.js +105 -0
  178. package/geometry/prop-haycock.js +60 -0
  179. package/geometry/prop-sacks.js +74 -0
  180. package/geometry/prop-sheaf.js +68 -0
  181. package/geometry/prop-street.js +69 -0
  182. package/geometry/prop-tents.js +396 -0
  183. package/geometry/prop-tombs.js +80 -0
  184. package/geometry/prop-trade.js +393 -0
  185. package/geometry/prop-vehicles.js +218 -0
  186. package/geometry/props.js +58 -0
  187. package/geometry/room-arcade.js +134 -0
  188. package/geometry/room-dome.js +188 -0
  189. package/geometry/room-flames.js +138 -0
  190. package/geometry/room-frame.js +106 -0
  191. package/geometry/room-furniture.js +260 -0
  192. package/geometry/room-hearth.js +98 -0
  193. package/geometry/room-kit.js +59 -0
  194. package/geometry/room-openings.js +142 -0
  195. package/geometry/room-stairs.js +180 -0
  196. package/geometry/room-surfaces.js +272 -0
  197. package/geometry/sampled-surface.js +24 -10
  198. package/geometry/scatter-grid.js +6 -3
  199. package/geometry/sculpt.js +5 -1
  200. package/geometry/ship-fittings.js +350 -0
  201. package/geometry/ship-hull.js +460 -0
  202. package/geometry/ship-kit.js +208 -0
  203. package/geometry/ship-lines.js +69 -0
  204. package/geometry/ship-oars.js +150 -0
  205. package/geometry/ship-presets.js +131 -0
  206. package/geometry/ship-rig.js +374 -0
  207. package/geometry/ship-sails.js +148 -0
  208. package/geometry/shore-grid.js +5 -1
  209. package/geometry/strata-field.js +44 -11
  210. package/geometry/strata-tiles.js +20 -6
  211. package/geometry/stream.js +32 -17
  212. package/geometry/swept-tube.js +124 -0
  213. package/geometry/terrain-chunks.js +139 -51
  214. package/geometry/terrain-extension.js +24 -8
  215. package/geometry/town-courtyard-inn.js +272 -0
  216. package/geometry/town-ground.js +76 -0
  217. package/geometry/town-houses.js +343 -0
  218. package/geometry/town-lights.js +254 -0
  219. package/geometry/town-lots.js +172 -0
  220. package/geometry/town-plan.js +370 -0
  221. package/geometry/town-works.js +465 -0
  222. package/geometry/village-layout.js +181 -0
  223. package/geometry/village-yards.js +167 -0
  224. package/geometry/wall-runs.js +64 -0
  225. package/index.js +134 -3
  226. package/math/cloud-textures.js +3 -7
  227. package/math/curve.js +5 -1
  228. package/math/lamp-texels.js +43 -0
  229. package/math/lit-share.js +22 -0
  230. package/math/mountain-ranges.js +177 -54
  231. package/math/periodic.js +6 -0
  232. package/math/rectangles.js +8 -2
  233. package/math/rock-texture.js +17 -12
  234. package/math/surface-textures.js +24 -9
  235. package/math/wandering-path.js +40 -0
  236. package/math/ways.js +120 -0
  237. package/motion/action-dynamics.js +398 -0
  238. package/motion/animal-bearing.js +247 -0
  239. package/motion/animal-canine-bearing.js +178 -0
  240. package/motion/animal-canine-cast.js +131 -0
  241. package/motion/animal-cattle-cast.js +64 -0
  242. package/motion/animal-herd-cast.js +154 -0
  243. package/motion/animal-horse-still.js +161 -0
  244. package/motion/animal-troop-cast.js +43 -0
  245. package/motion/arm-reach.js +3 -2
  246. package/motion/ballistic-arc.js +182 -2
  247. package/motion/biped-cycle.js +4 -2
  248. package/motion/biped-leg.js +4 -1
  249. package/motion/biped-posture.js +459 -0
  250. package/motion/biped-stride.js +142 -32
  251. package/motion/boat-sailing.js +214 -0
  252. package/motion/contact-transition.js +5 -6
  253. package/motion/crowd-alarms.js +36 -6
  254. package/motion/crowd-attention.js +108 -0
  255. package/motion/crowd-beasts.js +203 -0
  256. package/motion/crowd-camp.js +295 -0
  257. package/motion/crowd-figure.js +100 -0
  258. package/motion/crowd-herd.js +86 -0
  259. package/motion/crowd-hold.js +130 -0
  260. package/motion/crowd-pose.js +296 -0
  261. package/motion/crowd-poses.js +481 -0
  262. package/motion/crowd-routine.js +44 -14
  263. package/motion/crowd-town.js +166 -0
  264. package/motion/crowd-water.js +143 -0
  265. package/motion/deck-surface.js +4 -2
  266. package/motion/figure-acts.js +411 -0
  267. package/motion/figure-arms.js +437 -0
  268. package/motion/figure-blade-slide.js +149 -0
  269. package/motion/figure-body-place.js +180 -0
  270. package/motion/figure-bones.js +118 -0
  271. package/motion/figure-bow-draw.js +70 -0
  272. package/motion/figure-fingers.js +215 -0
  273. package/motion/figure-gaze.js +205 -0
  274. package/motion/figure-gestures.js +452 -0
  275. package/motion/figure-grip.js +134 -0
  276. package/motion/figure-head.js +287 -0
  277. package/motion/figure-legs.js +264 -0
  278. package/motion/figure-links.js +293 -0
  279. package/motion/figure-locomotion.js +391 -0
  280. package/motion/figure-mount-up.js +180 -0
  281. package/motion/figure-mount.js +201 -0
  282. package/motion/figure-pose-frame.js +375 -0
  283. package/motion/figure-pose-table.js +156 -0
  284. package/motion/figure-pose.js +343 -0
  285. package/motion/figure-seat.js +267 -0
  286. package/motion/figure-sway.js +125 -0
  287. package/motion/flier-corvid-pose.js +74 -0
  288. package/motion/flier-flight-air.js +122 -0
  289. package/motion/flier-flight-echelon.js +164 -0
  290. package/motion/flier-flight-roost.js +131 -0
  291. package/motion/flier-swarm-flight.js +252 -0
  292. package/motion/formation.js +193 -0
  293. package/motion/instance-sight.js +8 -1
  294. package/motion/melee-contact.js +143 -0
  295. package/motion/moorings.js +48 -0
  296. package/motion/path-steering.js +358 -0
  297. package/motion/player.js +7 -6
  298. package/motion/quadruped.js +109 -33
  299. package/motion/spaces.js +58 -6
  300. package/motion/speech-cadence.js +304 -0
  301. package/motion/vessel-motion.js +57 -0
  302. package/motion/walk-grid.js +235 -0
  303. package/motion/weather.js +70 -12
  304. package/motion/wind.js +27 -1
  305. package/package.json +27 -4
  306. package/rendering/alpha-mips.js +340 -0
  307. package/rendering/animal-camel-figure.js +29 -0
  308. package/rendering/animal-canine-figure.js +59 -0
  309. package/rendering/animal-cattle-figure.js +36 -0
  310. package/rendering/animal-horse-figure.js +49 -0
  311. package/rendering/atmosphere.js +86 -0
  312. package/rendering/camera-track.js +156 -0
  313. package/rendering/{road-surface.js → cart-track.js} +40 -11
  314. package/rendering/caster-motion.js +2 -1
  315. package/rendering/cell-lod-options.js +46 -0
  316. package/rendering/cell-lod.js +665 -80
  317. package/rendering/cloth-material.js +140 -0
  318. package/rendering/cloud-dome.js +2 -2
  319. package/rendering/compilation-schedule.js +18 -10
  320. package/rendering/contact-shadows.js +5 -2
  321. package/rendering/context.js +47 -8
  322. package/rendering/crowd-batches.js +420 -0
  323. package/rendering/crowd-herd.js +198 -0
  324. package/rendering/crowd-rig.js +132 -0
  325. package/rendering/crowd-skinning.js +52 -9
  326. package/rendering/crowd-update.js +419 -0
  327. package/rendering/crowd-visibility.js +107 -0
  328. package/rendering/day-cycle-defaults.js +200 -0
  329. package/rendering/day-cycle.js +487 -0
  330. package/rendering/daylight.js +1 -3
  331. package/rendering/detail-range.js +6 -5
  332. package/rendering/dof.js +11 -4
  333. package/rendering/effects-frame.js +149 -0
  334. package/rendering/effects-water-rises.js +221 -0
  335. package/rendering/energy-stream.js +128 -0
  336. package/rendering/facade-glass-material.js +105 -0
  337. package/rendering/far-shadow.js +81 -54
  338. package/rendering/field-surface.js +138 -0
  339. package/rendering/figure-shield.js +105 -0
  340. package/rendering/figure-skeleton.js +329 -0
  341. package/rendering/fire-light-watch.js +197 -0
  342. package/rendering/fire-pools.js +148 -0
  343. package/rendering/flame-sources.js +86 -0
  344. package/rendering/flier-bird-looks.js +97 -0
  345. package/rendering/flier-corvid-figure.js +67 -0
  346. package/rendering/flier-long-body-company.js +169 -0
  347. package/rendering/flier-swarm.js +186 -0
  348. package/rendering/flocks.js +6 -2
  349. package/rendering/garment-material.js +145 -49
  350. package/rendering/glsl-literal.js +19 -0
  351. package/rendering/ground-marks.js +316 -0
  352. package/rendering/hair-strands.js +38 -24
  353. package/rendering/height-haze.js +80 -33
  354. package/rendering/height-probe.js +15 -3
  355. package/rendering/house-kit-meshes.js +124 -0
  356. package/rendering/interior-bake.js +807 -0
  357. package/rendering/label-layout.js +13 -3
  358. package/rendering/label-range.js +5 -2
  359. package/rendering/lamp-light-map.js +159 -0
  360. package/rendering/lamp-maps.js +62 -0
  361. package/rendering/lamp-wash.js +51 -0
  362. package/rendering/light-budget.js +19 -3
  363. package/rendering/light-points.js +21 -5
  364. package/rendering/local-lights.js +27 -7
  365. package/rendering/material-lod.js +5 -6
  366. package/rendering/memory-estimate.js +84 -0
  367. package/rendering/moored-fleet.js +186 -0
  368. package/rendering/part-costs.js +104 -0
  369. package/rendering/particle-bursts.js +386 -0
  370. package/rendering/particle-emitters.js +61 -25
  371. package/rendering/particle-light-bursts.js +189 -0
  372. package/rendering/particles.js +134 -34
  373. package/rendering/pen-flocks.js +118 -0
  374. package/rendering/piece-batch.js +282 -6
  375. package/rendering/planar-reflection-options.js +159 -0
  376. package/rendering/planar-reflection.js +780 -77
  377. package/rendering/plant-cells.js +122 -0
  378. package/rendering/plant-reeds.js +113 -0
  379. package/rendering/plant-shade-trees.js +239 -0
  380. package/rendering/plant-tuft-patch.js +122 -0
  381. package/rendering/post-shaders.js +84 -21
  382. package/rendering/post.js +39 -19
  383. package/rendering/pressed-cover.js +135 -0
  384. package/rendering/prop-dig.js +136 -0
  385. package/rendering/room-light.js +250 -0
  386. package/rendering/room-materials.js +78 -0
  387. package/rendering/room-space.js +111 -0
  388. package/rendering/scene-lights.js +106 -0
  389. package/rendering/sea-shaders.js +83 -26
  390. package/rendering/settlement-approach.js +226 -0
  391. package/rendering/settlement-dissolve.js +89 -0
  392. package/rendering/settlement-quarter-warm.js +55 -0
  393. package/rendering/settlement-quarter.js +477 -0
  394. package/rendering/settlement-switch.js +42 -0
  395. package/rendering/settlement-town.js +110 -0
  396. package/rendering/shader-warmup.js +80 -36
  397. package/rendering/shadow-depth.js +40 -18
  398. package/rendering/ship-meshes.js +150 -0
  399. package/rendering/shot-cuts.js +68 -0
  400. package/rendering/sky-occlusion.js +42 -15
  401. package/rendering/sky-pmrem.js +216 -0
  402. package/rendering/sky.js +112 -50
  403. package/rendering/smoke-shadows.js +201 -0
  404. package/rendering/stage-framing.js +182 -0
  405. package/rendering/stage-lights.js +46 -39
  406. package/rendering/stain-material.js +74 -0
  407. package/rendering/static-point-shadow.js +62 -23
  408. package/rendering/still-casters.js +77 -27
  409. package/rendering/strata-material.js +2 -2
  410. package/rendering/street-lamps.js +166 -0
  411. package/rendering/sunbeam-motes.js +670 -0
  412. package/rendering/surface-light.js +65 -6
  413. package/rendering/surface-material.js +306 -0
  414. package/rendering/surface-projection.js +32 -0
  415. package/rendering/surface-snippets.js +314 -0
  416. package/rendering/taa.js +49 -18
  417. package/rendering/tree-impostor.js +929 -0
  418. package/rendering/vehicle-train.js +92 -0
  419. package/rendering/viewport.js +67 -4
  420. package/rendering/water-material.js +270 -82
  421. package/rendering/waypoint-beacons.js +191 -0
  422. package/rendering/world-matrices.js +0 -2
  423. package/ruff.toml +20 -0
  424. package/runtime/cue-cursor.js +21 -0
  425. package/runtime/device-quality.js +13 -2
  426. package/runtime/device.js +73 -0
  427. package/runtime/diagnostic-log.js +11 -3
  428. package/runtime/effect-sites.js +85 -0
  429. package/runtime/figure-orders.js +59 -0
  430. package/runtime/first-use.js +8 -5
  431. package/runtime/foley-script.js +124 -0
  432. package/runtime/foley-strides.js +333 -0
  433. package/runtime/frame-pacing.js +18 -4
  434. package/runtime/frame-yield.js +18 -0
  435. package/runtime/gpu-timing.js +8 -4
  436. package/runtime/grid-cache.js +16 -6
  437. package/runtime/grid-rows.js +5 -5
  438. package/runtime/hand-over.js +7 -2
  439. package/runtime/land-bake.js +78 -0
  440. package/runtime/lazy-sets.js +105 -0
  441. package/runtime/pool.js +17 -3
  442. package/runtime/quality-fit.js +59 -27
  443. package/runtime/region-pass-lay.js +40 -0
  444. package/runtime/region-pass.js +78 -0
  445. package/runtime/search.js +6 -2
  446. package/runtime/settlement-reach.js +42 -0
  447. package/runtime/sound-calls.js +113 -0
  448. package/runtime/sound-impacts.js +297 -0
  449. package/runtime/sound-voices.js +194 -0
  450. package/runtime/soundscape.js +282 -0
  451. package/runtime/spatial-audio.js +69 -20
  452. package/runtime/steady-frames.js +221 -0
  453. package/runtime/withdrawable-task.js +19 -8
  454. package/scripts/app-parts.mjs +118 -0
  455. package/scripts/bake-revisions.mjs +81 -0
  456. package/scripts/browser-scripts.mjs +64 -0
  457. package/scripts/bundle.mjs +192 -0
  458. package/scripts/check-app.sh +26 -0
  459. package/scripts/eslint-config.mjs +119 -0
  460. package/scripts/format.sh +92 -0
  461. package/scripts/keep-builds.mjs +158 -0
  462. package/scripts/layers.mjs +112 -0
  463. package/scripts/lint.sh +49 -0
  464. package/scripts/module-graph.mjs +123 -0
  465. package/scripts/pre-commit.sh +38 -0
  466. package/scripts/serve.py +5 -3
  467. package/scripts/site.mjs +358 -0
  468. package/scripts/test-runner.sh +42 -0
  469. package/scripts/vendor.mjs +221 -0
  470. package/scripts/verify-publish.mjs +175 -0
  471. package/scripts/world.mk +59 -0
  472. package/tools/README.md +73 -0
  473. package/tools/contact-sheet.cjs +137 -0
  474. package/tools/cpu-profile.cjs +275 -0
  475. package/tools/cpu-profile.test.cjs +98 -0
  476. package/tools/first-draws.cjs +395 -0
  477. package/tools/flight-guard.cjs +482 -0
  478. package/tools/flight-guard.test.cjs +153 -0
  479. package/tools/flight-profile.cjs +145 -0
  480. package/tools/frame-bench.cjs +336 -0
  481. package/tools/frame-parts.cjs +365 -0
  482. package/tools/ios-sim.sh +145 -0
  483. package/tools/load-audit.cjs +201 -0
  484. package/tools/look-compare.cjs +304 -0
  485. package/tools/look-guard.cjs +407 -0
  486. package/tools/look-guard.test.cjs +93 -0
  487. package/tools/look-stats.cjs +185 -0
  488. package/tools/look-stats.test.cjs +71 -0
  489. package/tools/memory-audit.cjs +323 -0
  490. package/tools/page-driver.cjs +320 -0
  491. package/tools/page-driver.test.cjs +219 -0
  492. package/tools/program-census-report.cjs +191 -0
  493. package/tools/program-census.cjs +465 -0
  494. package/tools/program-census.test.cjs +332 -0
  495. package/tools/remote-runner.sh +265 -0
  496. package/tools/runners.test.cjs +59 -0
  497. package/tools/scene-audit-beat.cjs +344 -0
  498. package/tools/scene-audit-sheet.cjs +282 -0
  499. package/tools/scene-audit.cjs +471 -0
  500. package/tools/scene-audit.test.cjs +201 -0
  501. package/tools/scene-batch.cjs +219 -0
  502. package/tools/scene-bench.cjs +149 -0
  503. package/tools/scene-bench.test.cjs +33 -0
  504. package/tools/scene-run.cjs +443 -0
  505. package/tools/scene-run.test.cjs +94 -0
  506. package/tools/servers.sh +59 -0
  507. package/tools/shader-arrival.cjs +316 -0
  508. package/tools/shader-renewal.cjs +53 -0
  509. package/tools/shader-renewal.test.cjs +115 -0
  510. package/tools/speed-guard.cjs +258 -0
  511. package/tools/stills.cjs +492 -0
  512. package/tools/stills.test.cjs +49 -0
  513. package/tools/turns.sh +7 -0
  514. package/tools/yaml.cjs +158 -0
  515. package/examples/viaduct.css +0 -75
  516. package/rendering/light-shafts.js +0 -131
@@ -0,0 +1,192 @@
1
+ // What some houses of a house kit carry beside the common run, and the clutter of streets a kit builds near the viewer like a
2
+ // house. A spec names one (`build: 'washing'`, `extra: 'belvedere'`) rather than handing over a function, so that a worker
3
+ // can build such a house too. Worker-safe.
4
+ import { dim } from '../math/color.js';
5
+ import { pickR } from '../math/random.js';
6
+ import { lerp } from '../math/scalar.js';
7
+ import { C, TRS, stick } from './primitives.js';
8
+ import { facePut } from './house-kit-frame.js';
9
+
10
+ /**
11
+ * The house kit's built-in builds and extras, bound to its shapes, frame and palette.
12
+ * @param {object} o
13
+ * @param {object} o.U - The unit shapes.
14
+ * @param {Function} o.kitPush - The kit frame's push.
15
+ * @param {Function} o.kitPop - The kit frame's pop.
16
+ * @param {object} o.palette - The house palette.
17
+ * @param {object} o.lump - A rounded lump geometry (`KIT_LUMP`).
18
+ * @param {Function} o.kitBarrel - The kit's barrel (`createHouseKitOpenings`).
19
+ * @returns {{builds: object, extras: object, propWashing: Function}} `builds`, by name, each called as (kit, random, spec) in
20
+ * place of a house: `washing`, a line across a lane between two upper windows with things drying on it, from (ax, ay, az) to
21
+ * (bx, by, bz) of the spec's origin; `laneBeam`, a timber bracing two houses across a tight lane, between the same ends.
22
+ * `extras`, by name, each called as (kit, house, spec) once its house is built: `belvedere`, a railed lookout astride the
23
+ * ridge, sometimes a pigeon loft; `butt`, a water butt and downpipe at a front corner; `stalls`, roofed stalls against a
24
+ * stable's front (the spec's `stalls`: { aisle, depth, bays }, metres and a count). `propWashing` is the washing line alone.
25
+ */
26
+ export function createHouseKitExtras({ U, kitPush, kitPop, palette, lump, kitBarrel }) {
27
+ const { black: BLACK, cloths: CLOTHS, hemp: HEMP } = palette,
28
+ KBLOB = lump;
29
+ function kitBelvedere(B, K, s) {
30
+ // a timber lookout platform astride the ridge, railed, sometimes with a pigeon loft on it
31
+ const R = K.R,
32
+ turn = s.turn,
33
+ span = turn ? s.d : s.w,
34
+ len = turn ? s.w : s.d,
35
+ rise = s.rise,
36
+ half = span / 2;
37
+ if (len < 4.6 || span < 4.4 || rise < 1.8) return;
38
+ const u0 = (R() < 0.5 ? -1 : 1) * len * 0.18,
39
+ ry = turn ? 0 : Math.PI / 2,
40
+ dy = s.h + rise + 0.4,
41
+ tim = K.tim,
42
+ rail = dim(tim, 1.25);
43
+ kitPush(0, 0, 0, ry); // local x now runs along the ridge
44
+ for (const a of [-0.95, 0.95])
45
+ for (const q of [-0.85, 0.85]) {
46
+ const yr = s.h + rise * (1 - Math.abs(q) / half) - 0.1;
47
+ B.wood.box(u0 + a, yr, q, 0.14, dy - yr + 0.05, 0.14, tim);
48
+ }
49
+ B.wood.box(u0, dy, 0, 2.3, 0.1, 2.1, dim(tim, 1.1));
50
+ for (let k = -2; k <= 2; k++) B.trim.box(u0 + k * 0.45, dy + 0.1, 0, 0.04, 0.012, 2.1, dim(tim, 0.7));
51
+ if (R() < 0.5) {
52
+ // a pigeon loft: a slatted box with a landing board and its birds
53
+ B.wood.box(u0, dy + 0.1, -0.35, 1.9, 1.05, 1.1, C(0x6a5a44, 0.15, R));
54
+ B.roof.add(U.prism, dim(s.rc, 0.9), TRS(u0, dy + 1.15, -0.35, 2.2, 0.45, 1.3, 0));
55
+ for (let k = 0; k < 4; k++) B.glass.box(u0 - 0.66 + k * 0.44, dy + 0.55, 0.205, 0.22, 0.2, 0.02, BLACK);
56
+ B.wood.box(u0, dy + 0.42, 0.42, 1.9, 0.04, 0.42, dim(tim, 1.2));
57
+ for (let k = 0, n = 2 + ((R() * 4) | 0); k < n; k++) {
58
+ const px = u0 + (R() - 0.5) * 1.7,
59
+ pz = 0.3 + R() * 0.25,
60
+ py = k % 2 ? dy + 0.46 : dy + 1.25,
61
+ c = C(pickR(R, [0x8a8c90, 0x6c6e74, 0xa8a49c, 0x5a5650]), 0.1, R);
62
+ B.cloth.add(U.sph, c, TRS(px, py + 0.09, pz, 0.15, 0.14, 0.22, R() * 6));
63
+ B.cloth.add(U.sph, c, TRS(px, py + 0.2, pz + 0.07, 0.08, 0.08, 0.08));
64
+ }
65
+ } else {
66
+ for (const q of [-1, 1]) {
67
+ B.wood.box(u0, dy + 0.85, q * 1.02, 2.3, 0.07, 0.07, rail);
68
+ for (let k = -2; k <= 2; k++) B.wood.box(u0 + k * 0.55, dy + 0.1, q * 1.02, 0.05, 0.78, 0.05, rail);
69
+ }
70
+ B.wood.box(u0 + 1.12, dy + 0.85, 0, 0.07, 0.07, 2.1, rail);
71
+ if (R() < 0.6) {
72
+ B.cloth.add(U.taper, [0.3, 0.13, 0.07], TRS(u0 - 0.7, dy + 0.1, 0.6, 0.34, 0.32, 0.34, 0, Math.PI));
73
+ B.cloth.add(KBLOB, [0.08, 0.16, 0.05], TRS(u0 - 0.7, dy + 0.5, 0.6, 0.5, 0.45, 0.5));
74
+ }
75
+ }
76
+ kitPop();
77
+ }
78
+ function kitButt(B, K, s) {
79
+ // a water butt at a front corner, fed by a downpipe
80
+ const R = K.R,
81
+ sg = R() < 0.5 ? -1 : 1,
82
+ put = facePut(0, s.w / 2, s.d / 2);
83
+ kitBarrel(B, put, sg * (s.w / 2 - 0.45), 0.42, 1.05, R);
84
+ put(B.cloth, U.cyl6, [0.08, 0.07, 0.06], sg * (s.w / 2 - 0.12), 0.95, 0.12, 0.1, s.h - 0.5, 0.1);
85
+ put(B.wood, U.box, C(0x5a4632, 0.15, R), sg * (s.w / 2 - 0.45), 0.92, 0.42, 0.62, 0.04, 0.62);
86
+ }
87
+ function propWashing(B, R, s) {
88
+ // a line across a lane between two upper windows, things drying on it; its ends are given from the spec's origin
89
+ const n = 6,
90
+ L = Math.hypot(s.bx - s.ax, s.bz - s.az),
91
+ sag = 0.25 + L * 0.06,
92
+ ry = Math.atan2(-(s.bz - s.az), s.bx - s.ax),
93
+ pts = [];
94
+ for (let k = 0; k <= n; k++) {
95
+ const t = k / n;
96
+ pts.push([lerp(s.ax, s.bx, t), lerp(s.ay, s.by, t) - sag * 4 * t * (1 - t), lerp(s.az, s.bz, t)]);
97
+ }
98
+ for (let k = 0; k < n; k++) stick(B.trim, pts[k], pts[k + 1], 0.018, HEMP, U.box);
99
+ for (const p of [pts[0], pts[n]]) B.cloth.box(p[0], p[1] - 0.06, p[2], 0.1, 0.12, 0.1, [0.05, 0.05, 0.05]);
100
+ for (let t = 0.12 + R() * 0.1; t < 0.9; t += 0.1 + R() * 0.14) {
101
+ const k = Math.min(n - 1, Math.floor(t * n)),
102
+ f = t * n - k,
103
+ a = pts[k],
104
+ b = pts[k + 1],
105
+ x = lerp(a[0], b[0], f),
106
+ y = lerp(a[1], b[1], f),
107
+ z = lerp(a[2], b[2], f),
108
+ w = 0.35 + R() * 0.45,
109
+ h = 0.4 + R() * 0.6;
110
+ B.cloth.add(U.box, C(pickR(R, CLOTHS), 0.15, R), TRS(x, y - h, z, w, h, 0.025, ry, (R() - 0.5) * 0.25, (R() - 0.5) * 0.12));
111
+ }
112
+ }
113
+ // A timber that braces two houses facing each other across a tight lane: the beam let into both walls, a strut under each end,
114
+ // and now and then something hung from it. Its ends are given from the spec's origin, as the washing line's are.
115
+ const LANE_BEAM = { thick: 0.2, inWall: 0.18, strut: 0.75, hung: 0.3 }; // the beam's section, how far it enters a wall, a strut's reach, how often something hangs
116
+ function propLaneBeam(B, R, s) {
117
+ const a = [s.ax, s.ay, s.az],
118
+ b = [s.bx, s.by, s.bz],
119
+ span = Math.hypot(b[0] - a[0], b[2] - a[2]),
120
+ ux = (b[0] - a[0]) / span,
121
+ uz = (b[2] - a[2]) / span,
122
+ oak = C(pickR(R, [0x3a2c20, 0x44332a, 0x2f251c]), 0.12, R),
123
+ { thick, inWall, strut } = LANE_BEAM;
124
+ stick(B.wood, [a[0] - ux * inWall, a[1], a[2] - uz * inWall], [b[0] + ux * inWall, b[1], b[2] + uz * inWall], thick, oak, U.box);
125
+ for (const [end, way] of [
126
+ [a, 1],
127
+ [b, -1],
128
+ ])
129
+ stick(
130
+ B.wood,
131
+ [end[0], end[1] - strut, end[2]],
132
+ [end[0] + way * ux * strut, end[1] - thick * 0.5, end[2] + way * uz * strut],
133
+ thick * 0.7,
134
+ oak,
135
+ U.box,
136
+ );
137
+ if (R() < LANE_BEAM.hung) {
138
+ // a bundle of herbs or a string of onions on a cord, off the middle
139
+ const t = 0.3 + R() * 0.4,
140
+ x = lerp(a[0], b[0], t),
141
+ z = lerp(a[2], b[2], t),
142
+ drop = 0.45 + R() * 0.3;
143
+ stick(B.trim, [x, a[1] - thick * 0.5, z], [x, a[1] - drop, z], 0.012, HEMP, U.box);
144
+ B.cloth.add(U.sph, C(pickR(R, [0x7a6a3a, 0x8a5a34, 0x5d6a3a]), 0.15, R), TRS(x, a[1] - drop - 0.14, z, 0.13, 0.2, 0.13));
145
+ }
146
+ }
147
+ // Roofed stalls against the front of a stable, with an aisle left clear to its door.
148
+ // Each stall opens onto the yard and is divided from its neighbour by kicking boards.
149
+ function kitStalls(kit, house, s) {
150
+ const { aisle, depth, bays } = s.stalls,
151
+ wall = s.d / 2,
152
+ width = (s.w - aisle) / 2,
153
+ bay = width / bays,
154
+ back = s.h - 0.22,
155
+ eave = back - 0.45,
156
+ pitch = Math.atan2(back - eave, depth),
157
+ timber = C(0x756048),
158
+ face = wall + depth;
159
+ for (const side of [-1, 1]) {
160
+ const centre = side * (aisle / 2 + width / 2);
161
+ kit.wood.box(centre, eave, face, width + 0.25, 0.18, 0.22, dim(timber, 0.87));
162
+ for (let i = 0; i <= bays; i++) {
163
+ const x = side * (aisle / 2 + i * bay);
164
+ kit.wood.add(U.cyl6, timber, TRS(x, 0, face, 0.19, eave + 0.04, 0.19));
165
+ stick(kit.wood, [x, back, wall], [x, eave + 0.12, face + 0.2], 0.08, timber, U.box);
166
+ for (let k = 0; k < 4; k++)
167
+ kit.wood.box(x, 0.35 + 0.21 * k, wall + depth / 2, 0.075, 0.18, depth, dim(timber, 0.87 + 0.16 * house.R()));
168
+ }
169
+ const boards = Math.ceil(width / 0.32);
170
+ for (let k = 0; k < boards; k++) {
171
+ const x = centre - width / 2 + ((k + 0.5) * width) / boards;
172
+ kit.wood.box(
173
+ x,
174
+ (back + eave) / 2 + 0.14,
175
+ wall + depth / 2,
176
+ width / boards,
177
+ 0.08,
178
+ depth + 0.45 + house.R() * 0.1,
179
+ C(0x86715a, 0.09, house.R),
180
+ 0,
181
+ pitch,
182
+ );
183
+ }
184
+ }
185
+ }
186
+
187
+ return {
188
+ builds: { washing: propWashing, laneBeam: propLaneBeam },
189
+ extras: { belvedere: kitBelvedere, butt: kitButt, stalls: kitStalls },
190
+ propWashing,
191
+ };
192
+ }
@@ -0,0 +1,298 @@
1
+ // The forms of a house kit's buildings: the gabled house, the hipped and corniced bodies, the flat-roofed house, the round
2
+ // and square towers, the domed building and the ruin. Worker-safe.
3
+ import { dim } from '../math/color.js';
4
+ import { pickR } from '../math/random.js';
5
+ import { clamp, TAU } from '../math/scalar.js';
6
+ import { C, TRS } from './primitives.js';
7
+ import { facePut } from './house-kit-frame.js';
8
+ import { kitSoot } from './house-kit-marks.js';
9
+
10
+ /**
11
+ * The house kit's built-in forms, bound to its parts. Each is called as form(kit, house, spec, bodyOptions), where `house`
12
+ * holds the house's values (its random stream `R`, its style `st`, its colours) and `spec` is the house's spec.
13
+ * @param {object} o
14
+ * @param {object} o.U - The unit shapes.
15
+ * @param {Function} o.kitPush - The kit frame's push.
16
+ * @param {Function} o.kitPop - The kit frame's pop.
17
+ * @param {object} o.palette - The house palette.
18
+ * @param {object} o.openings - The kit's openings (`createHouseKitOpenings`).
19
+ * @param {object} o.roofs - The kit's roofs (`createHouseKitRoofs`).
20
+ * @param {Function} o.kitBody - The kit's body (`createHouseKitBody`).
21
+ * @returns {object} The forms by name: `gable` (the default: a body under a pitched roof, its ridge across the front unless
22
+ * `turn`; a style's `yardClutter` stacks logs and a barrel by it), `hip` (a pyramid roof and two chimneys), `body` (a corniced
23
+ * body, its roof left to the caller), `flat` (a parapet, and a roof room with washing unless the style's roof is `bareRoof`),
24
+ * `round` (a round stone tower), `tower` (a square tower with a corbelled parapet), `dome` (a domed building) and `ruin`
25
+ * (broken walls, fallen beams and rubble: genHouse builds it for any spec whose `ruin` is under 1).
26
+ */
27
+ export function createHouseKitForms({ U, kitPush, kitPop, palette, openings, roofs, kitBody }) {
28
+ const { windowLight: WARM, black: BLACK, cloths: CLOTHS } = palette,
29
+ { kitBarrel, kitDoor, kitWindow } = openings,
30
+ { kitChimney, kitFinial, kitGable } = roofs;
31
+ // A round tower of stone: storeys marked by bands, windows staggered round it, a door at the foot and a conical roof.
32
+ function kitRound(kit, house, s) {
33
+ const { R: rand } = house,
34
+ r = s.w * 0.36,
35
+ h = s.h + 5,
36
+ n = Math.max(2, Math.round(h / 3.3)),
37
+ sh = h / n,
38
+ ap = r * Math.cos(Math.PI / 16),
39
+ sc = dim(s.col, 0.86);
40
+ kit.stone.add(U.cyl16, house.plinth, TRS(0, -2.4, 0, r * 2 + 0.3, 3.1, r * 2 + 0.3));
41
+ kit.stone.add(U.cyl16, sc, TRS(0, 0, 0, r * 2, h, r * 2));
42
+ for (let i = 1; i < n; i++) kit.stone.add(U.cyl16, house.trim, TRS(0, i * sh - 0.1, 0, r * 2 + 0.16, 0.2, r * 2 + 0.16));
43
+ kit.stone.add(U.cyl16, house.trim, TRS(0, h - 0.5, 0, r * 2 + 0.5, 0.5, r * 2 + 0.5));
44
+ const f0 = (rand() * 16) | 0;
45
+ for (let i = 0; i < n; i++)
46
+ for (let q = 0; q < 4; q++) {
47
+ kitPush(0, 0, 0, ((((f0 + q * 4 + (i % 2) * 2) % 16) + 0.5) * TAU) / 16);
48
+ const put = facePut(0, 0, ap);
49
+ if (i === 0 && q === 0) kitDoor(kit, house, put, 0, { w: 0.85 });
50
+ else if (i > 0 || rand() < 0.5)
51
+ kitWindow(kit, put, 0, i * sh + 1.0, Math.min(0.62, r * 0.3), Math.min(1.3, sh - 1.6), {
52
+ frame: house.frame,
53
+ lit: rand() < house.litP ? WARM[(rand() * 3) | 0] : null,
54
+ sill: house.trim,
55
+ lintel: house.trim,
56
+ });
57
+ kitPop();
58
+ }
59
+ kit.wood.add(U.cyl16, house.tim, TRS(0, h, 0, r * 2 + 1.1, 0.12, r * 2 + 1.1));
60
+ kit.roof.add(U.cone16, s.rc, TRS(0, h + 0.12, 0, r * 2 + 1.1, s.rise, r * 2 + 1.1));
61
+ kitFinial(kit, h + s.rise);
62
+ }
63
+ // A ruin: a plinth, four broken walls whose tops step down course by course, fallen beams and rubble round it.
64
+ function kitRuin(kit, house, s) {
65
+ const { R: rand } = house,
66
+ w = s.w,
67
+ d = s.d,
68
+ h = s.h,
69
+ th = 0.55,
70
+ sc = s.col;
71
+ kit.stone.box(0, -1.7, 0, w + 0.2, 1.85, d + 0.2, house.plinth);
72
+ for (let f = 0; f < 4; f++) {
73
+ const fw = f < 2 ? w : d - th * 2,
74
+ ns = Math.max(2, Math.round(fw / 2.2)),
75
+ sw = fw / ns,
76
+ put = facePut(f, w / 2 - th, d / 2 - th);
77
+ for (let k = 0; k < ns; k++) {
78
+ // a broken wall gives way course by course: sound to some height, then stepping back toward one end, so its top rakes down in steps
79
+ const hh = h * (0.35 + 0.65 * rand()) * (rand() < 0.15 ? 0.25 : 1),
80
+ u = (k + 0.5 - ns / 2) * sw,
81
+ c = dim(sc, 0.82 + rand() * 0.36),
82
+ W0 = sw + 0.02;
83
+ const hb = hh * (0.5 + 0.2 * rand()),
84
+ side = (k + f) % 2 ? 1 : -1,
85
+ cut = 0.45 + 0.45 * rand(),
86
+ nC = Math.max(1, Math.round((hh - hb) / 0.38)),
87
+ ch = (hh - hb) / nC;
88
+ put(kit.stone, U.box, c, u, 0, th / 2, W0, hb, th);
89
+ for (let j = 0; j < nC; j++) {
90
+ const ww = clamp(W0 * (1 - (cut * (j + 1)) / nC) + (rand() - 0.5) * 0.35, 0.3, W0);
91
+ put(
92
+ kit.stone,
93
+ U.box,
94
+ dim(c, 0.92 + rand() * 0.14),
95
+ u - (side * (W0 - ww)) / 2,
96
+ hb + j * ch,
97
+ th / 2 + (rand() - 0.5) * 0.05,
98
+ ww,
99
+ ch + 0.01,
100
+ th,
101
+ );
102
+ }
103
+ if (hb > 2.9 && rand() < 0.65) {
104
+ const wh = Math.min(1.3, hb - 1.75);
105
+ put(kit.cloth, U.quad, BLACK, u, 1.0, th + 0.02, 0.8, wh, 1);
106
+ put(kit.stone, U.boxF, dim(c, 1.2), u, 0.86, th + 0.06, 1.1, 0.12, 0.14);
107
+ kitSoot(kit, put, u, 1.0 + wh, 1.3, Math.min(1.8, hb - 1.0 - wh + 0.4), u * 0.37 + f * 0.21 + hh * 0.13, th);
108
+ }
109
+ if (rand() < 0.35) put(kit.stone, U.rock, c, u + side * W0 * 0.28, hb - 0.25, th / 2, 0.8, 0.55, th * 1.4);
110
+ }
111
+ }
112
+ const nb = 2 + ((rand() * 3) | 0);
113
+ for (let q = 0; q < nb; q++)
114
+ kit.wood.add(
115
+ U.box,
116
+ C(0x1c1714, 0.25, rand),
117
+ TRS(
118
+ (rand() - 0.5) * w * 0.6,
119
+ 0.15,
120
+ (rand() - 0.5) * d * 0.6,
121
+ 0.22,
122
+ 2.4 + rand() * Math.min(w, d) * 0.6,
123
+ 0.22,
124
+ rand() * 6,
125
+ 0.5 + rand() * 0.9,
126
+ (rand() - 0.5) * 0.8,
127
+ ),
128
+ );
129
+ for (let q = 0; q < 6; q++)
130
+ kit.stone.add(
131
+ U.rock,
132
+ dim(sc, 0.8 + rand() * 0.4),
133
+ TRS(
134
+ (rand() - 0.5) * (w + 2.5),
135
+ -0.2,
136
+ (rand() - 0.5) * (d + 2.5),
137
+ 0.6 + rand() * 1.3,
138
+ 0.4 + rand() * 0.8,
139
+ 0.6 + rand() * 1.3,
140
+ rand() * 6,
141
+ rand(),
142
+ rand(),
143
+ ),
144
+ );
145
+ }
146
+ // A square tower: a plain body, a corbelled parapet, a pyramid roof and its finial.
147
+ function kitTower(kit, house, s) {
148
+ const { w, d, h } = s;
149
+ const tw = w * 0.8,
150
+ td = d * 0.8,
151
+ th = h + 3;
152
+ kitBody(kit, house, tw, td, th, { plain: true, sideSkip: 0.15, n: s.n, party: s.party, found: s.found });
153
+ kit.stone.box(0, th - 0.8, 0, tw + 0.44, 0.8, td + 0.44, house.trim);
154
+ const nk = Math.max(3, Math.round(tw / 0.9));
155
+ for (let k = 0; k <= nk; k++)
156
+ for (const sg of [-1, 1]) {
157
+ kit.stone.box((k / nk - 0.5) * tw, th - 1.15, sg * (td / 2 + 0.1), 0.24, 0.36, 0.3, house.trim);
158
+ kit.stone.box(sg * (tw / 2 + 0.1), th - 1.15, (k / nk - 0.5) * td, 0.3, 0.36, 0.24, house.trim);
159
+ }
160
+ kit.wood.box(0, th, 0, tw + 1.2, 0.12, td + 1.2, house.tim);
161
+ kit.roof.add(U.pyr, s.rc, TRS(0, th + 0.12, 0, tw + 1.2, s.rise, td + 1.2));
162
+ kitFinial(kit, th + s.rise);
163
+ }
164
+
165
+ // A domed building: a plain body, a drum with windows, the dome and its finial.
166
+ function kitDomed(kit, house, s) {
167
+ const { R: rand } = house;
168
+ const { w, d, h } = s;
169
+ kitBody(kit, house, w, d, h, { plain: true, party: s.party, found: s.found });
170
+ const m = Math.min(w, d) * 0.92;
171
+ kit.stone.box(0, h - 0.05, 0, w + 0.4, 0.3, d + 0.4, house.trim);
172
+ kit.wall.box(0, h + 0.25, 0, w - 0.3, 0.4, d - 0.3, s.col);
173
+ kit.stone.add(U.cyl16, house.trim, TRS(0, h + 0.6, 0, m * 0.98, 1.0, m * 0.98));
174
+ for (let q = 0; q < 8; q++) {
175
+ kitPush(0, 0, 0, ((q * 2 + 0.5) * TAU) / 16);
176
+ facePut(0, 0, m * 0.49 * Math.cos(Math.PI / 16))(
177
+ kit.glass,
178
+ U.quad,
179
+ rand() < house.litP ? WARM[0] : BLACK,
180
+ 0,
181
+ h + 0.8,
182
+ 0.03,
183
+ m * 0.1,
184
+ 0.6,
185
+ 1,
186
+ );
187
+ kitPop();
188
+ }
189
+ kit.stone.add(U.cyl16, house.trim, TRS(0, h + 1.6, 0, m * 1.04, 0.14, m * 1.04));
190
+ kit.cloth.add(U.dome16, s.rc, TRS(0, h + 1.74, 0, m, m, m));
191
+ kitFinial(kit, h + 1.7 + m / 2, 1.2);
192
+ }
193
+
194
+ // A body with a cornice, and for form hip (`roofed`) a pyramid roof with two chimneys.
195
+ function kitHipped(kit, house, s, opts, roofed) {
196
+ const { w, d, h } = s;
197
+ const b = kitBody(kit, house, w, d, h, opts);
198
+ kit.stone.box(0, h - 0.1, 0, b.hw * 2 + 0.5, 0.34, b.hd * 2 + 0.5, house.trim);
199
+ if (roofed) {
200
+ kit.roof.add(U.pyr, s.rc, TRS(0, h + 0.24, 0, b.hw * 2 + 1.1, s.rise, b.hd * 2 + 1.1));
201
+ for (const sg of [-1, 1]) kitChimney(kit, house, sg * w * 0.28, 0, h + s.rise * 0.3, h + s.rise * 0.72 + 1.0);
202
+ }
203
+ }
204
+
205
+ // A flat-roofed house: a parapet round the roof and, unless its style's roof is bare (a ruin's), a room on the roof, washing on a line and pots.
206
+ function kitFlatRoofed(kit, house, s, opts) {
207
+ const { R: rand, st } = house;
208
+ const { w, d, h } = s;
209
+ const b = kitBody(kit, house, w, d, h, opts),
210
+ hw = b.hw,
211
+ hd = b.hd;
212
+ for (const sg of [1, -1]) {
213
+ kit.wall.box(0, h, sg * (hd - 0.15), hw * 2, 0.8, 0.3, s.col);
214
+ kit.wall.box(sg * (hw - 0.15), h, 0, 0.3, 0.8, hd * 2 - 0.6, s.col);
215
+ kit.stone.box(0, h + 0.8, sg * (hd - 0.15), hw * 2 + 0.1, 0.1, 0.42, house.trim);
216
+ kit.stone.box(sg * (hw - 0.15), h + 0.8, 0, 0.42, 0.1, hd * 2 + 0.1, house.trim);
217
+ }
218
+ if (!st.bareRoof) {
219
+ const hx = (rand() < 0.5 ? -1 : 1) * hw * 0.42,
220
+ hz = (rand() < 0.5 ? -1 : 1) * hd * 0.36,
221
+ uw = hw * 0.84,
222
+ ud = hd * 0.8;
223
+ kit.wall.box(hx, h, hz, uw, 2.1, ud, s.col2 || s.col);
224
+ kit.roof.add(U.box, s.rc, TRS(hx, h + 2.1, hz, uw + 0.5, 0.12, ud + 0.5, 0, 0.1));
225
+ kitPush(hx, h, hz, hx > 0 ? -Math.PI / 2 : Math.PI / 2);
226
+ facePut(0, 0, uw / 2)(kit.wood, U.boxF, C(st.door, 0.2, rand), 0, 0, 0.03, 0.8, 1.8, 0.06);
227
+ kitPop();
228
+ const lx = -hx,
229
+ nl = 3 + ((rand() * 3) | 0);
230
+ for (const sg of [-1, 1]) kit.wood.add(U.cyl6, house.tim, TRS(lx, h, sg * hd * 0.62, 0.07, 1.95, 0.07));
231
+ kit.cloth.box(lx, h + 1.84, 0, 0.025, 0.025, hd * 1.24, [0.03, 0.03, 0.03]);
232
+ for (let q = 0; q < nl; q++) {
233
+ const ch = 0.5 + rand() * 0.5;
234
+ kit.cloth.box(
235
+ lx,
236
+ h + 1.84 - ch,
237
+ (((q + 0.5 - nl / 2) * hd * 1.0) / nl) * 1.1,
238
+ 0.03,
239
+ ch,
240
+ 0.42 + rand() * 0.2,
241
+ C(pickR(rand, CLOTHS), 0.12, rand),
242
+ );
243
+ }
244
+ for (let q = 0; q < 3; q++) {
245
+ const px = (rand() - 0.5) * hw * 1.4,
246
+ pz = -hz + (rand() - 0.5) * 1.5;
247
+ kit.cloth.add(U.taper, [0.3, 0.13, 0.07], TRS(px, h, pz, 0.36, 0.34, 0.36, 0, Math.PI));
248
+ kit.cloth.add(U.sph, [0.07, 0.17, 0.05], TRS(px, h + 0.42, pz, 0.5, 0.5, 0.5));
249
+ }
250
+ }
251
+ }
252
+
253
+ // A gabled house; one of a style with a cluttered yard (`yardClutter`) with logs stacked by its side, a barrel at the door and a stovepipe.
254
+ function kitGabled(kit, house, s, opts) {
255
+ const { R: rand, st } = house;
256
+ const { w, d, h } = s;
257
+ const b = kitBody(kit, house, w, d, h, opts),
258
+ turn = s.turn;
259
+ kitGable(kit, house, 0, h, 0, turn ? b.hw * 2 : b.hd * 2, turn ? b.hd * 2 : b.hw * 2, s.rise, turn ? 0 : Math.PI / 2, s.rc, s.col, {
260
+ full: true,
261
+ chimney: s.chim,
262
+ chimAt: s.chimAt ? (turn ? s.chimAt : [-s.chimAt[1], s.chimAt[0]]) : null,
263
+ timber: b.timber,
264
+ gmat: house.rubble && !b.timber ? kit.rubble : st.material === 'wood' ? kit.wood : kit.wall,
265
+ });
266
+ if (st.yardClutter) {
267
+ const put = facePut(2, w / 2, d / 2);
268
+ if (rand() < 0.6)
269
+ for (let q = 0; q < 9; q++)
270
+ put(
271
+ kit.wood,
272
+ U.cyl6,
273
+ C(0x6a5540, 0.2, rand),
274
+ -d * 0.2 + (q % 3) * 0.3,
275
+ 0.02 + ((q / 3) | 0) * 0.26,
276
+ 0.5,
277
+ 0.28,
278
+ 0.9,
279
+ 0.28,
280
+ 0,
281
+ Math.PI / 2,
282
+ );
283
+ if (rand() < 0.6) kitBarrel(kit, facePut(0, w / 2, d / 2), w * 0.3, 0.5, 0.9, rand);
284
+ if (!s.chim) kit.cloth.add(U.cyl6, [0.03, 0.03, 0.03], TRS(w * 0.2, h, d * 0.15, 0.16, s.rise + 0.7, 0.16));
285
+ }
286
+ }
287
+
288
+ return {
289
+ gable: kitGabled,
290
+ hip: (kit, house, s, opts) => kitHipped(kit, house, s, opts, true),
291
+ body: (kit, house, s, opts) => kitHipped(kit, house, s, opts, false),
292
+ flat: kitFlatRoofed,
293
+ round: kitRound,
294
+ tower: kitTower,
295
+ dome: kitDomed,
296
+ ruin: kitRuin,
297
+ };
298
+ }
@@ -0,0 +1,74 @@
1
+ // The house kit's builders, one per material, and the frame its parts are placed in: kitPush and kitPop move it, facePut
2
+ // places on a wall. Worker-safe: no DOM, no WebGL.
3
+ import { boxFacePlacer, createBuilderFrame } from './builder-frame.js';
4
+ import { GB } from './builder.js';
5
+ import { TRS } from './primitives.js';
6
+
7
+ /**
8
+ * The kinds of a house kit, one geometry builder and one material each, in the order every kit's arrays are given.
9
+ * `trim` is woodwork too small to cast a shadow worth drawing (window frames, shutters, door leaves); `stain` holds the
10
+ * see-through weathering decals; `rubble`, the unsquared stone of the meanest houses.
11
+ * @type {ReadonlyArray<string>}
12
+ */
13
+ export const KIT_KEYS = Object.freeze(['wall', 'stone', 'wood', 'roof', 'glass', 'cloth', 'trim', 'stain', 'rubble']);
14
+ /** A bit for each kind of {@link KIT_KEYS}, in its order: every kind wanted. */
15
+ export const EVERY_KIND = (1 << KIT_KEYS.length) - 1;
16
+ /**
17
+ * The vertex counts of each kind of a kit, in {@link KIT_KEYS}'s order: where whatever is added next will start.
18
+ * @param {object} kit - A kit made by a house kit's `kitNew`.
19
+ * @returns {number[]}
20
+ */
21
+ export const kitCounts = kit => KIT_KEYS.map(kind => kit[kind].count);
22
+ /**
23
+ * A placer on one face of a box (the engine's `boxFacePlacer`): `put(builder, shape, colour, along, height, outward, sx, sy, sz, roll, pitch)`.
24
+ * Faces are numbered +Z, -Z, +X, -X.
25
+ */
26
+ export const facePut = boxFacePlacer;
27
+
28
+ // A builder for a kind of the kit that is not wanted (a block built without its small parts): the houses are built as ever,
29
+ // drawing the same numbers from their seeds, so the other kinds come out the same, but nothing put in it is kept.
30
+ class Unkept extends GB {
31
+ add() {
32
+ return this;
33
+ }
34
+ raw() {}
35
+ take() {}
36
+ }
37
+
38
+ /**
39
+ * The frame a house kit places its parts in, and its fresh kits. Each house kit has one: the frame is shared by every kit it
40
+ * makes, so parts placed by one builder land where the builder before it moved the frame.
41
+ * @returns {{
42
+ * kitFrame: import('three').Matrix4,
43
+ * kitPush: (x: number, y: number, z: number, ry?: number, rz?: number) => void,
44
+ * kitPop: () => void,
45
+ * kitNew: (lean?: boolean, kinds?: number) => object,
46
+ * kitAt: (kit: object, x: number, y: number, z: number, ry: number, streetLit: boolean, fn: Function, random?: () => number) => void,
47
+ * }} `kitFrame`, the frame's matrix (stable, read by every builder); `kitPush`, moves it by a translation in metres and turns
48
+ * about y then z in radians, remembering the old one; `kitPop`, puts the old one back; `kitNew(lean, kinds)`, a fresh kit of
49
+ * builders, one per kind (`lean`: built for the middle distance, where a house that knows how gives its rounded and finer
50
+ * parts fewer faces; `kinds`: a bit each, {@link EVERY_KIND}'s, the others keep nothing); `kitAt(kit, x, y, z, ry, streetLit, fn, random)`,
51
+ * calls fn(kit, random) with the frame at (x, y, z) turned by ry, its glass lit by street light at height y when `streetLit`.
52
+ */
53
+ export function createKitFrame() {
54
+ const { matrix: kitFrame, push, pop: kitPop } = createBuilderFrame();
55
+ function kitNew(lean = false, kinds = EVERY_KIND) {
56
+ const kit = { lean };
57
+ for (const [i, k] of KIT_KEYS.entries()) {
58
+ const g = (kit[k] = (kinds >> i) & 1 ? new GB() : new Unkept());
59
+ g.M = kitFrame;
60
+ if (k === 'wall' || k === 'stone' || k === 'wood' || k === 'trim' || k === 'rubble') g.tg = [];
61
+ }
62
+ return kit;
63
+ }
64
+ function kitPush(x, y, z, ry = 0, rz = 0) {
65
+ push(TRS(x, y, z, 1, 1, 1, ry, 0, rz));
66
+ }
67
+ function kitAt(B, x, y, z, ry, streetLit, fn, R) {
68
+ for (const k of KIT_KEYS) B[k].tv = streetLit ? y : y - 1000;
69
+ kitPush(x, y, z, ry);
70
+ fn(B, R);
71
+ kitPop();
72
+ }
73
+ return { kitFrame, kitPush, kitPop, kitNew, kitAt };
74
+ }
@@ -0,0 +1,93 @@
1
+ // Weathering on a house kit's walls: stains run down from sills and eaves, soot above openings, wear and tilled earth on the
2
+ // ground, all as see-through decals in the kit's `stain` builder. Each decal's vertex colour is not a colour: it carries
3
+ // (across, down, pattern) for the material that draws the kit's stains. Worker-safe and stateless.
4
+
5
+ /**
6
+ * A decal: a see-through quad lying just off a surface, written into a builder as two triangles.
7
+ * @param {object} g - The builder (a kit's `stain`).
8
+ * @param {number[]} a - Lower-left corner [x, y, z], in the builder's frame.
9
+ * @param {number[]} b - Lower-right corner.
10
+ * @param {number[]} c - Upper-right corner.
11
+ * @param {number[]} d - Upper-left corner.
12
+ * @param {number[]} n - The surface's normal.
13
+ * @param {number} k - The pattern code the stain material reads (a byte as 0..1).
14
+ */
15
+ export function kitDecal(g, a, b, c, d, n, k) {
16
+ // corners: lower left, lower right, upper right, upper left
17
+ g.raw(a[0], a[1], a[2], n[0], n[1], n[2], 0, 1, k);
18
+ g.raw(b[0], b[1], b[2], n[0], n[1], n[2], 1, 1, k);
19
+ g.raw(c[0], c[1], c[2], n[0], n[1], n[2], 1, 0, k);
20
+ g.raw(a[0], a[1], a[2], n[0], n[1], n[2], 0, 1, k);
21
+ g.raw(c[0], c[1], c[2], n[0], n[1], n[2], 1, 0, k);
22
+ g.raw(d[0], d[1], d[2], n[0], n[1], n[2], 0, 0, k);
23
+ }
24
+ function wallMark(kit, put, u, w, startY, endY, out, pattern) {
25
+ kitDecal(
26
+ kit.stain,
27
+ put.point(u - w / 2, endY, out),
28
+ put.point(u + w / 2, endY, out),
29
+ put.point(u + w / 2, startY, out),
30
+ put.point(u - w / 2, startY, out),
31
+ put.normal,
32
+ pattern,
33
+ );
34
+ }
35
+ const streakSeed = seed => (((seed % 1) + 1) % 1) * 0.48;
36
+ /**
37
+ * A stain run down a wall from a ledge (a sill, an eave): runoff hangs from yTop and fades h metres below it.
38
+ * @param {object} kit - A house kit's kit.
39
+ * @param {Function} put - The wall's face placer (`facePut`).
40
+ * @param {number} u - Metres along the face from its middle.
41
+ * @param {number} yTop - Height of the ledge, in metres.
42
+ * @param {number} w - Width of the stain, in metres.
43
+ * @param {number} h - Its length down the wall, in metres.
44
+ * @param {number} seed - Any number: its fraction picks the streaks' pattern.
45
+ */
46
+ export function kitStain(kit, put, u, yTop, w, h, seed) {
47
+ wallMark(kit, put, u, w, yTop, yTop - h, 0.014, streakSeed(seed));
48
+ }
49
+ /**
50
+ * Soot risen up a wall from an opening: from yBot it climbs h metres.
51
+ * @param {object} kit - A house kit's kit.
52
+ * @param {Function} put - The wall's face placer.
53
+ * @param {number} u - Metres along the face from its middle.
54
+ * @param {number} yBot - Height of the opening's head, in metres.
55
+ * @param {number} w - Width, in metres.
56
+ * @param {number} h - Height it climbs, in metres.
57
+ * @param {number} seed - Any number: its fraction picks the pattern.
58
+ * @param {number} [out=0] - Extra metres off the wall (for a wall thicker than its face).
59
+ */
60
+ export function kitSoot(kit, put, u, yBot, w, h, seed, out = 0) {
61
+ wallMark(kit, put, u, w, yBot, yBot + h, out + 0.016, 0.5 + streakSeed(seed));
62
+ }
63
+
64
+ const WEAR = 1; // the pattern the stain material draws as a blotch
65
+ /**
66
+ * Wear lying on the ground about the frame's origin, turned with it: a soft dark blotch where boots and wheels pass.
67
+ * @param {object} kit - A house kit's kit.
68
+ * @param {number} w - Metres across (x).
69
+ * @param {number} d - Metres deep (z).
70
+ * @param {number} [y=0.03] - Height over the ground, in metres.
71
+ */
72
+ export function kitWear(kit, w, d, y = 0.03) {
73
+ const x = w / 2,
74
+ z = d / 2;
75
+ kitDecal(kit.stain, [-x, y, z], [x, y, z], [x, y, -z], [-x, y, -z], [0, 1, 0], WEAR);
76
+ }
77
+ const TILLED = 252 / 255; // the pattern the stain material draws as tilled earth (a colour byte, between soot's codes and wear's)
78
+ /**
79
+ * Tilled earth over a bed: furrows down its length and clods.
80
+ * @param {object} kit - A house kit's kit.
81
+ * @param {number} x - Middle of the bed in the frame, metres.
82
+ * @param {number} y - Its height, metres.
83
+ * @param {number} z - Its middle, metres.
84
+ * @param {number} len - Its length down x, metres.
85
+ * @param {number} w - Its width across z, metres.
86
+ */
87
+ export function kitTilled(kit, x, y, z, len, w) {
88
+ const x0 = x - len / 2,
89
+ x1 = x + len / 2,
90
+ z0 = z - w / 2,
91
+ z1 = z + w / 2;
92
+ kitDecal(kit.stain, [x0, y, z0], [x0, y, z1], [x1, y, z1], [x1, y, z0], [0, 1, 0], TILLED);
93
+ }