Prompt specification
Build or customize the Three.js 3D scene "Two Habitat Islands and One Corridor Tile" 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: Two Habitat Islands and One Corridor Tile
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-habitat-islands-and-one-corridor-tile-x3941
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: two habitat islands and one corridor tile. Model two green habitat patches separated by an unsuitable region and a possible corridor. Label connectivity as a schematic species-dependent concept rather than universal ecological suitability.
Working Three.js Starter (two-habitat-islands-and-one-corridor-tile-x3941):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Habitat Connectivity — Species-Dependent Schematic</title>
<style>
:root {
--ink: #163439;
--muted: #557277;
--panel: rgba(249, 252, 247, 0.91);
--line: rgba(22, 52, 57, 0.13);
--green: #65bd69;
--gap: #898478;
--amber: #d6a13e;
--teal: #087f78;
--coral: #d85e59;
--shadow: 0 18px 55px rgba(13, 48, 52, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 50% 38%, #d9ece8 0, #afcfcc 43%, #739b9d 100%);
}
button {
font: inherit;
}
#app,
#stage {
position: fixed;
inset: 0;
}
#stage {
touch-action: none;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.hero {
position: fixed;
z-index: 5;
top: 28px;
left: 32px;
max-width: 530px;
pointer-events: none;
text-shadow: 0 1px 12px rgba(230, 247, 242, 0.45);
}
.eyebrow {
margin-bottom: 8px;
color: #286e6a;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.hero h1 {
margin: 0;
font-size: clamp(28px, 4vw, 51px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 0.98;
}
.hero p {
max-width: 480px;
margin: 12px 0 0;
color: #315e62;
font-size: 14px;
line-height: 1.5;
}
.concept-badge {
position: fixed;
z-index: 5;
top: 28px;
right: 30px;
max-width: 285px;
padding: 11px 14px;
border: 1px solid rgba(255, 255, 255, 0.45);
border-radius: 999px;
color: #174c50;
background: rgba(240, 249, 243, 0.72);
box-shadow: 0 8px 25px rgba(34, 77, 77, 0.12);
backdrop-filter: blur(13px);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.095em;
line-height: 1.35;
text-align: center;
text-transform: uppercase;
}
.panel {
position: fixed;
z-index: 10;
left: 28px;
bottom: 27px;
width: min(400px, calc(100vw - 56px));
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 22px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.panel-kicker {
color: var(--teal);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.panel h2 {
margin: 6px 0 8px;
font-size: 20px;
letter-spacing: -0.025em;
}
.panel-intro,
#profile-copy {
margin: 0;
color: var(--muted);
font-size: 12.5px;
line-height: 1.52;
}
.profile-tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
margin: 14px 0 12px;
padding: 4px;
border-radius: 13px;
background: rgba(27, 76, 77, 0.07);
}
.profile-tab {
min-height: 39px;
padding: 7px 8px;
border: 0;
border-radius: 10px;
color: #42676b;
background: transparent;
cursor: pointer;
font-size: 11px;
font-weight: 750;
transition:
color 160ms ease,
background 160ms ease,
box-shadow 160ms ease,
transform 160ms ease;
}
.profile-tab:hover {
color: var(--ink);
background: rgba(255, 255, 255, 0.48);
}
.profile-tab:focus-visible {
outline: 3px solid rgba(8, 127, 120, 0.25);
outline-offset: 2px;
}
.profile-tab[aria-pressed="true"] {
color: #145c59;
background: #fff;
box-shadow: 0 4px 12px rgba(29, 74, 74, 0.12);
}
.profile-tab[aria-pressed="true"]::before {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 5px;
border-radius: 50%;
background: var(--teal);
content: "";
vertical-align: 1px;
}
.status-row {
display: flex;
align-items: center;
gap: 8px;
min-height: 25px;
margin: 3px 0 11px;
color: #365e62;
font-size: 11px;
font-weight: 750;
}
.status-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.12);
}
.caveat {
padding-top: 11px;
border-top: 1px solid var(--line);
color: #667a7c;
font-size: 10.5px;
line-height: 1.45;
}
.caveat strong {
color: #315a5e;
}
.legend {
position: fixed;
z-index: 8;
right: 29px;
bottom: 28px;
width: 218px;
padding: 15px 16px;
border: 1px solid rgba(255, 255, 255, 0.62);
border-radius: 18px;
background: rgba(247, 251, 246, 0.82);
box-shadow: 0 12px 36px rgba(23, 65, 67, 0.14);
backdrop-filter: blur(15px);
}
.legend-title {
margin-bottom: 10px;
color: #315d61;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
color: #486a6e;
font-size: 10.5px;
line-height: 1.25;
}
.swatch {
flex: 0 0 auto;
width: 16px;
height: 10px;
border-radius: 3px;
}
.swatch.habitat {
background: var(--green);
}
.swatch.gap {
background: var(--gap);
}
.swatch.corridor {
background: var(--amber);
}
.swatch.route {
height: 0;
border-top: 2px dashed #177f79;
border-radius: 0;
}
.view-controls {
position: fixed;
z-index: 9;
top: 96px;
right: 30px;
display: flex;
align-items: center;
gap: 7px;
}
.view-button {
display: grid;
width: 34px;
height: 34px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.63);
border-radius: 50%;
color: #245d61;
background: rgba(245, 251, 246, 0.76);
box-shadow: 0 5px 16px rgba(28, 71, 72, 0.12);
cursor: pointer;
backdrop-filter: blur(12px);
font-size: 17px;
font-weight: 700;
transition: transform 150ms ease, background 150ms ease;
}
.view-button:hover {
background: rgba(255, 255, 255, 0.95);
transform: translateY(-1px);
}
.view-button:focus-visible {
outline: 3px solid rgba(8, 127, 120, 0.25);
outline-offset: 2px;
}
.view-button.reset {
width: auto;
padding: 0 12px;
border-radius: 999px;
font-size: 10px;
letter-spacing: 0.04em;
text-transform: uppercase;
}
#labels {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px 7px 8px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 11px;
background: rgba(249, 253, 247, 0.88);
box-shadow: 0 8px 23px rgba(28, 68, 69, 0.15);
opacity: 0;
transform: translate(-50%, calc(-100% - 10px));
transition: opacity 120ms ease;
white-space: nowrap;
backdrop-filter: blur(9px);
}
.world-label::after {
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 10px;
background: rgba(36, 89, 91, 0.45);
content: "";
}
.world-label .label-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 3px rgba(101, 189, 105, 0.16);
}
.world-label.gap .label-dot {
background: var(--gap);
box-shadow: 0 0 0 3px rgba(137, 132, 120, 0.16);
}
.world-label.corridor .label-dot {
background: var(--amber);
box-shadow: 0 0 0 3px rgba(214, 161, 62, 0.17);
}
.label-text {
display: flex;
flex-direction: column;
gap: 1px;
}
.label-title {
color: #244f53;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.01em;
}
.label-subtitle {
color: #718486;
font-size: 8px;
font-weight: 600;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
color: #2b6669;
background: #b9d6d2;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
visibility: hidden;
opacity: 0;
}
@media (max-width: 850px) {
.hero {
top: 18px;
left: 18px;
max-width: calc(100vw - 36px);
}
.hero h1 {
max-width: 390px;
}
.hero p {
max-width: 390px;
font-size: 12px;
}
.concept-badge {
display: none;
}
.view-controls {
top: auto;
right: 15px;
bottom: 19px;
}
.legend {
display: none;
}
.panel {
left: 14px;
bottom: 14px;
width: min(390px, calc(100vw - 86px));
padding: 14px;
border-radius: 18px;
}
.panel h2 {
font-size: 17px;
}
.panel-intro {
display: none;
}
.profile-tabs {
margin-top: 10px;
}
.caveat {
font-size: 9.5px;
}
.world-label {
transform: translate(-50%, calc(-100% - 5px)) scale(0.9);
}
}
@media (max-height: 650px) {
.hero p,
.panel-intro,
.caveat {
display: none;
}
.panel {
padding: 13px 15px;
}
.profile-tabs {
margin: 9px 0;
}
}
</style>
</head>
<body>
<div id="app">
<div id="stage"></div>
<header class="hero">
<div class="eyebrow">Landscape connectivity study</div>
<h1>Connectivity is a species-specific hypothesis.</h1>
<p>
Two habitat patches, an unsuitable region, and one candidate corridor
tile. The possible link changes with the organism and its movement needs.
</p>
</header>
<div class="concept-badge">
Schematic concept model · not a universal suitability map
</div>
<div class="view-controls" aria-label="Camera controls">
<button
class="view-button"
id="zoom-in"
type="button"
aria-label="Zoom in"
title="Zoom in"
>+</button>
<button
class="view-button"
id="zoom-out"
type="button"
aria-label="Zoom out"
title="Zoom out"
>−</button>
<button
class="view-button reset"
id="reset-view"
type="button"
title="Reset the camera"
>Reset</button>
</div>
<section class="panel" aria-labelledby="panel-title">
<div class="panel-kicker">Illustrative species lens</div>
<h2 id="panel-title">Connectivity depends on the organism.</h2>
<p class="panel-intro">
The green areas are core habitat for the illustrated lens. The central
region is a suitability or resistance gap, while the amber tile is a
candidate intervention—not a guaranteed connection.
</p>
<div class="profile-tabs" role="group" aria-label="Illustrative species profile">
<button
class="profile-tab"
type="button"
data-profile="terrestrial"
aria-pressed="true"
>Ground mover</button>
<button
class="profile-tab"
type="button"
data-profile="arboreal"
aria-pressed="false"
>Arboreal</button>
<button
class="profile-tab"
type="button"
data-profile="aquatic"
aria-pressed="false"
>Aquatic</button>
</div>
<p id="profile-copy">
A narrow corridor may support movement if its width, substrate,
disturbance, and continuity match this species’ dispersal traits.
</p>
<div class="status-row">
<span class="status-dot" id="status-dot"></span>
<span id="profile-status">Plausible for this illustrated species</span>
</div>
<div class="caveat">
<strong>Concept, not prediction:</strong>
suitability depends on species traits, seasonal conditions, landscape
structure, and the scale and purpose of the assessment.
</div>
</section>
<aside class="legend" aria-label="Scene legend">
<div class="legend-title">Schematic layers</div>
<div class="legend-row">
<span class="swatch habitat"></span>
Two existing habitat patches
</div>
<div class="legend-row">
<span class="swatch gap"></span>
Unsuitable region for the shown lens
</div>
<div class="legend-row">
<span class="swatch corridor"></span>
One candidate corridor tile
</div>
<div class="legend-row">
<span class="swatch route"></span>
Connectivity hypothesis
</div>
</aside>
<div id="labels" aria-hidden="true">
<div class="world-label" id="label-a">
<span class="label-dot"></span>
<span class="label-text">
<span class="label-title">Habitat patch A</span>
<span class="label-subtitle">core habitat for this lens</span>
</span>
</div>
<div class="world-label" id="label-b">
<span class="label-dot"></span>
<span class="label-text">
<span class="label-title">Habitat patch B</span>
<span class="label-subtitle">core habitat for this lens</span>
</span>
</div>
<div class="world-label gap" id="label-gap">
<span class="label-dot"></span>
<span class="label-text">
<span class="label-title">Unsuitable region</span>
<span class="label-subtitle">for the shown species lens</span>
</span>
</div>
<div class="world-label corridor" id="label-corridor">
<span class="label-dot"></span>
<span class="label-text">
<span class="label-title">Candidate corridor tile</span>
<span class="label-subtitle">one possible connectivity route</span>
</span>
</div>
</div>
<div id="loading">Building schematic landscape…</div>
</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 loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0xb7d2cf, 0.012);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive schematic of two habitat patches separated by an unsuitable region and a candidate corridor"
);
renderer.domElement.tabIndex = 0;
stage.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-8, 8, 5, -5, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.25, 0);
const view = {
theta: 0.58,
phi: 0.91,
zoom: 1
};
const desiredView = {
theta: view.theta,
phi: view.phi,
zoom: view.zoom
};
function updateCamera() {
const distance = 14;
const sinPhi = Math.sin(view.phi);
camera.position.set(
cameraTarget.x + distance * sinPhi * Math.sin(view.theta),
cameraTarget.y + distance * Math.cos(view.phi),
cameraTarget.z + distance * sinPhi * Math.cos(view.theta)
);
camera.zoom = view.zoom;
camera.lookAt(cameraTarget);
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
const viewHeight = Math.max(9.6, 14.5 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
updateCamera();
}
window.addEventListener("resize", resize);
resize();
// Lighting
scene.add(new THREE.HemisphereLight(0xeafff6, 0x49615c, 2.15));
const sun = new THREE.DirectionalLight(0xfff3d5, 3.25);
sun.position.set(-5.5, 10, 6.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0x77ced0, 1.15);
fillLight.position.set(7, 4, -6);
scene.add(fillLight);
const warmRim = new THREE.DirectionalLight(0xffcf91, 0.65);
warmRim.position.set(-4, 3, -8);
scene.add(warmRim);
// Ground shadow catcher
const shadowPlane = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.ShadowMaterial({
color: 0x244b4d,
opacity: 0.18
})
);
shadowPlane.rotation.x = -Math.PI / 2;
shadowPlane.position.y = -0.43;
shadowPlane.receiveShadow = true;
scene.add(shadowPlane);
// Geometry helpers
function roundedRectangleShape(width, height, radius) {
const shape = new THREE.Shape();
const left = -width / 2;
const right = width / 2;
const bottom = -height / 2;
const top = height / 2;
shape.moveTo(left + radius, bottom);
shape.lineTo(right - radius, bottom);
shape.quadraticCurveTo(right, bottom, right, bottom + radius);
shape.lineTo(right, top - radius);
shape.quadraticCurveTo(right, top, right - radius, top);
shape.lineTo(left + radius, top);
shape.quadraticCurveTo(left, top, left, top - radius);
shape.lineTo(left, bottom + radius);
shape.quadraticCurveTo(left, bottom, left + radius, bottom);
shape.closePath();
return shape;
}
function polygonShape(points) {
const shape = new THREE.Shape();
points.forEach((point, index) => {
if (index === 0) {
shape.moveTo(point[0], point[1]);
} else {
shape.lineTo(point[0], point[1]);
}
});
shape.closePath();
return shape;
}
function extrudedPolygon({
points,
y,
depth,
topMaterial,
sideMaterial,
castShadow = true
}) {
const geometry = new THREE.ExtrudeGeometry(polygonShape(points), {
depth,
bevelEnabled: false,
steps: 1
});
geometry.rotateX(-Math.PI / 2);
const mesh = new THREE.Mesh(geometry, [topMaterial, sideMaterial]);
mesh.position.y = y;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function outline(points, y, color, dashed = false) {
const worldPoints = points.map(
(point) => new THREE.Vector3(point[0], y, -point[1])
);
if (dashed) {
worldPoints.push(worldPoints[0].clone());
}
const geometry = new THREE.BufferGeometry().setFromPoints(worldPoints);
const material = dashed
? new THREE.LineDashedMaterial({
color,
dashSize: 0.13,
gapSize: 0.09,
transparent: true,
opacity: 0.75
})
: new THREE.LineBasicMaterial({
color,
transparent: true,
opacity: 0.65
});
const line = new THREE.Line(geometry, material);
if (dashed) {
line.computeLineDistances();
}
scene.add(line);
return line;
}
// Materials
const boardTop = new THREE.MeshStandardMaterial({
color: 0xdce7df,
roughness: 0.96
});
const boardSide = new THREE.MeshStandardMaterial({
color: 0x315e60,
roughness: 0.82
});
const habitatATop = new THREE.MeshStandardMaterial({
color: 0x61bd69,
roughness: 0.94
});
const habitatBTop = new THREE.MeshStandardMaterial({
color: 0x6bc675,
roughness: 0.94
});
const habitatSide = new THREE.MeshStandardMaterial({
color: 0x765840,
roughness: 1
});
const unsuitableTop = new THREE.MeshStandardMaterial({
color: 0x8b867a,
roughness: 1
});
const unsuitableSide = new THREE.MeshStandardMaterial({
color: 0x6f695f,
roughness: 1
});
const corridorTop = new THREE.MeshStandardMaterial({
color: 0xd6a13e,
roughness: 0.86,
emissive: 0x4a2900,
emissiveIntensity: 0.12
});
const corridorSide = new THREE.MeshStandardMaterial({
color: 0x98652a,
roughness: 0.95
});
// Floating diorama base
const boardGeometry = new THREE.ExtrudeGeometry(
roundedRectangleShape(12, 7.25, 0.72),
{
depth: 0.36,
bevelEnabled: false,
steps: 1
}
);
boardGeometry.rotateX(-Math.PI / 2);
const board = new THREE.Mesh(boardGeometry, [boardTop, boardSide]);
board.position.y = -0.36;
board.castShadow = true;
board.receiveShadow = true;
scene.add(board);
// Landscape layers
const habitatA = [
[-4.75, -0.75],
[-4.35, -1.35],
[-3.25, -1.52],
[-2.45, -1.28],
[-1.28, -0.92],
[-1.22, 0.76],
[-2.15, 1.35],
[-3.45, 1.48],
[-4.58, 0.86]
];
const habitatB = [
[1.22, -0.90],
[1.22, 0.78],
[2.15, 1.38],
[3.42, 1.50],
[4.62, 0.85],
[4.72, -0.72],
[4.20, -1.35],
[3.10, -1.50],
[2.10, -1.25]
];
const unsuitableRegion = [
[-1.28, -1.53],
[-0.90, -1.92],
[0.88, -1.90],
[1.28, -1.55],
[1.28, 1.52],
[0.88, 1.90],
[-0.90, 1.88],
[-1.28, 1.50]
];
const corridorTile = [
[-1.40, -0.48],
[-0.72, -0.38],
[0.00, -0.47],
[0.75, -0.37],
[1.40, -0.48],
[1.40, 0.48],
[0.72, 0.38],
[0.00, 0.47],
[-0.75, 0.38],
[-1.40, 0.48]
];
extrudedPolygon({
points: unsuitableRegion,
y: 0.012,
depth: 0.045,
topMaterial: unsuitableTop,
sideMaterial: unsuitableSide,
castShadow: false
});
extrudedPolygon({
points: habitatA,
y: 0.035,
depth: 0.15,
topMaterial: habitatATop,
sideMaterial: habitatSide
});
extrudedPolygon({
points: habitatB,
y: 0.035,
depth: 0.15,
topMaterial: habitatBTop,
sideMaterial: habitatSide
});
const corridorMesh = extrudedPolygon({
points: corridorTile,
y: 0.18,
depth: 0.08,
topMaterial: corridorTop,
sideMaterial: corridorSide
});
outline(habitatA, 0.193, 0x337c3e);
outline(habitatB, 0.193, 0x337c3e);
outline(unsuitableRegion, 0.073, 0x5d5b54, true);
// Small pavers provide visual detail to the single corridor tile.
const paverMaterial = new THREE.MeshStandardMaterial({
color: 0xf0c56d,
roughness: 0.86
});
[-0.66, 0, 0.66].forEach((x, index) => {
const paver = new THREE.Mesh(
new THREE.BoxGeometry(0.19, 0.028, 0.64 - index * 0.035),
paverMaterial
);
paver.position.set(x, 0.282, 0);
paver.rotation.y = index === 1 ? 0 : (index === 0 ? -0.08 : 0.08);
paver.castShadow = true;
paver.receiveShadow = true;
scene.add(paver);
});
// Deterministic pseudo-random helper
function mulberry32(seed) {
return function random() {
let value = seed += 0x6d2b79f5;
value = Math.imul(value ^ (value >>> 15), value | 1);
value ^= value + Math.imul(value ^ (value >>> 7), value | 61);
return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
};
}
const random = mulberry32(73);
// Stylized vegetation
const trunkMaterial = new THREE.MeshStandardMaterial({
color: 0x785039,
roughness: 1
});
const canopyMaterials = [
new THREE.MeshStandardMaterial({ color: 0x23764c, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x318958, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x439b5a, roughness: 1 })
];
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.065, 0.09, 0.44, 6),
trunkMaterial
);
trunk.position.y = 0.22;
const canopy = new THREE.Mesh(
new THREE.ConeGeometry(0.35, 0.83, 7),
canopyMaterials[Math.floor(random() * canopyMaterials.length)]
);
canopy.position.y = 0.76;
const crown = new THREE.Mesh(
new THREE.ConeGeometry(0.27, 0.62, 7),
canopyMaterials[Math.floor(random() * canopyMaterials.length)]
);
crown.position.set(0.05, 1.02, -0.02);
tree.add(trunk, canopy, crown);
tree.position.set(x, 0.19, z);
tree.scale.setScalar(scale);
tree.rotation.y = random() * Math.PI * 2;
tree.traverse((object) => {
if (object.isMesh) {
object.castShadow = true;
object.receiveShadow = true;
}
});
scene.add(tree);
}
[
[-4.00, -0.65, 1.00],
[-3.55, 0.55, 0.88],
[-2.90, -0.75, 1.08],
[-2.35, 0.45, 0.82],
[-3.02, 1.02, 0.95],
[-4.12, 0.02, 0.76],
[1.72, -0.55, 0.92],
[2.15, 0.55, 1.02],
[2.80, -0.75, 0.84],
[3.28, 0.65, 1.08],
[3.88, -0.20, 0.90],
[4.12, 0.60, 0.75],
[2.92, 1.03, 0.96]
].forEach((tree) => addTree(...tree));
const bushMaterial = new THREE.MeshStandardMaterial({
color: 0x3a8d50,
roughness: 1
});
function addBush(x, z, scale = 1) {
const bush = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.18, 0),
bushMaterial
);
bush.position.set(x, 0.28, z);
bush.scale.set(scale, scale * 0.65, scale);
bush.rotation.set(random(), random() * Math.PI, random());
bush.castShadow = true;
bush.receiveShadow = true;
scene.add(bush);
}
[
[-4.30, 0.55], [-3.72, -1.05], [-2.75, 0.95],
[-2.10, -0.30], [-1.80, 0.92], [1.70, 0.95],
[2.45, -1.02], [3.08, 0.98], [3.72, 0.65],
[4.32, -0.55], [4.15, 0.12], [2.60, 0.28]
].forEach((bush, index) => addBush(
bush[0],
bush[1],
0.72 + (index % 4) * 0.13
));
// Angular rocks make the unsuitable region visually resistant.
const rockMaterials = [
new THREE.MeshStandardMaterial({ color: 0x6e6b63, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x827b6e, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x5f625e, roughness: 1 })
];
[
[-0.75, -1.28, 0.18], [-0.48, -1.53, 0.12],
[0.67, -1.42, 0.17], [0.86, -1.08, 0.11],
[-0.70, 1.33, 0.16], [-0.42, 1.55, 0.11],
[0.64, 1.36, 0.18], [0.87, 1.10, 0.12],
[-0.92, -0.77, 0.10], [0.91, 0.73, 0.11]
].forEach((rock, index) => {
const mesh = new THREE.Mesh(
new THREE.DodecahedronGeometry(rock[2], 0),
rockMaterials[index % rockMaterials.length]
);
mesh.position.set(rock[0], 0.17, rock[1]);
mesh.rotation.set(random() * 2, random() * 2, random() * 2);
mesh.scale.y = 0.72;
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
});
// Conceptual dashed route
const routeMaterial = new THREE.LineDashedMaterial({
color: 0x168a83,
dashSize: 0.15,
gapSize: 0.105,
transparent: true,
opacity: 0.9,
depthTest: true
});
const routePoints = [
new THREE.Vector3(-2.45, 0.315, 0.18),
new THREE.Vector3(-1.25, 0.315, 0),
new THREE.Vector3(0.00, 0.315, 0),
new THREE.Vector3(1.25, 0.315, 0),
new THREE.Vector3(2.45, 0.315, 0.18)
];
const routeGeometry = new THREE.BufferGeometry().setFromPoints(routePoints);
const routeLine = new THREE.Line(routeGeometry, routeMaterial);
routeLine.computeLineDistances();
scene.add(routeLine);
const routeCurve = new THREE.CatmullRomCurve3(routePoints);
const movingDotMaterial = new THREE.MeshBasicMaterial({
color: 0xf7fff6,
transparent: true,
opacity: 0.96
});
const movingDots = [];
for (let index = 0; index < 3; index += 1) {
const dot = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 12, 8),
movingDotMaterial
);
dot.castShadow = false;
scene.add(dot);
movingDots.push(dot);
}
const endRingMaterial = new THREE.MeshBasicMaterial({
color: 0xf7f2dc,
transparent: true,
opacity: 0.88
});
[-1.37, 1.37].forEach((x) => {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.12, 0.026, 8, 22),
endRingMaterial
);
ring.rotation.x = Math.PI / 2;
ring.position.set(x, 0.30, 0);
scene.add(ring);
});
// Direct camera controls: no addons or OrbitControls are used.
let dragging = false;
let moved = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.pointerType === "mouse") return;
dragging = true;
moved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
if (Math.abs(deltaX) + Math.abs(deltaY) > 2) {
moved = true;
}
desiredView.theta -= deltaX * 0.006;
desiredView.phi = THREE.MathUtils.clamp(
desiredView.phi - deltaY * 0.005,
0.38,
1.35
);
pointerX = event.clientX;
pointerY = event.clientY;
});
function stopDragging(event) {
dragging = false;
if (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();
desiredView.zoom = THREE.MathUtils.clamp(
desiredView.zoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.75
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener("keydown", (event) => {
const key = event.key;
if (key === "ArrowLeft") desiredView.theta += 0.09;
if (key === "ArrowRight") desiredView.theta -= 0.09;
if (key === "ArrowUp") desiredView.phi = Math.max(0.38, desiredView.phi - 0.07);
if (key === "ArrowDown") desiredView.phi = Math.min(1.35, desiredView.phi + 0.07);
if (key === "+" || key === "=") desiredView.zoom = Math.min(1.75, desiredView.zoom * 1.1);
if (key === "-" || key === "_") desiredView.zoom = Math.max(0.68, desiredView.zoom / 1.1);
if (key.startsWith("Arrow") || key === "+" || key === "-" || key === "=") {
event.preventDefault();
}
});
function resetView() {
desiredView.theta = 0.58;
desiredView.phi = 0.91;
desiredView.zoom = 1;
}
document.querySelector("#reset-view").addEventListener("click", resetView);
document.querySelector("#zoom-in").addEventListener("click", () => {
desiredView.zoom = Math.min(1.75, desiredView.zoom * 1.12);
});
document.querySelector("#zoom-out").addEventListener("click", () => {
desiredView.zoom = Math.max(0.68, desiredView.zoom / 1.12);
});
// Species profiles make the species-dependence explicit.
const profiles = {
terrestrial: {
copy:
"A narrow corridor may support movement if its width, substrate, disturbance, and continuity match this species’ dispersal traits.",
status: "Plausible for this illustrated species",
color: 0x168a83,
cssColor: "#087f78",
showMovement: true,
corridorCopy: "one possible connectivity route"
},
arboreal: {
copy:
"A ground-level tile may not help this species. Functional connectivity may require suitable vegetation structure, canopy continuity, and a viable sequence of stepping sites.",
status: "Conditional — required canopy continuity is not shown",
color: 0xd39a39,
cssColor: "#b37b18",
showMovement: false,
corridorCopy: "needs a vegetation-structure check"
},
aquatic: {
copy:
"Neither the land corridor nor the shown unsuitable matrix represents a hydrological connection. A different landscape feature would need to be evaluated.",
status: "Not functional for this illustrated species",
color: 0xd85e59,
cssColor: "#c54d49",
showMovement: false,
corridorCopy: "not usable in this species lens"
}
};
const profileButtons = [...document.querySelectorAll(".profile-tab")];
const profileCopy = document.querySelector("#profile-copy");
const profileStatus = document.querySelector("#profile-status");
const statusDot = document.querySelector("#status-dot");
const corridorSubtitle = document.querySelector(
"#label-corridor .label-subtitle"
);
let activeProfile = "terrestrial";
function applyProfile(profileKey) {
const profile = profiles[profileKey];
activeProfile = profileKey;
profileButtons.forEach((button) => {
button.setAttribute(
"aria-pressed",
String(button.dataset.profile === profileKey)
);
});
profileCopy.textContent = profile.copy;
profileStatus.textContent = profile.status;
statusDot.style.background = profile.cssColor;
statusDot.style.boxShadow = `0 0 0 4px ${profile.cssColor}22`;
corridorSubtitle.textContent = profile.corridorCopy;
routeMaterial.color.setHex(profile.color);
routeMaterial.opacity = profileKey === "aquatic" ? 0.48 : 0.9;
endRingMaterial.color.setHex(
profileKey === "aquatic" ? 0xe7aaa5 : 0xf7f2dc
);
endRingMaterial.opacity = profileKey === "aquatic" ? 0.5 : 0.88;
corridorTop.emissiveIntensity =
profileKey === "terrestrial" ? 0.17 : 0.08;
}
profileButtons.forEach((button) => {
button.addEventListener("click", () => {
applyProfile(button.dataset.profile);
});
});
applyProfile(activeProfile);
// DOM labels are projected from 3D anchor points.
const labelAnchors = [
{
element: document.querySelector("#label-a"),
position: new THREE.Vector3(-3.0, 1.45, 0.05)
},
{
element: document.querySelector("#label-b"),
position: new THREE.Vector3(3.0, 1.45, 0.05)
},
{
element: document.querySelector("#label-gap"),
position: new THREE.Vector3(0, 0.30, -1.48)
},
{
element: document.querySelector("#label-corridor"),
position: new THREE.Vector3(0, 0.48, 0.92)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = renderer.domElement.clientWidth;
const height = renderer.domElement.clientHeight;
labelAnchors.forEach(({ element, position }) => {
projected.copy(position).project(camera);
const visible =
projected.z >= -1 &&
projected.z <= 1 &&
projected.x > -1.25 &&
projected.x < 1.25 &&
projected.y > -1.25 &&
projected.y < 1.25;
element.style.opacity = visible ? "1" : "0";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
});
}
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const clock = new THREE.Clock();
let firstFrame = true;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const damping = 1 - Math.pow(0.001, delta);
view.theta = THREE.MathUtils.lerp(
view.theta,
desiredView.theta,
damping
);
view.phi = THREE.MathUtils.lerp(
view.phi,
desiredView.phi,
damping
);
view.zoom = THREE.MathUtils.lerp(
view.zoom,
desiredView.zoom,
damping
);
updateCamera();
movingDots.forEach((dot, index) => {
dot.visible = profiles[activeProfile].showMovement;
if (dot.visible) {
const progress = (elapsed * 0.075 + index / movingDots.length) % 1;
const point = routeCurve.getPointAt(progress);
dot.position.copy(point);
dot.position.y += 0.025;
const pulse = 1 + Math.sin(elapsed * 4 + index) * 0.08;
dot.scale.setScalar(pulse);
}
});
updateLabels();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
loading.classList.add("hidden");
}
}
animate();
</script>
</body>
</html>
```