@bitefoundry/retrieviewer 0.0.0-stage → 0.0.2

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 (297) hide show
  1. package/ASSET-PROVENANCE.md +43 -0
  2. package/ASSETS-LICENSE.md +58 -0
  3. package/ATTRIBUTION.md +54 -0
  4. package/EMBEDDING.md +96 -0
  5. package/INSTALLING.md +126 -0
  6. package/LICENSE +16 -0
  7. package/LICENSE-CODE +21 -0
  8. package/PLUGIN.md +110 -0
  9. package/PUPPY-MEMORY.md +57 -0
  10. package/PUPPY-Q5-COMPARISON.md +73 -0
  11. package/README.md +86 -2
  12. package/RELEASING.md +70 -0
  13. package/THIRD-PARTY-NOTICES.md +17 -0
  14. package/TRADEMARKS.md +21 -0
  15. package/WINDOWS-COMPANION.md +113 -0
  16. package/braille.mjs +45 -0
  17. package/examples/bridge.py +62 -0
  18. package/examples/embed.mjs +15 -0
  19. package/examples/live.mjs +40 -0
  20. package/examples/plugin.mjs +21 -0
  21. package/integrations/opencode/runtime.mjs +195 -0
  22. package/integrations/opencode/tui.tsx +59 -0
  23. package/integrations/windows-overlay/Overlay.cs +259 -0
  24. package/integrations/windows-overlay/desktop.mjs +87 -0
  25. package/integrations/windows-overlay/protocol.mjs +39 -0
  26. package/integrations/windows-overlay/worker.mjs +60 -0
  27. package/locomotion-core.mjs +21 -0
  28. package/locomotion-puppy.animal +0 -0
  29. package/package.json +131 -4
  30. package/pet-q5-manifest.json +118 -0
  31. package/puppy-clean.mjs +51 -0
  32. package/puppy-companion-interactions-v3-q5.bin.gz +0 -0
  33. package/puppy-companion-interactions-v3.json +1 -0
  34. package/puppy-companion-life.mjs +182 -0
  35. package/puppy-companion-objects.mjs +30 -0
  36. package/puppy-companion-sprites.mjs +14 -0
  37. package/puppy-continuous.mjs +57 -0
  38. package/puppy-face.mjs +46 -0
  39. package/puppy-frame-predictive.mjs +147 -0
  40. package/puppy-frame-store.mjs +108 -0
  41. package/puppy-mouth-anchor.json +1 -0
  42. package/puppy-mouth-anchor.mjs +33 -0
  43. package/puppy-paper-actions-v9-q5.bin.gz +0 -0
  44. package/puppy-paper-actions-v9.json +1 -0
  45. package/puppy-paper-actions.mjs +48 -0
  46. package/puppy-paper-approach-q5.bin.gz +0 -0
  47. package/puppy-paper-approach.json +1 -0
  48. package/puppy-paper-area.mjs +15 -0
  49. package/puppy-paper-arrival-seat-q5.bin.gz +0 -0
  50. package/puppy-paper-arrival-seat.json +1 -0
  51. package/puppy-paper-behaviors-q5.bin.gz +0 -0
  52. package/puppy-paper-behaviors.json +1 -0
  53. package/puppy-paper-behaviors.mjs +8 -0
  54. package/puppy-paper-contact.mjs +103 -0
  55. package/puppy-paper-director.mjs +21 -0
  56. package/puppy-paper-paw-transport.mjs +76 -0
  57. package/puppy-paper-rear-gallop-q5.bin.gz +0 -0
  58. package/puppy-paper-rear-gallop.json +1 -0
  59. package/puppy-paper-seat-q5.bin.gz +0 -0
  60. package/puppy-paper-seat.json +14 -0
  61. package/puppy-paper-seat.mjs +13 -0
  62. package/puppy-paper-trick-timing.mjs +58 -0
  63. package/puppy-paper-world.mjs +108 -0
  64. package/puppy-paper.mjs +271 -0
  65. package/puppy-stable-meta.json +1606 -0
  66. package/puppy-stable.mjs +72 -0
  67. package/puppy-stride-meta.json +343 -0
  68. package/puppy-stride-tweens-q5.bin.gz +0 -0
  69. package/puppy-zoomies.mjs +27 -0
  70. package/puppy-zoomies30.mjs +12 -0
  71. package/retrieviewer-cli.mjs +94 -0
  72. package/retrieviewer-config.mjs +49 -0
  73. package/retrieviewer-install.mjs +157 -0
  74. package/retrieviewer-plugin.d.mts +44 -0
  75. package/retrieviewer-plugin.mjs +97 -0
  76. package/retrieviewer-stdio.mjs +38 -0
  77. package/retrieviewer.d.mts +85 -0
  78. package/retrieviewer.mjs +142 -0
  79. package/vendor/procedural-animals/LICENSE +21 -0
  80. package/vendor/procedural-animals/package.json +40 -0
  81. package/vendor/procedural-animals/src/animal.js +146 -0
  82. package/vendor/procedural-animals/src/bake.js +51 -0
  83. package/vendor/procedural-animals/src/build.js +81 -0
  84. package/vendor/procedural-animals/src/core/build/coatKit.js +121 -0
  85. package/vendor/procedural-animals/src/core/build/featherCards.js +189 -0
  86. package/vendor/procedural-animals/src/core/build/finEdges.js +85 -0
  87. package/vendor/procedural-animals/src/core/build/furSlope.js +115 -0
  88. package/vendor/procedural-animals/src/core/build/mesh.js +67 -0
  89. package/vendor/procedural-animals/src/core/build/pipeline.js +272 -0
  90. package/vendor/procedural-animals/src/core/build/seams.js +183 -0
  91. package/vendor/procedural-animals/src/core/build/warp.js +112 -0
  92. package/vendor/procedural-animals/src/core/build/weights.js +393 -0
  93. package/vendor/procedural-animals/src/core/math/vec.js +81 -0
  94. package/vendor/procedural-animals/src/core/motion/actions.js +800 -0
  95. package/vendor/procedural-animals/src/core/motion/bird.js +3063 -0
  96. package/vendor/procedural-animals/src/core/motion/birdActions.js +1059 -0
  97. package/vendor/procedural-animals/src/core/motion/common.js +158 -0
  98. package/vendor/procedural-animals/src/core/motion/index.js +22 -0
  99. package/vendor/procedural-animals/src/core/motion/quadruped.js +2875 -0
  100. package/vendor/procedural-animals/src/core/motion/snake.js +1594 -0
  101. package/vendor/procedural-animals/src/core/motion/spider.js +1810 -0
  102. package/vendor/procedural-animals/src/core/motion/swimmer.js +1047 -0
  103. package/vendor/procedural-animals/src/core/motion/swimmerActions.js +613 -0
  104. package/vendor/procedural-animals/src/core/render/animalObject.js +262 -0
  105. package/vendor/procedural-animals/src/core/render/coatMaterial.js +1301 -0
  106. package/vendor/procedural-animals/src/core/render/dqs.js +159 -0
  107. package/vendor/procedural-animals/src/core/render/eyes.js +676 -0
  108. package/vendor/procedural-animals/src/core/render/membranes.js +77 -0
  109. package/vendor/procedural-animals/src/core/render/skeleton.js +41 -0
  110. package/vendor/procedural-animals/src/core/rig/bird.js +327 -0
  111. package/vendor/procedural-animals/src/core/rig/quadruped.js +76 -0
  112. package/vendor/procedural-animals/src/core/rig/rig.js +79 -0
  113. package/vendor/procedural-animals/src/core/rig/snake.js +76 -0
  114. package/vendor/procedural-animals/src/core/rig/spider.js +110 -0
  115. package/vendor/procedural-animals/src/core/rig/swimmer.js +181 -0
  116. package/vendor/procedural-animals/src/core/sdf/eyeSocket.js +53 -0
  117. package/vendor/procedural-animals/src/core/sdf/mesher.js +238 -0
  118. package/vendor/procedural-animals/src/core/sdf/sdf.js +263 -0
  119. package/vendor/procedural-animals/src/index.d.ts +98 -0
  120. package/vendor/procedural-animals/src/index.js +29 -0
  121. package/vendor/procedural-animals/src/registry.js +48 -0
  122. package/vendor/procedural-animals/src/species/bear/behaviour.js +463 -0
  123. package/vendor/procedural-animals/src/species/bear/claws.js +147 -0
  124. package/vendor/procedural-animals/src/species/bear/coat.js +726 -0
  125. package/vendor/procedural-animals/src/species/bear/index.js +139 -0
  126. package/vendor/procedural-animals/src/species/bear/motion.js +112 -0
  127. package/vendor/procedural-animals/src/species/bear/regions.js +78 -0
  128. package/vendor/procedural-animals/src/species/bear/rig.js +112 -0
  129. package/vendor/procedural-animals/src/species/bear/sculpt.js +272 -0
  130. package/vendor/procedural-animals/src/species/boar/behaviour.js +335 -0
  131. package/vendor/procedural-animals/src/species/boar/coat.js +372 -0
  132. package/vendor/procedural-animals/src/species/boar/index.js +110 -0
  133. package/vendor/procedural-animals/src/species/boar/motion.js +85 -0
  134. package/vendor/procedural-animals/src/species/boar/regions.js +88 -0
  135. package/vendor/procedural-animals/src/species/boar/rig.js +111 -0
  136. package/vendor/procedural-animals/src/species/boar/sculpt.js +285 -0
  137. package/vendor/procedural-animals/src/species/cat/behaviour.js +559 -0
  138. package/vendor/procedural-animals/src/species/cat/coat.js +841 -0
  139. package/vendor/procedural-animals/src/species/cat/index.js +211 -0
  140. package/vendor/procedural-animals/src/species/cat/motion.js +101 -0
  141. package/vendor/procedural-animals/src/species/cat/regions.js +82 -0
  142. package/vendor/procedural-animals/src/species/cat/rig.js +100 -0
  143. package/vendor/procedural-animals/src/species/cat/sculpt.js +266 -0
  144. package/vendor/procedural-animals/src/species/cat/whiskers.js +110 -0
  145. package/vendor/procedural-animals/src/species/cheetah/coat.js +427 -0
  146. package/vendor/procedural-animals/src/species/cheetah/index.js +51 -0
  147. package/vendor/procedural-animals/src/species/cheetah/joints.js +3 -0
  148. package/vendor/procedural-animals/src/species/cheetah/motion.js +77 -0
  149. package/vendor/procedural-animals/src/species/cheetah/regions.js +95 -0
  150. package/vendor/procedural-animals/src/species/cheetah/rig.js +66 -0
  151. package/vendor/procedural-animals/src/species/cheetah/sculpt.js +158 -0
  152. package/vendor/procedural-animals/src/species/chicken/coat.js +313 -0
  153. package/vendor/procedural-animals/src/species/chicken/coverts.js +320 -0
  154. package/vendor/procedural-animals/src/species/chicken/index.js +110 -0
  155. package/vendor/procedural-animals/src/species/chicken/motion.js +177 -0
  156. package/vendor/procedural-animals/src/species/chicken/regions.js +66 -0
  157. package/vendor/procedural-animals/src/species/chicken/rig.js +144 -0
  158. package/vendor/procedural-animals/src/species/chicken/sculpt.js +389 -0
  159. package/vendor/procedural-animals/src/species/chicken/wingLook.js +66 -0
  160. package/vendor/procedural-animals/src/species/chicken/wingStack.js +124 -0
  161. package/vendor/procedural-animals/src/species/cow/behaviour.js +521 -0
  162. package/vendor/procedural-animals/src/species/cow/coat.js +465 -0
  163. package/vendor/procedural-animals/src/species/cow/index.js +118 -0
  164. package/vendor/procedural-animals/src/species/cow/motion.js +81 -0
  165. package/vendor/procedural-animals/src/species/cow/regions.js +98 -0
  166. package/vendor/procedural-animals/src/species/cow/rig.js +116 -0
  167. package/vendor/procedural-animals/src/species/cow/sculpt.js +339 -0
  168. package/vendor/procedural-animals/src/species/crow/coat.js +145 -0
  169. package/vendor/procedural-animals/src/species/crow/index.js +70 -0
  170. package/vendor/procedural-animals/src/species/crow/joints.js +3 -0
  171. package/vendor/procedural-animals/src/species/crow/motion.js +101 -0
  172. package/vendor/procedural-animals/src/species/crow/regions.js +50 -0
  173. package/vendor/procedural-animals/src/species/crow/rig.js +83 -0
  174. package/vendor/procedural-animals/src/species/crow/sculpt.js +118 -0
  175. package/vendor/procedural-animals/src/species/deer/behaviour.js +513 -0
  176. package/vendor/procedural-animals/src/species/deer/coat.js +391 -0
  177. package/vendor/procedural-animals/src/species/deer/index.js +106 -0
  178. package/vendor/procedural-animals/src/species/deer/motion.js +97 -0
  179. package/vendor/procedural-animals/src/species/deer/regions.js +60 -0
  180. package/vendor/procedural-animals/src/species/deer/rig.js +124 -0
  181. package/vendor/procedural-animals/src/species/deer/sculpt.js +297 -0
  182. package/vendor/procedural-animals/src/species/dog/behaviour.js +521 -0
  183. package/vendor/procedural-animals/src/species/dog/coat.js +495 -0
  184. package/vendor/procedural-animals/src/species/dog/index.js +144 -0
  185. package/vendor/procedural-animals/src/species/dog/motion.js +118 -0
  186. package/vendor/procedural-animals/src/species/dog/regions.js +61 -0
  187. package/vendor/procedural-animals/src/species/dog/rig.js +129 -0
  188. package/vendor/procedural-animals/src/species/dog/sculpt.js +246 -0
  189. package/vendor/procedural-animals/src/species/eagle/coat.js +250 -0
  190. package/vendor/procedural-animals/src/species/eagle/index.js +76 -0
  191. package/vendor/procedural-animals/src/species/eagle/joints.js +3 -0
  192. package/vendor/procedural-animals/src/species/eagle/motion.js +137 -0
  193. package/vendor/procedural-animals/src/species/eagle/regions.js +57 -0
  194. package/vendor/procedural-animals/src/species/eagle/rig.js +107 -0
  195. package/vendor/procedural-animals/src/species/eagle/sculpt.js +137 -0
  196. package/vendor/procedural-animals/src/species/fish/coat.js +271 -0
  197. package/vendor/procedural-animals/src/species/fish/index.js +88 -0
  198. package/vendor/procedural-animals/src/species/fish/motion.js +92 -0
  199. package/vendor/procedural-animals/src/species/fish/regions.js +27 -0
  200. package/vendor/procedural-animals/src/species/fish/rig.js +143 -0
  201. package/vendor/procedural-animals/src/species/fish/sculpt.js +214 -0
  202. package/vendor/procedural-animals/src/species/fish/variants.js +126 -0
  203. package/vendor/procedural-animals/src/species/fox/behaviour.js +314 -0
  204. package/vendor/procedural-animals/src/species/fox/coat.js +444 -0
  205. package/vendor/procedural-animals/src/species/fox/index.js +120 -0
  206. package/vendor/procedural-animals/src/species/fox/motion.js +81 -0
  207. package/vendor/procedural-animals/src/species/fox/regions.js +59 -0
  208. package/vendor/procedural-animals/src/species/fox/rig.js +91 -0
  209. package/vendor/procedural-animals/src/species/fox/sculpt.js +202 -0
  210. package/vendor/procedural-animals/src/species/frog/behaviour.js +590 -0
  211. package/vendor/procedural-animals/src/species/frog/coat.js +305 -0
  212. package/vendor/procedural-animals/src/species/frog/index.js +97 -0
  213. package/vendor/procedural-animals/src/species/frog/motion.js +69 -0
  214. package/vendor/procedural-animals/src/species/frog/regions.js +46 -0
  215. package/vendor/procedural-animals/src/species/frog/rig.js +156 -0
  216. package/vendor/procedural-animals/src/species/frog/sculpt.js +240 -0
  217. package/vendor/procedural-animals/src/species/goat/behaviour.js +509 -0
  218. package/vendor/procedural-animals/src/species/goat/coat.js +590 -0
  219. package/vendor/procedural-animals/src/species/goat/index.js +149 -0
  220. package/vendor/procedural-animals/src/species/goat/motion.js +95 -0
  221. package/vendor/procedural-animals/src/species/goat/regions.js +98 -0
  222. package/vendor/procedural-animals/src/species/goat/rig.js +181 -0
  223. package/vendor/procedural-animals/src/species/goat/sculpt.js +547 -0
  224. package/vendor/procedural-animals/src/species/horse/coat.js +361 -0
  225. package/vendor/procedural-animals/src/species/horse/coatSeam.js +122 -0
  226. package/vendor/procedural-animals/src/species/horse/index.js +80 -0
  227. package/vendor/procedural-animals/src/species/horse/motion.js +245 -0
  228. package/vendor/procedural-animals/src/species/horse/regions.js +60 -0
  229. package/vendor/procedural-animals/src/species/horse/rig.js +117 -0
  230. package/vendor/procedural-animals/src/species/horse/sculpt.js +316 -0
  231. package/vendor/procedural-animals/src/species/horse/seamWeights.js +272 -0
  232. package/vendor/procedural-animals/src/species/lion/behaviour.js +509 -0
  233. package/vendor/procedural-animals/src/species/lion/coat.js +1016 -0
  234. package/vendor/procedural-animals/src/species/lion/index.js +111 -0
  235. package/vendor/procedural-animals/src/species/lion/motion.js +87 -0
  236. package/vendor/procedural-animals/src/species/lion/regions.js +106 -0
  237. package/vendor/procedural-animals/src/species/lion/rig.js +110 -0
  238. package/vendor/procedural-animals/src/species/lion/sculpt.js +384 -0
  239. package/vendor/procedural-animals/src/species/lion/whiskers.js +132 -0
  240. package/vendor/procedural-animals/src/species/pig/behaviour.js +575 -0
  241. package/vendor/procedural-animals/src/species/pig/coat.js +730 -0
  242. package/vendor/procedural-animals/src/species/pig/ears.js +242 -0
  243. package/vendor/procedural-animals/src/species/pig/index.js +161 -0
  244. package/vendor/procedural-animals/src/species/pig/motion.js +105 -0
  245. package/vendor/procedural-animals/src/species/pig/regions.js +100 -0
  246. package/vendor/procedural-animals/src/species/pig/rig.js +152 -0
  247. package/vendor/procedural-animals/src/species/pig/sculpt.js +382 -0
  248. package/vendor/procedural-animals/src/species/rabbit/behaviour.js +605 -0
  249. package/vendor/procedural-animals/src/species/rabbit/coat.js +285 -0
  250. package/vendor/procedural-animals/src/species/rabbit/index.js +85 -0
  251. package/vendor/procedural-animals/src/species/rabbit/motion.js +85 -0
  252. package/vendor/procedural-animals/src/species/rabbit/regions.js +48 -0
  253. package/vendor/procedural-animals/src/species/rabbit/rig.js +99 -0
  254. package/vendor/procedural-animals/src/species/rabbit/sculpt.js +148 -0
  255. package/vendor/procedural-animals/src/species/rat/behaviour.js +539 -0
  256. package/vendor/procedural-animals/src/species/rat/coat.js +341 -0
  257. package/vendor/procedural-animals/src/species/rat/index.js +111 -0
  258. package/vendor/procedural-animals/src/species/rat/motion.js +90 -0
  259. package/vendor/procedural-animals/src/species/rat/regions.js +92 -0
  260. package/vendor/procedural-animals/src/species/rat/rig.js +112 -0
  261. package/vendor/procedural-animals/src/species/rat/sculpt.js +163 -0
  262. package/vendor/procedural-animals/src/species/rat/whiskers.js +119 -0
  263. package/vendor/procedural-animals/src/species/shark/coat.js +383 -0
  264. package/vendor/procedural-animals/src/species/shark/index.js +104 -0
  265. package/vendor/procedural-animals/src/species/shark/motion.js +69 -0
  266. package/vendor/procedural-animals/src/species/shark/regions.js +34 -0
  267. package/vendor/procedural-animals/src/species/shark/rig.js +194 -0
  268. package/vendor/procedural-animals/src/species/shark/sculpt.js +343 -0
  269. package/vendor/procedural-animals/src/species/shark/variants.js +105 -0
  270. package/vendor/procedural-animals/src/species/sheep/behaviour.js +522 -0
  271. package/vendor/procedural-animals/src/species/sheep/coat.js +529 -0
  272. package/vendor/procedural-animals/src/species/sheep/index.js +152 -0
  273. package/vendor/procedural-animals/src/species/sheep/motion.js +86 -0
  274. package/vendor/procedural-animals/src/species/sheep/neck.js +41 -0
  275. package/vendor/procedural-animals/src/species/sheep/regions.js +62 -0
  276. package/vendor/procedural-animals/src/species/sheep/rig.js +163 -0
  277. package/vendor/procedural-animals/src/species/sheep/sculpt.js +542 -0
  278. package/vendor/procedural-animals/src/species/snake/coat.js +315 -0
  279. package/vendor/procedural-animals/src/species/snake/index.js +73 -0
  280. package/vendor/procedural-animals/src/species/snake/motion.js +51 -0
  281. package/vendor/procedural-animals/src/species/snake/regions.js +51 -0
  282. package/vendor/procedural-animals/src/species/snake/rig.js +108 -0
  283. package/vendor/procedural-animals/src/species/snake/sculpt.js +122 -0
  284. package/vendor/procedural-animals/src/species/spider/coat.js +279 -0
  285. package/vendor/procedural-animals/src/species/spider/index.js +78 -0
  286. package/vendor/procedural-animals/src/species/spider/motion.js +72 -0
  287. package/vendor/procedural-animals/src/species/spider/regions.js +87 -0
  288. package/vendor/procedural-animals/src/species/spider/rig.js +118 -0
  289. package/vendor/procedural-animals/src/species/spider/sculpt.js +182 -0
  290. package/vendor/procedural-animals/src/species/wolf/behaviour.js +160 -0
  291. package/vendor/procedural-animals/src/species/wolf/coat.js +749 -0
  292. package/vendor/procedural-animals/src/species/wolf/index.js +107 -0
  293. package/vendor/procedural-animals/src/species/wolf/motion.js +80 -0
  294. package/vendor/procedural-animals/src/species/wolf/regions.js +57 -0
  295. package/vendor/procedural-animals/src/species/wolf/rig.js +87 -0
  296. package/vendor/procedural-animals/src/species/wolf/sculpt.js +339 -0
  297. package/vendor/procedural-animals/src/worker.js +29 -0
@@ -0,0 +1,145 @@
1
+ // The crow's plumage and bare parts, baked per vertex: contour-feather shingles (material 9) with a
2
+ // blue-violet structural gloss on the back, wings and tail and a matter head and underside, a short
3
+ // down haze (shells), forward-pointing nasal bristles, a black keratin bill and claws, scaled black
4
+ // tarsi and toes, and a dark eye ring. Colours sampled from the reference photos. Seeded
5
+ // variation shifts gloss and wear (brownish worn feathers) and the morph (American / carrion / hooded).
6
+ import { SDFModel } from '../../core/sdf/sdf.js';
7
+ import { norm, sub, dot, cross, add, mul, clamp, smoothstep, mix, fbm3 } from '../../core/math/vec.js';
8
+ import { srgb, mix3, MAT } from '../../core/build/coatKit.js';
9
+ import { HEAD_O } from './rig.js';
10
+
11
+ export function crowColours(p = {}) {
12
+ const wear = p.wear || 0, morph = p.morph || 'american';
13
+ const black = srgb(0x131316), matte = srgb(0x19191d), worn = srgb(0x2a2420);
14
+ const tint = (c) => mix3(c, worn, wear * 0.35);
15
+ return {
16
+ body: tint(black), under: tint(matte), head: tint(srgb(0x151518)),
17
+ grey: srgb(0x8c8c8a), greyUnder: srgb(0x9a9a98),
18
+ bill: srgb(0x141414), leg: srgb(0x17171a), claw: srgb(0x0e0e10), ring: srgb(0x1c1b1d),
19
+ // adult mouth lining dark grey (research); juveniles show a pink gape
20
+ gape: p.age === 'juvenile' ? srgb(0xb87c78) : srgb(0x2a2a2e), juvGape: p.age === 'juvenile', hooded: morph === 'hooded',
21
+ irid: (morph === 'carrion' ? 0.45 : 0.55) * (p.gloss ?? 1) * (1 - 0.5 * wear),
22
+ };
23
+ }
24
+
25
+ export function crowCoat(ctx) {
26
+ const { model, rig, pos, nrm, regionOf, regionNames, weights, nV, params } = ctx;
27
+ const { BONES, J } = rig;
28
+ const C = crowColours(params);
29
+ const comb = new Float32Array(nV * 3), tint = new Float32Array(nV * 4), surf = new Float32Array(nV * 4);
30
+ const furLen = new Float32Array(nV), mark = new Float32Array(nV).fill(1), pattern = new Float32Array(nV).fill(1);
31
+ const boneName = BONES.map((b) => b.name);
32
+ const tagged = (t) => model.prims.filter((p) => p.tag === t);
33
+ const billP = tagged('bill'), bristleP = tagged('bristles'), mandP = model.forPart('jaw');
34
+ const eyeP = tagged('eyesocket'), clawP = tagged('claw'), tarsusP = [...tagged('tarsus'), ...tagged('toe'), ...tagged('pad'), ...tagged('shank')];
35
+ const minD = (list, p) => { let d = 1e9; for (const q of list) d = Math.min(d, SDFModel.dist(q, p[0], p[1], p[2])); return d; };
36
+ const H = HEAD_O;
37
+ const axialPts = rig.AXIAL.points;
38
+ // flow along the body axis (bill -> tail) at the nearest axial segment
39
+ const axialDir = (p) => {
40
+ let best = 1e9, dir = [0, 0, -1];
41
+ for (let i = 0; i < axialPts.length - 1; i++) {
42
+ const a = axialPts[i], b = axialPts[i + 1], ab = sub(b, a), l2 = dot(ab, ab);
43
+ const t = clamp(dot(sub(p, a), ab) / l2, 0, 1);
44
+ const q = add(a, mul(ab, t)), d = Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
45
+ if (d < best) { best = d; dir = norm(ab); }
46
+ }
47
+ return dir;
48
+ };
49
+ for (let v = 0; v < nV; v++) {
50
+ const p = [pos[v * 3], pos[v * 3 + 1], pos[v * 3 + 2]], n = [nrm[v * 3], nrm[v * 3 + 1], nrm[v * 3 + 2]];
51
+ const bn = boneName[weights.dominant[v]] || '';
52
+ const region = regionNames[regionOf[v]];
53
+ let col = C.body, mat = MAT.FEATHER, fl = 0.0035, gloss = 0.55, size = 0.012, irid = C.irid;
54
+ let flow = axialDir(p);
55
+ const h = [p[0] - H[0], p[1] - H[1], p[2] - H[2]];
56
+ const up = n[1];
57
+ if (region === 'jaw' || bn === 'jaw') {
58
+ mat = MAT.KERATIN; col = C.bill; fl = 0; gloss = 0.5; size = 0; irid = 0;
59
+ flow = [0, 0, 1];
60
+ const dh = minD(billP, p);
61
+ if (dh < 0.0006 && h[2] < 0.06) { mat = C.juvGape ? MAT.DARK_SKIN : MAT.KERATIN; col = C.gape; gloss = 0.2; }
62
+ } else if (bn === 'head' || region === 'head') {
63
+ col = C.head; size = 0.006; irid = C.irid * 0.35; gloss = 0.45; fl = 0.0022;
64
+ flow = norm([0, -0.25, -1]);
65
+ if (Math.abs(h[0]) > 0.006) flow = norm([h[0] * 8, -0.3, -1]);
66
+ const db = minD(billP, p), dbr = minD(bristleP, p), dm = minD(mandP, p);
67
+ if (db < 0.0004 && h[2] > 0.028) { mat = MAT.KERATIN; col = C.bill; fl = 0; gloss = 0.55; irid = 0; flow = [0, 0, 1]; }
68
+ else if (dbr < 0.0012 && h[2] > 0.02) {
69
+ // nasal bristles: stiff forward-pointing feathers over the nostrils
70
+ mat = MAT.FUR; col = C.head; fl = 0.0035; flow = norm([h[0] * 2, -0.05, 1]); irid = 0;
71
+ } else if (dm < 0.001 && h[2] > 0.02) { mat = C.juvGape ? MAT.DARK_SKIN : MAT.KERATIN; col = C.gape; fl = 0; gloss = 0.2; irid = 0; }
72
+ // eye ring (bare dark skin right at the lid margin)
73
+ for (const e of eyeP) {
74
+ const de = SDFModel.dist(e, p[0], p[1], p[2]);
75
+ if (Math.abs(de) < 0.0009) { mat = MAT.DARK_SKIN; col = C.ring; fl = 0; }
76
+ else if (Math.abs(de) < 0.0025) { fl = Math.min(fl, 0.0008); size = 0.003; }
77
+ }
78
+ if (h[2] > 0.018) size = 0.0035;
79
+ } else if (/^(tarsus|toe)/.test(bn) || (bn.startsWith('tibia') && minD(tarsusP, p) < 0.0008)) {
80
+ mat = MAT.SCALES; col = C.leg; fl = 0; gloss = 0.35; size = 0.0022; irid = 0;
81
+ flow = [0, -1, 0];
82
+ if (minD(clawP, p) < 0.0004) { mat = MAT.KERATIN; col = C.claw; gloss = 0.65; size = 0; }
83
+ if (/^toe/.test(bn)) { const b = BONES[weights.dominant[v]]; flow = norm(sub(b.tail, b.head)); }
84
+ } else if (bn.startsWith('tibia') || bn.startsWith('femur')) {
85
+ // feathered "trousers": soft, matte, pointing down the leg
86
+ col = C.under; fl = 0.004; size = 0.008; irid = C.irid * 0.2; gloss = 0.4;
87
+ flow = [0, -1, -0.2];
88
+ } else if (/^(humerus|ulna|hand)/.test(bn)) {
89
+ // wing coverts: lie toward the trailing edge, glossy on top
90
+ const b = BONES[weights.dominant[v]];
91
+ const d = norm(sub(b.tail, b.head));
92
+ let wn = norm(cross(sub(J[b.side === 'R' ? 'elbowR' : 'elbowL'], J[b.side === 'R' ? 'shoulderR' : 'shoulderL']), sub(J[b.side === 'R' ? 'wristR' : 'wristL'], J[b.side === 'R' ? 'elbowR' : 'elbowL'])));
93
+ if (wn[1] < 0) wn = mul(wn, -1);
94
+ const s = b.side === 'R' ? -1 : 1;
95
+ flow = mul(norm(cross(wn, d)), s);
96
+ size = 0.009; fl = 0.0025;
97
+ const top = dot(n, wn);
98
+ if (top < 0) { col = C.under; irid = C.irid * 0.25; }
99
+ } else {
100
+ // body: glossy back and mantle, matte breast and belly
101
+ const dorsal = smoothstep(-0.2, 0.5, up);
102
+ col = mix3(C.under, C.body, dorsal);
103
+ irid = C.irid * mix(0.2, 0.7, dorsal) * mix(0.45, 1, dorsal); // underparts ~0.3x the back
104
+ gloss = mix(0.22, 0.6, dorsal); // matte underparts
105
+ size = p[1] > 0.2 && p[2] > 0.03 ? 0.008 : 0.012;
106
+ fl = mix(0.004, 0.003, dorsal);
107
+ if (C.hooded) {
108
+ // hooded crow: grey mantle, back, breast and belly; black head, bib, wings and tail
109
+ // (soft edges: the black bib ends in a rounded line on the upper breast, the grey fades into
110
+ // the black rump and undertail)
111
+ const bib = smoothstep(0.17, 0.2, p[1] + 0.25 * Math.max(0, p[2] - 0.03)) * smoothstep(0.03, 0.06, p[2]);
112
+ const gw = (1 - bib) * smoothstep(-0.105, -0.08, p[2]);
113
+ if (gw > 0) { col = mix3(col, mix3(C.greyUnder, C.grey, dorsal), gw); irid = mix(irid, 0.05, gw); }
114
+ }
115
+ // flow: along the body, bending around the flanks and down the breast
116
+ if (bn === 'chest' && p[2] > 0.04 && up < 0.2) flow = norm(add(flow, [0, -0.8, 0]));
117
+ }
118
+ // low-frequency variation (wear, sheen patches)
119
+ const cv = fbm3(p[0] * 40, p[1] * 40, p[2] * 40, 3) - 0.5;
120
+ col = [col[0] * (1 + 0.1 * cv), col[1] * (1 + 0.1 * cv), col[2] * (1 + 0.08 * cv)];
121
+ // comb: tangent to the surface
122
+ const f = sub(flow, mul(n, dot(flow, n)));
123
+ const fN = norm(Math.hypot(...f) > 1e-6 ? f : cross(n, [1, 0, 0]));
124
+ comb.set(fN, v * 3);
125
+ tint[v * 4] = col[0]; tint[v * 4 + 1] = col[1]; tint[v * 4 + 2] = col[2]; tint[v * 4 + 3] = mat;
126
+ furLen[v] = fl;
127
+ surf[v * 4] = gloss; surf[v * 4 + 1] = size; surf[v * 4 + 2] = 0; surf[v * 4 + 3] = mat === MAT.FEATHER ? irid : 0;
128
+ }
129
+ return { comb, tint, pattern, mark, furLen, surf, patternColor: new Float32Array(nV * 4) };
130
+ }
131
+
132
+ // flight-feather card colours: glossy black, iridescent on top, greyer and matte beneath
133
+ export function crowFeatherColour(params) {
134
+ const C = crowColours(params);
135
+ return (kind, i, side, t, c, layer) => {
136
+ const top = layer > 0;
137
+ const covert = kind.endsWith('Covert');
138
+ let rgb = top ? C.body : mix3(C.under, srgb(0x2a2a30), 0.35);
139
+ // primaries: the inner vane is a little duller (hidden under the next feather at rest)
140
+ if (kind === 'primary' && c > 0.3) rgb = mix3(rgb, C.under, 0.3);
141
+ if (C.hooded && covert && kind !== 'tailCovert') rgb = top ? C.body : C.under;
142
+ const k = 1 + 0.06 * Math.sin(i * 12.9898 + side * 3.1 + t * 2.1);
143
+ return { rgb: [rgb[0] * k, rgb[1] * k, rgb[2] * k], gloss: top ? 0.5 : 0.1, irid: top ? C.irid * (covert ? 0.7 : 0.5) : 0 };
144
+ };
145
+ }
@@ -0,0 +1,70 @@
1
+ // Crow (American crow Corvus brachyrhynchos; carrion crow C. corone and hooded crow C. cornix as
2
+ // variants). The proving species of the bird body plan (core/motion/bird.js).
3
+ import { crowRig, HEAD_O } from './rig.js';
4
+ import { sculptCrow, EYE } from './sculpt.js';
5
+ import { crowRegions } from './regions.js';
6
+ import { crowCoat, crowFeatherColour } from './coat.js';
7
+ import { motion, WING, FEATHERS } from './motion.js';
8
+ import { featherCards } from '../../core/build/featherCards.js';
9
+ import { srgb } from '../../core/build/coatKit.js';
10
+
11
+ export default {
12
+ id: 'crow',
13
+ name: 'Crow',
14
+ latin: 'Corvus brachyrhynchos',
15
+ group: 'birds',
16
+ plan: 'bird',
17
+ covering: 'feathers',
18
+ variants: [
19
+ { id: 'american', name: 'American crow', latin: 'Corvus brachyrhynchos' },
20
+ { id: 'carrion', name: 'Carrion crow', latin: 'Corvus corone' },
21
+ { id: 'hooded', name: 'Hooded crow', latin: 'Corvus cornix' },
22
+ ],
23
+
24
+ // Seeded individual. No plumage dimorphism; males ~5 % larger (wing, bill). Juveniles are adult-sized
25
+ // at fledging but duller, fluffier and blue-grey eyed with a shorter tail. Individuals differ in size,
26
+ // bill length and depth, leg length, head size, gloss and feather wear (brownish in summer).
27
+ // Variants: 'american' (default), 'carrion' (greener gloss, heavier bill), 'hooded' (grey body).
28
+ variation(R, o) {
29
+ const sex = o.sex || (R() < 0.5 ? 'male' : 'female');
30
+ const age = o.age || 'adult';
31
+ const juv = age === 'juvenile';
32
+ const g = () => (R() + R() + R() - 1.5) / 1.5;
33
+ const morph = o.variant || (R() < 0.75 ? 'american' : 'carrion');
34
+ const size = (sex === 'male' ? 1.03 : 0.97) * (1 + 0.045 * g()) * (juv ? 0.95 : 1) * (morph === 'american' ? 1 : 1.06);
35
+ const bill = (morph === 'carrion' ? 1.06 : 1) * (1 + 0.06 * g()) * (sex === 'male' ? 1.03 : 1);
36
+ return {
37
+ sex, age, size, morph, variant: morph,
38
+ warps: [
39
+ { type: 'legs', k: 1 + 0.04 * g(), top: 0.12 },
40
+ // bill length / depth about the bill base
41
+ { type: 'scaleAbout', c: [0, 0.292, 0.135], k: bill, r0: 0.03, r1: 0.06 },
42
+ { type: 'scaleAbout', c: HEAD_O, k: (1 + 0.03 * g()) * (juv ? 1.06 : 1), r0: 0.03, r1: 0.06 },
43
+ { type: 'girth', k: 1 + 0.05 * g() + (juv ? 0.05 : 0), cy: 0.16, z0: -0.08, z1: 0.1, fade: 0.04 },
44
+ ],
45
+ wear: Math.max(0, 0.25 * g() + (juv ? 0.4 : 0.1)),
46
+ gloss: 1 + 0.12 * g() - (juv ? 0.4 : 0),
47
+ tailK: juv ? 0.88 : 1 + 0.03 * g(),
48
+ };
49
+ },
50
+ rig: () => crowRig(),
51
+ sculpt: (m, rig) => sculptCrow(m, rig),
52
+ regions: crowRegions,
53
+ coat: crowCoat,
54
+ surfaces: (ctx) => featherCards({ ...ctx, wing: WING, feathers: FEATHERS, tail: { bindFan: 0.2 }, colour: crowFeatherColour(ctx.params) }),
55
+ eyeSpecs: (params) => [1, -1].map((side) => ({ side, spec: EYE, headOrigin: HEAD_O, bone: 'head', look: params.age === 'juvenile' ? EYE_JUV : EYE_LOOK })),
56
+ motion,
57
+ // featherEdge: faint shingle outlines (photos show a smooth sheen, not scaled feathers)
58
+ render: { markColor: srgb(0x121214), strandDensity: 900, clumpDensity: 1.4, shellScale: 1, finWidth: 0.3, featherEdge: 0.4 },
59
+ };
60
+
61
+ // Round pupil, dark brown iris (reads black at distance), bird lids with a nictitating membrane.
62
+ export const EYE_LOOK = {
63
+ pupil: 'round',
64
+ lids: 'bird',
65
+ iris: { inner: srgb(0x120c09), mid: srgb(0x2a1e18), hi: srgb(0x4a3526), outer: srgb(0x100b09) },
66
+ sclera: { visible: false, color: [0.02, 0.02, 0.02] },
67
+ lidColor: srgb(0x1c1b1d),
68
+ pupilSize: [0.36, 0.52],
69
+ };
70
+ export const EYE_JUV = { ...EYE_LOOK, iris: { inner: srgb(0x3a4450), mid: srgb(0x7d8ca0), hi: srgb(0xa6b3c2), outer: srgb(0x3c4552) } };
@@ -0,0 +1,3 @@
1
+ // Reference-pose joints of the crow (see rig.js), exported for modules that need fixed landmarks.
2
+ import { crowJoints } from './rig.js';
3
+ export const J = crowJoints();
@@ -0,0 +1,101 @@
1
+ // Crow motion data for the bird engine (schema: src/core/motion/bird.js). Numbers are for the
2
+ // reference individual (params.size = 1: ~450 g American crow, 44 cm bill to tail, span 0.92 m);
3
+ // the engine scales them by dynamic similarity.
4
+ //
5
+ // Ground: crows WALK with alternating steps (stately gait, head bobbing each step, tail swinging) and
6
+ // HOP (both feet together) when hurrying, before take-off and to turn round [research 4, 5].
7
+ // Flight: steady rowing flight, 3.84 Hz at 10.5 m/s (hooded crow, Pennycuick 2001), amplitude
8
+ // ~100 deg, flexed-wing upstroke; take-off beats faster (~6 Hz) and deeper (~140 deg); short glides
9
+ // (<= 2-3 s); landing: swoop, pitch up 40-70 deg, braking beats with the wings raised high, tail
10
+ // fanned and depressed, legs forward.
11
+ const G = (name, v, f, D, off, o) => ({ name, v, f, D, off, ...o });
12
+
13
+ export const WING = {
14
+ // humerus, ulna, hand (carpometacarpus + digit II) in metres
15
+ lengths: [0.067, 0.078, 0.058],
16
+ // degrees: elev (+ tip up), pitch (+ leading edge up), alpha (humerus, + back), elbow / wrist flexion
17
+ bind: { elev: -30, pitch: 0, alpha: 35, elbow: 95, wrist: 100, bend: 0, twist: 0 },
18
+ fold: { elev: -82, pitch: 4, alpha: 80, elbow: 175, wrist: 174, bend: 0, twist: 0 },
19
+ glide: { elev: 5, pitch: 3, alpha: 8, elbow: 24, wrist: 14, bend: 2, twist: 1 },
20
+ // flapping (cruise): stroke plane amplitude, frequency (Hz), downstroke share, wing flexion in the
21
+ // upstroke (crows fold the hand in the upstroke), sweep and twist
22
+ flap: { freq: 3.84, amp: 92, mid: 5, down: 0.55, upFlex: 34, upWrist: 40, sweep: 10, twist: 14 },
23
+ // take-off / climb / braking beats
24
+ power: { freq: 4.3, amp: 112, mid: 12, down: 0.52, upFlex: 50, upWrist: 62, sweep: 20, twist: 18 },
25
+ // intermittent flight: glide share at cruise (0 = always flapping, crows glide little)
26
+ glideShare: 0.15,
27
+ };
28
+
29
+ export const FEATHERS = {
30
+ // 10 primaries (p10 short, p5/p6-p9 emarginated "fingers", longest p6-p7); roots along the hand
31
+ primaries: [
32
+ { u: 0.06, len: 0.158, width: 0.030, spread: 80, fold: 9 },
33
+ { u: 0.16, len: 0.166, width: 0.030, spread: 71, fold: 8 },
34
+ { u: 0.27, len: 0.177, width: 0.029, spread: 62, fold: 7 },
35
+ { u: 0.38, len: 0.190, width: 0.028, spread: 53, fold: 6 },
36
+ { u: 0.49, len: 0.205, width: 0.027, spread: 44, fold: 5, emarg: 0.5 },
37
+ { u: 0.60, len: 0.222, width: 0.026, spread: 36, fold: 4, emarg: 0.9 },
38
+ { u: 0.71, len: 0.228, width: 0.025, spread: 28, fold: 3, emarg: 1 },
39
+ { u: 0.81, len: 0.222, width: 0.024, spread: 20, fold: 2, emarg: 1 },
40
+ { u: 0.91, len: 0.200, width: 0.022, spread: 12, fold: 1, emarg: 1 },
41
+ { u: 1.00, len: 0.122, width: 0.019, spread: 5, fold: 0.5, emarg: 0.6 },
42
+ ],
43
+ // 6 secondaries + 3 tertials, from the wrist to the elbow
44
+ secondaries: [
45
+ { u: 0.03, len: 0.150, width: 0.033, spread: 90, fold: 176 },
46
+ { u: 0.14, len: 0.150, width: 0.033, spread: 92, fold: 176 },
47
+ { u: 0.25, len: 0.148, width: 0.033, spread: 94, fold: 176 },
48
+ { u: 0.36, len: 0.146, width: 0.033, spread: 96, fold: 176 },
49
+ { u: 0.47, len: 0.144, width: 0.033, spread: 99, fold: 176 },
50
+ { u: 0.58, len: 0.140, width: 0.033, spread: 102, fold: 177 },
51
+ { u: 0.70, len: 0.132, width: 0.032, spread: 108, fold: 177 },
52
+ { u: 0.81, len: 0.122, width: 0.031, spread: 116, fold: 178 },
53
+ { u: 0.92, len: 0.108, width: 0.030, spread: 125, fold: 179 },
54
+ ],
55
+ // 12 rectrices (6 a side, central -> outer); tail slightly rounded; fan: fully spread angle
56
+ rectrices: [
57
+ { x: 0.002, len: 0.168, width: 0.034, fan: 4, fold: 0.5, bend: 0 },
58
+ { x: 0.004, len: 0.168, width: 0.033, fan: 14, fold: 1, bend: -1 },
59
+ { x: 0.006, len: 0.166, width: 0.032, fan: 25, fold: 1.5, bend: -2 },
60
+ { x: 0.008, len: 0.163, width: 0.031, fan: 36, fold: 2, bend: -3 },
61
+ { x: 0.010, len: 0.158, width: 0.030, fan: 47, fold: 2.5, bend: -4 },
62
+ { x: 0.012, len: 0.150, width: 0.029, fan: 58, fold: 3, bend: -5 },
63
+ ],
64
+ coverts: { primary: 0.34, secondary: 0.6, tail: 0.44 },
65
+ };
66
+
67
+ export const motion = {
68
+ gears: { walk: 0.5, hop: 1.2, fly: 10.5 },
69
+ maxSpeed: 13,
70
+ ground: { maxSpeed: 1.9, accel: [2.5, 4], decel: 5, turnRate: 4.5 },
71
+ gaits: [
72
+ G('walk', 0.0, 1.5, 0.72, [0, 0.5], { lift: 0.02, bob: 0.004, sway: 0.006, pitch: 0, headBob: 1, wings: 0, tail: 0.6 }),
73
+ G('walk', 0.45, 2.1, 0.66, [0, 0.5], { lift: 0.024, bob: 0.006, sway: 0.006, pitch: -2, headBob: 1, wings: 0, tail: 0.8 }),
74
+ G('walk', 0.75, 2.5, 0.6, [0, 0.5], { lift: 0.026, bob: 0.007, sway: 0.005, pitch: -5, headBob: 0.6, wings: 0.05, tail: 0.8 }),
75
+ G('hop', 1.0, 3.2, 0.42, [0, 0], { lift: 0.03, bob: 0.004, hop: 0.04, sway: 0, pitch: -10, headBob: 0.2, wings: 0.15, tail: 0.5 }),
76
+ G('hop', 1.8, 3.6, 0.36, [0, 0], { lift: 0.032, bob: 0.004, hop: 0.05, sway: 0, pitch: -14, headBob: 0.1, wings: 0.3, tail: 0.5 }),
77
+ ],
78
+ feet: { spread: [0, 22, 0, -22], curl: 70, grip: 1, pad: 0.0055 },
79
+ // standing body: axis tilt above horizontal (deg); belly section (bind, ref size): centre height,
80
+ // half height, half width
81
+ body: { tilt: 30, belly: { y: 0.15, hh: 0.058, hw: 0.045 } },
82
+ head: { bob: 1, yaw: 2.4, pitchUp: 0.6, pitchDown: 1.2, saccade: 1, cock: 0.35, jawRest: -4.6 },
83
+ tail: { pitch: -6, walkBob: 6, sway: 5, flick: 1, fanRest: 0.05 },
84
+ wing: WING,
85
+ feathers: FEATHERS,
86
+ flight: {
87
+ minSpeed: 5.5, cruise: 10.5, maxSpeed: 13, climb: [3.0, -5.0], bankMax: 60, turnRate: 2.4,
88
+ clearance: 1.6, glideRatio: 7, sustained: true,
89
+ // cruise: legs folded back along the body, feet under the undertail coverts (flight1 / flight2)
90
+ legTuck: { back: 0.86, down: 0.0, side: 0.5 },
91
+ },
92
+ takeoff: { crouch: 0.16, jump: 2.2, angle: 35, beats: 5 },
93
+ landing: { approach: 7, flare: 0.55, touch: 1.0 },
94
+ actions: {
95
+ attack: { style: 'peck' },
96
+ eat: { style: 'peck', rate: 2.4, reach: 1.3, billPitch: 0.62, bodyPitch: -0.5, drop: 0.32 },
97
+ drink: {},
98
+ jump: { height: 0.2, distance: 0.45 },
99
+ sleep: { style: 'sink' }, // roosting: head drawn into the shoulders, bill tucked into the breast feathers
100
+ },
101
+ };
@@ -0,0 +1,50 @@
1
+ // Meshing plan: body (incl. wing arms and legs) at 1.7 mm, head + the top of the neck at 0.86 mm
2
+ // (overlapping the body at the cut and cross-faded), eyelid patches at 0.35 mm, and the lower mandible
3
+ // as its own rigid surface so the bill can open. Cells scale with the quality tier (Q.res).
4
+ import { J } from './joints.js';
5
+ import { EYE } from './sculpt.js';
6
+ import { HEAD_O, NECK_SEGS } from './rig.js';
7
+ import { eyeFrameOf } from '../../core/sdf/eyeSocket.js';
8
+ import { lerp, norm, sub, smoothstep } from '../../core/math/vec.js';
9
+
10
+ export const NECK_CUT = (() => {
11
+ const d = norm(sub(J.occiput, J['neck' + (NECK_SEGS - 1)]));
12
+ const c = lerp(J['neck' + (NECK_SEGS - 1)], J.occiput, 0.55);
13
+ return { c, d, band: 0.004 };
14
+ })();
15
+ export const neckS = (x, y, z) => (x - NECK_CUT.c[0]) * NECK_CUT.d[0] + (y - NECK_CUT.c[1]) * NECK_CUT.d[1] + (z - NECK_CUT.c[2]) * NECK_CUT.d[2];
16
+
17
+ export const EYE_PATCH = { R: 0.0085, B: 0.0018, h: 0.00035, centres: [1, -1].map((s) => eyeFrameOf(EYE, HEAD_O, s).c) };
18
+ export function eyePatchWeight(x, y, z) {
19
+ let dmin = 1e9;
20
+ for (const c of EYE_PATCH.centres) dmin = Math.min(dmin, Math.hypot(x - c[0], y - c[1], z - c[2]));
21
+ return 1 - smoothstep(EYE_PATCH.R - EYE_PATCH.B, EYE_PATCH.R + EYE_PATCH.B, dmin);
22
+ }
23
+
24
+ export function crowRegions(rig, params, Q) {
25
+ const B = NECK_CUT.band, r = Q.res;
26
+ const patches = Q.eyePatches ? EYE_PATCH.centres.map((c) => ({ c, R: EYE_PATCH.R, B: EYE_PATCH.B, h: EYE_PATCH.h * Math.max(1, r) })) : [];
27
+ return {
28
+ jobs: [
29
+ [
30
+ { name: 'body', part: 'body', bmin: [-0.19, -0.004, -0.15], bmax: [0.19, 0.3, 0.14], h: 0.0017 * r, F: 4, clip: (x, y, z) => neckS(x, y, z) < B },
31
+ ],
32
+ [
33
+ { name: 'head', part: 'body', bmin: [-0.035, 0.225, 0.015], bmax: [0.035, 0.335, 0.192], h: 0.00086 * r, F: 6, clip: (x, y, z) => neckS(x, y, z) > -B, patches },
34
+ { name: 'jaw', part: 'jaw', bmin: [-0.014, 0.262, 0.1], bmax: [0.014, 0.296, 0.19], h: 0.00068 * r, F: 6, rigidBone: 'jaw' },
35
+ ],
36
+ ],
37
+ fade(x, y, z, name, patch) {
38
+ const sN = neckS(x, y, z);
39
+ if (name === 'body') return 1 - smoothstep(-B, B, sN);
40
+ if (name === 'head') {
41
+ // (the head surface reaches 1.5 mm past the body's cut: the two overlap instead of leaving a
42
+ // see-through crack where the meshes do not coincide exactly)
43
+ let f = smoothstep(-B - 0.0015, B - 0.0015, sN);
44
+ if (patches.length) { const ew = eyePatchWeight(x, y, z); f *= patch ? ew : 1 - ew; }
45
+ return f;
46
+ }
47
+ return 1;
48
+ },
49
+ };
50
+ }
@@ -0,0 +1,83 @@
1
+ // Crow skeleton in bind pose (metres). Forward = +Z, up = +Y, the bird's left = +X; ground at y = 0,
2
+ // the feet under the centre of mass at z ~ 0. Proportions from the side reference photo (side1: tarsus
3
+ // 60 mm -> 1.3 mm/px; bill tip to tail tip 0.44 m, crown 0.33 m above the feet with the head up) and
4
+ // corvid osteometry (femur 47, tibiotarsus 84, tarsometatarsus 57 mm; humerus 67, ulna 78, hand 58 mm).
5
+ // Wings are bound half open (drooped out to the side) so the arm skin deforms evenly toward both the
6
+ // folded and the spread wing; the flight feathers are separate bones (see core/rig/bird.js).
7
+ import { buildRig } from '../../core/rig/rig.js';
8
+ import { birdBones, birdLimbs, neckChain, wingJoints, featherJoints } from '../../core/rig/bird.js';
9
+ import { WING, FEATHERS } from './motion.js';
10
+
11
+ export const NECK_SEGS = 4;
12
+ // the head sits low and close on the body (the neck's S is hidden in the feathers): HEAD_DROP moves
13
+ // the skull and bill down / back from the base layout (otherwise the neck reads thick and upright)
14
+ export const HEAD_DROP = [0, -0.005, -0.003];
15
+ const hd = (v) => [v[0] + HEAD_DROP[0], v[1] + HEAD_DROP[1], v[2] + HEAD_DROP[2]];
16
+ export const HEAD_O = hd([0, 0.3, 0.106]); // head-local origin: between the eyes
17
+
18
+ const n2 = (y, z) => { const l = Math.hypot(y, z); return [0, y / l, z / l]; };
19
+
20
+ export function crowJoints() {
21
+ const J = {
22
+ synsacrum: [0, 0.166, -0.034],
23
+ tailBase: [0, 0.168, -0.074],
24
+ tailTip: [0, 0.166, -0.097],
25
+ neckBase: [0, 0.205, 0.046],
26
+ occiput: hd([0, 0.281, 0.064]),
27
+ bill: hd([0, 0.305, 0.187]),
28
+ jawHinge: hd([0, 0.29, 0.1]),
29
+ jawTip: hd([0, 0.296, 0.181]),
30
+ shoulderL: [0.03, 0.213, 0.03],
31
+ hipL: [0.026, 0.15, -0.03],
32
+ kneeL: [0.033, 0.122, 0.008],
33
+ ankleL: [0.03, 0.058, -0.044],
34
+ mtpL: [0.024, 0.0062, -0.02],
35
+ };
36
+ // toes: III (middle) forward, II inner, IV outer, I (hallux) back; two segments each (phalanges +
37
+ // claw in the distal one), lying on the ground
38
+ const toe = (j, yawDeg, a, b, back = false) => {
39
+ const y = (yawDeg * Math.PI) / 180, m = J.mtpL;
40
+ const dir = back ? [Math.sin(y), 0, -Math.cos(y)] : [Math.sin(y), 0, Math.cos(y)];
41
+ J[`t${j}mL`] = [m[0] + dir[0] * a, 0.0034, m[2] + dir[2] * a];
42
+ J[`t${j}tL`] = [m[0] + dir[0] * (a + b), 0.0022, m[2] + dir[2] * (a + b)];
43
+ };
44
+ toe(3, 2, 0.02, 0.021);
45
+ toe(2, -22, 0.014, 0.016);
46
+ toe(4, 24, 0.015, 0.017);
47
+ toe(1, -6, 0.014, 0.015, true);
48
+ neckChain(J, NECK_SEGS, n2(0.45, 1), n2(1, -0.35), 0.42);
49
+ wingJoints(J, WING);
50
+ featherJoints(J, WING, FEATHERS, { bindFan: 0.2 });
51
+ return J;
52
+ }
53
+
54
+ export function crowRig() {
55
+ const J = crowJoints();
56
+ const neck = Array.from({ length: NECK_SEGS - 1 }, (_, i) => 'neck' + (NECK_SEGS - 1 - i));
57
+ const neckBones = Array.from({ length: NECK_SEGS }, (_, i) => 'neck' + (NECK_SEGS - 1 - i));
58
+ return buildRig({
59
+ joints: J,
60
+ unit: 0.25,
61
+ headOrigin: HEAD_O,
62
+ bones: birdBones({ neckSegs: NECK_SEGS, jaw: true, primaries: FEATHERS.primaries.length, secondaries: FEATHERS.secondaries.length, rectrices: FEATHERS.rectrices.length }),
63
+ axial: {
64
+ points: ['bill', 'occiput', ...neck, 'neckBase', 'synsacrum', 'tailBase', 'tailTip'],
65
+ bones: ['head', ...neckBones, 'chest', 'pelvis', 'tail'],
66
+ // wide blends along the neck: a thick, feathered neck on few segments bends over its whole
67
+ // length instead of creasing at the joints. The skull's influence runs well down the neck and
68
+ // the neck base blends far into the breast (the breast feathers follow the neck), which keeps
69
+ // skin distortion low in head-down / head-back poses (metrics: distort3)
70
+ blend: Object.fromEntries([
71
+ [1, [-0.5, 0.2]],
72
+ ...Array.from({ length: NECK_SEGS - 1 }, (_, k) => [2 + k, [-0.1, 0.1]]),
73
+ [1 + NECK_SEGS, [-0.45, 0.03]],
74
+ ]),
75
+ },
76
+ limbs: birdLimbs({
77
+ leg: { tCore: 0.95, aCore: 0.07, aBody: -0.05, midX: 0.012 },
78
+ wing: { tCore: 0.3, aCore: 0.16, aBody: -0.16, midX: 0.02 },
79
+ }),
80
+ appendages: [],
81
+ webTags: ['flankfold', 'scapular'],
82
+ });
83
+ }
@@ -0,0 +1,118 @@
1
+ // The crow sculpted as a signed distance field (the feathered silhouette: contour feathers are part
2
+ // of the body shape; flight feathers are cards, see core/build/featherCards.js).
3
+ // Every primitive is attached to a bone and a group (axial / legL / wingL / jaw).
4
+ import { HEAD_O, NECK_SEGS } from './rig.js';
5
+ import { add, sub, mul, lerp, norm, cross, dot } from '../../core/math/vec.js';
6
+ import { sculptEyeSocket } from '../../core/sdf/eyeSocket.js';
7
+
8
+ // Eye (head-local, left): lateral-frontal (yaw 62 deg), visible iris ~7.5 mm, round aperture.
9
+ export const EYE = { c: [0.0185, 0.0005, 0.003], r: 0.0056, back: 0.0016, yaw: 1.08, pitch: 0.05, lid: 0.00045, R: 0.0047, d: 0.0006, off: 0.0, tilt: 0, irisZ: 0.0036, irisR: 0.0044 };
10
+
11
+ const hl = (v) => [v[0] + HEAD_O[0], v[1] + HEAD_O[1], v[2] + HEAD_O[2]];
12
+
13
+ export function sculptCrow(m, rig) {
14
+ const J = rig.J;
15
+ // ellipsoid whose local Y follows ydir and local X follows (roughly) xdir; r = [x, y, z]
16
+ const ellY = (o) => {
17
+ const y = norm(o.ydir);
18
+ let x = o.xdir || [1, 0, 0];
19
+ x = norm(sub(x, mul(y, dot(x, y))));
20
+ const z = cross(x, y);
21
+ return m.ell({ ...o, axis: z, up: y });
22
+ };
23
+ const A = { bone: 'chest' }, Pv = { bone: 'pelvis' };
24
+
25
+ // ---------------------------------------------------------------- TORSO (feathered)
26
+ const tilt = norm([0, 0.5, 0.866]);
27
+ m.ell({ ...A, tag: 'breast', c: [0, 0.182, 0.048], r: [0.044, 0.053, 0.07], axis: tilt, k: 0 });
28
+ m.ell({ ...A, tag: 'mantle', c: [0, 0.2, 0.0], r: [0.043, 0.038, 0.07], axis: tilt, k: 0.02 });
29
+ // straight underside from breast to vent (no sagging belly)
30
+ m.ell({ ...Pv, tag: 'belly', c: [0, 0.14, -0.012], r: [0.041, 0.036, 0.07], axis: norm([0, 0.35, 1]), k: 0.022 });
31
+ m.ell({ ...Pv, tag: 'rump', c: [0, 0.163, -0.07], r: [0.03, 0.03, 0.045], axis: norm([0, 0.3, 1]), k: 0.02 });
32
+ m.ell({ bone: 'tail', tag: 'undertail', c: [0, 0.147, -0.108], r: [0.019, 0.015, 0.055], axis: norm([0, 0.18, 1]), k: 0.016 });
33
+ m.ell({ bone: 'tail', tag: 'uppertail', c: [0, 0.172, -0.096], r: [0.019, 0.011, 0.032], axis: norm([0, 0.1, 1]), k: 0.012 });
34
+ for (const s of [1, -1]) {
35
+ m.ell({ ...Pv, tag: 'flankfold', c: [0.026 * s, 0.145, -0.02], r: [0.02, 0.03, 0.06], k: 0.02 });
36
+ // sides under the folded wing: the wing's lower edge is the silhouette
37
+ m.ell({ ...Pv, tag: 'sides', c: [0.03 * s, 0.162, -0.012], r: [0.017, 0.026, 0.066], axis: norm([0, 0.2, 1]), k: 0.02 });
38
+ m.ell({ ...A, tag: 'scapular', c: [0.026 * s, 0.211, 0.004], r: [0.02, 0.014, 0.05], axis: tilt, k: 0.018 });
39
+ }
40
+
41
+ // ---------------------------------------------------------------- NECK
42
+ const nj = ['neckBase', ...Array.from({ length: NECK_SEGS - 1 }, (_, i) => 'neck' + (i + 1)), 'occiput'];
43
+ // radius tapers from the base (30 mm) to the skull (19 mm)
44
+ const nr = nj.map((_, i) => { const u = i / NECK_SEGS; return 0.03 - 0.011 * Math.pow(u, 0.8); });
45
+ for (let i = 0; i < NECK_SEGS; i++) m.cone({ bone: 'neck' + i, tag: 'neck', a: J[nj[i]], b: J[nj[i + 1]], ra: nr[i], rb: nr[i + 1], k: 0.02 });
46
+ // throat filled out: bill, chin, throat and breast in one convex line
47
+ m.ell({ bone: 'neck' + Math.round(NECK_SEGS * 0.3), tag: 'throat', c: [0, 0.232, 0.087], r: [0.021, 0.028, 0.027], axis: norm([0, 0.6, 1]), k: 0.021 });
48
+ m.ell({ bone: 'neck' + Math.round(NECK_SEGS * 0.55), tag: 'nape', c: [0, 0.248, 0.04], r: [0.0166, 0.02, 0.0204], k: 0.022 });
49
+
50
+ // ---------------------------------------------------------------- HEAD (head-local, see HEAD_O)
51
+ // landmarks from side1 / face1: bill tip (0, 0.005, 0.081), bill base at z 0.031 (19 mm deep),
52
+ // eyes (+-0.0185, 0, 0.003), crown 0.029 above the eyes, occiput (0, -0.019, -0.042)
53
+ const H = { bone: 'head' };
54
+ // one smooth dome from the forehead over the crown to the nape (no double hump)
55
+ m.ell({ ...H, tag: 'cranium', c: hl([0, 0.004, -0.01]), r: [0.0185, 0.021, 0.031], k: 0.014 });
56
+ m.ell({ ...H, tag: 'crown', c: hl([0, 0.012, 0.006]), r: [0.0145, 0.0105, 0.022], axis: norm([0, -0.25, 1]), k: 0.016 });
57
+ m.ell({ ...H, tag: 'forehead', c: hl([0, 0.0115, 0.022]), r: [0.0115, 0.0115, 0.016], axis: norm([0, -0.45, 1]), k: 0.012 });
58
+ m.ell({ ...H, tag: 'chin', c: hl([0, -0.02, 0.006]), r: [0.012, 0.012, 0.026], axis: norm([0, 0.25, 1]), k: 0.012 });
59
+ for (const s of [1, -1]) {
60
+ m.ell({ ...H, tag: 'cheek', c: hl([0.011 * s, -0.009, 0.01]), r: [0.009, 0.012, 0.02], k: 0.008 });
61
+ m.ell({ ...H, tag: 'brow', c: hl([0.013 * s, 0.009, 0.004]), r: [0.007, 0.006, 0.014], k: 0.006 });
62
+ sculptEyeSocket(m, EYE, HEAD_O, s, { bone: 'head' });
63
+ }
64
+ // upper mandible: deep at the base, culmen curving down to a sharp tip; nasal bristles cover the
65
+ // basal third
66
+ // massive bill: ~18 mm deep at the base (about as deep as the forehead), strongly curved culmen
67
+ m.ell({ ...H, tag: 'bill', c: hl([0, 0.001, 0.042]), r: [0.0085, 0.0105, 0.022], axis: norm([0, -0.08, 1]), k: 0.007 });
68
+ m.cone({ ...H, tag: 'bill', a: hl([0, 0.004, 0.054]), b: hl([0, 0.0028, 0.0808]), ra: 0.0068, rb: 0.001, k: 0.007 });
69
+ m.cone({ ...H, tag: 'bill', a: hl([0, -0.004, 0.05]), b: hl([0, 0.0018, 0.0802]), ra: 0.0052, rb: 0.001, k: 0.006 });
70
+ // nasal bristles lie flat along the top of the bill base
71
+ m.ell({ ...H, tag: 'bristles', c: hl([0, 0.0098, 0.035]), r: [0.0078, 0.004, 0.013], axis: norm([0, -0.2, 1]), k: 0.005 });
72
+ // lower mandible (own surface so the bill can open)
73
+ const Jw = { bone: 'jaw', part: 'jaw' };
74
+ m.ell({ ...Jw, tag: 'mandible', c: hl([0, -0.0098, 0.038]), r: [0.0075, 0.0052, 0.028], axis: norm([0, 0.08, 1]), k: 0.004 });
75
+ m.cone({ ...Jw, tag: 'mandible', a: hl([0, -0.0082, 0.05]), b: hl([0, -0.0006, 0.0772]), ra: 0.0052, rb: 0.0009, k: 0.004 });
76
+ m.ell({ ...Jw, tag: 'gonys', c: hl([0, -0.0135, 0.02]), r: [0.0095, 0.0068, 0.02], k: 0.006 });
77
+
78
+ // ---------------------------------------------------------------- LEGS
79
+ for (const s of [1, -1]) {
80
+ const S = s > 0 ? 'L' : 'R', g = 'leg' + S;
81
+ const j = (n) => J[n + S];
82
+ // drumstick: feathered "trousers" down to ~1 cm above the ankle, then the bare lower tibiotarsus
83
+ const kn = j('knee'), an = j('ankle');
84
+ ellY({ bone: 'tibia' + S, group: g, tag: 'thigh', c: lerp(kn, an, 0.22), ydir: sub(an, kn), r: [0.017, 0.03, 0.02], k: 0.02 });
85
+ m.cone({ bone: 'tibia' + S, group: g, tag: 'trousers', a: lerp(kn, an, 0.3), b: lerp(kn, an, 0.8), ra: 0.014, rb: 0.0075, k: 0.01 });
86
+ m.cone({ bone: 'tibia' + S, group: g, tag: 'shank', a: lerp(kn, an, 0.7), b: an, ra: 0.0055, rb: 0.0045, k: 0.004 });
87
+ m.cone({ bone: 'tarsus' + S, group: g, tag: 'tarsus', a: an, b: j('mtp'), ra: 0.0044, rb: 0.0036, k: 0.003 });
88
+ m.sphere({ bone: 'tarsus' + S, group: g, tag: 'pad', c: add(j('mtp'), [0, -0.0015, 0.001]), rad: 0.0045, k: 0.003 });
89
+ for (const t of [1, 2, 3, 4]) {
90
+ const a = j('mtp'), b = J[`t${t}m${S}`], c = J[`t${t}t${S}`];
91
+ const r0 = t === 1 ? 0.0032 : 0.0028;
92
+ m.cone({ bone: `toe${t}a${S}`, group: g, tag: 'toe', a, b, ra: r0, rb: 0.0024, k: 0.0025 });
93
+ m.cone({ bone: `toe${t}b${S}`, group: g, tag: 'toe', a: b, b: lerp(b, c, 0.72), ra: 0.0024, rb: 0.0017, k: 0.002 });
94
+ m.cone({ bone: `toe${t}b${S}`, group: g, tag: 'claw', a: lerp(b, c, 0.65), b: c, ra: 0.0015, rb: 0.0003, k: 0.001 });
95
+ }
96
+ }
97
+
98
+ // ---------------------------------------------------------------- WINGS (arm; flight feathers are cards)
99
+ for (const s of [1, -1]) {
100
+ const S = s > 0 ? 'L' : 'R', g = 'wing' + S;
101
+ const sh = J['shoulder' + S], el = J['elbow' + S], wr = J['wrist' + S], tp = J['handTip' + S];
102
+ let n = norm(cross(sub(el, sh), sub(wr, el)));
103
+ if (n[1] < 0) n = mul(n, -1);
104
+ const seg = (a, b, bone, thick, chord, back, tag, k = 0.008) => {
105
+ const d = norm(sub(b, a));
106
+ const t = mul(norm(cross(n, d)), s); // trailing side
107
+ const c = add(lerp(a, b, 0.5), mul(t, back));
108
+ return ellY({ bone, group: g, tag, c, ydir: d, xdir: n, r: [thick, Math.hypot(...sub(b, a)) * 0.58, chord], k });
109
+ };
110
+ seg(sh, el, 'humerus' + S, 0.01, 0.026, 0.009, 'arm', 0.012);
111
+ seg(el, wr, 'ulna' + S, 0.0085, 0.026, 0.011, 'arm');
112
+ seg(wr, tp, 'hand' + S, 0.0055, 0.012, 0.004, 'hand', 0.006);
113
+ // leading-edge roll (propatagium, marginal coverts) on the forearm only: it stays on the arm when
114
+ // the elbow opens (a web spanning shoulder -> wrist swings forward as a loop)
115
+ seg(lerp(el, wr, 0.08), wr, 'ulna' + S, 0.0065, 0.009, -0.009, 'patagium', 0.009);
116
+ m.sphere({ bone: 'hand' + S, group: g, tag: 'wrist', c: wr, rad: 0.0065, k: 0.006 });
117
+ }
118
+ }