roamwright 0.20.1 → 0.55.1

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 (521) 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 +139 -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/cast-actors.js +379 -0
  253. package/motion/cast-manager.js +321 -0
  254. package/motion/contact-transition.js +5 -6
  255. package/motion/crowd-alarms.js +36 -6
  256. package/motion/crowd-attention.js +108 -0
  257. package/motion/crowd-beasts.js +203 -0
  258. package/motion/crowd-camp.js +295 -0
  259. package/motion/crowd-figure.js +100 -0
  260. package/motion/crowd-herd.js +86 -0
  261. package/motion/crowd-hold.js +130 -0
  262. package/motion/crowd-pose.js +296 -0
  263. package/motion/crowd-poses.js +481 -0
  264. package/motion/crowd-routine.js +44 -14
  265. package/motion/crowd-town.js +166 -0
  266. package/motion/crowd-water.js +143 -0
  267. package/motion/deck-surface.js +4 -2
  268. package/motion/figure-acts.js +411 -0
  269. package/motion/figure-arms.js +437 -0
  270. package/motion/figure-blade-slide.js +149 -0
  271. package/motion/figure-body-place.js +180 -0
  272. package/motion/figure-bones.js +118 -0
  273. package/motion/figure-bow-draw.js +70 -0
  274. package/motion/figure-fingers.js +215 -0
  275. package/motion/figure-gaze.js +205 -0
  276. package/motion/figure-gestures.js +452 -0
  277. package/motion/figure-grip.js +134 -0
  278. package/motion/figure-head.js +287 -0
  279. package/motion/figure-legs.js +264 -0
  280. package/motion/figure-links.js +293 -0
  281. package/motion/figure-locomotion.js +391 -0
  282. package/motion/figure-mount-up.js +180 -0
  283. package/motion/figure-mount.js +201 -0
  284. package/motion/figure-pose-frame.js +375 -0
  285. package/motion/figure-pose-table.js +156 -0
  286. package/motion/figure-pose.js +343 -0
  287. package/motion/figure-seat.js +267 -0
  288. package/motion/figure-sway.js +125 -0
  289. package/motion/flier-corvid-pose.js +74 -0
  290. package/motion/flier-flight-air.js +122 -0
  291. package/motion/flier-flight-echelon.js +164 -0
  292. package/motion/flier-flight-roost.js +131 -0
  293. package/motion/flier-swarm-flight.js +252 -0
  294. package/motion/formation.js +193 -0
  295. package/motion/instance-sight.js +8 -1
  296. package/motion/melee-contact.js +143 -0
  297. package/motion/moorings.js +48 -0
  298. package/motion/path-steering.js +358 -0
  299. package/motion/player.js +7 -6
  300. package/motion/quadruped.js +109 -33
  301. package/motion/spaces.js +58 -6
  302. package/motion/speech-cadence.js +304 -0
  303. package/motion/vessel-motion.js +57 -0
  304. package/motion/walk-grid.js +235 -0
  305. package/motion/weather.js +70 -12
  306. package/motion/wind.js +27 -1
  307. package/package.json +46 -4
  308. package/rendering/alpha-mips.js +340 -0
  309. package/rendering/animal-camel-figure.js +29 -0
  310. package/rendering/animal-canine-figure.js +59 -0
  311. package/rendering/animal-cattle-figure.js +36 -0
  312. package/rendering/animal-horse-figure.js +49 -0
  313. package/rendering/atmosphere.js +86 -0
  314. package/rendering/camera-track.js +156 -0
  315. package/rendering/{road-surface.js → cart-track.js} +40 -11
  316. package/rendering/cast-stage.js +299 -0
  317. package/rendering/caster-motion.js +2 -1
  318. package/rendering/cell-lod-options.js +46 -0
  319. package/rendering/cell-lod.js +665 -80
  320. package/rendering/cloth-material.js +140 -0
  321. package/rendering/cloud-dome.js +2 -2
  322. package/rendering/compilation-schedule.js +18 -10
  323. package/rendering/contact-shadows.js +5 -2
  324. package/rendering/context.js +47 -8
  325. package/rendering/crowd-batches.js +420 -0
  326. package/rendering/crowd-herd.js +198 -0
  327. package/rendering/crowd-rig.js +132 -0
  328. package/rendering/crowd-skinning.js +52 -9
  329. package/rendering/crowd-update.js +419 -0
  330. package/rendering/crowd-visibility.js +107 -0
  331. package/rendering/day-cycle-defaults.js +200 -0
  332. package/rendering/day-cycle.js +487 -0
  333. package/rendering/daylight.js +1 -3
  334. package/rendering/detail-range.js +6 -5
  335. package/rendering/dof.js +11 -4
  336. package/rendering/effects-frame.js +149 -0
  337. package/rendering/effects-water-rises.js +221 -0
  338. package/rendering/energy-stream.js +128 -0
  339. package/rendering/facade-glass-material.js +105 -0
  340. package/rendering/far-shadow.js +81 -54
  341. package/rendering/field-surface.js +138 -0
  342. package/rendering/figure-shield.js +105 -0
  343. package/rendering/figure-skeleton.js +329 -0
  344. package/rendering/fire-light-watch.js +197 -0
  345. package/rendering/fire-pools.js +148 -0
  346. package/rendering/flame-sources.js +86 -0
  347. package/rendering/flier-bird-looks.js +97 -0
  348. package/rendering/flier-corvid-figure.js +67 -0
  349. package/rendering/flier-long-body-company.js +169 -0
  350. package/rendering/flier-swarm.js +186 -0
  351. package/rendering/flocks.js +6 -2
  352. package/rendering/garment-material.js +145 -49
  353. package/rendering/glsl-literal.js +19 -0
  354. package/rendering/ground-marks.js +316 -0
  355. package/rendering/hair-strands.js +38 -24
  356. package/rendering/height-haze.js +80 -33
  357. package/rendering/height-probe.js +15 -3
  358. package/rendering/house-kit-meshes.js +124 -0
  359. package/rendering/interior-bake.js +807 -0
  360. package/rendering/label-layout.js +13 -3
  361. package/rendering/label-range.js +5 -2
  362. package/rendering/lamp-light-map.js +159 -0
  363. package/rendering/lamp-maps.js +62 -0
  364. package/rendering/lamp-wash.js +51 -0
  365. package/rendering/light-budget.js +19 -3
  366. package/rendering/light-points.js +21 -5
  367. package/rendering/local-lights.js +27 -7
  368. package/rendering/material-lod.js +5 -6
  369. package/rendering/memory-estimate.js +84 -0
  370. package/rendering/moored-fleet.js +186 -0
  371. package/rendering/nameplate-groups.js +84 -0
  372. package/rendering/nameplates.js +386 -0
  373. package/rendering/part-costs.js +104 -0
  374. package/rendering/particle-bursts.js +386 -0
  375. package/rendering/particle-emitters.js +61 -25
  376. package/rendering/particle-light-bursts.js +189 -0
  377. package/rendering/particles.js +134 -34
  378. package/rendering/pen-flocks.js +118 -0
  379. package/rendering/piece-batch.js +282 -6
  380. package/rendering/planar-reflection-options.js +159 -0
  381. package/rendering/planar-reflection.js +780 -77
  382. package/rendering/plant-cells.js +122 -0
  383. package/rendering/plant-reeds.js +113 -0
  384. package/rendering/plant-shade-trees.js +239 -0
  385. package/rendering/plant-tuft-patch.js +122 -0
  386. package/rendering/post-shaders.js +84 -21
  387. package/rendering/post.js +39 -19
  388. package/rendering/pressed-cover.js +135 -0
  389. package/rendering/prop-dig.js +136 -0
  390. package/rendering/room-light.js +250 -0
  391. package/rendering/room-materials.js +78 -0
  392. package/rendering/room-space.js +111 -0
  393. package/rendering/scene-lights.js +106 -0
  394. package/rendering/sea-shaders.js +83 -26
  395. package/rendering/settlement-approach.js +226 -0
  396. package/rendering/settlement-dissolve.js +89 -0
  397. package/rendering/settlement-quarter-warm.js +55 -0
  398. package/rendering/settlement-quarter.js +477 -0
  399. package/rendering/settlement-switch.js +42 -0
  400. package/rendering/settlement-town.js +110 -0
  401. package/rendering/shader-warmup.js +80 -36
  402. package/rendering/shadow-depth.js +40 -18
  403. package/rendering/ship-meshes.js +150 -0
  404. package/rendering/shot-cuts.js +68 -0
  405. package/rendering/sky-occlusion.js +42 -15
  406. package/rendering/sky-pmrem.js +216 -0
  407. package/rendering/sky.js +112 -50
  408. package/rendering/smoke-shadows.js +201 -0
  409. package/rendering/stage-framing.js +182 -0
  410. package/rendering/stage-lights.js +46 -39
  411. package/rendering/stain-material.js +74 -0
  412. package/rendering/static-point-shadow.js +62 -23
  413. package/rendering/still-casters.js +77 -27
  414. package/rendering/strata-material.js +2 -2
  415. package/rendering/street-lamps.js +166 -0
  416. package/rendering/sunbeam-motes.js +670 -0
  417. package/rendering/surface-light.js +65 -6
  418. package/rendering/surface-material.js +306 -0
  419. package/rendering/surface-projection.js +32 -0
  420. package/rendering/surface-snippets.js +314 -0
  421. package/rendering/taa.js +49 -18
  422. package/rendering/tree-impostor.js +929 -0
  423. package/rendering/vehicle-train.js +92 -0
  424. package/rendering/viewport.js +67 -4
  425. package/rendering/water-material.js +270 -82
  426. package/rendering/waypoint-beacons.js +191 -0
  427. package/rendering/world-matrices.js +0 -2
  428. package/ruff.toml +20 -0
  429. package/runtime/cue-cursor.js +21 -0
  430. package/runtime/device-quality.js +13 -2
  431. package/runtime/device.js +73 -0
  432. package/runtime/diagnostic-log.js +11 -3
  433. package/runtime/effect-sites.js +85 -0
  434. package/runtime/figure-orders.js +59 -0
  435. package/runtime/first-use.js +8 -5
  436. package/runtime/foley-script.js +124 -0
  437. package/runtime/foley-strides.js +333 -0
  438. package/runtime/frame-pacing.js +18 -4
  439. package/runtime/frame-yield.js +18 -0
  440. package/runtime/gpu-timing.js +8 -4
  441. package/runtime/grid-cache.js +16 -6
  442. package/runtime/grid-rows.js +5 -5
  443. package/runtime/hand-over.js +7 -2
  444. package/runtime/land-bake.js +78 -0
  445. package/runtime/lazy-sets.js +105 -0
  446. package/runtime/pool.js +17 -3
  447. package/runtime/quality-fit.js +59 -27
  448. package/runtime/region-pass-lay.js +40 -0
  449. package/runtime/region-pass.js +78 -0
  450. package/runtime/search.js +6 -2
  451. package/runtime/settlement-reach.js +42 -0
  452. package/runtime/sound-calls.js +113 -0
  453. package/runtime/sound-impacts.js +297 -0
  454. package/runtime/sound-voices.js +194 -0
  455. package/runtime/soundscape.js +282 -0
  456. package/runtime/spatial-audio.js +69 -20
  457. package/runtime/steady-frames.js +221 -0
  458. package/runtime/withdrawable-task.js +19 -8
  459. package/scripts/app-parts.mjs +118 -0
  460. package/scripts/bake-revisions.mjs +81 -0
  461. package/scripts/browser-scripts.mjs +64 -0
  462. package/scripts/bundle.mjs +192 -0
  463. package/scripts/check-app.sh +26 -0
  464. package/scripts/eslint-config.mjs +119 -0
  465. package/scripts/format.sh +92 -0
  466. package/scripts/keep-builds.mjs +158 -0
  467. package/scripts/layers.mjs +112 -0
  468. package/scripts/lint.sh +49 -0
  469. package/scripts/module-graph.mjs +123 -0
  470. package/scripts/pre-commit.sh +38 -0
  471. package/scripts/serve.py +5 -3
  472. package/scripts/site.mjs +358 -0
  473. package/scripts/test-runner.sh +42 -0
  474. package/scripts/vendor.mjs +221 -0
  475. package/scripts/verify-publish.mjs +175 -0
  476. package/scripts/world.mk +59 -0
  477. package/tools/README.md +73 -0
  478. package/tools/contact-sheet.cjs +137 -0
  479. package/tools/cpu-profile.cjs +275 -0
  480. package/tools/cpu-profile.test.cjs +98 -0
  481. package/tools/first-draws.cjs +395 -0
  482. package/tools/flight-guard.cjs +482 -0
  483. package/tools/flight-guard.test.cjs +153 -0
  484. package/tools/flight-profile.cjs +145 -0
  485. package/tools/frame-bench.cjs +336 -0
  486. package/tools/frame-parts.cjs +365 -0
  487. package/tools/ios-sim.sh +145 -0
  488. package/tools/load-audit.cjs +201 -0
  489. package/tools/look-compare.cjs +304 -0
  490. package/tools/look-guard.cjs +407 -0
  491. package/tools/look-guard.test.cjs +93 -0
  492. package/tools/look-stats.cjs +185 -0
  493. package/tools/look-stats.test.cjs +71 -0
  494. package/tools/memory-audit.cjs +323 -0
  495. package/tools/page-driver.cjs +320 -0
  496. package/tools/page-driver.test.cjs +219 -0
  497. package/tools/program-census-report.cjs +191 -0
  498. package/tools/program-census.cjs +465 -0
  499. package/tools/program-census.test.cjs +332 -0
  500. package/tools/remote-runner.sh +265 -0
  501. package/tools/runners.test.cjs +59 -0
  502. package/tools/scene-audit-beat.cjs +344 -0
  503. package/tools/scene-audit-sheet.cjs +282 -0
  504. package/tools/scene-audit.cjs +471 -0
  505. package/tools/scene-audit.test.cjs +201 -0
  506. package/tools/scene-batch.cjs +219 -0
  507. package/tools/scene-bench.cjs +149 -0
  508. package/tools/scene-bench.test.cjs +33 -0
  509. package/tools/scene-run.cjs +443 -0
  510. package/tools/scene-run.test.cjs +94 -0
  511. package/tools/servers.sh +59 -0
  512. package/tools/shader-arrival.cjs +316 -0
  513. package/tools/shader-renewal.cjs +53 -0
  514. package/tools/shader-renewal.test.cjs +115 -0
  515. package/tools/speed-guard.cjs +258 -0
  516. package/tools/stills.cjs +492 -0
  517. package/tools/stills.test.cjs +49 -0
  518. package/tools/turns.sh +7 -0
  519. package/tools/yaml.cjs +158 -0
  520. package/examples/viaduct.css +0 -75
  521. package/rendering/light-shafts.js +0 -131
@@ -0,0 +1,322 @@
1
+ import * as THREE from 'three';
2
+ import { lerp } from '../math/scalar.js';
3
+ import { C } from './primitives.js';
4
+ import { eye, scatter, tube } from './animal-skin.js';
5
+ import { triangle } from './figure-sculpt.js';
6
+
7
+ // ════════════════════════════════════════════════════════════════════════
8
+ // A large corvid (a raven, a crow, a rook), built as one is: a body clad in contour feathers, a head that flows into the neck
9
+ // with a heavy wedge of a bill, the bristles over its nostrils and the shaggy hackles of its throat, a graduated wedge of a tail,
10
+ // and scaled legs with three toes forward and one back. Sizes are in metres for a bird about a metre tall (scale it by its
11
+ // height), nose to +z. Everything is drawn into a GeometryBuilder (`GB`) as weighted vertices with no bones, tagged for a figure
12
+ // material: glossy plumage, smooth horn, the eyes. The wings are in `flier-corvid-wings.js`.
13
+ // ════════════════════════════════════════════════════════════════════════
14
+ export const FEATHER_TAG = 1.6; // a figure material's tag of glossy plumage: between skin (1) and an eye (2)
15
+ export const HORN_TAG = 1; // smooth horn: the bill, the legs' scutes and the claws
16
+ export const NO_BONES = [0];
17
+ /** Metres the body is drawn below where its parts are laid out, so that it sits low on its short legs. */
18
+ export const CORVID_SIT = 0.07;
19
+ /** Where the head turns (its pivot), at a height of 1. */
20
+ export const CORVID_NECK = [0, 0.86 - CORVID_SIT, 0.215];
21
+ /** The wings' shoulders (x either side), at a height of 1. */
22
+ export const CORVID_SHOULDER = [0.13, 0.69 - CORVID_SIT, 0.13];
23
+ /** The bird's height at a scale of 1: its crown over its feet, in metres. */
24
+ export const CORVID_TALL = 0.95;
25
+ const FOOT = [0.078, 0, 0.03];
26
+
27
+ /**
28
+ * A corvid's look: `feathers` its plumage and `horn` its bill and legs (hex, sRGB), `shade` a share that makes one bird of a roost a
29
+ * little darker or lighter than the next, and `height` its size (1: about a metre tall). The default is a dark grey bird with a
30
+ * slate bill.
31
+ */
32
+ export const CORVID_LOOK = { feathers: 0x303238, horn: 0x383532, shade: 1, height: 1 };
33
+
34
+ const _at = new THREE.Matrix4();
35
+ /** Puts what the builder draws next at `local` within the frame F the caller draws the bird in (either may be null). */
36
+ export function placeIn(b, F, local = null) {
37
+ b.M = F && local ? _at.multiplyMatrices(F, local) : local || F;
38
+ }
39
+
40
+ // Plumage, from the look's colour: blue and violet in the gloss of what faces up, a little lighter at the feathers' tips.
41
+ function plumage(c) {
42
+ const sheen = [c[0] * 0.92, c[1] * 1.02, c[2] * 1.32];
43
+ return (col, x, y, z, nx, ny) => {
44
+ const up = Math.max(0, ny),
45
+ grain = 0.86 + 0.28 * scatter(x * 91.7 + y * 57.3 + z * 33.1);
46
+ for (let i = 0; i < 3; i++) col[i] = lerp(c[i], sheen[i], up) * grain;
47
+ col[3] = FEATHER_TAG;
48
+ };
49
+ }
50
+
51
+ /**
52
+ * The colours a corvid is drawn in, from its look: `coat` (the plumage's colour by the point, a coat function as `tube` reads
53
+ * one), `horn` (linear) and `tip` (the feathers' tips, linear).
54
+ *
55
+ * @param {typeof CORVID_LOOK} [look=CORVID_LOOK]
56
+ */
57
+ export function corvidPalette(look = CORVID_LOOK) {
58
+ const feathers = C(look.feathers).map(v => v * (look.shade ?? 1));
59
+ return { coat: plumage(feathers), horn: C(look.horn), tip: [feathers[0] * 1.08, feathers[1] * 1.14, feathers[2] * 1.38] };
60
+ }
61
+
62
+ /**
63
+ * One feather: a vane along a curve from a, bowed towards m, to b, its upper face to `out`, `half` wide at its broadest, raised
64
+ * along its shaft, coloured from col at the quill to end at the tip and darker down its trailing edge where the next lies over it.
65
+ */
66
+ export function feather(gb, a, m, b, out, half, col, end, rows = 4) {
67
+ let prev = null;
68
+ for (let i = 0; i <= rows; i++) {
69
+ const u = i / rows,
70
+ v = 1 - u,
71
+ p = [0, 1, 2].map(k => v * v * a[k] + 2 * u * v * m[k] + u * u * b[k]),
72
+ d = [0, 1, 2].map(k => v * (m[k] - a[k]) + u * (b[k] - m[k])),
73
+ s = [d[1] * out[2] - d[2] * out[1], d[2] * out[0] - d[0] * out[2], d[0] * out[1] - d[1] * out[0]],
74
+ sl = Math.hypot(s[0], s[1], s[2]) || 1,
75
+ wide = half * (u < 0.35 ? 0.55 + (0.45 * u) / 0.35 : 1 - 0.78 * ((u - 0.35) / 0.65) ** 2),
76
+ rib = half * 0.22 * (1 - u),
77
+ c = [0, 1, 2].map(k => lerp(col[k], end[k], u * u)),
78
+ point = (k, lift, shade) => [
79
+ p[0] + (s[0] / sl) * wide * k + out[0] * lift,
80
+ p[1] + (s[1] / sl) * wide * k + out[1] * lift,
81
+ p[2] + (s[2] / sl) * wide * k + out[2] * lift,
82
+ out[0] * 0.85 + (s[0] / sl) * 0.5 * k,
83
+ out[1] * 0.85 + (s[1] / sl) * 0.5 * k,
84
+ out[2] * 0.85 + (s[2] / sl) * 0.5 * k,
85
+ c.map(x => x * shade),
86
+ ],
87
+ row = [point(-1, 0, 0.78), point(0, rib, 1), point(1, 0, 1)];
88
+ if (prev) {
89
+ triangle(gb, prev[0], prev[1], row[1], c, 0);
90
+ triangle(gb, prev[0], row[1], row[0], c, 0);
91
+ triangle(gb, prev[1], prev[2], row[2], c, 0);
92
+ triangle(gb, prev[1], row[2], row[1], c, 0);
93
+ }
94
+ prev = row;
95
+ }
96
+ }
97
+ export const lerp3 = (a, b, u) => [lerp(a[0], b[0], u), lerp(a[1], b[1], u), lerp(a[2], b[2], u)];
98
+ export const unit = (x, y, z) => {
99
+ const l = Math.hypot(x, y, z);
100
+ return [x / l, y / l, z / l];
101
+ };
102
+
103
+ /**
104
+ * The body, in the frame F (null: the builder's own): breast, belly and back from the root of the tail to the neck, under contour
105
+ * feathers that lie back towards the tail and stand out shaggier on the belly and the front of the neck; the feathered thighs; the
106
+ * tail; the legs and toes. Without `fine` the contour feathers are left to the surface's colour (a bird seen from further off).
107
+ */
108
+ export function corvidBody(b, coat, horn, tip, F, fine) {
109
+ const sit = new THREE.Matrix4().makeTranslation(0, -CORVID_SIT, 0);
110
+ placeIn(b, F, sit);
111
+ tube(
112
+ b,
113
+ [
114
+ [0.36, -0.36, 0, 0, 0, 0],
115
+ [0.38, -0.31, 0.07, 0.05, 0.06, 0],
116
+ [0.42, -0.21, 0.13, 0.11, 0.13, 0],
117
+ [0.47, -0.09, 0.17, 0.15, 0.18, 0],
118
+ [0.54, 0.03, 0.18, 0.16, 0.2, 0],
119
+ [0.63, 0.13, 0.16, 0.13, 0.17, 0],
120
+ [0.73, 0.19, 0.115, 0.09, 0.12, 0],
121
+ [0.83, 0.22, 0.088, 0.078, 0.085, 0],
122
+ [0.92, 0.23, 0.07, 0.066, 0.07, 0],
123
+ [0.97, 0.235, 0, 0, 0, 0],
124
+ ],
125
+ {
126
+ chain: NO_BONES,
127
+ around: 18,
128
+ sub: 3,
129
+ coat,
130
+ lay: -1,
131
+ droop: 0.15,
132
+ fur:
133
+ fine &&
134
+ ((out, x, y, z, nx, ny, nz, a, v) => {
135
+ const belly = ny < -0.3 && v > 0.2 && v < 0.62 ? 1 : 0,
136
+ throat = v > 0.66 && nz > 0.25 ? 1 : 0;
137
+ out[0] = (ny > 0.3 ? 0.026 : 0.034) + 0.022 * belly + 0.034 * throat;
138
+ out[1] = 0.02 + 0.1 * belly + 0.18 * throat;
139
+ out[2] = out[0] * (throat ? 0.4 : 0.7);
140
+ out[3] = 2;
141
+ out[4] = 1.05;
142
+ }),
143
+ },
144
+ );
145
+ for (const s of [-1, 1]) {
146
+ // the thighs, feathered to the heel
147
+ placeIn(b, F, sit);
148
+ tube(
149
+ b,
150
+ [
151
+ [0.44, 0.02, 0, 0, 0, 0],
152
+ [0.4, 0.02, 0.058, 0.06, 0.06, 0],
153
+ [0.31, 0.0, 0.05, 0.05, 0.055, 0],
154
+ [0.23, -0.01, 0.034, 0.034, 0.034, 0],
155
+ [0.2, -0.01, 0, 0, 0, 0],
156
+ ],
157
+ {
158
+ chain: NO_BONES,
159
+ x: s * 0.085,
160
+ side: s,
161
+ around: 10,
162
+ sub: 2,
163
+ coat,
164
+ lay: 1,
165
+ droop: 0.4,
166
+ fur:
167
+ fine &&
168
+ (out => {
169
+ out[0] = 0.05;
170
+ out[1] = 0.12;
171
+ out[2] = 0.03;
172
+ out[3] = 2;
173
+ out[4] = 1.05;
174
+ }),
175
+ },
176
+ );
177
+ leg(b, s, horn, F);
178
+ }
179
+ placeIn(b, F, sit);
180
+ tail(b, coat, tip);
181
+ placeIn(b, F);
182
+ }
183
+
184
+ // A leg below the feathers: the tarsus in its scutes, three toes forward and one back, each ending in a hooked claw.
185
+ function leg(b, s, horn, F) {
186
+ placeIn(b, F);
187
+ const scutes = (col, x, y) => {
188
+ const band = 0.82 + 0.3 * Math.abs(Math.sin(y * 170));
189
+ for (let i = 0; i < 3; i++) col[i] = horn[i] * band;
190
+ col[3] = HORN_TAG;
191
+ };
192
+ tube(
193
+ b,
194
+ [
195
+ [0.012, 0.03, 0, 0, 0, 0],
196
+ [0.02, 0.03, 0.019, 0.019, 0.021, 0],
197
+ [0.09, 0.022, 0.017, 0.017, 0.019, 0],
198
+ [0.15, 0.01, 0.019, 0.02, 0.021, 0],
199
+ [0.2, 0.0, 0.026, 0.027, 0.027, 0],
200
+ [0.22, -0.002, 0, 0, 0, 0],
201
+ ],
202
+ { chain: NO_BONES, x: s * FOOT[0], side: s, around: 8, sub: 2, coat: scutes },
203
+ );
204
+ const M = new THREE.Matrix4(),
205
+ claw = horn.map(x => x * 0.55);
206
+ for (const [turn, len] of [
207
+ [-0.38, 0.062],
208
+ [0, 0.078],
209
+ [0.38, 0.062],
210
+ [Math.PI, 0.046],
211
+ ]) {
212
+ placeIn(b, F, M.makeRotationY(turn * s).setPosition(s * FOOT[0], FOOT[1], FOOT[2]));
213
+ const toe = (col, x, y, z) => {
214
+ const c = z > len ? claw : horn,
215
+ knuckle = 0.85 + 0.25 * Math.abs(Math.sin(z * 120));
216
+ for (let i = 0; i < 3; i++) col[i] = c[i] * knuckle;
217
+ col[3] = HORN_TAG;
218
+ };
219
+ tube(
220
+ b,
221
+ [
222
+ [0.012, -0.005, 0, 0, 0, 0],
223
+ [0.012, 0, 0.009, 0.008, 0.007, 0],
224
+ [0.011, len * 0.5, 0.008, 0.007, 0.007, 0],
225
+ [0.009, len, 0.006, 0.006, 0.005, 0],
226
+ [0.006, len + 0.018, 0.0035, 0.0035, 0.003, 0],
227
+ [-0.002, len + 0.032, 0.0015, 0.0015, 0.001, 0],
228
+ [-0.006, len + 0.036, 0, 0, 0, 0],
229
+ ],
230
+ { chain: NO_BONES, around: 7, sub: 2, coat: toe },
231
+ );
232
+ }
233
+ placeIn(b, F);
234
+ }
235
+
236
+ // The tail: twelve feathers in a graduated wedge, the middle pair longest, angled down behind the perch, with coverts over its root.
237
+ function tail(b, coat, tip) {
238
+ const col = [0, 0, 0, 0],
239
+ dir = unit(0, -0.5, -0.866),
240
+ out = unit(0, 0.866, -0.5);
241
+ for (let i = 0; i < 12; i++) {
242
+ const k = (i - 5.5) / 5.5, // -1 the outer feather on the left, 1 on the right
243
+ len = 0.5 - 0.14 * k * k,
244
+ root = [k * 0.05, 0.37 + 0.004 * (1 - Math.abs(k)), -0.31],
245
+ end = [root[0] + k * 0.1 + dir[0] * len, root[1] + dir[1] * len + 0.006 * (1 - Math.abs(k)), root[2] + dir[2] * len];
246
+ coat(col, root[0], root[1], root[2], 0, 1, 0);
247
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.036, col, tip);
248
+ }
249
+ for (let i = 0; i < 5; i++) {
250
+ const k = (i - 2) / 2,
251
+ root = [k * 0.05, 0.42, -0.25],
252
+ end = [k * 0.07, 0.34, -0.42];
253
+ coat(col, root[0], root[1], root[2], 0, 1, 0);
254
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.04, col, tip, 3);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * The head, about its pivot at the top of the neck (`CORVID_NECK`): the skull with its flat crown and deep throat under short
260
+ * feathers and the long lanceolate hackles; the eyes; the bill, deep and pressed from the sides, its ridge curving down to a
261
+ * hooked tip, with the line of the gape; the bristles lying forward over the nostrils.
262
+ */
263
+ export function corvidHead(b, coat, horn, tip) {
264
+ tube(
265
+ b,
266
+ [
267
+ [0.07, -0.085, 0, 0, 0, 0],
268
+ [0.072, -0.07, 0.045, 0.045, 0.06, 0, 2.3],
269
+ [0.075, -0.04, 0.066, 0.06, 0.085, 0, 2.3],
270
+ [0.078, 0.0, 0.07, 0.062, 0.085, 0, 2.3],
271
+ [0.078, 0.035, 0.062, 0.058, 0.07, 0, 2.2],
272
+ [0.074, 0.065, 0.048, 0.05, 0.055, 0, 2.1],
273
+ [0.07, 0.09, 0.034, 0.04, 0.04, 0, 2],
274
+ [0.068, 0.105, 0, 0, 0, 0],
275
+ ],
276
+ {
277
+ chain: NO_BONES,
278
+ around: 16,
279
+ sub: 3,
280
+ coat,
281
+ lay: -1,
282
+ droop: 0.5,
283
+ fur: (out, x, y, z, nx, ny, nz, a, v) => {
284
+ const throat = ny < -0.25 && v < 0.75 ? 1 : 0;
285
+ if (!throat && v > 0.8) return false; // the face before the eyes is smooth
286
+ out[0] = throat ? 0.085 : 0.022;
287
+ out[1] = throat ? 0.3 : 0.05;
288
+ out[2] = throat ? 0.026 : 0.016;
289
+ out[3] = throat ? 3 : 2;
290
+ out[4] = throat ? 1.25 : 1.1;
291
+ },
292
+ },
293
+ );
294
+ for (const s of [-1, 1]) eye(b, s * 0.056, 0.088, 0.035, 0.012, 0.012, 0.012, [0.035, 0.022, 0.016]);
295
+ const bill = (col, x, y, z, nx, ny, nz, a) => {
296
+ const gape = Math.abs(Math.sin(a) + 0.22) < 0.09 && z < 0.215 ? 0.35 : 1; // the line where the mandibles meet
297
+ for (let i = 0; i < 3; i++) col[i] = horn[i] * gape * (0.9 + 0.2 * Math.max(0, ny));
298
+ col[3] = HORN_TAG;
299
+ };
300
+ tube(
301
+ b,
302
+ [
303
+ [0.066, 0.07, 0.028, 0.034, 0.03, 0, 2.6],
304
+ [0.064, 0.1, 0.025, 0.031, 0.027, 0, 2.6],
305
+ [0.06, 0.14, 0.02, 0.026, 0.021, 0, 2.4],
306
+ [0.054, 0.18, 0.014, 0.02, 0.014, 0, 2.2],
307
+ [0.045, 0.215, 0.008, 0.014, 0.007, 0, 2],
308
+ [0.032, 0.24, 0.0035, 0.007, 0.002, 0, 2],
309
+ [0.022, 0.25, 0, 0, 0, 0],
310
+ ],
311
+ { chain: NO_BONES, around: 12, sub: 3, coat: bill },
312
+ );
313
+ const col = [0, 0, 0, 0];
314
+ for (let i = 0; i < 9; i++) {
315
+ const around = lerp(-1.2, 1.2, i / 8),
316
+ out = [Math.sin(around), Math.cos(around), 0],
317
+ root = [out[0] * 0.032, 0.066 + out[1] * 0.036, 0.085],
318
+ end = [out[0] * 0.024, 0.066 + out[1] * 0.03, 0.14 - Math.abs(around) * 0.012];
319
+ coat(col, root[0], root[1], root[2], out[0], out[1], 0);
320
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.011, col, tip, 2);
321
+ }
322
+ }
@@ -0,0 +1,154 @@
1
+ import * as THREE from 'three';
2
+ import { lerp } from '../math/scalar.js';
3
+ import { tube } from './animal-skin.js';
4
+ import {
5
+ CORVID_LOOK,
6
+ CORVID_NECK,
7
+ CORVID_SIT,
8
+ NO_BONES,
9
+ corvidBody,
10
+ corvidHead,
11
+ corvidPalette,
12
+ feather,
13
+ lerp3,
14
+ placeIn,
15
+ unit,
16
+ } from './flier-corvid-body.js';
17
+
18
+ // ════════════════════════════════════════════════════════════════════════
19
+ // A large corvid's wings (`flier-corvid-body.js` builds the rest): folded along the body over the tail, or spread in flight with
20
+ // the outer primaries narrowed into the fingers it soars on; and a whole bird perched with its wings folded, drawn into a builder
21
+ // with the rest of a scene's still parts.
22
+ // ════════════════════════════════════════════════════════════════════════
23
+
24
+ /**
25
+ * A wing folded along the body, in the body's frame (the caller moves it to its shoulder): the coverts over the shoulder, the
26
+ * primaries beneath, crossing over the tail, the secondaries over them and the tertials on top, over the back. Without `fine` the
27
+ * coverts' feathers are left to the surface's colour.
28
+ *
29
+ * @param {object} b The builder (`GB`).
30
+ * @param {1 | -1} s The side: 1 the right wing.
31
+ */
32
+ export function foldedCorvidWing(b, s, coat, tip, fine = true) {
33
+ const col = [0, 0, 0, 0],
34
+ out = unit(s * 0.95, 0.3, 0),
35
+ X = p => [p[0] * s, p[1], p[2]];
36
+ for (let i = 0; i < 9; i++) {
37
+ const u = i / 8,
38
+ root = X([0.185 - 0.004 * u, lerp(0.62, 0.56, u), lerp(0.1, 0.0, u)]),
39
+ mid = X([0.15 - 0.003 * i, 0.44 - 0.01 * u, -0.22]),
40
+ end = X([lerp(0.07, 0.03, u), lerp(0.27, 0.24, u), lerp(-0.6, -0.64, u)]);
41
+ coat(col, root[0], root[1], root[2], out[0], out[1], out[2]);
42
+ feather(b, root, mid, end, out, 0.032, col, tip, 5);
43
+ }
44
+ for (let i = 0; i < 9; i++) {
45
+ const u = i / 8,
46
+ lift = 0.004 * (8 - i),
47
+ root = X([0.18 + lift, lerp(0.6, 0.5, u), lerp(0.05, -0.12, u)]),
48
+ end = X([lerp(0.175, 0.15, u) + lift, lerp(0.4, 0.36, u), lerp(-0.27, -0.36, u)]);
49
+ coat(col, root[0], root[1], root[2], out[0], out[1], out[2]);
50
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.04, col, tip);
51
+ }
52
+ const back = unit(s * 0.55, 0.83, 0);
53
+ for (let i = 0; i < 3; i++) {
54
+ const u = i / 2,
55
+ root = X([0.17, lerp(0.62, 0.57, u), lerp(0.02, -0.06, u)]),
56
+ end = X([lerp(0.12, 0.1, u), lerp(0.46, 0.44, u), lerp(-0.27, -0.31, u)]);
57
+ coat(col, root[0], root[1], root[2], back[0], back[1], back[2]);
58
+ feather(b, root, lerp3(root, end, 0.5), end, back, 0.046, col, tip);
59
+ }
60
+ // the coverts: a pad over the shoulder in short feathers that lie back
61
+ tube(
62
+ b,
63
+ [
64
+ [0.71, 0.15, 0, 0, 0, 0],
65
+ [0.69, 0.12, 0.03, 0.05, 0.05, 0],
66
+ [0.63, 0.04, 0.04, 0.075, 0.07, 0],
67
+ [0.55, -0.06, 0.035, 0.07, 0.06, 0],
68
+ [0.48, -0.13, 0.02, 0.05, 0.04, 0],
69
+ [0.45, -0.16, 0, 0, 0, 0],
70
+ ],
71
+ {
72
+ chain: NO_BONES,
73
+ x: s * 0.152,
74
+ side: s,
75
+ around: 12,
76
+ sub: 2,
77
+ coat,
78
+ lay: 1,
79
+ droop: 0.1,
80
+ fur:
81
+ fine &&
82
+ ((o, x, y, z, nx) => {
83
+ if (nx * s < 0.2) return false;
84
+ o[0] = 0.05;
85
+ o[1] = 0.06;
86
+ o[2] = 0.032;
87
+ o[3] = 2;
88
+ o[4] = 1.2;
89
+ }),
90
+ },
91
+ );
92
+ }
93
+
94
+ /**
95
+ * A wing spread in flight, about its shoulder: two rows of coverts along the arm, the secondaries trailing from it, and the
96
+ * primaries fanned from the wrist, the outer five narrowed into fingers.
97
+ *
98
+ * @param {object} b The builder (`GB`).
99
+ * @param {1 | -1} s The side: 1 the right wing.
100
+ */
101
+ export function spreadCorvidWing(b, s, coat, tip) {
102
+ const col = [0, 0, 0, 0],
103
+ out = [0, 1, 0],
104
+ X = p => [p[0] * s, p[1], p[2]];
105
+ for (let i = 0; i < 11; i++) {
106
+ const u = i / 10,
107
+ root = X([lerp(0.04, 0.52, u), 0.005 * u, -0.01]),
108
+ end = X([lerp(0.07, 0.56, u), 0.01 * u - 0.01, -0.31 + 0.02 * u]);
109
+ coat(col, root[0], root[1], root[2], 0, 1, 0);
110
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.03, col, tip);
111
+ }
112
+ for (let i = 0; i < 10; i++) {
113
+ const u = i / 9,
114
+ angle = lerp(-1.25, 0.08, u), // from back along the wing's trailing edge round to out past the wrist
115
+ len = lerp(0.42, 0.6, Math.min(1, u * 1.4)) - (u > 0.9 ? 0.05 : 0),
116
+ root = X([lerp(0.52, 0.6, u), 0.01, lerp(-0.01, 0.04, u)]),
117
+ dir = X([Math.cos(angle), 0.04 + 0.06 * u, Math.sin(angle)]),
118
+ end = [root[0] + dir[0] * len, root[1] + dir[1] * len, root[2] + dir[2] * len];
119
+ coat(col, root[0], root[1], root[2], 0, 1, 0);
120
+ feather(b, root, lerp3(root, end, 0.5), end, out, u > 0.5 ? 0.022 : 0.032, col, tip, 5);
121
+ }
122
+ for (const [z, len, n] of [
123
+ [0.06, 0.14, 9],
124
+ [0.02, 0.17, 10],
125
+ ])
126
+ for (let i = 0; i < n; i++) {
127
+ const u = i / (n - 1),
128
+ root = X([lerp(0.02, 0.6, u), 0.012 + 0.005 * (1 - u), z]),
129
+ end = X([lerp(0.04, 0.66, u), 0.01, z - len]);
130
+ coat(col, root[0], root[1], root[2], 0, 1, 0);
131
+ feather(b, root, lerp3(root, end, 0.5), end, out, 0.036, col, tip, 2);
132
+ }
133
+ }
134
+
135
+ /**
136
+ * A corvid perched with its wings folded, drawn into the builder b in the frame F (its feet at F's origin, nose to F's +z), of one
137
+ * mesh with the rest of a scene's still parts; its contour feathers are left to the surface's colour (a bird of a roost, seen from
138
+ * further off).
139
+ *
140
+ * @param {object} b The builder (`GB`).
141
+ * @param {THREE.Matrix4} F
142
+ * @param {typeof CORVID_LOOK} [look=CORVID_LOOK] Its `height` is not read: F carries the bird's size.
143
+ */
144
+ export function drawPerchedCorvid(b, F, look = CORVID_LOOK) {
145
+ const { coat, horn, tip } = corvidPalette(look),
146
+ frame = F.clone(), // F may be a matrix its maker reuses, which the eyes' placing would change under us
147
+ local = new THREE.Matrix4();
148
+ corvidBody(b, coat, horn, tip, frame, false);
149
+ placeIn(b, frame, local.makeTranslation(CORVID_NECK[0], CORVID_NECK[1], CORVID_NECK[2]));
150
+ corvidHead(b, coat, horn, tip);
151
+ placeIn(b, frame, local.makeTranslation(0, -CORVID_SIT, 0));
152
+ for (const s of [-1, 1]) foldedCorvidWing(b, s, coat, tip, false);
153
+ b.M = null;
154
+ }
@@ -0,0 +1,195 @@
1
+ import { GB } from './builder.js';
2
+ import { C, TRS, createUnitShapes, stick } from './primitives.js';
3
+ import { flierArrays, shapeBuilder, wingFan } from './flier-shapes.js';
4
+
5
+ // ════════════════════════════════════════════════════════════════════════
6
+ // A long-bodied four-winged flier large enough to be ridden, facing +z with the top of its thorax at y 0.3 (metres): an
7
+ // enormous wedge of a head mostly faceted eyes, with working mandibles and two small arms tucked beneath it; a long thorax
8
+ // carrying a high saddle forward and a second, ridged saddle rising at its back like a cowl; four thin legs folded beneath the
9
+ // saddles; and a tail of many segments in bands of colour, some six metres long, held straight out behind. Whoever rides it is
10
+ // the caller's (`rider`). Its four wings, clear as glass, are a shape of their own, drawn apart. Arithmetic only, so a pool's
11
+ // workers can build it: `createLongFlierCompany` makes the geometries on the page.
12
+ // ════════════════════════════════════════════════════════════════════════
13
+
14
+ /** The tail: where it starts and ends along z, and its radius there (metres). A company's shader sways what lies behind `from`. */
15
+ export const LONG_FLIER_TAIL = { from: -0.8, to: -6.9, r: [0.3, 0.085] };
16
+
17
+ /** A wing's length and its fore and hind chords, the wings' height, the fore and hind roots along z, and the hinge's x (metres). */
18
+ const WING = { long: 3.7, fore: 0.62, hind: 0.82, y: 0.3, zFore: 0.42, zHind: -0.2, hinge: 0.38 };
19
+
20
+ /**
21
+ * The flier's colours (hex, sRGB): `bands` the tail's hues, one running into the next down its length; `shell` the thorax and head,
22
+ * `plates` the plates down its back and its face, `eyes`, `rings` at the tail's joints, `saddle` and its `ridges`, `legs` and
23
+ * `claws` (with the mandibles); and the wings' linear colours, `clear` and the darker vein near each tip (`stigma`). The default
24
+ * is a dark bronze-green flier with a tail banded in blue and amber.
25
+ */
26
+ export const LONG_FLIER_PALETTE = {
27
+ bands: [0x2f4a3a, 0x58502c, 0x3c4a5c, 0x5c4630, 0x2e3e58],
28
+ shell: 0x2b3a30,
29
+ plates: 0x18221c,
30
+ eyes: 0x1a2420,
31
+ rings: 0x12161a,
32
+ saddle: 0x2e231a,
33
+ ridges: 0x3c2e22,
34
+ legs: 0x202c26,
35
+ claws: 0x101412,
36
+ clear: [0.8, 0.84, 0.84],
37
+ stigma: [0.24, 0.2, 0.16],
38
+ };
39
+
40
+ let plainShapes = null; // the unit shapes made with the engine's own noise, when a caller passes none
41
+ const defaultShapes = () => (plainShapes ??= createUnitShapes());
42
+
43
+ /**
44
+ * The flier's body (and its rider), as a builder's arrays.
45
+ *
46
+ * @param {object} [options]
47
+ * @param {boolean} [options.far=false] The lighter version for the far distance: no legs, arms or mandibles, and a tail of fewer
48
+ * segments.
49
+ * @param {typeof LONG_FLIER_PALETTE} [options.palette=LONG_FLIER_PALETTE]
50
+ * @param {(builder: GB, far: boolean) => void} [options.rider] Draws whoever rides it into the builder (in the flier's frame), near
51
+ * or far; none for a flier with an empty saddle.
52
+ * @param {object} [options.shapes] The unit shapes (`createUnitShapes`) the parts are made of.
53
+ * @returns {object} The builder's parts (`GB.parts`).
54
+ */
55
+ export function longFlierBody({ far = false, palette = LONG_FLIER_PALETTE, rider = null, shapes = defaultShapes() } = {}) {
56
+ const U = shapes,
57
+ b = new GB(),
58
+ shell = C(palette.shell),
59
+ dark = C(palette.plates);
60
+ // the thorax, and the plates down its back
61
+ b.add(U.sph, shell, TRS(0, 0, 0.1, 1.05, 0.82, 2.1));
62
+ if (!far) for (let i = 0; i < 3; i++) b.add(U.sph, dark, TRS(0, 0.27 - i * 0.02, 0.62 - i * 0.55, 0.74, 0.2, 0.5));
63
+ // the head: a wedge, its face drawn down to the mandibles, the eyes covering most of it
64
+ b.add(U.sph, shell, TRS(0, 0.1, 1.42, 0.86, 0.6, 0.92, 0, 0.15));
65
+ b.add(U.sph, dark, TRS(0, -0.06, 1.86, 0.5, 0.36, 0.62, 0, 0.3));
66
+ // the compound eyes, faceted, wrapping the sides and top of the head
67
+ for (const s of [-1, 1]) b.add(U.sph, C(palette.eyes), TRS(s * 0.27, 0.2, 1.38, 0.46, 0.56, 0.66, s * 0.2));
68
+ tail(b, far ? 6 : 13, palette, U);
69
+ saddles(b, far, palette, U);
70
+ if (!far) limbs(b, palette);
71
+ if (rider) rider(b, far);
72
+ const parts = b.parts(!b.wide);
73
+ b.release();
74
+ return parts;
75
+ }
76
+
77
+ // The tail: segments of chitin, each a short tube, with a darker ring at every joint; its hue runs through the bands.
78
+ function tail(b, n, palette, U) {
79
+ const T = LONG_FLIER_TAIL,
80
+ hues = palette.bands,
81
+ len = (T.from - T.to) / n,
82
+ ring = C(palette.rings);
83
+ for (let i = 0; i < n; i++) {
84
+ const u = (i + 0.5) / n,
85
+ r = T.r[0] + (T.r[1] - T.r[0]) * u,
86
+ z = T.from - i * len,
87
+ y = -0.04 + 0.05 * u * u, // a slight rise to the tip
88
+ h = (i / n) * (hues.length - 1),
89
+ a = C(hues[Math.floor(h)]),
90
+ c = C(hues[Math.min(hues.length - 1, Math.floor(h) + 1)]),
91
+ k = h - Math.floor(h),
92
+ shade = i % 2 ? 0.88 : 1;
93
+ b.add(
94
+ U.cyl,
95
+ [(a[0] + (c[0] - a[0]) * k) * shade, (a[1] + (c[1] - a[1]) * k) * shade, (a[2] + (c[2] - a[2]) * k) * shade],
96
+ TRS(0, y, z, 2 * r, len, 1.8 * r, 0, -Math.PI / 2),
97
+ );
98
+ b.add(U.cyl, ring, TRS(0, y, z + 0.03, 2.16 * r, 0.06, 1.96 * r, 0, -Math.PI / 2));
99
+ }
100
+ b.add(U.cone, C(hues[hues.length - 1]), TRS(0, 0.01, T.to, 2 * T.r[1], 0.45, 1.8 * T.r[1], 0, -Math.PI / 2)); // the tip
101
+ }
102
+
103
+ // The high saddle forward, with its pommel and cantle, and the second saddle rising at the back of the thorax, ridged.
104
+ function saddles(b, far, palette, U) {
105
+ const s = C(palette.saddle);
106
+ b.add(U.box, s, TRS(0, 0.3, 0.55, 0.62, 0.12, 0.74));
107
+ b.add(U.box, s, TRS(0, 0.36, 0.92, 0.46, 0.32, 0.1, 0, -0.35));
108
+ b.add(U.box, s, TRS(0, 0.36, 0.2, 0.52, 0.3, 0.1, 0, 0.3));
109
+ // the second saddle: a shell rising from the back of the thorax and swept back over it, its ridges running up its back
110
+ b.add(U.dome, s, TRS(0, 0.22, -0.42, 0.74, 0.62, 0.7, 0, -0.55));
111
+ if (!far) for (let i = -1; i <= 1; i++) b.add(U.sph, C(palette.ridges), TRS(i * 0.17, 0.4, -0.56, 0.06, 0.1, 0.5, 0, -0.6));
112
+ }
113
+
114
+ // Four thin legs folded up beneath the saddles, and two small arms tucked under the head; mandibles at the mouth.
115
+ function limbs(b, palette) {
116
+ const leg = C(palette.legs),
117
+ claw = C(palette.claws);
118
+ for (const s of [-1, 1]) {
119
+ for (const z of [0.55, -0.3]) {
120
+ // tucked up forward under the body in flight, as a dragonfly holds its legs
121
+ const hip = [s * 0.28, -0.22, z],
122
+ knee = [s * 0.46, -0.44, z - 0.18],
123
+ foot = [s * 0.2, -0.46, z + 0.38];
124
+ stick(b, hip, knee, 0.1, leg);
125
+ stick(b, knee, foot, 0.07, leg);
126
+ stick(b, foot, [foot[0] * 0.7, foot[1] + 0.03, foot[2] + 0.16], 0.04, claw);
127
+ }
128
+ const shoulder = [s * 0.18, -0.24, 1.15],
129
+ elbow = [s * 0.24, -0.44, 1.48];
130
+ stick(b, shoulder, elbow, 0.07, leg);
131
+ stick(b, elbow, [s * 0.08, -0.32, 1.78], 0.05, leg);
132
+ // a mandible: a curved pincer, closing in towards the other
133
+ const root = [s * 0.17, -0.16, 1.98],
134
+ bend = [s * 0.2, -0.2, 2.16];
135
+ stick(b, root, bend, 0.09, claw);
136
+ stick(b, bend, [s * 0.05, -0.23, 2.27], 0.06, claw);
137
+ }
138
+ }
139
+
140
+ /**
141
+ * The four wings: long, narrow and clear, a fore pair and a broader hind pair, each a fan from its root on the thorax's top; their
142
+ * weights (aW) are how far out from the hinge each corner lies, which the company's shader beats about. The vein near each tip
143
+ * (the pterostigma) is darker.
144
+ *
145
+ * @param {typeof LONG_FLIER_PALETTE} [palette=LONG_FLIER_PALETTE] Its `clear` and `stigma` colours.
146
+ * @returns {ReturnType<typeof flierArrays>}
147
+ */
148
+ export function longFlierWings(palette = LONG_FLIER_PALETTE) {
149
+ const B = shapeBuilder(),
150
+ L = WING.long,
151
+ clear = palette.clear,
152
+ stigma = palette.stigma;
153
+ for (const side of [-1, 1])
154
+ for (const [z, chord] of [
155
+ [WING.zFore, WING.fore],
156
+ [WING.zHind, WING.hind],
157
+ ]) {
158
+ const x = WING.hinge;
159
+ wingFan(
160
+ B,
161
+ side,
162
+ [x, z],
163
+ [
164
+ [x, z + chord * 0.3],
165
+ [x + L * 0.3, z + chord * 0.36],
166
+ [x + L * 0.7, z + chord * 0.32],
167
+ [x + L * 0.86, z + chord * 0.26],
168
+ [x + L * 0.97, z + chord * 0.12],
169
+ [x + L, z - chord * 0.08],
170
+ [x + L * 0.94, z - chord * 0.3],
171
+ [x + L * 0.7, z - chord * 0.5],
172
+ [x + L * 0.35, z - chord * 0.62],
173
+ [x + L * 0.12, z - chord * 0.58],
174
+ [x, z - chord * 0.3],
175
+ ],
176
+ (px, pz) => (px > x + L * 0.8 && pz > z + chord * 0.05 ? stigma : clear),
177
+ x,
178
+ );
179
+ }
180
+ return flierArrays(B.geometry().translate(0, WING.y, 0));
181
+ }
182
+
183
+ /**
184
+ * The flier's shapes as arrays, to hand from a worker to the page: the body near and far, and the wings.
185
+ *
186
+ * @param {object} [options] As `longFlierBody` takes them: `palette`, `rider`, `shapes`.
187
+ * @returns {{ near: object, far: object, wings: ReturnType<typeof flierArrays> }}
188
+ */
189
+ export function longFlierArrays({ palette = LONG_FLIER_PALETTE, rider = null, shapes = defaultShapes() } = {}) {
190
+ return {
191
+ near: longFlierBody({ far: false, palette, rider, shapes }),
192
+ far: longFlierBody({ far: true, palette, rider, shapes }),
193
+ wings: longFlierWings(palette),
194
+ };
195
+ }