@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.
- package/ASSET-PROVENANCE.md +43 -0
- package/ASSETS-LICENSE.md +58 -0
- package/ATTRIBUTION.md +54 -0
- package/EMBEDDING.md +96 -0
- package/INSTALLING.md +126 -0
- package/LICENSE +16 -0
- package/LICENSE-CODE +21 -0
- package/PLUGIN.md +110 -0
- package/PUPPY-MEMORY.md +57 -0
- package/PUPPY-Q5-COMPARISON.md +73 -0
- package/README.md +86 -2
- package/RELEASING.md +70 -0
- package/THIRD-PARTY-NOTICES.md +17 -0
- package/TRADEMARKS.md +21 -0
- package/WINDOWS-COMPANION.md +113 -0
- package/braille.mjs +45 -0
- package/examples/bridge.py +62 -0
- package/examples/embed.mjs +15 -0
- package/examples/live.mjs +40 -0
- package/examples/plugin.mjs +21 -0
- package/integrations/opencode/runtime.mjs +195 -0
- package/integrations/opencode/tui.tsx +59 -0
- package/integrations/windows-overlay/Overlay.cs +259 -0
- package/integrations/windows-overlay/desktop.mjs +87 -0
- package/integrations/windows-overlay/protocol.mjs +39 -0
- package/integrations/windows-overlay/worker.mjs +60 -0
- package/locomotion-core.mjs +21 -0
- package/locomotion-puppy.animal +0 -0
- package/package.json +131 -4
- package/pet-q5-manifest.json +118 -0
- package/puppy-clean.mjs +51 -0
- package/puppy-companion-interactions-v3-q5.bin.gz +0 -0
- package/puppy-companion-interactions-v3.json +1 -0
- package/puppy-companion-life.mjs +182 -0
- package/puppy-companion-objects.mjs +30 -0
- package/puppy-companion-sprites.mjs +14 -0
- package/puppy-continuous.mjs +57 -0
- package/puppy-face.mjs +46 -0
- package/puppy-frame-predictive.mjs +147 -0
- package/puppy-frame-store.mjs +108 -0
- package/puppy-mouth-anchor.json +1 -0
- package/puppy-mouth-anchor.mjs +33 -0
- package/puppy-paper-actions-v9-q5.bin.gz +0 -0
- package/puppy-paper-actions-v9.json +1 -0
- package/puppy-paper-actions.mjs +48 -0
- package/puppy-paper-approach-q5.bin.gz +0 -0
- package/puppy-paper-approach.json +1 -0
- package/puppy-paper-area.mjs +15 -0
- package/puppy-paper-arrival-seat-q5.bin.gz +0 -0
- package/puppy-paper-arrival-seat.json +1 -0
- package/puppy-paper-behaviors-q5.bin.gz +0 -0
- package/puppy-paper-behaviors.json +1 -0
- package/puppy-paper-behaviors.mjs +8 -0
- package/puppy-paper-contact.mjs +103 -0
- package/puppy-paper-director.mjs +21 -0
- package/puppy-paper-paw-transport.mjs +76 -0
- package/puppy-paper-rear-gallop-q5.bin.gz +0 -0
- package/puppy-paper-rear-gallop.json +1 -0
- package/puppy-paper-seat-q5.bin.gz +0 -0
- package/puppy-paper-seat.json +14 -0
- package/puppy-paper-seat.mjs +13 -0
- package/puppy-paper-trick-timing.mjs +58 -0
- package/puppy-paper-world.mjs +108 -0
- package/puppy-paper.mjs +271 -0
- package/puppy-stable-meta.json +1606 -0
- package/puppy-stable.mjs +72 -0
- package/puppy-stride-meta.json +343 -0
- package/puppy-stride-tweens-q5.bin.gz +0 -0
- package/puppy-zoomies.mjs +27 -0
- package/puppy-zoomies30.mjs +12 -0
- package/retrieviewer-cli.mjs +94 -0
- package/retrieviewer-config.mjs +49 -0
- package/retrieviewer-install.mjs +157 -0
- package/retrieviewer-plugin.d.mts +44 -0
- package/retrieviewer-plugin.mjs +97 -0
- package/retrieviewer-stdio.mjs +38 -0
- package/retrieviewer.d.mts +85 -0
- package/retrieviewer.mjs +142 -0
- package/vendor/procedural-animals/LICENSE +21 -0
- package/vendor/procedural-animals/package.json +40 -0
- package/vendor/procedural-animals/src/animal.js +146 -0
- package/vendor/procedural-animals/src/bake.js +51 -0
- package/vendor/procedural-animals/src/build.js +81 -0
- package/vendor/procedural-animals/src/core/build/coatKit.js +121 -0
- package/vendor/procedural-animals/src/core/build/featherCards.js +189 -0
- package/vendor/procedural-animals/src/core/build/finEdges.js +85 -0
- package/vendor/procedural-animals/src/core/build/furSlope.js +115 -0
- package/vendor/procedural-animals/src/core/build/mesh.js +67 -0
- package/vendor/procedural-animals/src/core/build/pipeline.js +272 -0
- package/vendor/procedural-animals/src/core/build/seams.js +183 -0
- package/vendor/procedural-animals/src/core/build/warp.js +112 -0
- package/vendor/procedural-animals/src/core/build/weights.js +393 -0
- package/vendor/procedural-animals/src/core/math/vec.js +81 -0
- package/vendor/procedural-animals/src/core/motion/actions.js +800 -0
- package/vendor/procedural-animals/src/core/motion/bird.js +3063 -0
- package/vendor/procedural-animals/src/core/motion/birdActions.js +1059 -0
- package/vendor/procedural-animals/src/core/motion/common.js +158 -0
- package/vendor/procedural-animals/src/core/motion/index.js +22 -0
- package/vendor/procedural-animals/src/core/motion/quadruped.js +2875 -0
- package/vendor/procedural-animals/src/core/motion/snake.js +1594 -0
- package/vendor/procedural-animals/src/core/motion/spider.js +1810 -0
- package/vendor/procedural-animals/src/core/motion/swimmer.js +1047 -0
- package/vendor/procedural-animals/src/core/motion/swimmerActions.js +613 -0
- package/vendor/procedural-animals/src/core/render/animalObject.js +262 -0
- package/vendor/procedural-animals/src/core/render/coatMaterial.js +1301 -0
- package/vendor/procedural-animals/src/core/render/dqs.js +159 -0
- package/vendor/procedural-animals/src/core/render/eyes.js +676 -0
- package/vendor/procedural-animals/src/core/render/membranes.js +77 -0
- package/vendor/procedural-animals/src/core/render/skeleton.js +41 -0
- package/vendor/procedural-animals/src/core/rig/bird.js +327 -0
- package/vendor/procedural-animals/src/core/rig/quadruped.js +76 -0
- package/vendor/procedural-animals/src/core/rig/rig.js +79 -0
- package/vendor/procedural-animals/src/core/rig/snake.js +76 -0
- package/vendor/procedural-animals/src/core/rig/spider.js +110 -0
- package/vendor/procedural-animals/src/core/rig/swimmer.js +181 -0
- package/vendor/procedural-animals/src/core/sdf/eyeSocket.js +53 -0
- package/vendor/procedural-animals/src/core/sdf/mesher.js +238 -0
- package/vendor/procedural-animals/src/core/sdf/sdf.js +263 -0
- package/vendor/procedural-animals/src/index.d.ts +98 -0
- package/vendor/procedural-animals/src/index.js +29 -0
- package/vendor/procedural-animals/src/registry.js +48 -0
- package/vendor/procedural-animals/src/species/bear/behaviour.js +463 -0
- package/vendor/procedural-animals/src/species/bear/claws.js +147 -0
- package/vendor/procedural-animals/src/species/bear/coat.js +726 -0
- package/vendor/procedural-animals/src/species/bear/index.js +139 -0
- package/vendor/procedural-animals/src/species/bear/motion.js +112 -0
- package/vendor/procedural-animals/src/species/bear/regions.js +78 -0
- package/vendor/procedural-animals/src/species/bear/rig.js +112 -0
- package/vendor/procedural-animals/src/species/bear/sculpt.js +272 -0
- package/vendor/procedural-animals/src/species/boar/behaviour.js +335 -0
- package/vendor/procedural-animals/src/species/boar/coat.js +372 -0
- package/vendor/procedural-animals/src/species/boar/index.js +110 -0
- package/vendor/procedural-animals/src/species/boar/motion.js +85 -0
- package/vendor/procedural-animals/src/species/boar/regions.js +88 -0
- package/vendor/procedural-animals/src/species/boar/rig.js +111 -0
- package/vendor/procedural-animals/src/species/boar/sculpt.js +285 -0
- package/vendor/procedural-animals/src/species/cat/behaviour.js +559 -0
- package/vendor/procedural-animals/src/species/cat/coat.js +841 -0
- package/vendor/procedural-animals/src/species/cat/index.js +211 -0
- package/vendor/procedural-animals/src/species/cat/motion.js +101 -0
- package/vendor/procedural-animals/src/species/cat/regions.js +82 -0
- package/vendor/procedural-animals/src/species/cat/rig.js +100 -0
- package/vendor/procedural-animals/src/species/cat/sculpt.js +266 -0
- package/vendor/procedural-animals/src/species/cat/whiskers.js +110 -0
- package/vendor/procedural-animals/src/species/cheetah/coat.js +427 -0
- package/vendor/procedural-animals/src/species/cheetah/index.js +51 -0
- package/vendor/procedural-animals/src/species/cheetah/joints.js +3 -0
- package/vendor/procedural-animals/src/species/cheetah/motion.js +77 -0
- package/vendor/procedural-animals/src/species/cheetah/regions.js +95 -0
- package/vendor/procedural-animals/src/species/cheetah/rig.js +66 -0
- package/vendor/procedural-animals/src/species/cheetah/sculpt.js +158 -0
- package/vendor/procedural-animals/src/species/chicken/coat.js +313 -0
- package/vendor/procedural-animals/src/species/chicken/coverts.js +320 -0
- package/vendor/procedural-animals/src/species/chicken/index.js +110 -0
- package/vendor/procedural-animals/src/species/chicken/motion.js +177 -0
- package/vendor/procedural-animals/src/species/chicken/regions.js +66 -0
- package/vendor/procedural-animals/src/species/chicken/rig.js +144 -0
- package/vendor/procedural-animals/src/species/chicken/sculpt.js +389 -0
- package/vendor/procedural-animals/src/species/chicken/wingLook.js +66 -0
- package/vendor/procedural-animals/src/species/chicken/wingStack.js +124 -0
- package/vendor/procedural-animals/src/species/cow/behaviour.js +521 -0
- package/vendor/procedural-animals/src/species/cow/coat.js +465 -0
- package/vendor/procedural-animals/src/species/cow/index.js +118 -0
- package/vendor/procedural-animals/src/species/cow/motion.js +81 -0
- package/vendor/procedural-animals/src/species/cow/regions.js +98 -0
- package/vendor/procedural-animals/src/species/cow/rig.js +116 -0
- package/vendor/procedural-animals/src/species/cow/sculpt.js +339 -0
- package/vendor/procedural-animals/src/species/crow/coat.js +145 -0
- package/vendor/procedural-animals/src/species/crow/index.js +70 -0
- package/vendor/procedural-animals/src/species/crow/joints.js +3 -0
- package/vendor/procedural-animals/src/species/crow/motion.js +101 -0
- package/vendor/procedural-animals/src/species/crow/regions.js +50 -0
- package/vendor/procedural-animals/src/species/crow/rig.js +83 -0
- package/vendor/procedural-animals/src/species/crow/sculpt.js +118 -0
- package/vendor/procedural-animals/src/species/deer/behaviour.js +513 -0
- package/vendor/procedural-animals/src/species/deer/coat.js +391 -0
- package/vendor/procedural-animals/src/species/deer/index.js +106 -0
- package/vendor/procedural-animals/src/species/deer/motion.js +97 -0
- package/vendor/procedural-animals/src/species/deer/regions.js +60 -0
- package/vendor/procedural-animals/src/species/deer/rig.js +124 -0
- package/vendor/procedural-animals/src/species/deer/sculpt.js +297 -0
- package/vendor/procedural-animals/src/species/dog/behaviour.js +521 -0
- package/vendor/procedural-animals/src/species/dog/coat.js +495 -0
- package/vendor/procedural-animals/src/species/dog/index.js +144 -0
- package/vendor/procedural-animals/src/species/dog/motion.js +118 -0
- package/vendor/procedural-animals/src/species/dog/regions.js +61 -0
- package/vendor/procedural-animals/src/species/dog/rig.js +129 -0
- package/vendor/procedural-animals/src/species/dog/sculpt.js +246 -0
- package/vendor/procedural-animals/src/species/eagle/coat.js +250 -0
- package/vendor/procedural-animals/src/species/eagle/index.js +76 -0
- package/vendor/procedural-animals/src/species/eagle/joints.js +3 -0
- package/vendor/procedural-animals/src/species/eagle/motion.js +137 -0
- package/vendor/procedural-animals/src/species/eagle/regions.js +57 -0
- package/vendor/procedural-animals/src/species/eagle/rig.js +107 -0
- package/vendor/procedural-animals/src/species/eagle/sculpt.js +137 -0
- package/vendor/procedural-animals/src/species/fish/coat.js +271 -0
- package/vendor/procedural-animals/src/species/fish/index.js +88 -0
- package/vendor/procedural-animals/src/species/fish/motion.js +92 -0
- package/vendor/procedural-animals/src/species/fish/regions.js +27 -0
- package/vendor/procedural-animals/src/species/fish/rig.js +143 -0
- package/vendor/procedural-animals/src/species/fish/sculpt.js +214 -0
- package/vendor/procedural-animals/src/species/fish/variants.js +126 -0
- package/vendor/procedural-animals/src/species/fox/behaviour.js +314 -0
- package/vendor/procedural-animals/src/species/fox/coat.js +444 -0
- package/vendor/procedural-animals/src/species/fox/index.js +120 -0
- package/vendor/procedural-animals/src/species/fox/motion.js +81 -0
- package/vendor/procedural-animals/src/species/fox/regions.js +59 -0
- package/vendor/procedural-animals/src/species/fox/rig.js +91 -0
- package/vendor/procedural-animals/src/species/fox/sculpt.js +202 -0
- package/vendor/procedural-animals/src/species/frog/behaviour.js +590 -0
- package/vendor/procedural-animals/src/species/frog/coat.js +305 -0
- package/vendor/procedural-animals/src/species/frog/index.js +97 -0
- package/vendor/procedural-animals/src/species/frog/motion.js +69 -0
- package/vendor/procedural-animals/src/species/frog/regions.js +46 -0
- package/vendor/procedural-animals/src/species/frog/rig.js +156 -0
- package/vendor/procedural-animals/src/species/frog/sculpt.js +240 -0
- package/vendor/procedural-animals/src/species/goat/behaviour.js +509 -0
- package/vendor/procedural-animals/src/species/goat/coat.js +590 -0
- package/vendor/procedural-animals/src/species/goat/index.js +149 -0
- package/vendor/procedural-animals/src/species/goat/motion.js +95 -0
- package/vendor/procedural-animals/src/species/goat/regions.js +98 -0
- package/vendor/procedural-animals/src/species/goat/rig.js +181 -0
- package/vendor/procedural-animals/src/species/goat/sculpt.js +547 -0
- package/vendor/procedural-animals/src/species/horse/coat.js +361 -0
- package/vendor/procedural-animals/src/species/horse/coatSeam.js +122 -0
- package/vendor/procedural-animals/src/species/horse/index.js +80 -0
- package/vendor/procedural-animals/src/species/horse/motion.js +245 -0
- package/vendor/procedural-animals/src/species/horse/regions.js +60 -0
- package/vendor/procedural-animals/src/species/horse/rig.js +117 -0
- package/vendor/procedural-animals/src/species/horse/sculpt.js +316 -0
- package/vendor/procedural-animals/src/species/horse/seamWeights.js +272 -0
- package/vendor/procedural-animals/src/species/lion/behaviour.js +509 -0
- package/vendor/procedural-animals/src/species/lion/coat.js +1016 -0
- package/vendor/procedural-animals/src/species/lion/index.js +111 -0
- package/vendor/procedural-animals/src/species/lion/motion.js +87 -0
- package/vendor/procedural-animals/src/species/lion/regions.js +106 -0
- package/vendor/procedural-animals/src/species/lion/rig.js +110 -0
- package/vendor/procedural-animals/src/species/lion/sculpt.js +384 -0
- package/vendor/procedural-animals/src/species/lion/whiskers.js +132 -0
- package/vendor/procedural-animals/src/species/pig/behaviour.js +575 -0
- package/vendor/procedural-animals/src/species/pig/coat.js +730 -0
- package/vendor/procedural-animals/src/species/pig/ears.js +242 -0
- package/vendor/procedural-animals/src/species/pig/index.js +161 -0
- package/vendor/procedural-animals/src/species/pig/motion.js +105 -0
- package/vendor/procedural-animals/src/species/pig/regions.js +100 -0
- package/vendor/procedural-animals/src/species/pig/rig.js +152 -0
- package/vendor/procedural-animals/src/species/pig/sculpt.js +382 -0
- package/vendor/procedural-animals/src/species/rabbit/behaviour.js +605 -0
- package/vendor/procedural-animals/src/species/rabbit/coat.js +285 -0
- package/vendor/procedural-animals/src/species/rabbit/index.js +85 -0
- package/vendor/procedural-animals/src/species/rabbit/motion.js +85 -0
- package/vendor/procedural-animals/src/species/rabbit/regions.js +48 -0
- package/vendor/procedural-animals/src/species/rabbit/rig.js +99 -0
- package/vendor/procedural-animals/src/species/rabbit/sculpt.js +148 -0
- package/vendor/procedural-animals/src/species/rat/behaviour.js +539 -0
- package/vendor/procedural-animals/src/species/rat/coat.js +341 -0
- package/vendor/procedural-animals/src/species/rat/index.js +111 -0
- package/vendor/procedural-animals/src/species/rat/motion.js +90 -0
- package/vendor/procedural-animals/src/species/rat/regions.js +92 -0
- package/vendor/procedural-animals/src/species/rat/rig.js +112 -0
- package/vendor/procedural-animals/src/species/rat/sculpt.js +163 -0
- package/vendor/procedural-animals/src/species/rat/whiskers.js +119 -0
- package/vendor/procedural-animals/src/species/shark/coat.js +383 -0
- package/vendor/procedural-animals/src/species/shark/index.js +104 -0
- package/vendor/procedural-animals/src/species/shark/motion.js +69 -0
- package/vendor/procedural-animals/src/species/shark/regions.js +34 -0
- package/vendor/procedural-animals/src/species/shark/rig.js +194 -0
- package/vendor/procedural-animals/src/species/shark/sculpt.js +343 -0
- package/vendor/procedural-animals/src/species/shark/variants.js +105 -0
- package/vendor/procedural-animals/src/species/sheep/behaviour.js +522 -0
- package/vendor/procedural-animals/src/species/sheep/coat.js +529 -0
- package/vendor/procedural-animals/src/species/sheep/index.js +152 -0
- package/vendor/procedural-animals/src/species/sheep/motion.js +86 -0
- package/vendor/procedural-animals/src/species/sheep/neck.js +41 -0
- package/vendor/procedural-animals/src/species/sheep/regions.js +62 -0
- package/vendor/procedural-animals/src/species/sheep/rig.js +163 -0
- package/vendor/procedural-animals/src/species/sheep/sculpt.js +542 -0
- package/vendor/procedural-animals/src/species/snake/coat.js +315 -0
- package/vendor/procedural-animals/src/species/snake/index.js +73 -0
- package/vendor/procedural-animals/src/species/snake/motion.js +51 -0
- package/vendor/procedural-animals/src/species/snake/regions.js +51 -0
- package/vendor/procedural-animals/src/species/snake/rig.js +108 -0
- package/vendor/procedural-animals/src/species/snake/sculpt.js +122 -0
- package/vendor/procedural-animals/src/species/spider/coat.js +279 -0
- package/vendor/procedural-animals/src/species/spider/index.js +78 -0
- package/vendor/procedural-animals/src/species/spider/motion.js +72 -0
- package/vendor/procedural-animals/src/species/spider/regions.js +87 -0
- package/vendor/procedural-animals/src/species/spider/rig.js +118 -0
- package/vendor/procedural-animals/src/species/spider/sculpt.js +182 -0
- package/vendor/procedural-animals/src/species/wolf/behaviour.js +160 -0
- package/vendor/procedural-animals/src/species/wolf/coat.js +749 -0
- package/vendor/procedural-animals/src/species/wolf/index.js +107 -0
- package/vendor/procedural-animals/src/species/wolf/motion.js +80 -0
- package/vendor/procedural-animals/src/species/wolf/regions.js +57 -0
- package/vendor/procedural-animals/src/species/wolf/rig.js +87 -0
- package/vendor/procedural-animals/src/species/wolf/sculpt.js +339 -0
- package/vendor/procedural-animals/src/worker.js +29 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Fish skeleton (bind pose, metres): forward = +Z, up = +Y, left = +X; the body rests just above y = 0.
|
|
2
|
+
// All landmarks come from the variant's outline table (variants.js), so the four body plans share one
|
|
3
|
+
// rig builder. The standard swimmer bone set is in core/rig/swimmer.js.
|
|
4
|
+
import { buildRig } from '../../core/rig/rig.js';
|
|
5
|
+
import { swimmerBones, swimmerAppendages, axialJoints, axialBones, swimmerJointsAlias, spineName } from '../../core/rig/swimmer.js';
|
|
6
|
+
import { VARIANTS } from './variants.js';
|
|
7
|
+
import { norm, add, mul } from '../../core/math/vec.js';
|
|
8
|
+
|
|
9
|
+
const cr = (p0, p1, p2, p3, t) => {
|
|
10
|
+
// Catmull-Rom (centripetal enough for our smooth tables), clamped to the neighbours' range
|
|
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
|
+
|
|
17
|
+
/** Geometry helper for one variant: outline lookups (metres) and the landmarks. Cached per params. */
|
|
18
|
+
export function fishGeo(params) {
|
|
19
|
+
const key = params.variant;
|
|
20
|
+
const V = VARIANTS[key];
|
|
21
|
+
if (!V) throw new Error(`fish: unknown variant "${key}"`);
|
|
22
|
+
const SL = V.SL;
|
|
23
|
+
const rows = V.prof;
|
|
24
|
+
const n = rows.length;
|
|
25
|
+
const col = (i, k) => rows[Math.max(0, Math.min(n - 1, i))][k];
|
|
26
|
+
const at = (u, k) => {
|
|
27
|
+
if (u <= rows[0][0]) return rows[0][k] * Math.sqrt(Math.max(0, u) / rows[0][0]);
|
|
28
|
+
if (u >= rows[n - 1][0]) return rows[n - 1][k];
|
|
29
|
+
let i = 0;
|
|
30
|
+
while (i < n - 2 && u > rows[i + 1][0]) i++;
|
|
31
|
+
const t = (u - rows[i][0]) / (rows[i + 1][0] - rows[i][0]);
|
|
32
|
+
return cr(col(i - 1, k), col(i, k), col(i + 1, k), col(i + 2, k), t);
|
|
33
|
+
};
|
|
34
|
+
let maxBot = 0;
|
|
35
|
+
for (const r of rows) maxBot = Math.max(maxBot, r[2]);
|
|
36
|
+
const axisY = (maxBot + 0.04) * SL;
|
|
37
|
+
const z0 = 0.42 * SL;
|
|
38
|
+
const G = {
|
|
39
|
+
V, SL, axisY, z0,
|
|
40
|
+
tailLen: V.fins.caudal.len * (params.tailK || 1),
|
|
41
|
+
finK: params.finK || 1,
|
|
42
|
+
L: SL * (1 + V.fins.caudal.len * (params.tailK || 1) * 0.95),
|
|
43
|
+
z: (u) => z0 - u * SL,
|
|
44
|
+
u: (z) => (z0 - z) / SL,
|
|
45
|
+
top: (u) => at(u, 1) * SL,
|
|
46
|
+
bot: (u) => at(u, 2) * SL,
|
|
47
|
+
hw: (u) => at(u, 3) * SL,
|
|
48
|
+
yc: (u) => axisY + ((at(u, 1) - at(u, 2)) / 2) * SL,
|
|
49
|
+
hd: (u) => ((at(u, 1) + at(u, 2)) / 2) * SL,
|
|
50
|
+
};
|
|
51
|
+
// surface half width at height y (elliptic cross-section)
|
|
52
|
+
G.surfX = (u, y) => {
|
|
53
|
+
const e = (y - G.yc(u)) / Math.max(1e-6, G.hd(u));
|
|
54
|
+
return G.hw(u) * Math.sqrt(Math.max(0, 1 - e * e));
|
|
55
|
+
};
|
|
56
|
+
// a point on the flank surface at (u, height fraction e in -1..1 of the half depth)
|
|
57
|
+
G.flank = (u, e, s = 1) => {
|
|
58
|
+
const y = G.yc(u) + e * G.hd(u);
|
|
59
|
+
return [s * G.surfX(u, y), y, G.z(u)];
|
|
60
|
+
};
|
|
61
|
+
const H = V.head;
|
|
62
|
+
G.mouthY = axisY + H.mouth.h * SL;
|
|
63
|
+
const eu = H.eye.u, ey = axisY + H.eye.h * SL;
|
|
64
|
+
G.eye = { u: eu, y: ey, r: H.eye.r * SL, z: G.z(eu) };
|
|
65
|
+
G.eye.x = G.surfX(eu, ey) - 0.62 * G.eye.r; // flush: only a shallow cap shows
|
|
66
|
+
G.headO = [0, ey, G.z(eu)];
|
|
67
|
+
return G;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function fishJoints(params) {
|
|
71
|
+
const G = fishGeo(params);
|
|
72
|
+
const V = G.V, SL = G.SL, H = V.head, F = V.fins;
|
|
73
|
+
const N = V.spineSegs, M = V.caudalSegs;
|
|
74
|
+
const J = {};
|
|
75
|
+
J.snout = [0, G.mouthY + 0.004 * SL, G.z0];
|
|
76
|
+
for (let i = 0; i <= N; i++) {
|
|
77
|
+
const u = H.occ + ((1 - H.occ) * i) / N;
|
|
78
|
+
J[spineName(i)] = [0, G.yc(u), G.z(u)];
|
|
79
|
+
}
|
|
80
|
+
swimmerJointsAlias(J, N);
|
|
81
|
+
const cl = G.tailLen * 0.86;
|
|
82
|
+
for (let j = 1; j <= M; j++) J['caudal' + j] = [0, G.yc(1), G.z(1 + (cl * j) / M)];
|
|
83
|
+
// lower jaw: hinge below the end of the gape, tip at the chin
|
|
84
|
+
const g = H.mouth.gape;
|
|
85
|
+
J.jawHinge = [0, G.mouthY - H.mouth.jawDepth * SL * 0.55, G.z(g + 0.02)];
|
|
86
|
+
J.jawTip = [0, G.mouthY - 0.006 * SL, G.z(0.004)];
|
|
87
|
+
J.premaxBase = [0, G.mouthY + 0.03 * SL, G.z(g * 0.85)];
|
|
88
|
+
J.premaxTip = [0, G.mouthY + 0.008 * SL, G.z(0.0)];
|
|
89
|
+
// gill cover: hinge along its front edge, free edge at the back
|
|
90
|
+
const op = H.op;
|
|
91
|
+
J.opHingeL = G.flank(op - 0.075, 0.5);
|
|
92
|
+
J.opLowL = G.flank(op - 0.1, -0.45);
|
|
93
|
+
J.opEdgeL = G.flank(op, 0.05);
|
|
94
|
+
// pectoral fin: base line on the flank behind the gill cover
|
|
95
|
+
const P = F.pectoral;
|
|
96
|
+
const pb = G.flank(P.u, (P.h * SL - (G.yc(P.u) - G.axisY)) / G.hd(P.u));
|
|
97
|
+
pb[0] += 0.004 * SL;
|
|
98
|
+
J.pecBaseL = pb;
|
|
99
|
+
J.pecUpL = [pb[0] - 0.004 * SL, pb[1] + 0.03 * SL, pb[2] + 0.008 * SL];
|
|
100
|
+
J.pecTipL = add(pb, mul(finDir(P.sweep, P.droop, P.abduct), P.len * G.finK * SL));
|
|
101
|
+
// pelvic fin: on the belly
|
|
102
|
+
const Q = F.pelvic;
|
|
103
|
+
const ybot = G.yc(Q.u) - G.hd(Q.u);
|
|
104
|
+
const pl = [G.hw(Q.u) * 0.42, ybot + 0.18 * G.hd(Q.u) * 0.3, G.z(Q.u)];
|
|
105
|
+
pl[1] = G.yc(Q.u) - G.hd(Q.u) * Math.sqrt(1 - Math.pow(pl[0] / G.hw(Q.u), 2)) + 0.003 * SL;
|
|
106
|
+
J.pelBaseL = pl;
|
|
107
|
+
J.pelFrontL = [pl[0] + 0.02 * SL, pl[1] - 0.004 * SL, pl[2] + 0.004 * SL];
|
|
108
|
+
J.pelTipL = add(pl, mul(finDir(90 - Q.sweep, 90 - Q.sweep * 0.2, Q.abduct, true), Q.len * G.finK * SL));
|
|
109
|
+
return { J, G };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Fin direction: `sweep` deg back from lateral toward -Z, `droop` deg below horizontal, `abduct` deg
|
|
113
|
+
// out from the body wall. For the pelvic (ventral) fins pass ventral = true: they point back and down.
|
|
114
|
+
export function finDir(sweep, droop, abduct, ventral = false) {
|
|
115
|
+
const d2r = Math.PI / 180;
|
|
116
|
+
if (ventral) {
|
|
117
|
+
const back = Math.cos(abduct * d2r), out = Math.sin(abduct * d2r);
|
|
118
|
+
return norm([out * 0.8, -Math.sin((90 - droop) * d2r) * 0.55 - 0.25, -back]);
|
|
119
|
+
}
|
|
120
|
+
const ab = abduct * d2r, dr = droop * d2r;
|
|
121
|
+
return norm([Math.sin(ab), -Math.sin(dr), -Math.cos(ab) * Math.cos(dr)]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function pickParent(G, u) {
|
|
125
|
+
const V = G.V, N = V.spineSegs, occ = V.head.occ;
|
|
126
|
+
const i = Math.max(0, Math.min(N - 1, Math.floor(((u - occ) / (1 - occ)) * N)));
|
|
127
|
+
return spineName(i);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function fishRig(params) {
|
|
131
|
+
const { J, G } = fishJoints(params);
|
|
132
|
+
const V = G.V, N = V.spineSegs, M = V.caudalSegs;
|
|
133
|
+
return buildRig({
|
|
134
|
+
joints: J,
|
|
135
|
+
unit: G.L / 1.3,
|
|
136
|
+
headOrigin: G.headO,
|
|
137
|
+
bones: swimmerBones({ spineSegs: N, caudalSegs: M, jaw: true, upperJaw: true, opercula: true, pectoralParent: pickParent(G, V.fins.pectoral.u), pelvicParent: pickParent(G, V.fins.pelvic.u) }),
|
|
138
|
+
axial: { points: axialJoints(N, M), bones: axialBones(N, M) },
|
|
139
|
+
limbs: {},
|
|
140
|
+
appendages: swimmerAppendages({ upperJaw: true, blend: [-0.004, 0.006] }),
|
|
141
|
+
meta: { variant: params.variant, SL: G.SL },
|
|
142
|
+
});
|
|
143
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// Fish sculpt: a dense chain of elliptic cross-sections along the outline table, a separately meshed
|
|
2
|
+
// lower jaw (cut from the same sections with two complementary profile prisms, so the lip line
|
|
3
|
+
// matches exactly), gill covers with a free rear edge over a gill slit, lidless eyes seated in a
|
|
4
|
+
// shallow orbit, and every fin as a thin membrane slab (core/rig/swimmer.js sculptFin).
|
|
5
|
+
import { fishGeo, pickParent } from './rig.js';
|
|
6
|
+
import { sculptFin, fanRays, spineName } from '../../core/rig/swimmer.js';
|
|
7
|
+
import { add, sub, mul, norm, lerp } from '../../core/math/vec.js';
|
|
8
|
+
|
|
9
|
+
// hero cell size relative to SL (regions.js) and the fin membrane thickness derived from it
|
|
10
|
+
export const CELL = 1 / 300;
|
|
11
|
+
export const finThickness = (SL, V) => SL * CELL * (V?.cellK || 1) * 2.9;
|
|
12
|
+
// lip thickness in front of the buccal cavity (fraction of SL)
|
|
13
|
+
export const MOUTH_LIP = 0.022;
|
|
14
|
+
// the free (rear) edge of the gill cover: u (fraction of SL) at height e (-1 belly .. 1 back, fraction of
|
|
15
|
+
// the half depth); the gill cover plate below follows it, the coat paints the edge line along it
|
|
16
|
+
export const opEdgeU = (op, e) => op + 0.003 - 0.045 * Math.min(1.44, e * e);
|
|
17
|
+
|
|
18
|
+
export function sculptFish(m, rig, params) {
|
|
19
|
+
const G = fishGeo(params);
|
|
20
|
+
const V = G.V, SL = G.SL, J = rig.J, H = V.head, F = V.fins;
|
|
21
|
+
const N = V.spineSegs;
|
|
22
|
+
const boneAt = (u) => (u < H.occ ? 'head' : pickParent(G, u));
|
|
23
|
+
const t = finThickness(SL, V);
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------- body sections
|
|
26
|
+
const step = 0.018, rzMax = 0.05;
|
|
27
|
+
const station = (u, part = 'body', extra = {}) => {
|
|
28
|
+
const rz = Math.min(rzMax, u * 0.95 + 0.004) * SL;
|
|
29
|
+
return m.ell({ tag: u < H.op ? 'head' : 'body', bone: boneAt(u), c: [0, G.yc(u), G.z(u)], r: [G.hw(u), G.hd(u), rz], k: 0.007 * SL, part, ...extra });
|
|
30
|
+
};
|
|
31
|
+
for (let u = 0.012; u <= 1.0001; u += step) station(Math.min(u, 1));
|
|
32
|
+
// the caudal peduncle runs on into the fin base
|
|
33
|
+
m.ell({ tag: 'body', bone: 'caudal0', c: [0, G.yc(1), G.z(1.025)], r: [G.hw(1) * 0.8, G.hd(1) * 0.92, 0.035 * SL], k: 0.008 * SL });
|
|
34
|
+
|
|
35
|
+
// ---------------------------------------------------------------- head features
|
|
36
|
+
// Eyes: no socket and no orbit rim. A fish's cornea bulges straight out of smooth head skin, so the
|
|
37
|
+
// lidless eyeball (drawn by the eye renderer) simply stands out of the head surface: the depth test
|
|
38
|
+
// draws the skin / cornea boundary as a clean circle at every tier. A socket carved around the ball
|
|
39
|
+
// left a sub-cell gap that meshed into a jagged dark rim, and a hole at the eye's front corner.
|
|
40
|
+
// gill covers: a plate on each cheek, slightly proud, free along its rear edge
|
|
41
|
+
const op = H.op;
|
|
42
|
+
for (const S of ['L', 'R']) {
|
|
43
|
+
const s = S === 'L' ? 1 : -1;
|
|
44
|
+
const uc = op - 0.055;
|
|
45
|
+
const c = G.flank(uc, 0.02, s);
|
|
46
|
+
const nrm = norm([s, 0, 0.12]);
|
|
47
|
+
m.ell({ tag: 'operculum', bone: 'operculum' + S, group: 'operculum' + S, c: sub(c, mul(nrm, 0.0205 * SL)), axis: [0, 0, 1], up: [0, 1, 0], r: [0.0225 * SL, G.hd(uc) * 0.78, 0.062 * SL], k: 0.014 * SL });
|
|
48
|
+
if (H.earFlap) {
|
|
49
|
+
// bluegill "ear": a black lobe at the top of the gill cover
|
|
50
|
+
// a flat rounded lobe reaching back from the upper gill cover (about 0.08 SL long, 0.05 high)
|
|
51
|
+
const ce = G.flank(op + 0.03, 0.2, s);
|
|
52
|
+
m.ell({ tag: 'earflap', bone: 'operculum' + S, group: 'operculum' + S, c: sub(ce, [s * 0.0035 * SL, 0, 0]), axis: [0, 0, 1], up: [0, 1, 0], r: [0.0065 * SL, H.earFlap * 0.5 * SL, H.earFlap * 0.8 * SL], k: 0.004 * SL });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// upper lip / premaxilla (protrudes when feeding)
|
|
56
|
+
m.ell({ tag: 'lip', bone: 'upperJaw', group: 'upperJaw', c: [0, G.mouthY + 0.01 * SL, G.z(0.02)], r: [G.hw(0.03) * 0.95, 0.012 * SL, 0.022 * SL], k: 0.006 * SL });
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------- carvers (after every union)
|
|
59
|
+
// mouth: the lower-jaw region, a profile prism in the median plane (z, y), cut out of the body
|
|
60
|
+
const gape = H.mouth.gape, jd = H.mouth.jawDepth * SL;
|
|
61
|
+
const zS = G.z0 + 0.03 * SL, yLow = -0.05 * SL;
|
|
62
|
+
const zc = G.z(gape), zh = G.z(gape + 0.03), zb = G.z(gape + 0.075);
|
|
63
|
+
const up = H.mouth.upturn * 0.012 * SL;
|
|
64
|
+
const jawPoly = [[zS, G.mouthY + up], [(zS + zc) / 2, G.mouthY + up * 0.4], [zc, G.mouthY], [zh, G.mouthY - jd * 0.55], [zb, yLow], [zS, yLow]];
|
|
65
|
+
const gap = 0.0013 * SL;
|
|
66
|
+
const wide = 0.5 * SL;
|
|
67
|
+
const prism = (poly, o) => m.fin({ o: [0, 0, 0], u: [0, 0, 1], v: [0, 1, 0], t: wide, poly, round: 0, ...o });
|
|
68
|
+
prism(offsetPoly(jawPoly, gap * 0.5), { tag: 'mouthcut', bone: 'head', carve: true, k: 0.004 * SL });
|
|
69
|
+
// buccal cavity: it starts behind the lips (MOUTH_LIP of SL behind the snout), so a closed mouth
|
|
70
|
+
// shows only the lip line and the dark cavity appears when the jaw drops. (Reaching through the
|
|
71
|
+
// snout, it held the mouth open as a dark O at rest.)
|
|
72
|
+
const uF = MOUTH_LIP, uB = gape + 0.035;
|
|
73
|
+
const cavY = G.mouthY - 0.003 * SL;
|
|
74
|
+
const mouthCav = (o) => m.ell({ tag: 'mouth', bone: 'head', c: [0, cavY, G.z((uF + uB) / 2)], r: [G.hw((uF + uB) / 2) * 0.55, Math.min(0.024 * SL, jd * 0.45), ((uB - uF) / 2) * SL], k: 0.003 * SL, carve: true, ...o });
|
|
75
|
+
mouthCav({});
|
|
76
|
+
// The gill slit is not carved: a sub-cell groove along the gill cover's edge meshed into a jagged
|
|
77
|
+
// dark crack. The coat paints the edge as a soft shading line instead (coat.js opEdgeU).
|
|
78
|
+
|
|
79
|
+
// ---------------------------------------------------------------- lower jaw (own surface, rigid)
|
|
80
|
+
const JW = { bone: 'jaw', group: 'jaw', part: 'jaw' };
|
|
81
|
+
for (let u = 0.012; u <= gape + 0.1; u += step) station(u, 'jaw', { ...JW, tag: 'jaw' });
|
|
82
|
+
// everything that is not lower jaw: the complement of the jaw prism
|
|
83
|
+
const big = SL;
|
|
84
|
+
const rest = [[zS, G.mouthY + up], [zS, G.mouthY + big], [zb - big, G.mouthY + big], [zb - big, yLow], [zb, yLow], [zh, G.mouthY - jd * 0.55], [zc, G.mouthY], [(zS + zc) / 2, G.mouthY + up * 0.4]];
|
|
85
|
+
prism(offsetPoly(rest, gap * 0.5), { ...JW, tag: 'jawcut', carve: true, k: 0.004 * SL });
|
|
86
|
+
mouthCav({ ...JW });
|
|
87
|
+
|
|
88
|
+
// ---------------------------------------------------------------- median fins (membranes, x = 0 plane)
|
|
89
|
+
const median = { origin: [0, 0, 0], u: [0, 0, 1], v: [0, 1, 0], t, sink: 0.022 * SL };
|
|
90
|
+
const dorsalBase = (u) => [G.z(u), G.yc(u) + G.hd(u) - 0.006 * SL];
|
|
91
|
+
const ventralBase = (u) => [G.z(u), G.yc(u) - G.hd(u) + 0.006 * SL];
|
|
92
|
+
const profileRays = (d, base, sign) => {
|
|
93
|
+
const rays = [];
|
|
94
|
+
for (let i = 0; i < d.n; i++) {
|
|
95
|
+
const f = d.n === 1 ? 0 : i / (d.n - 1);
|
|
96
|
+
const u = d.u0 + (d.u1 - d.u0) * f;
|
|
97
|
+
const a = ((d.a0 + (d.a1 - d.a0) * f) * Math.PI) / 180;
|
|
98
|
+
let L = d.len[0] + (d.len[1] - d.len[0]) * f;
|
|
99
|
+
if (d.round) L *= 0.78 + 0.34 * Math.sin(Math.PI * Math.min(1, f * 1.15 + 0.08));
|
|
100
|
+
if (d.spiny) L *= 1 - 0.18 * f * f;
|
|
101
|
+
if (!d.round && !d.spiny) L *= 1 - 0.12 * Math.pow(f, 0.7) * (1 - f) * 2.5;
|
|
102
|
+
const b = base(u);
|
|
103
|
+
rays.push([b, [b[0] + Math.cos(a) * L * SL, b[1] + Math.sin(a) * L * SL * sign]]);
|
|
104
|
+
}
|
|
105
|
+
// close the fin back to the body behind the last ray
|
|
106
|
+
return rays;
|
|
107
|
+
};
|
|
108
|
+
let fi = 0;
|
|
109
|
+
for (const d of F.dorsal) {
|
|
110
|
+
const rays = profileRays(d, dorsalBase, 1);
|
|
111
|
+
sculptFin(m, { ...median, rays, bone: boneAt((d.u0 + d.u1) / 2), tag: 'fin', name: 'dorsal' + fi++, notch: d.notch || 0, k: t * 1.2 });
|
|
112
|
+
}
|
|
113
|
+
for (const d of F.anal) {
|
|
114
|
+
// anal fin angles are given as absolute angles (below the axis)
|
|
115
|
+
const rays = [];
|
|
116
|
+
for (let i = 0; i < d.n; i++) {
|
|
117
|
+
const f = i / (d.n - 1);
|
|
118
|
+
const u = d.u0 + (d.u1 - d.u0) * f;
|
|
119
|
+
const a = ((d.a0 + (d.a1 - d.a0) * f) * Math.PI) / 180;
|
|
120
|
+
let L = d.len[0] + (d.len[1] - d.len[0]) * f;
|
|
121
|
+
if (d.round) L *= 0.8 + 0.3 * Math.sin(Math.PI * Math.min(1, f * 1.1 + 0.1));
|
|
122
|
+
const b = ventralBase(u);
|
|
123
|
+
rays.push([b, [b[0] + Math.cos(a) * L * SL, b[1] + Math.sin(a) * L * SL]]);
|
|
124
|
+
}
|
|
125
|
+
sculptFin(m, { ...median, rays, bone: boneAt((d.u0 + d.u1) / 2), tag: 'fin', name: 'anal', k: t * 1.2 });
|
|
126
|
+
}
|
|
127
|
+
if (F.adipose) {
|
|
128
|
+
const d = F.adipose, rays = [];
|
|
129
|
+
for (let i = 0; i < 6; i++) {
|
|
130
|
+
const f = i / 5, u = d.u0 + (d.u1 - d.u0) * f;
|
|
131
|
+
const b = dorsalBase(u);
|
|
132
|
+
const L = d.h * SL * (0.35 + 0.75 * Math.sin(Math.PI * Math.min(1, f * 0.9 + 0.1)));
|
|
133
|
+
const a = ((100 + 60 * f) * Math.PI) / 180;
|
|
134
|
+
rays.push([b, [b[0] + Math.cos(a) * L, b[1] + Math.sin(a) * L]]);
|
|
135
|
+
}
|
|
136
|
+
sculptFin(m, { ...median, t: 0.01 * SL, round: 0.004 * SL, rays, bone: boneAt(d.u0), tag: 'adipose', name: 'adipose', k: 0.006 * SL });
|
|
137
|
+
}
|
|
138
|
+
// caudal fin: rays fan from the hypural plate; fork > 0 shortens the middle rays (forked tail),
|
|
139
|
+
// fork < 0 lengthens them (rounded tail)
|
|
140
|
+
{
|
|
141
|
+
const C = F.caudal;
|
|
142
|
+
const h1 = G.hd(1), yb = G.yc(1), zb0 = G.z(1.0);
|
|
143
|
+
const rays = [];
|
|
144
|
+
for (let i = 0; i < C.n; i++) {
|
|
145
|
+
const f = i / (C.n - 1);
|
|
146
|
+
const e = 1 - 2 * f; // +1 upper lobe .. -1 lower lobe
|
|
147
|
+
const a = Math.PI + (e * C.spread * Math.PI) / 180;
|
|
148
|
+
const mid = 1 - Math.pow(Math.abs(e), C.lobe === 'pointed' ? 1.3 : 2.2);
|
|
149
|
+
let L = G.tailLen * SL * (1 - C.fork * mid);
|
|
150
|
+
if (C.lobe === 'rounded') L *= 1 - 0.1 * Math.pow(Math.abs(e), 4);
|
|
151
|
+
const b = [zb0 + 0.012 * SL, yb + e * h1 * 0.78];
|
|
152
|
+
rays.push([b, [b[0] + Math.cos(a) * L, b[1] - Math.sin(a) * L]]);
|
|
153
|
+
}
|
|
154
|
+
const bone = 'caudal0';
|
|
155
|
+
sculptFin(m, { ...median, sink: 0.03 * SL, rays, bone, tag: 'fin', name: 'caudal', k: t * 1.5 });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ---------------------------------------------------------------- paired fins (appendages)
|
|
159
|
+
for (const S of ['L', 'R']) {
|
|
160
|
+
const s = S === 'L' ? 1 : -1;
|
|
161
|
+
// pectoral: plane through the base line (pecBase -> pecUp) and the fin direction
|
|
162
|
+
{
|
|
163
|
+
const P = F.pectoral;
|
|
164
|
+
const b = J['pecBase' + S], upJ = J['pecUp' + S], tip = J['pecTip' + S];
|
|
165
|
+
const u = norm(sub(tip, b));
|
|
166
|
+
const vb = sub(upJ, b);
|
|
167
|
+
const v = norm(sub(vb, mul(u, vb[0] * u[0] + vb[1] * u[1] + vb[2] * u[2])));
|
|
168
|
+
const bl = 0.036 * SL, L = P.len * G.finK * SL;
|
|
169
|
+
const shape = P.shape;
|
|
170
|
+
const rays = fanRays({
|
|
171
|
+
base0: [-0.004 * SL, bl * 0.55], base1: [0.002 * SL, -bl * 0.45], n: P.n,
|
|
172
|
+
angle0: shape === 'sickle' ? 12 : 15, angle1: -17,
|
|
173
|
+
length: (f) => {
|
|
174
|
+
if (shape === 'pointed') return L * (1.0 - 0.55 * Math.pow(f, 1.2)) * (0.8 + 0.2 * Math.min(1, f * 6));
|
|
175
|
+
if (shape === 'sickle') return L * (1.0 - 0.78 * Math.pow(f, 0.8)) * (0.7 + 0.3 * Math.min(1, f * 8));
|
|
176
|
+
return L * (0.72 + 0.3 * Math.sin(Math.PI * Math.min(1, f * 1.05 + 0.12)));
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
// the right fin mirrors the left: flip the plane's v so the rays mirror too
|
|
180
|
+
sculptFin(m, { origin: b, u, v: s > 0 ? v : v, rays, t, sink: 0.006 * SL, bone: 'pectoral' + S, group: 'pectoral' + S, tag: 'fin', name: 'pectoral' + S, k: t * 0.9 });
|
|
181
|
+
}
|
|
182
|
+
// pelvic
|
|
183
|
+
{
|
|
184
|
+
const Q = F.pelvic;
|
|
185
|
+
const b = J['pelBase' + S], fr = J['pelFront' + S], tip = J['pelTip' + S];
|
|
186
|
+
const u = norm(sub(tip, b));
|
|
187
|
+
const vb = sub(fr, b);
|
|
188
|
+
const v = norm(sub(vb, mul(u, vb[0] * u[0] + vb[1] * u[1] + vb[2] * u[2])));
|
|
189
|
+
const bl = 0.026 * SL, L = Q.len * G.finK * SL;
|
|
190
|
+
const rays = fanRays({
|
|
191
|
+
base0: [0.002 * SL, bl * 0.5], base1: [-0.002 * SL, -bl * 0.5], n: Q.n, angle0: 18, angle1: -14,
|
|
192
|
+
length: (f) => L * (1.0 - 0.45 * Math.pow(f, 1.1)) * (0.85 + 0.15 * Math.min(1, f * 5)),
|
|
193
|
+
});
|
|
194
|
+
sculptFin(m, { origin: b, u, v, rays, t, sink: 0.006 * SL, bone: 'pelvic' + S, group: 'pelvic' + S, tag: 'fin', name: 'pelvic' + S, k: t * 0.9 });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
void spineName; void lerp; void add; void N;
|
|
198
|
+
return m;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// grows / shrinks a polygon outward by d (approximate: along the averaged edge normals)
|
|
202
|
+
function offsetPoly(poly, d) {
|
|
203
|
+
const n = poly.length;
|
|
204
|
+
let area = 0;
|
|
205
|
+
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]; }
|
|
206
|
+
const sgn = area > 0 ? 1 : -1;
|
|
207
|
+
return poly.map((p, i) => {
|
|
208
|
+
const a = poly[(i + n - 1) % n], b = poly[(i + 1) % n];
|
|
209
|
+
const e1 = norm([p[0] - a[0], p[1] - a[1], 0]), e2 = norm([b[0] - p[0], b[1] - p[1], 0]);
|
|
210
|
+
const n1 = [e1[1] * sgn, -e1[0] * sgn], n2 = [e2[1] * sgn, -e2[0] * sgn];
|
|
211
|
+
const nn = norm([n1[0] + n2[0], n1[1] + n2[1], 0]);
|
|
212
|
+
return [p[0] + nn[0] * d, p[1] + nn[1] * d];
|
|
213
|
+
});
|
|
214
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Fish variants: four teleost body plans in one species module.
|
|
2
|
+
//
|
|
3
|
+
// Every length is a fraction of the standard length SL (snout tip -> caudal base). `prof` rows are
|
|
4
|
+
// [u (fraction of SL from the snout), top (dorsal outline above the axis), bot (ventral outline below
|
|
5
|
+
// the axis), hw (half width)]. Fins are given by their base (u range on the outline) and ray
|
|
6
|
+
// lengths / angles in the median plane (u forward, v up; angle 90 = straight up, 180 = straight back).
|
|
7
|
+
// Colours are sRGB hex sampled from reference photos.
|
|
8
|
+
|
|
9
|
+
export const VARIANT_KEYS = ['trout', 'goldfish', 'clownfish', 'bluegill'];
|
|
10
|
+
|
|
11
|
+
export const VARIANTS = {
|
|
12
|
+
// Rainbow trout (Oncorhynchus mykiss), stream-resident adult: fusiform, small head-scales, spotted.
|
|
13
|
+
trout: {
|
|
14
|
+
name: 'Rainbow trout', latin: 'Oncorhynchus mykiss',
|
|
15
|
+
SL: 0.26, cellK: 1.0,
|
|
16
|
+
prof: [
|
|
17
|
+
[0.012, 0.016, 0.012, 0.012], [0.03, 0.028, 0.022, 0.022], [0.06, 0.0497, 0.0432, 0.034], [0.1, 0.0691, 0.0648, 0.045],
|
|
18
|
+
[0.16, 0.0886, 0.0842, 0.055], [0.23, 0.1048, 0.1004, 0.062], [0.32, 0.1188, 0.1145, 0.066], [0.42, 0.1264, 0.1188, 0.066],
|
|
19
|
+
[0.52, 0.121, 0.1112, 0.061], [0.62, 0.1058, 0.095, 0.053], [0.72, 0.0864, 0.0756, 0.042], [0.82, 0.068, 0.0594, 0.031],
|
|
20
|
+
[0.9, 0.0572, 0.0508, 0.023], [0.96, 0.054, 0.0497, 0.018], [1.0, 0.0562, 0.054, 0.015],
|
|
21
|
+
],
|
|
22
|
+
head: { op: 0.235, occ: 0.19, eye: { u: 0.072, h: 0.03, r: 0.022 }, mouth: { h: -0.012, gape: 0.105, jawDepth: 0.03, upturn: 0 }, snout: 0.5 },
|
|
23
|
+
fins: {
|
|
24
|
+
dorsal: [{ u0: 0.42, u1: 0.565, n: 12, a0: 118, a1: 150, len: [0.135, 0.05], notch: 0 }],
|
|
25
|
+
adipose: { u0: 0.79, u1: 0.845, h: 0.03 },
|
|
26
|
+
anal: [{ u0: 0.675, u1: 0.79, n: 10, a0: 238, a1: 208, len: [0.11, 0.045] }],
|
|
27
|
+
caudal: { len: 0.23, fork: 0.18, spread: 37, n: 19, lobe: 'pointed' },
|
|
28
|
+
pectoral: { u: 0.245, h: -0.07, len: 0.13, n: 12, sweep: 38, droop: 22, abduct: 28, shape: 'pointed', parentU: 0.25 },
|
|
29
|
+
pelvic: { u: 0.5, len: 0.105, n: 9, sweep: 22, abduct: 25 },
|
|
30
|
+
},
|
|
31
|
+
spineSegs: 12, caudalSegs: 3,
|
|
32
|
+
scale: 0.004, gloss: 0.8, irid: 0.45,
|
|
33
|
+
colour: {
|
|
34
|
+
back: 0x56604a, upper: 0x80846a, band: 0xb66f78, lower: 0xc2c6be, belly: 0xe9e9e2, spot: 0x1d1d19,
|
|
35
|
+
fin: 0x5e5c42, finEdge: 0xe8e6dc, head: 0x6f7456, cheek: 0xc97884, gill: 0x7a1c22,
|
|
36
|
+
},
|
|
37
|
+
eye: { iris: [0x3a3522, 0xb7a76e, 0xd8cc98, 0x2a2618] },
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
// Common goldfish (Carassius auratus): deep, round-backed cyprinid, big reflective scales, long dorsal.
|
|
41
|
+
goldfish: {
|
|
42
|
+
name: 'Goldfish', latin: 'Carassius auratus',
|
|
43
|
+
SL: 0.125, cellK: 1.33,
|
|
44
|
+
prof: [
|
|
45
|
+
[0.012, 0.024, 0.016, 0.016], [0.035, 0.05, 0.036, 0.034], [0.07, 0.084, 0.064, 0.056], [0.11, 0.113, 0.093, 0.074],
|
|
46
|
+
[0.17, 0.145, 0.123, 0.088], [0.24, 0.172, 0.15, 0.097], [0.33, 0.194, 0.172, 0.101], [0.43, 0.2, 0.176, 0.097],
|
|
47
|
+
[0.53, 0.19, 0.162, 0.09], [0.63, 0.166, 0.138, 0.078], [0.73, 0.133, 0.109, 0.062], [0.82, 0.102, 0.086, 0.046],
|
|
48
|
+
[0.9, 0.08, 0.071, 0.034], [0.96, 0.071, 0.066, 0.028], [1.0, 0.073, 0.069, 0.024],
|
|
49
|
+
],
|
|
50
|
+
head: { op: 0.275, occ: 0.22, eye: { u: 0.105, h: 0.046, r: 0.036 }, mouth: { h: -0.008, gape: 0.036, jawDepth: 0.026, upturn: 0.3 }, snout: 0.8 },
|
|
51
|
+
fins: {
|
|
52
|
+
dorsal: [{ u0: 0.42, u1: 0.77, n: 16, a0: 108, a1: 150, len: [0.22, 0.075], firstSpine: true }],
|
|
53
|
+
anal: [{ u0: 0.72, u1: 0.815, n: 7, a0: 238, a1: 214, len: [0.22, 0.12] }],
|
|
54
|
+
caudal: { len: 0.36, fork: 0.45, spread: 38, n: 19, lobe: 'rounded' },
|
|
55
|
+
pectoral: { u: 0.29, h: -0.13, len: 0.23, n: 14, sweep: 40, droop: 26, abduct: 32, shape: 'rounded' },
|
|
56
|
+
pelvic: { u: 0.48, len: 0.23, n: 9, sweep: 26, abduct: 28 },
|
|
57
|
+
},
|
|
58
|
+
spineSegs: 12, caudalSegs: 3,
|
|
59
|
+
scale: 0.052, gloss: 0.6, irid: 0.3, scaleEdge: 0.075, scaleFade: 0.03,
|
|
60
|
+
colour: {
|
|
61
|
+
back: 0xe0691a, upper: 0xee8a1e, band: 0xef8e22, lower: 0xf29a30, belly: 0xf6b25a, spot: 0xf4f1ea,
|
|
62
|
+
fin: 0xf5a04a, finEdge: 0xf6b872, head: 0xee8a1e, cheek: 0xf09a34, gill: 0x8a2020,
|
|
63
|
+
},
|
|
64
|
+
eye: { iris: [0x3b2a0c, 0xa8781f, 0xd8ae52, 0x2c1e08] },
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// Ocellaris clownfish (Amphiprion ocellaris): short oval body, rounded fins, three white bands.
|
|
68
|
+
clownfish: {
|
|
69
|
+
name: 'Clownfish', latin: 'Amphiprion ocellaris',
|
|
70
|
+
SL: 0.068, cellK: 1.45,
|
|
71
|
+
prof: [
|
|
72
|
+
[0.012, 0.03, 0.022, 0.018], [0.035, 0.066, 0.05, 0.04], [0.07, 0.106, 0.084, 0.06], [0.12, 0.145, 0.12, 0.08],
|
|
73
|
+
[0.2, 0.183, 0.16, 0.097], [0.3, 0.206, 0.188, 0.103], [0.4, 0.21, 0.198, 0.1], [0.5, 0.2, 0.19, 0.094],
|
|
74
|
+
[0.6, 0.18, 0.17, 0.084], [0.7, 0.152, 0.142, 0.07], [0.8, 0.118, 0.112, 0.055], [0.9, 0.092, 0.087, 0.04],
|
|
75
|
+
[0.96, 0.083, 0.08, 0.033], [1.0, 0.085, 0.082, 0.029],
|
|
76
|
+
],
|
|
77
|
+
head: { op: 0.315, occ: 0.26, eye: { u: 0.12, h: 0.055, r: 0.046 }, mouth: { h: -0.02, gape: 0.055, jawDepth: 0.04, upturn: 0.2 }, snout: 0.9 },
|
|
78
|
+
fins: {
|
|
79
|
+
dorsal: [
|
|
80
|
+
{ u0: 0.3, u1: 0.55, n: 10, a0: 100, a1: 128, len: [0.1, 0.085], notch: 0.15, spiny: true },
|
|
81
|
+
{ u0: 0.55, u1: 0.88, n: 15, a0: 112, a1: 158, len: [0.16, 0.1], round: true },
|
|
82
|
+
],
|
|
83
|
+
anal: [{ u0: 0.62, u1: 0.85, n: 12, a0: 250, a1: 205, len: [0.15, 0.1], round: true }],
|
|
84
|
+
caudal: { len: 0.24, fork: -0.08, spread: 36, n: 17, lobe: 'rounded' },
|
|
85
|
+
pectoral: { u: 0.33, h: -0.035, len: 0.21, n: 14, sweep: 30, droop: 10, abduct: 35, shape: 'rounded' },
|
|
86
|
+
pelvic: { u: 0.38, len: 0.17, n: 6, sweep: 30, abduct: 30 },
|
|
87
|
+
},
|
|
88
|
+
spineSegs: 12, caudalSegs: 2,
|
|
89
|
+
scale: 0.004, gloss: 0.65, irid: 0.02,
|
|
90
|
+
colour: {
|
|
91
|
+
back: 0xe85a14, upper: 0xf26b1d, band: 0xf26b1d, lower: 0xf47a28, belly: 0xf58a38, spot: 0xf7f7f2,
|
|
92
|
+
fin: 0xf07a25, finEdge: 0x111111, head: 0xf26b1d, cheek: 0xf57d30, gill: 0x7a1c1c,
|
|
93
|
+
},
|
|
94
|
+
eye: { iris: [0x2a1004, 0xc2561a, 0xea8a3c, 0x0c0604] },
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Bluegill (Lepomis macrochirus): deep, strongly compressed disc, dark ear flap, vertical bars.
|
|
98
|
+
bluegill: {
|
|
99
|
+
name: 'Bluegill', latin: 'Lepomis macrochirus',
|
|
100
|
+
SL: 0.155, cellK: 1.38,
|
|
101
|
+
prof: [
|
|
102
|
+
[0.012, 0.03, 0.022, 0.014], [0.035, 0.072, 0.052, 0.028], [0.07, 0.12, 0.09, 0.043], [0.12, 0.168, 0.138, 0.06],
|
|
103
|
+
[0.2, 0.218, 0.196, 0.075], [0.3, 0.254, 0.228, 0.083], [0.4, 0.262, 0.238, 0.083], [0.5, 0.25, 0.224, 0.078],
|
|
104
|
+
[0.6, 0.222, 0.196, 0.07], [0.7, 0.178, 0.156, 0.058], [0.8, 0.124, 0.11, 0.044], [0.88, 0.087, 0.078, 0.033],
|
|
105
|
+
[0.95, 0.07, 0.065, 0.026], [1.0, 0.07, 0.067, 0.022],
|
|
106
|
+
],
|
|
107
|
+
head: { op: 0.315, occ: 0.25, eye: { u: 0.118, h: 0.065, r: 0.042 }, mouth: { h: -0.01, gape: 0.05, jawDepth: 0.035, upturn: 0.25 }, snout: 0.85, earFlap: 0.055 },
|
|
108
|
+
fins: {
|
|
109
|
+
dorsal: [
|
|
110
|
+
{ u0: 0.36, u1: 0.6, n: 10, a0: 104, a1: 125, len: [0.13, 0.12], notch: 0.25, spiny: true },
|
|
111
|
+
{ u0: 0.6, u1: 0.88, n: 12, a0: 112, a1: 160, len: [0.18, 0.1], round: true },
|
|
112
|
+
],
|
|
113
|
+
anal: [{ u0: 0.6, u1: 0.87, n: 13, a0: 252, a1: 205, len: [0.15, 0.1], round: true }],
|
|
114
|
+
caudal: { len: 0.23, fork: 0.1, spread: 36, n: 17, lobe: 'rounded' },
|
|
115
|
+
pectoral: { u: 0.33, h: -0.03, len: 0.28, n: 13, sweep: 25, droop: -12, abduct: 30, shape: 'sickle' },
|
|
116
|
+
pelvic: { u: 0.36, len: 0.15, n: 6, sweep: 30, abduct: 30, spine: true },
|
|
117
|
+
},
|
|
118
|
+
spineSegs: 12, caudalSegs: 3,
|
|
119
|
+
scale: 0.007, gloss: 0.55, irid: 0.1,
|
|
120
|
+
colour: {
|
|
121
|
+
back: 0x4a5236, upper: 0x6e7250, band: 0x76784e, lower: 0x9a8a50, belly: 0xd8b050, spot: 0x33362a,
|
|
122
|
+
fin: 0x55543c, finEdge: 0x4c4a36, head: 0x666a48, cheek: 0x4a5aa0, gill: 0x6e1c1c, ear: 0x0f0f12, breast: 0xd9722a,
|
|
123
|
+
},
|
|
124
|
+
eye: { iris: [0x1c0a06, 0x5e2418, 0x8a3c26, 0x120604] },
|
|
125
|
+
},
|
|
126
|
+
};
|