// tech stack
// the challenge
The liver is the only organ with two blood inlets and one outlet: oxygen-rich blood arrives through the hepatic artery, nutrient-rich blood through the portal vein, and both leave through the hepatic veins into the inferior vena cava. Flat diagrams turn that into arrows, so students memorise labels without ever seeing how the vessels sit in space. The tool also had to run in classrooms with no internet connection and no install step.
// the solution
A single static page renders the liver with three.js. Geometry ships as base64-quantized Int16 buffers and is decoded back into Float32 positions in the browser, so a full anatomical mesh fits into a small script. Blood flow is one InstancedMesh: every cell carries a phase offset and is placed by arc length along a vessel centerline, so cells keep a constant speed in long vessels and slow down in capillaries. A five-step tour animates the camera and the OrbitControls target with GSAP while per-layer opacity multipliers dim everything out of focus, and the content file drives the tour text, the quiz, the glossary and the clinical cases.
// measurable impact
Runs straight from a folder — no build step, no server, no CDN, zero network requests at runtime. All teaching material (steps, 8 quiz questions, 9 glossary terms, 6 facts, 4 clinical cases) lives in one editable content file, so the anatomy script can be rewritten without touching the 3D or the UI code.
- Timeline
- November 2026
- Team
- Solo
- Role
- Concept, 3D pipeline and front-end development
// key highlights
- ◆Base64 + Int16 mesh quantization keeps the whole liver model inside compact script payloads that decode at runtime.
- ◆One InstancedMesh drives every blood cell, positioned by arc length along vessel centerlines instead of a fixed step.
- ◆Camera tour, layer dimming and card transitions are choreographed with GSAP timelines rather than a game-loop state machine.
- ◆Layer chips double as controls: single click hides a vessel, double click jumps to its guided step.
- ◆Quiz answers are shuffled per run and each one returns an explanation instead of only a score.
- ◆Fully offline: HTML, CSS, JS and vendored three.js / GSAP, with no request after the page loads.
// implementation sample
/* Blood cells: one InstancedMesh, every cell placed by arc length along its vessel */
const cells = [];
for (const k in PATHS) for (const e of PATHS[k]) {
const n = e.p.length / 3, L = e.L, v = Math.max((0.03 + 0.25 * e.r) * 24, L / 3.5);
const cnt = Math.max(1, Math.round(L / Math.max(.12, 5 * e.r)));
for (let c = 0; c < cnt; c++) {
cells.push({ g: k, pts: e.p, n, L, v, r: e.r,
ph: (c + Math.random() * .5 - .25) / cnt, // evenly spread phases
birth: Math.random() * 5, rank: Math.random() });
}
}
function updateCells(dt) {
if (started && playing) flowT += dt * speed;
cells.forEach((c, i) => {
const u = ((c.ph + flowT * c.v / c.L) % 1 + 1) % 1; // loop along the vessel
const f = u * (c.n - 1), a = Math.floor(f), t = f - a;
const b = Math.min(a + 1, c.n - 1), P = c.pts;
// hide cells on disabled layers and fade them at both vessel ends
const vis = layerOn[c.g] && c.rank <= density ? 1 : 0;
const s = c.r * fade(u) * Math.min(1, Math.max(0, (flowT - c.birth) / .6)) * focusMul[c.g].v * vis;
dummy.position.set(
P[3*a] + (P[3*b] - P[3*a]) * t,
P[3*a+1] + (P[3*b+1] - P[3*a+1]) * t,
P[3*a+2] + (P[3*b+2] - P[3*a+2]) * t);
dummy.scale.setScalar(Math.max(s, 1e-4));
dummy.updateMatrix();
cellMesh.setMatrixAt(i, dummy.matrix);
});
cellMesh.instanceMatrix.needsUpdate = true;
}