Prompt specification
Build or customize the Three.js 3D scene "Structural correspondence explorer" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Structural correspondence explorer
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/structural-correspondence-explorer-x0920
Scene Description Prompt:
Select corresponding bones across simplified voxel limbs, distinguishing shared ancestry from superficial resemblance and comparing functions. Three.js from cdnjs, one HTML file.
Working Three.js Starter (structural-correspondence-explorer-x0920):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Homology Lab — One Skeleton, Four Solutions</title>
<style>
:root {
color-scheme: dark;
--bg: #071016;
--panel: rgba(13, 25, 34, 0.84);
--panel-strong: #101e28;
--line: rgba(174, 219, 229, 0.14);
--text: #edf8f8;
--muted: #91a7b1;
--cyan: #69dfd0;
--coral: #ff8b79;
--purple: #b79cff;
--shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
margin: 0;
min-height: 100vh;
color: var(--text);
background:
radial-gradient(circle at 7% 4%, rgba(54, 155, 155, 0.16), transparent 29rem),
radial-gradient(circle at 91% 12%, rgba(116, 83, 180, 0.13), transparent 27rem),
var(--bg);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
-webkit-font-smoothing: antialiased;
}
button { font: inherit; }
button:focus-visible,
canvas:focus-visible {
outline: 2px solid var(--cyan);
outline-offset: 3px;
}
[hidden] { display: none !important; }
.app {
width: min(1520px, 100%);
margin: 0 auto;
padding: 30px 28px 44px;
}
.topbar {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 28px;
align-items: end;
padding-bottom: 25px;
border-bottom: 1px solid var(--line);
}
.brand {
display: flex;
gap: 18px;
align-items: flex-start;
}
.brand-mark {
position: relative;
width: 50px;
height: 50px;
flex: 0 0 50px;
margin-top: 5px;
transform: rotate(-8deg);
}
.brand-mark span {
position: absolute;
display: block;
border: 1px solid rgba(255,255,255,.28);
background: linear-gradient(145deg, #83eadb, #2e8f89);
box-shadow: inset -6px -7px 12px rgba(0,0,0,.16);
}
.brand-mark span:nth-child(1) { width: 24px; height: 24px; left: 0; top: 0; }
.brand-mark span:nth-child(2) { width: 24px; height: 24px; right: 0; top: 0; background: linear-gradient(145deg,#c3b5ff,#7665bd); }
.brand-mark span:nth-child(3) { width: 24px; height: 24px; right: 0; bottom: 0; background: linear-gradient(145deg,#ffc276,#b96845); }
.brand-mark span:nth-child(4) { width: 24px; height: 24px; left: 0; bottom: 0; background: linear-gradient(145deg,#f493ad,#9e4669); }
.eyebrow {
margin: 0 0 7px;
color: var(--cyan);
font-size: 0.69rem;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 850px;
font-size: clamp(2rem, 4.4vw, 4.2rem);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 780;
}
h1 em {
color: #a8b8c0;
font-style: normal;
font-weight: 420;
}
.intro {
max-width: 680px;
margin: 15px 0 0;
color: var(--muted);
font-size: 0.94rem;
line-height: 1.6;
}
.mode-wrap {
min-width: 330px;
}
.mode-label {
display: flex;
justify-content: space-between;
gap: 20px;
margin-bottom: 8px;
color: var(--muted);
font-size: 0.68rem;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.mode-toggle {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px;
padding: 4px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(4, 12, 17, 0.72);
}
.mode-toggle button {
min-height: 44px;
padding: 8px 12px;
border: 0;
border-radius: 9px;
color: var(--muted);
background: transparent;
cursor: pointer;
transition: background .2s, color .2s, box-shadow .2s;
font-size: 0.77rem;
font-weight: 760;
}
.mode-toggle button[aria-pressed="true"] {
color: #061113;
background: var(--cyan);
box-shadow: 0 5px 18px rgba(105, 223, 208, 0.18);
}
body[data-mode="analogy"] .mode-toggle button[aria-pressed="true"] {
color: #1d0b09;
background: var(--coral);
}
.mode-caption {
min-height: 34px;
margin: 8px 2px 0;
color: #8098a4;
font-size: 0.72rem;
line-height: 1.45;
}
.workspace {
display: grid;
grid-template-columns: minmax(0, 1fr) 344px;
gap: 22px;
align-items: start;
margin-top: 24px;
}
.models {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 18px;
}
.model-card {
position: relative;
overflow: hidden;
min-width: 0;
border: 1px solid var(--line);
border-radius: 19px;
background:
radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 48%),
linear-gradient(155deg, rgba(20, 37, 47, 0.96), rgba(8, 18, 25, 0.96));
box-shadow: var(--shadow);
transition: transform .25s, border-color .25s;
}
.model-card:hover {
transform: translateY(-2px);
border-color: color-mix(in srgb, var(--accent) 36%, transparent);
}
.card-head {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
padding: 17px 18px 8px;
}
.card-title-row {
display: flex;
align-items: baseline;
gap: 9px;
}
.card-number {
color: var(--accent);
font: 750 0.65rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
}
.card-head h2 {
margin: 0;
font-size: 1.04rem;
letter-spacing: -0.02em;
}
.card-subtitle {
margin: 6px 0 0;
color: var(--muted);
font-size: 0.73rem;
line-height: 1.35;
}
.view-badge {
flex: 0 0 auto;
padding: 6px 8px;
border: 1px solid var(--line);
border-radius: 7px;
color: #a6bac3;
background: rgba(4, 11, 16, 0.4);
font-size: 0.61rem;
font-weight: 750;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.viewport {
position: relative;
height: 270px;
min-height: 220px;
overflow: hidden;
}
.viewport canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
.surface-note {
position: absolute;
z-index: 3;
left: 50%;
bottom: 9px;
width: max-content;
max-width: 88%;
transform: translateX(-50%);
padding: 7px 10px;
border: 1px solid rgba(255, 139, 121, 0.32);
border-radius: 8px;
color: #ffd0c9;
background: rgba(61, 20, 18, 0.8);
backdrop-filter: blur(8px);
font-size: 0.65rem;
font-weight: 750;
letter-spacing: 0.07em;
text-transform: uppercase;
pointer-events: none;
}
.hover-tip {
position: absolute;
z-index: 5;
width: max-content;
max-width: 190px;
padding: 7px 9px;
border: 1px solid rgba(255,255,255,.15);
border-radius: 7px;
color: #eaf9f8;
background: rgba(4, 13, 18, 0.92);
box-shadow: 0 8px 22px rgba(0,0,0,.25);
opacity: 0;
transform: translateY(3px);
transition: opacity .12s, transform .12s;
pointer-events: none;
font-size: 0.68rem;
line-height: 1.35;
}
.hover-tip.visible {
opacity: 1;
transform: translateY(0);
}
.card-foot {
display: flex;
justify-content: space-between;
gap: 10px;
padding: 10px 16px 13px;
border-top: 1px solid rgba(174, 219, 229, 0.08);
color: #718894;
font-size: 0.64rem;
}
.match-state {
overflow: hidden;
color: color-mix(in srgb, var(--accent) 80%, #d9e6e8);
font-weight: 750;
text-overflow: ellipsis;
white-space: nowrap;
}
.reset-view {
flex: 0 0 auto;
padding: 0;
border: 0;
color: #8198a3;
background: none;
cursor: pointer;
font-size: 0.64rem;
}
.reset-view:hover { color: var(--text); }
.legend-panel {
margin-top: 18px;
padding: 16px 17px;
border: 1px solid var(--line);
border-radius: 16px;
background: rgba(10, 22, 30, 0.66);
}
.legend-head {
display: flex;
justify-content: space-between;
gap: 14px;
margin-bottom: 12px;
}
.legend-head strong {
font-size: 0.78rem;
letter-spacing: 0.02em;
}
.legend-head span {
color: var(--muted);
font-size: 0.68rem;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.legend button {
display: inline-flex;
align-items: center;
gap: 7px;
min-height: 31px;
padding: 6px 9px;
border: 1px solid rgba(174, 219, 229, 0.12);
border-radius: 8px;
color: #aebfc5;
background: rgba(4, 13, 18, 0.55);
cursor: pointer;
font-size: 0.68rem;
transition: border-color .18s, color .18s, background .18s;
}
.legend button:hover,
.legend button[aria-pressed="true"] {
color: #f4ffff;
border-color: rgba(105, 223, 208, 0.45);
background: rgba(105, 223, 208, 0.09);
}
.swatch {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--swatch);
box-shadow: 0 0 8px color-mix(in srgb, var(--swatch) 50%, transparent);
}
.aside {
position: sticky;
top: 18px;
display: grid;
gap: 14px;
}
.panel {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(15px);
}
.selection-panel { padding: 20px; }
.selected-topline {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 8px;
}
.homology-chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border: 1px solid rgba(105, 223, 208, 0.24);
border-radius: 999px;
color: var(--cyan);
background: rgba(105, 223, 208, 0.07);
font-size: 0.61rem;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.homology-chip::before {
content: "";
width: 6px;
height: 6px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 9px currentColor;
}
.selected-region {
color: #718994;
font-size: 0.67rem;
}
.selection-panel h2 {
margin: 0;
font-size: 2rem;
letter-spacing: -0.04em;
}
.selected-summary {
margin: 10px 0 17px;
color: #9eb2bb;
font-size: 0.78rem;
line-height: 1.6;
}
.match-box {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 19px;
padding: 12px;
border: 1px solid rgba(105, 223, 208, 0.14);
border-radius: 11px;
background: rgba(105, 223, 208, 0.055);
}
.match-box strong {
color: var(--cyan);
font: 780 1.55rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.match-box span {
color: #91a7b1;
font-size: 0.7rem;
line-height: 1.4;
}
.function-title {
margin: 0 0 9px;
color: #d9e9eb;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.function-list {
display: grid;
gap: 7px;
}
.function-row {
display: grid;
grid-template-columns: 8px 91px minmax(0, 1fr);
gap: 9px;
align-items: start;
padding: 9px 10px;
border: 1px solid rgba(174, 219, 229, 0.08);
border-radius: 9px;
background: rgba(4, 13, 18, 0.34);
}
.function-row .dot {
width: 7px;
height: 7px;
margin-top: 4px;
border-radius: 2px;
background: var(--accent);
}
.function-row strong {
color: #dfeaec;
font-size: 0.71rem;
line-height: 1.45;
}
.function-row p {
margin: 0;
color: #8da2ac;
font-size: 0.67rem;
line-height: 1.45;
}
.function-row.absent {
opacity: 0.58;
border-style: dashed;
}
.concept {
position: relative;
padding: 19px 20px 20px;
overflow: hidden;
}
.concept::after {
content: "";
position: absolute;
width: 120px;
height: 120px;
right: -46px;
bottom: -52px;
border: 22px solid rgba(105, 223, 208, 0.05);
transform: rotate(25deg);
}
.concept h3 {
margin: 0 0 9px;
font-size: 1.05rem;
letter-spacing: -0.025em;
}
.concept p {
margin: 0;
color: #91a7b1;
font-size: 0.73rem;
line-height: 1.6;
}
.concept strong { color: #d8ebec; }
.relation {
display: grid;
grid-template-columns: 1fr auto 1fr;
gap: 8px;
align-items: center;
margin-top: 14px;
padding: 10px;
border: 1px solid rgba(174, 219, 229, 0.1);
border-radius: 9px;
background: rgba(4, 13, 18, 0.36);
text-align: center;
}
.relation span {
color: #d8e8ea;
font-size: 0.66rem;
font-weight: 750;
}
.relation b {
color: var(--cyan);
font-size: 1rem;
}
.relation small {
grid-column: 1 / -1;
color: #6f8792;
font-size: 0.59rem;
letter-spacing: 0.1em;
text-transform: uppercase;
}
body[data-mode="analogy"] .concept::after {
border-color: rgba(255, 139, 121, 0.055);
}
body[data-mode="analogy"] .relation b {
color: var(--coral);
}
.footnote {
margin: 17px 2px 0;
color: #647b86;
font-size: 0.66rem;
line-height: 1.55;
}
.footnote strong { color: #8fa5ae; }
@media (max-width: 1120px) {
.workspace { grid-template-columns: 1fr; }
.aside { position: static; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
.app { padding: 22px 16px 35px; }
.topbar { grid-template-columns: 1fr; }
.mode-wrap { min-width: 0; }
.aside { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
.models { grid-template-columns: 1fr; }
.brand-mark { display: none; }
.viewport { height: 245px; }
.legend-head { flex-direction: column; gap: 4px; }
.card-foot { font-size: 0.6rem; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto !important;
transition-duration: .01ms !important;
}
}
</style>
</head>
<body data-mode="homology">
<main class="app">
<header class="topbar">
<div>
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<span></span><span></span><span></span><span></span>
</div>
<div>
<p class="eyebrow">Comparative anatomy / interactive lab</p>
<h1>One skeleton.<br><em>Four solutions.</em></h1>
</div>
</div>
<p class="intro">
Compare human, bat, bird, and whale forelimbs. Select a colored bone to
trace its corresponding elements across species, then compare what each
structure does.
</p>
</div>
<div class="mode-wrap">
<div class="mode-label">
<span>View the evidence</span>
<span>Shared ancestry ≠ shared function</span>
</div>
<div class="mode-toggle" role="group" aria-label="Interpretive view">
<button type="button" data-mode="homology" aria-pressed="true">
Bone homology
</button>
<button type="button" data-mode="analogy" aria-pressed="false">
Flight resemblance
</button>
</div>
<p class="mode-caption" id="modeCaption">
Bone colors mark corresponding elements of the inherited tetrapod forelimb.
</p>
</div>
</header>
<section class="workspace">
<div>
<div class="models" id="models"></div>
<section class="legend-panel" aria-label="Bone selection">
<div class="legend-head">
<strong>Select a corresponding structure</strong>
<span>You can also click a bone directly in any model.</span>
</div>
<div class="legend" id="legend"></div>
</section>
<p class="footnote">
<strong>Schematic, not to scale.</strong>
Voxel shapes simplify curvature, size, and tissue. The correspondence
follows the conventional tetrapod forelimb plan; whale digit identities
are generalized, and some bones are fused, reduced, or absent.
</p>
</div>
<aside class="aside">
<section class="panel selection-panel">
<div class="selected-topline">
<span class="homology-chip">Direct homology</span>
<span class="selected-region" id="selectedRegion"></span>
</div>
<h2 id="selectedName">Humerus</h2>
<p class="selected-summary" id="selectedSummary"></p>
<div class="match-box">
<strong id="matchCount">4</strong>
<span id="matchCopy">visible correspondences across four forelimbs</span>
</div>
<h3 class="function-title">Compare functions</h3>
<div class="function-list" id="functionRows"></div>
</section>
<section class="panel concept" id="homologyConcept">
<p class="eyebrow">Ancestry lens</p>
<h3>Same structural plan, different jobs</h3>
<p>
The highlighted structures trace to the same inherited tetrapod
forelimb. Their proportions changed for different jobs, so
<strong>homology does not require identical appearance or function.</strong>
</p>
<div class="relation">
<span>Bat humerus</span>
<b>↔</b>
<span>Bird humerus</span>
<small>Homologous: shared ancestral origin</small>
</div>
</section>
<section class="panel concept" id="analogyConcept" hidden>
<p class="eyebrow">Function lens</p>
<h3>Same job, separate origins</h3>
<p>
Bat and bird wings look alike because both support powered flight.
The wing surfaces evolved independently, making them
<strong>analogous structures</strong>—even though their underlying
forelimb bones remain homologous.
</p>
<div class="relation">
<span>Bat wing</span>
<b>≈</b>
<span>Bird wing</span>
<small>Analogous: similar function, separate origin</small>
</div>
</section>
</aside>
</section>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
/* --------------------------------------------------------------------------
Educational content
-------------------------------------------------------------------------- */
const BONES = {
humerus: {
label: "Humerus",
region: "Upper arm",
color: "#69d7c7",
summary:
"The ancestral upper-limb bone. Its changing length, mass, and attachment sites redirect one inherited plan toward gripping, flight, or swimming.",
functions: {
human: "Braces the elbow and positions the forearm for controlled gripping.",
bat: "Acts as the short, stout root of the articulated wing frame.",
bird: "Transfers aerodynamic and muscle loads into the shoulder.",
whale: "Stabilizes the shoulder within the dense swimming paddle."
}
},
radius: {
label: "Radius",
region: "Forearm · thumb side",
color: "#f4c95d",
summary:
"A paired forearm bone that can rotate in humans but becomes a span member or folding strut in flying vertebrates.",
functions: {
human: "Rotates around the ulna to set the palm’s orientation.",
bat: "Forms the long leading edge of the extended wing frame.",
bird: "Supports the leading edge and participates in wing folding.",
whale: "Forms one broad, stiffening plate of the flipper."
}
},
ulna: {
label: "Ulna",
region: "Forearm · little-finger side",
color: "#ff8d70",
summary:
"The second forearm bone. It is a strong rotational brace in humans, relatively reduced in bats, and broad and rigid in whales.",
functions: {
human: "Anchors the elbow and stabilizes forearm rotation.",
bat: "Reduced; contributes relatively little to the elongated wing span.",
bird: "Robust and load-bearing; helps resist wing folding.",
whale: "Broadens and stiffens the flipper against bending."
}
},
carpals: {
label: "Carpals",
region: "Wrist",
color: "#b79cff",
summary:
"Small wrist bones connect the forearm to the hand. Their number and fusion vary without erasing their common tetrapod origin.",
functions: {
human: "A compact, mobile wrist that transfers load into the hand.",
bat: "A flexible wrist that helps regulate membrane tension.",
bird: "Reduced and partly fused into the specialized wrist complex.",
whale: "Embedded in the flipper and contributes little independent motion."
}
},
metacarpals: {
label: "Metacarpals",
region: "Palm / hand",
color: "#69a7ff",
summary:
"Palm bones connect the wrist to the digits. Their elongation and fusion radically reshape the terminal part of the limb.",
functions: {
human: "Spread the palm and provide levers for the fingers.",
bat: "Elongate to support the finger struts and wing membrane.",
bird: "Fuse into the carpometacarpus, creating a stiff wing hand.",
whale: "Broaden into reinforcing elements within the paddle."
}
},
digitI: {
label: "Digit I",
region: "Thumb",
color: "#ff7eb6",
summary:
"The first digit is developmentally homologous across tetrapods, even when it becomes reduced, specialized, or absent.",
functions: {
human: "Opposes the other digits to enable precision and power grip.",
bat: "Remains a small, free hook used in climbing and gripping.",
bird: "The alular thumb braces and helps steer the feathered wing.",
whale: "No visible digit I; the structure is absent in modern whales."
}
},
digitII: {
label: "Digit II",
region: "Index / second digit",
color: "#f58cff",
summary:
"The second digit follows the same inherited sequence, even when one lineage elongates it into a major flight strut.",
functions: {
human: "Supports precise pointing, pinching, and fine manipulation.",
bat: "Elongates into a load-bearing finger of the membrane wing.",
bird: "Forms a major wing digit supporting the primary-feather fan.",
whale: "One of several digits embedded in the steering paddle."
}
},
digitIII: {
label: "Digit III",
region: "Middle / third digit",
color: "#c77dff",
summary:
"The middle digit is another inherited positional landmark. Its proportions reveal how lineages remodel a common limb.",
functions: {
human: "Provides a strong central axis for the gripping hand.",
bat: "Tunes membrane span and tension as a long wing finger.",
bird: "Anchors the central primary-feather array of the wing.",
whale: "Helps stiffen the broad flipper as an embedded digit."
}
},
digitIV: {
label: "Digit IV",
region: "Ring / fourth digit",
color: "#8f9cff",
summary:
"The fourth digit retains its place in the tetrapod digit series despite extensive changes in length and function.",
functions: {
human: "Adds reach and another axis of control to the hand.",
bat: "Extends as another long strut supporting the outer membrane.",
bird: "Supports the rear portion of the feathered wing.",
whale: "Adds stiffness within the flipper’s internal framework."
}
},
digitV: {
label: "Digit V",
region: "Little / fifth digit",
color: "#70d8ff",
summary:
"The fifth digit can remain functional, become a membrane support, or be reduced while retaining correspondence to the ancestral series.",
functions: {
human: "Adds a fifth axis of reach to the hand.",
bat: "Supports the outer edge and tension of the wing membrane.",
bird: "Greatly reduced; its ancestral position is mostly vestigial.",
whale: "Helps stiffen the flipper as one of its embedded digits."
}
}
};
const SPECIES = [
{
id: "human",
title: "Human arm",
number: "01",
subtitle: "Precision & manipulation",
job: "Opposable, dexterous hand",
accent: "#69d7c7",
cameraRadius: 5.15,
segments: [
{ key: "humerus", a: [-1.62, .48, 0], b: [-.72, .16, 0], w: .27 },
{ key: "radius", a: [-.70, .13, .12], b: [.43, .03, .12], w: .17 },
{ key: "ulna", a: [-.70, .13, -.12], b: [.43, .03, -.12], w: .17 },
{ key: "carpals", a: [.42, .03, 0], b: [.62, .01, 0], w: .25 },
{ key: "metacarpals", a: [.60, .01, 0], b: [.96, -.03, 0], w: .25 },
{ key: "digitI", a: [.78, -.06, .03], b: [.61, -.68, .03], w: .12 },
{ key: "digitII", a: [.88, -.05, 0], b: [.98, -.79, 0], w: .12 },
{ key: "digitIII", a: [.96, -.05, 0], b: [1.18, -.87, 0], w: .12 },
{ key: "digitIV", a: [1.03, -.05, 0], b: [1.39, -.75, 0], w: .12 },
{ key: "digitV", a: [1.08, -.04, 0], b: [1.58, -.55, 0], w: .12 }
]
},
{
id: "bat",
title: "Bat wing",
number: "02",
subtitle: "Membrane-powered flight",
job: "Lightweight, articulated wing",
accent: "#b79cff",
cameraRadius: 5.3,
segments: [
{ key: "humerus", a: [-1.68, .55, 0], b: [-.96, .25, 0], w: .25 },
{ key: "radius", a: [-.96, .25, .08], b: [.05, .55, .05], w: .15 },
{ key: "ulna", a: [-.96, .18, -.08], b: [0, .46, -.08], w: .12 },
{ key: "carpals", a: [.03, .53, 0], b: [.22, .54, 0], w: .21 },
{ key: "metacarpals", a: [.20, .54, 0], b: [.75, .82, 0], w: .13 },
{ key: "metacarpals", a: [.20, .54, 0], b: [.92, .55, 0], w: .13 },
{ key: "metacarpals", a: [.20, .54, 0], b: [.83, .22, 0], w: .13 },
{ key: "metacarpals", a: [.20, .54, 0], b: [.62, -.02, 0], w: .13 },
{ key: "digitI", a: [.21, .49, 0], b: [.04, .10, 0], w: .11 },
{ key: "digitII", a: [.75, .82, 0], b: [1.35, 1.15, 0], w: .11 },
{ key: "digitIII", a: [.92, .55, 0], b: [1.62, .66, 0], w: .11 },
{ key: "digitIV", a: [.83, .22, 0], b: [1.52, .08, 0], w: .11 },
{ key: "digitV", a: [.62, -.02, 0], b: [1.13, -.23, 0], w: .11 }
],
surface: {
kind: "flight",
color: "#ff8b79",
points: [
[-1.68, .55], [-.96, .18], [.05, .55],
[1.35, 1.15], [1.62, .66], [1.52, .08], [1.13, -.23]
]
}
},
{
id: "bird",
title: "Bird wing",
number: "03",
subtitle: "Feather-powered flight",
job: "Fused, stiff wing hand",
accent: "#f4c95d",
cameraRadius: 5.55,
segments: [
{ key: "humerus", a: [-1.68, .45, 0], b: [-.86, .22, 0], w: .26 },
{ key: "radius", a: [-.86, .22, .08], b: [.22, .30, .06], w: .16 },
{ key: "ulna", a: [-.86, .15, -.08], b: [.22, .22, -.06], w: .18 },
{ key: "carpals", a: [.20, .28, 0], b: [.38, .28, 0], w: .21 },
{ key: "metacarpals", a: [.38, .28, 0], b: [.82, .26, 0], w: .20 },
{ key: "digitI", a: [.38, .26, 0], b: [.27, -.15, 0], w: .10 },
{ key: "digitII", a: [.55, .28, 0], b: [1.75, .72, 0], w: .12 },
{ key: "digitIII", a: [.72, .27, 0], b: [2.08, .30, 0], w: .12 },
{ key: "digitIV", a: [.62, .24, 0], b: [1.80, -.20, 0], w: .12 },
{ key: "digitV", a: [.42, .22, 0], b: [.52, .02, 0], w: .07 }
],
surface: {
kind: "flight",
color: "#ff8b79",
points: [
[-1.68, .45], [-1.08, -.36], [1.80, -.20],
[2.08, .30], [1.75, .72], [.38, .28], [-.86, .15]
]
}
},
{
id: "whale",
title: "Whale flipper",
number: "04",
subtitle: "Underwater steering",
job: "Broad paddle with embedded digits",
accent: "#69a7ff",
cameraRadius: 5.4,
segments: [
{ key: "humerus", a: [-1.58, .30, 0], b: [-.72, .12, 0], w: .30 },
{ key: "radius", a: [-.72, .12, .14], b: [.43, .08, .14], w: .22 },
{ key: "ulna", a: [-.72, .12, -.14], b: [.43, .08, -.14], w: .22 },
{ key: "carpals", a: [.41, .08, 0], b: [.72, .08, 0], w: .29 },
{ key: "metacarpals", a: [.68, .08, 0], b: [1.18, .08, 0], w: .30 },
{ key: "digitII", a: [.96, .04, .07], b: [1.78, -.18, .08], w: .13 },
{ key: "digitIII", a: [1.02, .08, 0], b: [1.95, -.08, 0], w: .13 },
{ key: "digitIV", a: [1.02, .06, -.07], b: [1.80, .12, -.08], w: .13 },
{ key: "digitV", a: [.94, .03, -.07], b: [1.65, .28, -.08], w: .13 }
],
surface: {
kind: "context",
color: "#69a7ff",
points: [
[-1.58, .30], [-.55, .75], [1.20, .65], [1.96, -.08],
[1.35, -.62], [-.52, -.55]
]
}
}
];
const state = {
selected: "humerus",
mode: "homology"
};
const modelsGrid = document.querySelector("#models");
const legend = document.querySelector("#legend");
modelsGrid.innerHTML = SPECIES.map((sp) => `
<article class="model-card" data-id="${sp.id}" style="--accent:${sp.accent}">
<header class="card-head">
<div>
<div class="card-title-row">
<span class="card-number">${sp.number}</span>
<h2>${sp.title}</h2>
</div>
<p class="card-subtitle">${sp.subtitle} · ${sp.job}</p>
</div>
<span class="view-badge">Bone plan</span>
</header>
<div class="viewport" data-id="${sp.id}" aria-label="Interactive 3D model of ${sp.title}">
<div class="hover-tip" aria-hidden="true"></div>
<div class="surface-note" hidden>Flight surface · evolved independently</div>
</div>
<footer class="card-foot">
<span class="match-state">Humerus · 4/4 visible matches</span>
<button class="reset-view" type="button">Reset view</button>
</footer>
</article>
`).join("");
legend.innerHTML = Object.entries(BONES).map(([key, bone]) => `
<button type="button" data-bone="${key}" aria-pressed="${key === state.selected}">
<span class="swatch" style="--swatch:${bone.color}"></span>
${bone.label}
</button>
`).join("");
/* --------------------------------------------------------------------------
Voxel model construction
-------------------------------------------------------------------------- */
const voxelGeometry = new THREE.BoxGeometry(1, 1, 1);
const upAxis = new THREE.Vector3(0, 1, 0);
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function addVoxelSegment(group, materials, pickables, segment) {
const a = new THREE.Vector3(...segment.a);
const b = new THREE.Vector3(...segment.b);
const direction = b.clone().sub(a);
const length = direction.length();
if (length < 0.001) return;
const count = Math.max(2, Math.ceil(length / 0.22));
const blockLength = length / count;
const quaternion = new THREE.Quaternion().setFromUnitVectors(
upAxis,
direction.clone().normalize()
);
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
const mesh = new THREE.Mesh(voxelGeometry, materials[segment.key]);
mesh.position.copy(a).lerp(b, t);
mesh.quaternion.copy(quaternion);
mesh.scale.set(segment.w, blockLength * 0.82, segment.w);
mesh.userData.baseScale = mesh.scale.clone();
mesh.userData.boneKey = segment.key;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
pickables.push(mesh);
}
}
function buildModel(species) {
const group = new THREE.Group();
const pickables = [];
const materials = {};
for (const [key, bone] of Object.entries(BONES)) {
materials[key] = new THREE.MeshStandardMaterial({
color: bone.color,
roughness: 0.58,
metalness: 0.035,
transparent: true,
opacity: 0.74,
emissive: new THREE.Color(bone.color),
emissiveIntensity: 0
});
}
for (const segment of species.segments) {
addVoxelSegment(group, materials, pickables, segment);
}
let surface = null;
if (species.surface) {
const shape = new THREE.Shape(
species.surface.points.map(([x, y]) => new THREE.Vector2(x, y))
);
const geometry = new THREE.ShapeGeometry(shape);
const material = new THREE.MeshBasicMaterial({
color: species.surface.color,
transparent: true,
opacity: species.surface.kind === "flight" ? 0 : 0.075,
side: THREE.DoubleSide,
depthWrite: false
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.z = -0.18;
mesh.renderOrder = -2;
group.add(mesh);
const linePoints = species.surface.points.map(
([x, y]) => new THREE.Vector3(x, y, -0.165)
);
const lineMaterial = new THREE.LineBasicMaterial({
color: species.surface.color,
transparent: true,
opacity: species.surface.kind === "flight" ? 0 : 0.22,
depthWrite: false
});
const line = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(linePoints),
lineMaterial
);
line.renderOrder = -1;
group.add(line);
surface = { kind: species.surface.kind, mesh, material, line, lineMaterial };
}
return { group, pickables, materials, surface };
}
/* --------------------------------------------------------------------------
Viewer with directly implemented orbit / zoom / picking controls
-------------------------------------------------------------------------- */
class Viewer {
constructor(container, species) {
this.container = container;
this.species = species;
this.canvas = document.createElement("canvas");
this.canvas.tabIndex = 0;
this.canvas.setAttribute(
"aria-label",
`${species.title} model. Drag to orbit, scroll to zoom, and select bones with the pointer.`
);
container.prepend(this.canvas);
this.renderer = new THREE.WebGLRenderer({
canvas: this.canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
this.renderer.setClearColor(0x000000, 0);
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
this.renderer.toneMappingExposure = 1.12;
this.renderer.shadowMap.enabled = true;
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(40, 1, 0.1, 50);
this.target = new THREE.Vector3(0.13, 0.02, 0);
this.theta = -0.08;
this.phi = 1.18;
this.radius = species.cameraRadius;
this.raycaster = new THREE.Raycaster();
this.pointer = new THREE.Vector2();
this.hoverKey = null;
this.selected = state.selected;
this.mode = state.mode;
this.dragging = false;
this.pointerId = null;
this.moved = false;
this.lastX = 0;
this.lastY = 0;
this.tip = container.querySelector(".hover-tip");
const hemisphere = new THREE.HemisphereLight(0xc9f7ff, 0x15202a, 2.1);
this.scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(3.2, 5.5, 5.4);
keyLight.castShadow = true;
this.scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x62d9ff, 1.55);
rimLight.position.set(-4, 1.2, 2.2);
this.scene.add(rimLight);
const warmLight = new THREE.DirectionalLight(0xffc17d, 0.8);
warmLight.position.set(1, -2, 3);
this.scene.add(warmLight);
const grid = new THREE.GridHelper(6, 18, 0x315b62, 0x19343d);
grid.position.y = -1.22;
grid.material.transparent = true;
grid.material.opacity = 0.3;
this.scene.add(grid);
this.model = buildModel(species);
this.scene.add(this.model.group);
this.attachControls();
this.updateCamera();
this.resizeObserver = new ResizeObserver(() => this.resize());
this.resizeObserver.observe(container);
this.resize();
this.setMode(state.mode);
this.setSelected(state.selected);
}
resize() {
const width = Math.max(1, this.container.clientWidth);
const height = Math.max(1, this.container.clientHeight);
this.renderer.setSize(width, height, false);
this.camera.aspect = width / height;
this.camera.updateProjectionMatrix();
}
updateCamera() {
const sinPhi = Math.sin(this.phi);
this.camera.position.set(
this.target.x + this.radius * sinPhi * Math.sin(this.theta),
this.target.y + this.radius * Math.cos(this.phi),
this.target.z + this.radius * sinPhi * Math.cos(this.theta)
);
this.camera.lookAt(this.target);
}
resetView() {
this.theta = -0.08;
this.phi = 1.18;
this.radius = this.species.cameraRadius;
this.updateCamera();
}
attachControls() {
this.canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.pointerType === "mouse") return;
this.dragging = true;
this.moved = false;
this.pointerId = event.pointerId;
this.lastX = event.clientX;
this.lastY = event.clientY;
this.canvas.setPointerCapture(event.pointerId);
this.canvas.style.cursor = "grabbing";
this.tip.classList.remove("visible");
});
this.canvas.addEventListener("pointermove", (event) => {
if (this.dragging && event.pointerId === this.pointerId) {
const dx = event.clientX - this.lastX;
const dy = event.clientY - this.lastY;
if (Math.abs(dx) + Math.abs(dy) > 3) this.moved = true;
this.theta -= dx * 0.008;
this.phi = THREE.MathUtils.clamp(this.phi + dy * 0.006, 0.48, 2.48);
this.lastX = event.clientX;
this.lastY = event.clientY;
this.updateCamera();
return;
}
const key = this.keyAt(event.clientX, event.clientY);
this.hoverKey = key;
this.canvas.style.cursor = key ? "pointer" : "grab";
if (!key) {
this.tip.classList.remove("visible");
return;
}
const rect = this.canvas.getBoundingClientRect();
const localX = event.clientX - rect.left;
const localY = event.clientY - rect.top;
this.tip.textContent = `${BONES[key].label} · select to compare`;
this.tip.style.left = `${Math.min(localX + 12, rect.width - 178)}px`;
this.tip.style.top = `${Math.max(8, localY - 37)}px`;
this.tip.classList.add("visible");
});
this.canvas.addEventListener("pointerup", (event) => {
if (event.pointerId !== this.pointerId) return;
const wasMoved = this.moved;
this.dragging = false;
this.pointerId = null;
this.canvas.style.cursor = this.hoverKey ? "pointer" : "grab";
if (this.canvas.hasPointerCapture(event.pointerId)) {
this.canvas.releasePointerCapture(event.pointerId);
}
if (!wasMoved) {
const key = this.keyAt(event.clientX, event.clientY);
if (key) selectBone(key);
}
});
this.canvas.addEventListener("pointercancel", () => {
this.dragging = false;
this.pointerId = null;
this.canvas.style.cursor = "grab";
this.tip.classList.remove("visible");
});
this.canvas.addEventListener("pointerleave", () => {
if (!this.dragging) {
this.hoverKey = null;
this.tip.classList.remove("visible");
}
});
this.canvas.addEventListener("wheel", (event) => {
event.preventDefault();
const factor = Math.exp(event.deltaY * 0.001);
this.radius = THREE.MathUtils.clamp(this.radius * factor, 3.45, 8.2);
this.updateCamera();
}, { passive: false });
this.canvas.addEventListener("dblclick", () => this.resetView());
this.canvas.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") this.theta -= 0.1;
else if (key === "arrowright") this.theta += 0.1;
else if (key === "arrowup") this.phi = Math.max(0.48, this.phi - 0.08);
else if (key === "arrowdown") this.phi = Math.min(2.48, this.phi + 0.08);
else if (key === "+" || key === "=") this.radius = Math.max(3.45, this.radius - 0.25);
else if (key === "-" || key === "_") this.radius = Math.min(8.2, this.radius + 0.25);
else if (key === "r") {
this.resetView();
return;
} else {
return;
}
event.preventDefault();
this.updateCamera();
});
}
keyAt(clientX, clientY) {
const rect = this.canvas.getBoundingClientRect();
this.pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
this.pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
this.raycaster.setFromCamera(this.pointer, this.camera);
const hits = this.raycaster.intersectObjects(this.model.pickables, false);
return hits.length ? hits[0].object.userData.boneKey : null;
}
setSelected(key) {
this.selected = key;
this.updateMaterials();
}
setMode(mode) {
this.mode = mode;
this.updateMaterials();
}
updateMaterials() {
for (const [key, material] of Object.entries(this.model.materials)) {
const selected = key === this.selected;
if (this.mode === "analogy") {
material.opacity = selected ? 0.30 : 0.10;
} else {
material.opacity = selected ? 0.98 : 0.70;
}
material.depthWrite = material.opacity > 0.45;
}
if (this.model.surface) {
const surface = this.model.surface;
if (surface.kind === "flight") {
const visible = this.mode === "analogy";
surface.mesh.visible = visible;
surface.line.visible = visible;
surface.material.opacity = 0.43;
surface.lineMaterial.opacity = 0.82;
} else {
surface.mesh.visible = true;
surface.line.visible = true;
surface.material.opacity = this.mode === "analogy" ? 0.035 : 0.075;
surface.lineMaterial.opacity = this.mode === "analogy" ? 0.10 : 0.22;
}
}
for (const mesh of this.model.pickables) {
const selected = mesh.userData.boneKey === this.selected;
mesh.scale.copy(mesh.userData.baseScale).multiplyScalar(selected ? 1.055 : 1);
}
}
render(time) {
const pulse = reduceMotion ? 0 : (Math.sin(time * 0.004) + 1) * 0.045;
for (const [key, material] of Object.entries(this.model.materials)) {
if (key === this.selected) {
material.emissiveIntensity = 0.17 + pulse;
} else if (key === this.hoverKey) {
material.emissiveIntensity = 0.18;
} else {
material.emissiveIntensity = 0;
}
}
this.renderer.render(this.scene, this.camera);
}
}
/* --------------------------------------------------------------------------
Interface and interpretation
-------------------------------------------------------------------------- */
const viewers = new Map();
for (const species of SPECIES) {
const viewport = document.querySelector(`.viewport[data-id="${species.id}"]`);
const viewer = new Viewer(viewport, species);
viewers.set(species.id, viewer);
const card = document.querySelector(`.model-card[data-id="${species.id}"]`);
card.querySelector(".reset-view").addEventListener("click", () => {
viewer.resetView();
});
}
function selectBone(key) {
state.selected = key;
for (const viewer of viewers.values()) {
viewer.setSelected(key);
}
document.querySelectorAll("[data-bone]").forEach((button) => {
button.setAttribute("aria-pressed", String(button.dataset.bone === key));
});
updatePanel();
}
function updatePanel() {
const bone = BONES[state.selected];
const visibleSpecies = SPECIES.filter((species) =>
species.segments.some((segment) => segment.key === state.selected)
);
const absentSpecies = SPECIES.filter((species) =>
!species.segments.some((segment) => segment.key === state.selected)
);
document.querySelector("#selectedName").textContent = bone.label;
document.querySelector("#selectedRegion").textContent = bone.region;
document.querySelector("#selectedSummary").textContent = bone.summary;
document.querySelector("#matchCount").textContent = visibleSpecies.length;
document.querySelector("#matchCopy").textContent =
absentSpecies.length === 0
? "visible correspondences across all four forelimbs"
: `visible correspondences; absent in ${absentSpecies.map((s) => s.title.toLowerCase()).join(" and ")}`;
document.querySelector("#functionRows").innerHTML = SPECIES.map((species) => {
const absent = !species.segments.some((segment) => segment.key === state.selected);
const text = bone.functions[species.id];
return `
<div class="function-row ${absent ? "absent" : ""}" style="--accent:${species.accent}">
<span class="dot"></span>
<strong>${species.title}</strong>
<p>${text}</p>
</div>
`;
}).join("");
for (const species of SPECIES) {
const card = document.querySelector(`.model-card[data-id="${species.id}"]`);
const present = visibleSpecies.some((item) => item.id === species.id);
card.querySelector(".match-state").textContent =
`${bone.label} · ${present ? "visible match" : "no visible counterpart"}`;
}
}
function setMode(mode) {
state.mode = mode;
document.body.dataset.mode = mode;
document.querySelectorAll("[data-mode]").forEach((button) => {
button.setAttribute("aria-pressed", String(button.dataset.mode === mode));
});
document.querySelector("#homologyConcept").hidden = mode !== "homology";
document.querySelector("#analogyConcept").hidden = mode !== "analogy";
document.querySelector("#modeCaption").textContent =
mode === "homology"
? "Bone colors mark corresponding elements of the inherited tetrapod forelimb."
: "Colored sheets mark independently evolved flight surfaces; the bones beneath remain homologous.";
for (const viewer of viewers.values()) {
viewer.setMode(mode);
}
for (const species of SPECIES) {
const card = document.querySelector(`.model-card[data-id="${species.id}"]`);
const isFlight = mode === "analogy" && (species.id === "bat" || species.id === "bird");
card.querySelector(".view-badge").textContent =
isFlight ? "Flight surface" : "Bone plan";
card.querySelector(".surface-note").hidden = !isFlight;
}
}
document.querySelectorAll("[data-mode]").forEach((button) => {
button.addEventListener("click", () => setMode(button.dataset.mode));
});
document.querySelectorAll("[data-bone]").forEach((button) => {
button.addEventListener("click", () => selectBone(button.dataset.bone));
});
setMode("homology");
selectBone("humerus");
function animate(time) {
for (const viewer of viewers.values()) {
viewer.render(time);
}
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```