roamwright 0.20.1 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (516) hide show
  1. package/.prettierrc.yaml +12 -0
  2. package/CONTRIBUTING.md +19 -14
  3. package/README.md +35 -16
  4. package/examples/animals.html +49 -0
  5. package/examples/animals.js +209 -0
  6. package/examples/crowds.html +50 -0
  7. package/examples/crowds.js +268 -0
  8. package/examples/effects.html +53 -0
  9. package/examples/effects.js +343 -0
  10. package/examples/figure-motion.html +55 -0
  11. package/examples/figure-motion.js +265 -0
  12. package/examples/figure.html +49 -0
  13. package/examples/figure.js +238 -0
  14. package/examples/fliers.html +53 -0
  15. package/examples/fliers.js +292 -0
  16. package/examples/fortification.html +54 -0
  17. package/examples/fortification.js +288 -0
  18. package/examples/house-kit.html +48 -0
  19. package/examples/house-kit.js +175 -0
  20. package/examples/index.html +26 -16
  21. package/examples/island.html +48 -0
  22. package/examples/island.js +134 -52
  23. package/examples/land.html +54 -0
  24. package/examples/land.js +392 -0
  25. package/examples/props-and-plants.html +53 -0
  26. package/examples/props-and-plants.js +275 -0
  27. package/examples/rooms.html +48 -0
  28. package/examples/rooms.js +242 -0
  29. package/examples/ships.html +51 -0
  30. package/examples/ships.js +235 -0
  31. package/examples/showcase.css +320 -0
  32. package/examples/small-world-land.js +151 -0
  33. package/examples/small-world-life.js +160 -0
  34. package/examples/small-world-town.js +127 -0
  35. package/examples/small-world.html +57 -0
  36. package/examples/small-world.js +226 -0
  37. package/examples/soundscape.html +138 -0
  38. package/examples/soundscape.js +467 -0
  39. package/examples/stage-kits.js +300 -0
  40. package/examples/stage.js +374 -0
  41. package/examples/towns.html +50 -0
  42. package/examples/towns.js +325 -0
  43. package/examples/viaduct-camera.js +8 -4
  44. package/examples/viaduct-landscape.js +28 -17
  45. package/examples/viaduct.html +45 -43
  46. package/examples/viaduct.js +68 -92
  47. package/geometry/animal-camel-body.js +410 -0
  48. package/geometry/animal-camel-head.js +118 -0
  49. package/geometry/animal-canine-body.js +361 -0
  50. package/geometry/animal-canine-breeds.js +316 -0
  51. package/geometry/animal-canine-head.js +337 -0
  52. package/geometry/animal-cattle-body.js +391 -0
  53. package/geometry/animal-cattle-coat.js +42 -0
  54. package/geometry/animal-cattle-head.js +152 -0
  55. package/geometry/animal-hen.js +248 -0
  56. package/geometry/animal-horse-body.js +446 -0
  57. package/geometry/animal-horse-bridle.js +171 -0
  58. package/geometry/animal-horse-coat.js +68 -0
  59. package/geometry/animal-horse-face.js +162 -0
  60. package/geometry/animal-horse-hair.js +304 -0
  61. package/geometry/animal-horse-head.js +133 -0
  62. package/geometry/animal-horse-tack.js +157 -0
  63. package/geometry/animal-options.js +59 -0
  64. package/geometry/animal-shapes.js +21 -0
  65. package/geometry/animal-skin.js +390 -0
  66. package/geometry/builder-cells.js +10 -2
  67. package/geometry/builder-frame.js +2 -1
  68. package/geometry/builder.js +15 -4
  69. package/geometry/card-emblem.js +437 -0
  70. package/geometry/catenary-canvas.js +396 -0
  71. package/geometry/cloth-folds.js +143 -0
  72. package/geometry/crawl-shapes.js +71 -0
  73. package/geometry/creased-sheet.js +7 -2
  74. package/geometry/crowd-dress.js +315 -0
  75. package/geometry/crowd-far.js +174 -0
  76. package/geometry/crowd-look.js +42 -0
  77. package/geometry/crowd-weld.js +218 -0
  78. package/geometry/ear.js +9 -4
  79. package/geometry/erosion.js +7 -4
  80. package/geometry/face-grid.js +26 -6
  81. package/geometry/field-map.js +59 -0
  82. package/geometry/figure-arms.js +339 -0
  83. package/geometry/figure-beard.js +250 -0
  84. package/geometry/figure-body.js +297 -0
  85. package/geometry/figure-bow.js +105 -0
  86. package/geometry/figure-cloak.js +189 -0
  87. package/geometry/figure-clothes.js +337 -0
  88. package/geometry/figure-face-grids.js +75 -0
  89. package/geometry/figure-gear.js +446 -0
  90. package/geometry/figure-hair-far.js +151 -0
  91. package/geometry/figure-hair-hangs.js +108 -0
  92. package/geometry/figure-hair-patch.js +66 -0
  93. package/geometry/figure-hair.js +320 -0
  94. package/geometry/figure-hands.js +321 -0
  95. package/geometry/figure-head-features.js +280 -0
  96. package/geometry/figure-head.js +375 -0
  97. package/geometry/figure-headwear.js +223 -0
  98. package/geometry/figure-legs.js +231 -0
  99. package/geometry/figure-limbs.js +39 -0
  100. package/geometry/figure-sculpt.js +82 -0
  101. package/geometry/figure-skin.js +97 -0
  102. package/geometry/figure-skirts.js +303 -0
  103. package/geometry/figure-trunk.js +411 -0
  104. package/geometry/flier-corvid-body.js +322 -0
  105. package/geometry/flier-corvid-wings.js +154 -0
  106. package/geometry/flier-long-body.js +195 -0
  107. package/geometry/flier-shapes.js +219 -0
  108. package/geometry/flier-soaring-bird.js +84 -0
  109. package/geometry/foliage.js +177 -4
  110. package/geometry/fort-city-walls.js +479 -0
  111. package/geometry/fort-gate-approach.js +233 -0
  112. package/geometry/fort-great-walls.js +280 -0
  113. package/geometry/fort-keep.js +297 -0
  114. package/geometry/fort-parts.js +261 -0
  115. package/geometry/fort-polyline.js +261 -0
  116. package/geometry/fort-portal.js +96 -0
  117. package/geometry/fort-ring-wall.js +267 -0
  118. package/geometry/fort-seawall.js +104 -0
  119. package/geometry/fort-terrace-gates.js +323 -0
  120. package/geometry/fort-terrace-plan.js +250 -0
  121. package/geometry/fort-terrace-wall.js +345 -0
  122. package/geometry/garment-tags.js +11 -3
  123. package/geometry/grid-gather.js +69 -0
  124. package/geometry/grid-sample.js +185 -0
  125. package/geometry/hair-gathers.js +19 -4
  126. package/geometry/hair-locks.js +1 -1
  127. package/geometry/hair-patch.js +6 -2
  128. package/geometry/hair-shell.js +14 -2
  129. package/geometry/head-presets.js +103 -0
  130. package/geometry/head-profile.js +13 -2
  131. package/geometry/head-shape.js +51 -23
  132. package/geometry/heightfield.js +26 -9
  133. package/geometry/horizon-angles.js +166 -0
  134. package/geometry/house-kit-body.js +195 -0
  135. package/geometry/house-kit-courtyard-parts.js +340 -0
  136. package/geometry/house-kit-courtyard-roof.js +223 -0
  137. package/geometry/house-kit-courtyard.js +409 -0
  138. package/geometry/house-kit-cut.js +29 -0
  139. package/geometry/house-kit-extras.js +192 -0
  140. package/geometry/house-kit-forms.js +298 -0
  141. package/geometry/house-kit-frame.js +74 -0
  142. package/geometry/house-kit-marks.js +93 -0
  143. package/geometry/house-kit-openings.js +193 -0
  144. package/geometry/house-kit-palette.js +54 -0
  145. package/geometry/house-kit-pool.js +71 -0
  146. package/geometry/house-kit-roofs.js +151 -0
  147. package/geometry/house-kit.js +202 -0
  148. package/geometry/instances.js +4 -4
  149. package/geometry/lamp-wash.js +65 -0
  150. package/geometry/land-clearings.js +83 -0
  151. package/geometry/land-ditches.js +290 -0
  152. package/geometry/land-dry-basin.js +327 -0
  153. package/geometry/land-dunes.js +150 -0
  154. package/geometry/land-earthworks.js +432 -0
  155. package/geometry/land-edge.js +292 -0
  156. package/geometry/land-mound-faces.js +349 -0
  157. package/geometry/land-near-relief.js +102 -0
  158. package/geometry/land-sheet.js +220 -0
  159. package/geometry/land-town-ground.js +256 -0
  160. package/geometry/land-waters.js +228 -0
  161. package/geometry/land-wildness.js +123 -0
  162. package/geometry/lathed-vessel.js +293 -0
  163. package/geometry/outline-grid.js +5 -4
  164. package/geometry/outline-segments.js +74 -0
  165. package/geometry/part-ranges.js +35 -0
  166. package/geometry/path-field.js +35 -1
  167. package/geometry/planked-floor.js +149 -0
  168. package/geometry/plant-broadleaf.js +268 -0
  169. package/geometry/plant-shrub.js +198 -0
  170. package/geometry/plant-tints.js +80 -0
  171. package/geometry/plant-trees.js +453 -0
  172. package/geometry/plant-tussock.js +107 -0
  173. package/geometry/primitives.js +65 -23
  174. package/geometry/prop-battlefield.js +69 -0
  175. package/geometry/prop-camp.js +175 -0
  176. package/geometry/prop-door.js +26 -0
  177. package/geometry/prop-harbour.js +105 -0
  178. package/geometry/prop-haycock.js +60 -0
  179. package/geometry/prop-sacks.js +74 -0
  180. package/geometry/prop-sheaf.js +68 -0
  181. package/geometry/prop-street.js +69 -0
  182. package/geometry/prop-tents.js +396 -0
  183. package/geometry/prop-tombs.js +80 -0
  184. package/geometry/prop-trade.js +393 -0
  185. package/geometry/prop-vehicles.js +218 -0
  186. package/geometry/props.js +58 -0
  187. package/geometry/room-arcade.js +134 -0
  188. package/geometry/room-dome.js +188 -0
  189. package/geometry/room-flames.js +138 -0
  190. package/geometry/room-frame.js +106 -0
  191. package/geometry/room-furniture.js +260 -0
  192. package/geometry/room-hearth.js +98 -0
  193. package/geometry/room-kit.js +59 -0
  194. package/geometry/room-openings.js +142 -0
  195. package/geometry/room-stairs.js +180 -0
  196. package/geometry/room-surfaces.js +272 -0
  197. package/geometry/sampled-surface.js +24 -10
  198. package/geometry/scatter-grid.js +6 -3
  199. package/geometry/sculpt.js +5 -1
  200. package/geometry/ship-fittings.js +350 -0
  201. package/geometry/ship-hull.js +460 -0
  202. package/geometry/ship-kit.js +208 -0
  203. package/geometry/ship-lines.js +69 -0
  204. package/geometry/ship-oars.js +150 -0
  205. package/geometry/ship-presets.js +131 -0
  206. package/geometry/ship-rig.js +374 -0
  207. package/geometry/ship-sails.js +148 -0
  208. package/geometry/shore-grid.js +5 -1
  209. package/geometry/strata-field.js +44 -11
  210. package/geometry/strata-tiles.js +20 -6
  211. package/geometry/stream.js +32 -17
  212. package/geometry/swept-tube.js +124 -0
  213. package/geometry/terrain-chunks.js +139 -51
  214. package/geometry/terrain-extension.js +24 -8
  215. package/geometry/town-courtyard-inn.js +272 -0
  216. package/geometry/town-ground.js +76 -0
  217. package/geometry/town-houses.js +343 -0
  218. package/geometry/town-lights.js +254 -0
  219. package/geometry/town-lots.js +172 -0
  220. package/geometry/town-plan.js +370 -0
  221. package/geometry/town-works.js +465 -0
  222. package/geometry/village-layout.js +181 -0
  223. package/geometry/village-yards.js +167 -0
  224. package/geometry/wall-runs.js +64 -0
  225. package/index.js +134 -3
  226. package/math/cloud-textures.js +3 -7
  227. package/math/curve.js +5 -1
  228. package/math/lamp-texels.js +43 -0
  229. package/math/lit-share.js +22 -0
  230. package/math/mountain-ranges.js +177 -54
  231. package/math/periodic.js +6 -0
  232. package/math/rectangles.js +8 -2
  233. package/math/rock-texture.js +17 -12
  234. package/math/surface-textures.js +24 -9
  235. package/math/wandering-path.js +40 -0
  236. package/math/ways.js +120 -0
  237. package/motion/action-dynamics.js +398 -0
  238. package/motion/animal-bearing.js +247 -0
  239. package/motion/animal-canine-bearing.js +178 -0
  240. package/motion/animal-canine-cast.js +131 -0
  241. package/motion/animal-cattle-cast.js +64 -0
  242. package/motion/animal-herd-cast.js +154 -0
  243. package/motion/animal-horse-still.js +161 -0
  244. package/motion/animal-troop-cast.js +43 -0
  245. package/motion/arm-reach.js +3 -2
  246. package/motion/ballistic-arc.js +182 -2
  247. package/motion/biped-cycle.js +4 -2
  248. package/motion/biped-leg.js +4 -1
  249. package/motion/biped-posture.js +459 -0
  250. package/motion/biped-stride.js +142 -32
  251. package/motion/boat-sailing.js +214 -0
  252. package/motion/contact-transition.js +5 -6
  253. package/motion/crowd-alarms.js +36 -6
  254. package/motion/crowd-attention.js +108 -0
  255. package/motion/crowd-beasts.js +203 -0
  256. package/motion/crowd-camp.js +295 -0
  257. package/motion/crowd-figure.js +100 -0
  258. package/motion/crowd-herd.js +86 -0
  259. package/motion/crowd-hold.js +130 -0
  260. package/motion/crowd-pose.js +296 -0
  261. package/motion/crowd-poses.js +481 -0
  262. package/motion/crowd-routine.js +44 -14
  263. package/motion/crowd-town.js +166 -0
  264. package/motion/crowd-water.js +143 -0
  265. package/motion/deck-surface.js +4 -2
  266. package/motion/figure-acts.js +411 -0
  267. package/motion/figure-arms.js +437 -0
  268. package/motion/figure-blade-slide.js +149 -0
  269. package/motion/figure-body-place.js +180 -0
  270. package/motion/figure-bones.js +118 -0
  271. package/motion/figure-bow-draw.js +70 -0
  272. package/motion/figure-fingers.js +215 -0
  273. package/motion/figure-gaze.js +205 -0
  274. package/motion/figure-gestures.js +452 -0
  275. package/motion/figure-grip.js +134 -0
  276. package/motion/figure-head.js +287 -0
  277. package/motion/figure-legs.js +264 -0
  278. package/motion/figure-links.js +293 -0
  279. package/motion/figure-locomotion.js +391 -0
  280. package/motion/figure-mount-up.js +180 -0
  281. package/motion/figure-mount.js +201 -0
  282. package/motion/figure-pose-frame.js +375 -0
  283. package/motion/figure-pose-table.js +156 -0
  284. package/motion/figure-pose.js +343 -0
  285. package/motion/figure-seat.js +267 -0
  286. package/motion/figure-sway.js +125 -0
  287. package/motion/flier-corvid-pose.js +74 -0
  288. package/motion/flier-flight-air.js +122 -0
  289. package/motion/flier-flight-echelon.js +164 -0
  290. package/motion/flier-flight-roost.js +131 -0
  291. package/motion/flier-swarm-flight.js +252 -0
  292. package/motion/formation.js +193 -0
  293. package/motion/instance-sight.js +8 -1
  294. package/motion/melee-contact.js +143 -0
  295. package/motion/moorings.js +48 -0
  296. package/motion/path-steering.js +358 -0
  297. package/motion/player.js +7 -6
  298. package/motion/quadruped.js +109 -33
  299. package/motion/spaces.js +58 -6
  300. package/motion/speech-cadence.js +304 -0
  301. package/motion/vessel-motion.js +57 -0
  302. package/motion/walk-grid.js +235 -0
  303. package/motion/weather.js +70 -12
  304. package/motion/wind.js +27 -1
  305. package/package.json +27 -4
  306. package/rendering/alpha-mips.js +340 -0
  307. package/rendering/animal-camel-figure.js +29 -0
  308. package/rendering/animal-canine-figure.js +59 -0
  309. package/rendering/animal-cattle-figure.js +36 -0
  310. package/rendering/animal-horse-figure.js +49 -0
  311. package/rendering/atmosphere.js +86 -0
  312. package/rendering/camera-track.js +156 -0
  313. package/rendering/{road-surface.js → cart-track.js} +40 -11
  314. package/rendering/caster-motion.js +2 -1
  315. package/rendering/cell-lod-options.js +46 -0
  316. package/rendering/cell-lod.js +665 -80
  317. package/rendering/cloth-material.js +140 -0
  318. package/rendering/cloud-dome.js +2 -2
  319. package/rendering/compilation-schedule.js +18 -10
  320. package/rendering/contact-shadows.js +5 -2
  321. package/rendering/context.js +47 -8
  322. package/rendering/crowd-batches.js +420 -0
  323. package/rendering/crowd-herd.js +198 -0
  324. package/rendering/crowd-rig.js +132 -0
  325. package/rendering/crowd-skinning.js +52 -9
  326. package/rendering/crowd-update.js +419 -0
  327. package/rendering/crowd-visibility.js +107 -0
  328. package/rendering/day-cycle-defaults.js +200 -0
  329. package/rendering/day-cycle.js +487 -0
  330. package/rendering/daylight.js +1 -3
  331. package/rendering/detail-range.js +6 -5
  332. package/rendering/dof.js +11 -4
  333. package/rendering/effects-frame.js +149 -0
  334. package/rendering/effects-water-rises.js +221 -0
  335. package/rendering/energy-stream.js +128 -0
  336. package/rendering/facade-glass-material.js +105 -0
  337. package/rendering/far-shadow.js +81 -54
  338. package/rendering/field-surface.js +138 -0
  339. package/rendering/figure-shield.js +105 -0
  340. package/rendering/figure-skeleton.js +329 -0
  341. package/rendering/fire-light-watch.js +197 -0
  342. package/rendering/fire-pools.js +148 -0
  343. package/rendering/flame-sources.js +86 -0
  344. package/rendering/flier-bird-looks.js +97 -0
  345. package/rendering/flier-corvid-figure.js +67 -0
  346. package/rendering/flier-long-body-company.js +169 -0
  347. package/rendering/flier-swarm.js +186 -0
  348. package/rendering/flocks.js +6 -2
  349. package/rendering/garment-material.js +145 -49
  350. package/rendering/glsl-literal.js +19 -0
  351. package/rendering/ground-marks.js +316 -0
  352. package/rendering/hair-strands.js +38 -24
  353. package/rendering/height-haze.js +80 -33
  354. package/rendering/height-probe.js +15 -3
  355. package/rendering/house-kit-meshes.js +124 -0
  356. package/rendering/interior-bake.js +807 -0
  357. package/rendering/label-layout.js +13 -3
  358. package/rendering/label-range.js +5 -2
  359. package/rendering/lamp-light-map.js +159 -0
  360. package/rendering/lamp-maps.js +62 -0
  361. package/rendering/lamp-wash.js +51 -0
  362. package/rendering/light-budget.js +19 -3
  363. package/rendering/light-points.js +21 -5
  364. package/rendering/local-lights.js +27 -7
  365. package/rendering/material-lod.js +5 -6
  366. package/rendering/memory-estimate.js +84 -0
  367. package/rendering/moored-fleet.js +186 -0
  368. package/rendering/part-costs.js +104 -0
  369. package/rendering/particle-bursts.js +386 -0
  370. package/rendering/particle-emitters.js +61 -25
  371. package/rendering/particle-light-bursts.js +189 -0
  372. package/rendering/particles.js +134 -34
  373. package/rendering/pen-flocks.js +118 -0
  374. package/rendering/piece-batch.js +282 -6
  375. package/rendering/planar-reflection-options.js +159 -0
  376. package/rendering/planar-reflection.js +780 -77
  377. package/rendering/plant-cells.js +122 -0
  378. package/rendering/plant-reeds.js +113 -0
  379. package/rendering/plant-shade-trees.js +239 -0
  380. package/rendering/plant-tuft-patch.js +122 -0
  381. package/rendering/post-shaders.js +84 -21
  382. package/rendering/post.js +39 -19
  383. package/rendering/pressed-cover.js +135 -0
  384. package/rendering/prop-dig.js +136 -0
  385. package/rendering/room-light.js +250 -0
  386. package/rendering/room-materials.js +78 -0
  387. package/rendering/room-space.js +111 -0
  388. package/rendering/scene-lights.js +106 -0
  389. package/rendering/sea-shaders.js +83 -26
  390. package/rendering/settlement-approach.js +226 -0
  391. package/rendering/settlement-dissolve.js +89 -0
  392. package/rendering/settlement-quarter-warm.js +55 -0
  393. package/rendering/settlement-quarter.js +477 -0
  394. package/rendering/settlement-switch.js +42 -0
  395. package/rendering/settlement-town.js +110 -0
  396. package/rendering/shader-warmup.js +80 -36
  397. package/rendering/shadow-depth.js +40 -18
  398. package/rendering/ship-meshes.js +150 -0
  399. package/rendering/shot-cuts.js +68 -0
  400. package/rendering/sky-occlusion.js +42 -15
  401. package/rendering/sky-pmrem.js +216 -0
  402. package/rendering/sky.js +112 -50
  403. package/rendering/smoke-shadows.js +201 -0
  404. package/rendering/stage-framing.js +182 -0
  405. package/rendering/stage-lights.js +46 -39
  406. package/rendering/stain-material.js +74 -0
  407. package/rendering/static-point-shadow.js +62 -23
  408. package/rendering/still-casters.js +77 -27
  409. package/rendering/strata-material.js +2 -2
  410. package/rendering/street-lamps.js +166 -0
  411. package/rendering/sunbeam-motes.js +670 -0
  412. package/rendering/surface-light.js +65 -6
  413. package/rendering/surface-material.js +306 -0
  414. package/rendering/surface-projection.js +32 -0
  415. package/rendering/surface-snippets.js +314 -0
  416. package/rendering/taa.js +49 -18
  417. package/rendering/tree-impostor.js +929 -0
  418. package/rendering/vehicle-train.js +92 -0
  419. package/rendering/viewport.js +67 -4
  420. package/rendering/water-material.js +270 -82
  421. package/rendering/waypoint-beacons.js +191 -0
  422. package/rendering/world-matrices.js +0 -2
  423. package/ruff.toml +20 -0
  424. package/runtime/cue-cursor.js +21 -0
  425. package/runtime/device-quality.js +13 -2
  426. package/runtime/device.js +73 -0
  427. package/runtime/diagnostic-log.js +11 -3
  428. package/runtime/effect-sites.js +85 -0
  429. package/runtime/figure-orders.js +59 -0
  430. package/runtime/first-use.js +8 -5
  431. package/runtime/foley-script.js +124 -0
  432. package/runtime/foley-strides.js +333 -0
  433. package/runtime/frame-pacing.js +18 -4
  434. package/runtime/frame-yield.js +18 -0
  435. package/runtime/gpu-timing.js +8 -4
  436. package/runtime/grid-cache.js +16 -6
  437. package/runtime/grid-rows.js +5 -5
  438. package/runtime/hand-over.js +7 -2
  439. package/runtime/land-bake.js +78 -0
  440. package/runtime/lazy-sets.js +105 -0
  441. package/runtime/pool.js +17 -3
  442. package/runtime/quality-fit.js +59 -27
  443. package/runtime/region-pass-lay.js +40 -0
  444. package/runtime/region-pass.js +78 -0
  445. package/runtime/search.js +6 -2
  446. package/runtime/settlement-reach.js +42 -0
  447. package/runtime/sound-calls.js +113 -0
  448. package/runtime/sound-impacts.js +297 -0
  449. package/runtime/sound-voices.js +194 -0
  450. package/runtime/soundscape.js +282 -0
  451. package/runtime/spatial-audio.js +69 -20
  452. package/runtime/steady-frames.js +221 -0
  453. package/runtime/withdrawable-task.js +19 -8
  454. package/scripts/app-parts.mjs +118 -0
  455. package/scripts/bake-revisions.mjs +81 -0
  456. package/scripts/browser-scripts.mjs +64 -0
  457. package/scripts/bundle.mjs +192 -0
  458. package/scripts/check-app.sh +26 -0
  459. package/scripts/eslint-config.mjs +119 -0
  460. package/scripts/format.sh +92 -0
  461. package/scripts/keep-builds.mjs +158 -0
  462. package/scripts/layers.mjs +112 -0
  463. package/scripts/lint.sh +49 -0
  464. package/scripts/module-graph.mjs +123 -0
  465. package/scripts/pre-commit.sh +38 -0
  466. package/scripts/serve.py +5 -3
  467. package/scripts/site.mjs +358 -0
  468. package/scripts/test-runner.sh +42 -0
  469. package/scripts/vendor.mjs +221 -0
  470. package/scripts/verify-publish.mjs +175 -0
  471. package/scripts/world.mk +59 -0
  472. package/tools/README.md +73 -0
  473. package/tools/contact-sheet.cjs +137 -0
  474. package/tools/cpu-profile.cjs +275 -0
  475. package/tools/cpu-profile.test.cjs +98 -0
  476. package/tools/first-draws.cjs +395 -0
  477. package/tools/flight-guard.cjs +482 -0
  478. package/tools/flight-guard.test.cjs +153 -0
  479. package/tools/flight-profile.cjs +145 -0
  480. package/tools/frame-bench.cjs +336 -0
  481. package/tools/frame-parts.cjs +365 -0
  482. package/tools/ios-sim.sh +145 -0
  483. package/tools/load-audit.cjs +201 -0
  484. package/tools/look-compare.cjs +304 -0
  485. package/tools/look-guard.cjs +407 -0
  486. package/tools/look-guard.test.cjs +93 -0
  487. package/tools/look-stats.cjs +185 -0
  488. package/tools/look-stats.test.cjs +71 -0
  489. package/tools/memory-audit.cjs +323 -0
  490. package/tools/page-driver.cjs +320 -0
  491. package/tools/page-driver.test.cjs +219 -0
  492. package/tools/program-census-report.cjs +191 -0
  493. package/tools/program-census.cjs +465 -0
  494. package/tools/program-census.test.cjs +332 -0
  495. package/tools/remote-runner.sh +265 -0
  496. package/tools/runners.test.cjs +59 -0
  497. package/tools/scene-audit-beat.cjs +344 -0
  498. package/tools/scene-audit-sheet.cjs +282 -0
  499. package/tools/scene-audit.cjs +471 -0
  500. package/tools/scene-audit.test.cjs +201 -0
  501. package/tools/scene-batch.cjs +219 -0
  502. package/tools/scene-bench.cjs +149 -0
  503. package/tools/scene-bench.test.cjs +33 -0
  504. package/tools/scene-run.cjs +443 -0
  505. package/tools/scene-run.test.cjs +94 -0
  506. package/tools/servers.sh +59 -0
  507. package/tools/shader-arrival.cjs +316 -0
  508. package/tools/shader-renewal.cjs +53 -0
  509. package/tools/shader-renewal.test.cjs +115 -0
  510. package/tools/speed-guard.cjs +258 -0
  511. package/tools/stills.cjs +492 -0
  512. package/tools/stills.test.cjs +49 -0
  513. package/tools/turns.sh +7 -0
  514. package/tools/yaml.cjs +158 -0
  515. package/examples/viaduct.css +0 -75
  516. package/rendering/light-shafts.js +0 -131
@@ -0,0 +1,337 @@
1
+ /**
2
+ * What a person wears over the body: the belt or a robe's sash, a cuirass with its pauldrons, furs, mantles and what hangs
3
+ * from the belt (figure-skirts.js).
4
+ * @module
5
+ */
6
+ import { lerp, sstep } from '../math/scalar.js';
7
+ import { HANGS, garmentTag } from './garment-tags.js';
8
+ import { C, TRS, plainUnitShapes } from './primitives.js';
9
+ import { loft, triangle } from './figure-sculpt.js';
10
+ import { SMOOTH } from './cloth-folds.js';
11
+ import { ARM_L, ARM_R, CAPE_L, CAPE_R } from '../motion/figure-bones.js';
12
+ import { BELT_Y } from './figure-trunk.js';
13
+ import { rotted, skirt, tatter } from './figure-skirts.js';
14
+
15
+ const U = plainUnitShapes();
16
+
17
+ // What a person wears over the body (figure-body.js): the belt or a robe's sash, a cuirass with its pauldrons, a fur
18
+ // mantle, a collar, and what hangs from the belt (figure-skirts.js); the cloak is figure-cloak.js's. Each lies over the trunk's
19
+ // own form at a girth of its own (figure-trunk.js).
20
+
21
+ // The belt: where its edges are, how far it stands off what is under it (a share of the girth), and its buckle's size. A
22
+ // near body's sash: its folds along its length ([height, girth of the belt's]) and how dark the hollow between them is, where
23
+ // its knot is round the trunk (radians from the right side, through the front) and the knot's size, and its two ends hanging
24
+ // from the knot: how wide the pair is round the skirt (radians), how low each hangs, and how far they stand off the skirt.
25
+ const BELT = { low: 0.982, high: 1.036, off: 1.035, buckle: [0.05, 0.045, 0.012] },
26
+ SASH = {
27
+ folds: [
28
+ [0.997, 1.008],
29
+ [1.009, 0.996],
30
+ [1.021, 1.008],
31
+ ],
32
+ shade: 0.72,
33
+ at: Math.PI / 2 + 0.85,
34
+ knot: [0.034, 0.03, 0.02],
35
+ tails: { wide: 0.34, low: [0.77, 0.7], off: 0.006 },
36
+ };
37
+ // A cuirass: its girth over the trunk's, where it begins, how far up the slope from the shoulders to the neck it goes, and
38
+ // the height under which it is plain plate, with no need of the trunk's finer rings.
39
+ const CUIRASS = { girth: 1.07, from: 0.97, neck: 0.55, plain: 1.2 };
40
+ // A cuirass over the chest and back, shaped to them, which the shoulders come out of, and a gorget at the neck.
41
+ function cuirass(fig) {
42
+ const { body, trunk, metal, metalEdge } = fig,
43
+ over = trunk.lay(CUIRASS.girth),
44
+ hole = trunk.armhole * CUIRASS.girth,
45
+ rings = trunk
46
+ .rings(CUIRASS.girth, () => metal, CUIRASS.from, lerp(trunk.capTop, trunk.neckY, CUIRASS.neck))
47
+ .filter(r => !(r.fine && r[0] < CUIRASS.plain));
48
+ rings[0][5] = rings.at(-1)[5] = metalEdge;
49
+ loft(body, 0, 0, 0, rings, trunk.sides, {
50
+ joined: true,
51
+ lay: (p, a, ring) => {
52
+ over(p, a, ring);
53
+ if (Math.abs(p[0]) > hole) p[0] = p[0] < 0 ? -hole : hole; // the shell ends flat where the arm passes through it
54
+ },
55
+ });
56
+ body.add(U.cyl16, metalEdge, TRS(0, 1.495, -0.004, Math.min(0.15 * fig.sw, 0.19), 0.05, 0.15)); // a ring round the neck's foot, inside the shoulders' slope
57
+ }
58
+ // A pauldron on each shoulder of a cuirass: a domed plate over the shoulder's cap, and a second plate hanging from under it
59
+ // over the upper arm. Each plate's rings are [angle down from its top (degrees) or height under the dome's middle (a share of
60
+ // its radius), radius (a share of the dome's)]; the dome goes part of the way with the arm, the lower plate all the way.
61
+ const PAULDRON = {
62
+ off: 0.012, // how far the dome stands off the cap
63
+ flat: 0.92, // how high it is for its width
64
+ deep: 1.1, // and how deep
65
+ share: 0.6,
66
+ dome: [8, 32, 58, 84, 102],
67
+ rim: [0.24, 0.9], // the dome's edge turned in: how far under its middle, and its radius
68
+ lame: [
69
+ [0.4, 0.9],
70
+ [0.55, 1.01],
71
+ [1.2, 0.97],
72
+ [1.24, 0.9],
73
+ ],
74
+ sides: 12,
75
+ };
76
+ function pauldrons(fig) {
77
+ const { body, sx, trunk, metal, metalEdge } = fig,
78
+ R = trunk.capR + PAULDRON.off,
79
+ ring = (y, r, bone, share) => [trunk.capY + y * R, r * R, r * R * PAULDRON.deep, 0, 0, metal, bone, 0, share];
80
+ for (const [s, arm] of [
81
+ [-1, ARM_L],
82
+ [1, ARM_R],
83
+ ]) {
84
+ const dome = PAULDRON.dome.map(deg => {
85
+ const at = (deg * Math.PI) / 180;
86
+ return ring(Math.cos(at) * PAULDRON.flat, Math.sin(at), arm, PAULDRON.share);
87
+ }),
88
+ rim = ring(-PAULDRON.rim[0], PAULDRON.rim[1], arm, PAULDRON.share),
89
+ lame = PAULDRON.lame.map(([under, r]) => ring(-under, r, arm, 1));
90
+ dome.at(-1)[5] = rim[5] = lame.at(-2)[5] = lame.at(-1)[5] = metalEdge;
91
+ // the far bodies keep a dome of three rings and the lower plate's two edges
92
+ for (const fine of [dome[1], dome[3], rim, lame[0], lame[3]]) fine.fine = true;
93
+ loft(body, s * sx, 0, 0, [...dome, rim], PAULDRON.sides, { joined: true });
94
+ loft(body, s * sx, 0, 0, lame, PAULDRON.sides, { joined: true });
95
+ }
96
+ }
97
+ // A mantle over the shoulders, of fur or of the cloth a hood falls onto: its girth over the trunk's, how much wider it closes
98
+ // round the neck, how far under the shoulders' caps it hangs (and the rings of that fall), how far its hem dips before and
99
+ // behind, how far back it sits, and how much more than the cap what hangs under it goes with an arm.
100
+ const MANTLE = {
101
+ fur: { girth: 1.12, collar: 1.16, hang: [0.11, 0.06, 0.025], dip: 0.08, back: 0.006, arm: 1.5 },
102
+ hood: { girth: 1.06, collar: 1.12, hang: [0.13, 0.075, 0.03], dip: 0.11, back: 0.004, arm: 1.5 }, // a hood's short cape, of thinner cloth
103
+ };
104
+ // The trunk's own top from the shoulders' caps up, a little larger, so that it falls from the neck as the shoulders do (its
105
+ // collar keeps its edge off the trunk's); under the caps it hangs straight down over the arms, lower over the chest and between
106
+ // the shoulders than at the sides.
107
+ // A ragged mantle (rotting furs) at ragged 1: how much longer it hangs, how much deeper its tatters are than a skirt's, and how
108
+ // far in toward the arms its hem sags, as a share of its width over the caps.
109
+ const MANTLE_RAGS = { longer: 0.5, torn: 1.8, drape: 0.16 };
110
+ function mantle(fig, kind, cloth) {
111
+ const { body, trunk } = fig,
112
+ M = MANTLE[kind],
113
+ ragged = fig.L.ragged ?? 0,
114
+ hang = M.hang.map(under => under * (1 + MANTLE_RAGS.longer * ragged)), // rotting furs hang lower, shapeless, over the back and arms
115
+ k = M.girth,
116
+ over = trunk.lay(k),
117
+ capY = trunk.capY,
118
+ hemY = capY - hang[0],
119
+ cap = trunk.ring(capY, k, cloth),
120
+ chest = trunk.at(1.31),
121
+ deep = Math.max(cap[2], ((chest.zf + chest.zb) / 2) * k * 1.04), // deep enough for the chest it hangs before
122
+ rings = [...hang.map(under => [capY - under, cap[1], deep, 0, cap[4], cloth, 0]), ...trunk.rings(k, () => cloth, capY)];
123
+ for (let i = 0; i < rings.length; i++) {
124
+ const r = rings[i],
125
+ collar = i >= rings.length - 2 ? M.collar : 1;
126
+ r[1] *= collar;
127
+ r[2] *= collar;
128
+ r[4] -= M.back;
129
+ if (ragged && i < hang.length) r[1] *= 1 - (MANTLE_RAGS.drape * ragged * (hang.length - i)) / hang.length; // hides sag in onto the arms
130
+ }
131
+ loft(body, 0, 0, 0, rings, trunk.sides, {
132
+ joined: true,
133
+ crease: kind !== 'hood' ? null : fig.lod ? SMOOTH : () => HANGS, // a near body's cape of cloth hangs in its finer folds
134
+ relief: trunk.relief, // and lies on the cloth under it, where that stands off the body
135
+ // what hangs over an arm goes with it more than the cap does, so that an arm swung back or out does not come through it;
136
+ // but on the bone beside it (CAPE_L, CAPE_R), which follows an arm raised or swung forward only a little, as cloth would
137
+ sk: (y, a, ring) => {
138
+ const bones = trunk.bones(Math.max(y, capY), a, ring);
139
+ if (y < capY) {
140
+ bones[2] = Math.min(1, bones[2] * M.arm);
141
+ if (bones[0] === ARM_L || bones[0] === ARM_R) bones[0] = bones[0] === ARM_L ? CAPE_L : CAPE_R;
142
+ }
143
+ return bones;
144
+ },
145
+ fold: (v, a) => 1 + (1 - v) * (0.06 * Math.cos(a * 11) + 0.035 * Math.cos(a * 7 + 1)),
146
+ lay: (p, a, ring) => {
147
+ const y = p[1],
148
+ s = Math.sin(a);
149
+ p[1] = Math.max(y, capY); // under the caps the mantle keeps their round
150
+ over(p, a, ring);
151
+ p[1] = y - (M.dip * s * s + MANTLE_RAGS.torn * tatter(fig.kit.hash, ragged, a, 2)) * sstep(capY, hemY, y);
152
+ },
153
+ tint: (p, a, ring) =>
154
+ (1 - 0.14 * sstep(capY, hemY, ring[0]) * (0.5 - 0.5 * Math.cos(a * 11))) * rotted(fig.kit.hash, ragged, a, ring[0]),
155
+ });
156
+ }
157
+ // The belt, with its buckle; a robe or a gown is girt with a sash of cloth in the look's second colour instead, which a near
158
+ // body shows folded along its length and knotted at one hip (its ends hang down the skirt, figure-skirts.js).
159
+ function girdle(fig) {
160
+ const { body, trunk, metal, leather, c2, lod, robe } = fig,
161
+ colour = robe ? c2 : leather,
162
+ folded = robe && !lod,
163
+ rings = [
164
+ trunk.ring(BELT.low, 1, colour),
165
+ trunk.ring(BELT.low + 0.004, BELT.off, colour),
166
+ ...(folded ? SASH.folds.map(([y, k]) => trunk.ring(y, BELT.off * k, colour)) : []),
167
+ trunk.ring(BELT.high - 0.004, BELT.off, colour),
168
+ trunk.ring(BELT.high, 1, colour),
169
+ ];
170
+ if (folded) rings[3].hollow = true;
171
+ loft(body, 0, 0, 0, rings, trunk.sides, {
172
+ joined: true,
173
+ lay: trunk.lay(BELT.off),
174
+ tint: (p, a, ring) => (ring.hollow ? SASH.shade : 1),
175
+ crease: robe ? SMOOTH : null, // a sash is of the garment's cloth; a belt is leather, by its colour
176
+ kind: fig.cloth,
177
+ });
178
+ if (folded) {
179
+ const [y, rx, rz, , cz] = trunk.ring(BELT_Y + 0.008, BELT.off, colour),
180
+ [wide, tall, thick] = SASH.knot;
181
+ body.add(U.sph, colour, TRS(Math.cos(SASH.at) * rx, y, cz + Math.sin(SASH.at) * rz, wide, tall, thick, Math.PI / 2 - SASH.at));
182
+ } else body.box(0, BELT.low + 0.006, trunk.reach(BELT_Y + 0.01, 1, BELT.off), ...BELT.buckle, robe ? colour : metal);
183
+ }
184
+ // A band lying on the chest along a path of [metres across from the middle, height] points: the edge of one side of a robe
185
+ // wrapped over the other, a jerkin's laced front, the slit of a tunic's neck. `half` its half-width, `off` how far it stands
186
+ // off the cloth under it; its edges go down to the cloth in `shade` of its colour.
187
+ const BAND_EDGE = 1.3, // how much wider the band is at its foot than on top
188
+ SLOPE_STEP = 0.004; // how far apart the chest is read to find its slope (metres)
189
+ function chestBand(fig, path, half, off, colour, shade = 0.6) {
190
+ const { body, trunk } = fig,
191
+ dark = [colour[0] * shade, colour[1] * shade, colour[2] * shade],
192
+ z = (x, y) => trunk.reach(y, 1, 1, x),
193
+ // a point of the band `lift` metres off the chest, with the chest's normal there
194
+ at = (x, y, lift, tone) => {
195
+ const nx = -(z(x + SLOPE_STEP, y) - z(x - SLOPE_STEP, y)) / (2 * SLOPE_STEP),
196
+ ny = -(z(x, y + SLOPE_STEP) - z(x, y - SLOPE_STEP)) / (2 * SLOPE_STEP),
197
+ l = Math.hypot(nx, ny, 1);
198
+ return [x + (nx / l) * lift, y + (ny / l) * lift, z(x, y) + lift / l, nx / l, ny / l, 1 / l, tone];
199
+ };
200
+ let before = null;
201
+ body.tv = body.tags.get(colour) ?? garmentTag(0, fig.cloth); // the garment's own stuff
202
+ for (let i = 0; i < path.length; i++) {
203
+ const [x, y] = path[i],
204
+ [px, py] = path[Math.max(0, i - 1)],
205
+ [qx, qy] = path[Math.min(path.length - 1, i + 1)],
206
+ l = Math.hypot(qx - px, qy - py),
207
+ ax = ((qy - py) / l) * half, // across the band
208
+ ay = (-(qx - px) / l) * half,
209
+ row = [
210
+ at(x - ax * BAND_EDGE, y - ay * BAND_EDGE, -0.001, dark),
211
+ at(x - ax, y - ay, off, colour),
212
+ at(x + ax, y + ay, off, colour),
213
+ at(x + ax * BAND_EDGE, y + ay * BAND_EDGE, -0.001, dark),
214
+ ];
215
+ if (before)
216
+ for (let k = 0; k < 3; k++) {
217
+ triangle(body, before[k], row[k], row[k + 1], colour, 0);
218
+ triangle(body, before[k], row[k + 1], before[k + 1], colour, 0);
219
+ }
220
+ before = row;
221
+ }
222
+ body.tv = 0;
223
+ }
224
+ // The points of a straight band down the chest from one [across, height] to another, a point every `step` metres of height.
225
+ function downChest([x0, y0], [x1, y1], step = 0.028) {
226
+ const n = Math.max(1, Math.ceil((y0 - y1) / step)),
227
+ path = [];
228
+ for (let i = 0; i <= n; i++) path.push([lerp(x0, x1, i / n), lerp(y0, y1, i / n)]);
229
+ return path;
230
+ }
231
+ // What closes a near body's garment at the neck and down the chest, by what it is: a jerkin's standing collar, open before,
232
+ // over a front laced shut; a robe's one side wrapped over the other to the sash, its edge and collar bound in the look's
233
+ // second colour; a gown's neck bound in it to a point; a tunic's plain collar and the slit that lets the head through.
234
+ const FRONT = {
235
+ jerkin: {
236
+ collar: { over: 0.03, off: 0.011, open: 0.34 },
237
+ band: [0.011, 0.0022],
238
+ from: 0.04,
239
+ laces: [1.345, 1.285, 1.225, 1.165],
240
+ lace: [0.03, 0.0032, 0.0025, 0.6],
241
+ },
242
+ robe: { collar: { over: 0.013, off: 0.01 }, band: [0.013, 0.0026], from: [0.034, 0.012], to: [-0.5, 0.012] },
243
+ gown: { collar: { over: 0.009, off: 0.009 }, band: [0.009, 0.002], from: [0.045, 0.01], point: 0.115 },
244
+ tunic: { collar: { over: 0.014, off: 0.009 }, band: [0.0035, 0.0006], slit: [0.008, 0.095], shade: 0.42 },
245
+ };
246
+ const RAWHIDE = 0x8a7558; // a jerkin's lacing
247
+ function neckline(fig) {
248
+ const { body, L, trunk, c1, c2 } = fig,
249
+ neckY = trunk.neckY,
250
+ foot = BELT.high + 0.006; // where the belt, or the sash, takes the cloth in
251
+ if (L.garb === 'leather') {
252
+ const F = FRONT.jerkin,
253
+ thong = C(RAWHIDE),
254
+ [long, wide, thick, slant] = F.lace;
255
+ collar(fig, F.collar, c1);
256
+ chestBand(fig, downChest([0, neckY - F.from], [0, foot]), ...F.band, c1);
257
+ for (const y of F.laces)
258
+ for (const turn of [-slant, slant]) body.box(0, y, trunk.reach(y, 1) + F.band[1] + thick, long, wide, thick, thong, 0, 0, turn);
259
+ } else if (L.garb === 'robe') {
260
+ const F = FRONT.robe;
261
+ collar(fig, F.collar, c2);
262
+ chestBand(fig, downChest([F.from[0], neckY - F.from[1]], [F.to[0] * trunk.at(foot).rx, foot + F.to[1]]), ...F.band, c2);
263
+ } else if (L.garb === 'gown') {
264
+ const F = FRONT.gown;
265
+ collar(fig, F.collar, c2);
266
+ for (const s of [-1, 1]) chestBand(fig, downChest([s * F.from[0], neckY - F.from[1]], [0, neckY - F.point], 0.02), ...F.band, c2);
267
+ } else {
268
+ const F = FRONT.tunic;
269
+ collar(fig, F.collar, c1);
270
+ chestBand(
271
+ fig,
272
+ downChest([0, neckY - F.slit[0]], [0, neckY - F.slit[1]], 0.022),
273
+ ...F.band,
274
+ [c1[0] * F.shade, c1[1] * F.shade, c1[2] * F.shade],
275
+ 1,
276
+ );
277
+ }
278
+ }
279
+ // The belt and what is worn below and over the trunk, before the head and arms are built.
280
+ function dressBody(fig) {
281
+ const { L, c1, c2, lod } = fig;
282
+ girdle(fig);
283
+ if (fig.robe) {
284
+ skirt(fig, 'robe', c1, L.garb === 'gown' ? c2 : c1, lod ? null : { ...SASH.tails, at: SASH.at, colour: c2 });
285
+ // the toes of the boots show under the hem
286
+ for (const [leg, s] of [
287
+ [fig.legView[0], -1],
288
+ [fig.legView[1], 1],
289
+ ])
290
+ leg.add(U.sph, fig.boot, TRS(s * (0.08 - fig.lx), -0.89, 0.14, 0.09, 0.075, 0.2));
291
+ } else if (L.garb === 'tunic' || L.garb === 'armor') skirt(fig, 'tunic', fig.mail ?? c1);
292
+ else if (L.garb === 'fur') skirt(fig, 'fur', fig.fur);
293
+ else if (L.garb === 'leather' && !lod) skirt(fig, 'jerkin', c1);
294
+ if (L.garb === 'armor') {
295
+ cuirass(fig);
296
+ pauldrons(fig);
297
+ } else if (L.garb === 'fur') mantle(fig, 'fur', fig.fur);
298
+ else if (L.hood)
299
+ mantle(fig, 'hood', C(L.hood === true ? L.cloak || L.c1 : L.hood)); // the cape the hood falls onto
300
+ else if (!L.bare && !lod) neckline(fig);
301
+ }
302
+ // A collar: the neck's opening of what is worn, standing a little off the neck. The neck's half-width at heights, as the head
303
+ // builds it (figure-head-features.js, neck), for a neck of girth 1; how far under the trunk's top a collar begins and how far behind
304
+ // the trunk's middle it stands. A collar of a kind goes `over` the trunk's top by so much, stands `off` the neck, and may be
305
+ // `open` before (radians to each side of the middle).
306
+ const NECK = [
307
+ [1.498, 0.071],
308
+ [1.532, 0.0625],
309
+ [1.562, 0.058],
310
+ [1.6, 0.0565],
311
+ ],
312
+ COLLAR = { under: 0.014, back: -0.012, sides: 20 };
313
+ function collar(fig, { over, off, open = 0 }, colour) {
314
+ const { body, trunk, fem, w } = fig,
315
+ top = trunk.neckY + over,
316
+ at = NECK.findIndex(n => n[0] >= top),
317
+ [low, high] = at < 0 ? [NECK[NECK.length - 1], NECK[NECK.length - 1]] : [NECK[Math.max(0, at - 1)], NECK[at]],
318
+ neck = lerp(low[1], high[1], high[0] > low[0] ? (top - low[0]) / (high[0] - low[0]) : 0) * (fem ? 0.85 : 1) * (0.8 + 0.2 * w),
319
+ edge = (y, r) => [y, r, r * 0.98, 0, COLLAR.back, colour, 0];
320
+ loft(
321
+ body,
322
+ 0,
323
+ 0,
324
+ 0,
325
+ [trunk.ring(trunk.neckY - COLLAR.under, 1.03, colour), edge(top, neck + off), edge(top - 0.002, neck + 0.001)],
326
+ COLLAR.sides,
327
+ {
328
+ joined: true,
329
+ crease: SMOOTH,
330
+ kind: fig.cloth,
331
+ a0: Math.PI / 2 + open,
332
+ a1: Math.PI / 2 + 2 * Math.PI - open,
333
+ tint: (p, a, ring) => (ring[0] === top - 0.002 ? 0.7 : 1), // the shade inside it
334
+ },
335
+ );
336
+ }
337
+ export { CUIRASS, dressBody };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The grids a face is sculpted on: its rows from the chin up and its columns across, near and far, and where a point of the
3
+ * face lies on them.
4
+ * @module
5
+ */
6
+ import { CHANNELS, faceAt, faceGrid, faceSculpt } from './face-grid.js';
7
+ import { FURROWS, LID_ABOVE, LID_BELOW, LID_LOW, LID_TOP, SEAM } from './head-shape.js';
8
+
9
+ // The rows of a face from the chin up. Those named for the lips' seam, the lids and an aged brow's furrows are where the
10
+ // head's shape has an edge or a crease to lay a row along (head-shape.js).
11
+ const CHIN_TO_LIP = [-116, -113, -109.5, -105, -100, -95, -90.5, -87, -84.5, -82, -79.5, -77.6, -76, -74.4, -72.8, -71.2, -69.6, -68.3],
12
+ LIP_TO_EYE = [
13
+ -65.8, -64.5, -63, -61.5, -60, -58.4, -56.4, -54.2, -52, -50, -48.4, -46.8, -45.2, -43.6, -42, -40.2, -38.2, -36, -33.5, -30, -26.5,
14
+ -23, -19.5,
15
+ ],
16
+ UNDER_EYE = [-14, -11.5, -9, -7.2],
17
+ OVER_EYE = [4.1, 5.4, 7.4, 9.6, 12, 14.5],
18
+ BROW = [19, 21.5, 24.5, 28, 33],
19
+ FOREHEAD = [42, 53],
20
+ CROWN = [64, 75, 84, 93, 101, 108, 113.5, 116.8],
21
+ SEAM_ROWS = [SEAM - 0.2, SEAM, SEAM + 0.2],
22
+ LID_ROWS = [LID_LOW, LID_LOW + 0.35, LID_LOW + 1.8, -1.4, LID_TOP - 1.8, LID_TOP - 0.35, LID_TOP],
23
+ FURROW_ROWS = FURROWS.flatMap(y => [y - 4.5, y - 0.8, y, y + 0.8]),
24
+ ACROSS = [
25
+ 0, 2.3, 4.6, 7, 9.5, 12, 14.5, 17, 19.4, 21.8, 24.2, 26.6, 29, 31.5, 34, 36.5, 39, 41.4, 43.6, 45.5, 48, 51.5, 55.5, 60, 64.5, 68.5,
26
+ 71.5,
27
+ ],
28
+ BEHIND = [84, 96, 109, 124, 141, 160, 180],
29
+ BACK_ROWS = [-109.5, -100, -90.5, -82, -72.8, SEAM, -54.2, -42, -30, LID_BELOW, -1.4, 14.5, 28, 64, 84, 101, 113.5],
30
+ faceRows = forehead =>
31
+ [
32
+ ...CHIN_TO_LIP,
33
+ ...SEAM_ROWS,
34
+ ...LIP_TO_EYE,
35
+ LID_BELOW,
36
+ ...UNDER_EYE,
37
+ ...LID_ROWS,
38
+ ...OVER_EYE,
39
+ LID_ABOVE,
40
+ ...BROW,
41
+ ...forehead,
42
+ ...CROWN,
43
+ ].sort((a, b) => a - b);
44
+ const FACE = faceGrid(faceRows(FOREHEAD), ACROSS, BEHIND, [...BACK_ROWS, 42]),
45
+ FACE_OLD = faceGrid(faceRows(FURROW_ROWS), ACROSS, BEHIND, [...BACK_ROWS, FURROWS[0]]), // with rows for the furrows of the brow
46
+ FACE_ONE = faceGrid(faceRows([2, 26, 30.5, 36, 39, 42, 47, 53]), ACROSS, BEHIND, [...BACK_ROWS, 42]), // with rows for one eye in the brow
47
+ FACE_LO = faceGrid(
48
+ [-115.5, -110, -102, -92, -82, -72.5, SEAM, -63, -56, -48, -42, -36, -31, -24, -14, -5, 2.5, 13, 22, 30, 44, 64, 84, 100, 113],
49
+ [0, 6.5, 13, 19, 31.5, 45.5, 56, 66],
50
+ [80, 100, 125, 152, 180],
51
+ [-102, -82, SEAM, -48, -31, -14, 13, 30, 64, 100],
52
+ ),
53
+ // the light figure's face (lod 2), a few pixels high where it is drawn: the head's outline and its lips' seam
54
+ FACE_LIGHT = faceGrid(
55
+ [-115.5, -102, -82, SEAM, -56, -42, -24, -5, 13, 30, 64, 100, 113],
56
+ [0, 13, 31.5, 56, 66],
57
+ [100, 152, 180],
58
+ [-102, SEAM, -24, 13, 64, 100],
59
+ );
60
+
61
+ const SKULL_COLUMNS = [80, 89, 98, 107, 116, 125, 134, 143, 152, 161, 170, 180], // degrees around the back of the head
62
+ detailedSkulls = new WeakMap();
63
+
64
+ // Keep the frontal anatomy and fill in the back and crown where the cut exposes the skull.
65
+ function withSkullDetail(grid) {
66
+ let detail = detailedSkulls.get(grid);
67
+ if (!detail) {
68
+ const backRows = grid.rows.filter((_, i) => grid.used[i * grid.nc]);
69
+ detail = faceGrid(grid.rows, ACROSS, SKULL_COLUMNS, [...backRows, 53, ...CROWN]);
70
+ detailedSkulls.set(grid, detail);
71
+ }
72
+ return detail;
73
+ }
74
+
75
+ export { CHANNELS, FACE, FACE_LIGHT, FACE_LO, FACE_OLD, FACE_ONE, faceAt, faceGrid, faceSculpt, withSkullDetail };