@bitefoundry/retrieviewer 0.0.3 → 0.0.5
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 +11 -0
- package/ASSETS-LICENSE.md +2 -1
- package/ATTRIBUTION.md +6 -1
- package/COMFORT-ART.md +95 -0
- package/DESKTOP-PLATFORMS.md +6 -1
- package/INSTALLING.md +4 -0
- package/PLUGIN.md +13 -10
- package/PREREQUISITES.md +95 -0
- package/PUPPY-MEMORY.md +102 -1
- package/README.ko.md +116 -0
- package/README.md +121 -59
- package/RELEASING.md +33 -13
- package/THIRD-PARTY-NOTICES.md +5 -3
- package/braille.mjs +35 -9
- package/examples/live.mjs +2 -2
- package/integrations/linux-overlay/overlay.py +8 -2
- package/integrations/macos-overlay/overlay.jxa +9 -7
- package/integrations/opencode/runtime.mjs +4 -4
- package/integrations/opencode/tui.tsx +1 -1
- package/integrations/windows-overlay/Overlay.cs +7 -6
- package/integrations/windows-overlay/desktop.mjs +2 -1
- package/integrations/windows-overlay/protocol.mjs +13 -7
- package/integrations/windows-overlay/worker.mjs +1 -1
- package/package.json +34 -13
- package/puppy-comfort-sprites.mjs +33 -0
- package/puppy-companion-comfort-q5.bin.gz +0 -0
- package/puppy-companion-comfort.json +140 -0
- package/puppy-companion-life.mjs +58 -18
- package/puppy-companion-objects.mjs +12 -0
- package/puppy-companion-sprites.mjs +4 -2
- package/puppy-frame-predictive.mjs +15 -9
- package/puppy-frame-store.mjs +2 -2
- package/puppy-paper-actions.mjs +4 -2
- package/puppy-paper-behaviors.mjs +1 -1
- package/puppy-paper-contact.mjs +4 -2
- package/puppy-paper-seat.mjs +4 -2
- package/puppy-paper-world.mjs +14 -0
- package/puppy-paper.mjs +79 -21
- package/retrieviewer-cli.mjs +8 -6
- package/retrieviewer-plugin.d.mts +1 -1
- package/retrieviewer-plugin.mjs +1 -1
- package/retrieviewer.d.mts +12 -4
- package/retrieviewer.mjs +20 -14
- package/locomotion-core.mjs +0 -21
- package/locomotion-puppy.animal +0 -0
- package/vendor/procedural-animals/package.json +0 -40
- package/vendor/procedural-animals/src/animal.js +0 -146
- package/vendor/procedural-animals/src/bake.js +0 -51
- package/vendor/procedural-animals/src/build.js +0 -81
- package/vendor/procedural-animals/src/core/build/coatKit.js +0 -121
- package/vendor/procedural-animals/src/core/build/featherCards.js +0 -189
- package/vendor/procedural-animals/src/core/build/finEdges.js +0 -85
- package/vendor/procedural-animals/src/core/build/furSlope.js +0 -115
- package/vendor/procedural-animals/src/core/build/mesh.js +0 -67
- package/vendor/procedural-animals/src/core/build/pipeline.js +0 -272
- package/vendor/procedural-animals/src/core/build/seams.js +0 -183
- package/vendor/procedural-animals/src/core/build/warp.js +0 -112
- package/vendor/procedural-animals/src/core/build/weights.js +0 -393
- package/vendor/procedural-animals/src/core/math/vec.js +0 -81
- package/vendor/procedural-animals/src/core/motion/actions.js +0 -800
- package/vendor/procedural-animals/src/core/motion/bird.js +0 -3063
- package/vendor/procedural-animals/src/core/motion/birdActions.js +0 -1059
- package/vendor/procedural-animals/src/core/motion/common.js +0 -158
- package/vendor/procedural-animals/src/core/motion/index.js +0 -22
- package/vendor/procedural-animals/src/core/motion/quadruped.js +0 -2875
- package/vendor/procedural-animals/src/core/motion/snake.js +0 -1594
- package/vendor/procedural-animals/src/core/motion/spider.js +0 -1810
- package/vendor/procedural-animals/src/core/motion/swimmer.js +0 -1047
- package/vendor/procedural-animals/src/core/motion/swimmerActions.js +0 -613
- package/vendor/procedural-animals/src/core/render/animalObject.js +0 -262
- package/vendor/procedural-animals/src/core/render/coatMaterial.js +0 -1301
- package/vendor/procedural-animals/src/core/render/dqs.js +0 -159
- package/vendor/procedural-animals/src/core/render/eyes.js +0 -676
- package/vendor/procedural-animals/src/core/render/membranes.js +0 -77
- package/vendor/procedural-animals/src/core/render/skeleton.js +0 -41
- package/vendor/procedural-animals/src/core/rig/bird.js +0 -327
- package/vendor/procedural-animals/src/core/rig/quadruped.js +0 -76
- package/vendor/procedural-animals/src/core/rig/rig.js +0 -79
- package/vendor/procedural-animals/src/core/rig/snake.js +0 -76
- package/vendor/procedural-animals/src/core/rig/spider.js +0 -110
- package/vendor/procedural-animals/src/core/rig/swimmer.js +0 -181
- package/vendor/procedural-animals/src/core/sdf/eyeSocket.js +0 -53
- package/vendor/procedural-animals/src/core/sdf/mesher.js +0 -238
- package/vendor/procedural-animals/src/core/sdf/sdf.js +0 -263
- package/vendor/procedural-animals/src/index.d.ts +0 -98
- package/vendor/procedural-animals/src/index.js +0 -29
- package/vendor/procedural-animals/src/registry.js +0 -48
- package/vendor/procedural-animals/src/species/bear/behaviour.js +0 -463
- package/vendor/procedural-animals/src/species/bear/claws.js +0 -147
- package/vendor/procedural-animals/src/species/bear/coat.js +0 -726
- package/vendor/procedural-animals/src/species/bear/index.js +0 -139
- package/vendor/procedural-animals/src/species/bear/motion.js +0 -112
- package/vendor/procedural-animals/src/species/bear/regions.js +0 -78
- package/vendor/procedural-animals/src/species/bear/rig.js +0 -112
- package/vendor/procedural-animals/src/species/bear/sculpt.js +0 -272
- package/vendor/procedural-animals/src/species/boar/behaviour.js +0 -335
- package/vendor/procedural-animals/src/species/boar/coat.js +0 -372
- package/vendor/procedural-animals/src/species/boar/index.js +0 -110
- package/vendor/procedural-animals/src/species/boar/motion.js +0 -85
- package/vendor/procedural-animals/src/species/boar/regions.js +0 -88
- package/vendor/procedural-animals/src/species/boar/rig.js +0 -111
- package/vendor/procedural-animals/src/species/boar/sculpt.js +0 -285
- package/vendor/procedural-animals/src/species/cat/behaviour.js +0 -559
- package/vendor/procedural-animals/src/species/cat/coat.js +0 -841
- package/vendor/procedural-animals/src/species/cat/index.js +0 -211
- package/vendor/procedural-animals/src/species/cat/motion.js +0 -101
- package/vendor/procedural-animals/src/species/cat/regions.js +0 -82
- package/vendor/procedural-animals/src/species/cat/rig.js +0 -100
- package/vendor/procedural-animals/src/species/cat/sculpt.js +0 -266
- package/vendor/procedural-animals/src/species/cat/whiskers.js +0 -110
- package/vendor/procedural-animals/src/species/cheetah/coat.js +0 -427
- package/vendor/procedural-animals/src/species/cheetah/index.js +0 -51
- package/vendor/procedural-animals/src/species/cheetah/joints.js +0 -3
- package/vendor/procedural-animals/src/species/cheetah/motion.js +0 -77
- package/vendor/procedural-animals/src/species/cheetah/regions.js +0 -95
- package/vendor/procedural-animals/src/species/cheetah/rig.js +0 -66
- package/vendor/procedural-animals/src/species/cheetah/sculpt.js +0 -158
- package/vendor/procedural-animals/src/species/chicken/coat.js +0 -313
- package/vendor/procedural-animals/src/species/chicken/coverts.js +0 -320
- package/vendor/procedural-animals/src/species/chicken/index.js +0 -110
- package/vendor/procedural-animals/src/species/chicken/motion.js +0 -177
- package/vendor/procedural-animals/src/species/chicken/regions.js +0 -66
- package/vendor/procedural-animals/src/species/chicken/rig.js +0 -144
- package/vendor/procedural-animals/src/species/chicken/sculpt.js +0 -389
- package/vendor/procedural-animals/src/species/chicken/wingLook.js +0 -66
- package/vendor/procedural-animals/src/species/chicken/wingStack.js +0 -124
- package/vendor/procedural-animals/src/species/cow/behaviour.js +0 -521
- package/vendor/procedural-animals/src/species/cow/coat.js +0 -465
- package/vendor/procedural-animals/src/species/cow/index.js +0 -118
- package/vendor/procedural-animals/src/species/cow/motion.js +0 -81
- package/vendor/procedural-animals/src/species/cow/regions.js +0 -98
- package/vendor/procedural-animals/src/species/cow/rig.js +0 -116
- package/vendor/procedural-animals/src/species/cow/sculpt.js +0 -339
- package/vendor/procedural-animals/src/species/crow/coat.js +0 -145
- package/vendor/procedural-animals/src/species/crow/index.js +0 -70
- package/vendor/procedural-animals/src/species/crow/joints.js +0 -3
- package/vendor/procedural-animals/src/species/crow/motion.js +0 -101
- package/vendor/procedural-animals/src/species/crow/regions.js +0 -50
- package/vendor/procedural-animals/src/species/crow/rig.js +0 -83
- package/vendor/procedural-animals/src/species/crow/sculpt.js +0 -118
- package/vendor/procedural-animals/src/species/deer/behaviour.js +0 -513
- package/vendor/procedural-animals/src/species/deer/coat.js +0 -391
- package/vendor/procedural-animals/src/species/deer/index.js +0 -106
- package/vendor/procedural-animals/src/species/deer/motion.js +0 -97
- package/vendor/procedural-animals/src/species/deer/regions.js +0 -60
- package/vendor/procedural-animals/src/species/deer/rig.js +0 -124
- package/vendor/procedural-animals/src/species/deer/sculpt.js +0 -297
- package/vendor/procedural-animals/src/species/dog/behaviour.js +0 -521
- package/vendor/procedural-animals/src/species/dog/coat.js +0 -495
- package/vendor/procedural-animals/src/species/dog/index.js +0 -144
- package/vendor/procedural-animals/src/species/dog/motion.js +0 -118
- package/vendor/procedural-animals/src/species/dog/regions.js +0 -61
- package/vendor/procedural-animals/src/species/dog/rig.js +0 -129
- package/vendor/procedural-animals/src/species/dog/sculpt.js +0 -246
- package/vendor/procedural-animals/src/species/eagle/coat.js +0 -250
- package/vendor/procedural-animals/src/species/eagle/index.js +0 -76
- package/vendor/procedural-animals/src/species/eagle/joints.js +0 -3
- package/vendor/procedural-animals/src/species/eagle/motion.js +0 -137
- package/vendor/procedural-animals/src/species/eagle/regions.js +0 -57
- package/vendor/procedural-animals/src/species/eagle/rig.js +0 -107
- package/vendor/procedural-animals/src/species/eagle/sculpt.js +0 -137
- package/vendor/procedural-animals/src/species/fish/coat.js +0 -271
- package/vendor/procedural-animals/src/species/fish/index.js +0 -88
- package/vendor/procedural-animals/src/species/fish/motion.js +0 -92
- package/vendor/procedural-animals/src/species/fish/regions.js +0 -27
- package/vendor/procedural-animals/src/species/fish/rig.js +0 -143
- package/vendor/procedural-animals/src/species/fish/sculpt.js +0 -214
- package/vendor/procedural-animals/src/species/fish/variants.js +0 -126
- package/vendor/procedural-animals/src/species/fox/behaviour.js +0 -314
- package/vendor/procedural-animals/src/species/fox/coat.js +0 -444
- package/vendor/procedural-animals/src/species/fox/index.js +0 -120
- package/vendor/procedural-animals/src/species/fox/motion.js +0 -81
- package/vendor/procedural-animals/src/species/fox/regions.js +0 -59
- package/vendor/procedural-animals/src/species/fox/rig.js +0 -91
- package/vendor/procedural-animals/src/species/fox/sculpt.js +0 -202
- package/vendor/procedural-animals/src/species/frog/behaviour.js +0 -590
- package/vendor/procedural-animals/src/species/frog/coat.js +0 -305
- package/vendor/procedural-animals/src/species/frog/index.js +0 -97
- package/vendor/procedural-animals/src/species/frog/motion.js +0 -69
- package/vendor/procedural-animals/src/species/frog/regions.js +0 -46
- package/vendor/procedural-animals/src/species/frog/rig.js +0 -156
- package/vendor/procedural-animals/src/species/frog/sculpt.js +0 -240
- package/vendor/procedural-animals/src/species/goat/behaviour.js +0 -509
- package/vendor/procedural-animals/src/species/goat/coat.js +0 -590
- package/vendor/procedural-animals/src/species/goat/index.js +0 -149
- package/vendor/procedural-animals/src/species/goat/motion.js +0 -95
- package/vendor/procedural-animals/src/species/goat/regions.js +0 -98
- package/vendor/procedural-animals/src/species/goat/rig.js +0 -181
- package/vendor/procedural-animals/src/species/goat/sculpt.js +0 -547
- package/vendor/procedural-animals/src/species/horse/coat.js +0 -361
- package/vendor/procedural-animals/src/species/horse/coatSeam.js +0 -122
- package/vendor/procedural-animals/src/species/horse/index.js +0 -80
- package/vendor/procedural-animals/src/species/horse/motion.js +0 -245
- package/vendor/procedural-animals/src/species/horse/regions.js +0 -60
- package/vendor/procedural-animals/src/species/horse/rig.js +0 -117
- package/vendor/procedural-animals/src/species/horse/sculpt.js +0 -316
- package/vendor/procedural-animals/src/species/horse/seamWeights.js +0 -272
- package/vendor/procedural-animals/src/species/lion/behaviour.js +0 -509
- package/vendor/procedural-animals/src/species/lion/coat.js +0 -1016
- package/vendor/procedural-animals/src/species/lion/index.js +0 -111
- package/vendor/procedural-animals/src/species/lion/motion.js +0 -87
- package/vendor/procedural-animals/src/species/lion/regions.js +0 -106
- package/vendor/procedural-animals/src/species/lion/rig.js +0 -110
- package/vendor/procedural-animals/src/species/lion/sculpt.js +0 -384
- package/vendor/procedural-animals/src/species/lion/whiskers.js +0 -132
- package/vendor/procedural-animals/src/species/pig/behaviour.js +0 -575
- package/vendor/procedural-animals/src/species/pig/coat.js +0 -730
- package/vendor/procedural-animals/src/species/pig/ears.js +0 -242
- package/vendor/procedural-animals/src/species/pig/index.js +0 -161
- package/vendor/procedural-animals/src/species/pig/motion.js +0 -105
- package/vendor/procedural-animals/src/species/pig/regions.js +0 -100
- package/vendor/procedural-animals/src/species/pig/rig.js +0 -152
- package/vendor/procedural-animals/src/species/pig/sculpt.js +0 -382
- package/vendor/procedural-animals/src/species/rabbit/behaviour.js +0 -605
- package/vendor/procedural-animals/src/species/rabbit/coat.js +0 -285
- package/vendor/procedural-animals/src/species/rabbit/index.js +0 -85
- package/vendor/procedural-animals/src/species/rabbit/motion.js +0 -85
- package/vendor/procedural-animals/src/species/rabbit/regions.js +0 -48
- package/vendor/procedural-animals/src/species/rabbit/rig.js +0 -99
- package/vendor/procedural-animals/src/species/rabbit/sculpt.js +0 -148
- package/vendor/procedural-animals/src/species/rat/behaviour.js +0 -539
- package/vendor/procedural-animals/src/species/rat/coat.js +0 -341
- package/vendor/procedural-animals/src/species/rat/index.js +0 -111
- package/vendor/procedural-animals/src/species/rat/motion.js +0 -90
- package/vendor/procedural-animals/src/species/rat/regions.js +0 -92
- package/vendor/procedural-animals/src/species/rat/rig.js +0 -112
- package/vendor/procedural-animals/src/species/rat/sculpt.js +0 -163
- package/vendor/procedural-animals/src/species/rat/whiskers.js +0 -119
- package/vendor/procedural-animals/src/species/shark/coat.js +0 -383
- package/vendor/procedural-animals/src/species/shark/index.js +0 -104
- package/vendor/procedural-animals/src/species/shark/motion.js +0 -69
- package/vendor/procedural-animals/src/species/shark/regions.js +0 -34
- package/vendor/procedural-animals/src/species/shark/rig.js +0 -194
- package/vendor/procedural-animals/src/species/shark/sculpt.js +0 -343
- package/vendor/procedural-animals/src/species/shark/variants.js +0 -105
- package/vendor/procedural-animals/src/species/sheep/behaviour.js +0 -522
- package/vendor/procedural-animals/src/species/sheep/coat.js +0 -529
- package/vendor/procedural-animals/src/species/sheep/index.js +0 -152
- package/vendor/procedural-animals/src/species/sheep/motion.js +0 -86
- package/vendor/procedural-animals/src/species/sheep/neck.js +0 -41
- package/vendor/procedural-animals/src/species/sheep/regions.js +0 -62
- package/vendor/procedural-animals/src/species/sheep/rig.js +0 -163
- package/vendor/procedural-animals/src/species/sheep/sculpt.js +0 -542
- package/vendor/procedural-animals/src/species/snake/coat.js +0 -315
- package/vendor/procedural-animals/src/species/snake/index.js +0 -73
- package/vendor/procedural-animals/src/species/snake/motion.js +0 -51
- package/vendor/procedural-animals/src/species/snake/regions.js +0 -51
- package/vendor/procedural-animals/src/species/snake/rig.js +0 -108
- package/vendor/procedural-animals/src/species/snake/sculpt.js +0 -122
- package/vendor/procedural-animals/src/species/spider/coat.js +0 -279
- package/vendor/procedural-animals/src/species/spider/index.js +0 -78
- package/vendor/procedural-animals/src/species/spider/motion.js +0 -72
- package/vendor/procedural-animals/src/species/spider/regions.js +0 -87
- package/vendor/procedural-animals/src/species/spider/rig.js +0 -118
- package/vendor/procedural-animals/src/species/spider/sculpt.js +0 -182
- package/vendor/procedural-animals/src/species/wolf/behaviour.js +0 -160
- package/vendor/procedural-animals/src/species/wolf/coat.js +0 -749
- package/vendor/procedural-animals/src/species/wolf/index.js +0 -107
- package/vendor/procedural-animals/src/species/wolf/motion.js +0 -80
- package/vendor/procedural-animals/src/species/wolf/regions.js +0 -57
- package/vendor/procedural-animals/src/species/wolf/rig.js +0 -87
- package/vendor/procedural-animals/src/species/wolf/sculpt.js +0 -339
- package/vendor/procedural-animals/src/worker.js +0 -29
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
// Shark coat: dermal denticles (material 6 with a sub-millimetre feature size and weak rims: a matte,
|
|
2
|
-
// sandpaper skin, no visible scales), countershading with a crisp ragged boundary (the pattern SDF,
|
|
3
|
-
// white belly), fin colours (white shark: pale pectoral undersides with black tips; blacktip reef: the
|
|
4
|
-
// black tips of every fin and the pale band under the dorsal tip, as crisp marks), the blacktip's
|
|
5
|
-
// white flank wedge, gill slits and ampullae pores as marks, seeded scars, gums, mouth and teeth.
|
|
6
|
-
import { SDFModel } from '../../core/sdf/sdf.js';
|
|
7
|
-
import { norm, sub, dot, clamp, smoothstep, rng, fbm3, add, mul, cross } from '../../core/math/vec.js';
|
|
8
|
-
import { srgb, mix3, MAT, distPolyline, poissonFeatures, featureDistance, projectToSurface } from '../../core/build/coatKit.js';
|
|
9
|
-
import { sharkGeo } from './rig.js';
|
|
10
|
-
import { CELL } from './sculpt.js';
|
|
11
|
-
|
|
12
|
-
// body kinds
|
|
13
|
-
const K_BODY = 0, K_FIN = 2, K_MOUTH = 3, K_GILL = 4, K_TOOTH = 5, K_GUM = 6, K_DARK = 8, K_CUT = 9;
|
|
14
|
-
|
|
15
|
-
export function sharkCoat(ctx) {
|
|
16
|
-
const { pos, nrm, nV, lists, regionOf, regionNames, params } = ctx;
|
|
17
|
-
const G = sharkGeo(params);
|
|
18
|
-
const V = G.V, TL = G.TL, H = V.head;
|
|
19
|
-
const key = params.variant;
|
|
20
|
-
const white = key === 'white';
|
|
21
|
-
const R = rng(7331 + (params.coatSeed || 0));
|
|
22
|
-
const col = {};
|
|
23
|
-
for (const [k, hex] of Object.entries(V.colour)) if (typeof hex === 'number') col[k] = srgb(hex);
|
|
24
|
-
// individual tone: one of the species' dorsal tones, then a small shade shift
|
|
25
|
-
const tones = V.colour.tones;
|
|
26
|
-
const tone = srgb(tones[Math.min(tones.length - 1, params.tone | 0)][0]);
|
|
27
|
-
const shade = params.coatShade || 0;
|
|
28
|
-
const back = tone.map((x) => x * (1 + 0.14 * shade));
|
|
29
|
-
const flank = mix3(col.flank, back, 0.35).map((x) => x * (1 + 0.1 * shade));
|
|
30
|
-
const cell = TL * CELL * (V.cellK || 1);
|
|
31
|
-
// per-individual offsets of the noise fields (ragged boundary, mottling) and of the boundary height
|
|
32
|
-
const ox = ((params.coatSeed || 0) % 997) * 0.731, oy = ((params.coatSeed || 0) % 991) * 0.377;
|
|
33
|
-
const bShift = params.bndShift || 0;
|
|
34
|
-
|
|
35
|
-
const comb = new Float32Array(nV * 3);
|
|
36
|
-
const tint = new Float32Array(nV * 4);
|
|
37
|
-
const pattern = new Float32Array(nV).fill(1);
|
|
38
|
-
const patternColor = new Float32Array(nV * 4);
|
|
39
|
-
const mark = new Float32Array(nV).fill(1);
|
|
40
|
-
const furLen = new Float32Array(nV);
|
|
41
|
-
const surf = new Float32Array(nV * 4);
|
|
42
|
-
// the skin without fins and carvers: lines laid out on the outline (G.flank) are projected onto it
|
|
43
|
-
// (the smooth unions of the sections stand a few millimetres proud of the outline)
|
|
44
|
-
const skinPrims = ctx.model.forPart('body').filter((pr) => !pr.carve && (pr.tag === 'head' || pr.tag === 'body' || pr.tag === 'keel'));
|
|
45
|
-
const onSkin = (q) => projectToSurface(skinPrims, q, 4);
|
|
46
|
-
const rJaw = regionNames.indexOf('jaw'), rUT = regionNames.indexOf('uteeth'), rLT = regionNames.indexOf('lteeth');
|
|
47
|
-
|
|
48
|
-
// ---- seeded scars (long pale crescents read as marks drawn on the skin):
|
|
49
|
-
// short, thin, faint scratches on the grey flank and head, and on adults a few healed tooth rakes
|
|
50
|
-
// (3-5 short parallel scratches); the blacktip carries at most one or two
|
|
51
|
-
const scars = [];
|
|
52
|
-
const nScar = white ? Math.round((params.scarK ?? 1) * (1.5 + 3.5 * R())) : (R() < 0.35 * (params.scarK ?? 1) ? 1 : 0);
|
|
53
|
-
const addScratch = (u0, e0, s, ang, l, w, k) => {
|
|
54
|
-
const pts = [];
|
|
55
|
-
const n = 4;
|
|
56
|
-
for (let j = 0; j <= n; j++) {
|
|
57
|
-
const f = j / n;
|
|
58
|
-
const du = (Math.cos(ang) * (f - 0.5) * l) / TL;
|
|
59
|
-
const de = (Math.sin(ang) * (f - 0.5) * l) / Math.max(0.01 * TL, G.hd(u0));
|
|
60
|
-
pts.push(onSkin(G.flank(clamp(u0 + du, 0.03, G.pc), clamp(e0 + de, -0.6, 0.95), s)));
|
|
61
|
-
}
|
|
62
|
-
scars.push({ pts, w: pts.map((_, j) => w * (j === 0 || j === n ? 0.35 : 1)), s, k });
|
|
63
|
-
};
|
|
64
|
-
for (let i = 0; i < nScar; i++) {
|
|
65
|
-
const s = R() < 0.5 ? 1 : -1;
|
|
66
|
-
const u0 = 0.1 + 0.55 * R(), e0 = 0.05 + 0.7 * R();
|
|
67
|
-
const ang = (R() - 0.5) * 1.4;
|
|
68
|
-
const w = (0.0011 + 0.0007 * R()) * TL;
|
|
69
|
-
const k = 0.22 + 0.18 * R();
|
|
70
|
-
if (white && R() < 0.3) {
|
|
71
|
-
// healed tooth rake: short parallel scratches across a bite arc
|
|
72
|
-
const nR = 3 + Math.floor(R() * 3), l = (0.008 + 0.006 * R()) * TL, gap = 0.006 * TL;
|
|
73
|
-
for (let j = 0; j < nR; j++) addScratch(u0 + ((j - nR / 2) * gap * Math.cos(ang)) / TL, e0 + ((j - nR / 2) * gap * Math.sin(ang)) / Math.max(0.01 * TL, G.hd(u0)), s, ang + Math.PI / 2, l * (0.8 + 0.4 * R()), w * 0.9, k);
|
|
74
|
-
} else addScratch(u0, e0, s, ang, (0.012 + 0.03 * R()) * TL, w, k);
|
|
75
|
-
}
|
|
76
|
-
// gill slits (polylines on both sides, as in the sculpt)
|
|
77
|
-
const slits = [];
|
|
78
|
-
{
|
|
79
|
-
const Gi = H.gills;
|
|
80
|
-
for (const s of [1, -1]) {
|
|
81
|
-
for (let i = 0; i < Gi.n; i++) {
|
|
82
|
-
const u = Gi.u0 + ((Gi.u1 - Gi.u0) * i) / (Gi.n - 1);
|
|
83
|
-
const len = 1 - 0.18 * Math.abs(i - (Gi.n - 1) * 0.6) / Gi.n;
|
|
84
|
-
const pts = [];
|
|
85
|
-
for (let j = 0; j <= 6; j++) {
|
|
86
|
-
const e = Gi.e0 + ((Gi.e1 - Gi.e0) * len * j) / 6;
|
|
87
|
-
pts.push(onSkin(G.flank(u - Gi.lean * (e - Gi.e0), e, s)));
|
|
88
|
-
}
|
|
89
|
-
const w = Math.max((white ? 0.0013 : 0.0009) * TL, (white ? 0.45 : 0.35) * cell * ((ctx.Q && ctx.Q.res) || 1));
|
|
90
|
-
slits.push({ pts, w: pts.map((_, j) => w * (j === 0 || j === 6 ? 0.45 : 1)) });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// nostrils (a dark carved cup reads as a second eye): a thin dark oblique slit on the
|
|
96
|
-
// shallow groove, as a crisp mark
|
|
97
|
-
const nostrils = [];
|
|
98
|
-
for (const s of [1, -1]) {
|
|
99
|
-
const c0 = G.flank(H.nostril.u, H.nostril.e, s), ax = norm([s * 0.5, 0, 1]);
|
|
100
|
-
const pts = [-1, -0.5, 0, 0.5, 1].map((f) => onSkin(add(c0, mul(ax, f * 0.0075 * TL))));
|
|
101
|
-
const w = Math.max(0.0007 * TL, 0.3 * cell);
|
|
102
|
-
nostrils.push({ pts, w: pts.map((_, j) => w * (j === 0 || j === 4 ? 0.3 : j === 2 ? 1 : 0.8)) });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// ---- classify every vertex
|
|
106
|
-
const kind = new Uint8Array(nV);
|
|
107
|
-
const finOf = new Array(nV);
|
|
108
|
-
const wFin = new Float32Array(nV);
|
|
109
|
-
for (let v = 0; v < nV; v++) {
|
|
110
|
-
const reg = regionOf[v];
|
|
111
|
-
if (reg === rUT || reg === rLT) { kind[v] = K_TOOTH; continue; }
|
|
112
|
-
const p = [pos[v * 3], pos[v * 3 + 1], pos[v * 3 + 2]];
|
|
113
|
-
const n = [nrm[v * 3], nrm[v * 3 + 1], nrm[v * 3 + 2]];
|
|
114
|
-
let bestF = null, dF = 1e9, dB = 1e9, carveHit = null;
|
|
115
|
-
for (const pr of lists[v]) {
|
|
116
|
-
const d = SDFModel.dist(pr, p[0], p[1], p[2]);
|
|
117
|
-
if (pr.carve) { if (Math.abs(d) < cell * 0.9 && (!carveHit || Math.abs(d) < carveHit.d)) carveHit = { pr, d: Math.abs(d) }; continue; }
|
|
118
|
-
const isFin = pr.tag === 'fin' || pr.tag === 'finCore' || pr.tag === 'clasper';
|
|
119
|
-
if (isFin) { if (d < dF) { dF = d; bestF = pr; } } else if (pr.tag !== 'pecBase' && d < dB) dB = d;
|
|
120
|
-
}
|
|
121
|
-
let k = K_BODY;
|
|
122
|
-
if (bestF) {
|
|
123
|
-
// continuous fin share: the fin colours blend into the body's over a short fillet (no jagged
|
|
124
|
-
// border where the nearest primitive switches)
|
|
125
|
-
finOf[v] = bestF;
|
|
126
|
-
wFin[v] = smoothstep(-0.25, 1, (dB - dF) / (0.012 * TL));
|
|
127
|
-
if (wFin[v] > 0.5) k = K_FIN;
|
|
128
|
-
}
|
|
129
|
-
if (carveHit) {
|
|
130
|
-
const tg = carveHit.pr.tag;
|
|
131
|
-
if (tg === 'gillslit') k = K_BODY;
|
|
132
|
-
else if (tg === 'mouthcut' || tg === 'jawcut') k = G.u(p[2]) > H.mouth.uC + 0.004 ? K_BODY : K_CUT;
|
|
133
|
-
else if (tg === 'mouth') k = K_MOUTH;
|
|
134
|
-
else if (tg === 'eyesocket') k = K_DARK;
|
|
135
|
-
else if (tg === 'nostril') k = K_BODY;
|
|
136
|
-
}
|
|
137
|
-
kind[v] = k;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ampullae of Lorenzini: dark pores on the underside and sides of the snout
|
|
141
|
-
const pores = poissonFeatures({
|
|
142
|
-
pos, nrm, nV, R,
|
|
143
|
-
radius: (v) => {
|
|
144
|
-
if (kind[v] !== K_BODY) return 0;
|
|
145
|
-
const u = G.u(pos[v * 3 + 2]);
|
|
146
|
-
if (u > 0.085 || u < 0.006) return 0;
|
|
147
|
-
const e = (pos[v * 3 + 1] - G.yc(u)) / Math.max(1e-6, G.hd(u));
|
|
148
|
-
return e < 0.35 ? (white ? 0.0011 : 0.0012) * TL : 0;
|
|
149
|
-
},
|
|
150
|
-
spacing: 3.2, gap: 0.004 * TL, cell: 0.02 * TL,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
const bnd = V.boundary;
|
|
154
|
-
// boundary height (fraction of the half depth) of the pale belly along the body
|
|
155
|
-
const eBound = (u) => {
|
|
156
|
-
if (white) {
|
|
157
|
-
// from below the eye through the mouth corner, dipping under the pectoral, rising to the peduncle
|
|
158
|
-
const tbl = [[0, -0.9], [0.03, -0.55], [0.06, -0.32], [0.12, -0.3], [0.2, -0.26], [0.28, -0.3], [0.36, -0.14], [0.46, -0.08], [0.56, 0.0], [0.66, 0.02], [0.74, 0.1], [0.8, 0.14]];
|
|
159
|
-
return lerpTable(tbl, u) + bnd.e + 0.12;
|
|
160
|
-
}
|
|
161
|
-
const tbl = [[0, -0.5], [0.08, -0.42], [0.18, -0.4], [0.3, -0.42], [0.45, -0.38], [0.6, -0.3], [0.72, -0.2], [0.8, -0.1]];
|
|
162
|
-
return lerpTable(tbl, u) + bnd.e + 0.3;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
for (let v = 0; v < nV; v++) {
|
|
166
|
-
const o3 = v * 3, o4 = v * 4;
|
|
167
|
-
const p = [pos[o3], pos[o3 + 1], pos[o3 + 2]];
|
|
168
|
-
const n = [nrm[o3], nrm[o3 + 1], nrm[o3 + 2]];
|
|
169
|
-
const k = kind[v];
|
|
170
|
-
const u = clamp(G.u(p[2]), 0, 1.3);
|
|
171
|
-
const uc = Math.min(u, G.pc);
|
|
172
|
-
// height on the flank as a fraction of the half depth (held at a minimum depth at the snout tip,
|
|
173
|
-
// where the section shrinks to a point: the tip is grey above, pale below, not a pale blob)
|
|
174
|
-
const e = (p[1] - G.yc(uc)) / Math.max(G.hd(uc), 0.03 * TL);
|
|
175
|
-
// mottling: broad cloudy patches, smaller blotches and fine flecks (stronger on the back)
|
|
176
|
-
const m1 = fbm3(p[0] * 6 / TL + ox, p[1] * 6 / TL, p[2] * 6 / TL + oy, 3) - 0.5;
|
|
177
|
-
const m2 = fbm3(p[0] * 22 / TL + oy, p[1] * 22 / TL + 4.1, p[2] * 22 / TL + ox, 3) - 0.5;
|
|
178
|
-
const m3 = fbm3(p[0] * 90 / TL + 7.7, p[1] * 90 / TL + ox, p[2] * 90 / TL + oy, 2) - 0.5;
|
|
179
|
-
// denticles lie nose -> tail
|
|
180
|
-
let cm = norm(sub([0, 0, -1], mul(n, -n[2])));
|
|
181
|
-
if (!Number.isFinite(cm[0])) cm = [0, 0, -1];
|
|
182
|
-
let c, mat = MAT.SCALES, gl = V.gloss, sz = V.denticle;
|
|
183
|
-
if (k === K_TOOTH) {
|
|
184
|
-
c = col.tooth;
|
|
185
|
-
tint.set([c[0], c[1], c[2], MAT.KERATIN], o4);
|
|
186
|
-
comb.set([0, 1, 0], o3);
|
|
187
|
-
surf.set([0.75, 0, 0, 0], o4);
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (k === K_MOUTH || k === K_CUT) {
|
|
191
|
-
// (not a red-gummed band) the lip line itself is a dark, neutral crease; only the
|
|
192
|
-
// inside of the mouth, seen when the jaws open, is dark pink
|
|
193
|
-
c = k === K_CUT ? mix3(back.map((x) => x * 0.22), col.mouth, 0.25) : col.mouth;
|
|
194
|
-
tint.set([c[0], c[1], c[2], MAT.SKIN], o4);
|
|
195
|
-
comb.set(cm, o3);
|
|
196
|
-
surf.set([0.6, 0, 0, 0], o4);
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (k === K_GUM) {
|
|
200
|
-
c = col.gum;
|
|
201
|
-
tint.set([c[0], c[1], c[2], MAT.SKIN], o4);
|
|
202
|
-
comb.set(cm, o3);
|
|
203
|
-
surf.set([0.65, 0, 0, 0], o4);
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
if (k === K_DARK || k === K_GILL) {
|
|
207
|
-
c = k === K_GILL ? col.gill : [0.012, 0.011, 0.011];
|
|
208
|
-
tint.set([c[0], c[1], c[2], MAT.SKIN], o4);
|
|
209
|
-
comb.set(cm, o3);
|
|
210
|
-
surf.set([0.3, 0, 0, 0], o4);
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
// ---------------- skin: body, head, jaw and fins
|
|
214
|
-
const up = smoothstep(-0.6, 1.0, e * 0.8 + n[1] * 0.45);
|
|
215
|
-
c = mix3(flank, back, up);
|
|
216
|
-
// body pattern: the pale belly below a crisp, ragged boundary
|
|
217
|
-
// (domain-warped noise at three scales: long tongues of grey reaching down, white notches up, and a
|
|
218
|
-
// jagged fine edge; near the peduncle the line breaks up into patches)
|
|
219
|
-
const wq = (fbm3(p[0] * 9 / TL + ox, p[1] * 9 / TL + 2.3, p[2] * 9 / TL + oy, 2) - 0.5) * 0.06 * TL;
|
|
220
|
-
const q0 = p[0] + wq, q1 = p[1] - wq, q2 = p[2] + wq * 1.7;
|
|
221
|
-
const ragK = 1 + 0.8 * smoothstep(0.55, 0.78, uc);
|
|
222
|
-
const rag = ragK * (bnd.rag * (fbm3(q0 * 14 / TL + 3.1 + ox, q1 * 14 / TL + oy, q2 * 14 / TL, 3) - 0.5) * 2
|
|
223
|
-
+ bnd.rag * 0.8 * (fbm3(q0 * 38 / TL + oy, q1 * 38 / TL + 1.7, q2 * 38 / TL + ox, 3) - 0.5)
|
|
224
|
-
+ bnd.rag * 0.45 * (fbm3(q0 * 95 / TL + 5.3, q1 * 95 / TL + ox, q2 * 95 / TL + oy, 2) - 0.5));
|
|
225
|
-
let belly = (e - (eBound(uc) + rag + bShift * smoothstep(0.08, 0.2, uc))) * Math.max(G.hd(uc), 0.03 * TL) * 0.6;
|
|
226
|
-
const cBody0 = c;
|
|
227
|
-
let cFin = null, bellyFin = 0;
|
|
228
|
-
if (finOf[v] && wFin[v] > 0.001) {
|
|
229
|
-
const pr = finOf[v];
|
|
230
|
-
const nm = pr.finName || 'clasper';
|
|
231
|
-
const f2 = pr.fin2;
|
|
232
|
-
const q = f2 ? sub(p, f2.origin) : [0, 0, 0];
|
|
233
|
-
const a = f2 ? dot(q, f2.u) : 0, b = f2 ? dot(q, f2.v) : 0;
|
|
234
|
-
let polyMaxA = 0, polyMaxB = -1e9, polyMinB = 1e9;
|
|
235
|
-
if (f2) for (const pp of f2.poly) { polyMaxA = Math.max(polyMaxA, pp[0]); polyMaxB = Math.max(polyMaxB, pp[1]); polyMinB = Math.min(polyMinB, pp[1]); }
|
|
236
|
-
cm = norm(sub(cm, mul(n, dot(cm, n))));
|
|
237
|
-
bellyFin = 0.01 * TL;
|
|
238
|
-
if (nm.startsWith('pectoral') || nm.startsWith('pelvic')) {
|
|
239
|
-
// pale undersides of the paired fins: only the flat of the underside, read against the fin's own
|
|
240
|
-
// plane (a test on the world normal wrapped the pale underside round the rounded
|
|
241
|
-
// edge into a pale rim, a fat sausage edge seen from the front). The whole rim stays grey, as on
|
|
242
|
-
// the real fins (the white shark's pectoral underside has a dark margin).
|
|
243
|
-
const nF = norm(cross(f2.u, f2.v));
|
|
244
|
-
const nd = dot(n, nF) * (nF[1] >= 0 ? 1 : -1);
|
|
245
|
-
const wU = smoothstep(-0.6, -0.85, nd);
|
|
246
|
-
c = mix3(mix3(back, flank, 0.15), mix3(c, col.finUnder, white ? 0.9 : 0.8), wU);
|
|
247
|
-
bellyFin = clamp((nd + 0.74) * 0.03 * TL, -0.01 * TL, 0.01 * TL);
|
|
248
|
-
const span = polyMaxA;
|
|
249
|
-
if (white && nm.startsWith('pectoral')) {
|
|
250
|
-
// black blotch at the ventral tip, dusky trailing margin (underside only)
|
|
251
|
-
mark[v] = Math.min(mark[v], Math.max((0.86 * span - a) * 0.5, (nd + 0.74) * 0.03 * TL));
|
|
252
|
-
c = mix3(c, back, smoothstep(0.55, 0.95, a / span) * 0.35 * wU);
|
|
253
|
-
}
|
|
254
|
-
if (!white) mark[v] = Math.min(mark[v], ((nm.startsWith('pelvic') ? 0.72 : 0.8) * span - a) * 0.6);
|
|
255
|
-
} else if (nm === 'dorsal1') {
|
|
256
|
-
c = mix3(back, flank, 0.1);
|
|
257
|
-
if (!white) {
|
|
258
|
-
const hFin = polyMaxB;
|
|
259
|
-
mark[v] = Math.min(mark[v], (0.78 * hFin - b) * 0.6);
|
|
260
|
-
// pale band under the black tip
|
|
261
|
-
c = mix3(c, col.paleBand, (1 - smoothstep(0.08, 0.2, Math.abs(b / hFin - 0.68))) * 0.55);
|
|
262
|
-
}
|
|
263
|
-
} else if (nm === 'dorsal2' || nm === 'anal') {
|
|
264
|
-
c = mix3(back, flank, nm === 'anal' ? 0.6 : 0.1);
|
|
265
|
-
if (!white) mark[v] = Math.min(mark[v], nm === 'anal' ? (b - 0.5 * polyMinB) * 0.6 : (0.55 * polyMaxB - b) * 0.6);
|
|
266
|
-
} else if (nm === 'caudal') {
|
|
267
|
-
c = mix3(back, flank, smoothstep(0.1, -0.15, b / TL) * 0.4);
|
|
268
|
-
if (!white) {
|
|
269
|
-
// black lower lobe tip and a dusky trailing margin
|
|
270
|
-
const tipL = [Math.cos(G.caudal.la) * G.caudal.low * TL, Math.sin(G.caudal.la) * G.caudal.low * TL];
|
|
271
|
-
const dl = Math.hypot(a - tipL[0], b - tipL[1]) - 0.42 * G.caudal.low * TL;
|
|
272
|
-
const tipU = [Math.cos(G.caudal.ua) * G.caudal.up * TL, Math.sin(G.caudal.ua) * G.caudal.up * TL];
|
|
273
|
-
const du = Math.hypot(a - tipU[0], b - tipU[1]) - 0.12 * G.caudal.up * TL;
|
|
274
|
-
mark[v] = Math.min(mark[v], dl * 0.8, du * 0.8);
|
|
275
|
-
const trail = trailDist(f2.poly, a, b);
|
|
276
|
-
mark[v] = Math.min(mark[v], trail - 0.006 * TL);
|
|
277
|
-
} else {
|
|
278
|
-
c = mix3(c, back.map((x) => x * 0.8), 0.3);
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
// claspers
|
|
282
|
-
c = mix3(col.finUnder, flank, 0.5);
|
|
283
|
-
}
|
|
284
|
-
if (nm === 'clasper') cm = [0, 0, -1];
|
|
285
|
-
cFin = c;
|
|
286
|
-
c = cBody0;
|
|
287
|
-
}
|
|
288
|
-
if (k !== K_FIN) {
|
|
289
|
-
// head and body details: a thin shadow round the eye (the black eye must stand out of the grey)
|
|
290
|
-
const de = Math.hypot(Math.abs(p[0]) - G.eye.x, p[1] - G.eye.y, p[2] - G.eye.z);
|
|
291
|
-
c = mix3(c, back.map((x) => x * 0.6), (1 - smoothstep(G.eye.r * 1.05, G.eye.r * 1.6, de)) * 0.45);
|
|
292
|
-
if (!white) {
|
|
293
|
-
// the white flank wedge: a pale tongue running forward from above the pelvic fins
|
|
294
|
-
const t = clamp((u - 0.36) / 0.3, 0, 1);
|
|
295
|
-
const ec = -0.05 - 0.2 * t;
|
|
296
|
-
const hw = 0.03 + 0.22 * t * t;
|
|
297
|
-
const dw = (Math.abs(e - ec + rag * 0.3) - hw) * G.hd(uc) * 0.6 + (u < 0.36 ? (0.36 - u) * TL * 0.6 : 0) + (u > 0.68 ? (u - 0.68) * TL : 0);
|
|
298
|
-
belly = Math.min(belly, dw);
|
|
299
|
-
}
|
|
300
|
-
// pores: small dark dots shaded into the colour (sub-vertex in size: a soft darkening, no hard mark)
|
|
301
|
-
const [dp] = featureDistance(pores, p, n);
|
|
302
|
-
if (dp < 0.004 * TL) c = mix3(c, c.map((x) => x * 0.6), (1 - smoothstep(-0.0012 * TL, 0.0025 * TL, dp)) * 0.45);
|
|
303
|
-
// white shark: dark freckles on the snout and around the jaws; scattered dark flecks on the back
|
|
304
|
-
if (white) {
|
|
305
|
-
// (5 cm snout blotches read as leopard spots) a few small dark dots
|
|
306
|
-
// along the upper lip only, and faint scattered flecks on the back
|
|
307
|
-
const m4 = fbm3(p[0] * 160 / TL + oy, p[1] * 160 / TL + 2.9, p[2] * 160 / TL + ox, 2) - 0.5;
|
|
308
|
-
const lip = (1 - smoothstep(0.07, 0.1, u)) * smoothstep(0.03, 0.05, u) * (1 - smoothstep(0.08, 0.22, Math.abs(e - (H.mouth.eC + 0.12))));
|
|
309
|
-
const fk = smoothstep(0.3, 0.34, m4) * lip * 0.7 + smoothstep(0.34, 0.37, m3) * 0.12 * smoothstep(0.0, 0.5, e);
|
|
310
|
-
c = mix3(c, col.freckle, clamp(fk, 0, 1) * 0.5);
|
|
311
|
-
} else {
|
|
312
|
-
// blacktip: the dusky band along the flank above the white wedge
|
|
313
|
-
const t = clamp((u - 0.3) / 0.38, 0, 1);
|
|
314
|
-
const db = Math.abs(e - (-0.02 - 0.12 * t + rag * 0.3)) / (0.07 + 0.05 * Math.sin(Math.PI * t));
|
|
315
|
-
c = mix3(c, col.flankBand, (1 - smoothstep(0.6, 1.4, db)) * smoothstep(0.26, 0.4, u) * (1 - smoothstep(0.66, 0.76, u)) * 0.55);
|
|
316
|
-
}
|
|
317
|
-
if (u < H.nostril.u + 0.02) for (const ns of nostrils) mark[v] = Math.min(mark[v], distPolyline(p, ns.pts, ns.w));
|
|
318
|
-
// gill slits
|
|
319
|
-
if (u > H.gills.u0 - 0.03 && u < H.gills.u1 + 0.03) {
|
|
320
|
-
for (const sl of slits) mark[v] = Math.min(mark[v], distPolyline(p, sl.pts, sl.w));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (cFin) {
|
|
324
|
-
const w = wFin[v];
|
|
325
|
-
c = mix3(c, cFin, w);
|
|
326
|
-
belly = belly + (bellyFin - belly) * w;
|
|
327
|
-
}
|
|
328
|
-
// scars: pale, slightly glossy scratches
|
|
329
|
-
for (const sc of scars) {
|
|
330
|
-
if (Math.sign(p[0]) !== sc.s && Math.abs(p[0]) > 0.02 * TL) continue;
|
|
331
|
-
const d = distPolyline(p, sc.pts, sc.w);
|
|
332
|
-
if (d < 0.004 * TL) {
|
|
333
|
-
const f = 1 - smoothstep(-0.0004 * TL, 0.0009 * TL, d);
|
|
334
|
-
c = mix3(c, col.scar, f * sc.k);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
// mottling (on the grey, a little on the fins; the pale belly stays clean)
|
|
338
|
-
const dors = 0.5 + 0.5 * smoothstep(-0.4, 0.6, e);
|
|
339
|
-
c = c.map((x) => x * (1 + dors * (0.2 * m1 + 0.1 * m2 + (white ? 0.1 : 0.07) * m3)));
|
|
340
|
-
if (regionOf[v] === rJaw) belly = Math.min(belly, -0.004 * TL + (e + 0.2) * 0.001);
|
|
341
|
-
pattern[v] = belly;
|
|
342
|
-
const bc = mix3(col.belly, col.boundary, smoothstep(-0.03 * TL, 0, belly) * 0.35);
|
|
343
|
-
patternColor.set([...bc, 1], o4);
|
|
344
|
-
tint.set([c[0], c[1], c[2], mat], o4);
|
|
345
|
-
comb.set(cm, o3);
|
|
346
|
-
surf.set([gl, sz * (k === K_FIN ? 0.8 : 1), 0, 0], o4);
|
|
347
|
-
}
|
|
348
|
-
// clamp far SDF values (the shader's antialiasing width comes from their derivatives)
|
|
349
|
-
for (let v = 0; v < nV; v++) {
|
|
350
|
-
if (pattern[v] > 0.02 * TL) pattern[v] = 0.02 * TL;
|
|
351
|
-
if (pattern[v] < -0.02 * TL) pattern[v] = -0.02 * TL;
|
|
352
|
-
if (mark[v] > 0.02 * TL) mark[v] = 0.02 * TL;
|
|
353
|
-
if (mark[v] < -0.02 * TL) mark[v] = -0.02 * TL;
|
|
354
|
-
}
|
|
355
|
-
return { comb, tint, pattern, mark, furLen, patternColor, surf, stats: { scars: scars.length, pores: pores.spots.length } };
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function lerpTable(tbl, u) {
|
|
359
|
-
if (u <= tbl[0][0]) return tbl[0][1];
|
|
360
|
-
for (let i = 1; i < tbl.length; i++) {
|
|
361
|
-
if (u <= tbl[i][0]) {
|
|
362
|
-
const t = (u - tbl[i - 1][0]) / (tbl[i][0] - tbl[i - 1][0]);
|
|
363
|
-
const s = t * t * (3 - 2 * t);
|
|
364
|
-
return tbl[i - 1][1] + (tbl[i][1] - tbl[i - 1][1]) * s;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return tbl[tbl.length - 1][1];
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// distance (2D) from (a, b) to the caudal fin's trailing edge: the part of the outline behind the tips
|
|
371
|
-
function trailDist(poly, a, b) {
|
|
372
|
-
let best = 1e9;
|
|
373
|
-
// the trailing edge is the stretch between the upper tip (max b) and the lower tip (min b)
|
|
374
|
-
let iU = 0, iL = 0;
|
|
375
|
-
for (let i = 0; i < poly.length; i++) { if (poly[i][1] > poly[iU][1]) iU = i; if (poly[i][1] < poly[iL][1]) iL = i; }
|
|
376
|
-
for (let i = iU; i < iL; i++) {
|
|
377
|
-
const p = poly[i], q = poly[i + 1];
|
|
378
|
-
const ex = q[0] - p[0], ey = q[1] - p[1];
|
|
379
|
-
const t = clamp(((a - p[0]) * ex + (b - p[1]) * ey) / (ex * ex + ey * ey || 1e-12), 0, 1);
|
|
380
|
-
best = Math.min(best, Math.hypot(a - p[0] - ex * t, b - p[1] - ey * t));
|
|
381
|
-
}
|
|
382
|
-
return best;
|
|
383
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// Sharks: the great white (default) and the blacktip reef shark as variants
|
|
2
|
-
// (createAnimal('shark', { variant: 'blacktip' })). Swimmer body plan (core/motion/swimmer.js):
|
|
3
|
-
// thunniform / carangiform tail-driven swimming, stiff pectorals, heterocercal tail, obligate ram
|
|
4
|
-
// ventilation (it never stops), upper-jaw protrusion, eye roll (white) / nictitating membrane
|
|
5
|
-
// (blacktip) on the bite.
|
|
6
|
-
import { sharkRig, sharkGeo } from './rig.js';
|
|
7
|
-
import { sculptShark, CELL } from './sculpt.js';
|
|
8
|
-
import { sharkRegions } from './regions.js';
|
|
9
|
-
import { sharkCoat } from './coat.js';
|
|
10
|
-
import { motion } from './motion.js';
|
|
11
|
-
import { VARIANTS, VARIANT_KEYS } from './variants.js';
|
|
12
|
-
import { srgb } from '../../core/build/coatKit.js';
|
|
13
|
-
|
|
14
|
-
const pick = (R, table) => {
|
|
15
|
-
let x = R(), acc = 0;
|
|
16
|
-
for (const [k, w] of table) { acc += w; if (x < acc) return k; }
|
|
17
|
-
return table[table.length - 1][0];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
id: 'shark',
|
|
22
|
-
name: 'Shark',
|
|
23
|
-
latin: 'Selachimorpha',
|
|
24
|
-
group: 'swimmers',
|
|
25
|
-
plan: 'swimmer',
|
|
26
|
-
covering: 'scales',
|
|
27
|
-
variants: VARIANT_KEYS,
|
|
28
|
-
|
|
29
|
-
// Seeded individual. Variant from opts.variant (default: white shark). Within a variant: sex
|
|
30
|
-
// (females larger in both species; males carry claspers), age (juveniles smaller with relatively
|
|
31
|
-
// bigger heads and fins), girth, fin and tail proportions, dorsal tone, scars.
|
|
32
|
-
variation(R, o) {
|
|
33
|
-
const variant = o.variant && VARIANTS[o.variant] ? o.variant : 'white';
|
|
34
|
-
const V = VARIANTS[variant];
|
|
35
|
-
const sex = o.sex || (R() < 0.5 ? 'male' : 'female');
|
|
36
|
-
const age = o.age || (R() < 0.15 ? 'juvenile' : 'adult');
|
|
37
|
-
const juv = age === 'juvenile';
|
|
38
|
-
const g = () => (R() + R() + R() - 1.5) / 1.5;
|
|
39
|
-
const white = variant === 'white';
|
|
40
|
-
// white: females 4.5-5 m, males 3.4-4 m; juveniles 1.5-2.5 m. Blacktip: 1-1.4 m, pups ~0.5 m
|
|
41
|
-
let size = (sex === 'male' ? (white ? 0.84 : 0.92) : 1) * (1 + (white ? 0.09 : 0.08) * g());
|
|
42
|
-
if (juv) size = white ? 0.36 + 0.14 * R() : 0.42 + 0.12 * R();
|
|
43
|
-
const TL = V.TL;
|
|
44
|
-
const G = sharkGeo({ variant });
|
|
45
|
-
const headK = (1 + 0.03 * g()) * (juv ? 1.1 : 1);
|
|
46
|
-
const tones = V.colour.tones;
|
|
47
|
-
return {
|
|
48
|
-
variant, sex, age, size,
|
|
49
|
-
girthK: (1 + 0.05 * g()) * (juv ? 0.9 : 1) * (sex === 'female' && !juv ? 1.03 : 1),
|
|
50
|
-
finK: (1 + 0.05 * g()) * (juv ? 1.08 : 1),
|
|
51
|
-
pecK: 1 + 0.05 * g(),
|
|
52
|
-
dorsalK: (1 + 0.07 * g()) * (juv ? 1.05 : 1),
|
|
53
|
-
tailK: 1 + 0.04 * g(),
|
|
54
|
-
lowLobeK: 1 + 0.06 * g(),
|
|
55
|
-
warps: [
|
|
56
|
-
{ type: 'scaleAbout', c: G.headO, k: headK, r0: 0.1 * TL, r1: 0.26 * TL },
|
|
57
|
-
],
|
|
58
|
-
tone: pickIdx(R, tones),
|
|
59
|
-
coatShade: 0.9 * g(),
|
|
60
|
-
bndShift: (white ? 0.1 : 0.06) * g(),
|
|
61
|
-
coatSeed: Math.floor(R() * 1e6),
|
|
62
|
-
scarK: (juv ? 0.2 : 1) * (sex === 'female' ? 1.3 : 0.9) * (0.4 + 0.9 * R()),
|
|
63
|
-
minThick: TL * CELL * (V.cellK || 1) * 1.2,
|
|
64
|
-
nicks: finNicks(R, white, juv),
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
rig: (params) => sharkRig(params),
|
|
68
|
-
sculpt: (m, rig, params) => sculptShark(m, rig, params),
|
|
69
|
-
regions: sharkRegions,
|
|
70
|
-
coat: sharkCoat,
|
|
71
|
-
eyeSpecs(params) {
|
|
72
|
-
const G = sharkGeo(params);
|
|
73
|
-
const V = G.V, Ey = G.eye;
|
|
74
|
-
const bird = V.eye.lids === 'bird';
|
|
75
|
-
const spec = { c: [Ey.x, 0, 0], r: Ey.r, back: 0, yaw: 1.38, pitch: 0.05, lid: 0, R: Ey.r * (bird ? 1.1 : 1.0), d: bird ? Ey.r * 0.42 : 0, off: 0, tilt: 0, irisZ: Ey.r * (bird ? 0.42 : 0.3), irisR: Ey.r * (bird ? 0.84 : 0.95) };
|
|
76
|
-
// (white shark: the black iris fills the whole aperture: no pale sclera ring at rest; it shows only
|
|
77
|
-
// when the eye rolls back on the bite)
|
|
78
|
-
const iris = V.eye.iris.map((h) => srgb(h));
|
|
79
|
-
const look = {
|
|
80
|
-
pupil: 'round', lids: V.eye.lids, blink: false, pupilSize: V.eye.pupil,
|
|
81
|
-
iris: { inner: iris[0], mid: iris[1], hi: iris[2], outer: iris[3] },
|
|
82
|
-
sclera: { color: srgb(V.eye.sclera), visible: true },
|
|
83
|
-
lidColor: srgb(V.colour.back),
|
|
84
|
-
};
|
|
85
|
-
return [1, -1].map((side) => ({ side, spec, headOrigin: G.headO, bone: 'head', look }));
|
|
86
|
-
},
|
|
87
|
-
motion,
|
|
88
|
-
// denticles: material 6 is drawn as shark skin (matte, a fine grain along the body, a soft broad
|
|
89
|
-
// sheen across the denticle ridges, no clear coat)
|
|
90
|
-
render: { markColor: [0.006, 0.006, 0.007], scaleEdge: 0.18, denticles: 1 },
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// seeded nicks in the trailing edges of adults' fins (old bites, abrasion): 0-3 on the first dorsal,
|
|
94
|
-
// sometimes one on the upper caudal lobe; blacktips and juveniles have fewer
|
|
95
|
-
function finNicks(R, white, juv) {
|
|
96
|
-
const n = juv ? (R() < 0.15 ? 1 : 0) : Math.floor(R() * (white ? 3.6 : 2.2));
|
|
97
|
-
const out = [];
|
|
98
|
-
for (let i = 0; i < n; i++) out.push({ fin: R() < 0.2 ? 'caudal' : 'dorsal1', t: 0.1 + 0.8 * R(), r: (white ? 0.0035 : 0.004) + 0.004 * R() });
|
|
99
|
-
return out;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function pickIdx(R, tones) {
|
|
103
|
-
return pick(R, tones.map((t, i) => [i, t[1]]));
|
|
104
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// Shark motion data for the swimmer engine (schema: src/core/motion/swimmer.js). Speeds in body
|
|
2
|
-
// lengths per second (BL/s), so one table serves every size; the blacktip overrides in `variants`.
|
|
3
|
-
//
|
|
4
|
-
// White shark (lamnid, thunniform): stiff anterior body (envelope u^2.5), long body wave, lunate tail
|
|
5
|
-
// that stays a flat plate. Cruise 0.2-0.25 TL/s for adults (0.8-1 m/s), transit ~0.5 TL/s, bursts to
|
|
6
|
-
// ~1.5-2 TL/s (Spurgeon 2022, Semmens 2019); tail-beat f ~ 0.25 + 1.6 U/L Hz (research fit to 0.4-0.5
|
|
7
|
-
// Hz at cruise, 0.83-1.67 Hz in the breach ascent), amplitude ~0.18 TL peak-to-peak.
|
|
8
|
-
// Blacktip (carcharhinid, carangiform): U = 0.75 +- 0.18 TL/s at f = 0.82 +- 0.24 Hz, tail amplitude
|
|
9
|
-
// 0.24 TL, body wave over the rear half (Porter 2020, C. limbatus); head yaw noticeably.
|
|
10
|
-
// Both are obligate ram ventilators: minSpeed keeps them patrolling in wide circles when told to stop;
|
|
11
|
-
// rest postures keep swimming. Wave rows: [v, f Hz, amp p-p / L, lambda / L, pectoral activity,
|
|
12
|
-
// pectoral beat Hz, pectoral fold].
|
|
13
|
-
export const motion = {
|
|
14
|
-
speeds: { patrol: 0.2, cruise: 0.35, sprint: 1.0 },
|
|
15
|
-
minSpeed: 0.15, maxSpeed: 1.3, burstSpeed: 2.0, accel: 0.9, decel: 0.25, turnRate: 0.8, turnRadius: 0.9,
|
|
16
|
-
patrolRadius: 3.5,
|
|
17
|
-
wave: [
|
|
18
|
-
[0, 0.3, 0.1, 1.35, 0, 1, 0],
|
|
19
|
-
[0.2, 0.55, 0.15, 1.3, 0, 1, 0],
|
|
20
|
-
[0.4, 0.85, 0.17, 1.25, 0, 1, 0],
|
|
21
|
-
[0.8, 1.45, 0.18, 1.2, 0, 1, 0.2],
|
|
22
|
-
[1.3, 1.9, 0.19, 1.15, 0, 1, 0.45],
|
|
23
|
-
[2.0, 2.4, 0.2, 1.1, 0, 1, 0.7],
|
|
24
|
-
],
|
|
25
|
-
envelope: { pow: 2.5 },
|
|
26
|
-
flex: [0.3, 0.95], caudalStiff: 0.9, bend: 0.45, cBend: 1.1, bank: 0.45, bankGain: 1.4, pitchMax: 0.6, hover: 0.08,
|
|
27
|
-
clearance: 0.12, cruiseDepth: 0.8,
|
|
28
|
-
strandRoll: 0.25, // stranded on dry ground: on its belly (core default 1.3, a bony fish on its side)
|
|
29
|
-
// stiff hydrofoil pectorals: no sculling; pressed a little toward the body at speed, depressed
|
|
30
|
-
// (flared) when braking and on the inside of turns
|
|
31
|
-
pectoral: { rest: [0, 0, 0], flap: 0, row: 0, feather: 0, fold: 7, flare: 30, alternate: 0, stiff: 1 },
|
|
32
|
-
pelvic: { rest: 0, spread: 0, fold: 3 },
|
|
33
|
-
breath: { rate: 0.4, operculum: 0, mouth: 0.1, ram: 0.2, slits: true },
|
|
34
|
-
jaw: { gape: 50, protrude: 0.016, protrudeDir: [0, -0.8, 0.6] },
|
|
35
|
-
actions: {
|
|
36
|
-
burst: { turn: 70, coast: 1.4 },
|
|
37
|
-
jump: { height: 0.55, bite: true, roll: 1.3 },
|
|
38
|
-
attack: { headLift: 0.32, shake: 2, eye: 'roll', lunge: 1.2 },
|
|
39
|
-
eat: { style: 'tear', headLift: 0.25, shake: 3, eye: 'roll' },
|
|
40
|
-
drink: { reach: 0 },
|
|
41
|
-
sleep: { style: 'hover' },
|
|
42
|
-
death: { roll: 1.5708 },
|
|
43
|
-
},
|
|
44
|
-
variants: {
|
|
45
|
-
white: {},
|
|
46
|
-
blacktip: {
|
|
47
|
-
speeds: { patrol: 0.4, cruise: 0.75, sprint: 2.0 },
|
|
48
|
-
minSpeed: 0.3, maxSpeed: 2.6, burstSpeed: 4.0, accel: 2.5, decel: 0.7, turnRate: 2.0, turnRadius: 0.35,
|
|
49
|
-
patrolRadius: 2.5,
|
|
50
|
-
wave: [
|
|
51
|
-
[0, 0.5, 0.12, 1.0, 0, 1, 0],
|
|
52
|
-
[0.4, 0.66, 0.18, 1.0, 0, 1, 0],
|
|
53
|
-
[0.75, 0.85, 0.22, 0.95, 0, 1, 0],
|
|
54
|
-
[1.5, 1.4, 0.24, 0.9, 0, 1, 0.2],
|
|
55
|
-
[2.5, 2.1, 0.24, 0.85, 0, 1, 0.45],
|
|
56
|
-
[4.0, 3.0, 0.25, 0.8, 0, 1, 0.7],
|
|
57
|
-
],
|
|
58
|
-
envelope: { pow: 1.6, head: 0.3 },
|
|
59
|
-
flex: [0.2, 0.95], caudalStiff: 0.6, bend: 0.9, cBend: 1.8, bank: 0.5, bankGain: 1.0,
|
|
60
|
-
jaw: { gape: 44, protrude: 0.012, protrudeDir: [0, -0.8, 0.6] },
|
|
61
|
-
actions: {
|
|
62
|
-
jump: { height: 0.35, bite: false, roll: 0 },
|
|
63
|
-
attack: { headLift: 0.25, shake: 3, eye: 'nictitate', lunge: 1.0 },
|
|
64
|
-
eat: { style: 'tear', headLift: 0.2, shake: 3, eye: 'nictitate' },
|
|
65
|
-
death: { roll: 2.7 },
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Meshing plan: the whole shark (body + fleshy fins) as one surface at TL * CELL (1 cm for a 4.5 m
|
|
2
|
-
// white shark at the hero tier), the lower jaw as its own rigid surface so the mouth can open, and
|
|
3
|
-
// the two tooth rows as rigid parts at a fine cell size (hero and high; from medium on the teeth
|
|
4
|
-
// are sub-pixel and are left out).
|
|
5
|
-
import { sharkGeo } from './rig.js';
|
|
6
|
-
import { CELL } from './sculpt.js';
|
|
7
|
-
|
|
8
|
-
export function sharkRegions(rig, params, Q) {
|
|
9
|
-
const G = sharkGeo(params);
|
|
10
|
-
const TL = G.TL, V = G.V, r = Q.res;
|
|
11
|
-
const h = TL * CELL * (V.cellK || 1) * r;
|
|
12
|
-
const J = rig.J;
|
|
13
|
-
let hw = 0, top = 0;
|
|
14
|
-
for (const row of V.prof) { hw = Math.max(hw, row[3]); top = Math.max(top, row[1]); }
|
|
15
|
-
const xMax = Math.max(hw * TL * (G.girthK || 1) * 1.1, Math.abs(J.pecTipL[0]) + 0.03 * TL) + 0.02 * TL;
|
|
16
|
-
const topY = Math.max(G.axisY + (top + 0.13 * G.dorsalK) * TL, J['caudal' + V.caudalSegs][1] + 0.05 * TL) + 0.02 * TL;
|
|
17
|
-
const botY = -0.03 * TL;
|
|
18
|
-
const zTail = G.z(G.pc) - Math.max(G.caudal.up, G.caudal.low) * TL - 0.06 * TL;
|
|
19
|
-
const M = V.head.mouth;
|
|
20
|
-
const jobs = [
|
|
21
|
-
[{ name: 'body', part: 'body', bmin: [-xMax, botY, zTail], bmax: [xMax, topY, G.z0 + 0.02 * TL], h, F: 6 }],
|
|
22
|
-
[{ name: 'jaw', part: 'jaw', bmin: [-0.12 * TL, G.bot(M.uC) - 0.03 * TL, G.z(M.uC + 0.09)], bmax: [0.12 * TL, G.yC + 0.02 * TL, G.z(0) + 0.01 * TL], h: h * 0.75, F: 4, rigidBone: 'jaw' }],
|
|
23
|
-
];
|
|
24
|
-
if (r < 1.9) {
|
|
25
|
-
const ht = TL * (params.variant === 'white' ? 0.0011 : 0.0009) * Math.min(r, 1.6);
|
|
26
|
-
const y0 = Math.min(G.yC, G.yF), y1 = Math.max(G.yC, G.yF);
|
|
27
|
-
const box = (dy0, dy1) => ({ bmin: [-0.11 * TL, y0 + dy0 * TL, G.z(M.uC + 0.015)], bmax: [0.11 * TL, y1 + dy1 * TL, G.z(M.uF) + 0.01 * TL] });
|
|
28
|
-
jobs.push([
|
|
29
|
-
{ name: 'uteeth', part: 'uteeth', ...box(-0.025, 0.025), h: ht, F: 4, rigidBone: 'upperJaw' },
|
|
30
|
-
{ name: 'lteeth', part: 'lteeth', ...box(-0.025, 0.025), h: ht, F: 4, rigidBone: 'jaw' },
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
return { jobs, fade: () => 1 };
|
|
34
|
-
}
|