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
@@ -13,11 +13,18 @@ function through(rings, k, t) {
13
13
  const last = rings.length - 1,
14
14
  i = Math.min(last - 1, Math.floor(t)),
15
15
  f = t - i,
16
- a = rings[Math.max(0, i - 1)][k],
17
- b = rings[i][k],
18
- c = rings[i + 1][k],
19
- d = rings[Math.min(last, i + 2)][k];
20
- return b + 0.5 * f * (c - a + f * (2 * a - 5 * b + 4 * c - d + f * (3 * (b - c) + d - a)));
16
+ previousValue = rings[Math.max(0, i - 1)][k],
17
+ startValue = rings[i][k],
18
+ endValue = rings[i + 1][k],
19
+ nextValue = rings[Math.min(last, i + 2)][k];
20
+ return (
21
+ startValue +
22
+ 0.5 *
23
+ f *
24
+ (endValue -
25
+ previousValue +
26
+ f * (2 * previousValue - 5 * startValue + 4 * endValue - nextValue + f * (3 * (startValue - endValue) + nextValue - previousValue)))
27
+ );
21
28
  }
22
29
 
23
30
  // The ring a rope begins with, above its first: drawn in to a point.
@@ -29,12 +36,12 @@ const shut = ring => [ring[0] + ring[1] * 0.8, ring[1] * SHUT, ring[2] * SHUT, r
29
36
  // y) (its thickness there, of the rings'), hem(a) (how much lower its end hangs there, metres), lean (how far its strands slant:
30
37
  // the way across them goes so much round for each metre down), from (the strand its first side lies at), root (how dark it is
31
38
  // where it begins, if not as dark as hair that is gathered).
32
- function hang(patch, rings, o) {
33
- const open = o.a1 !== undefined;
39
+ function hang(patch, rings, options) {
40
+ const open = options.a1 !== undefined;
34
41
  if (!open) rings = [shut(rings[0]), ...rings];
35
- const { rows, sides, colour } = o,
36
- a0 = o.a0 ?? 0,
37
- a1 = o.a1 ?? TAU,
42
+ const { rows, sides, colour } = options,
43
+ a0 = options.a0 ?? 0,
44
+ a1 = options.a1 ?? TAU,
38
45
  first = patch.points.length / POINT,
39
46
  spans = rings.length - 1,
40
47
  at = (i, j) => first + i * (sides + 1) + j,
@@ -48,13 +55,13 @@ function hang(patch, rings, o) {
48
55
  const v = i / rows,
49
56
  t = v * spans;
50
57
  for (let j = 0; j <= sides; j++) {
51
- const a = a0 + ((a1 - a0) * j) / sides,
52
- y = through(rings, 0, t) - (o.hem ? o.hem(a) * v * v : 0),
53
- k = o.swell ? o.swell(v, a, y) : 1;
58
+ const angle = a0 + ((a1 - a0) * j) / sides,
59
+ y = through(rings, 0, t) - (options.hem ? options.hem(angle) * v * v : 0),
60
+ k = options.swell ? options.swell(v, angle, y) : 1;
54
61
  place.push(
55
- through(rings, 3, t) + Math.cos(a) * through(rings, 1, t) * k,
62
+ through(rings, 3, t) + Math.cos(angle) * through(rings, 1, t) * k,
56
63
  y,
57
- through(rings, 4, t) + Math.sin(a) * through(rings, 2, t) * k,
64
+ through(rings, 4, t) + Math.sin(angle) * through(rings, 2, t) * k,
58
65
  );
59
66
  }
60
67
  }
@@ -66,8 +73,8 @@ function hang(patch, rings, o) {
66
73
  r = (i * (sides + 1) + wrap(j + 1)) * 3,
67
74
  up = (Math.max(0, i - 1) * (sides + 1) + j) * 3,
68
75
  down = (Math.min(rows, i + 1) * (sides + 1) + j) * 3,
69
- p = (i * (sides + 1) + j) * 3,
70
- a = a0 + ((a1 - a0) * j) / sides,
76
+ vertexOffset = (i * (sides + 1) + j) * 3,
77
+ angle = a0 + ((a1 - a0) * j) / sides,
71
78
  v = i / rows,
72
79
  tx = place[r] - place[l],
73
80
  ty = place[r + 1] - place[l + 1],
@@ -79,22 +86,22 @@ function hang(patch, rings, o) {
79
86
  ny = tz * ux - tx * uz,
80
87
  nz = tx * uy - ty * ux;
81
88
  const length = Math.hypot(nx, ny, nz) || 1,
82
- out = nx * Math.cos(a) + nz * Math.sin(a) < 0 ? -1 : 1,
83
- tone = (o.tone ? o.tone(v, a) : 1) * lerp(o.root ?? ROOT_SHADE, 1, sstep(0, 0.35, v));
89
+ out = nx * Math.cos(angle) + nz * Math.sin(angle) < 0 ? -1 : 1,
90
+ tone = (options.tone ? options.tone(v, angle) : 1) * lerp(options.root ?? ROOT_SHADE, 1, sstep(0, 0.35, v));
84
91
  nx *= out / length;
85
92
  ny *= out / length;
86
93
  nz *= out / length;
87
94
  patch.points.push(
88
- place[p],
89
- place[p + 1],
90
- place[p + 2],
95
+ place[vertexOffset],
96
+ place[vertexOffset + 1],
97
+ place[vertexOffset + 2],
91
98
  nx,
92
99
  ny,
93
100
  nz,
94
101
  colour[0] * tone,
95
102
  colour[1] * tone,
96
103
  colour[2] * tone,
97
- (o.from || 0) + (round * j) / sides + (o.lean || 0) * (rings[0][0] - place[p + 1]),
104
+ (options.from || 0) + (round * j) / sides + (options.lean || 0) * (rings[0][0] - place[vertexOffset + 1]),
98
105
  );
99
106
  if (i < rows && j < sides) patch.triangles.push(at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j), at(i + 1, j + 1), at(i, j + 1));
100
107
  }
@@ -103,21 +110,22 @@ function hang(patch, rings, o) {
103
110
  // A plait hanging: two halves side by side, their strands slanting in to the line between them, each turn of the plait
104
111
  // standing out on one side and then the other. turn: the height of one turn (metres); side: which way it faces (the angle of
105
112
  // the line between its halves, as a loft counts angles).
106
- function plait(patch, rings, o) {
113
+ function plait(patch, rings, options) {
107
114
  rings = [shut(rings[0]), ...rings];
108
- const turns = Math.max(1, Math.round((rings[0][0] - rings[rings.length - 1][0]) / o.turn)),
115
+ const turns = Math.max(1, Math.round((rings[0][0] - rings[rings.length - 1][0]) / options.turn)),
109
116
  rows = turns * PLAIT_ROWS;
110
117
  for (const half of [-1, 1])
111
118
  hang(patch, rings, {
112
- ...o,
119
+ ...options,
113
120
  rows,
114
- sides: o.sides >> 1,
115
- a0: o.side + (half < 0 ? -Math.PI : 0),
116
- a1: o.side + (half < 0 ? 0 : Math.PI),
121
+ sides: options.sides >> 1,
122
+ a0: options.side + (half < 0 ? -Math.PI : 0),
123
+ a1: options.side + (half < 0 ? 0 : Math.PI),
117
124
  lean: (half * PLAIT_LEAN) / STRANDS.span,
118
- from: (o.from || 0) + half,
119
- swell: (v, a) => 1 + PLAIT_SWELL * half * Math.cos(v * turns * TAU) * Math.sin(Math.abs(a - o.side)) * sstep(0, 0.06, v),
120
- tone: (v, a) => 0.72 + 0.28 * Math.sin(Math.abs(a - o.side)),
125
+ from: (options.from || 0) + half,
126
+ swell: (v, angle) =>
127
+ 1 + PLAIT_SWELL * half * Math.cos(v * turns * TAU) * Math.sin(Math.abs(angle - options.side)) * sstep(0, 0.06, v),
128
+ tone: (v, angle) => 0.72 + 0.28 * Math.sin(Math.abs(angle - options.side)),
121
129
  });
122
130
  }
123
131
 
@@ -129,10 +137,10 @@ function knot(patch, place, at, size, colour, rows, sides) {
129
137
  for (let i = 0; i <= rows; i++)
130
138
  for (let j = 0; j <= sides; j++) {
131
139
  const polar = (i / rows) * Math.PI,
132
- a = (j / sides) * TAU,
133
- nx = Math.sin(polar) * Math.cos(a),
140
+ angle = (j / sides) * TAU,
141
+ nx = Math.sin(polar) * Math.cos(angle),
134
142
  ny = Math.cos(polar),
135
- nz = Math.sin(polar) * Math.sin(a),
143
+ nz = Math.sin(polar) * Math.sin(angle),
136
144
  tone = 0.8 + 0.2 * ny,
137
145
  v = place([at[0] + nx * size[0], at[1] + ny * size[1], at[2] + nz * size[2], nx / size[0], ny / size[1], nz / size[2]]);
138
146
  patch.points.push(
@@ -148,13 +156,20 @@ function knot(patch, place, at, size, colour, rows, sides) {
148
156
  (round * j) / sides + 0.35 * (i / rows),
149
157
  );
150
158
  if (i < rows && j < sides) {
151
- const p = first + i * (sides + 1) + j;
152
- patch.triangles.push(p, p + sides + 1, p + sides + 2, p, p + sides + 2, p + 1);
159
+ const vertexIndex = first + i * (sides + 1) + j;
160
+ patch.triangles.push(
161
+ vertexIndex,
162
+ vertexIndex + sides + 1,
163
+ vertexIndex + sides + 2,
164
+ vertexIndex,
165
+ vertexIndex + sides + 2,
166
+ vertexIndex + 1,
167
+ );
153
168
  }
154
169
  }
155
170
  }
156
171
 
157
- // The fall of long hair down the back as a near head wears it: the far fall's rings (hair-far.js, fallShape: [height, half-
172
+ // The fall of long hair down the back as a near head wears it: the distant fall's rings (fallShape: [height, half-
158
173
  // width, half-depth, middle]), but beginning on the mass of the hair itself, where the long locks leave the head, instead of
159
174
  // standing off it. crown: the ring of the mass there. Returns the rings, and at(y): the fall's half-width, half-depth and
160
175
  // middle at a height.
@@ -163,10 +178,10 @@ function nearFallRings(rings, crown) {
163
178
  at = y => {
164
179
  let i = 0;
165
180
  while (i < fallen.length - 2 && y < fallen[i + 1][0]) i++;
166
- const a = fallen[i],
167
- b = fallen[i + 1],
168
- t = Math.min(1, Math.max(0, (y - a[0]) / (b[0] - a[0])));
169
- return [lerp(a[1], b[1], t), lerp(a[2], b[2], t), lerp(a[3], b[3], t)];
181
+ const upperRing = fallen[i],
182
+ lowerRing = fallen[i + 1],
183
+ t = Math.min(1, Math.max(0, (y - upperRing[0]) / (lowerRing[0] - upperRing[0])));
184
+ return [lerp(upperRing[1], lowerRing[1], t), lerp(upperRing[2], lowerRing[2], t), lerp(upperRing[3], lowerRing[3], t)];
170
185
  };
171
186
  return { rings: fallen, at };
172
187
  }
@@ -4,7 +4,7 @@ import { STRANDS } from './hair-tags.js';
4
4
  import { POINT } from './hair-patch.js';
5
5
 
6
6
  // ════════════════════════════════════════════════════════════════════════
7
- // Locks of a near head's hair. A lock is a narrow strip that lies on the mass of the hair (hair-mass.js) along the lie of the
7
+ // Locks of a near head's hair. A lock is a narrow strip that lies on the base hair mass along the lie of the
8
8
  // cut and curves with it, each a little over the one below as hair lies in layers, lifting only toward its tip; a lock of
9
9
  // long hair is combed over the head and hangs over the fall behind. It is drawn as a ribbon that comes to a point, rounded by
10
10
  // its normals, its strands running on to its edge. Lengths are metres from the head's middle.
@@ -28,17 +28,17 @@ const _p = new THREE.Vector3(),
28
28
  _dir = new THREE.Vector3();
29
29
 
30
30
  // Moves a point off the neck and the shoulders (o.neck: how far from the neck's axis; o.shoulder: half the shoulders' breadth).
31
- function clearNeck(p, o) {
32
- if (p.y < HAIRLINE && p.z > FACE_EDGE) p.z = FACE_EDGE;
33
- if (p.y >= -0.075) return;
34
- const low = sstep(-0.14, -0.215, p.y),
35
- rx = lerp(o.neck, o.shoulder + 0.035, low),
36
- rz = lerp(o.neck, SHOULDER_DEEP, low),
37
- z = p.z + 0.012,
38
- q = Math.hypot(p.x / rx, z / rz);
31
+ function clearNeck(point, options) {
32
+ if (point.y < HAIRLINE && point.z > FACE_EDGE) point.z = FACE_EDGE;
33
+ if (point.y >= -0.075) return;
34
+ const low = sstep(-0.14, -0.215, point.y),
35
+ rx = lerp(options.neck, options.shoulder + 0.035, low),
36
+ rz = lerp(options.neck, SHOULDER_DEEP, low),
37
+ z = point.z + 0.012,
38
+ q = Math.hypot(point.x / rx, z / rz);
39
39
  if (q < 1) {
40
- p.x /= q;
41
- p.z = z / q - 0.012;
40
+ point.x /= q;
41
+ point.z = z / q - 0.012;
42
42
  }
43
43
  }
44
44
 
@@ -47,22 +47,22 @@ function clearNeck(p, o) {
47
47
  // segs, base, rise and tip (its lift off the mass at the root, how much more by its end, and how far its tip stands up besides,
48
48
  // metres), wave and coil (how far it winds from side to side and how fast), curl (how far it turns at each step, one way),
49
49
  // phase, neck and shoulder.
50
- function layLock(mass, root, o) {
50
+ function layLock(mass, root, options) {
51
51
  const points = [],
52
- step = o.length / o.segs;
52
+ step = options.length / options.segs;
53
53
  _dir.copy(root);
54
- for (let i = 0; i <= o.segs; i++) {
55
- const u = i / o.segs,
56
- lift = o.base + o.rise * u + o.tip * u * u * u;
54
+ for (let i = 0; i <= options.segs; i++) {
55
+ const u = i / options.segs,
56
+ lift = options.base + options.rise * u + options.tip * u * u * u;
57
57
  mass.at(_dir, lift, _p, _n);
58
- clearNeck(_p, o);
58
+ clearNeck(_p, options);
59
59
  points.push([_p.x, _p.y, _p.z, _n.x, _n.y, _n.z, lift]);
60
- if (i === o.segs) break;
61
- o.flow(_dir, _f);
62
- _f.x += o.aside[0];
63
- _f.z += o.aside[1];
60
+ if (i === options.segs) break;
61
+ options.flow(_dir, _f);
62
+ _f.x += options.aside[0];
63
+ _f.z += options.aside[1];
64
64
  _f.addScaledVector(_n, -_f.dot(_n)).normalize();
65
- const turn = (o.wave || 0) * Math.sin(o.phase + i * o.coil) + (o.curl || 0) * (i + 0.5);
65
+ const turn = (options.wave || 0) * Math.sin(options.phase + i * options.coil) + (options.curl || 0) * (i + 0.5);
66
66
  if (turn) _f.applyAxisAngle(_n, turn);
67
67
  mass.at(_dir, 0, _q).addScaledVector(_f, step);
68
68
  mass.skull.under(_q.x, _q.y, _q.z, _dir);
@@ -74,16 +74,16 @@ function layLock(mass, root, o) {
74
74
  // nape, then hanging over the fall of hair down the back. o: round (where round the fall it hangs, as the fall counts angles),
75
75
  // shape(y) (the fall's half-width, half-depth and middle at a height), from (the height at which it leaves the head, as a
76
76
  // share of the head's), end (how low it hangs), combed and segs (its lengths over the head and hanging), lift (metres off the mass), sway and phase (how it wavers as it hangs).
77
- function hangLock(mass, root, o) {
77
+ function hangLock(mass, root, options) {
78
78
  const points = [];
79
- _d.set(Math.cos(o.round), 0, Math.sin(o.round)).multiplyScalar(Math.sqrt(1 - o.from * o.from));
80
- _d.y = o.from;
81
- for (let i = 0; i <= o.combed; i++) {
82
- const lift = 0.001 + o.lift * Math.sin((i / o.combed) * Math.PI * 0.5);
79
+ _d.set(Math.cos(options.round), 0, Math.sin(options.round)).multiplyScalar(Math.sqrt(1 - options.from * options.from));
80
+ _d.y = options.from;
81
+ for (let i = 0; i <= options.combed; i++) {
82
+ const lift = 0.001 + options.lift * Math.sin((i / options.combed) * Math.PI * 0.5);
83
83
  mass.at(
84
84
  _s
85
85
  .copy(root)
86
- .lerp(_d, i / o.combed)
86
+ .lerp(_d, i / options.combed)
87
87
  .normalize(),
88
88
  lift,
89
89
  _p,
@@ -92,14 +92,14 @@ function hangLock(mass, root, o) {
92
92
  points.push([_p.x, _p.y, _p.z, _n.x, _n.y, _n.z, lift]);
93
93
  }
94
94
  const top = _p.y;
95
- for (let j = 1; j <= o.segs; j++) {
96
- const t = j / o.segs,
97
- y = lerp(top, o.end, t),
98
- [rx, rz, cz] = o.shape(y),
99
- a = o.round + o.sway * Math.sin(o.phase + j * 1.3) * t,
95
+ for (let j = 1; j <= options.segs; j++) {
96
+ const t = j / options.segs,
97
+ y = lerp(top, options.end, t),
98
+ [rx, rz, cz] = options.shape(y),
99
+ angle = options.round + options.sway * Math.sin(options.phase + j * 1.3) * t,
100
100
  out = 0.004 + 0.006 * t;
101
- _n.set(Math.cos(a) / rx, 0.6, Math.sin(a) / rz).normalize();
102
- points.push([Math.cos(a) * (rx + out), y, cz + Math.sin(a) * (rz + out), _n.x, _n.y, _n.z, FREE]);
101
+ _n.set(Math.cos(angle) / rx, 0.6, Math.sin(angle) / rz).normalize();
102
+ points.push([Math.cos(angle) * (rx + out), y, cz + Math.sin(angle) * (rz + out), _n.x, _n.y, _n.z, FREE]);
103
103
  }
104
104
  return points;
105
105
  }
@@ -111,18 +111,18 @@ function drawLock(patch, place, mass, points, half, colour, tone, strand) {
111
111
  const last = points.length - 1,
112
112
  first = patch.points.length / POINT;
113
113
  for (let i = 0; i <= last; i++) {
114
- const p = points[i],
115
- a = points[Math.max(0, i - 1)],
116
- b = points[Math.min(last, i + 1)],
114
+ const point = points[i],
115
+ previousPoint = points[Math.max(0, i - 1)],
116
+ nextPoint = points[Math.min(last, i + 1)],
117
117
  u = i / last,
118
118
  wide = half * (0.4 + 0.6 * Math.sin(Math.min(1, u * 3) * Math.PI * 0.5)) * lerp(1, TIP, Math.pow(u, 1.4)),
119
119
  shade = tone * lerp(ROOT_SHADE, TIP_SHADE, u);
120
- _d.set(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
121
- _n.set(p[3], p[4], p[5]);
120
+ _d.set(nextPoint[0] - previousPoint[0], nextPoint[1] - previousPoint[1], nextPoint[2] - previousPoint[2]);
121
+ _n.set(point[3], point[4], point[5]);
122
122
  _s.crossVectors(_d, _n).normalize();
123
123
  for (const k of [-1, 1]) {
124
- _p.set(p[0] + _s.x * wide * k, p[1] + _s.y * wide * k, p[2] + _s.z * wide * k);
125
- if (p[6] !== FREE) mass.at(mass.skull.under(_p.x, _p.y, _p.z, _dir), p[6], _p, _q);
124
+ _p.set(point[0] + _s.x * wide * k, point[1] + _s.y * wide * k, point[2] + _s.z * wide * k);
125
+ if (point[6] !== FREE) mass.at(mass.skull.under(_p.x, _p.y, _p.z, _dir), point[6], _p, _q);
126
126
  else _q.copy(_n);
127
127
  const v = place([
128
128
  _p.x,
@@ -7,32 +7,36 @@ const POINT = 10, // numbers to a point: its place, its normal, its colour, and
7
7
 
8
8
  // Emit each shared vertex once per strand band, correcting the winding from the supplied normals.
9
9
  function packHairPatch(points, triangles, emitVertex) {
10
- const bands = new Map(), corners = [];
10
+ const bands = new Map(),
11
+ corners = [];
11
12
  let vertexCount = 0;
12
13
  for (let t = 0; t < triangles.length; t += 3) {
13
- const a = triangles[t] * POINT,
14
- b = triangles[t + 1] * POINT,
15
- c = triangles[t + 2] * POINT,
16
- band = Math.floor((points[a + 9] + points[b + 9] + points[c + 9]) / 3 / BAND),
17
- ux = points[b] - points[a],
18
- uy = points[b + 1] - points[a + 1],
19
- uz = points[b + 2] - points[a + 2],
20
- vx = points[c] - points[a],
21
- vy = points[c + 1] - points[a + 1],
22
- vz = points[c + 2] - points[a + 2],
14
+ const firstOffset = triangles[t] * POINT,
15
+ secondOffset = triangles[t + 1] * POINT,
16
+ thirdOffset = triangles[t + 2] * POINT,
17
+ band = Math.floor((points[firstOffset + 9] + points[secondOffset + 9] + points[thirdOffset + 9]) / 3 / BAND),
18
+ ux = points[secondOffset] - points[firstOffset],
19
+ uy = points[secondOffset + 1] - points[firstOffset + 1],
20
+ uz = points[secondOffset + 2] - points[firstOffset + 2],
21
+ vx = points[thirdOffset] - points[firstOffset],
22
+ vy = points[thirdOffset + 1] - points[firstOffset + 1],
23
+ vz = points[thirdOffset + 2] - points[firstOffset + 2],
23
24
  faces =
24
- (uy * vz - uz * vy) * (points[a + 3] + points[b + 3] + points[c + 3]) +
25
- (uz * vx - ux * vz) * (points[a + 4] + points[b + 4] + points[c + 4]) +
26
- (ux * vy - uy * vx) * (points[a + 5] + points[b + 5] + points[c + 5]);
25
+ (uy * vz - uz * vy) * (points[firstOffset + 3] + points[secondOffset + 3] + points[thirdOffset + 3]) +
26
+ (uz * vx - ux * vz) * (points[firstOffset + 4] + points[secondOffset + 4] + points[thirdOffset + 4]) +
27
+ (ux * vy - uy * vx) * (points[firstOffset + 5] + points[secondOffset + 5] + points[thirdOffset + 5]);
27
28
  let put = bands.get(band);
28
- if (!put) { put = new Map(); bands.set(band, put); }
29
- for (const p of faces < 0 ? [a, c, b] : [a, b, c]) {
30
- let v = put.get(p);
29
+ if (!put) {
30
+ put = new Map();
31
+ bands.set(band, put);
32
+ }
33
+ for (const pointOffset of faces < 0 ? [firstOffset, thirdOffset, secondOffset] : [firstOffset, secondOffset, thirdOffset]) {
34
+ let v = put.get(pointOffset);
31
35
  if (v === undefined) {
32
36
  v = vertexCount++;
33
- put.set(p, v);
34
- const tag = HAIR_NEAR + Math.min(MOST, Math.max(0, points[p + 9] - band * BAND + MARGIN));
35
- emitVertex(p, tag);
37
+ put.set(pointOffset, v);
38
+ const tag = HAIR_NEAR + Math.min(MOST, Math.max(0, points[pointOffset + 9] - band * BAND + MARGIN));
39
+ emitVertex(pointOffset, tag);
36
40
  }
37
41
  corners.push(v);
38
42
  }
@@ -20,23 +20,24 @@ const _o = new THREE.Vector3(),
20
20
 
21
21
  // The mass of a cut. scale: how far out from the skull its fullest stands (across, up, fore and aft, as shares of the skull);
22
22
  // inHair(x, y, z): how far inside the hairline a direction lies; drop: how far it hangs below the ears; lumps: how deep its
23
- // lumps are (a share of the skull) and lumpy: how many there are round the head; tucked(d): where it lies under a fall of long
23
+ // lumps are (a share of the skull) and lumpy: how many there are round the head; tucked(direction): where it lies under a fall of long
24
24
  // hair and is drawn in to the skull, 0 to 1.
25
- // Returns at(d, lift, out, outward): the point of the mass at a direction from the head's middle, raised off it by lift
26
- // (metres), and the way out there; and full(d): how much of its fullness the mass has at a direction, 0 to 1.
25
+ // Returns at(direction, lift, out, outward): the point of the mass at a direction from the head's middle, raised off it by lift
26
+ // (metres), and the way out there; and full(direction): how much of its fullness the mass has at a direction, 0 to 1.
27
27
  function massOf({ skull, scale, inHair, drop = 0, lumps = 0, lumpy = 5, tucked = null }) {
28
- const full = d => (EDGE + (1 - EDGE) * sstep(-0.01, RISE, inHair(d.x, d.y, d.z))) * (tucked ? 1 - TUCK * tucked(d) : 1),
29
- swell = d =>
28
+ const full = direction =>
29
+ (EDGE + (1 - EDGE) * sstep(-0.01, RISE, inHair(direction.x, direction.y, direction.z))) * (tucked ? 1 - TUCK * tucked(direction) : 1),
30
+ swell = direction =>
30
31
  lumps *
31
- (Math.sin(d.x * lumpy * 2.3 + d.y * lumpy * 1.3) * Math.sin(d.z * lumpy * 2.1 - d.y * lumpy * 1.7) +
32
- 0.6 * Math.sin(d.y * lumpy * 2.9 + d.x * lumpy * 1.1 - d.z * lumpy * 1.9)),
33
- at = (d, lift, out, outward = _n) => {
34
- const k = full(d),
35
- more = lumps ? swell(d) * k : 0;
36
- skull.skull(d, out);
32
+ (Math.sin(direction.x * lumpy * 2.3 + direction.y * lumpy * 1.3) * Math.sin(direction.z * lumpy * 2.1 - direction.y * lumpy * 1.7) +
33
+ 0.6 * Math.sin(direction.y * lumpy * 2.9 + direction.x * lumpy * 1.1 - direction.z * lumpy * 1.9)),
34
+ at = (direction, lift, out, outward = _n) => {
35
+ const k = full(direction),
36
+ more = lumps ? swell(direction) * k : 0;
37
+ skull.skull(direction, out);
37
38
  out.set(
38
39
  out.x * (1 + (scale[0] - 1) * k + more),
39
- out.y * (1 + (scale[1] - 1) * k + more) * (d.y < 0 ? 1 + drop : 1),
40
+ out.y * (1 + (scale[1] - 1) * k + more) * (direction.y < 0 ? 1 + drop : 1),
40
41
  out.z * (1 + (scale[2] - 1) * k + more),
41
42
  );
42
43
  outward.copy(out).sub(MIDDLE).normalize();
@@ -52,7 +53,7 @@ function roundPole(pole) {
52
53
  e1 = new THREE.Vector3(1, 0, 0).addScaledVector(axis, -axis.x).normalize(),
53
54
  e2 = new THREE.Vector3().crossVectors(axis, e1),
54
55
  turn = TURNS * STRANDS.period;
55
- const across = d => (Math.atan2(d.dot(e2), d.dot(e1)) / TAU) * turn;
56
+ const across = direction => (Math.atan2(direction.dot(e2), direction.dot(e1)) / TAU) * turn;
56
57
  across.turn = turn;
57
58
  across.axis = axis;
58
59
  return across;
@@ -65,8 +66,8 @@ function createHairShells(sculptMesh) {
65
66
  return function shellOf(key, mass, across) {
66
67
  let shell = shells.get(key);
67
68
  if (shell) return shell;
68
- const soup = sculptMesh('mass:' + key, DETAIL, (d, o) => mass.at(d, 0, o)),
69
- { P, N, D } = soup,
69
+ const soup = sculptMesh('mass:' + key, DETAIL, (direction, o) => mass.at(direction, 0, o)),
70
+ { P: positions, N: normals, D: directions } = soup,
70
71
  points = [], // x, y, z, the normal, the direction
71
72
  inside = [],
72
73
  known = new Map(),
@@ -79,10 +80,21 @@ function createHairShells(sculptMesh) {
79
80
  // Shared sphere directions have identical positions along the hairline.
80
81
  for (let i = 0; i < soup.n; i++) {
81
82
  const q = i * 3,
82
- at = Math.round(D[q] * 2e4) + ',' + Math.round(D[q + 1] * 2e4) + ',' + Math.round(D[q + 2] * 2e4);
83
+ at = Math.round(directions[q] * 2e4) + ',' + Math.round(directions[q + 1] * 2e4) + ',' + Math.round(directions[q + 2] * 2e4);
83
84
  let v = known.get(at);
84
85
  if (v === undefined) {
85
- v = add(P[q], P[q + 1], P[q + 2], N[q], N[q + 1], N[q + 2], D[q], D[q + 1], D[q + 2], mass.inHair(D[q], D[q + 1], D[q + 2]));
86
+ v = add(
87
+ positions[q],
88
+ positions[q + 1],
89
+ positions[q + 2],
90
+ normals[q],
91
+ normals[q + 1],
92
+ normals[q + 2],
93
+ directions[q],
94
+ directions[q + 1],
95
+ directions[q + 2],
96
+ mass.inHair(directions[q], directions[q + 1], directions[q + 2]),
97
+ );
86
98
  known.set(at, v);
87
99
  }
88
100
  numbered[i] = v;
@@ -95,23 +107,23 @@ function createHairShells(sculptMesh) {
95
107
  if (v !== undefined) return v;
96
108
  let low = 0,
97
109
  high = 1;
98
- const a = i * 9,
99
- b = j * 9;
110
+ const firstOffset = i * 9,
111
+ secondOffset = j * 9;
100
112
  for (let s = 0; s < SEAM_STEPS; s++) {
101
113
  const t = (low + high) / 2;
102
- _d.set(points[a + 6], points[a + 7], points[a + 8])
103
- .lerp(_e1.set(points[b + 6], points[b + 7], points[b + 8]), t)
114
+ _d.set(points[firstOffset + 6], points[firstOffset + 7], points[firstOffset + 8])
115
+ .lerp(_e1.set(points[secondOffset + 6], points[secondOffset + 7], points[secondOffset + 8]), t)
104
116
  .normalize();
105
117
  if (mass.inHair(_d.x, _d.y, _d.z) > 0) low = t;
106
118
  else high = t;
107
119
  }
108
- _d.set(points[a + 6], points[a + 7], points[a + 8])
109
- .lerp(_e1.set(points[b + 6], points[b + 7], points[b + 8]), low)
120
+ _d.set(points[firstOffset + 6], points[firstOffset + 7], points[firstOffset + 8])
121
+ .lerp(_e1.set(points[secondOffset + 6], points[secondOffset + 7], points[secondOffset + 8]), low)
110
122
  .normalize();
111
123
  mass.at(_d, 0, _o);
112
124
  _e2
113
- .set(points[a + 3], points[a + 4], points[a + 5])
114
- .lerp(_e1.set(points[b + 3], points[b + 4], points[b + 5]), low)
125
+ .set(points[firstOffset + 3], points[firstOffset + 4], points[firstOffset + 5])
126
+ .lerp(_e1.set(points[secondOffset + 3], points[secondOffset + 4], points[secondOffset + 5]), low)
115
127
  .normalize();
116
128
  v = add(_o.x, _o.y, _o.z, _e2.x, _e2.y, _e2.z, _d.x, _d.y, _d.z, 0);
117
129
  crossings.set(side, v);
@@ -134,8 +146,8 @@ function createHairShells(sculptMesh) {
134
146
  for (let t = 0; t < triangles.length; t += 3) {
135
147
  let most = 0;
136
148
  for (let e = 0; e < 3; e++) {
137
- const p = triangles[t + e] * 9;
138
- let q = across(_d.set(points[p + 6], points[p + 7], points[p + 8]));
149
+ const vertexOffset = triangles[t + e] * 9;
150
+ let q = across(_d.set(points[vertexOffset + 6], points[vertexOffset + 7], points[vertexOffset + 8]));
139
151
  if (e) {
140
152
  q += across.turn * Math.round((strands[t] - q) / across.turn);
141
153
  most = Math.max(most, Math.abs(q - strands[t]));
@@ -161,17 +173,17 @@ function placeHairShell(shell, place, colour) {
161
173
  const same = new Map();
162
174
  let count = 0;
163
175
  for (let t = 0; t < triangles.length; t++) {
164
- const p = triangles[t],
165
- key = p * 8192 + Math.round(strands[t] * 1024) + 4096;
176
+ const vertexIndex = triangles[t],
177
+ key = vertexIndex * 8192 + Math.round(strands[t] * 1024) + 4096;
166
178
  let at = same.get(key);
167
179
  if (at === undefined) {
168
180
  at = count++;
169
181
  same.set(key, at);
170
- const q = p * 9,
182
+ const q = vertexIndex * 9,
171
183
  k = at * POINT;
172
184
  for (let i = 0; i < 6; i++) v[i] = points[q + i];
173
185
  place(v);
174
- colour(inside[p], points[q + 6], points[q + 7], points[q + 8], tint);
186
+ colour(inside[vertexIndex], points[q + 6], points[q + 7], points[q + 8], tint);
175
187
  for (let i = 0; i < 6; i++) placed[k + i] = v[i];
176
188
  placed[k + 6] = tint[0];
177
189
  placed[k + 7] = tint[1];
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The kinds of human head a figure's face is varied from (`HEAD_PRESETS`: man, woman, heavy, skull), and the skull that caps,
3
+ * helmets, hoods and hair lie over (`SKULL`). A world adds heads of its own peoples beside these (figure-body.js, `heads`).
4
+ * @module
5
+ */
6
+ import { headFn } from './head-shape.js';
7
+
8
+ /**
9
+ * Kinds of head, as how strongly each feature is drawn; a figure's own face is one of these varied by its seed and look.
10
+ * jaw 0..1 the breadth at the jaw's angle; chin, chinW its jut and breadth; nose its reach, noseW, noseL, bridge (a hump, or a
11
+ * dip below 0); brow the ridge; socket how deep the eyes sit; cheek the cheekbones; hollow the cheeks under them; lips their
12
+ * fullness; mouthW; eye how far the lids open; tilt the outer corners raised; slope the forehead leaning back; fold the crease
13
+ * from nose to mouth; wide and tall: the whole head's breadth and height; age and fat 0..1; scar: a seam from [x, y] to [x, y]
14
+ * (millimetres from the head's middle, x to the person's left), then its width and how far its middle bows down; dead: a dried
15
+ * face, with pits for eyes; oneEye: the two eyes healed over and one large faceted eye in the middle of the brow, under a
16
+ * jutting ridge. The shape itself is head-shape.js's `headFn`.
17
+ * @type {Record<string, object>}
18
+ */
19
+ const HEAD_PRESETS = {
20
+ man: {
21
+ jaw: 0.55,
22
+ chin: 1,
23
+ chinW: 1,
24
+ nose: 1,
25
+ noseW: 1,
26
+ noseL: 1,
27
+ bridge: 0.25,
28
+ brow: 1,
29
+ socket: 1,
30
+ cheek: 1,
31
+ hollow: 0.35,
32
+ lips: 0.88,
33
+ mouthW: 1,
34
+ eye: 0.94,
35
+ tilt: 0,
36
+ slope: 1,
37
+ fold: 1,
38
+ },
39
+ woman: {
40
+ jaw: 0.2,
41
+ chin: 0.7,
42
+ chinW: 0.84,
43
+ nose: 0.86,
44
+ noseW: 0.88,
45
+ noseL: 0.96,
46
+ bridge: -0.25,
47
+ brow: 0.3,
48
+ socket: 0.8,
49
+ cheek: 1.12,
50
+ hollow: 0.1,
51
+ lips: 1.22,
52
+ mouthW: 0.93,
53
+ eye: 1.06,
54
+ tilt: 0.35,
55
+ slope: 0.3,
56
+ fold: 0.6,
57
+ },
58
+ heavy: {
59
+ jaw: 1,
60
+ chin: 1.35,
61
+ chinW: 1.25,
62
+ nose: 1.05,
63
+ noseW: 1.3,
64
+ noseL: 1,
65
+ bridge: 0.5,
66
+ brow: 1.8,
67
+ socket: 1.3,
68
+ cheek: 1.3,
69
+ hollow: 0.4,
70
+ lips: 0.8,
71
+ mouthW: 1.1,
72
+ eye: 0.88,
73
+ tilt: 0,
74
+ slope: 1.6,
75
+ fold: 1.4,
76
+ },
77
+ skull: {
78
+ dead: 1,
79
+ jaw: 0.45,
80
+ chin: 0.9,
81
+ chinW: 0.9,
82
+ nose: 0.2,
83
+ noseW: 0.9,
84
+ noseL: 0.8,
85
+ bridge: 0,
86
+ brow: 1.7,
87
+ socket: 2.1,
88
+ cheek: 1.7,
89
+ hollow: 2.6,
90
+ lips: 0,
91
+ mouthW: 1.05,
92
+ eye: 1.3,
93
+ tilt: 0,
94
+ slope: 1.2,
95
+ fold: 0,
96
+ age: 1,
97
+ },
98
+ };
99
+
100
+ /** The skull caps and hair are laid over: a man's head with its forehead leaning back less. */
101
+ const SKULL = headFn({ ...HEAD_PRESETS.man, slope: 0.65 });
102
+
103
+ export { HEAD_PRESETS, SKULL };