@bitefoundry/retrieviewer 0.0.2 → 0.0.4

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 (261) hide show
  1. package/ASSET-PROVENANCE.md +6 -0
  2. package/ASSETS-LICENSE.md +2 -1
  3. package/ATTRIBUTION.md +6 -1
  4. package/COMFORT-ART.md +65 -0
  5. package/DESKTOP-PLATFORMS.md +75 -0
  6. package/INSTALLING.md +8 -5
  7. package/PLUGIN.md +13 -10
  8. package/PREREQUISITES.md +95 -0
  9. package/PUPPY-MEMORY.md +102 -1
  10. package/README.ko.md +110 -0
  11. package/README.md +119 -58
  12. package/RELEASING.md +27 -14
  13. package/THIRD-PARTY-NOTICES.md +5 -3
  14. package/braille.mjs +35 -9
  15. package/examples/live.mjs +2 -2
  16. package/integrations/desktop/platform.mjs +27 -0
  17. package/integrations/linux-overlay/README.md +83 -0
  18. package/integrations/linux-overlay/overlay.py +1094 -0
  19. package/integrations/macos-overlay/README.md +83 -0
  20. package/integrations/macos-overlay/overlay.jxa +639 -0
  21. package/integrations/opencode/runtime.mjs +4 -4
  22. package/integrations/opencode/tui.tsx +1 -1
  23. package/integrations/windows-overlay/Overlay.cs +4 -4
  24. package/integrations/windows-overlay/desktop.mjs +40 -8
  25. package/integrations/windows-overlay/protocol.mjs +11 -7
  26. package/integrations/windows-overlay/worker.mjs +13 -7
  27. package/package.json +41 -14
  28. package/puppy-comfort-sprites.mjs +25 -0
  29. package/puppy-companion-comfort-q5.bin.gz +0 -0
  30. package/puppy-companion-comfort.json +77 -0
  31. package/puppy-companion-life.mjs +49 -16
  32. package/puppy-companion-objects.mjs +12 -0
  33. package/puppy-frame-predictive.mjs +15 -9
  34. package/puppy-frame-store.mjs +2 -2
  35. package/puppy-paper-world.mjs +14 -0
  36. package/puppy-paper.mjs +65 -14
  37. package/retrieviewer-cli.mjs +10 -3
  38. package/retrieviewer-plugin.d.mts +1 -1
  39. package/retrieviewer-plugin.mjs +1 -1
  40. package/retrieviewer.d.mts +10 -4
  41. package/retrieviewer.mjs +20 -14
  42. package/locomotion-core.mjs +0 -21
  43. package/locomotion-puppy.animal +0 -0
  44. package/vendor/procedural-animals/package.json +0 -40
  45. package/vendor/procedural-animals/src/animal.js +0 -146
  46. package/vendor/procedural-animals/src/bake.js +0 -51
  47. package/vendor/procedural-animals/src/build.js +0 -81
  48. package/vendor/procedural-animals/src/core/build/coatKit.js +0 -121
  49. package/vendor/procedural-animals/src/core/build/featherCards.js +0 -189
  50. package/vendor/procedural-animals/src/core/build/finEdges.js +0 -85
  51. package/vendor/procedural-animals/src/core/build/furSlope.js +0 -115
  52. package/vendor/procedural-animals/src/core/build/mesh.js +0 -67
  53. package/vendor/procedural-animals/src/core/build/pipeline.js +0 -272
  54. package/vendor/procedural-animals/src/core/build/seams.js +0 -183
  55. package/vendor/procedural-animals/src/core/build/warp.js +0 -112
  56. package/vendor/procedural-animals/src/core/build/weights.js +0 -393
  57. package/vendor/procedural-animals/src/core/math/vec.js +0 -81
  58. package/vendor/procedural-animals/src/core/motion/actions.js +0 -800
  59. package/vendor/procedural-animals/src/core/motion/bird.js +0 -3063
  60. package/vendor/procedural-animals/src/core/motion/birdActions.js +0 -1059
  61. package/vendor/procedural-animals/src/core/motion/common.js +0 -158
  62. package/vendor/procedural-animals/src/core/motion/index.js +0 -22
  63. package/vendor/procedural-animals/src/core/motion/quadruped.js +0 -2875
  64. package/vendor/procedural-animals/src/core/motion/snake.js +0 -1594
  65. package/vendor/procedural-animals/src/core/motion/spider.js +0 -1810
  66. package/vendor/procedural-animals/src/core/motion/swimmer.js +0 -1047
  67. package/vendor/procedural-animals/src/core/motion/swimmerActions.js +0 -613
  68. package/vendor/procedural-animals/src/core/render/animalObject.js +0 -262
  69. package/vendor/procedural-animals/src/core/render/coatMaterial.js +0 -1301
  70. package/vendor/procedural-animals/src/core/render/dqs.js +0 -159
  71. package/vendor/procedural-animals/src/core/render/eyes.js +0 -676
  72. package/vendor/procedural-animals/src/core/render/membranes.js +0 -77
  73. package/vendor/procedural-animals/src/core/render/skeleton.js +0 -41
  74. package/vendor/procedural-animals/src/core/rig/bird.js +0 -327
  75. package/vendor/procedural-animals/src/core/rig/quadruped.js +0 -76
  76. package/vendor/procedural-animals/src/core/rig/rig.js +0 -79
  77. package/vendor/procedural-animals/src/core/rig/snake.js +0 -76
  78. package/vendor/procedural-animals/src/core/rig/spider.js +0 -110
  79. package/vendor/procedural-animals/src/core/rig/swimmer.js +0 -181
  80. package/vendor/procedural-animals/src/core/sdf/eyeSocket.js +0 -53
  81. package/vendor/procedural-animals/src/core/sdf/mesher.js +0 -238
  82. package/vendor/procedural-animals/src/core/sdf/sdf.js +0 -263
  83. package/vendor/procedural-animals/src/index.d.ts +0 -98
  84. package/vendor/procedural-animals/src/index.js +0 -29
  85. package/vendor/procedural-animals/src/registry.js +0 -48
  86. package/vendor/procedural-animals/src/species/bear/behaviour.js +0 -463
  87. package/vendor/procedural-animals/src/species/bear/claws.js +0 -147
  88. package/vendor/procedural-animals/src/species/bear/coat.js +0 -726
  89. package/vendor/procedural-animals/src/species/bear/index.js +0 -139
  90. package/vendor/procedural-animals/src/species/bear/motion.js +0 -112
  91. package/vendor/procedural-animals/src/species/bear/regions.js +0 -78
  92. package/vendor/procedural-animals/src/species/bear/rig.js +0 -112
  93. package/vendor/procedural-animals/src/species/bear/sculpt.js +0 -272
  94. package/vendor/procedural-animals/src/species/boar/behaviour.js +0 -335
  95. package/vendor/procedural-animals/src/species/boar/coat.js +0 -372
  96. package/vendor/procedural-animals/src/species/boar/index.js +0 -110
  97. package/vendor/procedural-animals/src/species/boar/motion.js +0 -85
  98. package/vendor/procedural-animals/src/species/boar/regions.js +0 -88
  99. package/vendor/procedural-animals/src/species/boar/rig.js +0 -111
  100. package/vendor/procedural-animals/src/species/boar/sculpt.js +0 -285
  101. package/vendor/procedural-animals/src/species/cat/behaviour.js +0 -559
  102. package/vendor/procedural-animals/src/species/cat/coat.js +0 -841
  103. package/vendor/procedural-animals/src/species/cat/index.js +0 -211
  104. package/vendor/procedural-animals/src/species/cat/motion.js +0 -101
  105. package/vendor/procedural-animals/src/species/cat/regions.js +0 -82
  106. package/vendor/procedural-animals/src/species/cat/rig.js +0 -100
  107. package/vendor/procedural-animals/src/species/cat/sculpt.js +0 -266
  108. package/vendor/procedural-animals/src/species/cat/whiskers.js +0 -110
  109. package/vendor/procedural-animals/src/species/cheetah/coat.js +0 -427
  110. package/vendor/procedural-animals/src/species/cheetah/index.js +0 -51
  111. package/vendor/procedural-animals/src/species/cheetah/joints.js +0 -3
  112. package/vendor/procedural-animals/src/species/cheetah/motion.js +0 -77
  113. package/vendor/procedural-animals/src/species/cheetah/regions.js +0 -95
  114. package/vendor/procedural-animals/src/species/cheetah/rig.js +0 -66
  115. package/vendor/procedural-animals/src/species/cheetah/sculpt.js +0 -158
  116. package/vendor/procedural-animals/src/species/chicken/coat.js +0 -313
  117. package/vendor/procedural-animals/src/species/chicken/coverts.js +0 -320
  118. package/vendor/procedural-animals/src/species/chicken/index.js +0 -110
  119. package/vendor/procedural-animals/src/species/chicken/motion.js +0 -177
  120. package/vendor/procedural-animals/src/species/chicken/regions.js +0 -66
  121. package/vendor/procedural-animals/src/species/chicken/rig.js +0 -144
  122. package/vendor/procedural-animals/src/species/chicken/sculpt.js +0 -389
  123. package/vendor/procedural-animals/src/species/chicken/wingLook.js +0 -66
  124. package/vendor/procedural-animals/src/species/chicken/wingStack.js +0 -124
  125. package/vendor/procedural-animals/src/species/cow/behaviour.js +0 -521
  126. package/vendor/procedural-animals/src/species/cow/coat.js +0 -465
  127. package/vendor/procedural-animals/src/species/cow/index.js +0 -118
  128. package/vendor/procedural-animals/src/species/cow/motion.js +0 -81
  129. package/vendor/procedural-animals/src/species/cow/regions.js +0 -98
  130. package/vendor/procedural-animals/src/species/cow/rig.js +0 -116
  131. package/vendor/procedural-animals/src/species/cow/sculpt.js +0 -339
  132. package/vendor/procedural-animals/src/species/crow/coat.js +0 -145
  133. package/vendor/procedural-animals/src/species/crow/index.js +0 -70
  134. package/vendor/procedural-animals/src/species/crow/joints.js +0 -3
  135. package/vendor/procedural-animals/src/species/crow/motion.js +0 -101
  136. package/vendor/procedural-animals/src/species/crow/regions.js +0 -50
  137. package/vendor/procedural-animals/src/species/crow/rig.js +0 -83
  138. package/vendor/procedural-animals/src/species/crow/sculpt.js +0 -118
  139. package/vendor/procedural-animals/src/species/deer/behaviour.js +0 -513
  140. package/vendor/procedural-animals/src/species/deer/coat.js +0 -391
  141. package/vendor/procedural-animals/src/species/deer/index.js +0 -106
  142. package/vendor/procedural-animals/src/species/deer/motion.js +0 -97
  143. package/vendor/procedural-animals/src/species/deer/regions.js +0 -60
  144. package/vendor/procedural-animals/src/species/deer/rig.js +0 -124
  145. package/vendor/procedural-animals/src/species/deer/sculpt.js +0 -297
  146. package/vendor/procedural-animals/src/species/dog/behaviour.js +0 -521
  147. package/vendor/procedural-animals/src/species/dog/coat.js +0 -495
  148. package/vendor/procedural-animals/src/species/dog/index.js +0 -144
  149. package/vendor/procedural-animals/src/species/dog/motion.js +0 -118
  150. package/vendor/procedural-animals/src/species/dog/regions.js +0 -61
  151. package/vendor/procedural-animals/src/species/dog/rig.js +0 -129
  152. package/vendor/procedural-animals/src/species/dog/sculpt.js +0 -246
  153. package/vendor/procedural-animals/src/species/eagle/coat.js +0 -250
  154. package/vendor/procedural-animals/src/species/eagle/index.js +0 -76
  155. package/vendor/procedural-animals/src/species/eagle/joints.js +0 -3
  156. package/vendor/procedural-animals/src/species/eagle/motion.js +0 -137
  157. package/vendor/procedural-animals/src/species/eagle/regions.js +0 -57
  158. package/vendor/procedural-animals/src/species/eagle/rig.js +0 -107
  159. package/vendor/procedural-animals/src/species/eagle/sculpt.js +0 -137
  160. package/vendor/procedural-animals/src/species/fish/coat.js +0 -271
  161. package/vendor/procedural-animals/src/species/fish/index.js +0 -88
  162. package/vendor/procedural-animals/src/species/fish/motion.js +0 -92
  163. package/vendor/procedural-animals/src/species/fish/regions.js +0 -27
  164. package/vendor/procedural-animals/src/species/fish/rig.js +0 -143
  165. package/vendor/procedural-animals/src/species/fish/sculpt.js +0 -214
  166. package/vendor/procedural-animals/src/species/fish/variants.js +0 -126
  167. package/vendor/procedural-animals/src/species/fox/behaviour.js +0 -314
  168. package/vendor/procedural-animals/src/species/fox/coat.js +0 -444
  169. package/vendor/procedural-animals/src/species/fox/index.js +0 -120
  170. package/vendor/procedural-animals/src/species/fox/motion.js +0 -81
  171. package/vendor/procedural-animals/src/species/fox/regions.js +0 -59
  172. package/vendor/procedural-animals/src/species/fox/rig.js +0 -91
  173. package/vendor/procedural-animals/src/species/fox/sculpt.js +0 -202
  174. package/vendor/procedural-animals/src/species/frog/behaviour.js +0 -590
  175. package/vendor/procedural-animals/src/species/frog/coat.js +0 -305
  176. package/vendor/procedural-animals/src/species/frog/index.js +0 -97
  177. package/vendor/procedural-animals/src/species/frog/motion.js +0 -69
  178. package/vendor/procedural-animals/src/species/frog/regions.js +0 -46
  179. package/vendor/procedural-animals/src/species/frog/rig.js +0 -156
  180. package/vendor/procedural-animals/src/species/frog/sculpt.js +0 -240
  181. package/vendor/procedural-animals/src/species/goat/behaviour.js +0 -509
  182. package/vendor/procedural-animals/src/species/goat/coat.js +0 -590
  183. package/vendor/procedural-animals/src/species/goat/index.js +0 -149
  184. package/vendor/procedural-animals/src/species/goat/motion.js +0 -95
  185. package/vendor/procedural-animals/src/species/goat/regions.js +0 -98
  186. package/vendor/procedural-animals/src/species/goat/rig.js +0 -181
  187. package/vendor/procedural-animals/src/species/goat/sculpt.js +0 -547
  188. package/vendor/procedural-animals/src/species/horse/coat.js +0 -361
  189. package/vendor/procedural-animals/src/species/horse/coatSeam.js +0 -122
  190. package/vendor/procedural-animals/src/species/horse/index.js +0 -80
  191. package/vendor/procedural-animals/src/species/horse/motion.js +0 -245
  192. package/vendor/procedural-animals/src/species/horse/regions.js +0 -60
  193. package/vendor/procedural-animals/src/species/horse/rig.js +0 -117
  194. package/vendor/procedural-animals/src/species/horse/sculpt.js +0 -316
  195. package/vendor/procedural-animals/src/species/horse/seamWeights.js +0 -272
  196. package/vendor/procedural-animals/src/species/lion/behaviour.js +0 -509
  197. package/vendor/procedural-animals/src/species/lion/coat.js +0 -1016
  198. package/vendor/procedural-animals/src/species/lion/index.js +0 -111
  199. package/vendor/procedural-animals/src/species/lion/motion.js +0 -87
  200. package/vendor/procedural-animals/src/species/lion/regions.js +0 -106
  201. package/vendor/procedural-animals/src/species/lion/rig.js +0 -110
  202. package/vendor/procedural-animals/src/species/lion/sculpt.js +0 -384
  203. package/vendor/procedural-animals/src/species/lion/whiskers.js +0 -132
  204. package/vendor/procedural-animals/src/species/pig/behaviour.js +0 -575
  205. package/vendor/procedural-animals/src/species/pig/coat.js +0 -730
  206. package/vendor/procedural-animals/src/species/pig/ears.js +0 -242
  207. package/vendor/procedural-animals/src/species/pig/index.js +0 -161
  208. package/vendor/procedural-animals/src/species/pig/motion.js +0 -105
  209. package/vendor/procedural-animals/src/species/pig/regions.js +0 -100
  210. package/vendor/procedural-animals/src/species/pig/rig.js +0 -152
  211. package/vendor/procedural-animals/src/species/pig/sculpt.js +0 -382
  212. package/vendor/procedural-animals/src/species/rabbit/behaviour.js +0 -605
  213. package/vendor/procedural-animals/src/species/rabbit/coat.js +0 -285
  214. package/vendor/procedural-animals/src/species/rabbit/index.js +0 -85
  215. package/vendor/procedural-animals/src/species/rabbit/motion.js +0 -85
  216. package/vendor/procedural-animals/src/species/rabbit/regions.js +0 -48
  217. package/vendor/procedural-animals/src/species/rabbit/rig.js +0 -99
  218. package/vendor/procedural-animals/src/species/rabbit/sculpt.js +0 -148
  219. package/vendor/procedural-animals/src/species/rat/behaviour.js +0 -539
  220. package/vendor/procedural-animals/src/species/rat/coat.js +0 -341
  221. package/vendor/procedural-animals/src/species/rat/index.js +0 -111
  222. package/vendor/procedural-animals/src/species/rat/motion.js +0 -90
  223. package/vendor/procedural-animals/src/species/rat/regions.js +0 -92
  224. package/vendor/procedural-animals/src/species/rat/rig.js +0 -112
  225. package/vendor/procedural-animals/src/species/rat/sculpt.js +0 -163
  226. package/vendor/procedural-animals/src/species/rat/whiskers.js +0 -119
  227. package/vendor/procedural-animals/src/species/shark/coat.js +0 -383
  228. package/vendor/procedural-animals/src/species/shark/index.js +0 -104
  229. package/vendor/procedural-animals/src/species/shark/motion.js +0 -69
  230. package/vendor/procedural-animals/src/species/shark/regions.js +0 -34
  231. package/vendor/procedural-animals/src/species/shark/rig.js +0 -194
  232. package/vendor/procedural-animals/src/species/shark/sculpt.js +0 -343
  233. package/vendor/procedural-animals/src/species/shark/variants.js +0 -105
  234. package/vendor/procedural-animals/src/species/sheep/behaviour.js +0 -522
  235. package/vendor/procedural-animals/src/species/sheep/coat.js +0 -529
  236. package/vendor/procedural-animals/src/species/sheep/index.js +0 -152
  237. package/vendor/procedural-animals/src/species/sheep/motion.js +0 -86
  238. package/vendor/procedural-animals/src/species/sheep/neck.js +0 -41
  239. package/vendor/procedural-animals/src/species/sheep/regions.js +0 -62
  240. package/vendor/procedural-animals/src/species/sheep/rig.js +0 -163
  241. package/vendor/procedural-animals/src/species/sheep/sculpt.js +0 -542
  242. package/vendor/procedural-animals/src/species/snake/coat.js +0 -315
  243. package/vendor/procedural-animals/src/species/snake/index.js +0 -73
  244. package/vendor/procedural-animals/src/species/snake/motion.js +0 -51
  245. package/vendor/procedural-animals/src/species/snake/regions.js +0 -51
  246. package/vendor/procedural-animals/src/species/snake/rig.js +0 -108
  247. package/vendor/procedural-animals/src/species/snake/sculpt.js +0 -122
  248. package/vendor/procedural-animals/src/species/spider/coat.js +0 -279
  249. package/vendor/procedural-animals/src/species/spider/index.js +0 -78
  250. package/vendor/procedural-animals/src/species/spider/motion.js +0 -72
  251. package/vendor/procedural-animals/src/species/spider/regions.js +0 -87
  252. package/vendor/procedural-animals/src/species/spider/rig.js +0 -118
  253. package/vendor/procedural-animals/src/species/spider/sculpt.js +0 -182
  254. package/vendor/procedural-animals/src/species/wolf/behaviour.js +0 -160
  255. package/vendor/procedural-animals/src/species/wolf/coat.js +0 -749
  256. package/vendor/procedural-animals/src/species/wolf/index.js +0 -107
  257. package/vendor/procedural-animals/src/species/wolf/motion.js +0 -80
  258. package/vendor/procedural-animals/src/species/wolf/regions.js +0 -57
  259. package/vendor/procedural-animals/src/species/wolf/rig.js +0 -87
  260. package/vendor/procedural-animals/src/species/wolf/sculpt.js +0 -339
  261. package/vendor/procedural-animals/src/worker.js +0 -29
@@ -1,194 +0,0 @@
1
- // Shark skeleton (bind pose, metres): forward = +Z, up = +Y, left = +X; the lowest fin tips rest near
2
- // y = 0. Every landmark comes from the variant's outline table (variants.js), so the white shark and
3
- // the blacktip share one builder. The standard swimmer bone set is in core/rig/swimmer.js; the
4
- // heterocercal tail is the caudal chain climbing into the upper lobe (the engine reads its rest pitch).
5
- import { buildRig } from '../../core/rig/rig.js';
6
- import { swimmerBones, swimmerAppendages, axialJoints, axialBones, swimmerJointsAlias, spineName } from '../../core/rig/swimmer.js';
7
- import { VARIANTS } from './variants.js';
8
- import { norm, add, mul, cross, sub, dot } from '../../core/math/vec.js';
9
-
10
- const cr = (p0, p1, p2, p3, t) => {
11
- const t2 = t * t, t3 = t2 * t;
12
- const v = 0.5 * (2 * p1 + (-p0 + p2) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3 * p1 - 3 * p2 + p3) * t3);
13
- const lo = Math.min(p1, p2), hi = Math.max(p1, p2), pad = (hi - lo) * 0.25;
14
- return Math.max(lo - pad, Math.min(hi + pad, v));
15
- };
16
- const D2R = Math.PI / 180;
17
-
18
- /** Geometry helper for one individual: outline lookups (metres), landmarks and fin frames. */
19
- export function sharkGeo(params) {
20
- const V = VARIANTS[params.variant];
21
- if (!V) throw new Error(`shark: unknown variant "${params.variant}"`);
22
- const TL = V.TL;
23
- const rows = V.prof, n = rows.length;
24
- const col = (i, k) => rows[Math.max(0, Math.min(n - 1, i))][k];
25
- const at = (u, k) => {
26
- if (u <= rows[0][0]) return rows[0][k] * Math.sqrt(Math.max(0, u) / rows[0][0]);
27
- if (u >= rows[n - 1][0]) return rows[n - 1][k];
28
- let i = 0;
29
- while (i < n - 2 && u > rows[i + 1][0]) i++;
30
- const t = (u - rows[i][0]) / (rows[i + 1][0] - rows[i][0]);
31
- return cr(col(i - 1, k), col(i, k), col(i + 1, k), col(i + 2, k), t);
32
- };
33
- const girthK = params.girthK || 1;
34
- const axisY = 0.155 * TL;
35
- const z0 = 0.45 * TL;
36
- const G = {
37
- V, TL, axisY, z0, girthK,
38
- finK: params.finK || 1, dorsalK: params.dorsalK || 1, pecK: params.pecK || 1, tailK: params.tailK || 1,
39
- pc: V.precaudal,
40
- z: (u) => z0 - u * TL,
41
- u: (z) => (z0 - z) / TL,
42
- yc: (u) => axisY + ((at(u, 1) - at(u, 2)) / 2) * TL,
43
- hd: (u) => ((at(u, 1) + at(u, 2)) / 2) * TL * (u > 0.1 && u < 0.72 ? 1 + (girthK - 1) * Math.sin(Math.PI * (u - 0.1) / 0.62) : 1),
44
- hw: (u) => at(u, 3) * TL * (u > 0.1 && u < 0.72 ? 1 + (girthK - 1) * Math.sin(Math.PI * (u - 0.1) / 0.62) : 1),
45
- };
46
- G.top = (u) => G.yc(u) + G.hd(u);
47
- G.bot = (u) => G.yc(u) - G.hd(u);
48
- // Cross-section: not an ellipse (that reads as an inflated balloon) but a rounded teardrop: an upper
49
- // ellipse narrower than the body (the back rises to a rounded ridge) united with a wide, flat lower
50
- // ellipse (the flanks are widest below the axis, at the pectoral level, and the belly is flattish).
51
- // The snout is flat underneath and conical above; the peduncle (caudal keels) stays wide.
52
- G.LOW = { dy: 0.3, ry: 0.7 };
53
- G.wk = (u) => {
54
- const t1 = Math.max(0, Math.min(1, (u - 0.08) / 0.14)), t2 = Math.max(0, Math.min(1, (u - 0.66) / 0.12));
55
- const s1 = t1 * t1 * (3 - 2 * t1), s2 = t2 * t2 * (3 - 2 * t2);
56
- return 0.95 - 0.11 * s1 + 0.09 * s2;
57
- };
58
- // surface half width at height y
59
- G.surfX = (u, y) => {
60
- const hd = Math.max(1e-6, G.hd(u)), hw = G.hw(u);
61
- const e = (y - G.yc(u)) / hd;
62
- const eb = (y - (G.yc(u) - G.LOW.dy * hd)) / (G.LOW.ry * hd);
63
- return Math.max(hw * G.wk(u) * Math.sqrt(Math.max(0, 1 - e * e)), hw * Math.sqrt(Math.max(0, 1 - eb * eb)));
64
- };
65
- // the ventral surface at a fraction f of the half width (f < 1)
66
- G.belly = (u, f) => G.yc(u) - G.LOW.dy * G.hd(u) - G.LOW.ry * G.hd(u) * Math.sqrt(Math.max(0, 1 - f * f));
67
- // a point on the flank at (u, height fraction e of the half depth)
68
- G.flank = (u, e, s = 1) => {
69
- const y = G.yc(u) + e * G.hd(u);
70
- return [s * G.surfX(u, y), y, G.z(u)];
71
- };
72
- // mouth: the upper lip line in the side view, from the front of the gape (on the underside) to the
73
- // corner. lipY(u) for u in [uF, uC]
74
- const H = V.head, M = H.mouth;
75
- G.uF = M.uF; G.uC = M.uC;
76
- G.yF = G.bot(M.uF) + 0.0015 * TL;
77
- G.yC = G.yc(M.uC) + M.eC * G.hd(M.uC);
78
- G.lipY = (u) => {
79
- const t = Math.max(0, Math.min(1, (u - M.uF) / (M.uC - M.uF)));
80
- // rises steeply behind the front, then runs flatter to the corner; `smile` bows it down a little
81
- return G.yF + (G.yC - G.yF) * Math.pow(t, 0.7) - M.smile * 0.012 * TL * Math.sin(Math.PI * t);
82
- };
83
- // the lip arc in 3D (one side), t = 0 front centre .. 1 corner; inset (0..1) toward the midline
84
- G.lipPoint = (t, s = 1, inset = 0.9, dy = 0) => {
85
- const u = M.uF + (M.uC - M.uF) * Math.pow(t, 0.75);
86
- const y = G.lipY(u) + dy;
87
- const x = G.surfX(u, y) * inset;
88
- return [s * x, y, G.z(u)];
89
- };
90
- const E = H.eye;
91
- G.eye = { u: E.u, y: G.yc(E.u) + E.e * G.hd(E.u), r: E.r * TL, z: G.z(E.u) };
92
- // (the smooth unions of the sculpt's sections stand ~0.0033 TL proud of the outline: the eye sits at
93
- // the real skin)
94
- G.skinOut = 0.0033 * TL;
95
- G.eye.x = G.surfX(E.u, G.eye.y) + G.skinOut - 0.3 * G.eye.r;
96
- G.headO = [0, G.eye.y, G.eye.z];
97
- // caudal lobes (2D in the median plane: b = backward from the precaudal pit, h = up from the axis)
98
- const C = V.fins.caudal;
99
- const ua = C.upAng * D2R, la = C.lowAng * D2R;
100
- G.caudal = {
101
- up: C.up * G.tailK, low: C.low * G.tailK * (params.lowLobeK || 1), ua, la,
102
- pit: [0, G.yc(G.pc), G.z(G.pc)],
103
- tipUp: [Math.cos(ua) * C.up * G.tailK, Math.sin(ua) * C.up * G.tailK],
104
- };
105
- return G;
106
- }
107
-
108
- // the pectoral's direction from sweep-back (abduct = angle from straight back toward lateral) and droop
109
- export function pecDir(abduct, droop) {
110
- const ab = abduct * D2R, dr = droop * D2R;
111
- return norm([Math.sin(ab) * Math.cos(dr), -Math.sin(dr), -Math.cos(ab) * Math.cos(dr)]);
112
- }
113
-
114
- // a fin frame: s = span direction, c = chord direction (forward, orthogonal to s), n = normal
115
- export function finFrame(s) {
116
- const f = [0, 0, 1];
117
- const c = norm(sub(f, mul(s, dot(f, s))));
118
- return { s, c, n: norm(cross(s, c)) };
119
- }
120
-
121
- export function sharkJoints(params) {
122
- const G = sharkGeo(params);
123
- const V = G.V, TL = G.TL, H = V.head, F = V.fins;
124
- const N = V.spineSegs, M = V.caudalSegs;
125
- const J = {};
126
- J.snout = [0, G.yc(0) + H.snoutY * TL, G.z0];
127
- for (let i = 0; i <= N; i++) {
128
- const u = H.occ + ((G.pc - H.occ) * i) / N;
129
- J[spineName(i)] = [0, G.yc(u), G.z(u)];
130
- }
131
- swimmerJointsAlias(J, N);
132
- // the vertebral column runs up into the upper caudal lobe (heterocercal)
133
- // the rise is spread over the last joints (a smooth upward curve, no kink at the pit): the last
134
- // trunk segment pitches up ~0.17 x the lobe angle, then the caudal segments 0.54 / 0.89 / 1.2 x
135
- const ua = G.caudal.ua;
136
- const segL = ((G.pc - H.occ) / N) * TL;
137
- J[spineName(N)][1] += Math.sin(0.17 * ua) * segL;
138
- swimmerJointsAlias(J, N);
139
- const cl = G.caudal.up * 0.92 * TL;
140
- let q = J[spineName(N)].slice();
141
- const fac = M === 3 ? [0.54, 0.89, 1.2] : Array.from({ length: M }, (_, j) => 0.5 + (0.7 * j) / Math.max(1, M - 1));
142
- for (let j = 1; j <= M; j++) {
143
- const a = fac[j - 1] * ua, l = cl / M;
144
- q = [0, q[1] + Math.sin(a) * l, q[2] - Math.cos(a) * l];
145
- J['caudal' + j] = q;
146
- }
147
- // lower jaw: hinge at the mouth corner, tip at the symphysis
148
- const Mo = H.mouth;
149
- J.jawHinge = [0, G.yC - Mo.jawDepth * 0.35 * TL, G.z(Mo.uC + 0.012)];
150
- J.jawTip = [0, G.yF - 0.004 * TL, G.z(Mo.uF + 0.004)];
151
- // upper jaw (palatoquadrate): protrudes forward and down on the bite
152
- J.premaxBase = [0, G.yC + 0.035 * TL, G.z(Mo.uC + 0.01)];
153
- J.premaxTip = [0, G.yF + 0.012 * TL, G.z(Mo.uF + 0.006)];
154
- // pectoral fin: base low on the flank behind the gill slits
155
- const P = F.pectoral;
156
- const pb = G.flank(P.u, P.e);
157
- pb[0] -= 0.004 * TL;
158
- const pd = pecDir(P.abduct, P.droop);
159
- J.pecBaseL = pb;
160
- J.pecUpL = add(pb, [0, 0.002 * TL, 0.03 * TL]);
161
- J.pecTipL = add(pb, mul(pd, P.len * G.finK * G.pecK * TL));
162
- // pelvic fin: on the belly
163
- const Q = F.pelvic;
164
- const yb = G.bot(Q.u);
165
- const px = G.hw(Q.u) * 0.42;
166
- const pl = [px, G.belly(Q.u, 0.42) + 0.004 * TL, G.z(Q.u)];
167
- const qd = norm([Math.sin(Q.abduct * D2R) * 0.9, -0.5, -1.0]);
168
- J.pelBaseL = pl;
169
- J.pelFrontL = add(pl, [0.002 * TL, 0, 0.02 * TL]);
170
- J.pelTipL = add(pl, mul(qd, Q.len * G.finK * TL));
171
- void yb;
172
- return { J, G };
173
- }
174
-
175
- export function pickParent(G, u) {
176
- const V = G.V, N = V.spineSegs, occ = V.head.occ;
177
- const i = Math.max(0, Math.min(N - 1, Math.floor(((u - occ) / (G.pc - occ)) * N)));
178
- return spineName(i);
179
- }
180
-
181
- export function sharkRig(params) {
182
- const { J, G } = sharkJoints(params);
183
- const V = G.V, N = V.spineSegs, M = V.caudalSegs;
184
- return buildRig({
185
- joints: J,
186
- unit: G.TL / 1.3,
187
- headOrigin: G.headO,
188
- bones: swimmerBones({ spineSegs: N, caudalSegs: M, jaw: true, upperJaw: true, opercula: false, pectoralParent: pickParent(G, V.fins.pectoral.u), pelvicParent: pickParent(G, V.fins.pelvic.u) }),
189
- axial: { points: axialJoints(N, M), bones: axialBones(N, M) },
190
- limbs: {},
191
- appendages: swimmerAppendages({ upperJaw: true, opercula: false, blend: [-0.003, 0.004] }),
192
- meta: { variant: params.variant, TL: G.TL },
193
- });
194
- }
@@ -1,343 +0,0 @@
1
- // Shark sculpt: a dense chain of elliptic sections along the outline table (conical snout, spindle
2
- // trunk, caudal keel), fleshy fins as tapered slabs (a thin full outline + thicker inner cores, so the
3
- // fin is an airfoil that thins toward its trailing edge), a separately meshed lower jaw cut from the
4
- // same sections with two complementary profile prisms (the lip line matches exactly), an upper-jaw
5
- // (gum) pad that protrudes on the bite, rows of triangular teeth meshed as their own rigid parts,
6
- // gill slits, nostrils and small lidless eyes in shallow sockets, claspers on males.
7
- import { sharkGeo, pickParent, pecDir, finFrame } from './rig.js';
8
- import { add, sub, mul, norm, cross, dot, lerp } from '../../core/math/vec.js';
9
-
10
- // hero cell size relative to TL (regions.js)
11
- export const CELL = 1 / 415;
12
- // fin outlines squeezed to knife edges below the cell size (core build/finEdges.js): the meshed rim
13
- // (~2 cells thick, rounded) scaled to 0.15 of its thickness at the outline, easing back over 3 cells,
14
- // the round cap beyond the outline drawn in to 0.4 of its width
15
- const SHARP = { edge: 0.15, band: 3, rim: 0.4 };
16
-
17
- export function sculptShark(m, rig, params) {
18
- const G = sharkGeo(params);
19
- const V = G.V, TL = G.TL, J = rig.J, H = V.head, F = V.fins;
20
- const boneAt = (u) => (u < H.occ ? 'head' : pickParent(G, u));
21
- const cell = TL * CELL * (V.cellK || 1);
22
-
23
- // ---------------------------------------------------------------- body sections
24
- // Two ellipsoids per station (the teardrop cross-section of rig.js: a narrower upper ellipse and a
25
- // wide, flat lower one), long along the body and closely spaced, so the union has no scallops between
26
- // stations (they showed as rings in the highlights).
27
- // (short ellipsoids in the head, where the outline curves fast: long ones would stand proud of the
28
- // outline there, burying the eyes and swelling the snout)
29
- // (the spacing follows the length, so the number of overlapping sections, and with it the bulge of the
30
- // smooth unions over the outline, changes smoothly along the body: no step where the spacing changes)
31
- const rzAt = (u) => Math.min(0.045, u * 0.9 + 0.003, 0.012 + 0.033 * Math.max(0, Math.min(1, (u - 0.12) / 0.16)));
32
- const stepAt = (u) => Math.max(0.003, Math.min(0.0075, rzAt(u) / 4.5));
33
- const station = (u, part = 'body', extra = {}) => {
34
- const rz = rzAt(u) * TL;
35
- const hd = G.hd(u), hw = G.hw(u), yc = G.yc(u), tag = u < 0.24 ? 'head' : 'body';
36
- m.ell({ tag, bone: boneAt(u), c: [0, yc, G.z(u)], r: [hw * G.wk(u), hd, rz], k: 0.006 * TL, part, ...extra });
37
- return m.ell({ tag, bone: boneAt(u), c: [0, yc - G.LOW.dy * hd, G.z(u)], r: [hw, G.LOW.ry * hd, rz], k: 0.006 * TL, part, ...extra });
38
- };
39
- for (let u = 0.004; u <= G.pc + 0.0001; u += stepAt(u)) station(Math.min(u, G.pc));
40
- // the peduncle runs on into the caudal fin base
41
- {
42
- const u = G.pc + 0.02;
43
- m.ell({ tag: 'body', bone: 'caudal0', c: [0, G.yc(G.pc) + 0.004 * TL, G.z(u)], r: [G.hw(G.pc) * 0.75, G.hd(G.pc) * 0.95, 0.03 * TL], k: 0.006 * TL });
44
- }
45
- // caudal keel (white shark): a lateral ridge along the peduncle
46
- if (F.caudal.keel > 0) {
47
- for (let u = 0.69; u <= G.pc + 0.025; u += 0.012) {
48
- const f = Math.sin(Math.PI * Math.min(1, (u - 0.69) / (G.pc + 0.03 - 0.69)));
49
- m.ell({ tag: 'keel', bone: boneAt(Math.min(u, G.pc - 0.001)), c: [0, G.yc(Math.min(u, G.pc)), G.z(u)], r: [Math.min(G.hw(Math.min(u, G.pc)), G.hw(G.pc)) + F.caudal.keel * TL * f, G.hd(Math.min(u, G.pc)) * 0.22, 0.02 * TL], k: 0.008 * TL });
50
- }
51
- }
52
-
53
- // ---------------------------------------------------------------- head features
54
- const E = G.eye;
55
- // a slight swelling around the small eye
56
- for (const s of [1, -1]) m.sphere({ tag: 'orbit', bone: 'head', c: [s * (E.x - 0.6 * E.r), E.y, E.z], rad: E.r * 1.5, k: E.r * 1.2 });
57
- // upper jaw pad (gums behind the upper lip): protrudes forward / down with the upperJaw bone
58
- for (const s of [1, -1]) {
59
- for (let i = 0; i <= 4; i++) {
60
- const t = i / 4;
61
- const p = G.lipPoint(t * 0.92, s, 0.6, 0.016 * TL);
62
- m.sphere({ tag: 'gumU', bone: 'upperJaw', group: 'upperJaw', c: p, rad: 0.014 * TL * (1 - 0.3 * t), k: 0.009 * TL });
63
- }
64
- }
65
-
66
- // ---------------------------------------------------------------- median fins
67
- const dorsalBase = (u) => G.top(u) - 0.004 * TL;
68
- const medianFin = (d, name, sign, bone, k = 1) => {
69
- // poly in TL units: (du back from the origin, dv up (sign +1) / down (sign -1) from the outline)
70
- const u0 = d.u;
71
- const y0 = sign > 0 ? dorsalBase(u0) : G.bot(u0) + 0.004 * TL;
72
- const origin = [0, y0, G.z(u0)];
73
- const poly = d.poly.map(([a, b]) => [a * TL, b * TL * k]);
74
- // follow the body outline under the base: sink the base points by the local outline change
75
- for (const p of poly) {
76
- const uu = u0 + p[0] / TL;
77
- const yy = sign > 0 ? dorsalBase(Math.min(uu, G.pc)) : G.bot(Math.min(uu, G.pc)) + 0.004 * TL;
78
- p[1] = p[1] + (yy - y0);
79
- }
80
- const root = [poly[1][0] + 0.25 * (poly[poly.length - 2][0] - poly[1][0]), poly[1][1]];
81
- taperFin(m, { sharpen: SHARP, origin, u: [0, 0, -1], v: [0, 1, 0], poly, root, tRoot: d.thick * TL, tEdge: Math.max(2.1 * cell, d.thick * TL * 0.28), bone, tag: 'fin', name, k: d.thick * TL * 0.9 });
82
- };
83
- medianFin(F.dorsal1, 'dorsal1', 1, boneAt(F.dorsal1.u + 0.04), G.dorsalK);
84
- medianFin(F.dorsal2, 'dorsal2', 1, boneAt(F.dorsal2.u));
85
- medianFin(F.anal, 'anal', -1, boneAt(F.anal.u));
86
-
87
- // caudal fin: upper lobe along the caudal chain, lunate / heterocercal trailing edge, lower lobe
88
- {
89
- const C = F.caudal, Cg = G.caudal;
90
- const pit = Cg.pit;
91
- const hdp = G.hd(G.pc);
92
- const P2 = (b, h) => [b * TL, h * TL]; // (backward, up) in TL
93
- const ua = Cg.ua, la = Cg.la;
94
- const up = Cg.up, low = Cg.low;
95
- const pts = [];
96
- // root, upper leading edge (slightly convex), tip
97
- pts.push(P2(-0.035, hdp / TL * 0.6));
98
- const nU = 7;
99
- for (let i = 0; i <= nU; i++) {
100
- const f = i / nU;
101
- const l = up * f;
102
- const bow = 0.012 * Math.sin(Math.PI * f) * (1 - f * 0.3);
103
- pts.push(P2(Math.cos(ua) * l - Math.sin(ua) * bow + 0.0 * f, hdp / TL * 0.85 * (1 - f) + Math.sin(ua) * l + Math.cos(ua) * bow));
104
- }
105
- const tipU = [Math.cos(ua) * up, Math.sin(ua) * up];
106
- // trailing edge of the upper lobe: from the tip down to the fork (concave), with the terminal
107
- // lobe notch of carcharhinids just below the tip
108
- const fork = [C.fork * G.tailK + 0.02, -0.004];
109
- const tipL = [Math.cos(la) * low, Math.sin(la) * low];
110
- const edge = (a, b, n, sag, fromTip = 0) => {
111
- for (let i = 1; i <= n; i++) {
112
- const f = i / n;
113
- const x = a[0] + (b[0] - a[0]) * f, y = a[1] + (b[1] - a[1]) * f;
114
- // sag toward the front (lunate concave trailing edge)
115
- const s = sag * Math.sin(Math.PI * f);
116
- let notch = 0;
117
- if (fromTip && C.notch > 0) notch = -C.notch * Math.exp(-Math.pow((f - 0.14) / 0.06, 2));
118
- pts.push(P2(x - s + notch, y));
119
- }
120
- };
121
- edge(tipU, fork, 9, 0.028 * G.tailK, 1);
122
- edge(fork, tipL, 6, 0.018 * G.tailK);
123
- // lower lobe leading edge back to the peduncle underside
124
- const nL = 5;
125
- for (let i = 1; i <= nL; i++) {
126
- const f = 1 - i / nL;
127
- const l = low * f;
128
- const bow = 0.01 * Math.sin(Math.PI * f);
129
- pts.push(P2(Math.cos(la) * l + Math.sin(-la) * bow * 0, -hdp / TL * 0.85 * (1 - f) + Math.sin(la) * l - Math.cos(la) * bow));
130
- }
131
- pts.push(P2(-0.035, -hdp / TL * 0.6));
132
- const origin = pit.slice();
133
- const root = [0.01 * TL, 0.02 * TL];
134
- taperFin(m, { sharpen: SHARP, origin, u: [0, 0, -1], v: [0, 1, 0], poly: pts, root, tRoot: C.thick * TL, tEdge: Math.max(2.1 * cell, C.thick * TL * 0.3), bone: 'caudal0', tag: 'fin', name: 'caudal', k: C.thick * TL, rootAlong: [Math.cos(ua), Math.sin(ua)], rootLen: up * TL * 0.85 });
135
- }
136
-
137
- // ---------------------------------------------------------------- paired fins (appendages)
138
- for (const S of ['L', 'R']) {
139
- const s = S === 'L' ? 1 : -1;
140
- const mir = (v) => [v[0] * s, v[1], v[2]];
141
- // pectoral: a thick, stiff hydrofoil
142
- {
143
- const P = F.pectoral;
144
- const b = J['pecBase' + S];
145
- const sp = mir(pecDir(P.abduct, P.droop));
146
- const fr = finFrame(sp);
147
- const span = P.len * G.finK * G.pecK * TL;
148
- const poly = P.poly.map(([a, c]) => [a * span, c * TL * G.finK]);
149
- taperFin(m, { sharpen: SHARP, origin: b, u: fr.s, v: fr.c, poly, root: [0.02 * span, 0.03 * TL], tRoot: P.thick * TL, tEdge: Math.max(2.1 * cell, P.thick * TL * 0.2), bone: 'pectoral' + S, group: 'pectoral' + S, tag: 'fin', name: 'pectoral' + S, k: P.thick * TL * 0.8, rootAlong: [1, 0.12], rootLen: span * 0.8 });
150
- // fleshy base blending into the flank
151
- m.ell({ tag: 'pecBase', bone: 'pectoral' + S, group: 'pectoral' + S, c: add(b, mul(fr.s, 0.02 * TL)), axis: fr.c, up: fr.n, r: [0.035 * TL, 0.0085 * TL, 0.045 * TL], k: 0.01 * TL });
152
- }
153
- // pelvic
154
- {
155
- const Q = F.pelvic;
156
- const b = J['pelBase' + S], tip = J['pelTip' + S];
157
- const sp = norm(sub(tip, b));
158
- const fr = finFrame(sp);
159
- const span = Q.len * G.finK * TL;
160
- const poly = Q.poly.map(([a, c]) => [a * span, c * TL]);
161
- taperFin(m, { sharpen: SHARP, origin: b, u: fr.s, v: fr.c, poly, root: [0.05 * span, 0.01 * TL], tRoot: Q.thick * TL, tEdge: Math.max(2.1 * cell, Q.thick * TL * 0.3), bone: 'pelvic' + S, group: 'pelvic' + S, tag: 'fin', name: 'pelvic' + S, k: Q.thick * TL * 0.8 });
162
- // claspers (males): calcified rods along the inner edge of the pelvic fins
163
- if (params.sex === 'male') {
164
- const cl = F.clasper * TL * (params.age === 'juvenile' ? 0.35 : 1);
165
- const a = add(b, [-s * 0.01 * TL, -0.004 * TL, -0.012 * TL]);
166
- const d = norm([s * 0.05, -0.18, -1]);
167
- m.cone({ tag: 'clasper', bone: 'pelvic' + S, group: 'pelvic' + S, a, b: add(a, mul(d, cl)), ra: 0.0065 * TL, rb: 0.0035 * TL, k: 0.004 * TL });
168
- }
169
- }
170
- }
171
-
172
- // ---------------------------------------------------------------- carvers (after every union)
173
- const Mo = H.mouth;
174
- const zS = G.z0 + 0.03 * TL, yLow = G.bot(Mo.uF) - 0.06 * TL;
175
- const lipPts = [];
176
- for (let i = 0; i <= 8; i++) {
177
- const t = i / 8;
178
- const u = Mo.uF + (Mo.uC - Mo.uF) * t;
179
- lipPts.push([G.z(u), G.lipY(u)]);
180
- }
181
- const zc = G.z(Mo.uC), zh = G.z(Mo.uC + 0.022), zb = G.z(Mo.uC + 0.06);
182
- const jd = Mo.jawDepth * TL;
183
- // lower-jaw region in the median plane (z, y): below the lip line, behind the front of the gape
184
- const zF = G.z(Mo.uF);
185
- const jawPoly = [[zF + 0.006 * TL, G.yF - 0.02 * TL], ...lipPts, [zh, G.yC - jd * 0.5], [zb, yLow], [zF + 0.006 * TL, yLow]];
186
- const gap = 0.0012 * TL;
187
- const wide = 0.6 * TL;
188
- const prism = (poly, o) => m.fin({ o: [0, 0, 0], u: [0, 0, 1], v: [0, 1, 0], t: wide, poly, round: 0, ...o });
189
- prism(offsetPoly(jawPoly, gap * 0.5), { tag: 'mouthcut', bone: 'head', carve: true, k: 0.002 * TL });
190
- // mouth cavity behind the lips (seen when the jaws open)
191
- const cavU = Mo.uF + (Mo.uC - Mo.uF) * 0.55;
192
- const mouthCav = (o) => m.ell({ tag: 'mouth', bone: 'head', c: [0, G.lipY(cavU) + 0.004 * TL, G.z(cavU)], r: [G.hw(cavU) * 0.68, 0.014 * TL, (Mo.uC - Mo.uF) * 0.62 * TL], k: 0.003 * TL, carve: true, ...o });
193
- mouthCav({});
194
- // eye sockets
195
- for (const s of [1, -1]) m.sphere({ tag: 'eyesocket', bone: 'head', c: [s * E.x, E.y, E.z], rad: E.r * 1.05, k: E.r * 0.25, carve: true });
196
- // nostrils: oblique slits on the underside of the snout
197
- {
198
- const Nn = H.nostril;
199
- for (const s of [1, -1]) {
200
- const p = G.flank(Nn.u, Nn.e, s);
201
- m.ell({ tag: 'nostril', bone: 'head', c: p, axis: norm([s * 0.5, 0, 1]), up: [0, 1, 0], r: [0.002 * TL, 0.0018 * TL, 0.008 * TL], k: 0.002 * TL, carve: true });
202
- }
203
- }
204
- // gill slits: shallow grooves (the coat paints them dark)
205
- {
206
- const Gi = H.gills;
207
- for (const s of [1, -1]) {
208
- for (let i = 0; i < Gi.n; i++) {
209
- const u = Gi.u0 + ((Gi.u1 - Gi.u0) * i) / (Gi.n - 1);
210
- const len = 1 - 0.18 * Math.abs(i - (Gi.n - 1) * 0.6) / Gi.n;
211
- for (let j = 0; j <= 8; j++) {
212
- const e = Gi.e0 + ((Gi.e1 - Gi.e0) * len * j) / 8;
213
- const uu = u - Gi.lean * (e - Gi.e0);
214
- const p = G.flank(uu, e, s);
215
- const nx = norm([s * 1, e * 0.5, 0]);
216
- if (!params.gillGrooves) continue;
217
- m.ell({ tag: 'gillslit', bone: 'head', c: sub(p, mul(nx, 0.0016 * TL)), axis: [0, 0, 1], up: norm(cross([0, 0, 1], nx)), r: [0.0026 * TL, ((Gi.e1 - Gi.e0) / 8) * G.hd(uu) * 1.6, 0.0011 * TL], k: 0.002 * TL, carve: true });
218
- }
219
- }
220
- }
221
- }
222
-
223
- // ---------------------------------------------------------------- fin nicks (adults)
224
- // old bite and abrasion nicks in the trailing edge of the first dorsal (and the upper caudal lobe):
225
- // small seeded bites carved out of the edge
226
- for (const nk of params.nicks || []) {
227
- if (nk.fin === 'dorsal1') {
228
- // trailing edge of the first dorsal: from the apex down to the free rear tip
229
- const d = F.dorsal1, poly = d.poly, i0 = 5, i1 = poly.length - 2;
230
- const f = (i1 - i0) * nk.t, i = Math.min(i1 - 1, i0 + Math.floor(f)), fr = f - Math.floor(f);
231
- const a = poly[i][0] + (poly[i + 1][0] - poly[i][0]) * fr, b = (poly[i][1] + (poly[i + 1][1] - poly[i][1]) * fr) * G.dorsalK;
232
- const uu = d.u + a, y = dorsalBase(Math.min(uu, G.pc)) + b * TL;
233
- m.sphere({ tag: 'nick', bone: boneAt(d.u + 0.04), c: [0, y, G.z(uu) - nk.r * 0.35 * TL], rad: nk.r * TL, k: 0.0015 * TL, carve: true });
234
- } else {
235
- // upper caudal lobe trailing edge, behind the leading edge toward the tip
236
- const Cg = G.caudal, l = Cg.up * (0.55 + 0.35 * nk.t);
237
- const p = [0, Cg.pit[1] + Math.sin(Cg.ua) * l * TL, Cg.pit[2] - Math.cos(Cg.ua) * l * TL - 0.012 * TL];
238
- m.sphere({ tag: 'nick', bone: 'caudal' + V.caudalSegs, c: p, rad: nk.r * TL, k: 0.0015 * TL, carve: true });
239
- }
240
- }
241
-
242
- // ---------------------------------------------------------------- lower jaw (own surface, rigid)
243
- const JW = { bone: 'jaw', group: 'jaw', part: 'jaw' };
244
- for (let u = 0.004; u <= Mo.uC + 0.075; u += stepAt(u)) station(u, 'jaw', { ...JW, tag: 'jaw' });
245
- const big = TL;
246
- const rest = [[zF + 0.006 * TL, G.yF - 0.02 * TL], [zS, G.yF - 0.02 * TL], [zS, G.yF + big], [zb - big, G.yF + big], [zb - big, yLow], [zb, yLow], [zh, G.yC - jd * 0.5], ...lipPts.slice().reverse()];
247
- prism(offsetPoly(rest, gap * 0.5), { ...JW, tag: 'jawcut', carve: true, k: 0.002 * TL });
248
- mouthCav({ ...JW });
249
-
250
- // ---------------------------------------------------------------- teeth (rigid parts)
251
- sculptTeeth(m, G, params);
252
- void lerp;
253
- return m;
254
- }
255
-
256
- // Rows of serrated triangular teeth: the upper row hangs from the upper jaw (part 'uteeth', rides
257
- // the protruding upperJaw bone), the lower row stands on the lower jaw (part 'lteeth').
258
- export function sculptTeeth(m, G, params) {
259
- const TL = G.TL, V = G.V;
260
- const white = params.variant === 'white';
261
- const nT = white ? 12 : 13;
262
- const h0 = (white ? 0.0105 : 0.0075) * TL * (params.age === 'juvenile' ? 0.8 : 1);
263
- for (const [part, bone, dir] of [['uteeth', 'upperJaw', -1], ['lteeth', 'jaw', 1]]) {
264
- for (const s of [1, -1]) {
265
- for (let i = 0; i < nT; i++) {
266
- const t = (i + 0.5) / nT;
267
- const upper = dir < 0;
268
- const p = G.lipPoint(t * 0.94, s, upper ? 0.86 : 0.8, upper ? 0.003 * TL : -0.004 * TL);
269
- const pn = G.lipPoint(Math.min(1, t * 0.94 + 0.02), s, upper ? 0.86 : 0.8);
270
- const tang = norm(sub(pn, p));
271
- // front teeth largest; white upper teeth broad triangles, lower narrower and pointed
272
- const h = h0 * (1 - 0.55 * t * t) * (upper ? 1 : 0.9);
273
- const w = h * (white ? (upper ? 0.85 : 0.6) : (upper ? 0.55 : 0.45));
274
- const axis = norm([0, dir, -0.12 - 0.25 * t * (upper ? 1 : -0.3)]);
275
- // tooth plane: tangent to the jaw arc; blade leans slightly inward (toward the midline)
276
- const inward = norm([-s * 0.25, 0, 0]);
277
- const v = norm(add(axis, mul(inward, 0.2)));
278
- const u = norm(sub(tang, mul(v, dot(tang, v))));
279
- const base = sub(p, mul(v, h * 0.35));
280
- const poly = [[-w * 0.5, 0], [-w * 0.42, h * 0.35], [-w * 0.12, h * 0.85], [0.02 * w, h], [w * 0.16, h * 0.84], [w * 0.44, h * 0.35], [w * 0.5, 0]];
281
- const th = Math.max(w * 0.34, 0.0022 * TL);
282
- const pr = m.fin({ o: base, u, v, t: th, poly, round: th * 0.45, bone, part, tag: 'tooth', k: 0.0006 * TL });
283
- pr.thin = false;
284
- }
285
- }
286
- }
287
- }
288
-
289
- // Tapered fleshy fin: a thin slab with the full outline plus thicker slabs of the outline shrunk
290
- // toward `root` (optionally stretched along `rootAlong` so the leading edge / the caudal lobe's
291
- // vertebral column stays thick), smoothly united: an airfoil thinning toward the trailing edge.
292
- export function taperFin(m, o) {
293
- const { origin, u, v, poly, root, tRoot, tEdge, bone, group, tag, name, k } = o;
294
- // (most of the fin is close to the edge thickness: a thin blade with a thick root and leading edge,
295
- // not a uniformly fat paddle)
296
- // (three cores in big steps left grooves along the span, a rubbery look: six cores in
297
- // small steps give a smooth airfoil)
298
- const layers = [[1, tEdge]];
299
- for (let i = 1; i <= 6; i++) {
300
- const f = i / 6;
301
- layers.push([1 - 0.72 * f, tEdge + (tRoot - tEdge) * Math.pow(f, 1.2)]);
302
- }
303
- let first = null;
304
- for (const [sc, t] of layers) {
305
- const pts = poly.map(([a, b]) => {
306
- let da = a - root[0], db = b - root[1];
307
- if (o.rootAlong) {
308
- // shrink across the root line more than along it
309
- const ax = o.rootAlong, al = Math.hypot(ax[0], ax[1]);
310
- const ex = ax[0] / al, ey = ax[1] / al;
311
- const along = da * ex + db * ey, across = -da * ey + db * ex;
312
- const al2 = along * (sc + (1 - sc) * 0.55), ac2 = across * sc;
313
- da = al2 * ex - ac2 * ey; db = al2 * ey + ac2 * ex;
314
- return [root[0] + da, root[1] + db];
315
- }
316
- return [root[0] + da * sc, root[1] + db * sc];
317
- });
318
- const pr = m.fin({ o: origin, u, v, t, poly: pts, round: t * 0.5, bone, group, ...(o.part ? { part: o.part } : {}), tag: sc === 1 ? tag : 'finCore', k: sc === 1 ? k : t * 1.2 });
319
- pr.thin = sc === 1;
320
- // the outline slab's meshed rim squeezed to a knife edge (core build/finEdges.js): 0.15 of the
321
- // meshed thickness at the outline, full over ~3 cells inward
322
- if (sc === 1 && o.sharpen) pr.sharpen = o.sharpen;
323
- pr.finName = name;
324
- pr.fin2 = { origin: origin.slice(), u: norm(u), v: norm(sub(v, mul(norm(u), dot(v, norm(u))))), poly: poly.map((p) => p.slice()) };
325
- if (!first) first = pr;
326
- }
327
- return first;
328
- }
329
-
330
- // grows / shrinks a polygon outward by d (approximate: along the averaged edge normals)
331
- function offsetPoly(poly, d) {
332
- const n = poly.length;
333
- let area = 0;
334
- for (let i = 0; i < n; i++) { const a = poly[i], b = poly[(i + 1) % n]; area += a[0] * b[1] - b[0] * a[1]; }
335
- const sgn = area > 0 ? 1 : -1;
336
- return poly.map((p, i) => {
337
- const a = poly[(i + n - 1) % n], b = poly[(i + 1) % n];
338
- const e1 = norm([p[0] - a[0], p[1] - a[1], 0]), e2 = norm([b[0] - p[0], b[1] - p[1], 0]);
339
- const n1 = [e1[1] * sgn, -e1[0] * sgn], n2 = [e2[1] * sgn, -e2[0] * sgn];
340
- const nn = norm([n1[0] + n2[0], n1[1] + n2[1], 0]);
341
- return [p[0] + nn[0] * d, p[1] + nn[1] * d];
342
- });
343
- }
@@ -1,105 +0,0 @@
1
- // Shark variants: the great white (default) and the blacktip reef shark in one species module
2
- // (createAnimal('shark', { variant: 'blacktip' })).
3
- //
4
- // Every length is a fraction of the total length TL (snout tip -> tip of the upper caudal lobe,
5
- // measured along the body axis). `prof` rows are [u (fraction of TL from the snout), top (dorsal
6
- // outline above the axis), bot (ventral outline below the axis), hw (half width)]. Fin outlines are
7
- // 2D polygons in TL units (see sculpt.js for each fin's frame). Colours are sRGB hex sampled from the
8
- // reference photos.
9
-
10
- export const VARIANT_KEYS = ['white', 'blacktip'];
11
-
12
- export const VARIANTS = {
13
- // Great white shark (Carcharodon carcharias), adult female: spindle-shaped, conical snout, near
14
- // symmetric lunate tail with a caudal keel, tiny second dorsal and anal fins.
15
- white: {
16
- name: 'Great white shark', latin: 'Carcharodon carcharias',
17
- TL: 4.5, cellK: 1.0,
18
- prof: [
19
- [0.004, 0.004, 0.003, 0.005], [0.02, 0.019, 0.013, 0.02], [0.045, 0.034, 0.028, 0.04], [0.08, 0.048, 0.043, 0.059],
20
- [0.13, 0.062, 0.057, 0.074], [0.19, 0.075, 0.07, 0.081], [0.26, 0.085, 0.08, 0.084], [0.33, 0.091, 0.083, 0.085],
21
- [0.4, 0.09, 0.08, 0.082], [0.47, 0.083, 0.071, 0.074], [0.55, 0.07, 0.057, 0.062], [0.63, 0.053, 0.042, 0.047],
22
- [0.7, 0.039, 0.031, 0.036], [0.75, 0.029, 0.023, 0.03], [0.8, 0.022, 0.019, 0.027],
23
- ],
24
- // head landmarks: occ = spine0 (the rigid head ends behind the gill slits), eye (u, e = height
25
- // as a fraction of the half depth, r = radius / TL), mouth: front of the gape on the underside
26
- // (uF), corner (uC, eC), lower-jaw depth, nostril
27
- head: {
28
- occ: 0.21, eye: { u: 0.066, e: 0.3, r: 0.0058 }, snoutY: 0.004,
29
- mouth: { uF: 0.047, uC: 0.1, eC: -0.42, jawDepth: 0.03, smile: 0.35 },
30
- gills: { u0: 0.185, u1: 0.258, n: 5, e0: -0.62, e1: 0.5, lean: 0.012 },
31
- nostril: { u: 0.028, e: -0.62 },
32
- },
33
- precaudal: 0.8,
34
- fins: {
35
- // first dorsal: points (du back from the origin, dv up from the back) in TL
36
- dorsal1: { u: 0.365, poly: [[0, -0.02], [0, 0], [0.018, 0.04], [0.035, 0.078], [0.049, 0.103], [0.058, 0.108], [0.063, 0.1], [0.064, 0.072], [0.072, 0.04], [0.088, 0.016], [0.108, 0.004], [0.1, -0.02]], thick: 0.014 },
37
- dorsal2: { u: 0.71, poly: [[0, -0.01], [0, 0], [0.006, 0.012], [0.012, 0.016], [0.016, 0.01], [0.026, 0.002], [0.024, -0.01]], thick: 0.006 },
38
- anal: { u: 0.725, poly: [[0, 0.01], [0, 0], [0.006, -0.012], [0.012, -0.016], [0.016, -0.01], [0.026, -0.002], [0.024, 0.01]], thick: 0.006 },
39
- // caudal: upper / lower lobe length and angle (deg from the axis), fork depth, keel
40
- caudal: { up: 0.245, upAng: 40, low: 0.185, lowAng: -46, fork: 0.085, notch: 0, chord: 0.05, keel: 0.012, thick: 0.0105 },
41
- // pectoral: base (u, e on the flank), span (anterior margin) / TL, sweep back / droop / abduct
42
- // (deg), outline in (s along the span 0..1, c chordwise in TL, + = leading edge)
43
- pectoral: {
44
- u: 0.262, e: -0.55, len: 0.19, sweep: 42, droop: 26, abduct: 50, thick: 0.0095,
45
- poly: [[-0.02, 0.05], [0.25, 0.042], [0.55, 0.026], [0.8, 0.004], [0.93, -0.014], [1.0, -0.03], [0.985, -0.034], [0.9, -0.033], [0.8, -0.031], [0.55, -0.034], [0.3, -0.042], [0.12, -0.05], [0.02, -0.058], [-0.02, -0.05]],
46
- },
47
- pelvic: { u: 0.6, len: 0.07, abduct: 26, thick: 0.008, poly: [[-0.05, 0.035], [0.4, 0.028], [0.8, 0.01], [1.0, -0.006], [0.9, -0.018], [0.4, -0.02], [-0.05, -0.024]] },
48
- clasper: 0.075,
49
- },
50
- spineSegs: 12, caudalSegs: 3,
51
- denticle: 0.0012, gloss: 0.26,
52
- colour: {
53
- back: 0x757b7f, flank: 0x8e9497, belly: 0xf0efea, boundary: 0xa9aeb0, finTip: 0x19191b,
54
- finUnder: 0xdedcd6, gum: 0xa87a7a, mouth: 0x4a3436, tooth: 0xf1ece0, gill: 0x2a2224, scar: 0xb8bcbc,
55
- freckle: 0x3c4248,
56
- tones: [[0x757b7f, 0.45], [0x7e7a70, 0.35], [0x676e74, 0.2]],
57
- },
58
- eye: { iris: [0x07080a, 0x101820, 0x1a2430, 0x040506], sclera: 0xd6d6d0, pupil: [0.72, 0.82], lids: 'none' },
59
- boundary: { e: -0.12, rag: 0.12 },
60
- },
61
-
62
- // Blacktip reef shark (Carcharhinus melanopterus): slender, short broadly rounded snout, large
63
- // first dorsal over the pectoral free tips, heterocercal tail with a terminal lobe, black fin tips.
64
- blacktip: {
65
- name: 'Blacktip reef shark', latin: 'Carcharhinus melanopterus',
66
- TL: 1.3, cellK: 1.15,
67
- prof: [
68
- [0.004, 0.004, 0.003, 0.009], [0.02, 0.014, 0.011, 0.025], [0.045, 0.024, 0.021, 0.036], [0.08, 0.034, 0.031, 0.045],
69
- [0.13, 0.045, 0.042, 0.053], [0.19, 0.056, 0.052, 0.058], [0.26, 0.068, 0.064, 0.062], [0.33, 0.077, 0.07, 0.065],
70
- [0.4, 0.078, 0.069, 0.064], [0.47, 0.073, 0.062, 0.059], [0.55, 0.058, 0.048, 0.048], [0.63, 0.046, 0.037, 0.038],
71
- [0.7, 0.034, 0.027, 0.027], [0.75, 0.025, 0.02, 0.02], [0.78, 0.021, 0.018, 0.017],
72
- ],
73
- head: {
74
- occ: 0.2, eye: { u: 0.07, e: 0.28, r: 0.0078 }, snoutY: 0.002,
75
- mouth: { uF: 0.052, uC: 0.098, eC: -0.55, jawDepth: 0.026, smile: 0.15 },
76
- gills: { u0: 0.2, u1: 0.25, n: 5, e0: -0.45, e1: 0.25, lean: 0.006 },
77
- nostril: { u: 0.03, e: -0.6 },
78
- },
79
- precaudal: 0.785,
80
- fins: {
81
- dorsal1: { u: 0.39, poly: [[0, -0.02], [0, 0], [0.024, 0.042], [0.046, 0.08], [0.064, 0.11], [0.074, 0.118], [0.08, 0.11], [0.08, 0.078], [0.086, 0.044], [0.1, 0.02], [0.122, 0.006], [0.112, -0.02]], thick: 0.011 },
82
- dorsal2: { u: 0.72, poly: [[0, -0.01], [0, 0], [0.01, 0.024], [0.017, 0.034], [0.023, 0.03], [0.026, 0.012], [0.04, 0.004], [0.036, -0.01]], thick: 0.006 },
83
- anal: { u: 0.735, poly: [[0, 0.01], [0, 0], [0.01, -0.024], [0.017, -0.032], [0.023, -0.028], [0.026, -0.012], [0.04, -0.004], [0.036, 0.01]], thick: 0.006 },
84
- caudal: { up: 0.265, upAng: 29, low: 0.145, lowAng: -52, fork: 0.07, notch: 0.035, chord: 0.045, keel: 0, thick: 0.0075 },
85
- pectoral: {
86
- u: 0.28, e: -0.62, len: 0.175, sweep: 44, droop: 30, abduct: 52, thick: 0.0085,
87
- poly: [[-0.02, 0.045], [0.25, 0.04], [0.55, 0.027], [0.8, 0.007], [0.93, -0.01], [1.0, -0.026], [0.985, -0.031], [0.9, -0.03], [0.8, -0.029], [0.55, -0.03], [0.3, -0.036], [0.12, -0.042], [0.02, -0.05], [-0.02, -0.044]],
88
- },
89
- pelvic: { u: 0.6, len: 0.075, abduct: 28, thick: 0.0065, poly: [[-0.05, 0.035], [0.4, 0.028], [0.8, 0.01], [1.0, -0.008], [0.9, -0.02], [0.4, -0.022], [-0.05, -0.026]] },
90
- clasper: 0.085,
91
- },
92
- spineSegs: 12, caudalSegs: 3,
93
- denticle: 0.0006, gloss: 0.28,
94
- colour: {
95
- back: 0x817e77, flank: 0x9d9b95, belly: 0xf1f0ec, boundary: 0xc6c5c0, finTip: 0x111112,
96
- finUnder: 0xe4e3de, gum: 0xa88078, mouth: 0x4a3434, tooth: 0xf1ece0, gill: 0x3a3634, scar: 0xb4b3ae,
97
- paleBand: 0xd2d0ca, freckle: 0x6a6964, flankBand: 0x6e6d68,
98
- // grey with a faint bronze cast (#8a8476 rendered sandy tan / khaki
99
- // in the warm showcase light)
100
- tones: [[0x817e77, 0.5], [0x857f75, 0.3], [0x7b7c7a, 0.2]],
101
- },
102
- eye: { iris: [0x1c1f18, 0x6f7564, 0x8f9480, 0x2a2d24], sclera: 0x9a9a92, pupil: [0.35, 0.7], lids: 'bird' },
103
- boundary: { e: -0.3, rag: 0.03 },
104
- },
105
- };