/ghibli-threejs:threejs-fish-school-boidsfrom ghibli-threejs
Builds a school of swimming fish (koi) in three.js with vertex-shader swimming, fragment-shader patterns, and calm boids behavior including obstacle avoidance, surface kisses, and night bioluminescence.
Ships in ghibli-threejs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Produces vivid, wet-looking koi that swim with a believable body wave, bank into turns, spread along the whole river instead of clumping, avoid shallows, rocks, a boat and a submerged camera, and now and then rise to kiss the surface (spawning a ripple ring the water shader draws).
Stack: three.js WebGLRenderer, MeshPhysicalMaterial patched with onBeforeCompile, a
matching MeshDepthMaterial for shadows; the mesh comes from headless Blender. Vanilla or R3F.
Water surface at y = 0, bed height terrainHeight(x, z).
Add
{{n, e.g. 24}}{{creature, e.g. koi}}to{{entry file}}.
- Mesh (Blender, headless): one neutral mesh with body, fins, eyes and barbels, and no painted pattern. Chunky from above. Fins are multi-segment sheets. Put animation data in
COLOR_0: R = pectoral weight (root → tip), G = side, B = flutter weight toward free edges. Export withexport_vertex_color='ACTIVE'. In three, rename the attribute tofinDataso it doesn't tint the material.- Patterns in the fragment shader from object-space position: one variety uniform per fish (kohaku, sanke, showa, ogon, tancho, asagi, kigoi…). Crisp noise patches biased to the back, a pale belly, hex scale rows (
atanaround the body).MeshPhysicalMaterialwith clearcoat 0.9; ogon metalness 0.7. Fins translucent with rays, alpha fading to the edge.- Vertex swimming: a travelling wave growing toward the tail; a whole-body C-bend ∝ turn rate; pectorals flap and tuck in when sprinting; free edges flutter. Give the
customDepthMaterialthe same patch.- Behaviour: boids (cohesion, alignment, separation) plus wander; look ahead and turn away from the shallows; avoid rocks; occasional bursts; turn-rate-limited heading; roll into turns (Euler
YXZ); a slow, natural tail beat (~0.65 Hz cruising, ~1 Hz in a burst) whose rate follows speed but is integrated into a phase on the CPU; every few seconds one fish kisses the surface and spawns a ripple. Give each fish a patrol home and expose count/speed/spacing/schooling/roam in a Tune folder.
finData on load: geo.setAttribute('finData', geo.attributes.color); geo.deleteAttribute('color')./fin/ → translucent fin material, /eye/ → black clearcoat, else body.references/koi-shader.js)s = clamp((x + .30)/.58) (0 tail, 1 snout); amp = uAmp·(.010 + .085(1 − s)^2.2);
z += amp·sin(x·10.5 − uSwim + phase), where uSwim is a phase (see Behaviour); C-bend
z += uTurn·(x − .14)²·2.2; pectorals y += R·(sin(uFinBeat + sideOffset)·.016 − fold·.004)
(uFinBeat also a phase), tuck z += R·side·fold·−.028; flutter z += B·sin(4.5t + 28x + 37y)·.0045.top = smoothstep(−.02, .035, y), belly smoothstep(−.012, −.05, y), two-fbm
noise; patches smoothstep(.465, .495, n + top·.2 + head·.22 − .1)·(1 − belly) — a narrow
smoothstep gives crisp edges. Scale rows: (x·105, atan(z, y)·8.5) with odd rows offset by .5,
darken edges by 16 %. Fin rays .86 + .14 sin(190·(…)), alpha mix(.95, .45, B).MeshPhysicalMaterial({ roughness .3, clearcoat .9, clearcoatRoughness .12, sheen .4 }); fins transparent, opacity .78, DoubleSide, depthWrite false; ogon metalness 0.7.customDepthMaterial = a MeshDepthMaterial(RGBADepthPacking)
with the same vertex chunk and uniforms.references/koi-boids.js)d² < 5.8): cohesion .12·schooling/n, alignment .1 + .5·schooling,
separation ramped (1 − d²/r²)² inside 0.9 m × spacing (not 1/d²).sin(.05t)·2.5·roam); a soft spring only beyond reach = 2.5·roam + .5. Keep cohesion small
(schooling ≈ .25).sin(.23t + w) + .6 sin(.61t + 1.7w)), not a per-frame
random walk..20 + .06 sin(…) + bursts (.28 sin(π·b/1.4),
rate ~0.04/s), speed and depth eased with 1 − exp(−dt·k) (frame-rate independent).turn eased, bank rotation.x = turn·.25 with Euler order YXZ;
uAmp = .55 + 1.2·speed + .8|turn|, uFold = smoothstep(speed, .3, .55).2.6 + 8·speed rad/s (≈ 0.65 Hz cruising, ≈ 1 Hz
in a burst; real koi cruise well under 1 Hz), pectorals 1.6 + 1.6·(1 − fold); ease the rate with
1 − exp(−1.5·dt), then phase = (phase + rate·dt) mod 2000π and upload the phase.(x, z, amp .9, startTime) just ahead of its snout.Clearcoat → 1.0, clearcoat roughness → 0.05. Bioluminescence: the colour function also outputs a
glow mask; add mask × orange × (.55 + .45 sin(t·1.3 + phase)) × uBio to
totalEmissiveRadiance; fin tips pale cyan from B. Ghost/silver variety: metalness ≈ 0.35,
faint steady silver emissive. See threejs-ghibli-night-mode.
onBeforeCompile, inject helper GLSL before any code that calls it.sin(uTime·rate) with a speed-driven rate makes the tail flick too fast and twitch: with page-time
uTime in the thousands, each small rate change jumps the phase by uTime·Δrate. Integrate the phase
on the CPU. A base rate above ~1 Hz also reads as frantic for a koi.threejs-camera-guided-tour), flag them scripted
so the flocking step skips them, and hand them a velocity on release.threejs-webgl-realistic-water · threejs-webgl-underwater-effect · threejs-ghibli-night-mode ·
threejs-blender-glb-pipeline · threejs-camera-guided-tour · threejs-boat-buoyancy-steering
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
threejs, boids, koi, fish-school, shader-animation, flocking
Other plugins' skills for the same job
31 skills in this plugin
/threejs-blender-glb-pipelineBuilds a reference-image-driven asset pipeline from headless Blender to GLB for a three.js scene — an asset contract (units, axes, grounding, required mesh/material names, budgets, attachment numbers), one parallel subagent per asset group writing craft_<slug>.py generators, preview renders compared against the reference, measured-bounding-box placement in the web scene, Draco compression, and a scored asset quality pass. Use when the user has a reference picture and wants a 3D scene from it, asks to model props/trees/characters in Blender for three.js, export GLBs, fix glTF export issues (vertex-colour alpha, UV flip, axes, custom normals), compress models, or rate and improve every asset in a scene./threejs-boat-buoyancy-steeringFloats a boat (or any buoyant prop) on three.js water with Gerstner waves generated from one JS table that feeds both the GLSL vertex shader and a CPU waveHeight(), four-probe heave/pitch/roll damped springs, an arc-length drift lane that bends round rocks, click-to-steer W/A/S/D rowing with momentum and drag, an autopilot that pursues the lane back, and a chase camera that keeps the orbit. Use when the user wants a drifting or steerable boat, buoyancy, objects bobbing on waves, Gerstner waves on a river/lake, a boat autopilot, or a follow/chase camera behind a vehicle on water.npx claudepluginhub nicksonthc/ghibli-threejs --plugin ghibli-threejs