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,205 @@
1
+ /**
2
+ * Gaze: where people's heads turn. In a scene everyone looks at whoever last spoke, moved or struck (the director names them
3
+ * with `heed`), and that person looks at whoever held the stage before, or at the nearest of the others: so in a closer shot
4
+ * the speaker looks at the one spoken to, not past the lens. Someone with nobody to watch glances about now and then, each on a
5
+ * rhythm of their own. A script can also say what somebody looks at (`a.watch`: the moon, a coin spinning in the air). A head
6
+ * turns as far as a neck allows; what is behind is left alone. Angles are radians, distances metres.
7
+ * @module
8
+ */
9
+ import { TAU, clamp } from '../math/scalar.js';
10
+ import { createHash } from '../math/random.js';
11
+
12
+ const SIDEWAYS = 0.95, // as far as a head turns to either side, in radians
13
+ BEHIND = 1.9, // beyond this off the facing, a thing is behind and not looked at
14
+ UP = 0.45, // as far as a head tips up, and down
15
+ DOWN = 0.38,
16
+ TOO_NEAR = 1.2, // metres within which a thing is not looked at (it is the looker's own place)
17
+ IN_EARSHOT = 14, // the one spoken to is within this many metres
18
+ THREAT_NEAR = 8.5, // metres within which a sudden weapon draw or lunge startles onlookers
19
+ EYES = 0.88, // the eyes' height, as a share of the figure's
20
+ GLANCE_EVERY = 3.2, // seconds between glances, at the least, and how much longer for the most placid
21
+ GLANCE_SPREAD = 3.5,
22
+ GLANCE = 0.55; // how far a glance goes to either side
23
+ const MAX_CAST = 64;
24
+ /**
25
+ * The gaze of a world's people: one stage, on which a scene's players watch each other.
26
+ * @param {object} [options]
27
+ * @param {function(number, number, number=): number} [options.hash] - A repeatable hash in [0, 1) of two integers and a seed
28
+ * (math/random.js createHash), which times each one's glances. Defaults to createHash(0).
29
+ * @returns {object} gaze: the stage ({ on, at, cast, who, was, ... }, read by those who place onlookers); heed(a): actor a does
30
+ * something now and holds the stage; setGaze(cast, at): a scene begins with its players (and the point its camera looks at,
31
+ * for when nobody has acted yet), or ends (null); lookOf(a, i, t): where the head of actor a (the i-th) turns at time t
32
+ * (seconds) from its body's facing ({ yaw, pitch, handoffAge, threatAge, threatYaw }, shared by every call). An actor's
33
+ * `x`, `y`, `z`, `yaw`, `height`, `pose`, `seed`, `inScene`, `active`, `space`, `watch`, `lookAt`, `act`, `fx_` and
34
+ * `armed` are read.
35
+ */
36
+ function createFigureGaze({ hash = createHash() } = {}) {
37
+ const gaze = {
38
+ on: false, // a scene is playing
39
+ at: null, // what its camera looks at, for when nobody has acted yet
40
+ cast: [], // its players
41
+ who: null, // the one who holds the stage,
42
+ was: null, // and the one who held it before
43
+ seq: 0, // incremented on each speaker/action handoff after the first
44
+ seenSeq: 0,
45
+ handoffAt: -10, // scene clock when the active speaker last changed
46
+ threatAt: -10, // scene clock when a nearby cast member last drew a blade or lunged
47
+ threatWho: null,
48
+ threatX: 0,
49
+ threatZ: 0,
50
+ };
51
+ const look = { yaw: 0, pitch: 0, handoffAge: -1, threatAge: -1, threatYaw: 0 }; // where a head turns and reacts, as lookOf leaves it
52
+ const _castFlags = new Uint8Array(MAX_CAST);
53
+ let _frameTime = -1,
54
+ _castPrimed = false;
55
+
56
+ // The director: actor a does something now, and holds the stage.
57
+ function heed(a) {
58
+ if (!a || a === gaze.who) return;
59
+ if (gaze.who) gaze.seq++;
60
+ gaze.was = gaze.who;
61
+ gaze.who = a;
62
+ }
63
+ // A scene begins (with its players) or ends (with none).
64
+ function setGaze(cast, at) {
65
+ gaze.on = !!cast;
66
+ gaze.cast = cast || [];
67
+ gaze.at = at || null;
68
+ gaze.who = gaze.was = null;
69
+ gaze.seq = gaze.seenSeq = 0;
70
+ gaze.handoffAt = gaze.threatAt = -10;
71
+ gaze.threatWho = null;
72
+ _frameTime = -1;
73
+ _castPrimed = false;
74
+ _castFlags.fill(0);
75
+ }
76
+
77
+ // Tracks speaker handoff timestamps and detects newly started weapon draws or strikes once per frame.
78
+ function pollStageEvents(t) {
79
+ if (t === _frameTime) return;
80
+ _frameTime = t;
81
+ if (gaze.seq !== gaze.seenSeq) {
82
+ gaze.seenSeq = gaze.seq;
83
+ gaze.handoffAt = t;
84
+ }
85
+ const cast = gaze.cast,
86
+ count = Math.min(cast.length, MAX_CAST);
87
+ for (let k = 0; k < count; k++) {
88
+ const o = cast[k];
89
+ if (!o) continue;
90
+ const drawing = o.act && o.act.A && o.act.A.slide && o.act.A.slide.out > 0 ? 1 : 0,
91
+ striking = o.pose === 'strike' || !!(o.fx_ && o.fx_.busy) ? 2 : 0,
92
+ armed = o.armed ? 4 : 0,
93
+ mask = drawing | striking | armed,
94
+ prev = _castFlags[k];
95
+ if (_castPrimed && o.active && ((mask & 3 & ~prev) !== 0 || ((mask & 4) !== 0 && (prev & 4) === 0))) {
96
+ gaze.threatAt = t;
97
+ gaze.threatWho = o;
98
+ gaze.threatX = o.x;
99
+ gaze.threatZ = o.z;
100
+ }
101
+ _castFlags[k] = mask;
102
+ }
103
+ _castPrimed = true;
104
+ }
105
+ const watchable = (o, a) => o && o !== a && o.active && o.space === a.space;
106
+ // Whom the one who holds the stage looks at: the one who held it before, if near, or else the nearest of the others.
107
+ function addressed(a) {
108
+ if (watchable(gaze.was, a) && Math.hypot(gaze.was.x - a.x, gaze.was.z - a.z) < IN_EARSHOT) return gaze.was;
109
+ let best = null,
110
+ near = IN_EARSHOT;
111
+ for (const o of gaze.cast) {
112
+ if (!watchable(o, a) || o.pose === 'dead') continue;
113
+ const d = Math.hypot(o.x - a.x, o.z - a.z);
114
+ if (d < near) {
115
+ near = d;
116
+ best = o;
117
+ }
118
+ }
119
+ return best;
120
+ }
121
+ // Where the head of actor a (the i-th) turns at time t, from its body's facing: look.yaw to the side, look.pitch up,
122
+ // plus active speaker-handoff and nearby threat timing for whole-body listening and startle micro-reactions.
123
+ function lookOf(a, i, t) {
124
+ look.yaw = look.pitch = look.threatYaw = 0;
125
+ look.handoffAge = look.threatAge = -1;
126
+ if (a.pose === 'dead') return look;
127
+ if (a.inScene && gaze.on) {
128
+ pollStageEvents(t);
129
+ if (a !== gaze.who && gaze.handoffAt >= 0 && t >= gaze.handoffAt) look.handoffAge = t - gaze.handoffAt;
130
+ const threatAge = gaze.threatAt >= 0 && t >= gaze.threatAt ? t - gaze.threatAt : -1;
131
+ if (threatAge >= 0 && threatAge < 0.75 && gaze.threatWho !== a && !(a.fx_ && a.fx_.busy)) {
132
+ const tx = gaze.threatX - a.x,
133
+ tz = gaze.threatZ - a.z,
134
+ td = Math.hypot(tx, tz);
135
+ if (td > 0.2 && td < THREAT_NEAR) {
136
+ let rel = Math.atan2(tx, tz) - a.yaw;
137
+ rel -= Math.round(rel / TAU) * TAU;
138
+ if (Math.abs(rel) < BEHIND) {
139
+ look.threatAge = threatAge;
140
+ look.threatYaw = rel;
141
+ }
142
+ }
143
+ }
144
+ }
145
+ const n = Math.floor(t / (GLANCE_EVERY + GLANCE_SPREAD * a.seed) + a.seed * 17);
146
+ look.yaw = hash(n, i, 31) < 0.45 ? 0 : (hash(n, i, 32) - 0.5) * 2 * GLANCE;
147
+ let x = 0,
148
+ y = 0,
149
+ z = 0,
150
+ found = false;
151
+ if (a.watch) {
152
+ // told by the script what to look at: a person, or a point in the air
153
+ x = a.watch.x;
154
+ z = a.watch.z;
155
+ y = a.watch.height ? a.watch.y + a.watch.height * EYES : a.watch.y;
156
+ found = true;
157
+ } else if (a.inScene && gaze.on) {
158
+ // Listeners linger briefly on the previous speaker across a handoff and occasionally check back during dialogue.
159
+ const lingerPrev =
160
+ a !== gaze.who && a !== gaze.was && look.handoffAge >= 0 && look.handoffAge < 0.14 + 0.1 * a.seed && watchable(gaze.was, a),
161
+ checkOther = a !== gaze.who && (lingerPrev || (hash(n, i, 37) < 0.22 && watchable(gaze.was, a))),
162
+ threatFocus = look.threatAge >= 0 && look.threatAge < 0.42 && watchable(gaze.threatWho, a),
163
+ o = threatFocus ? gaze.threatWho : a === gaze.who ? addressed(a) : checkOther ? gaze.was : gaze.who;
164
+ if (watchable(o, a)) {
165
+ x = o.x;
166
+ z = o.z;
167
+ const eyeShare =
168
+ o.pose === 'dead' || o.pose === 'lie' || o.pose === 'prone'
169
+ ? 0.12
170
+ : o.pose === 'kneel' || o.pose === 'sit' || o.pose === 'sittalk'
171
+ ? 0.62
172
+ : o.pose === 'crouch' || o.pose === 'rest' || o.pose === 'cower'
173
+ ? 0.55
174
+ : EYES;
175
+ y = o.y + o.height * eyeShare;
176
+ found = true;
177
+ } else if (gaze.at && a !== gaze.who) {
178
+ x = gaze.at.x;
179
+ y = gaze.at.y;
180
+ z = gaze.at.z;
181
+ found = true;
182
+ }
183
+ } else if (a.lookAt) {
184
+ x = a.lookAt.x;
185
+ z = a.lookAt.z;
186
+ y = a.lookAt.y ?? a.y + a.height * EYES;
187
+ found = true;
188
+ }
189
+ if (!found) return look;
190
+ const dx = x - a.x,
191
+ dz = z - a.z,
192
+ far = Math.hypot(dx, dz);
193
+ if (far < TOO_NEAR) return look;
194
+ let off = Math.atan2(dx, dz) - a.yaw;
195
+ off -= Math.round(off / TAU) * TAU;
196
+ if (Math.abs(off) > BEHIND) return look;
197
+ look.yaw = look.yaw * 0.2 + clamp(off, -SIDEWAYS, SIDEWAYS) * 0.9;
198
+ look.pitch = clamp(Math.atan2(y - (a.y + a.height * EYES), far), -DOWN, UP) * 0.85;
199
+ return look;
200
+ }
201
+
202
+ return { gaze, heed, lookOf, setGaze };
203
+ }
204
+
205
+ export { createFigureGaze };
@@ -0,0 +1,452 @@
1
+ /**
2
+ * Gestures: what the arms, the trunk and the head of a person's figure do in a pose beyond holding it. A pose
3
+ * (figure-pose-table.js) is a stance; this gives it life: someone speaking marks their words with one hand and then the other
4
+ * way, from a small store of gestures taken in an order of their own; hands that reach work at what they reach for; a load is
5
+ * cradled on bent arms; a pointing arm goes out straight while the other hand rests; a crossbow is levelled, hands are held to
6
+ * a fire, a page is read. Every channel moves on a damped spring with proximal-to-distal lag so shoulders lead elbows and
7
+ * wrists in natural arcs. Angles are radians; lengths figure units (a figure of full size stands 1.9 m).
8
+ * @module
9
+ */
10
+ import { stepGestureSprings } from './action-dynamics.js';
11
+ import { createHash } from '../math/random.js';
12
+
13
+ /**
14
+ * The parts a gesture (and an act, figure-acts.js) moves, as places in its array of PARTS values:
15
+ * upper arms (left, right; less is further forward and up), arms out from the sides (left: more is inward; right: less is),
16
+ * elbows (less is more bent), the trunk's lean forward, the head's nod; the upper arms' turn about their own length (left:
17
+ * more turns the forearm inward; right: less does), the head's turn and tilt, the trunk's twist, the hips lowered (SINK, in
18
+ * figure units) and shifted forward (SHIFT), the shoulders lifted (SHRUG, 0 to 1), the thighs of legs that are not standing
19
+ * (a climber's, a crawler's), and the trunk bent forward at the
20
+ * waist over hips that stay where they are (BEND: a bow, a stoop; LEAN tips the whole figure from the feet, as a run does).
21
+ */
22
+ const LA = 0,
23
+ RA = 1,
24
+ LZ = 2,
25
+ RZ = 3,
26
+ FL = 4,
27
+ FR = 5,
28
+ LEAN = 6,
29
+ NOD = 7,
30
+ LY = 8,
31
+ RY = 9,
32
+ TURN = 10,
33
+ TILT = 11,
34
+ TWIST = 12,
35
+ SINK = 13,
36
+ SHIFT = 14,
37
+ SHRUG = 15,
38
+ LL = 16,
39
+ LR = 17,
40
+ BEND = 18,
41
+ PARTS = 19;
42
+
43
+ // Per-channel spring frequency multipliers: trunk leads, shoulders follow, elbows and forearm/wrist turns trail slightly.
44
+ const CHANNEL_SCALE = new Float32Array([
45
+ 0.98, // LA
46
+ 0.98, // RA
47
+ 0.96, // LZ
48
+ 0.96, // RZ
49
+ 0.84, // FL
50
+ 0.84, // FR
51
+ 1.08, // LEAN
52
+ 0.92, // NOD
53
+ 0.75, // LY
54
+ 0.75, // RY
55
+ 0.9, // TURN
56
+ 0.88, // TILT
57
+ 1.08, // TWIST
58
+ 1.05, // SINK
59
+ 1.05, // SHIFT
60
+ 0.95, // SHRUG
61
+ 0.95, // LL
62
+ 0.95, // LR
63
+ 1.0, // BEND
64
+ ]);
65
+
66
+ // What someone speaking does with the hands, a beat at a time: [right upper arm, right elbow, left upper arm, left elbow, right arm out, nod, right turn].
67
+ // People talking keep their elbows by their sides and speak with their forearms: the hand works between the belt and the
68
+ // breastbone, a forearm's length before the body, and falls back to the side between thoughts. An upper arm lifted from the
69
+ // shoulder holds the hand up at the height of the face, where it reads as a hand holding something up.
70
+ const SPOKEN = [
71
+ [-0.16, -1.15, 0, 0, -0.05, 0.05, -0.3], // the open hand offered, at the belt
72
+ [-0.26, -0.95, 0, 0, -0.03, 0.1, -0.12], // a point made, the hand coming down on it
73
+ [-0.14, -1.1, -0.14, -1.05, -0.08, 0.03, -0.26], // both hands, weighing
74
+ [-0.03, -0.18, 0, 0, 0, -0.03, 0], // the hand let fall between two thoughts
75
+ [-0.2, -1.95, 0, 0, 0.1, 0.06, -0.75], // the hand to the chest
76
+ [-0.08, -0.8, -0.06, -0.7, -0.12, 0, -0.3], // a shrug of the forearms
77
+ ],
78
+ BEAT = 2.4, // seconds a spoken gesture is held, give or take a third
79
+ SPOKEN_REST = 0.45, // the share of beats in which the hands rest while the voice goes on
80
+ FREQ = 10.2, // spring natural frequency (rad/s) for brisk gestures,
81
+ FREQ_SPOKEN = 5.6, // and one made while speaking, which flows from the last
82
+ FREQ_HABIT = 4.4, // and a habit of someone at ease, which is in no hurry
83
+ GUARD_WEAVE = 0.07, // how far a guard's arm drifts, up and down and at the elbow
84
+ GUARD_ELBOW = -1.02; // and how far its elbow is bent beyond a hanging arm's
85
+ // What someone standing at ease does with the hands now and then:
86
+ // [left upper arm, left elbow, left out, left turn, right upper arm, right elbow, right out, right turn, nod]
87
+ const HABITS = [
88
+ [-0.1, -0.85, -0.1, 0.25, 0, 0, 0, 0, 0], // a hand at the belt
89
+ [-0.1, -0.85, -0.1, 0.25, -0.1, -0.85, 0.1, -0.25, 0], // both thumbs in the belt
90
+ [0, 0, 0, 0, -0.52, -2.3, 0, -0.5, 0.07], // a hand to the chin
91
+ [-0.4, -1.6, 0.04, 1.0, -0.34, -1.68, -0.04, -1.0, 0], // the arms folded
92
+ [0.32, -0.7, 0.04, 1.45, 0.32, -0.7, -0.04, -1.45, -0.03], // the hands clasped behind the back
93
+ ],
94
+ HABITS_IN_SCENE = 0, // while a scene plays, none: what a hand does there is the script's to say, and a forearm held out at the belt reads as a hand holding something
95
+ HABIT_EVERY = 11, // seconds between habits at the least, and how much longer for the most placid
96
+ HABIT_SPREAD = 13,
97
+ HABIT_HELD = 0.42; // the share of that time a habit is kept
98
+ /**
99
+ * The gestures of a world's people, which draw what each does when from a seeded hash.
100
+ * @param {object} [options]
101
+ * @param {function(number, number, number=): number} [options.hash] - A repeatable hash in [0, 1) of two integers and a seed
102
+ * (math/random.js createHash); the world's own makes its people's habits its own. Defaults to createHash(0).
103
+ * @returns {{gestureOf: function(object, number, number, boolean, boolean): Float32Array}} gestureOf(a, t, dt, other,
104
+ * walking): the gesture of actor a at time t (seconds), eased by dt: an array of PARTS values to add to its pose (kept on
105
+ * the actor as `a.ges`). `other` is true when the right hand is taken (a planted staff): the left then does what the right
106
+ * would; `walking` while it strides. The actor's `pose`, `seed`, `phase`, `inScene`, `mount`, `move`, `feet` and `hip` are
107
+ * read; `ges` and `gesDraw` are kept on it.
108
+ */
109
+ function createFigureGestures({ hash = createHash() } = {}) {
110
+ const _to = new Float32Array(PARTS);
111
+ // The draws and spring velocities a gesture keeps on the actor (a.gesDraw) with zero per-frame allocations.
112
+ const drawsOf = a => (a.gesDraw ??= { beat: NaN, spoken: NaN, turn: NaN, rest: NaN, habit: NaN, vel: new Float32Array(PARTS) });
113
+
114
+ // Both arms, mirrored: the upper arms to `arm`, out from the sides by `out`, the elbows to `elbow`, turned in by `turn`.
115
+ function bothArms(arm, elbow, out = 0, turn = 0) {
116
+ _to[LA] = _to[RA] = arm;
117
+ _to[FL] = _to[FR] = elbow;
118
+ _to[LZ] = -out;
119
+ _to[RZ] = out;
120
+ _to[LY] = turn;
121
+ _to[RY] = -turn;
122
+ }
123
+ // What a person at ease does this moment, if anything: one of their two habits, for a while, then nothing for a longer while.
124
+ function habit(a, t) {
125
+ const every = HABIT_EVERY + HABIT_SPREAD * a.seed,
126
+ at = t / every + a.seed * 5,
127
+ n = Math.floor(at);
128
+ if (at - n > HABIT_HELD) return;
129
+ const d = drawsOf(a);
130
+ if (d.turn !== n) {
131
+ d.turn = n;
132
+ d.rest = hash(n, a.seed * 53);
133
+ d.habit = hash(n % 2, a.seed * 71);
134
+ }
135
+ if (d.rest < 0.3) return;
136
+ const store = a.inScene ? HABITS_IN_SCENE : HABITS.length;
137
+ if (!store) return;
138
+ const h = HABITS[Math.floor(d.habit * store) % store];
139
+ _to[LA] = h[0];
140
+ _to[FL] = h[1];
141
+ _to[LZ] = h[2];
142
+ _to[LY] = h[3];
143
+ _to[RA] = h[4];
144
+ _to[FR] = h[5];
145
+ _to[RZ] = h[6];
146
+ _to[RY] = h[7];
147
+ _to[NOD] = h[8];
148
+ }
149
+ // The gesture of actor a at time t, eased by dt (see createFigureGestures).
150
+ function gestureOf(a, t, dt, other, walking) {
151
+ const g = (a.ges ??= new Float32Array(PARTS)),
152
+ d = drawsOf(a),
153
+ pose = walking && a.pose !== 'carry' && a.pose !== 'crawl' && a.pose !== 'climb' && a.pose !== 'guard' ? 'walk' : a.pose;
154
+ if (a.feet === null && Number.isNaN(a.hip)) d.vel.fill(0);
155
+ let freq = FREQ;
156
+ _to.fill(0);
157
+ if (pose === 'talk') {
158
+ const beat = BEAT * (0.75 + 0.5 * a.seed),
159
+ beats = t / beat + a.seed * 7,
160
+ at = Math.floor(beats),
161
+ frac = beats - at;
162
+ if (d.beat !== at) {
163
+ d.beat = at;
164
+ d.spoken = hash(at, a.seed * 91);
165
+ }
166
+ const pick = d.spoken,
167
+ s = pick < SPOKEN_REST ? SPOKEN[3] : SPOKEN[Math.floor(((pick - SPOKEN_REST) / (1 - SPOKEN_REST)) * SPOKEN.length) % SPOKEN.length],
168
+ anticipation = frac < 0.14 ? -Math.sin((frac / 0.14) * Math.PI) * 0.045 : 0,
169
+ stress = Math.max(0, Math.sin(frac * Math.PI)) ** 2; // each gesture gathers, swells, and settles
170
+ _to[RA] = s[0] - 0.04 * stress - anticipation;
171
+ _to[FR] = s[1] - 0.14 * stress + anticipation * 0.8;
172
+ _to[LA] = s[2];
173
+ _to[FL] = s[3];
174
+ _to[RZ] = s[4];
175
+ _to[RY] = s[6] * (0.65 + 0.35 * stress);
176
+ _to[LY] = s[2] < -0.1 ? -s[6] * 0.6 : 0;
177
+ _to[NOD] = s[5] * stress;
178
+ _to[LEAN] = 0.03 + 0.02 * stress;
179
+ freq = FREQ_SPOKEN;
180
+ if (other) {
181
+ _to[LA] = _to[RA];
182
+ _to[FL] = _to[FR];
183
+ _to[LZ] = -_to[RZ];
184
+ _to[LY] = -_to[RY];
185
+ _to[RA] = _to[FR] = _to[RZ] = _to[RY] = 0;
186
+ }
187
+ } else if (pose === 'guard') {
188
+ // on guard nobody stands still: the point weaves a little, the weight rides on bent knees, the shoulders turn to the foe
189
+ const s = a.seed * 40;
190
+ // The sword hand is held before the belt with the elbow bent and the point up towards the foe's throat, the free hand back
191
+ // by the hip: a blade held out at arm's length, with the other hand out beside it, is a child's guard, and puts two
192
+ // fighters' hands almost together.
193
+ _to[RA] = GUARD_WEAVE * Math.sin(t * 1.3 + s);
194
+ _to[FR] = GUARD_ELBOW + GUARD_WEAVE * Math.sin(t * 1.1 + s * 0.7);
195
+ _to[LA] = 0.5 * GUARD_WEAVE * Math.sin(t * 0.9 + s * 1.3);
196
+ _to[FL] = -0.55;
197
+ _to[LY] = 0.3;
198
+ _to[SINK] = -0.012 - 0.01 * Math.sin(t * 2.1 + s);
199
+ _to[TWIST] = -0.12 + 0.05 * Math.sin(t * 0.7 + s * 0.4);
200
+ _to[NOD] = 0.06;
201
+ freq = FREQ_HABIT;
202
+ } else if (pose === 'reach') {
203
+ // one dominant hand reaches purposefully forward while the off-hand stays bent low as a counterbalance
204
+ const s = a.seed * 20,
205
+ drift = Math.sin(t * 0.9 + s);
206
+ _to[RA] = -0.08 + 0.09 * drift;
207
+ _to[FR] = -0.34 - 0.1 * Math.cos(t * 1.15 + s);
208
+ _to[RY] = -0.18;
209
+ _to[LA] = 0.08 - 0.04 * drift;
210
+ _to[FL] = -0.78;
211
+ _to[LY] = 0.24;
212
+ _to[TWIST] = 0.16 + 0.03 * drift;
213
+ _to[LEAN] = 0.05 + 0.02 * drift;
214
+ _to[NOD] = 0.14;
215
+ if (other) {
216
+ _to[LA] = -0.95 + 0.09 * drift;
217
+ _to[FL] = _to[FR];
218
+ _to[LY] = 0.18;
219
+ _to[RA] = _to[FR] = _to[RY] = 0;
220
+ _to[TWIST] = -_to[TWIST];
221
+ }
222
+ } else if (pose === 'cast') {
223
+ // asymmetric sorcerous channeling: the lead hand shapes the working high while the off-hand anchors lower
224
+ const s = a.seed * 29,
225
+ weave = Math.sin(t * 0.95 + s),
226
+ pulse = Math.cos(t * 1.35 + s * 0.7);
227
+ _to[RA] = 0.14 * weave;
228
+ _to[FR] = -0.58 - 0.16 * pulse;
229
+ _to[RY] = -0.35 + 0.2 * weave;
230
+ _to[LA] = 0.12 - 0.1 * pulse;
231
+ _to[FL] = -1.05 + 0.14 * weave;
232
+ _to[LY] = 0.42;
233
+ _to[TWIST] = -0.14 + 0.06 * weave;
234
+ _to[NOD] = -0.08 + 0.04 * pulse;
235
+ freq = FREQ_SPOKEN;
236
+ } else if (pose === 'strike') {
237
+ // about to cut: the sword arm's elbow bent so the blade lies back over the shoulder, the body coiled away from the foe
238
+ _to[FR] = -1.15;
239
+ _to[FL] = -0.5;
240
+ _to[TWIST] = -0.3;
241
+ _to[NOD] = 0.05;
242
+ } else if (pose === 'cower') {
243
+ // asymmetric defensive cover: one forearm crossed high shielding brow and temple, the other guarding the ribs
244
+ const s = a.seed * 31,
245
+ side = a.seed >= 0.5 ? 1 : -1,
246
+ tremor = Math.sin(t * 6.2 + s) * 0.025;
247
+ _to[LA] = -0.18 + tremor;
248
+ _to[FL] = -1.78;
249
+ _to[LY] = 0.88;
250
+ _to[RA] = 0.08 - tremor;
251
+ _to[FR] = -1.54;
252
+ _to[RY] = -0.66;
253
+ _to[SHRUG] = 0.72;
254
+ _to[TWIST] = 0.22 * side;
255
+ _to[NOD] = 0.34;
256
+ _to[TURN] = 0.32 * side;
257
+ _to[TILT] = 0.14 * side;
258
+ } else if (pose === 'slump' || pose === 'wounded') {
259
+ // wounded or spent: one forearm clutched across the ribs, the other hanging slack, head bowed with heavy breaths
260
+ const s = a.seed * 19,
261
+ heave = Math.sin(t * 1.6 + s);
262
+ _to[LA] = -0.08;
263
+ _to[FL] = -1.58;
264
+ _to[LY] = 0.95;
265
+ _to[FR] = -0.34;
266
+ _to[TWIST] = -0.12;
267
+ _to[SINK] = -0.018 * heave;
268
+ _to[NOD] = 0.28 + 0.04 * heave;
269
+ _to[TILT] = 0.14;
270
+ freq = FREQ_SPOKEN;
271
+ } else if (pose === 'suspended') {
272
+ // held off the ground by sorcery: arched spine, arms drawn out with slack elbows, legs hanging unevenly
273
+ const s = a.seed * 23,
274
+ sway = Math.sin(t * 1.15 + s),
275
+ strain = Math.cos(t * 1.7 + s);
276
+ _to[LA] = 0.1 * sway;
277
+ _to[RA] = -0.08 * strain;
278
+ _to[FL] = -0.58 + 0.1 * strain;
279
+ _to[FR] = -0.44 - 0.1 * sway;
280
+ _to[LL] = -0.22 + 0.08 * sway;
281
+ _to[LR] = 0.08 - 0.07 * strain;
282
+ _to[NOD] = -0.28 + 0.07 * sway;
283
+ _to[TURN] = 0.16 * strain;
284
+ _to[TWIST] = 0.08 * sway;
285
+ freq = FREQ_SPOKEN;
286
+ } else if (pose === 'bound' || pose === 'crucified') {
287
+ // nailed or bound by the wrists along a crossbeam: head sunk on the chest, straining up only for a rare breath
288
+ const s = a.seed * 37,
289
+ lift = Math.max(0, Math.sin(t * 0.52 + s)) ** 3,
290
+ strain = Math.sin(t * 0.85 + s * 1.3);
291
+ _to[FL] = -0.18 - 0.1 * lift;
292
+ _to[FR] = -0.22 - 0.1 * lift;
293
+ _to[LL] = -0.12 - 0.12 * lift;
294
+ _to[LR] = -0.24 - 0.08 * lift;
295
+ _to[NOD] = 0.54 - 0.42 * lift;
296
+ _to[TURN] = 0.22 * strain;
297
+ _to[TILT] = 0.12;
298
+ _to[SHRUG] = 0.45 - 0.2 * lift;
299
+ freq = FREQ_HABIT;
300
+ } else if (pose === 'search') {
301
+ // rummaging through shelves, desks, or packs: one hand steadying while the other shifts and the eyes scan
302
+ const s = a.seed * 27,
303
+ scan = Math.sin(t * 0.95 + s),
304
+ reach = Math.cos(t * 1.45 + s);
305
+ _to[FL] = -0.68;
306
+ _to[LY] = 0.32;
307
+ _to[RA] = -0.16 + 0.22 * scan;
308
+ _to[FR] = -0.84 + 0.26 * reach;
309
+ _to[RY] = -0.28 + 0.2 * scan;
310
+ _to[TWIST] = 0.14 * scan;
311
+ _to[NOD] = 0.24 + 0.07 * reach;
312
+ _to[TURN] = 0.28 * scan;
313
+ freq = FREQ_SPOKEN;
314
+ } else if (pose === 'restrain') {
315
+ // braced lunge holding someone back by shoulder and chest
316
+ const s = a.seed * 17,
317
+ strain = Math.sin(t * 1.9 + s) * 0.04;
318
+ _to[FL] = -0.58 + strain;
319
+ _to[FR] = -0.76 - strain;
320
+ _to[LY] = 0.36;
321
+ _to[RY] = -0.42;
322
+ _to[TWIST] = -0.14;
323
+ _to[NOD] = 0.08;
324
+ } else if (pose === 'lean') {
325
+ // forearms resting along a rail, parapet, or table edge with unhurried weight shifts
326
+ const s = a.seed * 33,
327
+ drift = Math.sin(t * 0.48 + s);
328
+ _to[FL] = -1.22;
329
+ _to[FR] = -1.28;
330
+ _to[LY] = 0.52;
331
+ _to[RY] = -0.48;
332
+ _to[TWIST] = 0.07 * drift;
333
+ _to[NOD] = 0.06 + 0.03 * Math.cos(t * 0.62 + s);
334
+ _to[TILT] = 0.04 * drift;
335
+ freq = FREQ_HABIT;
336
+ } else if (pose === 'carry') {
337
+ // the load lies on the forearms, held against the body
338
+ _to[LA] = _to[RA] = 0.72;
339
+ _to[FL] = _to[FR] = -1.12;
340
+ _to[LEAN] = -0.05;
341
+ } else if (pose === 'point') {
342
+ // the arm straight out to what is shown, the other hand resting at the belt
343
+ _to[FR] = 0.22;
344
+ _to[LA] = -0.12;
345
+ _to[FL] = -0.85;
346
+ _to[LZ] = -0.1;
347
+ _to[LEAN] = 0.03;
348
+ } else if (pose === 'aim') {
349
+ // a crossbow levelled: the stock to the shoulder, the other hand under it, the head down to the sight
350
+ _to[LA] = -1.15;
351
+ _to[FL] = -0.75;
352
+ _to[LY] = 0.5;
353
+ _to[RA] = -1.02;
354
+ _to[FR] = -1.4;
355
+ _to[RY] = -0.35;
356
+ _to[TWIST] = -0.28;
357
+ _to[NOD] = 0.08;
358
+ _to[TILT] = 0.08;
359
+ } else if (pose === 'shoot') {
360
+ // a bow drawn: the bow arm straight out, the string hand back at the jaw, the body side on to the mark
361
+ _to[LA] = -1.5;
362
+ _to[FL] = -0.04;
363
+ _to[RA] = -1.5;
364
+ _to[FR] = -2.35;
365
+ _to[RZ] = -0.3;
366
+ _to[TWIST] = -0.55;
367
+ _to[LEAN] = -0.04;
368
+ } else if (pose === 'read') {
369
+ // a page held up in both hands, the head bent to it, the eyes going down it
370
+ bothArms(-0.72, -1.5, 0, 0.35);
371
+ _to[NOD] = 0.3 + 0.04 * Math.sin(t * 0.6 + a.seed * 9);
372
+ _to[TURN] = 0.07 * Math.sin(t * 1.4 + a.seed * 9);
373
+ } else if (pose === 'write') {
374
+ // the page steadied with one hand, the other moving across it and back
375
+ const line = (t * 0.45 + a.seed) % 1;
376
+ _to[LA] = -0.62;
377
+ _to[FL] = -1.05;
378
+ _to[LY] = 0.5;
379
+ _to[RA] = -0.66 + 0.02 * Math.sin(t * 13);
380
+ _to[FR] = -1.08 + 0.03 * Math.sin(t * 17);
381
+ _to[RY] = -0.42 + 0.3 * line;
382
+ _to[LEAN] = 0.16;
383
+ _to[NOD] = 0.34;
384
+ } else if (pose === 'warm') {
385
+ // the hands held out to a fire, turned and rubbed together now and then
386
+ const rub = Math.max(0, Math.sin(t * 0.5 + a.seed * 30)) ** 4;
387
+ bothArms(-1.02, -0.5, 0, 0.25);
388
+ _to[FL] -= 0.5 * rub;
389
+ _to[FR] -= 0.5 * rub;
390
+ _to[LZ] += 0.08 * rub;
391
+ _to[RZ] -= 0.08 * rub;
392
+ _to[LY] += 0.5 * rub;
393
+ _to[RY] -= 0.5 * rub;
394
+ _to[FL] += 0.1 * rub * Math.sin(t * 9);
395
+ _to[FR] -= 0.1 * rub * Math.sin(t * 9);
396
+ _to[LEAN] = 0.1;
397
+ _to[NOD] = 0.12;
398
+ } else if (pose === 'embrace') {
399
+ // the arms round another, the head beside theirs
400
+ bothArms(-1.25, -1.05, 0.1, 0.95);
401
+ _to[RA] = -1.4;
402
+ _to[LEAN] = 0.1;
403
+ _to[TURN] = 0.35;
404
+ _to[TILT] = 0.14;
405
+ _to[NOD] = 0.1;
406
+ } else if (pose === 'rest') {
407
+ // sitting on the ground, the forearms on the raised knees
408
+ bothArms(-0.95, -0.55, 0, 0.3);
409
+ _to[NOD] = 0.08;
410
+ } else if (pose === 'kneel') {
411
+ // on one knee: the hand of the raised knee's side rests on that knee, the arm a little bent; the other hangs by the hip
412
+ _to[FL] = -0.42;
413
+ _to[LY] = 0.15;
414
+ _to[FR] = -0.22;
415
+ _to[NOD] = 0.06;
416
+ freq = FREQ_HABIT;
417
+ } else if (pose === 'crouch') {
418
+ // down on the haunches, one hand to the ground
419
+ _to[LA] = -0.5;
420
+ _to[FL] = -0.3;
421
+ _to[RA] = -0.75;
422
+ _to[FR] = -1.2;
423
+ _to[NOD] = -0.2;
424
+ } else if (pose === 'crawl' || pose === 'climb') {
425
+ // hand over hand, and the opposite knee with each: over the ground, or up a wall, a ladder or a rope
426
+ const going = walking || a.move ? 1 : 0,
427
+ beat = Math.sin(a.phase * (pose === 'crawl' ? 0.45 : 0.6)) * going,
428
+ up = pose === 'climb';
429
+ _to[LA] = (up ? 0.45 : 0.34) * beat;
430
+ _to[RA] = -_to[LA];
431
+ _to[FL] = up ? -0.75 + 0.6 * beat : -0.1;
432
+ _to[FR] = up ? -0.75 - 0.6 * beat : -0.1;
433
+ _to[LL] = (up ? -0.55 : 0) + (up ? 0.5 : 0.3) * beat;
434
+ _to[LR] = (up ? -0.55 : 0) - (up ? 0.5 : 0.3) * beat;
435
+ _to[NOD] = up ? -0.3 : -0.55;
436
+ freq = 16;
437
+ } else if (pose === 'idle' || pose === 'walk') {
438
+ // nobody's arms hang quite alike: a little more or less bend at each elbow
439
+ _to[FL] = -0.16 * a.seed;
440
+ _to[FR] = -0.16 * (1 - a.seed);
441
+ if (pose === 'idle' && !a.mount) {
442
+ habit(a, t);
443
+ freq = FREQ_HABIT;
444
+ }
445
+ }
446
+ stepGestureSprings(g, d.vel, _to, PARTS, dt, freq, CHANNEL_SCALE);
447
+ return g;
448
+ }
449
+ return { gestureOf };
450
+ }
451
+
452
+ export { BEND, FL, FR, LA, LEAN, LL, LR, LY, LZ, NOD, PARTS, RA, RY, RZ, SHIFT, SHRUG, SINK, TILT, TURN, TWIST, createFigureGestures };