Prompt specification
Build or customize the Three.js 3D scene "Streamlined body comparison models" 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: Streamlined body comparison models
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/streamlined-body-comparison-models-x0893
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring convergent evolution. Place schematic dolphin-like and shark-like silhouettes beside separate lineage markers; compare external streamlining while explicitly distinguishing mammal and fish ancestry. Low-poly.
Working Three.js Starter (streamlined-body-comparison-models-x0893):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Convergent Evolution — Three.js Exhibit</title>
<style>
:root {
color-scheme: dark;
--bg: #07121c;
--panel: rgba(11, 27, 39, 0.82);
--border: rgba(166, 211, 226, 0.18);
--text: #edf7fa;
--muted: #91aab4;
--mammal: #bd91ff;
--fish: #58ddca;
--gold: #f4c85b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--text);
}
body {
background:
radial-gradient(circle at 50% 43%, #102c3b 0%, #091923 42%, #050d15 100%);
}
#stage {
position: fixed;
inset: 0;
touch-action: none;
cursor: grab;
}
#stage:active {
cursor: grabbing;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
}
.ui {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
header {
position: absolute;
top: 28px;
left: 30px;
max-width: 560px;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: var(--gold);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 2px;
background: var(--gold);
content: "";
}
h1 {
margin: 0;
font-size: clamp(28px, 4vw, 54px);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 760;
}
header p {
max-width: 480px;
margin: 12px 0 0;
color: #a9bec7;
font-size: 14px;
line-height: 1.5;
}
.controls {
position: absolute;
top: 28px;
right: 30px;
display: flex;
align-items: center;
gap: 8px;
pointer-events: auto;
}
button {
border: 1px solid var(--border);
border-radius: 999px;
padding: 9px 13px;
background: rgba(9, 24, 35, 0.78);
color: #dcebf0;
font: inherit;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.04em;
cursor: pointer;
backdrop-filter: blur(12px);
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
button:hover {
border-color: rgba(244, 200, 91, 0.55);
background: rgba(20, 42, 54, 0.9);
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 3px;
}
.hint {
margin-left: 4px;
color: #6f8994;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
white-space: nowrap;
}
.panel {
border: 1px solid var(--border);
border-radius: 16px;
background: var(--panel);
box-shadow:
0 16px 50px rgba(0, 0, 0, 0.28),
inset 0 1px 0 rgba(255, 255, 255, 0.025);
backdrop-filter: blur(16px);
}
.lineage {
position: absolute;
top: 43%;
width: 230px;
padding: 17px 18px 16px;
transform: translateY(-50%);
}
.lineage::before {
position: absolute;
top: 20px;
bottom: 20px;
width: 3px;
border-radius: 4px;
content: "";
opacity: 0.9;
}
.lineage.mammal {
left: 28px;
}
.lineage.mammal::before {
right: -18px;
background: var(--mammal);
box-shadow: 0 0 18px rgba(189, 145, 255, 0.35);
}
.lineage.fish {
right: 28px;
}
.lineage.fish::before {
left: -18px;
background: var(--fish);
box-shadow: 0 0 18px rgba(88, 221, 202, 0.35);
}
.lineage-number {
margin-bottom: 7px;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
opacity: 0.75;
}
.mammal .lineage-number {
color: var(--mammal);
}
.fish .lineage-number {
color: var(--fish);
}
.lineage h2 {
margin: 0 0 7px;
font-size: 20px;
letter-spacing: -0.025em;
}
.ancestry {
margin: 0;
color: #c6d5da;
font-size: 12px;
line-height: 1.45;
}
.traits {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin: 13px 0;
}
.traits span {
border: 1px solid rgba(255, 255, 255, 0.09);
border-radius: 999px;
padding: 4px 7px;
background: rgba(255, 255, 255, 0.035);
color: #9fb3bc;
font-size: 9px;
font-weight: 650;
}
.endpoint {
display: flex;
align-items: center;
gap: 8px;
padding-top: 11px;
border-top: 1px solid rgba(255, 255, 255, 0.08);
color: #edf7fa;
font-size: 11px;
font-weight: 700;
}
.endpoint svg {
width: 23px;
height: 23px;
flex: 0 0 auto;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.5;
}
.mammal .endpoint {
color: var(--mammal);
}
.fish .endpoint {
color: var(--fish);
}
.convergence {
position: absolute;
bottom: 27px;
left: 50%;
width: min(410px, calc(100vw - 40px));
padding: 17px 20px 16px;
transform: translateX(-50%);
text-align: center;
}
.convergence .label {
color: var(--gold);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.convergence h2 {
margin: 6px 0;
font-size: 18px;
letter-spacing: -0.02em;
}
.convergence p {
margin: 0 auto;
max-width: 350px;
color: #9fb3bc;
font-size: 11px;
line-height: 1.45;
}
.not-related {
display: inline-block;
margin-top: 10px;
padding: 5px 9px;
border: 1px solid rgba(244, 200, 91, 0.24);
border-radius: 999px;
background: rgba(244, 200, 91, 0.06);
color: #f6d989;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.outline-key {
position: absolute;
top: 146px;
left: 50%;
display: flex;
align-items: center;
gap: 8px;
transform: translateX(-50%);
color: #8199a3;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
white-space: nowrap;
}
.outline-key i {
width: 28px;
border-top: 2px dashed var(--gold);
}
.specimen-tag {
position: absolute;
z-index: 3;
min-width: 145px;
padding: 7px 11px 8px;
transform: translate(-50%, 0);
border: 1px solid var(--border);
border-radius: 9px;
background: rgba(6, 18, 27, 0.88);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
text-align: center;
pointer-events: none;
backdrop-filter: blur(10px);
}
.specimen-tag::before {
position: absolute;
bottom: 100%;
left: 50%;
width: 1px;
height: 15px;
background: rgba(255, 255, 255, 0.18);
content: "";
}
.specimen-tag strong {
display: block;
font-size: 9px;
letter-spacing: 0.12em;
}
.specimen-tag small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
}
#dolphinTag strong {
color: var(--mammal);
}
#sharkTag strong {
color: var(--fish);
}
@media (max-width: 1000px) {
.lineage {
width: 195px;
padding: 14px;
}
.lineage h2 {
font-size: 17px;
}
.traits span {
font-size: 8px;
}
.hint {
display: none;
}
}
@media (max-width: 700px) {
header {
top: 16px;
left: 16px;
max-width: 68%;
}
.eyebrow {
margin-bottom: 7px;
font-size: 8px;
}
h1 {
font-size: 28px;
}
header p {
display: none;
}
.controls {
top: 16px;
right: 14px;
flex-direction: column;
align-items: flex-end;
}
button {
padding: 7px 9px;
font-size: 9px;
}
.lineage {
top: 118px;
width: calc(50% - 20px);
padding: 11px 12px;
transform: none;
}
.lineage.mammal {
left: 12px;
}
.lineage.fish {
right: 12px;
}
.lineage::before,
.traits,
.endpoint {
display: none;
}
.lineage-number {
margin-bottom: 4px;
font-size: 7px;
}
.lineage h2 {
margin-bottom: 3px;
font-size: 14px;
}
.ancestry {
font-size: 9px;
line-height: 1.3;
}
.outline-key {
top: 91px;
font-size: 7px;
}
.convergence {
bottom: 12px;
padding: 12px 14px;
}
.convergence h2 {
font-size: 15px;
}
.convergence p {
font-size: 9px;
}
.not-related {
margin-top: 7px;
font-size: 7px;
}
.specimen-tag {
min-width: 112px;
padding: 5px 8px;
}
.specimen-tag strong,
.specimen-tag small {
font-size: 7px;
}
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive three-dimensional comparison of dolphin-like and shark-like body forms"></div>
<div class="ui">
<header>
<div class="eyebrow">Exhibit 04 · Comparative Biology</div>
<h1>Convergent evolution</h1>
<p>
Similar pressure can produce similar bodies—even when the animals
inherit those bodies from very different ancestors.
</p>
</header>
<div class="controls">
<button id="outlineToggle" type="button" aria-pressed="true">Outlines: on</button>
<button id="resetView" type="button">Reset view</button>
<span class="hint">DRAG TO ORBIT · SCROLL TO ZOOM</span>
</div>
<div class="outline-key">
<i></i>
similar hydrodynamic envelope
</div>
<aside class="panel lineage mammal">
<div class="lineage-number">Separate lineage · 01</div>
<h2>Mammal ancestry</h2>
<p class="ancestry">
An air-breathing tetrapod branch, not a fish branch.
</p>
<div class="traits">
<span>lungs</span>
<span>milk + hair</span>
<span>warm-blooded</span>
</div>
<div class="endpoint">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M5 12h8m0 0-3-3m3 3-3 3M9 5v4m0 6v4" />
<circle cx="19" cy="12" r="2" />
</svg>
dolphin-like body form
</div>
</aside>
<aside class="panel lineage fish">
<div class="lineage-number">Separate lineage · 02</div>
<h2>Fish ancestry</h2>
<p class="ancestry">
An aquatic vertebrate branch, specifically a cartilaginous fish.
</p>
<div class="traits">
<span>gills</span>
<span>fins + scales</span>
<span>cold-blooded</span>
</div>
<div class="endpoint">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 12c3-5 8-6 14-1-5 5-10 4-14 1Z" />
<path d="m7 9-3-3v6l3-3Zm0 6-3 3V9l3 3Z" />
<circle cx="15" cy="11" r=".8" />
</svg>
shark-like body form
</div>
</aside>
<section class="panel convergence">
<div class="label">Convergence · shared water pressure</div>
<h2>Similar streamlined shape, separate ancestry</h2>
<p>
Independent lineages evolved similar drag-reducing forms in response
to similar aquatic selective pressures.
</p>
<div class="not-related">
Dolphins did not evolve from sharks — and sharks did not evolve from mammals
</div>
</section>
<div id="dolphinTag" class="specimen-tag">
<strong>DOLPHIN-LIKE</strong>
<small>mammal · streamlined body</small>
</div>
<div id="sharkTag" class="specimen-tag">
<strong>SHARK-LIKE</strong>
<small>fish · streamlined body</small>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Scene
// -------------------------------------------------------------------------
const stage = document.querySelector("#stage");
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07121c, 13, 31);
const camera = new THREE.PerspectiveCamera(40, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setClearColor(0x07121c, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
const cameraTarget = new THREE.Vector3(0, 1.05, 0);
const view = {
yaw: 0.12,
pitch: 0.16,
distance: 10.8
};
const hemi = new THREE.HemisphereLight(0xb9e6f1, 0x081019, 1.65);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xe9f8ff, 2.6);
keyLight.position.set(3.5, 7, 6);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -4;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x7898ff, 1.25);
rimLight.position.set(-5, 3, -5);
scene.add(rimLight);
const mammalLight = new THREE.PointLight(0xbd91ff, 10, 7, 2);
mammalLight.position.set(-3, 2.3, 2.2);
scene.add(mammalLight);
const fishLight = new THREE.PointLight(0x58ddca, 10, 7, 2);
fishLight.position.set(3, 2.3, 2.2);
scene.add(fishLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0x07131d,
roughness: 0.92,
metalness: 0.08
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.01;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(30, 30, 0x1e4655, 0x12303b);
grid.position.y = 0.012;
grid.material.transparent = true;
grid.material.opacity = 0.2;
scene.add(grid);
// -------------------------------------------------------------------------
// Low-poly geometry helpers
// -------------------------------------------------------------------------
function lowPolyMaterial(color, extra = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.76,
metalness: 0.04,
flatShading: true,
side: THREE.DoubleSide,
...extra
});
}
function fusiformGeometry(rings, radialSegments = 10) {
const positions = [];
const indices = [];
for (const ring of rings) {
for (let j = 0; j < radialSegments; j++) {
const angle = (j / radialSegments) * Math.PI * 2;
positions.push(
ring.x,
Math.cos(angle) * ring.ry,
Math.sin(angle) * ring.rz
);
}
}
for (let i = 0; i < rings.length - 1; i++) {
for (let j = 0; j < radialSegments; j++) {
const nextJ = (j + 1) % radialSegments;
const a = i * radialSegments + j;
const b = i * radialSegments + nextJ;
const c = (i + 1) * radialSegments + j;
const d = (i + 1) * radialSegments + nextJ;
indices.push(a, b, c, b, d, c);
}
}
const tailCenter = positions.length / 3;
positions.push(rings[0].x, 0, 0);
const noseCenter = positions.length / 3;
positions.push(rings[rings.length - 1].x, 0, 0);
const lastRing = (rings.length - 1) * radialSegments;
for (let j = 0; j < radialSegments; j++) {
const nextJ = (j + 1) % radialSegments;
indices.push(tailCenter, nextJ, j);
indices.push(noseCenter, lastRing + j, lastRing + nextJ);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
function prismGeometry(points, depth) {
const shape = new THREE.Shape();
points.forEach(([x, y], index) => {
if (index === 0) shape.moveTo(x, y);
else shape.lineTo(x, y);
});
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: false,
steps: 1
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
function triangleGeometry(points) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(points.flat(), 3)
);
geometry.computeVertexNormals();
return geometry;
}
function lineFrom(points, color, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((p) => new THREE.Vector3(...p))
);
const material = new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity
});
return new THREE.Line(geometry, material);
}
function outlineFor(rings) {
const top = rings.map((r) => new THREE.Vector3(r.x, r.ry, 0.34));
const bottom = [...rings]
.reverse()
.map((r) => new THREE.Vector3(r.x, -r.ry, 0.34));
const points = [...top, ...bottom, top[0].clone()];
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineDashedMaterial({
color: 0xf4c85b,
dashSize: 0.09,
gapSize: 0.065,
transparent: true,
opacity: 0.72
});
const outline = new THREE.Line(geometry, material);
outline.computeLineDistances();
outline.name = "streamline-outline";
return outline;
}
// -------------------------------------------------------------------------
// Schematic dolphin-like mammal
// -------------------------------------------------------------------------
function createDolphin() {
const group = new THREE.Group();
const bodyMaterial = lowPolyMaterial(0x668fa8);
const finMaterial = lowPolyMaterial(0x83b5c9);
const darkMaterial = lowPolyMaterial(0x172834);
const rings = [
{ x: -1.45, ry: 0.075, rz: 0.065 },
{ x: -1.15, ry: 0.13, rz: 0.105 },
{ x: -0.72, ry: 0.29, rz: 0.215 },
{ x: -0.20, ry: 0.40, rz: 0.285 },
{ x: 0.35, ry: 0.39, rz: 0.285 },
{ x: 0.72, ry: 0.30, rz: 0.245 },
{ x: 1.02, ry: 0.225, rz: 0.215 },
{ x: 1.27, ry: 0.125, rz: 0.155 },
{ x: 1.48, ry: 0.070, rz: 0.095 },
{ x: 1.60, ry: 0.020, rz: 0.035 }
];
const body = new THREE.Mesh(
fusiformGeometry(rings, 10),
bodyMaterial
);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
// Swept dorsal fin.
const dorsal = new THREE.Mesh(
prismGeometry([
[-0.68, 0.25],
[-0.50, 0.82],
[-0.06, 0.32]
], 0.075),
finMaterial
);
dorsal.castShadow = true;
group.add(dorsal);
// Near and far pectoral flippers.
const nearFlipper = new THREE.Mesh(
triangleGeometry([
[0.70, -0.10, 0.22],
[0.18, -0.51, 0.34],
[0.49, -0.24, 0.36]
]),
finMaterial
);
nearFlipper.castShadow = true;
group.add(nearFlipper);
const farFlipper = new THREE.Mesh(
triangleGeometry([
[0.70, -0.10, -0.22],
[0.18, -0.51, -0.34],
[0.49, -0.24, -0.36]
]),
finMaterial
);
group.add(farFlipper);
// Horizontal tail flukes.
const nearFlukeA = new THREE.Mesh(
triangleGeometry([
[-1.36, 0.015, 0.04],
[-1.84, 0.025, 0.49],
[-1.50, 0.015, 0.39]
]),
finMaterial
);
const nearFlukeB = new THREE.Mesh(
triangleGeometry([
[-1.50, 0.015, 0.39],
[-1.84, 0.025, 0.49],
[-1.65, 0.01, 0.66]
]),
finMaterial
);
const farFlukeA = new THREE.Mesh(
triangleGeometry([
[-1.36, -0.015, -0.04],
[-1.50, -0.015, -0.39],
[-1.84, -0.025, -0.49]
]),
finMaterial
);
const farFlukeB = new THREE.Mesh(
triangleGeometry([
[-1.50, -0.015, -0.39],
[-1.65, -0.01, -0.66],
[-1.84, -0.025, -0.49]
]),
finMaterial
);
group.add(nearFlukeA, nearFlukeB, farFlukeA, farFlukeB);
// Eye and small highlight.
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 8, 6),
darkMaterial
);
eye.position.set(1.00, 0.13, 0.215);
group.add(eye);
const glint = new THREE.Mesh(
new THREE.SphereGeometry(0.016, 6, 4),
new THREE.MeshBasicMaterial({ color: 0xeafcff })
);
glint.position.set(1.012, 0.148, 0.263);
group.add(glint);
// Mouth and blowhole distinguish the mammal silhouette.
group.add(lineFrom([
[1.53, -0.025, 0.13],
[1.29, -0.075, 0.185],
[1.08, -0.145, 0.225]
], 0x17252f));
group.add(lineFrom([
[0.26, 0.385, 0.04],
[0.42, 0.382, 0.04]
], 0x263c4a));
group.add(outlineFor(rings));
return group;
}
// -------------------------------------------------------------------------
// Schematic shark-like fish
// -------------------------------------------------------------------------
function createShark() {
const group = new THREE.Group();
const bodyMaterial = lowPolyMaterial(0x4f7180);
const finMaterial = lowPolyMaterial(0x668e9b);
const darkMaterial = lowPolyMaterial(0x101d25);
const rings = [
{ x: -1.65, ry: 0.075, rz: 0.060 },
{ x: -1.35, ry: 0.16, rz: 0.115 },
{ x: -0.86, ry: 0.33, rz: 0.225 },
{ x: -0.20, ry: 0.43, rz: 0.285 },
{ x: 0.42, ry: 0.36, rz: 0.260 },
{ x: 0.94, ry: 0.245, rz: 0.205 },
{ x: 1.43, ry: 0.125, rz: 0.145 },
{ x: 1.70, ry: 0.050, rz: 0.080 },
{ x: 1.82, ry: 0.015, rz: 0.030 }
];
const body = new THREE.Mesh(
fusiformGeometry(rings, 10),
bodyMaterial
);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
// Tall triangular dorsal fin.
const dorsal = new THREE.Mesh(
prismGeometry([
[-0.61, 0.28],
[-0.28, 0.98],
[0.19, 0.27]
], 0.08),
finMaterial
);
dorsal.castShadow = true;
group.add(dorsal);
// Small second dorsal fin.
const secondDorsal = new THREE.Mesh(
prismGeometry([
[-1.12, 0.14],
[-1.03, 0.38],
[-0.86, 0.17]
], 0.055),
finMaterial
);
group.add(secondDorsal);
// Large pectoral fins.
const nearPectoral = new THREE.Mesh(
triangleGeometry([
[0.58, -0.11, 0.24],
[0.01, -0.70, 0.41],
[0.38, -0.23, 0.42]
]),
finMaterial
);
nearPectoral.castShadow = true;
group.add(nearPectoral);
const farPectoral = new THREE.Mesh(
triangleGeometry([
[0.58, -0.11, -0.24],
[0.38, -0.23, -0.42],
[0.01, -0.70, -0.41]
]),
finMaterial
);
group.add(farPectoral);
// Vertical caudal fin with unequal lobes.
const tail = new THREE.Mesh(
prismGeometry([
[-1.27, 0.16],
[-1.62, 0.86],
[-1.78, 0.88],
[-1.53, 0.08],
[-1.82, -0.66],
[-1.57, -0.69],
[-1.30, -0.13]
], 0.09),
finMaterial
);
tail.castShadow = true;
group.add(tail);
// Pelvic fin.
const pelvic = new THREE.Mesh(
triangleGeometry([
[-0.34, -0.30, 0.25],
[-0.59, -0.52, 0.32],
[-0.13, -0.36, 0.29]
]),
finMaterial
);
group.add(pelvic);
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.052, 8, 6),
darkMaterial
);
eye.position.set(1.15, 0.105, 0.165);
group.add(eye);
const glint = new THREE.Mesh(
new THREE.SphereGeometry(0.014, 6, 4),
new THREE.MeshBasicMaterial({ color: 0xeafcff })
);
glint.position.set(1.16, 0.122, 0.208);
group.add(glint);
// Mouth line.
group.add(lineFrom([
[1.76, -0.020, 0.075],
[1.48, -0.090, 0.155],
[1.18, -0.145, 0.205]
], 0x12222b));
// Five gill slits.
for (let i = 0; i < 5; i++) {
const x = 0.34 - i * 0.13;
group.add(lineFrom([
[x, 0.13, 0.277],
[x - 0.025, 0.025, 0.289],
[x - 0.015, -0.11, 0.274]
], 0x1d323d));
}
group.add(outlineFor(rings));
return group;
}
// -------------------------------------------------------------------------
// Exhibit pedestals and separate lineage markers
// -------------------------------------------------------------------------
function createPedestal(accent) {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(1.18, 1.32, 0.46, 12),
lowPolyMaterial(0x102735, { metalness: 0.22 })
);
base.position.y = 0.24;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const top = new THREE.Mesh(
new THREE.CylinderGeometry(1.12, 1.12, 0.07, 12),
lowPolyMaterial(0x173645, { metalness: 0.28 })
);
top.position.y = 0.50;
top.receiveShadow = true;
group.add(top);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(1.03, 0.018, 5, 48),
new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.65
})
);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.545;
group.add(ring);
const halo = new THREE.Mesh(
new THREE.CircleGeometry(1.55, 48),
new THREE.MeshBasicMaterial({
color: accent,
transparent: true,
opacity: 0.035,
depthWrite: false
})
);
halo.rotation.x = -Math.PI / 2;
halo.position.y = 0.015;
group.add(halo);
return group;
}
function createLineageMarker(color) {
const group = new THREE.Group();
const lineMaterial = new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.8
});
const segments = [
[[0, 0.56, 0.79], [0, 1.02, 0.79]],
[[0, 1.02, 0.79], [-0.18, 1.18, 0.79]],
[[0, 1.02, 0.79], [0.18, 1.18, 0.79]]
];
for (const segment of segments) {
group.add(lineFrom(segment, color, 0.8));
}
const nodeMaterial = new THREE.MeshBasicMaterial({ color });
for (const point of [
[0, 0.56, 0.79],
[0, 1.02, 0.79],
[-0.18, 1.18, 0.79],
[0.18, 1.18, 0.79]
]) {
const node = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.055, 0),
nodeMaterial
);
node.position.set(...point);
group.add(node);
}
const support = lineFrom([
[0, 0.56, 0.79],
[0, 1.16, 0.22]
], color, 0.2);
group.add(support);
return group;
}
const dolphinAssembly = new THREE.Group();
const sharkAssembly = new THREE.Group();
const dolphinModel = createDolphin();
const sharkModel = createShark();
dolphinModel.position.y = 1.58;
sharkModel.position.y = 1.58;
dolphinAssembly.add(
createPedestal(0xbd91ff),
createLineageMarker(0xbd91ff),
dolphinModel
);
sharkAssembly.add(
createPedestal(0x58ddca),
createLineageMarker(0x58ddca),
sharkModel
);
scene.add(dolphinAssembly, sharkAssembly);
// -------------------------------------------------------------------------
// Convergence hub: two independent paths merge at a shared form-level result
// -------------------------------------------------------------------------
const convergenceGroup = new THREE.Group();
scene.add(convergenceGroup);
const convergenceCore = new THREE.Mesh(
new THREE.OctahedronGeometry(0.18, 0),
new THREE.MeshStandardMaterial({
color: 0xf4c85b,
emissive: 0x7b5510,
emissiveIntensity: 1.25,
roughness: 0.38,
metalness: 0.38,
flatShading: true
})
);
convergenceCore.position.set(0, 0.67, 0);
convergenceGroup.add(convergenceCore);
const convergenceRing = new THREE.Mesh(
new THREE.TorusGeometry(0.28, 0.014, 5, 48),
new THREE.MeshBasicMaterial({
color: 0xf4c85b,
transparent: true,
opacity: 0.85
})
);
convergenceRing.position.set(0, 0.67, 0);
convergenceGroup.add(convergenceRing);
const convergenceRingHorizontal = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.012, 5, 48),
new THREE.MeshBasicMaterial({
color: 0x88d9e5,
transparent: true,
opacity: 0.5
})
);
convergenceRingHorizontal.rotation.x = Math.PI / 2;
convergenceRingHorizontal.position.set(0, 0.67, 0);
convergenceGroup.add(convergenceRingHorizontal);
const pathGroup = new THREE.Group();
scene.add(pathGroup);
let spread = 1.9;
function rebuildPaths() {
for (const child of [...pathGroup.children]) {
child.geometry.dispose();
child.material.dispose();
pathGroup.remove(child);
}
const makePath = (side, color) => {
const points = [
new THREE.Vector3(side * spread, 0.68, 0.79),
new THREE.Vector3(side * spread * 0.48, 0.67, 0.35),
new THREE.Vector3(0, 0.67, 0)
];
const curve = new THREE.CatmullRomCurve3(points);
const geometry = new THREE.TubeGeometry(curve, 28, 0.022, 5, false);
const material = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.8
});
pathGroup.add(new THREE.Mesh(geometry, material));
};
makePath(-1, 0xbd91ff);
makePath(1, 0x58ddca);
}
// -------------------------------------------------------------------------
// Camera controls implemented without external helper modules
// -------------------------------------------------------------------------
function updateCamera() {
const cosPitch = Math.cos(view.pitch);
camera.position.set(
cameraTarget.x + Math.sin(view.yaw) * cosPitch * view.distance,
cameraTarget.y + Math.sin(view.pitch) * view.distance,
cameraTarget.z + Math.cos(view.yaw) * cosPitch * view.distance
);
camera.lookAt(cameraTarget);
}
function resetView() {
view.yaw = 0.12;
view.pitch = 0.16;
view.distance = camera.aspect < 1.2 ? 13.8 : 10.8;
updateCamera();
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
view.yaw = THREE.MathUtils.clamp(
view.yaw + dx * 0.004,
-0.55,
0.55
);
view.pitch = THREE.MathUtils.clamp(
view.pitch + dy * 0.003,
0.08,
0.42
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.distance = THREE.MathUtils.clamp(
view.distance + event.deltaY * 0.008,
8.5,
19
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#resetView").addEventListener("click", resetView);
const outlineToggle = document.querySelector("#outlineToggle");
let outlinesVisible = true;
outlineToggle.addEventListener("click", () => {
outlinesVisible = !outlinesVisible;
dolphinModel.getObjectByName("streamline-outline").visible =
outlinesVisible;
sharkModel.getObjectByName("streamline-outline").visible =
outlinesVisible;
outlineToggle.textContent = `Outlines: ${outlinesVisible ? "on" : "off"}`;
outlineToggle.setAttribute("aria-pressed", String(outlinesVisible));
});
// -------------------------------------------------------------------------
// Responsive layout and projected labels
// -------------------------------------------------------------------------
const dolphinTag = document.querySelector("#dolphinTag");
const sharkTag = document.querySelector("#sharkTag");
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
const aspect = width / height;
renderer.setSize(width, height, false);
camera.aspect = aspect;
camera.updateProjectionMatrix();
if (aspect < 0.8) {
spread = 1.58;
view.distance = 17.2;
} else if (aspect < 1.2) {
spread = 1.67;
view.distance = 13.8;
} else {
spread = 1.9;
view.distance = 10.8;
}
dolphinAssembly.position.x = -spread;
sharkAssembly.position.x = spread;
rebuildPaths();
updateCamera();
}
window.addEventListener("resize", resize);
resize();
const projected = new THREE.Vector3();
function placeLabel(element, object) {
object.getWorldPosition(projected);
projected.y -= 0.79;
projected.project(camera);
const x = (projected.x * 0.5 + 0.5) * stage.clientWidth;
const y = (-projected.y * 0.5 + 0.5) * stage.clientHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = projected.z < 1 ? "1" : "0";
}
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
dolphinModel.position.y =
1.58 + Math.sin(elapsed * 0.9) * 0.022;
sharkModel.position.y =
1.58 + Math.sin(elapsed * 0.9 + 1.3) * 0.022;
convergenceCore.rotation.y = elapsed * 0.55;
convergenceCore.rotation.x = elapsed * 0.18;
convergenceRing.rotation.z = elapsed * 0.22;
convergenceRingHorizontal.rotation.z = -elapsed * 0.18;
placeLabel(dolphinTag, dolphinModel);
placeLabel(sharkTag, sharkModel);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```