Prompt specification
Build or customize the Three.js 3D scene "Wing flipper and arm comparison" 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: Wing flipper and arm comparison
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/wing-flipper-and-arm-comparison-x0918
Scene Description Prompt:
Wing flipper and arm comparison. Place three stylized limb models around a shared skeletal pattern inset; highlight homologous components while separating similarities of ancestry from differences of current function. Please build this with Three.js from cdnjs in one self-contained HTML file, using stylized solid shapes.
Working Three.js Starter (wing-flipper-and-arm-comparison-x0918):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One Skeletal Plan, Three Limbs</title>
<style>
:root {
color-scheme: dark;
--bg: #071018;
--panel: rgba(12, 23, 32, 0.82);
--panel-solid: #0d1922;
--line: rgba(177, 211, 225, 0.18);
--text: #eef5f6;
--muted: #8ea6b3;
--cyan: #65d7ff;
--blue: #668cff;
--amber: #ffb45f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas.dragging {
cursor: grabbing;
}
.header {
position: fixed;
z-index: 10;
top: 28px;
left: 32px;
max-width: 560px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 10px;
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(28px, 4vw, 54px);
font-weight: 720;
letter-spacing: -0.055em;
line-height: 0.96;
}
.subtitle {
max-width: 520px;
margin: 14px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.view-controls {
position: fixed;
z-index: 20;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 12px;
}
.segmented {
display: flex;
padding: 4px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(9, 18, 26, 0.84);
backdrop-filter: blur(16px);
}
.segmented button {
min-width: 116px;
padding: 10px 14px;
border: 0;
border-radius: 9px;
color: var(--muted);
background: transparent;
cursor: pointer;
transition:
color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.segmented button:hover {
color: var(--text);
}
.segmented button.active {
color: #071018;
background: #dff8ff;
box-shadow: 0 5px 22px rgba(101, 215, 255, 0.16);
}
.icon-button,
.reset-button {
border: 1px solid var(--line);
color: var(--text);
background: rgba(9, 18, 26, 0.84);
backdrop-filter: blur(16px);
cursor: pointer;
}
.icon-button {
width: 42px;
height: 42px;
border-radius: 12px;
font-size: 18px;
}
.reset-button {
padding: 11px 13px;
border-radius: 11px;
color: var(--muted);
font-size: 12px;
}
.icon-button:hover,
.reset-button:hover {
color: var(--text);
border-color: rgba(177, 211, 225, 0.38);
}
.legend,
.inspector {
position: fixed;
z-index: 15;
border: 1px solid var(--line);
border-radius: 17px;
background: var(--panel);
backdrop-filter: blur(18px);
box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
}
.legend {
left: 30px;
bottom: 28px;
width: 286px;
padding: 17px;
}
.legend h2,
.inspector h2 {
margin: 0;
font-size: 13px;
font-weight: 700;
letter-spacing: -0.01em;
}
.legend p,
.inspector p {
margin: 7px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.legend-items {
display: grid;
gap: 9px;
margin-top: 15px;
}
.legend-row {
display: grid;
grid-template-columns: 11px 1fr auto;
align-items: center;
gap: 9px;
color: #c9d8de;
font-size: 12px;
}
.legend-row small {
color: #718996;
font-size: 10px;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 50%;
box-shadow: 0 0 12px currentColor;
}
.overlay-toggle {
display: flex;
align-items: center;
gap: 9px;
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
cursor: pointer;
}
.overlay-toggle input {
accent-color: var(--cyan);
}
.inspector {
right: 30px;
bottom: 28px;
width: min(350px, calc(100vw - 60px));
padding: 19px;
}
.inspector-kicker {
margin-bottom: 7px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.inspector-title {
font-size: 20px;
font-weight: 700;
letter-spacing: -0.025em;
}
.comparison {
display: grid;
gap: 10px;
margin-top: 15px;
}
.comparison-box {
padding: 12px;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
}
.comparison-box strong {
display: block;
margin-bottom: 5px;
color: #d9e9ee;
font-size: 10px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.comparison-box p {
margin: 0;
font-size: 11px;
line-height: 1.5;
}
.model-label {
position: fixed;
z-index: 8;
display: flex;
align-items: center;
gap: 10px;
min-width: 160px;
padding: 10px 12px;
border: 1px solid rgba(177, 211, 225, 0.22);
border-radius: 12px;
background: rgba(7, 16, 24, 0.8);
backdrop-filter: blur(12px);
pointer-events: none;
transform: translate(-50%, -100%);
transition: opacity 100ms ease;
}
.model-label::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 19px;
background: rgba(177, 211, 225, 0.35);
content: "";
}
.model-number {
display: grid;
width: 27px;
height: 27px;
place-items: center;
border-radius: 8px;
color: #071018;
font-size: 10px;
font-weight: 900;
}
.model-label strong,
.model-label small {
display: block;
}
.model-label strong {
font-size: 12px;
}
.model-label small {
margin-top: 2px;
color: var(--muted);
font-size: 10px;
}
.help {
position: fixed;
z-index: 8;
bottom: 30px;
left: 50%;
padding: 9px 12px;
border: 1px solid rgba(177, 211, 225, 0.12);
border-radius: 999px;
color: #718996;
background: rgba(7, 16, 24, 0.68);
font-size: 10px;
letter-spacing: 0.03em;
pointer-events: none;
transform: translateX(-50%);
}
.hover-tag {
position: fixed;
z-index: 30;
padding: 7px 9px;
border: 1px solid rgba(177, 211, 225, 0.25);
border-radius: 8px;
color: var(--text);
background: rgba(5, 12, 18, 0.92);
font-size: 10px;
pointer-events: none;
opacity: 0;
transform: translate(12px, 12px);
transition: opacity 100ms ease;
}
.hover-tag.visible {
opacity: 1;
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
color: var(--muted);
background: var(--bg);
font-size: 12px;
letter-spacing: 0.16em;
text-transform: uppercase;
}
@media (max-width: 900px) {
.header {
top: 20px;
left: 20px;
max-width: 390px;
}
.subtitle {
display: none;
}
.view-controls {
top: 18px;
right: 18px;
}
.segmented button {
min-width: 92px;
padding: 9px 10px;
font-size: 11px;
}
.reset-button {
display: none;
}
.legend {
left: 18px;
bottom: 18px;
width: 220px;
}
.inspector {
right: 18px;
bottom: 18px;
width: 260px;
}
.help {
display: none;
}
}
@media (max-width: 650px) {
.header {
top: 16px;
left: 16px;
}
.eyebrow {
margin-bottom: 7px;
font-size: 9px;
}
h1 {
max-width: 240px;
font-size: 28px;
}
.view-controls {
top: 104px;
left: 16px;
right: auto;
}
.segmented button {
min-width: 92px;
}
.legend {
display: none;
}
.inspector {
left: 16px;
right: 16px;
bottom: 16px;
width: auto;
}
.model-label {
min-width: 135px;
padding: 8px 9px;
}
.model-label strong {
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive three-dimensional comparison of a bird wing, whale flipper, and human arm"></div>
<header class="header">
<div class="eyebrow">Comparative anatomy · Homology</div>
<h1>One skeletal plan.<br />Three working limbs.</h1>
<p class="subtitle">
Bird wings, whale flippers, and human arms began with the same inherited
forelimb elements. Their proportions and shapes changed as each lineage
adapted to a different environment.
</p>
</header>
<nav class="view-controls" aria-label="Visualization controls">
<div class="segmented">
<button class="active" data-mode="homology" aria-pressed="true">
Homology
</button>
<button data-mode="function" aria-pressed="false">
Current function
</button>
</div>
<button class="reset-button" id="reset-view">Reset view</button>
<button class="icon-button" id="toggle-labels" title="Show or hide model labels" aria-label="Toggle model labels">
⌖
</button>
</nav>
<section class="legend" aria-label="Legend">
<h2 id="legend-title">Homologous elements</h2>
<p id="legend-description">
Matching colors identify inherited skeletal components, even when their
shapes and proportions differ.
</p>
<div class="legend-items" id="legend-items"></div>
<label class="overlay-toggle">
<input type="checkbox" id="bone-toggle" checked />
Show skeletal overlay
</label>
</section>
<aside class="inspector" aria-live="polite">
<div class="inspector-kicker" id="inspector-kicker">Select a colored element</div>
<div class="inspector-title" id="inspector-title">Read the shared plan</div>
<div class="comparison">
<div class="comparison-box">
<strong>Shared ancestry</strong>
<p id="ancestry-text">
The same upper arm, paired forearm, wrist, palm, and digit elements
are present in all three limbs.
</p>
</div>
<div class="comparison-box">
<strong>Current function</strong>
<p id="function-text">
Switch views to see how the shared elements became specialized for
flight, aquatic steering, and human manipulation.
</p>
</div>
</div>
</aside>
<div class="model-label" id="label-bird">
<div class="model-number" style="background:#65d7ff">01</div>
<div>
<strong>Bird wing</strong>
<small>Flight · feathered lifting surface</small>
</div>
</div>
<div class="model-label" id="label-whale">
<div class="model-number" style="background:#668cff">02</div>
<div>
<strong>Whale flipper</strong>
<small>Aquatic steering · broad paddle</small>
</div>
</div>
<div class="model-label" id="label-human">
<div class="model-number" style="background:#ffb45f">03</div>
<div>
<strong>Human arm</strong>
<small>Manipulation · grasping hand</small>
</div>
</div>
<div class="help">Drag to orbit · Scroll to zoom · Select a bone</div>
<div class="hover-tag" id="hover-tag"></div>
<div id="loading">Loading comparative anatomy…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x071018, 1);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional limb anatomy comparison"
);
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x071018, 0.026);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 0.1, 0);
let azimuth = 0;
let elevation = 1.31;
let cameraRadius = 15;
function updateCamera() {
const sinElevation = Math.sin(elevation);
camera.position.set(
target.x + cameraRadius * sinElevation * Math.sin(azimuth),
target.y + cameraRadius * Math.cos(elevation),
target.z + cameraRadius * sinElevation * Math.cos(azimuth)
);
camera.lookAt(target);
}
updateCamera();
scene.add(new THREE.HemisphereLight(0xc6e7ff, 0x15202b, 2.1));
const keyLight = new THREE.DirectionalLight(0xffffff, 2.8);
keyLight.position.set(-4, 7, 10);
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x65d7ff, 2.2);
rimLight.position.set(8, -3, 5);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffb45f, 26, 18, 2);
warmLight.position.set(-5, -4, 5);
scene.add(warmLight);
const bonePalette = {
humerus: "#ef6178",
radius: "#f4a261",
ulna: "#36b6a2",
carpals: "#8b73ff",
metacarpals: "#d96bc3",
phalanges: "#f3d36b"
};
const speciesPalette = {
bird: "#65d7ff",
whale: "#668cff",
human: "#ffb45f"
};
const speciesNames = {
bird: "Bird wing",
whale: "Whale flipper",
human: "Human arm"
};
const boneInfo = {
humerus: {
name: "Humerus",
common:
"The single upper-arm element between shoulder and elbow. It is the proximal anchor for the entire limb.",
function: {
bird:
"A short, sturdy anchor that transfers forces from the shoulder into the flight feathers.",
whale:
"A short, massive lever that anchors the flipper to the shoulder and braces the paddle.",
human:
"A long lever that raises, lowers, and rotates the forearm relative to the torso."
}
},
radius: {
name: "Radius",
common:
"One of the paired forearm elements. Together, radius and ulna connect the elbow to the wrist.",
function: {
bird:
"Part of a relatively stiff forearm that supports and positions the feathered wing.",
whale:
"An internal brace that helps distribute pressure through the broad flipper.",
human:
"Rotates against the ulna to turn the palm downward, upward, and inward."
}
},
ulna: {
name: "Ulna",
common:
"The second forearm element. It links the elbow to the wrist and provides a stable opposing partner to the radius.",
function: {
bird:
"Stabilizes the elbow and maintains the controlled angle of the wing.",
whale:
"Forms a firm internal framework within the flexible flipper.",
human:
"Acts as the stable axis around which the radius and hand rotate."
}
},
carpals: {
name: "Carpals",
common:
"A cluster of small wrist elements that connect the forearm to the palm.",
function: {
bird:
"A compact wrist region that anchors the flight feathers and limits unnecessary movement.",
whale:
"Provides a flexible transition between the arm and the broad steering surface.",
human:
"Allows the hand to flex, extend, and deviate at the wrist."
}
},
metacarpals: {
name: "Metacarpals",
common:
"The elongated palm elements between the wrist and the digits.",
function: {
bird:
"Reduced and partly fused elements create a compact, reinforced base for the flight feathers.",
whale:
"Spread and lengthened elements help distribute force across the paddle.",
human:
"A lengthened, mobile palm provides the reach needed for gripping and tool use."
}
},
phalanges: {
name: "Phalanges",
common:
"The bone series within the digits. Their number and arrangement reveal how the inherited hand was remodeled.",
function: {
bird:
"Mostly reduced and fused into a compact support for the primary feathers.",
whale:
"Short, robust digits spread across the leading edge to stiffen the flipper.",
human:
"Long, jointed fingers form an opposable, dexterous grasping hand."
}
}
};
const models = {};
const boneMeshes = [];
function makeTissueMaterial(color) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.62,
metalness: 0.02,
transparent: true,
opacity: 0.23,
depthWrite: false,
side: THREE.DoubleSide
});
}
function extrudedShape(shape, depth, material, bevelSize = 0.035) {
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
steps: 1,
curveSegments: 18,
bevelEnabled: true,
bevelSegments: 2,
bevelSize,
bevelThickness: bevelSize
});
geometry.translate(0, 0, -depth / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.renderOrder = 0;
return mesh;
}
function createBone(model, category, pointA, pointB, radius) {
const a = new THREE.Vector3(...pointA);
const b = new THREE.Vector3(...pointB);
const midpoint = a.clone().add(b).multiplyScalar(0.5);
const direction = b.clone().sub(a);
const length = direction.length();
const material = new THREE.MeshStandardMaterial({
color: bonePalette[category],
emissive: bonePalette[category],
emissiveIntensity: 0.08,
roughness: 0.45,
metalness: 0.04
});
const group = new THREE.Group();
group.position.copy(midpoint);
group.position.z = 0.34;
group.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(
radius * 0.78,
radius * 0.9,
Math.max(0.04, length),
12
),
material
);
shaft.scale.z = 0.74;
group.add(shaft);
const capGeometry = new THREE.SphereGeometry(radius, 14, 10);
const capA = new THREE.Mesh(capGeometry, material);
capA.position.y = -length / 2;
capA.scale.z = 0.62;
group.add(capA);
const capB = new THREE.Mesh(capGeometry, material);
capB.position.y = length / 2;
capB.scale.z = 0.62;
group.add(capB);
group.userData.category = category;
group.userData.species = model.key;
group.userData.material = material;
group.userData.baseColor = new THREE.Color(bonePalette[category]);
group.traverse((child) => {
if (child.isMesh) {
child.userData.bone = group;
boneMeshes.push(child);
}
});
model.group.add(group);
model.bones.push(group);
return group;
}
function addBone(model, category, a, b, radius = 0.13) {
return createBone(model, category, a, b, radius);
}
function createFeather(root, length, width, angle, material) {
const shape = new THREE.Shape();
shape.moveTo(0, -width * 0.38);
shape.quadraticCurveTo(
length * 0.42,
-width * 0.62,
length,
-width * 0.05
);
shape.quadraticCurveTo(
length * 0.48,
width * 0.64,
0,
width * 0.38
);
shape.closePath();
const feather = extrudedShape(shape, 0.13, material, 0.025);
feather.position.set(root[0], root[1], -0.18);
feather.rotation.z = angle;
return feather;
}
function createModel(key, position, rotation, neutralTissue) {
const group = new THREE.Group();
group.position.set(...position);
group.rotation.z = rotation;
const tissueMaterial = makeTissueMaterial(neutralTissue);
const model = {
key,
group,
tissueMaterial,
bones: [],
anchor: new THREE.Vector3()
};
scene.add(group);
models[key] = model;
return model;
}
// ------------------------------------------------------------------
// Bird wing
// ------------------------------------------------------------------
const bird = createModel(
"bird",
[-4.45, 2.15, 0.05],
-0.11,
"#d6e0e4"
);
const birdCover = new THREE.Shape();
birdCover.moveTo(-0.08, 0.22);
birdCover.bezierCurveTo(0.48, 0.44, 1.3, 0.38, 2.18, 0.25);
birdCover.bezierCurveTo(2.35, 0.17, 2.35, -0.12, 2.12, -0.25);
birdCover.bezierCurveTo(1.35, -0.36, 0.5, -0.3, -0.08, -0.23);
birdCover.closePath();
bird.group.add(
extrudedShape(birdCover, 0.24, bird.tissueMaterial, 0.055)
);
const featherSpecs = [
[1.82, 0.13, 1.68, 0.31, 0.36],
[1.93, 0.08, 1.86, 0.26, 0.4],
[2.02, 0.02, 2.0, 0.18, 0.43],
[2.02, -0.05, 1.95, 0.02, 0.44],
[1.96, -0.12, 1.75, -0.24, 0.42],
[1.86, -0.18, 1.45, -0.49, 0.38]
];
featherSpecs.forEach(([x, y, length, angle, width]) => {
bird.group.add(
createFeather([x, y], length, width, angle, bird.tissueMaterial)
);
});
addBone(bird, "humerus", [0, 0], [0.92, -0.02], 0.19);
addBone(bird, "radius", [0.98, 0.07], [1.9, 0.13], 0.105);
addBone(bird, "ulna", [0.98, -0.08], [1.9, -0.06], 0.11);
addBone(bird, "carpals", [1.92, 0.08], [2.16, 0.09], 0.13);
addBone(bird, "metacarpals", [2.18, 0.09], [2.86, 0.17], 0.14);
addBone(bird, "phalanges", [2.88, 0.17], [3.68, 0.6], 0.09);
addBone(bird, "phalanges", [2.88, 0.17], [3.88, 0.15], 0.085);
addBone(bird, "phalanges", [2.88, 0.17], [3.65, -0.35], 0.085);
bird.anchor.set(0.55, 1.3, 0.2);
// ------------------------------------------------------------------
// Whale flipper
// ------------------------------------------------------------------
const whale = createModel(
"whale",
[3.15, 2.05, 0],
0.08,
"#a7bac4"
);
const flipper = new THREE.Shape();
flipper.moveTo(-0.12, 0.24);
flipper.bezierCurveTo(0.42, 0.48, 1.05, 0.55, 1.75, 0.7);
flipper.bezierCurveTo(2.45, 0.86, 3.12, 1.02, 3.5, 0.68);
flipper.bezierCurveTo(3.83, 0.38, 3.75, -0.16, 3.42, -0.54);
flipper.bezierCurveTo(3.02, -0.98, 2.25, -1.03, 1.58, -0.72);
flipper.bezierCurveTo(0.95, -0.46, 0.42, -0.38, -0.12, -0.24);
flipper.closePath();
whale.group.add(
extrudedShape(flipper, 0.28, whale.tissueMaterial, 0.07)
);
addBone(whale, "humerus", [0, 0], [0.77, 0.02], 0.22);
addBone(whale, "radius", [0.81, 0.12], [1.51, 0.18], 0.12);
addBone(whale, "ulna", [0.81, -0.1], [1.51, -0.14], 0.12);
addBone(whale, "carpals", [1.53, 0.1], [1.82, 0.1], 0.16);
addBone(whale, "metacarpals", [1.84, 0.11], [2.48, 0.17], 0.13);
addBone(whale, "phalanges", [2.5, 0.18], [3.13, 0.7], 0.095);
addBone(whale, "phalanges", [2.5, 0.18], [3.35, 0.24], 0.09);
addBone(whale, "phalanges", [2.5, 0.18], [3.06, -0.37], 0.09);
addBone(whale, "phalanges", [2.5, 0.18], [2.87, -0.69], 0.08);
whale.anchor.set(1.0, 1.28, 0.2);
// ------------------------------------------------------------------
// Human arm
// ------------------------------------------------------------------
const human = createModel(
"human",
[-1.65, -2.85, -0.04],
-0.18,
"#c9aa99"
);
const armShape = new THREE.Shape();
armShape.moveTo(-0.13, 0.23);
armShape.bezierCurveTo(0.4, 0.4, 0.82, 0.33, 1.05, 0.22);
armShape.bezierCurveTo(1.42, 0.09, 1.82, 0.18, 2.18, 0.3);
armShape.bezierCurveTo(2.45, 0.39, 2.62, 0.3, 2.68, 0.12);
armShape.bezierCurveTo(2.58, -0.15, 2.2, -0.27, 1.82, -0.22);
armShape.bezierCurveTo(1.42, -0.17, 1.08, -0.24, 0.81, -0.27);
armShape.bezierCurveTo(0.42, -0.31, 0.13, -0.25, -0.13, -0.23);
armShape.closePath();
human.group.add(
extrudedShape(armShape, 0.25, human.tissueMaterial, 0.065)
);
const palm = new THREE.Shape();
palm.moveTo(2.35, 0.27);
palm.bezierCurveTo(2.55, 0.38, 2.82, 0.34, 2.98, 0.2);
palm.bezierCurveTo(3.03, 0.04, 2.92, -0.22, 2.66, -0.3);
palm.bezierCurveTo(2.42, -0.35, 2.28, -0.1, 2.35, 0.27);
palm.closePath();
human.group.add(
extrudedShape(palm, 0.25, human.tissueMaterial, 0.045)
);
const fingerWidth = 0.15;
[
[2.84, 0.2, 3.56, 0.25],
[2.88, 0.07, 3.69, 0.08],
[2.87, -0.06, 3.55, -0.09],
[2.79, -0.19, 3.33, -0.26]
].forEach(([x1, y1, x2, y2]) => {
const shape = new THREE.Shape();
const length = x2 - x1;
const radius = fingerWidth / 2;
shape.moveTo(x1, y1 - radius);
shape.lineTo(x2 - radius, y2 - radius);
shape.quadraticCurveTo(x2, y2 - radius, x2, y2);
shape.quadraticCurveTo(x2, y2 + radius, x2 - radius, y2 + radius);
shape.lineTo(x1, y1 + radius);
shape.quadraticCurveTo(x1 - radius, y1 + radius, x1 - radius, y1);
shape.quadraticCurveTo(x1 - radius, y1 - radius, x1, y1 - radius);
shape.closePath();
human.group.add(
extrudedShape(shape, 0.23, human.tissueMaterial, 0.035)
);
});
const thumb = new THREE.Shape();
thumb.moveTo(2.42, 0.23);
thumb.quadraticCurveTo(2.63, 0.45, 2.86, 0.53);
thumb.quadraticCurveTo(3.02, 0.58, 3.05, 0.43);
thumb.quadraticCurveTo(3.05, 0.3, 2.83, 0.25);
thumb.quadraticCurveTo(2.65, 0.18, 2.42, 0.23);
thumb.closePath();
human.group.add(
extrudedShape(thumb, 0.23, human.tissueMaterial, 0.035)
);
addBone(human, "humerus", [0, 0], [1.0, 0.03], 0.19);
addBone(human, "radius", [1.04, 0.1], [2.13, 0.18], 0.105);
addBone(human, "ulna", [1.04, -0.08], [2.12, -0.08], 0.11);
addBone(human, "carpals", [2.16, 0.1], [2.42, 0.08], 0.14);
addBone(human, "metacarpals", [2.43, 0.09], [2.92, 0.15], 0.105);
addBone(human, "phalanges", [2.92, 0.17], [3.52, 0.23], 0.075);
addBone(human, "phalanges", [2.94, 0.08], [3.62, 0.08], 0.075);
addBone(human, "phalanges", [2.92, -0.01], [3.48, -0.07], 0.075);
addBone(human, "phalanges", [2.86, -0.1], [3.26, -0.24], 0.07);
addBone(human, "phalanges", [2.45, 0.12], [2.83, 0.48], 0.075);
human.anchor.set(1.0, 1.03, 0.2);
// ------------------------------------------------------------------
// Shared skeletal-pattern inset
// ------------------------------------------------------------------
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - radius,
y + height
);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function drawTemplate() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 620;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 0, 0, 1024, 620, 28);
ctx.fillStyle = "#0c1821";
ctx.fill();
ctx.strokeStyle = "rgba(173, 215, 231, 0.26)";
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = "#65d7ff";
ctx.font = "700 24px Arial, sans-serif";
ctx.fillText("SHARED ANCESTRAL PLAN", 54, 64);
ctx.fillStyle = "#8ea6b3";
ctx.font = "22px Arial, sans-serif";
ctx.fillText(
"The vertebrate forelimb: one inherited set of elements",
54,
101
);
ctx.save();
ctx.translate(0, 28);
ctx.lineCap = "round";
function line(x1, y1, x2, y2, color, width) {
ctx.strokeStyle = color;
ctx.lineWidth = width;
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
}
function circle(x, y, radius, color) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, radius, 0, Math.PI * 2);
ctx.fill();
}
line(120, 318, 305, 318, bonePalette.humerus, 66);
circle(120, 318, 35, bonePalette.humerus);
circle(305, 318, 35, bonePalette.humerus);
line(323, 300, 500, 315, bonePalette.radius, 31);
line(323, 340, 487, 355, bonePalette.ulna, 31);
circle(528, 330, 38, bonePalette.carpals);
circle(565, 328, 33, bonePalette.carpals);
line(596, 328, 716, 335, bonePalette.metacarpals, 35);
line(722, 335, 842, 260, bonePalette.phalanges, 25);
line(722, 335, 878, 326, bonePalette.phalanges, 25);
line(722, 335, 835, 418, bonePalette.phalanges, 25);
line(722, 335, 777, 445, bonePalette.phalanges, 23);
ctx.restore();
const labels = [
[120, 401, "1 humerus", bonePalette.humerus],
[334, 413, "2 radius + ulna", bonePalette.radius],
[521, 416, "3 carpals", bonePalette.carpals],
[631, 414, "4 metacarpals", bonePalette.metacarpals],
[805, 486, "5 phalanges", bonePalette.phalanges]
];
labels.forEach(([x, y, text, color]) => {
ctx.fillStyle = color;
ctx.font = "700 18px Arial, sans-serif";
ctx.fillText(text, x, y);
});
roundedRect(ctx, 54, 531, 916, 49, 15);
ctx.fillStyle = "rgba(101, 215, 255, 0.08)";
ctx.fill();
ctx.fillStyle = "#b8ccd5";
ctx.font = "19px Arial, sans-serif";
ctx.textAlign = "center";
ctx.fillText(
"Same elements and broad relationships — different proportions, shapes, and jobs",
512,
563
);
ctx.textAlign = "left";
return canvas;
}
const templateTexture = new THREE.CanvasTexture(drawTemplate());
templateTexture.colorSpace = THREE.SRGBColorSpace;
templateTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const templateMaterial = new THREE.MeshBasicMaterial({
map: templateTexture,
transparent: true,
depthWrite: false,
toneMapped: false
});
const template = new THREE.Mesh(
new THREE.PlaneGeometry(4.75, 2.88),
templateMaterial
);
template.position.set(0, 0.25, 0.48);
template.renderOrder = 2;
scene.add(template);
// ------------------------------------------------------------------
// Subtle spatial backdrop
// ------------------------------------------------------------------
const backdropMaterial = new THREE.LineBasicMaterial({
color: 0x2a5264,
transparent: true,
opacity: 0.19
});
[5.4, 7.4, 9.6].forEach((radius) => {
const points = [];
for (let i = 0; i <= 128; i++) {
const angle = (i / 128) * Math.PI * 2;
points.push(
new THREE.Vector3(
Math.cos(angle) * radius,
Math.sin(angle) * radius * 0.66,
-1.1
)
);
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
scene.add(new THREE.Line(geometry, backdropMaterial));
});
const particleCount = 180;
const particlePositions = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount; i++) {
particlePositions[i * 3] = (Math.random() - 0.5) * 20;
particlePositions[i * 3 + 1] = (Math.random() - 0.5) * 12;
particlePositions[i * 3 + 2] = -1 + Math.random() * 3;
}
const particleGeometry = new THREE.BufferGeometry();
particleGeometry.setAttribute(
"position",
new THREE.BufferAttribute(particlePositions, 3)
);
const particles = new THREE.Points(
particleGeometry,
new THREE.PointsMaterial({
color: 0x91c7d7,
size: 0.025,
transparent: true,
opacity: 0.35,
depthWrite: false
})
);
scene.add(particles);
function addGuide(start, end, color) {
const middle = start.clone().lerp(end, 0.5);
middle.y += 0.14;
const curve = new THREE.QuadraticBezierCurve3(start, middle, end);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(36));
const line = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color,
transparent: true,
opacity: 0.28,
dashSize: 0.12,
gapSize: 0.1,
depthWrite: false
})
);
line.computeLineDistances();
scene.add(line);
}
addGuide(
new THREE.Vector3(-2.15, 1.12, -0.45),
new THREE.Vector3(-4.2, 2.1, -0.45),
speciesPalette.bird
);
addGuide(
new THREE.Vector3(2.15, 1.12, -0.45),
new THREE.Vector3(3.3, 2.0, -0.45),
speciesPalette.whale
);
addGuide(
new THREE.Vector3(0, -1.45, -0.45),
new THREE.Vector3(-1.4, -2.65, -0.45),
speciesPalette.human
);
[bird, whale, human].forEach((model) => {
const ring = new THREE.Mesh(
new THREE.RingGeometry(1.15, 1.17, 64),
new THREE.MeshBasicMaterial({
color: speciesPalette[model.key],
transparent: true,
opacity: 0.17,
side: THREE.DoubleSide,
depthWrite: false
})
);
ring.position.set(
model.group.position.x + 0.9,
model.group.position.y,
-0.7
);
ring.scale.y = 0.58;
scene.add(ring);
});
// ------------------------------------------------------------------
// Mode, legend, and inspector
// ------------------------------------------------------------------
let currentMode = "homology";
let hoveredBone = null;
let selectedBone = null;
let labelsVisible = true;
const legendTitle = document.getElementById("legend-title");
const legendDescription = document.getElementById("legend-description");
const legendItems = document.getElementById("legend-items");
const inspectorKicker = document.getElementById("inspector-kicker");
const inspectorTitle = document.getElementById("inspector-title");
const ancestryText = document.getElementById("ancestry-text");
const functionText = document.getElementById("function-text");
const hoverTag = document.getElementById("hover-tag");
const boneToggle = document.getElementById("bone-toggle");
const homologyLegend = [
["Humerus", "upper arm", bonePalette.humerus],
["Radius", "forearm", bonePalette.radius],
["Ulna", "forearm", bonePalette.ulna],
["Carpals", "wrist", bonePalette.carpals],
["Metacarpals", "palm", bonePalette.metacarpals],
["Phalanges", "digits", bonePalette.phalanges]
];
const functionLegend = [
["Bird wing", "flight", speciesPalette.bird],
["Whale flipper", "aquatic steering", speciesPalette.whale],
["Human arm", "manipulation", speciesPalette.human]
];
function renderLegend() {
const isHomology = currentMode === "homology";
legendTitle.textContent = isHomology
? "Homologous elements"
: "Current functional use";
legendDescription.textContent = isHomology
? "Matching colors identify inherited skeletal components, even when their shapes and proportions differ."
: "The same inherited elements are remodeled for distinct present-day tasks.";
const entries = isHomology ? homologyLegend : functionLegend;
legendItems.innerHTML = entries
.map(
([name, description, color]) => `
<div class="legend-row">
<span class="swatch" style="background:${color};color:${color}"></span>
<span>${name}</span>
<small>${description}</small>
</div>
`
)
.join("");
}
function applyMode(mode) {
currentMode = mode;
Object.values(models).forEach((model) => {
const isHomology = mode === "homology";
model.tissueMaterial.color.set(
isHomology ? model.neutralTissue : speciesPalette[model.key]
);
model.tissueMaterial.opacity = isHomology ? 0.23 : 0.9;
model.tissueMaterial.depthWrite = !isHomology;
model.bones.forEach((bone) => {
const color = isHomology
? bonePalette[bone.userData.category]
: speciesPalette[model.key];
bone.userData.material.color.set(color);
bone.userData.material.emissive.set(color);
});
});
templateMaterial.opacity = mode === "homology" ? 1 : 0.86;
document.querySelectorAll("[data-mode]").forEach((button) => {
const active = button.dataset.mode === mode;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
renderLegend();
refreshHighlights();
refreshInspector();
}
function refreshHighlights() {
Object.values(models).forEach((model) => {
model.bones.forEach((bone) => {
const emphasized =
bone === hoveredBone || bone === selectedBone;
bone.scale.setScalar(emphasized ? 1.075 : 1);
bone.userData.material.emissiveIntensity = emphasized ? 0.52 : 0.08;
});
});
}
function refreshInspector() {
const bone = hoveredBone || selectedBone;
if (!bone) {
inspectorKicker.textContent = "Select a colored element";
inspectorTitle.textContent = "Read the shared plan";
ancestryText.textContent =
"The same upper arm, paired forearm, wrist, palm, and digit elements are present in all three limbs.";
functionText.textContent =
"Switch views to see how the shared elements became specialized for flight, aquatic steering, and human manipulation.";
return;
}
const info = boneInfo[bone.userData.category];
const species = bone.userData.species;
inspectorKicker.textContent = `${speciesNames[species]} · homologous element`;
inspectorTitle.textContent = info.name;
ancestryText.textContent = info.common;
functionText.textContent = info.function[species];
}
renderLegend();
applyMode("homology");
document.querySelectorAll("[data-mode]").forEach((button) => {
button.addEventListener("click", () => {
applyMode(button.dataset.mode);
});
});
boneToggle.addEventListener("change", () => {
Object.values(models).forEach((model) => {
model.bones.forEach((bone) => {
bone.visible = boneToggle.checked;
});
});
});
document.getElementById("toggle-labels").addEventListener("click", () => {
labelsVisible = !labelsVisible;
["bird", "whale", "human"].forEach((key) => {
document.getElementById(`label-${key}`).style.display = labelsVisible
? "flex"
: "none";
});
});
// ------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and reset
// ------------------------------------------------------------------
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let pointerDown = false;
let pointerMoved = false;
let lastPointerX = 0;
let lastPointerY = 0;
function setPointerFromEvent(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pickBone(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(boneMeshes, false);
if (!hits.length) return null;
return hits[0].object.userData.bone;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerDown = true;
pointerMoved = false;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointerDown) {
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
if (Math.abs(dx) + Math.abs(dy) > 3) pointerMoved = true;
azimuth -= dx * 0.006;
elevation = THREE.MathUtils.clamp(
elevation + dy * 0.005,
0.58,
2.42
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
updateCamera();
return;
}
const bone = pickBone(event);
if (bone !== hoveredBone) {
hoveredBone = bone;
refreshHighlights();
refreshInspector();
}
if (bone) {
hoverTag.textContent =
`${boneInfo[bone.userData.category].name} · ${speciesNames[bone.userData.species]}`;
hoverTag.style.left = `${event.clientX}px`;
hoverTag.style.top = `${event.clientY}px`;
hoverTag.classList.add("visible");
} else {
hoverTag.classList.remove("visible");
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!pointerMoved) {
selectedBone = pickBone(event);
refreshHighlights();
refreshInspector();
}
pointerDown = false;
renderer.domElement.classList.remove("dragging");
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = false;
renderer.domElement.classList.remove("dragging");
});
renderer.domElement.addEventListener("pointerleave", () => {
hoveredBone = null;
hoverTag.classList.remove("visible");
refreshHighlights();
refreshInspector();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius * Math.exp(event.deltaY * 0.001),
10,
22
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset-view").addEventListener("click", () => {
azimuth = 0;
elevation = 1.31;
cameraRadius = window.innerWidth < 650 ? 17.5 : 15;
updateCamera();
});
// ------------------------------------------------------------------
// Projected model labels
// ------------------------------------------------------------------
const labelElements = {
bird: document.getElementById("label-bird"),
whale: document.getElementById("label-whale"),
human: document.getElementById("label-human")
};
function updateLabels() {
const width = renderer.domElement.clientWidth;
const height = renderer.domElement.clientHeight;
Object.entries(models).forEach(([key, model]) => {
const world = model.group.localToWorld(model.anchor.clone());
const projected = world.clone().project(camera);
const element = labelElements[key];
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible =
projected.z > -1 &&
projected.z < 1 &&
x > -100 &&
x < width + 100 &&
y > -100 &&
y < height + 100;
element.style.opacity = visible && labelsVisible ? "1" : "0";
element.style.left = `${x}px`;
element.style.top = `${y}px`;
});
}
// ------------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
particles.rotation.z = Math.sin(elapsed * 0.08) * 0.012;
template.quaternion.copy(camera.quaternion);
updateLabels();
renderer.render(scene, camera);
}
resize();
renderer.setAnimationLoop(animate);
document.getElementById("loading").style.display = "none";
</script>
</body>
</html>
```