roamwright 0.4.0 → 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 (549) hide show
  1. package/.prettierrc.yaml +12 -0
  2. package/CONTRIBUTING.md +21 -14
  3. package/README.md +38 -42
  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/bedding.js +141 -0
  67. package/geometry/builder-cells.js +50 -0
  68. package/geometry/builder-frame.js +48 -0
  69. package/geometry/builder.js +200 -177
  70. package/geometry/card-emblem.js +437 -0
  71. package/geometry/catenary-canvas.js +396 -0
  72. package/geometry/cell-mask.js +25 -0
  73. package/geometry/cloth-folds.js +143 -0
  74. package/geometry/crawl-shapes.js +71 -0
  75. package/geometry/creased-sheet.js +40 -35
  76. package/geometry/crowd-dress.js +315 -0
  77. package/geometry/crowd-far.js +174 -0
  78. package/geometry/crowd-look.js +42 -0
  79. package/geometry/crowd-weld.js +218 -0
  80. package/geometry/ear.js +44 -39
  81. package/geometry/erosion.js +71 -45
  82. package/geometry/face-grid.js +85 -65
  83. package/geometry/field-map.js +59 -0
  84. package/geometry/figure-arms.js +339 -0
  85. package/geometry/figure-beard.js +250 -0
  86. package/geometry/figure-body.js +297 -0
  87. package/geometry/figure-bow.js +105 -0
  88. package/geometry/figure-cloak.js +189 -0
  89. package/geometry/figure-clothes.js +337 -0
  90. package/geometry/figure-face-grids.js +75 -0
  91. package/geometry/figure-gear.js +446 -0
  92. package/geometry/figure-hair-far.js +151 -0
  93. package/geometry/figure-hair-hangs.js +108 -0
  94. package/geometry/figure-hair-patch.js +66 -0
  95. package/geometry/figure-hair.js +320 -0
  96. package/geometry/figure-hands.js +321 -0
  97. package/geometry/figure-head-features.js +280 -0
  98. package/geometry/figure-head.js +375 -0
  99. package/geometry/figure-headwear.js +223 -0
  100. package/geometry/figure-legs.js +231 -0
  101. package/geometry/figure-limbs.js +39 -0
  102. package/geometry/figure-sculpt.js +82 -0
  103. package/geometry/figure-skin.js +97 -0
  104. package/geometry/figure-skirts.js +303 -0
  105. package/geometry/figure-trunk.js +411 -0
  106. package/geometry/flier-corvid-body.js +322 -0
  107. package/geometry/flier-corvid-wings.js +154 -0
  108. package/geometry/flier-long-body.js +195 -0
  109. package/geometry/flier-shapes.js +219 -0
  110. package/geometry/flier-soaring-bird.js +84 -0
  111. package/geometry/foliage.js +187 -14
  112. package/geometry/fort-city-walls.js +479 -0
  113. package/geometry/fort-gate-approach.js +233 -0
  114. package/geometry/fort-great-walls.js +280 -0
  115. package/geometry/fort-keep.js +297 -0
  116. package/geometry/fort-parts.js +261 -0
  117. package/geometry/fort-polyline.js +261 -0
  118. package/geometry/fort-portal.js +96 -0
  119. package/geometry/fort-ring-wall.js +267 -0
  120. package/geometry/fort-seawall.js +104 -0
  121. package/geometry/fort-terrace-gates.js +323 -0
  122. package/geometry/fort-terrace-plan.js +250 -0
  123. package/geometry/fort-terrace-wall.js +345 -0
  124. package/geometry/garment-tags.js +11 -3
  125. package/geometry/grid-gather.js +69 -0
  126. package/geometry/grid-sample.js +185 -0
  127. package/geometry/hair-gathers.js +57 -42
  128. package/geometry/hair-locks.js +42 -42
  129. package/geometry/hair-patch.js +24 -20
  130. package/geometry/hair-shell.js +43 -31
  131. package/geometry/head-presets.js +103 -0
  132. package/geometry/head-profile.js +26 -15
  133. package/geometry/head-shape.js +123 -95
  134. package/geometry/heightfield.js +50 -24
  135. package/geometry/horizon-angles.js +166 -0
  136. package/geometry/house-kit-body.js +195 -0
  137. package/geometry/house-kit-courtyard-parts.js +340 -0
  138. package/geometry/house-kit-courtyard-roof.js +223 -0
  139. package/geometry/house-kit-courtyard.js +409 -0
  140. package/geometry/house-kit-cut.js +29 -0
  141. package/geometry/house-kit-extras.js +192 -0
  142. package/geometry/house-kit-forms.js +298 -0
  143. package/geometry/house-kit-frame.js +74 -0
  144. package/geometry/house-kit-marks.js +93 -0
  145. package/geometry/house-kit-openings.js +193 -0
  146. package/geometry/house-kit-palette.js +54 -0
  147. package/geometry/house-kit-pool.js +71 -0
  148. package/geometry/house-kit-roofs.js +151 -0
  149. package/geometry/house-kit.js +202 -0
  150. package/geometry/index-parts.js +2 -2
  151. package/geometry/instance-visibility.js +12 -12
  152. package/geometry/instances.js +17 -17
  153. package/geometry/lamp-wash.js +65 -0
  154. package/geometry/land-clearings.js +83 -0
  155. package/geometry/land-ditches.js +290 -0
  156. package/geometry/land-dry-basin.js +327 -0
  157. package/geometry/land-dunes.js +150 -0
  158. package/geometry/land-earthworks.js +432 -0
  159. package/geometry/land-edge.js +292 -0
  160. package/geometry/land-mound-faces.js +349 -0
  161. package/geometry/land-near-relief.js +102 -0
  162. package/geometry/land-sheet.js +220 -0
  163. package/geometry/land-town-ground.js +256 -0
  164. package/geometry/land-waters.js +228 -0
  165. package/geometry/land-wildness.js +123 -0
  166. package/geometry/lathed-vessel.js +293 -0
  167. package/geometry/outline-grid.js +11 -10
  168. package/geometry/outline-segments.js +74 -0
  169. package/geometry/part-ranges.js +38 -3
  170. package/geometry/path-field.js +98 -34
  171. package/geometry/placement.js +52 -52
  172. package/geometry/planked-floor.js +149 -0
  173. package/geometry/plant-broadleaf.js +268 -0
  174. package/geometry/plant-shrub.js +198 -0
  175. package/geometry/plant-tints.js +80 -0
  176. package/geometry/plant-trees.js +453 -0
  177. package/geometry/plant-tussock.js +107 -0
  178. package/geometry/point-buckets.js +50 -0
  179. package/geometry/primitives.js +117 -59
  180. package/geometry/prop-battlefield.js +69 -0
  181. package/geometry/prop-camp.js +175 -0
  182. package/geometry/prop-door.js +26 -0
  183. package/geometry/prop-harbour.js +105 -0
  184. package/geometry/prop-haycock.js +60 -0
  185. package/geometry/prop-sacks.js +74 -0
  186. package/geometry/prop-sheaf.js +68 -0
  187. package/geometry/prop-street.js +69 -0
  188. package/geometry/prop-tents.js +396 -0
  189. package/geometry/prop-tombs.js +80 -0
  190. package/geometry/prop-trade.js +393 -0
  191. package/geometry/prop-vehicles.js +218 -0
  192. package/geometry/props.js +58 -0
  193. package/geometry/room-arcade.js +134 -0
  194. package/geometry/room-dome.js +188 -0
  195. package/geometry/room-flames.js +138 -0
  196. package/geometry/room-frame.js +106 -0
  197. package/geometry/room-furniture.js +260 -0
  198. package/geometry/room-hearth.js +98 -0
  199. package/geometry/room-kit.js +59 -0
  200. package/geometry/room-openings.js +142 -0
  201. package/geometry/room-stairs.js +180 -0
  202. package/geometry/room-surfaces.js +272 -0
  203. package/geometry/sagging-tube.js +27 -27
  204. package/geometry/sampled-surface.js +123 -77
  205. package/geometry/scatter-grid.js +49 -6
  206. package/geometry/sculpt.js +97 -93
  207. package/geometry/ship-fittings.js +350 -0
  208. package/geometry/ship-hull.js +460 -0
  209. package/geometry/ship-kit.js +208 -0
  210. package/geometry/ship-lines.js +69 -0
  211. package/geometry/ship-oars.js +150 -0
  212. package/geometry/ship-presets.js +131 -0
  213. package/geometry/ship-rig.js +374 -0
  214. package/geometry/ship-sails.js +148 -0
  215. package/geometry/shore-grid.js +81 -34
  216. package/geometry/strata-field.js +131 -98
  217. package/geometry/strata-tiles.js +108 -94
  218. package/geometry/stream.js +96 -59
  219. package/geometry/swept-tube.js +124 -0
  220. package/geometry/terrain-chunks.js +216 -123
  221. package/geometry/terrain-extension.js +29 -13
  222. package/geometry/town-courtyard-inn.js +272 -0
  223. package/geometry/town-ground.js +76 -0
  224. package/geometry/town-houses.js +343 -0
  225. package/geometry/town-lights.js +254 -0
  226. package/geometry/town-lots.js +172 -0
  227. package/geometry/town-plan.js +370 -0
  228. package/geometry/town-works.js +465 -0
  229. package/geometry/village-layout.js +181 -0
  230. package/geometry/village-yards.js +167 -0
  231. package/geometry/wall-runs.js +64 -0
  232. package/index.js +138 -2
  233. package/math/cell-edge.js +16 -16
  234. package/math/cell-key.js +6 -0
  235. package/math/circle-clearances.js +19 -0
  236. package/math/cloth-textures.js +6 -6
  237. package/math/cloud-textures.js +22 -26
  238. package/math/color.js +14 -14
  239. package/math/curve.js +26 -22
  240. package/math/lamp-texels.js +43 -0
  241. package/math/lit-share.js +22 -0
  242. package/math/mountain-ranges.js +379 -205
  243. package/math/noise.js +101 -49
  244. package/math/particle-noise.js +28 -28
  245. package/math/periodic.js +11 -5
  246. package/math/random.js +24 -15
  247. package/math/rectangles.js +58 -0
  248. package/math/rock-texture.js +22 -17
  249. package/math/scalar.js +5 -5
  250. package/math/surface-textures.js +74 -59
  251. package/math/wandering-path.js +40 -0
  252. package/math/ways.js +120 -0
  253. package/motion/action-dynamics.js +398 -0
  254. package/motion/animal-bearing.js +247 -0
  255. package/motion/animal-canine-bearing.js +178 -0
  256. package/motion/animal-canine-cast.js +131 -0
  257. package/motion/animal-cattle-cast.js +64 -0
  258. package/motion/animal-herd-cast.js +154 -0
  259. package/motion/animal-horse-still.js +161 -0
  260. package/motion/animal-troop-cast.js +43 -0
  261. package/motion/arm-reach.js +27 -26
  262. package/motion/ballistic-arc.js +191 -0
  263. package/motion/biped-cycle.js +46 -0
  264. package/motion/biped-leg.js +40 -0
  265. package/motion/biped-posture.js +459 -0
  266. package/motion/biped-stride.js +226 -140
  267. package/motion/boat-sailing.js +214 -0
  268. package/motion/contact-transition.js +32 -0
  269. package/motion/crowd-alarms.js +72 -42
  270. package/motion/crowd-attention.js +108 -0
  271. package/motion/crowd-beasts.js +203 -0
  272. package/motion/crowd-camp.js +295 -0
  273. package/motion/crowd-figure.js +100 -0
  274. package/motion/crowd-herd.js +86 -0
  275. package/motion/crowd-hold.js +130 -0
  276. package/motion/crowd-pose.js +296 -0
  277. package/motion/crowd-poses.js +481 -0
  278. package/motion/crowd-routine.js +126 -67
  279. package/motion/crowd-town.js +166 -0
  280. package/motion/crowd-water.js +143 -0
  281. package/motion/daily-clock.js +9 -9
  282. package/motion/deck-surface.js +40 -0
  283. package/motion/figure-acts.js +411 -0
  284. package/motion/figure-arms.js +437 -0
  285. package/motion/figure-blade-slide.js +149 -0
  286. package/motion/figure-body-place.js +180 -0
  287. package/motion/figure-bones.js +118 -0
  288. package/motion/figure-bow-draw.js +70 -0
  289. package/motion/figure-fingers.js +215 -0
  290. package/motion/figure-gaze.js +205 -0
  291. package/motion/figure-gestures.js +452 -0
  292. package/motion/figure-grip.js +134 -0
  293. package/motion/figure-head.js +287 -0
  294. package/motion/figure-legs.js +264 -0
  295. package/motion/figure-links.js +293 -0
  296. package/motion/figure-locomotion.js +391 -0
  297. package/motion/figure-mount-up.js +180 -0
  298. package/motion/figure-mount.js +201 -0
  299. package/motion/figure-pose-frame.js +375 -0
  300. package/motion/figure-pose-table.js +156 -0
  301. package/motion/figure-pose.js +343 -0
  302. package/motion/figure-seat.js +267 -0
  303. package/motion/figure-sway.js +125 -0
  304. package/motion/flier-corvid-pose.js +74 -0
  305. package/motion/flier-flight-air.js +122 -0
  306. package/motion/flier-flight-echelon.js +164 -0
  307. package/motion/flier-flight-roost.js +131 -0
  308. package/motion/flier-swarm-flight.js +252 -0
  309. package/motion/formation.js +193 -0
  310. package/motion/ground-lookahead.js +5 -5
  311. package/motion/instance-sight.js +15 -8
  312. package/motion/melee-contact.js +143 -0
  313. package/motion/moorings.js +48 -0
  314. package/motion/path-steering.js +358 -0
  315. package/motion/player.js +41 -32
  316. package/motion/quadruped.js +244 -168
  317. package/motion/spaces.js +90 -38
  318. package/motion/speech-cadence.js +304 -0
  319. package/motion/vessel-motion.js +57 -0
  320. package/motion/walk-grid.js +235 -0
  321. package/motion/weather.js +133 -26
  322. package/motion/wind.js +58 -13
  323. package/package.json +33 -6
  324. package/rendering/alpha-mips.js +340 -0
  325. package/rendering/animal-camel-figure.js +29 -0
  326. package/rendering/animal-canine-figure.js +59 -0
  327. package/rendering/animal-cattle-figure.js +36 -0
  328. package/rendering/animal-horse-figure.js +49 -0
  329. package/rendering/atmosphere.js +86 -0
  330. package/rendering/camera-track.js +156 -0
  331. package/rendering/cart-track.js +92 -0
  332. package/rendering/caster-motion.js +6 -5
  333. package/rendering/cell-lod-options.js +46 -0
  334. package/rendering/cell-lod.js +754 -113
  335. package/rendering/cloth-material.js +140 -0
  336. package/rendering/cloud-dome.js +30 -30
  337. package/rendering/cloud-field.js +2 -2
  338. package/rendering/compilation-schedule.js +79 -14
  339. package/rendering/contact-shadows.js +7 -4
  340. package/rendering/context.js +57 -6
  341. package/rendering/crowd-batches.js +420 -0
  342. package/rendering/crowd-herd.js +198 -0
  343. package/rendering/crowd-rig.js +132 -0
  344. package/rendering/crowd-skinning.js +62 -19
  345. package/rendering/crowd-update.js +419 -0
  346. package/rendering/crowd-visibility.js +107 -0
  347. package/rendering/crust.js +18 -12
  348. package/rendering/day-cycle-defaults.js +200 -0
  349. package/rendering/day-cycle.js +487 -0
  350. package/rendering/daylight.js +4 -6
  351. package/rendering/detail-range.js +29 -0
  352. package/rendering/dispose-meshes.js +18 -0
  353. package/rendering/dof.js +20 -13
  354. package/rendering/effects-frame.js +149 -0
  355. package/rendering/effects-water-rises.js +221 -0
  356. package/rendering/energy-stream.js +128 -0
  357. package/rendering/eye-adapt.js +14 -14
  358. package/rendering/facade-glass-material.js +105 -0
  359. package/rendering/far-shadow.js +89 -62
  360. package/rendering/field-surface.js +138 -0
  361. package/rendering/figure-shield.js +105 -0
  362. package/rendering/figure-skeleton.js +329 -0
  363. package/rendering/fire-light-watch.js +197 -0
  364. package/rendering/fire-pools.js +148 -0
  365. package/rendering/flame-sources.js +86 -0
  366. package/rendering/flier-bird-looks.js +97 -0
  367. package/rendering/flier-corvid-figure.js +67 -0
  368. package/rendering/flier-long-body-company.js +169 -0
  369. package/rendering/flier-swarm.js +186 -0
  370. package/rendering/flocks.js +82 -78
  371. package/rendering/garment-material.js +147 -51
  372. package/rendering/glow-lines.js +13 -13
  373. package/rendering/glsl-literal.js +19 -0
  374. package/rendering/ground-marks.js +316 -0
  375. package/rendering/hair-strands.js +45 -31
  376. package/rendering/height-haze.js +80 -33
  377. package/rendering/height-probe.js +164 -22
  378. package/rendering/house-kit-meshes.js +124 -0
  379. package/rendering/interior-bake.js +807 -0
  380. package/rendering/label-layout.js +56 -0
  381. package/rendering/label-range.js +41 -0
  382. package/rendering/lamp-light-map.js +159 -0
  383. package/rendering/lamp-maps.js +62 -0
  384. package/rendering/lamp-wash.js +51 -0
  385. package/rendering/light-budget.js +71 -55
  386. package/rendering/light-points.js +21 -5
  387. package/rendering/local-lights.js +39 -8
  388. package/rendering/material-lod.js +49 -50
  389. package/rendering/memory-estimate.js +84 -0
  390. package/rendering/moored-fleet.js +186 -0
  391. package/rendering/part-costs.js +104 -0
  392. package/rendering/particle-bursts.js +386 -0
  393. package/rendering/particle-emitters.js +135 -99
  394. package/rendering/particle-light-bursts.js +189 -0
  395. package/rendering/particles.js +212 -101
  396. package/rendering/pen-flocks.js +118 -0
  397. package/rendering/piece-batch.js +298 -11
  398. package/rendering/planar-reflection-options.js +159 -0
  399. package/rendering/planar-reflection.js +806 -103
  400. package/rendering/plant-cells.js +122 -0
  401. package/rendering/plant-reeds.js +113 -0
  402. package/rendering/plant-shade-trees.js +239 -0
  403. package/rendering/plant-tuft-patch.js +122 -0
  404. package/rendering/post-shaders.js +98 -31
  405. package/rendering/post.js +107 -87
  406. package/rendering/pressed-cover.js +135 -0
  407. package/rendering/prop-dig.js +136 -0
  408. package/rendering/rain-streaks.js +67 -0
  409. package/rendering/room-light.js +250 -0
  410. package/rendering/room-materials.js +78 -0
  411. package/rendering/room-space.js +111 -0
  412. package/rendering/scene-lights.js +106 -0
  413. package/rendering/sea-shaders.js +94 -37
  414. package/rendering/settlement-approach.js +226 -0
  415. package/rendering/settlement-dissolve.js +89 -0
  416. package/rendering/settlement-quarter-warm.js +55 -0
  417. package/rendering/settlement-quarter.js +477 -0
  418. package/rendering/settlement-switch.js +42 -0
  419. package/rendering/settlement-town.js +110 -0
  420. package/rendering/shader-warmup.js +101 -44
  421. package/rendering/shadow-alignment.js +4 -4
  422. package/rendering/shadow-depth.js +47 -25
  423. package/rendering/ship-meshes.js +150 -0
  424. package/rendering/shot-cuts.js +68 -0
  425. package/rendering/sky-occlusion.js +56 -29
  426. package/rendering/sky-pmrem.js +216 -0
  427. package/rendering/sky.js +126 -54
  428. package/rendering/smoke-shadows.js +201 -0
  429. package/rendering/stage-framing.js +182 -0
  430. package/rendering/stage-lights.js +46 -39
  431. package/rendering/stain-material.js +74 -0
  432. package/rendering/static-point-shadow.js +65 -26
  433. package/rendering/still-casters.js +77 -27
  434. package/rendering/strata-material.js +12 -12
  435. package/rendering/stream-flow.js +10 -10
  436. package/rendering/street-lamps.js +166 -0
  437. package/rendering/sunbeam-motes.js +670 -0
  438. package/rendering/surface-light.js +65 -6
  439. package/rendering/surface-material.js +306 -0
  440. package/rendering/surface-projection.js +32 -0
  441. package/rendering/surface-snippets.js +314 -0
  442. package/rendering/taa.js +75 -44
  443. package/rendering/talus.js +15 -15
  444. package/rendering/terrain-rock.js +7 -7
  445. package/rendering/texture-fills.js +8 -8
  446. package/rendering/textures.js +28 -28
  447. package/rendering/tree-impostor.js +929 -0
  448. package/rendering/vehicle-train.js +92 -0
  449. package/rendering/viewport.js +67 -4
  450. package/rendering/wakes.js +24 -24
  451. package/rendering/water-material.js +304 -103
  452. package/rendering/waypoint-beacons.js +191 -0
  453. package/rendering/world-matrices.js +38 -40
  454. package/ruff.toml +20 -0
  455. package/runtime/cue-cursor.js +21 -0
  456. package/runtime/device-quality.js +13 -2
  457. package/runtime/device.js +73 -0
  458. package/runtime/diagnostic-log.js +12 -4
  459. package/runtime/effect-sites.js +85 -0
  460. package/runtime/figure-orders.js +59 -0
  461. package/runtime/first-use.js +36 -28
  462. package/runtime/foley-script.js +124 -0
  463. package/runtime/foley-strides.js +333 -0
  464. package/runtime/frame-pacing.js +47 -0
  465. package/runtime/frame-yield.js +18 -0
  466. package/runtime/gpu-timing.js +15 -11
  467. package/runtime/grid-cache.js +16 -6
  468. package/runtime/grid-rows.js +44 -5
  469. package/runtime/hand-over.js +47 -24
  470. package/runtime/land-bake.js +78 -0
  471. package/runtime/lazy-sets.js +105 -0
  472. package/runtime/pool.js +73 -17
  473. package/runtime/quality-fit.js +60 -28
  474. package/runtime/region-pass-lay.js +40 -0
  475. package/runtime/region-pass.js +78 -0
  476. package/runtime/search.js +26 -22
  477. package/runtime/settlement-reach.js +42 -0
  478. package/runtime/sound-calls.js +113 -0
  479. package/runtime/sound-impacts.js +297 -0
  480. package/runtime/sound-voices.js +194 -0
  481. package/runtime/soundscape.js +282 -0
  482. package/runtime/spatial-audio.js +79 -30
  483. package/runtime/steady-frames.js +221 -0
  484. package/runtime/withdrawable-task.js +46 -0
  485. package/runtime/worker.js +7 -0
  486. package/scripts/app-parts.mjs +118 -0
  487. package/scripts/bake-revisions.mjs +81 -0
  488. package/scripts/browser-scripts.mjs +64 -0
  489. package/scripts/bundle.mjs +192 -0
  490. package/scripts/check-app.sh +26 -0
  491. package/scripts/eslint-config.mjs +119 -0
  492. package/scripts/format.sh +92 -0
  493. package/scripts/keep-builds.mjs +158 -0
  494. package/scripts/layers.mjs +112 -0
  495. package/scripts/lint.sh +49 -0
  496. package/scripts/module-graph.mjs +123 -0
  497. package/scripts/pre-commit.sh +38 -0
  498. package/scripts/serve.py +5 -3
  499. package/scripts/site.mjs +358 -0
  500. package/scripts/test-runner.sh +42 -0
  501. package/scripts/vendor.mjs +221 -0
  502. package/scripts/verify-publish.mjs +175 -0
  503. package/scripts/world.mk +59 -0
  504. package/tools/README.md +73 -0
  505. package/tools/contact-sheet.cjs +137 -0
  506. package/tools/cpu-profile.cjs +275 -0
  507. package/tools/cpu-profile.test.cjs +98 -0
  508. package/tools/first-draws.cjs +395 -0
  509. package/tools/flight-guard.cjs +482 -0
  510. package/tools/flight-guard.test.cjs +153 -0
  511. package/tools/flight-profile.cjs +145 -0
  512. package/tools/frame-bench.cjs +336 -0
  513. package/tools/frame-parts.cjs +365 -0
  514. package/tools/ios-sim.sh +145 -0
  515. package/tools/load-audit.cjs +201 -0
  516. package/tools/look-compare.cjs +304 -0
  517. package/tools/look-guard.cjs +407 -0
  518. package/tools/look-guard.test.cjs +93 -0
  519. package/tools/look-stats.cjs +185 -0
  520. package/tools/look-stats.test.cjs +71 -0
  521. package/tools/memory-audit.cjs +323 -0
  522. package/tools/page-driver.cjs +320 -0
  523. package/tools/page-driver.test.cjs +219 -0
  524. package/tools/program-census-report.cjs +191 -0
  525. package/tools/program-census.cjs +465 -0
  526. package/tools/program-census.test.cjs +332 -0
  527. package/tools/remote-runner.sh +265 -0
  528. package/tools/runners.test.cjs +59 -0
  529. package/tools/scene-audit-beat.cjs +344 -0
  530. package/tools/scene-audit-sheet.cjs +282 -0
  531. package/tools/scene-audit.cjs +471 -0
  532. package/tools/scene-audit.test.cjs +201 -0
  533. package/tools/scene-batch.cjs +219 -0
  534. package/tools/scene-bench.cjs +149 -0
  535. package/tools/scene-bench.test.cjs +33 -0
  536. package/tools/scene-run.cjs +443 -0
  537. package/tools/scene-run.test.cjs +94 -0
  538. package/tools/servers.sh +59 -0
  539. package/tools/shader-arrival.cjs +316 -0
  540. package/tools/shader-renewal.cjs +53 -0
  541. package/tools/shader-renewal.test.cjs +115 -0
  542. package/tools/speed-guard.cjs +258 -0
  543. package/tools/stills.cjs +492 -0
  544. package/tools/stills.test.cjs +49 -0
  545. package/tools/turns.sh +7 -0
  546. package/tools/yaml.cjs +158 -0
  547. package/examples/viaduct.css +0 -75
  548. package/rendering/light-shafts.js +0 -131
  549. package/rendering/road-surface.js +0 -63
@@ -0,0 +1,54 @@
1
+ // The colours a house kit dresses its houses in, as a world gives them (each has a default): window light, curtains, timber,
2
+ // shutters, awnings and washing; and the courtyard house's colours. Colours are linear [r, g, b] or sRGB hex numbers, as noted.
3
+ import { IcosahedronGeometry } from 'three';
4
+
5
+ /**
6
+ * The house kit's default palette. A world passes its own to `createHouseKit({ palette })`; keys it leaves out take these.
7
+ * - `windowLight`: three warm lamplights of lit windows, linear [r, g, b].
8
+ * - `black`: an unlit opening.
9
+ * - `drapes`: the curtains behind windows, linear; `indoors`: the light a curtain takes in a room's shade, as a share of the
10
+ * street's; `folds`: a drawn curtain's folds across it, the light on each.
11
+ * - `timbers`: a house's timber frame (sRGB hex), picked by where the house stands; `hemp`: rope and lines, linear.
12
+ * - `shutters`, `awnings`, `cloths`: sRGB hex choices for shutters, shop awnings, and washing on a line.
13
+ */
14
+ export const HOUSE_PALETTE = Object.freeze({
15
+ windowLight: [
16
+ [1.0, 0.62, 0.28],
17
+ [1.0, 0.74, 0.42],
18
+ [0.92, 0.5, 0.2],
19
+ ],
20
+ black: [0, 0, 0],
21
+ // three muted dyes, linen the commonest: faded madder, ochre, undyed linen twice
22
+ drapes: [
23
+ [0.4, 0.16, 0.12],
24
+ [0.46, 0.36, 0.19],
25
+ [0.6, 0.56, 0.48],
26
+ [0.6, 0.56, 0.48],
27
+ ],
28
+ indoors: 0.3,
29
+ folds: [0.95, 0.6, 1, 0.7],
30
+ // weathered oak, mostly brown, some silvered grey, some tarred dark
31
+ timbers: [0x5a4434, 0x6a5644, 0x6a5644, 0x7c7468, 0x3e3128],
32
+ hemp: [0.3, 0.25, 0.15],
33
+ shutters: [0x2f4a44, 0x4a2a24, 0x2a3a52, 0x3d3324, 0x55452c, 0x304030],
34
+ awnings: [0x8a3a30, 0x2f5a52, 0x9a7a35, 0x3a4a6a, 0x6a3a55],
35
+ cloths: [0xb9ad92, 0x8a3a30, 0x3f5a6a, 0xc9b98a, 0x6a7a4a, 0x9a8a9a, 0xd8d2c4],
36
+ });
37
+
38
+ /**
39
+ * The courtyard house's default colours (sRGB hex choices): `fired`, fired brick of plinths and sills; `timber`, lintels and
40
+ * screens; `clay`, water jars; `awning`, `rugs`, `washing`, the cloth of awnings, hung rugs and washing; `brass`, finials.
41
+ * A world passes its own to `createHouseKit({ courtyard })`.
42
+ */
43
+ export const COURTYARD_PALETTE = Object.freeze({
44
+ fired: [0x9a6a4a, 0x8e5f42, 0xa5765a],
45
+ timber: [0x5a4632, 0x4a3828, 0x6a5238, 0x3f3022],
46
+ clay: [0xa0603c, 0xb07048, 0x8f5636],
47
+ awning: [0xb04a32, 0x2f6a7a, 0xc9a24a, 0x7a3a5a, 0xd8cfb8, 0x4a6a3a, 0x9a5a2a],
48
+ rugs: [0x8a2a24, 0x2a3a6a, 0x6a2a3a, 0x9a6a2a, 0x3a5a4a],
49
+ washing: [0xe0d8c4, 0xb9ad92, 0x8a3a30, 0x3f5a6a, 0xc9b98a, 0x2a4a6a, 0xd8c070],
50
+ brass: 0xb8923a,
51
+ });
52
+
53
+ /** A cheap rounded lump, half a metre across (an icosahedron): flower heads, loaves, cabbages. */
54
+ export const KIT_LUMP = new IcosahedronGeometry(0.5, 0);
@@ -0,0 +1,71 @@
1
+ // Houses of a house kit built by a pool of workers, for a builder that fills a kit and makes it meshes whole. The builder
2
+ // fills the pooled kit as it would any (genHouse included): a plain house is noted with where it goes instead and built on
3
+ // another core meanwhile; `mesh` then makes the kit's meshes with every house in its place, and its lit windows in theirs,
4
+ // as the page alone would have built them.
5
+ import { Matrix4 } from 'three';
6
+ import { insertPartGroups } from './part-ranges.js';
7
+ import { KIT_KEYS, kitCounts } from './house-kit-frame.js';
8
+
9
+ const UNMOVED = new Matrix4();
10
+
11
+ /**
12
+ * Whether a house's spec is plain numbers and names, which a worker can build: not if a builder has given it a function of
13
+ * its own to call (only the page can call that).
14
+ * @param {object} spec - A house's spec.
15
+ * @returns {boolean}
16
+ */
17
+ export const isPlain = spec => !Object.values(spec).some(value => typeof value === 'function');
18
+
19
+ /**
20
+ * Binds the pooled kit to a house kit and a pool of workers. The workers' job (`job`, 'houses' if not given) is given
21
+ * { specs, frames } and answers what the kit's `housesFromSpecs(specs, frames)` returns.
22
+ * @param {object} o
23
+ * @param {object} o.houseKit - The house kit (`createHouseKit`).
24
+ * @param {object} o.pool - The worker pool: `pooled()` (whether there are workers), `ready(job)` (start them on a job),
25
+ * `runOrHere(job, args, here)` (run it on a worker, or call `here` on the page where none can).
26
+ * @param {(parts: object[], parent: object) => object[]} o.kitMeshes - Makes a kit's arrays meshes (`createHouseKitMeshes`).
27
+ * @param {string} [o.job='houses'] - The workers' job name.
28
+ * @returns {Function} The PooledKit class: `new PooledKit()` holds a fresh `kit`; `mesh(parent)` promises its meshes under
29
+ * parent; `parts()` promises each kind's arrays with the pool's houses in their places (the kit is let go).
30
+ */
31
+ export function createPooledKit({ houseKit, pool, kitMeshes, job = 'houses' }) {
32
+ const { kitFrame, kitNew, tagKit, housesFromSpecs, addLitWindows, litWindowCount } = houseKit,
33
+ { pooled, ready, runOrHere } = pool;
34
+ return class PooledKit {
35
+ constructor() {
36
+ if (pooled()) ready(job);
37
+ this.kit = kitNew();
38
+ this.kit.toPool = spec => this.take(spec);
39
+ this.sent = []; // the houses for the pool, each with where it goes: the kit's counts and the lit windows noted when it was
40
+ // handed over, and the kit's frame it was placed in where the builder had moved it
41
+ }
42
+ // Whether genHouse leaves a house to the pool: not if it carries a function, or goes into a kit cut into cells by its
43
+ // parts (kitCells), whose part marks a worker does not send back.
44
+ take(spec) {
45
+ if (!pooled() || !isPlain(spec) || this.kit.wall.pb) return false;
46
+ this.sent.push({ spec, at: kitCounts(this.kit), lit: litWindowCount(), frame: kitFrame.equals(UNMOVED) ? null : kitFrame.toArray() });
47
+ tagKit(this.kit, spec); // as genHouse leaves it, for what the builder adds round the house
48
+ return true;
49
+ }
50
+ // The kit's meshes, one to a kind, under parent (as kitStatic makes them); the promise is kept once they stand.
51
+ async mesh(parent) {
52
+ return kitMeshes(await this.parts(), parent);
53
+ }
54
+ // Each kind's arrays (GB.parts), in KIT_KEYS's order, with the pool's houses in their places; the kit is let go.
55
+ async parts() {
56
+ const own = KIT_KEYS.map(k => this.kit[k].parts(true));
57
+ for (const k of KIT_KEYS) this.kit[k].release();
58
+ if (!this.sent.length) return own;
59
+ const specs = this.sent.map(s => s.spec),
60
+ frames = this.sent.map(s => s.frame),
61
+ at = this.sent.map(s => s.at);
62
+ const built = await runOrHere(
63
+ job,
64
+ () => ({ specs, frames }),
65
+ () => housesFromSpecs(specs, frames),
66
+ );
67
+ for (let i = this.sent.length - 1; i >= 0; i--) addLitWindows(built.lit[i], this.sent[i].lit); // the last first, so the places noted before it hold
68
+ return insertPartGroups(own, built.kits, at, built.ends);
69
+ }
70
+ };
71
+ }
@@ -0,0 +1,151 @@
1
+ // A house kit's roofs: pitched roofs with eaves, barge boards and ridges, dormers, chimneys and their soot, finials.
2
+ // Worker-safe.
3
+ import { dim } from '../math/color.js';
4
+ import { TRS } from './primitives.js';
5
+ import { facePut } from './house-kit-frame.js';
6
+ import { kitDecal } from './house-kit-marks.js';
7
+
8
+ /**
9
+ * A house kit's roofs, bound to its shapes, frame, palette and windows.
10
+ * @param {object} o
11
+ * @param {object} o.U - The unit shapes.
12
+ * @param {Function} o.kitPush - The kit frame's push (`createKitFrame`).
13
+ * @param {Function} o.kitPop - The kit frame's pop.
14
+ * @param {object} o.palette - The house palette.
15
+ * @param {Function} o.kitWindow - The kit's windows (`createHouseKitOpenings`).
16
+ * @returns {object} `kitGable(kit, house, x, y, z, len, span, rise, ry, roofColour, wallColour, o)`, a pitched roof with real
17
+ * thickness whose ridge runs along local x (len, span and rise in metres; o: `eave`, `over`, `bare`, `full` for its gable
18
+ * ends, dormers and `chimney`/`chimAt`, `timber`, `gmat`); `kitChimney(kit, house, x, z, y0, top)`, a stack with its soot and
19
+ * pots; `kitFinial(kit, y, scale)`, a spike and ball on a roof's top. `house` is the house's values (`R`, its random stream;
20
+ * `tim`, `frame`, `trim`, `chim` colours; `litP`).
21
+ */
22
+ export function createHouseKitRoofs({ U, kitPush, kitPop, palette, kitWindow }) {
23
+ const WARM = palette.windowLight;
24
+ function kitChimney(kit, house, x, z, y0, top) {
25
+ const c = house.chim;
26
+ kit.stone.box(x, y0, z, 0.74, top - y0, 0.74, c);
27
+ kit.stone.box(x, top, z, 0.94, 0.13, 0.94, dim(c, 0.45));
28
+ kit.stone.box(x, top - 0.55, z, 0.765, 0.55, 0.765, dim(c, 0.6)); // soot round the mouth of the flue
29
+ for (const [ax, az] of [
30
+ [1, 0],
31
+ [-1, 0],
32
+ [0, 1],
33
+ [0, -1],
34
+ ]) {
35
+ // and smoke-black run down the stack below it, longest on the lee side
36
+ const o = 0.386,
37
+ yt = top - 0.55,
38
+ hh = Math.min(yt - y0 - 0.1, 0.35 + house.R() * (ax > 0 ? 1.4 : 0.8)),
39
+ px = x + ax * o,
40
+ pz = z + az * o,
41
+ tx = -az * 0.36,
42
+ tz = ax * 0.36;
43
+ if (hh > 0.2)
44
+ kitDecal(
45
+ kit.stain,
46
+ [px - tx, yt - hh, pz - tz],
47
+ [px + tx, yt - hh, pz + tz],
48
+ [px + tx, yt, pz + tz],
49
+ [px - tx, yt, pz - tz],
50
+ [ax, 0, az],
51
+ house.R() * 0.48,
52
+ );
53
+ }
54
+ const two = house.R() < 0.5;
55
+ kit.cloth.add(U.taper, [0.3, 0.12, 0.06], TRS(x - (two ? 0.17 : 0), top + 0.13, z, 0.3, 0.46, 0.3));
56
+ if (two) kit.cloth.add(U.taper, [0.26, 0.1, 0.05], TRS(x + 0.17, top + 0.13, z, 0.28, 0.38, 0.28));
57
+ }
58
+ function kitDormer(kit, house, u, span, rise, sg, rc, wc) {
59
+ // inside the roof frame (ridge along x), on the +z or -z slope
60
+ const zf = span / 2 - 0.4,
61
+ yb = rise * (1 - zf / (span / 2)),
62
+ dh = 1.15,
63
+ yt = yb + dh;
64
+ if (yt > rise - 0.3) return;
65
+ const zb = ((1 - yt / rise) * span) / 2,
66
+ dp = zf - zb + 0.3,
67
+ dw = 1.25;
68
+ kitPush(u, 0, 0, sg > 0 ? 0 : Math.PI);
69
+ kit.wall.box(0, yb - 0.2, zf - dp / 2, dw, dh + 0.2, dp, wc);
70
+ kitGable(kit, house, 0, yt, zf - dp / 2 + 0.06, dp + 0.14, dw, 0.52, Math.PI / 2, rc, wc, { eave: 0.16, over: 0.12, bare: true });
71
+ kitWindow(kit, facePut(0, dw / 2, zf), 0, yb + 0.24, 0.66, 0.74, {
72
+ frame: house.frame,
73
+ lit: house.R() < house.litP ? WARM[1] : null,
74
+ sill: house.trim,
75
+ dry: true,
76
+ });
77
+ kitPop();
78
+ }
79
+ // A pitched roof with real thickness, eaves, barge boards and a ridge; the ridge runs along local x.
80
+ function kitGable(kit, house, x, y, z, len, span, rise, ry, rc, wc, o = {}) {
81
+ kitPush(x, y, z, ry);
82
+ const rand = house.R,
83
+ ev = o.eave ?? 0.42,
84
+ ov = o.over ?? 0.32,
85
+ a = Math.atan2(rise, span / 2),
86
+ sl = Math.hypot(span / 2, rise) + ev,
87
+ sa = Math.sin(a),
88
+ ca = Math.cos(a);
89
+ if (wc) (o.gmat || kit.wall).add(U.prism, wc, TRS(0, 0, 0, span, rise - 0.04, len, Math.PI / 2));
90
+ for (const sg of [1, -1]) {
91
+ kit.roof.add(U.box, rc, TRS(0, rise - (sa * sl) / 2, (sg * ca * sl) / 2, len + ov * 2, 0.15, sl, 0, sg * a));
92
+ if (!o.bare)
93
+ for (const e of [1, -1])
94
+ kit.wood.add(
95
+ U.box,
96
+ house.tim,
97
+ TRS(e * (len / 2 + ov), rise - (sa * sl) / 2 - 0.12, (sg * ca * sl) / 2, 0.07, 0.26, sl + 0.02, 0, sg * a),
98
+ );
99
+ }
100
+ kit.roof.add(U.box, dim(rc, 0.72), TRS(0, rise + 0.05, 0, len + ov * 2 + 0.05, 0.13, 0.36));
101
+ if (o.full) {
102
+ if (rise > 1.9)
103
+ for (const e of [2, 3]) {
104
+ const put = facePut(e, len / 2, 0);
105
+ if (o.timber) {
106
+ put(kit.wood, U.boxF, house.tim, 0, 0, 0.03, 0.17, rise - 0.3, 0.06);
107
+ put(kit.wood, U.boxF, house.tim, 0, rise * 0.42, 0.03, span * 0.5, 0.14, 0.06);
108
+ put(kit.wood, U.boxF, house.tim, 0, 0, 0.03, span - 0.2, 0.16, 0.06);
109
+ } else
110
+ kitWindow(kit, put, 0, rise * 0.2, 0.6, Math.min(0.8, rise * 0.38), {
111
+ frame: house.frame,
112
+ lit: rand() < house.litP ? WARM[0] : null,
113
+ sill: house.trim,
114
+ drop: Math.max(0.1, rise * 0.2 - 0.25),
115
+ });
116
+ }
117
+ if (rise > 2.3 && len > 5 && rand() < 0.5) {
118
+ const nd = len > 8 ? 2 : 1,
119
+ sg = rand() < 0.5 ? 1 : -1;
120
+ for (let q = 0; q < nd; q++) kitDormer(kit, house, (q + 0.5 - nd / 2) * len * 0.5, span, rise, sg, rc, wc);
121
+ }
122
+ if (o.chimney) {
123
+ const cu = o.chimAt ? o.chimAt[0] : (rand() - 0.5) * len * 0.6,
124
+ cz = o.chimAt ? o.chimAt[1] : (rand() < 0.5 ? 1 : -1) * span * (0.12 + rand() * 0.2);
125
+ kitChimney(kit, house, cu, cz, rise * (1 - Math.abs(cz) / (span / 2)) - 0.4, rise + 0.5 + rand() * 0.8);
126
+ const sg = cz < 0 ? -1 : 1,
127
+ z0 = Math.abs(cz) + 0.3,
128
+ z1 = Math.min(z0 + 1.6 + rand() * 1.4, span / 2 + ev * ca - 0.05),
129
+ yy = z => rise * (1 - z / (span / 2)) + 0.19 / ca,
130
+ hw = 0.6;
131
+ if (z1 > z0 + 0.5)
132
+ kitDecal(
133
+ kit.stain,
134
+ [cu - hw * sg, yy(z1), sg * z1],
135
+ [cu + hw * sg, yy(z1), sg * z1],
136
+ [cu + hw * sg, yy(z0), sg * z0],
137
+ [cu - hw * sg, yy(z0), sg * z0],
138
+ [0, ca, sg * sa],
139
+ 0.5 + rand() * 0.48,
140
+ );
141
+ }
142
+ }
143
+ kitPop();
144
+ }
145
+ function kitFinial(kit, y, s = 1) {
146
+ kit.cloth.add(U.cone6, [0.32, 0.26, 0.1], TRS(0, y - 0.1, 0, 0.14 * s, 1.3 * s, 0.14 * s));
147
+ kit.cloth.add(U.sph, [0.36, 0.29, 0.1], TRS(0, y + 0.35 * s, 0, 0.3 * s, 0.3 * s, 0.3 * s));
148
+ }
149
+
150
+ return { kitChimney, kitFinial, kitGable };
151
+ }
@@ -0,0 +1,202 @@
1
+ // The house kit: buildings assembled from real parts (window frames and glass, sills, shutters, doors and steps, jettied
2
+ // storeys, timber framing, eaved roofs, dormers, chimneys; and the flat-roofed courtyard house of a hot land) from plain
3
+ // specs, into one geometry builder per material. A world makes one with its unit shapes, its styles and palette, and the
4
+ // forms, builds and extras of its own it adds. Worker-safe: a worker that builds houses makes the same kit as the page.
5
+ import { mulberry32, pickR } from '../math/random.js';
6
+ import { C } from './primitives.js';
7
+ import { facePut, KIT_KEYS, kitCounts, createKitFrame } from './house-kit-frame.js';
8
+ import { COURTYARD_PALETTE, HOUSE_PALETTE, KIT_LUMP } from './house-kit-palette.js';
9
+ import { createHouseKitOpenings, litAt } from './house-kit-openings.js';
10
+ import { createHouseKitRoofs } from './house-kit-roofs.js';
11
+ import { createHouseKitBody } from './house-kit-body.js';
12
+ import { createHouseKitForms } from './house-kit-forms.js';
13
+ import { createHouseKitExtras } from './house-kit-extras.js';
14
+ import { createCourtyardParts } from './house-kit-courtyard-parts.js';
15
+ import { createCourtyardRoof } from './house-kit-courtyard-roof.js';
16
+ import { createCourtyardHouse } from './house-kit-courtyard.js';
17
+
18
+ const plainHash = (x, z, salt) => {
19
+ const s = Math.sin(x * 127.1 + z * 311.7 + salt * 74.7) * 43758.5453;
20
+ return s - Math.floor(s);
21
+ };
22
+
23
+ /** A house kit's default style: what a spec whose `style` the kit does not know is built as. */
24
+ export const PLAIN_HOUSE_STYLE = Object.freeze({
25
+ material: 'wall',
26
+ storey: 3.0,
27
+ timber: 0.55,
28
+ jetty: 0.6,
29
+ shutters: 0.65,
30
+ shops: 0.45,
31
+ balconies: 0.1,
32
+ windowW: 0.9,
33
+ windowH: 1.35,
34
+ frame: 0x45311f,
35
+ door: 0x2f2016,
36
+ trim: 0xa89c86,
37
+ });
38
+
39
+ /**
40
+ * Makes a house kit.
41
+ *
42
+ * A house's spec: `{ x, y, z, w, d, h, rot, style, form, col, rc, seed, rise, turn, chim, streetLit, ruin, lean, n, ... }` (metres,
43
+ * radians, linear colours `col` for its walls and `rc` its roof, `seed` its random stream). `form` names a form: `gable`
44
+ * (the default), `hip`, `body`, `flat`, `round`, `tower`, `dome`, `courtyard`, or one of `forms`; a spec whose `ruin` is
45
+ * under 1 is built as a ruin. `build` names one of `builds` (built in place of a house: street clutter), and `extra` one of
46
+ * `extras` (built after it), or either is a function of the caller's own (which only the page can call, not a worker).
47
+ *
48
+ * A style (`styles[spec.style]`, {@link PLAIN_HOUSE_STYLE} where none): `material` ('stone', 'wood', or 'wall' for render
49
+ * over brick), `storey` (metres), `timber` (the share of houses framed), `jetty` (the share jettied), `shutters`, `shops` and
50
+ * `balconies` (the shares with them), `windowW` and `windowH` (metres), `frame`, `door`, `trim` (sRGB hex); and optionally `timberColour`, `plinthColour`, `chimneyColour`
51
+ * (sRGB hex, in place of the palette's), `litShare` (the share of its windows lit at night, 0.32 if not given), `bareRoof`
52
+ * (a flat roof with nothing on it), `yardClutter` (logs and a barrel by a gabled house) and `rich` (a courtyard house's
53
+ * richer door).
54
+ *
55
+ * @param {object} o
56
+ * @param {object} o.shapes - The unit shapes (`createUnitShapes`).
57
+ * @param {(x: number, z: number, salt: number) => number} [o.hash] - A hash in [0, 1) of whole numbers: picks a house's
58
+ * timber by where it stands.
59
+ * @param {Object<string, object>} [o.styles] - The styles by name.
60
+ * @param {object} [o.palette] - The house palette's keys to change (`HOUSE_PALETTE`).
61
+ * @param {object} [o.courtyard] - The courtyard palette's keys to change (`COURTYARD_PALETTE`).
62
+ * @param {Object<string, Function|string>} [o.forms] - Forms of the world's own, by name, each (kit, house, spec,
63
+ * bodyOptions); a string names another form (an alias).
64
+ * @param {Object<string, Function>} [o.builds] - Builds of the world's own, by name, each (kit, random, spec).
65
+ * @param {Object<string, Function>} [o.extras] - Extras of the world's own, by name, each (kit, house, spec).
66
+ * @returns {object} The kit's frame (`kitFrame`, `kitPush`, `kitPop`, `kitNew`, `kitAt`, `facePut`, `KIT_KEYS`, `kitCounts`);
67
+ * `genHouse(kit, spec)`, builds one house into a kit; `housesFromSpecs(specs, frames, build)`, builds many into a fresh kit as
68
+ * a worker would; `tagKit(kit, spec)`; its lit windows (`takeLitWindows`, `litWindowCount`, `addLitWindows`, `litAt`); and
69
+ * every part, to build with outside a house (`kitWindow`, `kitDoor`, `kitBarrel`, `kitShop`, `kitGable`, `kitChimney`,
70
+ * `kitFinial`, `kitBody`, `propWashing`, the courtyard parts, `forms`, `builds`, `extras`, `palette`, `courtyard`).
71
+ */
72
+ export function createHouseKit({
73
+ shapes: U,
74
+ hash = plainHash,
75
+ styles = {},
76
+ palette: ownPalette,
77
+ courtyard: ownCourtyard,
78
+ forms: ownForms,
79
+ builds: ownBuilds,
80
+ extras: ownExtras,
81
+ } = {}) {
82
+ if (!U) throw new Error('createHouseKit: shapes (createUnitShapes) are required');
83
+ const palette = Object.freeze({ ...HOUSE_PALETTE, ...ownPalette }),
84
+ courtyard = Object.freeze({ ...COURTYARD_PALETTE, ...ownCourtyard }),
85
+ lump = KIT_LUMP,
86
+ TIMBERS = palette.timbers,
87
+ SHUT = palette.shutters;
88
+ const frame = createKitFrame(),
89
+ { kitFrame, kitPush, kitPop, kitNew } = frame;
90
+ const openings = createHouseKitOpenings({ U, kitFrame, palette, lump }),
91
+ roofs = createHouseKitRoofs({ U, kitPush, kitPop, palette, kitWindow: openings.kitWindow }),
92
+ { kitBody } = createHouseKitBody({ U, palette, openings }),
93
+ builtIn = createHouseKitForms({ U, kitPush, kitPop, palette, openings, roofs, kitBody }),
94
+ more = createHouseKitExtras({ U, kitPush, kitPop, palette, lump, kitBarrel: openings.kitBarrel }),
95
+ parts = createCourtyardParts({ U, palette }),
96
+ roof = createCourtyardRoof({ U, kitPush, kitPop, palette, parts }),
97
+ { kitCourtyardHouse } = createCourtyardHouse({ U, kitPush, kitPop, palette, courtyard, parts, roof });
98
+ const forms = Object.assign(Object.create(null), builtIn, { courtyard: kitCourtyardHouse }, ownForms),
99
+ builds = Object.assign(Object.create(null), more.builds, ownBuilds),
100
+ extras = Object.assign(Object.create(null), more.extras, ownExtras);
101
+ const formOf = name => {
102
+ let f = forms[name];
103
+ for (let hops = 0; typeof f === 'string' && hops < 8; hops++) f = forms[f];
104
+ return typeof f === 'function' ? f : forms.gable;
105
+ };
106
+
107
+ // Tags what the kit's builders take from here on with the house's height (the shaders' lit windows and street light): left
108
+ // so after the house, for what its builder adds round it.
109
+ function tagKit(kit, s) {
110
+ const tag = s.streetLit ? s.y : s.y - 1000;
111
+ for (const k of KIT_KEYS) kit[k].tv = tag;
112
+ }
113
+ // One building from its spec. A kit that hands houses to workers (`kit.toPool`) may take the house to be built there instead.
114
+ function genHouse(kit, s) {
115
+ if (kit.toPool?.(s)) return;
116
+ const rand = mulberry32(s.seed),
117
+ st = styles[s.style] ?? PLAIN_HOUSE_STYLE;
118
+ tagKit(kit, s);
119
+ if (s.build) {
120
+ kitPush(s.x, s.y, s.z, s.rot || 0);
121
+ (builds[s.build] ?? s.build)(kit, rand, s);
122
+ kitPop();
123
+ return;
124
+ } // street furniture and roof clutter that is only worth building near the viewer
125
+ kitPush(s.x, s.y, s.z, s.rot, s.lean || 0);
126
+ const house = {
127
+ R: rand, // the house's own random stream; other builders pass their own as R
128
+ st,
129
+ col: s.col,
130
+ rc: s.rc,
131
+ tim: C(st.timberColour ?? TIMBERS[Math.floor(hash(Math.round(s.x), Math.round(s.z), 17) * TIMBERS.length)], 0.2, rand),
132
+ frame: C(st.frame, 0.14, rand),
133
+ trim: C(st.trim, 0.08, rand),
134
+ plinth: C(st.plinthColour ?? 0x6f6a60, 0.1, rand),
135
+ chim: C(st.chimneyColour ?? 0x7a6f62, 0.12, rand),
136
+ shut: C(pickR(rand, SHUT), 0.12, rand),
137
+ hasShut: rand() < st.shutters,
138
+ litP: s.litP ?? st.litShare ?? 0.32,
139
+ rubble: !!s.rubble, // its walls of rubble stone, unplastered
140
+ };
141
+ const bodyOpts = {
142
+ n: s.n,
143
+ center: s.center,
144
+ noBal: s.noBal,
145
+ party: s.party,
146
+ shop: s.shop,
147
+ arch: s.arch,
148
+ found: s.found,
149
+ lite: s.lite,
150
+ doorCol: s.doorCol,
151
+ timber: s.timber,
152
+ };
153
+ (s.ruin < 1 ? forms.ruin : formOf(s.form))(kit, house, s, bodyOpts);
154
+ if (s.extra) (extras[s.extra] ?? s.extra)(kit, house, s);
155
+ kitPop();
156
+ }
157
+ // Houses from plain specs, as a worker builds them, or the page when there is none: each kit's arrays, where each house
158
+ // ends in them, and the lit windows each puts on the street. `frames`: for each house, the kit's frame it was placed in
159
+ // (kitFrame's numbers), where its builder had moved it; none, where it had not. `build`: lean, built for the middle
160
+ // distance, and kinds, the kinds of the kit wanted (kitNew: the others come back empty); padded, four bytes to a normal
161
+ // and a colour (GB.parts).
162
+ function housesFromSpecs(specs, frames = [], build = {}) {
163
+ const B = kitNew(build.lean, build.kinds),
164
+ ends = [],
165
+ lit = [],
166
+ before = kitFrame.clone();
167
+ specs.forEach((spec, i) => {
168
+ const from = openings.litWindowCount();
169
+ if (frames[i]) kitFrame.fromArray(frames[i]);
170
+ else kitFrame.copy(before);
171
+ genHouse(B, spec);
172
+ ends.push(kitCounts(B));
173
+ lit.push(openings.takeLitWindows(from));
174
+ });
175
+ kitFrame.copy(before);
176
+ return { kits: KIT_KEYS.map(k => B[k].parts(true, build.padded)), ends, lit };
177
+ }
178
+
179
+ return {
180
+ ...frame,
181
+ ...openings,
182
+ ...roofs,
183
+ ...parts,
184
+ ...roof,
185
+ KIT_KEYS,
186
+ kitCounts,
187
+ facePut,
188
+ litAt,
189
+ kitBody,
190
+ kitCourtyardHouse,
191
+ propWashing: more.propWashing,
192
+ genHouse,
193
+ housesFromSpecs,
194
+ tagKit,
195
+ forms,
196
+ builds,
197
+ extras,
198
+ palette,
199
+ courtyard,
200
+ lump,
201
+ };
202
+ }
@@ -51,10 +51,10 @@ export function indexParts(parts) {
51
51
  return packed;
52
52
  }
53
53
 
54
- function sameVertex(attributes, a, b) {
54
+ function sameVertex(attributes, firstVertex, secondVertex) {
55
55
  for (let i = 0; i < attributes.length; i++) {
56
56
  const { source, stride } = attributes[i];
57
- for (let j = 0; j < stride; j++) if (source[a * stride + j] !== source[b * stride + j]) return false;
57
+ for (let j = 0; j < stride; j++) if (source[firstVertex * stride + j] !== source[secondVertex * stride + j]) return false;
58
58
  }
59
59
  return true;
60
60
  }
@@ -2,33 +2,33 @@
2
2
  // visible records occupy the front of the arrays. The original full bounds stay valid.
3
3
  export function createInstanceVisibility(mesh) {
4
4
  const slots = Uint32Array.from({ length: mesh.count }, (_, i) => i);
5
- const ids = slots.slice();
5
+ const logicalIds = slots.slice();
6
6
  const attributes = [mesh.instanceMatrix];
7
7
  if (mesh.instanceColor) attributes.push(mesh.instanceColor);
8
8
  if (!mesh.boundingSphere) mesh.computeBoundingSphere();
9
9
  return function show(id, visible) {
10
- if (!Number.isInteger(id) || id < 0 || id >= ids.length) throw new RangeError('Unknown instance id');
10
+ if (!Number.isInteger(id) || id < 0 || id >= logicalIds.length) throw new RangeError('Unknown instance id');
11
11
  const from = slots[id];
12
12
  if (from < mesh.count === visible) return;
13
13
  const to = visible ? mesh.count++ : --mesh.count;
14
14
  if (from === to) return;
15
- const other = ids[to];
16
- ids[from] = other;
15
+ const other = logicalIds[to];
16
+ logicalIds[from] = other;
17
17
  slots[other] = from;
18
- ids[to] = id;
18
+ logicalIds[to] = id;
19
19
  slots[id] = to;
20
20
  for (const attribute of attributes) {
21
21
  const { array, itemSize } = attribute;
22
- const a = from * itemSize,
23
- b = to * itemSize;
22
+ const sourceOffset = from * itemSize,
23
+ destinationOffset = to * itemSize;
24
24
  for (let i = 0; i < itemSize; i++) {
25
- const value = array[a + i];
26
- array[a + i] = array[b + i];
27
- array[b + i] = value;
25
+ const value = array[sourceOffset + i];
26
+ array[sourceOffset + i] = array[destinationOffset + i];
27
+ array[destinationOffset + i] = value;
28
28
  }
29
29
  // Include the hidden slot: it can become visible by growing count without another swap.
30
- const start = Math.min(a, b),
31
- end = Math.max(a, b) + itemSize;
30
+ const start = Math.min(sourceOffset, destinationOffset),
31
+ end = Math.max(sourceOffset, destinationOffset) + itemSize;
32
32
  const range = attribute.updateRanges[0];
33
33
  if (range) {
34
34
  const limit = Math.max(end, range.start + range.count);
@@ -7,14 +7,14 @@ import { markStill } from '../rendering/still-casters.js';
7
7
  // (instanceArrays, putInstance), and the instanced meshes the page draws from them (instancedMesh, instancedTwin).
8
8
  // ════════════════════════════════════════════════════════════════════════
9
9
 
10
- // The arrays of `n` copies: a matrix and a linear colour to each, filled by putInstance.
11
- const instanceArrays = n => ({ matrices: new Float32Array(n * 16), colours: new Float32Array(n * 3) });
12
- // Copy `i` of `arrays`: placed by `matrix` (TRS), tinted (r, g, b), as InstancedMesh.setMatrixAt and setColorAt would write them.
13
- function putInstance(arrays, i, matrix, r, g, b) {
14
- matrix.toArray(arrays.matrices, i * 16);
15
- arrays.colours[i * 3] = r;
16
- arrays.colours[i * 3 + 1] = g;
17
- arrays.colours[i * 3 + 2] = b;
10
+ // Allocate space for one matrix and one linear RGB colour per instance.
11
+ const instanceArrays = instanceCount => ({ matrices: new Float32Array(instanceCount * 16), colours: new Float32Array(instanceCount * 3) });
12
+ // Write the transform and linear RGB colour at instanceIndex in Three.js buffer order.
13
+ function putInstance(arrays, instanceIndex, matrix, red, green, blue) {
14
+ matrix.toArray(arrays.matrices, instanceIndex * 16);
15
+ arrays.colours[instanceIndex * 3] = red;
16
+ arrays.colours[instanceIndex * 3 + 1] = green;
17
+ arrays.colours[instanceIndex * 3 + 2] = blue;
18
18
  }
19
19
  // An instanced mesh of `geometry` drawn at the copies of `arrays`. It is made empty and then given them, so that it does not
20
20
  // first write a matrix of its own for every copy only to have it replaced.
@@ -46,15 +46,15 @@ class Copies {
46
46
  this.matrices = [];
47
47
  this.colours = [];
48
48
  }
49
- add(shape, col, m) {
49
+ add(shape, color, transform) {
50
50
  if (shape !== this.shape) throw new Error('Copies hold one shape');
51
- const e = m.elements;
52
- this.matrices.push(...e);
51
+ const elements = transform.elements;
52
+ this.matrices.push(...elements);
53
53
  const at = this.matrices.length - 4; // the translation, moved to the builder's origin
54
54
  this.matrices[at] += this.ox;
55
55
  this.matrices[at + 1] += this.oy;
56
56
  this.matrices[at + 2] += this.oz;
57
- this.colours.push(col[0], col[1], col[2]);
57
+ this.colours.push(color[0], color[1], color[2]);
58
58
  }
59
59
  // The instanced mesh of the copies under `parent`, standing still, casting a shadow unless told not to; the lists are let go.
60
60
  mesh(material, parent, shadow = true) {
@@ -82,17 +82,17 @@ export function partitionInstances(arrays, cellSize) {
82
82
  const { matrices, colours } = arrays;
83
83
  const cells = new Map();
84
84
  for (let i = 0; i < matrices.length / 16; i++) {
85
- const k = Math.floor(matrices[i*16+12] / cellSize) + ',' + Math.floor(matrices[i*16+14] / cellSize);
86
- let ids = cells.get(k);
87
- if (!ids) cells.set(k, ids = []);
85
+ const cellKey = Math.floor(matrices[i * 16 + 12] / cellSize) + ',' + Math.floor(matrices[i * 16 + 14] / cellSize);
86
+ let ids = cells.get(cellKey);
87
+ if (!ids) cells.set(cellKey, (ids = []));
88
88
  ids.push(i);
89
89
  }
90
90
  if (cells.size < 2) return matrices.length ? [arrays] : [];
91
91
  return Array.from(cells.values(), ids => {
92
92
  const cell = instanceArrays(ids.length);
93
93
  ids.forEach((id, i) => {
94
- cell.matrices.set(matrices.subarray(id*16,id*16+16), i*16);
95
- cell.colours.set(colours.subarray(id*3,id*3+3), i*3);
94
+ cell.matrices.set(matrices.subarray(id * 16, id * 16 + 16), i * 16);
95
+ cell.colours.set(colours.subarray(id * 3, id * 3 + 3), i * 3);
96
96
  });
97
97
  return cell;
98
98
  });