Prompt specification
Build or customize the Three.js 3D scene "Island divergence museum scene" 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: Island divergence museum scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/island-divergence-museum-scene-x0959
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: island divergence museum scene. Compose a source habitat and isolated island populations with branching relationship panels; label the scenario hypothetical and avoid presenting speciation as inevitable or instant. Return one self-contained HTML file.
Working Three.js Starter (island-divergence-museum-scene-x0959):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Island Divergence — Hypothetical Museum Exhibit</title>
<style>
:root {
--ink: #193237;
--muted: #617277;
--paper: rgba(250, 248, 240, 0.94);
--line: rgba(25, 50, 55, 0.16);
--accent: #d9854d;
--green: #4d7668;
--blue: #477b89;
--shadow: 0 14px 40px rgba(24, 43, 47, 0.16);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce6e3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button { font: inherit; }
#stage, #stage canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#stage canvas {
outline: none;
touch-action: none;
}
.glass {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.78);
box-shadow: var(--shadow);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#masthead {
position: fixed;
top: 18px;
left: 18px;
width: min(430px, calc(100vw - 36px));
border-radius: 16px;
padding: 17px 19px 16px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(217, 133, 77, 0.16);
}
h1 {
margin: 0;
font-size: clamp(25px, 3.4vw, 39px);
line-height: 0.98;
letter-spacing: -0.045em;
}
#masthead p {
margin: 10px 0 0;
max-width: 370px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.hypothetical {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 12px;
padding: 6px 9px;
border-radius: 6px;
color: #874d2f;
background: #f6e4d7;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.11em;
text-transform: uppercase;
}
#reading {
position: fixed;
top: 18px;
right: 18px;
width: 318px;
border-radius: 16px;
padding: 17px;
}
#reading h2 {
margin: 0 0 7px;
font-size: 15px;
letter-spacing: -0.015em;
}
#reading > p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.48;
}
.steps {
display: grid;
gap: 7px;
margin: 13px 0;
}
.step {
display: grid;
grid-template-columns: 25px 1fr;
gap: 9px;
align-items: start;
color: #3c5358;
font-size: 12px;
line-height: 1.38;
}
.step b {
display: grid;
place-items: center;
width: 24px;
height: 24px;
border-radius: 7px;
color: #fff;
background: var(--green);
font-size: 10px;
}
.caution {
margin-top: 12px;
padding: 10px 11px;
border-left: 3px solid var(--accent);
border-radius: 2px 8px 8px 2px;
background: rgba(217, 133, 77, 0.09);
color: #6b4b39;
font-size: 11px;
line-height: 1.45;
}
#selection {
margin-top: 14px;
padding-top: 13px;
border-top: 1px solid var(--line);
}
#selection .kicker {
color: var(--muted);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#selection h3 {
margin: 5px 0 4px;
font-size: 16px;
}
#selection p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
#legend {
position: fixed;
left: 18px;
bottom: 18px;
border-radius: 14px;
padding: 12px 14px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
pointer-events: none;
}
#legend strong {
color: var(--ink);
display: block;
margin-bottom: 3px;
font-size: 11px;
}
.legend-row {
display: flex;
align-items: center;
gap: 8px;
margin-top: 5px;
}
.swatch {
width: 18px;
height: 6px;
border-radius: 2px;
background: var(--accent);
}
.swatch.dashed {
height: 0;
border-top: 2px dashed var(--accent);
background: transparent;
}
#controls {
position: fixed;
right: 18px;
bottom: 18px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
max-width: 440px;
}
.control {
border: 1px solid rgba(25, 50, 55, 0.13);
border-radius: 10px;
padding: 9px 11px;
color: var(--ink);
background: rgba(250, 248, 240, 0.93);
box-shadow: 0 7px 22px rgba(24, 43, 47, 0.1);
cursor: pointer;
font-size: 11px;
font-weight: 750;
transition: transform 0.15s ease, background 0.15s ease;
}
.control:hover { transform: translateY(-1px); }
.control[aria-pressed="false"] {
color: #788589;
background: rgba(245, 244, 237, 0.78);
}
#world-labels {
position: fixed;
inset: 0;
pointer-events: none;
overflow: hidden;
}
#world-labels.hidden { display: none; }
.world-label {
position: absolute;
left: 0;
top: 0;
min-width: 92px;
padding: 7px 9px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 8px;
color: var(--ink);
background: rgba(250, 248, 240, 0.89);
box-shadow: 0 7px 20px rgba(24, 43, 47, 0.12);
text-align: center;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
transform: translate(-50%, -100%);
transition: opacity 0.15s ease;
}
.world-label::after {
content: "";
position: absolute;
left: 50%;
bottom: -5px;
width: 8px;
height: 8px;
background: rgba(250, 248, 240, 0.89);
border-right: 1px solid rgba(255, 255, 255, 0.8);
border-bottom: 1px solid rgba(255, 255, 255, 0.8);
transform: translateX(-50%) rotate(45deg);
}
.world-label.selected {
color: #fff;
background: rgba(25, 50, 55, 0.92);
}
.world-label.selected::after { background: rgba(25, 50, 55, 0.92); }
#credit {
position: fixed;
left: 50%;
bottom: 20px;
transform: translateX(-50%);
color: rgba(25, 50, 55, 0.62);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 900px) {
#masthead {
width: min(365px, calc(100vw - 36px));
}
#reading {
width: 282px;
}
#legend { display: none; }
#credit { display: none; }
}
@media (max-width: 680px) {
#masthead {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 14px;
}
#masthead p { display: none; }
.hypothetical { margin-top: 9px; }
#reading {
top: auto;
right: 10px;
bottom: 68px;
width: min(310px, calc(100vw - 20px));
max-height: 38vh;
overflow: auto;
padding: 13px;
}
#reading > p,
#reading .steps { display: none; }
#selection { margin-top: 0; padding-top: 0; border-top: 0; }
#controls {
left: 10px;
right: 10px;
bottom: 10px;
justify-content: center;
max-width: none;
}
.control { padding: 8px 10px; }
.world-label { font-size: 8px; min-width: 74px; }
}
</style>
</head>
<body>
<div id="stage" aria-label="Interactive three-dimensional museum diorama"></div>
<div id="world-labels" aria-hidden="true">
<div class="world-label" data-label="source">Source habitat</div>
<div class="world-label" data-label="forest">Forest island</div>
<div class="world-label" data-label="dry">Dry island</div>
<div class="world-label" data-label="coast">Coastal island</div>
</div>
<header id="masthead" class="glass">
<div class="eyebrow">Museum study 04 · population relationships</div>
<h1>Island Divergence</h1>
<p>
A spatial exhibit about how separated populations might change over many
generations—and why that outcome is never guaranteed.
</p>
<div class="hypothetical">Hypothetical scenario · not a prediction</div>
</header>
<aside id="reading" class="glass">
<h2>Reading the exhibit</h2>
<p>
The model begins with one hypothetical source population whose descendants
may have reached three separate islands.
</p>
<div class="steps">
<div class="step"><b>1</b><span>Separation may reduce movement and gene flow between populations.</span></div>
<div class="step"><b>2</b><span>Local environments, selection, and chance can alter inherited traits over many generations.</span></div>
<div class="step"><b>3</b><span>Differences are outcomes to investigate, not a promise of a new species.</span></div>
</div>
<div class="caution">
Isolation alone does not prove speciation. Any separate species designation
would require additional biological evidence.
</div>
<section id="selection" aria-live="polite">
<div class="kicker">Selected display</div>
<h3 id="selection-title">Source habitat</h3>
<p id="selection-text">
A single illustrative founding population occupies a connected habitat.
The organisms are symbols rather than representations of a named species.
</p>
</section>
</aside>
<div id="legend" class="glass">
<strong>Exhibit key</strong>
<div class="legend-row"><span class="swatch dashed"></span>Possible dispersal route</div>
<div class="legend-row"><span class="swatch"></span>Selected population</div>
</div>
<nav id="controls" aria-label="Exhibit controls">
<button class="control" id="reset" type="button">Reset view</button>
<button class="control" id="map" type="button" aria-pressed="true">Concept map</button>
<button class="control" id="labels" type="button" aria-pressed="true">Labels</button>
</nav>
<div id="credit">Drag to orbit · Right-drag to pan · Scroll to zoom · Click an island</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const worldLabels = document.querySelector("#world-labels");
const labelElements = [...document.querySelectorAll(".world-label")];
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.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.domElement.setAttribute("aria-label", "Voxel museum diorama of a source habitat and three island populations");
renderer.domElement.tabIndex = 0;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce6e3);
scene.fog = new THREE.Fog(0xdce6e3, 55, 88);
const camera = new THREE.OrthographicCamera(-30, 30, 18, -18, 0.1, 150);
const controls = {
target: new THREE.Vector3(0, 3.2, 0),
azimuth: 0.42,
polar: 0.96,
distance: 46,
zoom: 1
};
const hemi = new THREE.HemisphereLight(0xf5fbf5, 0x7b796d, 2.1);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff2dc, 3.0);
key.position.set(-15, 28, 18);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -34;
key.shadow.camera.right = 34;
key.shadow.camera.top = 28;
key.shadow.camera.bottom = -25;
key.shadow.camera.near = 1;
key.shadow.camera.far = 70;
key.shadow.bias = -0.00035;
scene.add(key);
const fill = new THREE.DirectionalLight(0xb9dbe1, 1.2);
fill.position.set(22, 14, -18);
scene.add(fill);
const warm = new THREE.PointLight(0xffb56f, 14, 28, 2);
warm.position.set(-4, 10, 8);
scene.add(warm);
const materialCache = new Map();
function material(color) {
if (!materialCache.has(color)) {
materialCache.set(color, new THREE.MeshStandardMaterial({
color,
roughness: 0.83,
metalness: 0.02,
flatShading: true
}));
}
return materialCache.get(color);
}
function box(parent, w, h, d, color, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material(color));
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function makeCanvas(width, height) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
return canvas;
}
function roundedRect(ctx, x, y, w, h, r, fill, stroke = null) {
ctx.beginPath();
ctx.roundRect(x, y, w, h, r);
if (fill) {
ctx.fillStyle = fill;
ctx.fill();
}
if (stroke) {
ctx.strokeStyle = stroke;
ctx.lineWidth = 2;
ctx.stroke();
}
}
function fitText(ctx, text, maxWidth, startSize, weight = 700) {
let size = startSize;
do {
ctx.font = `${weight} ${size}px system-ui, sans-serif`;
if (ctx.measureText(text).width <= maxWidth) break;
size -= 1;
} while (size > 12);
return size;
}
function drawMainPanel(ctx, w, h) {
ctx.fillStyle = "#f7f3e8";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#193237";
ctx.fillRect(0, 0, w, 76);
ctx.fillStyle = "#f7f3e8";
ctx.font = "800 38px system-ui, sans-serif";
ctx.fillText("ISLAND DIVERGENCE", 42, 49);
ctx.font = "700 16px system-ui, sans-serif";
ctx.fillStyle = "#d9a06d";
ctx.textAlign = "right";
ctx.fillText("HYPOTHETICAL MUSEUM MODEL", w - 42, 47);
ctx.textAlign = "left";
ctx.fillStyle = "#617277";
ctx.font = "500 17px system-ui, sans-serif";
ctx.fillText("Scenario hypothesis: descendants of one source population may have reached separate islands.", 42, 108);
const sourceX = 66;
const sourceY = 204;
const sourceW = 255;
const sourceH = 130;
roundedRect(ctx, sourceX, sourceY, sourceW, sourceH, 14, "#e7ddc9", "#b87345");
ctx.fillStyle = "#193237";
ctx.font = "800 21px system-ui, sans-serif";
ctx.fillText("SOURCE", sourceX + 20, sourceY + 35);
ctx.font = "700 17px system-ui, sans-serif";
ctx.fillText("founding population", sourceX + 20, sourceY + 62);
ctx.fillStyle = "#617277";
ctx.font = "500 14px system-ui, sans-serif";
ctx.fillText("connected habitat", sourceX + 20, sourceY + 89);
const destinations = [
{ y: 154, title: "FOREST ISLAND", sub: "isolated population", color: "#4d7668" },
{ y: 286, title: "DRY ISLAND", sub: "isolated population", color: "#c38b42" },
{ y: 418, title: "COASTAL ISLAND", sub: "isolated population", color: "#477b89" }
];
const splitX = 620;
ctx.save();
ctx.strokeStyle = "#b87345";
ctx.lineWidth = 4;
ctx.setLineDash([10, 9]);
ctx.beginPath();
ctx.moveTo(sourceX + sourceW, sourceY + sourceH / 2);
ctx.lineTo(splitX, sourceY + sourceH / 2);
for (const d of destinations) {
ctx.moveTo(splitX, sourceY + sourceH / 2);
ctx.lineTo(900, d.y + 53);
}
ctx.stroke();
ctx.restore();
ctx.fillStyle = "#9a643f";
ctx.font = "800 13px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText("POSSIBLE DISPERSAL", 500, 190);
ctx.textAlign = "left";
for (const d of destinations) {
roundedRect(ctx, 900, d.y, 300, 106, 14, "#ffffff", "#d6ded9");
ctx.fillStyle = d.color;
ctx.fillRect(900, d.y, 10, 106);
ctx.fillStyle = "#193237";
ctx.font = "800 19px system-ui, sans-serif";
ctx.fillText(d.title, 928, d.y + 39);
ctx.fillStyle = "#617277";
ctx.font = "500 15px system-ui, sans-serif";
ctx.fillText(d.sub, 928, d.y + 67);
ctx.fillText("relationship shown", 928, d.y + 89);
}
ctx.fillStyle = "#f1dfcf";
ctx.fillRect(0, h - 61, w, 61);
ctx.fillStyle = "#754a34";
ctx.font = "700 15px system-ui, sans-serif";
ctx.fillText("Branching here represents population separation—not a guaranteed or immediate transition into new species.", 42, h - 23);
}
function drawPopulationPanel(ctx, w, h, data) {
ctx.fillStyle = "#f8f4e9";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = data.color;
ctx.fillRect(0, 0, 12, h);
ctx.fillStyle = "#193237";
ctx.font = "800 31px system-ui, sans-serif";
ctx.fillText(data.title, 38, 54);
ctx.fillStyle = "#617277";
ctx.font = "700 16px system-ui, sans-serif";
ctx.fillText(data.kicker.toUpperCase(), 38, 83);
const y = 170;
const xs = [120, 410, 700];
ctx.strokeStyle = data.color;
ctx.lineWidth = 5;
ctx.setLineDash([9, 8]);
ctx.beginPath();
ctx.moveTo(xs[0], y);
ctx.lineTo(xs[1], y);
ctx.lineTo(xs[2], y);
ctx.stroke();
ctx.setLineDash([]);
for (const x of xs) {
ctx.fillStyle = x === xs[2] ? data.color : "#f8f4e9";
ctx.strokeStyle = data.color;
ctx.lineWidth = 4;
ctx.beginPath();
ctx.arc(x, y, 19, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
}
ctx.textAlign = "center";
ctx.fillStyle = "#193237";
ctx.font = "800 15px system-ui, sans-serif";
ctx.fillText("SHARED", xs[0], 218);
ctx.fillText("SEPARATION", xs[1], 218);
ctx.fillText("MANY", xs[2], 218);
ctx.fillText("GENERATIONS", xs[2], 237);
ctx.textAlign = "left";
ctx.fillStyle = "#617277";
ctx.font = "500 15px system-ui, sans-serif";
ctx.fillText(data.body, 38, 285);
ctx.fillStyle = "#eee7d9";
roundedRect(ctx, 38, 330, w - 76, 68, 9, "#eee7d9");
ctx.fillStyle = "#754a34";
ctx.font = "700 14px system-ui, sans-serif";
ctx.fillText("POPULATION RELATIONSHIP SHOWN", 56, 358);
ctx.fillStyle = "#617277";
ctx.font = "500 13px system-ui, sans-serif";
ctx.fillText("A distinct species is not established by this display.", 56, 381);
}
function makePanel({ x, y, z, width, height, rotation = 0, draw }) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
box(group, width + 0.28, height + 0.28, 0.18, "#243f43", 0, 0, -0.05);
const canvas = makeCanvas(1500, Math.round(1500 * height / width));
const ctx = canvas.getContext("2d");
draw(ctx, canvas.width, canvas.height);
const face = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: canvasTexture(canvas), side: THREE.DoubleSide })
);
face.position.z = 0.055;
group.add(face);
const postLength = Math.max(0, y - height / 2 - 0.18);
if (postLength > 0) {
const postY = (-y - height / 2) / 2;
for (const side of [-1, 1]) {
box(group, 0.13, postLength, 0.13, "#42585b", side * width * 0.32, postY, -0.07);
box(group, 0.55, 0.16, 0.55, "#607376", side * width * 0.32, -y + 0.08, -0.07);
}
}
return group;
}
const relationshipGroup = new THREE.Group();
scene.add(relationshipGroup);
relationshipGroup.add(makePanel({
x: 0, y: 9.6, z: -15.35, width: 24, height: 7.2,
rotation: 0.03, draw: drawMainPanel
}));
const panelData = {
source: {
title: "Source habitat",
kicker: "founding population",
color: "#b87345",
body: "One connected habitat supports an illustrative source population.",
body2: ""
},
forest: {
title: "Forest island",
kicker: "population panel 01",
color: "#4d7668",
body: "Isolation may reduce gene flow; different forest conditions could favor some inherited differences over time."
},
dry: {
title: "Dry island",
kicker: "population panel 02",
color: "#c38b42",
body: "Limited water and different predators could alter which traits are favored—or remain neutral."
},
coast: {
title: "Coastal island",
kicker: "population panel 03",
color: "#477b89",
body: "Salt, wind, and a different food web could affect survival and inherited variation over many generations."
}
};
const sourcePanel = makePanel({
x: -13.2, y: 6.6, z: -4.7, width: 8.8, height: 5.1,
rotation: 0.12,
draw: (ctx, w, h) => drawPopulationPanel(ctx, w, h, panelData.source)
});
relationshipGroup.add(sourcePanel);
relationshipGroup.add(makePanel({
x: 1.1, y: 6.4, z: -3.0, width: 7.8, height: 4.8,
rotation: 0.12,
draw: (ctx, w, h) => drawPopulationPanel(ctx, w, h, panelData.forest)
}));
relationshipGroup.add(makePanel({
x: 10.5, y: 6.5, z: -8.5, width: 7.8, height: 4.8,
rotation: 0.12,
draw: (ctx, w, h) => drawPopulationPanel(ctx, w, h, panelData.dry)
}));
relationshipGroup.add(makePanel({
x: 17.0, y: 5.9, z: 2.5, width: 7.6, height: 4.7,
rotation: 0.12,
draw: (ctx, w, h) => drawPopulationPanel(ctx, w, h, panelData.coast)
}));
function makeFloorPlaque() {
const canvas = makeCanvas(1400, 240);
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#193237";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = "#f6f0e3";
ctx.font = "800 48px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.fillText("ISLAND DIVERGENCE", canvas.width / 2, 92);
ctx.fillStyle = "#d9a06d";
ctx.font = "700 22px system-ui, sans-serif";
ctx.fillText("A HYPOTHETICAL MUSEUM MODEL · NOT TO SCALE", canvas.width / 2, 145);
ctx.fillStyle = "#aebcbb";
ctx.font = "500 18px system-ui, sans-serif";
ctx.fillText("Possible routes and relationships only", canvas.width / 2, 190);
const texture = canvasTexture(canvas);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(12, 2.05),
new THREE.MeshBasicMaterial({ map: texture })
);
plaque.rotation.x = -Math.PI / 2;
plaque.position.set(0, 0.015, 11.1);
scene.add(plaque);
}
makeFloorPlaque();
const floor = new THREE.Group();
scene.add(floor);
box(floor, 54, 0.6, 34, "#cfcac0", 0, -0.32, 0, false);
box(floor, 54, 14, 0.5, "#e7e6dd", 0, 6.65, -16.35, false);
box(floor, 0.5, 14, 34, "#e1e3dc", -26.75, 6.65, 0, false);
const gridColor = "#bcb8ae";
for (let x = -24; x <= 24; x += 4) {
box(floor, 0.025, 0.015, 31, gridColor, x, 0.012, 0, false);
}
for (let z = -14; z <= 14; z += 4) {
box(floor, 51, 0.015, 0.025, gridColor, 0, 0.012, z, false);
}
function addTree(parent, x, z, yBase, size = 1, dark = false) {
const group = new THREE.Group();
group.position.set(x, yBase, z);
group.scale.setScalar(size);
parent.add(group);
box(group, 0.24, 1.15, 0.24, "#6f513b", 0, 0.58, 0);
const leaf = dark ? "#315c4e" : "#4d7962";
box(group, 1.25, 0.7, 1.15, leaf, 0, 1.35, 0);
box(group, 0.85, 0.55, 0.85, dark ? "#3e6c58" : "#658c6d", 0, 1.9, 0);
}
function addShrub(parent, x, z, yBase, color = "#78926e", size = 1) {
const g = new THREE.Group();
g.position.set(x, yBase, z);
g.scale.setScalar(size);
parent.add(g);
box(g, 0.72, 0.45, 0.72, color, 0, 0.23, 0);
box(g, 0.45, 0.3, 0.48, color, 0.18, 0.54, -0.05);
}
function addCreature(parent, x, z, yBase, color, scale = 1) {
const g = new THREE.Group();
g.position.set(x, yBase, z);
g.scale.setScalar(scale);
parent.add(g);
box(g, 0.82, 0.5, 0.68, color, 0, 0.62, 0);
box(g, 0.62, 0.55, 0.55, color, 0, 0.77, 0.48);
box(g, 0.32, 0.22, 0.18, "#e7d6bb", 0, 0.69, 0.82);
box(g, 0.15, 0.3, 0.16, color, -0.21, 1.17, 0.47);
box(g, 0.15, 0.3, 0.16, color, 0.21, 1.17, 0.47);
box(g, 0.13, 0.13, 0.08, "#233437", -0.17, 0.84, 0.76);
box(g, 0.13, 0.13, 0.08, "#233437", 0.17, 0.84, 0.76);
box(g, 0.16, 0.38, 0.16, color, -0.25, 0.18, 0.04);
box(g, 0.16, 0.38, 0.16, color, 0.25, 0.18, 0.04);
box(g, 0.24, 0.34, 0.24, color, -0.25, 0.16, 0.35);
box(g, 0.24, 0.34, 0.24, color, 0.25, 0.16, 0.35);
box(g, 0.26, 0.26, 0.72, color, 0, 0.62, -0.62);
box(g, 0.24, 0.24, 0.22, "#ead9bd", 0, 0.64, -0.98);
return g;
}
function makeSelectionFrame(parent, width, depth, color) {
const mat = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.92,
depthWrite: false
});
const frame = new THREE.Group();
frame.position.y = 0.07;
const t = 0.1;
box(frame, width, t, t, mat, 0, 0, depth / 2, false);
box(frame, width, t, t, mat, 0, 0, -depth / 2, false);
box(frame, t, t, depth, mat, width / 2, 0, 0, false);
box(frame, t, t, depth, mat, -width / 2, 0, 0, false);
parent.add(frame);
return mat;
}
const interactiveRoots = [];
const selectionMaterials = {};
function createHabitat({ key, x, z, width, depth, top, color, type }) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.userData.islandKey = key;
scene.add(group);
interactiveRoots.push(group);
box(group, width, 0.62, depth, "#cbb58a", 0, 0.3, 0);
box(group, width - 0.55, 0.38, depth - 0.55, color, 0, 0.76, 0);
if (type === "source") {
box(group, 3.4, 0.12, 3.0, "#5c9eaa", 3.1, 0.99, -1.8, false);
box(group, 2.2, 0.13, 1.4, "#75b2b8", 3.45, 1.0, -2.3, false);
addTree(group, -3.7, -1.9, 0.96, 1.25);
addTree(group, -2.1, -2.5, 0.96, 1.0, true);
addTree(group, -4.1, 0.4, 0.96, 0.95);
addTree(group, -1.8, 1.3, 0.96, 0.8, true);
addShrub(group, 0.7, 2.2, 0.96, "#688569", 1.1);
addShrub(group, -0.7, -1.9, 0.96, "#78916b", 0.85);
addCreature(group, -0.7, 0.6, 0.96, "#a9613e", 1.05);
addCreature(group, 0.7, -0.4, 0.96, "#b36b43", 0.92);
addCreature(group, -2.6, 1.7, 0.96, "#a45e3d", 0.82);
addCreature(group, 1.3, 1.7, 0.96, "#b87348", 0.78);
}
if (type === "forest") {
addTree(group, -1.9, -1.5, 0.96, 1.25, true);
addTree(group, 0, -1.8, 0.96, 1.4);
addTree(group, 1.8, -1.2, 0.96, 1.08, true);
addTree(group, -1.8, 1.2, 0.96, 0.95);
addTree(group, 0.8, 1.5, 0.96, 1.12);
addShrub(group, 2.2, 1.3, 0.96, "#668a68", 0.8);
addCreature(group, -0.9, 0.4, 0.96, "#9d5939", 1.02);
addCreature(group, 1.0, 0.4, 0.96, "#a85e3b", 0.92);
addCreature(group, 0.1, 1.7, 0.96, "#a96340", 0.78);
}
if (type === "dry") {
box(group, 1.2, 0.14, 2.7, "#b7a878", -1.6, 0.99, 0.4, false);
box(group, 0.35, 0.8, 0.35, "#617b55", 1.9, 1.34, -1.1);
box(group, 0.28, 0.6, 0.28, "#617b55", 2.15, 1.16, -1.1);
box(group, 0.28, 0.6, 0.28, "#617b55", 1.65, 1.16, -1.1);
box(group, 0.7, 0.35, 0.7, "#8e8e73", -2.2, 1.12, -1.8);
box(group, 0.45, 0.3, 0.45, "#a19b7d", 2.0, 1.1, 1.7);
addCreature(group, -0.4, 0.7, 0.96, "#c4a46c", 0.82);
addCreature(group, 0.8, -0.5, 0.96, "#c8aa72", 0.75);
addCreature(group, 1.4, 1.4, 0.96, "#bd9b61", 0.68);
}
if (type === "coast") {
box(group, 3.2, 0.13, 2.1, "#6aa1aa", 1.55, 0.99, -1.4, false);
box(group, 1.8, 0.14, 1.2, "#80b6bb", 1.9, 1.0, -1.8, false);
box(group, 0.55, 0.45, 0.55, "#8e9183", -1.8, 1.17, -1.5);
box(group, 0.35, 0.28, 0.35, "#a8a78e", -2.1, 1.05, -0.9);
addShrub(group, -1.8, 1.7, 0.96, "#6f8871", 0.85);
addCreature(group, -0.8, 0.4, 0.96, "#708487", 0.86);
addCreature(group, 0.3, 1.0, 0.96, "#7a8d8f", 0.78);
addCreature(group, 0.9, -0.4, 0.96, "#647a7d", 0.72);
}
selectionMaterials[key] = makeSelectionFrame(group, width + 0.45, depth + 0.45, 0xd9854d);
selectionMaterials[key].opacity = key === "source" ? 0.95 : 0.08;
return group;
}
createHabitat({
key: "source", x: -14, z: 2, width: 11, depth: 8,
top: 1.2, color: "#718a68", type: "source"
});
createHabitat({
key: "forest", x: 1.2, z: 4.2, width: 7.1, depth: 6.2,
top: 0.95, color: "#567b61", type: "forest"
});
createHabitat({
key: "dry", x: 10.2, z: -4.2, width: 6.8, depth: 5.8,
top: 0.95, color: "#b3a477", type: "dry"
});
createHabitat({
key: "coast", x: 16.0, z: 7.0, width: 6.3, depth: 5.7,
top: 0.95, color: "#8c9a79", type: "coast"
});
function addDottedRoute(start, end, count) {
for (let i = 0; i < count; i++) {
const t = i / (count - 1);
const x = THREE.MathUtils.lerp(start.x, end.x, t);
const z = THREE.MathUtils.lerp(start.z, end.z, t);
const dot = box(
relationshipGroup,
0.18, 0.045, 0.18,
i % 3 === 0 ? "#d9854d" : "#e2a36f",
x, 0.055, z, false
);
dot.rotation.y = Math.atan2(end.z - start.z, end.x - start.x);
}
}
addDottedRoute(new THREE.Vector3(-8.1, 0, 2.1), new THREE.Vector3(-2.5, 0, 4.2), 12);
addDottedRoute(new THREE.Vector3(-8.1, 0, 1.3), new THREE.Vector3(6.5, 0, -4.2), 23);
addDottedRoute(new THREE.Vector3(-8.1, 0, 3.4), new THREE.Vector3(12.7, 0, 7.0), 30);
const info = {
source: {
title: "Source habitat",
text: "A single illustrative founding population occupies a connected habitat. The organisms are symbols rather than representations of a named species."
},
forest: {
title: "Forest island population",
text: "Separation may reduce gene flow with the source. Different forest conditions could favor some inherited differences over many generations, but divergence is not guaranteed."
},
dry: {
title: "Dry island population",
text: "A different environment can alter which traits are favored—or remain neutral. This panel shows a possible population relationship, not a confirmed species boundary."
},
coast: {
title: "Coastal island population",
text: "Salt, wind, and different resources could influence inherited variation. Establishing a separate species would require additional reproductive and evolutionary evidence."
}
};
let selected = "source";
function selectHabitat(key) {
selected = key;
document.querySelector("#selection-title").textContent = info[key].title;
document.querySelector("#selection-text").textContent = info[key].text;
for (const [name, mat] of Object.entries(selectionMaterials)) {
mat.opacity = name === key ? 0.96 : 0.08;
}
for (const label of labelElements) {
label.classList.toggle("selected", label.dataset.label === key);
}
}
selectHabitat("source");
const labelAnchors = {
source: new THREE.Vector3(-14, 4.4, 2),
forest: new THREE.Vector3(1.2, 3.7, 4.2),
dry: new THREE.Vector3(10.2, 3.6, -4.2),
coast: new THREE.Vector3(16, 3.5, 7)
};
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(31, 56 / aspect);
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
const sinPolar = Math.sin(controls.polar);
camera.position.set(
controls.target.x + controls.distance * sinPolar * Math.sin(controls.azimuth),
controls.target.y + controls.distance * Math.cos(controls.polar),
controls.target.z + controls.distance * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
function resetView() {
controls.target.set(0, 3.2, 0);
controls.azimuth = 0.42;
controls.polar = 0.96;
controls.zoom = 1;
updateCamera();
}
updateCamera();
let pointerDown = null;
let pointerMoved = false;
renderer.domElement.addEventListener("contextmenu", event => event.preventDefault());
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointerDown = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
button: event.button
};
pointerMoved = false;
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointerDown) return;
const dx = event.clientX - pointerDown.lastX;
const dy = event.clientY - pointerDown.lastY;
if (Math.hypot(event.clientX - pointerDown.x, event.clientY - pointerDown.y) > 5) {
pointerMoved = true;
}
if (pointerDown.button === 0) {
controls.azimuth -= dx * 0.006;
controls.polar = THREE.MathUtils.clamp(controls.polar + dy * 0.005, 0.36, 1.32);
} else {
const height = (camera.top - camera.bottom) / camera.zoom;
const scale = height / renderer.domElement.clientHeight;
const forward = new THREE.Vector3();
camera.getWorldDirection(forward);
const right = new THREE.Vector3().crossVectors(forward, camera.up).normalize();
const screenUp = new THREE.Vector3().crossVectors(right, forward).normalize();
controls.target.addScaledVector(right, -dx * scale);
controls.target.addScaledVector(screenUp, dy * scale);
controls.target.x = THREE.MathUtils.clamp(controls.target.x, -18, 18);
controls.target.z = THREE.MathUtils.clamp(controls.target.z, -12, 12);
}
pointerDown.lastX = event.clientX;
pointerDown.lastY = event.clientY;
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
if (!pointerDown) return;
if (!pointerMoved && pointerDown.button === 0) {
const rect = renderer.domElement.getBoundingClientRect();
const pointer = new THREE.Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveRoots, true);
if (hits.length) {
let object = hits[0].object;
while (object && !object.userData.islandKey) object = object.parent;
if (object?.userData.islandKey) selectHabitat(object.userData.islandKey);
}
}
pointerDown = null;
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = null;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
controls.zoom = THREE.MathUtils.clamp(
controls.zoom * Math.exp(-event.deltaY * 0.001),
0.62,
2.1
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetView);
document.querySelector("#reset").addEventListener("click", resetView);
const mapButton = document.querySelector("#map");
mapButton.addEventListener("click", () => {
const visible = !relationshipGroup.visible;
relationshipGroup.visible = visible;
mapButton.setAttribute("aria-pressed", String(visible));
mapButton.textContent = visible ? "Concept map" : "Show concept map";
});
const labelsButton = document.querySelector("#labels");
labelsButton.addEventListener("click", () => {
const visible = worldLabels.classList.contains("hidden");
worldLabels.classList.toggle("hidden", !visible);
labelsButton.setAttribute("aria-pressed", String(visible));
labelsButton.textContent = visible ? "Labels" : "Show labels";
});
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetView();
if (event.key.toLowerCase() === "m") mapButton.click();
if (event.key.toLowerCase() === "l") labelsButton.click();
});
function resize() {
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
updateCamera();
}
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labelElements) {
const anchor = labelAnchors[label.dataset.label];
projected.copy(anchor).project(camera);
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 > -80 && x < width + 80 && y > -40 && y < height + 40;
label.style.opacity = visible ? "1" : "0";
label.style.left = `${x}px`;
label.style.top = `${y}px`;
}
}
function animate() {
requestAnimationFrame(animate);
updateLabels();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```