Prompt specification
Build or customize the Three.js 3D scene "Wetland animal moving between dry refuges" 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: Wetland animal moving between dry refuges
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/wetland-animal-moving-between-dry-refuges-x3106
Scene Description Prompt:
Use Three.js from cdnjs to create a respectful Pantanal vignette with one referenced animal species and low mounds. Animate movement along a dry route without inventing complex species-specific behavior. Deliver one self-contained HTML file with low-poly forms.
Working Three.js Starter (wetland-animal-moving-between-dry-refuges-x3106):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#d8d4bd">
<title>Dry-Season Passage — Pantanal</title>
<style>
:root {
--ink: #252720;
--muted: #5f6257;
--paper: rgba(245, 242, 225, 0.88);
--line: rgba(55, 58, 47, 0.19);
--accent: #865b2d;
--track: rgba(55, 58, 47, 0.15);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d4bd;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
a {
-webkit-tap-highlight-color: transparent;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
#stage canvas:active {
cursor: grabbing;
}
.grain {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
opacity: 0.12;
background-image:
repeating-radial-gradient(circle at 17% 32%, transparent 0 1px, rgba(35, 34, 28, 0.16) 1px 2px),
repeating-radial-gradient(circle at 73% 68%, transparent 0 1px, rgba(35, 34, 28, 0.12) 1px 2px);
background-size: 7px 7px, 11px 11px;
mix-blend-mode: multiply;
}
.frame {
position: fixed;
inset: 18px;
z-index: 3;
pointer-events: none;
border: 1px solid rgba(255, 255, 255, 0.28);
box-shadow: inset 0 0 90px rgba(73, 65, 43, 0.08);
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--line);
background: var(--paper);
box-shadow: 0 14px 45px rgba(47, 43, 31, 0.11);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#title-card {
top: 38px;
left: 38px;
width: min(410px, calc(100vw - 76px));
padding: 24px 26px 23px;
}
.eyebrow {
margin: 0 0 13px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(35px, 5vw, 59px);
font-weight: 400;
line-height: 0.96;
letter-spacing: -0.035em;
}
.subtitle {
max-width: 330px;
margin: 17px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.65;
}
.species-line {
display: flex;
align-items: center;
gap: 10px;
margin-top: 19px;
padding-top: 15px;
border-top: 1px solid var(--line);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.species-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(134, 91, 45, 0.11);
}
#reference-card {
top: 38px;
right: 38px;
width: min(310px, calc(100vw - 76px));
padding: 20px 21px;
}
#reference-card h2 {
margin: 0 0 9px;
font-size: 11px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#reference-card p {
margin: 0 0 12px;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
#reference-card em {
color: var(--ink);
}
.references {
display: flex;
flex-wrap: wrap;
gap: 8px 13px;
}
.references a {
color: var(--accent);
font-size: 11px;
font-weight: 750;
text-underline-offset: 3px;
}
#transport {
left: 38px;
right: 38px;
bottom: 38px;
min-height: 74px;
display: grid;
grid-template-columns: minmax(190px, 0.8fr) minmax(230px, 1fr) auto;
align-items: center;
gap: 25px;
padding: 14px 16px 14px 21px;
}
.route-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
}
.route-heading strong {
font-size: 10px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
#route-position {
color: var(--muted);
font-size: 10px;
font-variant-numeric: tabular-nums;
}
.track {
position: relative;
height: 2px;
overflow: hidden;
background: var(--track);
}
#route-fill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
background: var(--accent);
transition: width 80ms linear;
}
.controls {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 8px;
}
button {
min-height: 40px;
padding: 0 14px;
border: 1px solid var(--line);
border-radius: 0;
background: rgba(255, 255, 255, 0.38);
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
button:hover,
button:focus-visible {
border-color: rgba(55, 58, 47, 0.4);
background: rgba(255, 255, 255, 0.75);
outline: none;
}
button.active {
border-color: var(--accent);
background: var(--accent);
color: #fffaf0;
}
.camera-hint {
color: var(--muted);
font-size: 10px;
line-height: 1.45;
text-align: right;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #d8d4bd;
transition: opacity 500ms ease;
}
body.ready #loading {
opacity: 0;
pointer-events: none;
}
.loader {
width: 180px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-align: center;
text-transform: uppercase;
}
.loader::after {
content: "";
display: block;
height: 1px;
margin-top: 14px;
overflow: hidden;
background: rgba(55, 58, 47, 0.15);
}
.loader::before {
content: "";
display: block;
height: 1px;
margin-bottom: -1px;
background: var(--accent);
animation: load 1.1s ease-in-out infinite alternate;
}
@keyframes load {
from { width: 8%; }
to { width: 100%; }
}
@media (max-width: 900px) {
#reference-card {
display: none;
}
#title-card {
width: min(350px, calc(100vw - 56px));
top: 28px;
left: 28px;
padding: 20px;
}
.subtitle {
font-size: 12px;
}
#transport {
left: 28px;
right: 28px;
bottom: 28px;
grid-template-columns: 1fr auto;
gap: 14px;
}
.route-block {
grid-column: 1 / -1;
}
.camera-hint {
display: none;
}
}
@media (max-width: 560px) {
.frame {
inset: 10px;
}
#title-card {
top: 20px;
left: 20px;
width: calc(100vw - 40px);
}
h1 {
font-size: 40px;
}
.subtitle {
max-width: 290px;
}
#transport {
left: 20px;
right: 20px;
bottom: 20px;
padding: 13px;
grid-template-columns: 1fr;
}
.controls {
justify-content: stretch;
}
.controls button {
flex: 1;
padding: 0 8px;
}
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
}
</style>
</head>
<body>
<main id="stage" aria-label="Interactive low-poly Pantanal vignette"></main>
<div class="grain" aria-hidden="true"></div>
<div class="frame" aria-hidden="true"></div>
<header id="title-card" class="panel">
<p class="eyebrow">Pantanal · Seasonal study</p>
<h1>Dry-season<br>passage</h1>
<p class="subtitle">
A restrained field vignette of one jaguar moving along an exposed route.
The animation is a simple transit loop, not a reconstruction of specific behavior.
</p>
<div class="species-line">
<span class="species-dot" aria-hidden="true"></span>
<span>Jaguar · <i>Panthera onca</i></span>
</div>
</header>
<aside id="reference-card" class="panel" aria-label="Species reference">
<h2>Species reference</h2>
<p>
<em>Panthera onca</em> is native to the Pantanal. This generalized dry-season
scene is illustrative, not a habitat map or depiction of a particular individual.
</p>
<p>
No hunting, display, interaction, or other inferred behavior is staged.
</p>
<div class="references">
<a href="https://www.iucnredlist.org/species/15955/19392379"
target="_blank" rel="noopener noreferrer">IUCN Red List</a>
<a href="https://www.britannica.com/place/Pantanal"
target="_blank" rel="noopener noreferrer">Britannica: Pantanal</a>
</div>
</aside>
<section id="transport" class="panel" aria-label="Scene controls">
<div class="route-block">
<div class="route-heading">
<strong>Dry route</strong>
<span id="route-position" aria-live="polite">0% along route</span>
</div>
<div class="track" aria-hidden="true">
<span id="route-fill"></span>
</div>
</div>
<div class="controls">
<button id="pause-button" type="button" aria-pressed="false">Pause motion</button>
<button id="follow-button" type="button" aria-pressed="false">Follow jaguar</button>
<button id="reset-button" type="button">Reset view</button>
</div>
<div class="camera-hint">
Drag to orbit · wheel or pinch to zoom<br>
Space: pause · F: follow · R: reset
</div>
</section>
<div id="loading" aria-live="polite">
<div class="loader">Preparing the seasonal ground</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 pauseButton = document.querySelector("#pause-button");
const followButton = document.querySelector("#follow-button");
const resetButton = document.querySelector("#reset-button");
const routePosition = document.querySelector("#route-position");
const routeFill = document.querySelector("#route-fill");
const clamp = THREE.MathUtils.clamp;
const lerp = THREE.MathUtils.lerp;
// Deterministic procedural placement keeps the vignette reproducible.
function mulberry32(seed) {
return function () {
let t = seed += 0x6D2B79F5;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const random = mulberry32(24031992);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d4bd);
scene.fog = new THREE.Fog(0xd8d4bd, 28, 67);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
120
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.75));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.04;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.appendChild(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Low-poly jaguar moving through a dry Pantanal landscape. Drag to orbit and use the controls to pause or follow."
);
renderer.domElement.tabIndex = 0;
const hemisphere = new THREE.HemisphereLight(0xf5ead0, 0x67654a, 1.75);
scene.add(hemisphere);
const sunLight = new THREE.DirectionalLight(0xffedc5, 2.5);
sunLight.position.set(-12, 19, 9);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -30;
sunLight.shadow.camera.right = 30;
sunLight.shadow.camera.top = 27;
sunLight.shadow.camera.bottom = -27;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 55;
sunLight.shadow.bias = -0.0005;
scene.add(sunLight);
const fillLight = new THREE.DirectionalLight(0xb9c9bd, 0.45);
fillLight.position.set(14, 8, -13);
scene.add(fillLight);
// The route is a closed visual guide around the remaining wetland.
const routeCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-17, 0, 5),
new THREE.Vector3(-11, 0, 8),
new THREE.Vector3(-3, 0, 6),
new THREE.Vector3(5, 0, 2),
new THREE.Vector3(12, 0, 4),
new THREE.Vector3(17, 0, -1),
new THREE.Vector3(13, 0, -8),
new THREE.Vector3(4, 0, -10),
new THREE.Vector3(-5, 0, -8),
new THREE.Vector3(-13, 0, -10),
new THREE.Vector3(-19, 0, -4)
], true, "catmullrom", 0.45);
routeCurve.arcLengthDivisions = 500;
const routeSamples = [];
for (let i = 0; i < 160; i++) {
routeSamples.push(routeCurve.getPointAt(i / 160));
}
function distanceToRoute(x, z) {
let minimum = Infinity;
for (const point of routeSamples) {
const dx = point.x - x;
const dz = point.z - z;
minimum = Math.min(minimum, dx * dx + dz * dz);
}
return Math.sqrt(minimum);
}
function terrainHeight(x, z) {
const broad =
Math.sin(x * 0.22) * 0.13 +
Math.cos(z * 0.29) * 0.10 +
Math.sin((x + z) * 0.13) * 0.07;
const routeDistance = distanceToRoute(x, z);
const routeFlatten = clamp((routeDistance - 1.25) / 4.0, 0, 1);
const pondDistance = Math.sqrt(
Math.pow(x / 5.5, 2) +
Math.pow((z + 1) / 3.8, 2)
);
const pondFlatten = clamp((pondDistance - 0.74) / 0.52, 0, 1);
let height = broad * routeFlatten * pondFlatten;
if (pondDistance < 0.95) {
height = -0.23 + broad * 0.06;
}
return height;
}
function routeWidth(u) {
return 1.14 + Math.sin(u * Math.PI * 14) * 0.12 +
Math.sin(u * Math.PI * 31 + 0.8) * 0.08;
}
// Faceted, subtly colored ground.
const groundGeometry = new THREE.PlaneGeometry(54, 44, 54, 44);
groundGeometry.rotateX(-Math.PI / 2);
const groundPositions = groundGeometry.attributes.position;
const groundColors = [];
for (let i = 0; i < groundPositions.count; i++) {
const x = groundPositions.getX(i);
const z = groundPositions.getZ(i);
const y = terrainHeight(x, z);
groundPositions.setY(i, y);
const color = new THREE.Color();
color.setHSL(
0.13 + random() * 0.025,
0.20 + random() * 0.06,
0.43 + random() * 0.045
);
groundColors.push(color.r, color.g, color.b);
}
groundGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(groundColors, 3)
);
groundGeometry.computeVertexNormals();
const groundMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true
});
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.receiveShadow = true;
scene.add(ground);
// A low-poly ribbon establishes the dry route without resembling pavement.
const ribbonSegments = 240;
const ribbonPositions = [];
const ribbonColors = [];
const ribbonIndices = [];
const ribbonUvs = [];
for (let i = 0; i <= ribbonSegments; i++) {
const u = i / ribbonSegments;
const point = routeCurve.getPointAt(u);
const tangent = routeCurve.getTangentAt(u);
const perpendicular = new THREE.Vector3(-tangent.z, 0, tangent.x).normalize();
const width = routeWidth(u);
for (let side = 0; side < 2; side++) {
const sign = side === 0 ? -1 : 1;
const px = point.x + perpendicular.x * width * sign;
const pz = point.z + perpendicular.z * width * sign;
ribbonPositions.push(
px,
terrainHeight(px, pz) + 0.028,
pz
);
ribbonUvs.push(u * 24, side);
const color = new THREE.Color().setHSL(
0.105,
0.27,
0.59 + Math.sin(i * 1.7) * 0.018
);
ribbonColors.push(color.r, color.g, color.b);
}
if (i < ribbonSegments) {
const a = i * 2;
ribbonIndices.push(a, a + 2, a + 1, a + 1, a + 2, a + 3);
}
}
const ribbonGeometry = new THREE.BufferGeometry();
ribbonGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(ribbonPositions, 3)
);
ribbonGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(ribbonColors, 3)
);
ribbonGeometry.setAttribute(
"uv",
new THREE.Float32BufferAttribute(ribbonUvs, 2)
);
ribbonGeometry.setIndex(ribbonIndices);
ribbonGeometry.computeVertexNormals();
const ribbon = new THREE.Mesh(
ribbonGeometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
})
);
ribbon.receiveShadow = true;
scene.add(ribbon);
// Irregular remnant water and muddy margin.
function makePond(scale, y, material) {
const segments = 18;
const positions = [0, y, 0];
const indices = [];
for (let i = 0; i < segments; i++) {
const angle = i / segments * Math.PI * 2;
const radius = scale * (
0.91 +
Math.sin(angle * 3 + 0.7) * 0.055 +
Math.sin(angle * 7) * 0.025
);
positions.push(
Math.cos(angle) * radius,
y,
Math.sin(angle) * radius * 0.72
);
if (i < segments - 1) {
indices.push(0, i + 1, i + 2);
}
}
indices.push(0, segments, 1);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.position.z = -1;
mesh.receiveShadow = true;
scene.add(mesh);
}
makePond(
1.12,
-0.195,
new THREE.MeshStandardMaterial({
color: 0x82755d,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
})
);
makePond(
1,
-0.125,
new THREE.MeshStandardMaterial({
color: 0x71877c,
roughness: 0.55,
metalness: 0.04,
flatShading: true,
side: THREE.DoubleSide
})
);
// Low, faceted mounds.
const moundGeometry = new THREE.IcosahedronGeometry(1, 1);
const moundLocations = [
[-15, -2, 2.5, 0.48],
[-14, 10, 2.2, 0.42],
[7, 11, 2.8, 0.55],
[18, 8, 2.1, 0.42],
[19, -10, 2.7, 0.48],
[-7, 13, 1.9, 0.38],
[2, -14, 2.5, 0.44],
[-21, -8, 2.0, 0.38]
];
moundLocations.forEach(([x, z, radius, height], index) => {
const material = new THREE.MeshStandardMaterial({
color: new THREE.Color().setHSL(
0.13,
0.18,
0.39 + index * 0.007
),
roughness: 1,
flatShading: true
});
const mound = new THREE.Mesh(moundGeometry, material);
mound.position.set(x, terrainHeight(x, z) - 0.16, z);
mound.scale.set(radius, height, radius * 0.73);
mound.rotation.y = random() * Math.PI;
mound.receiveShadow = true;
scene.add(mound);
});
// Small, crossed grass blades distributed in low-poly tufts.
const grassPositions = [];
for (let blade = 0; blade < 3; blade++) {
const angle = blade * Math.PI / 3 + 0.2;
const dx = Math.cos(angle) * 0.035;
const dz = Math.sin(angle) * 0.035;
const tipX = Math.sin(angle) * 0.045;
const tipZ = Math.cos(angle) * 0.045;
grassPositions.push(
-dx, 0, -dz,
dx, 0, dz,
tipX, 0.31, tipZ
);
}
const grassGeometry = new THREE.BufferGeometry();
grassGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(grassPositions, 3)
);
grassGeometry.computeVertexNormals();
const grassMaterial = new THREE.MeshStandardMaterial({
color: 0x777650,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
});
const grassCount = 310;
const grass = new THREE.InstancedMesh(
grassGeometry,
grassMaterial,
grassCount
);
const dummy = new THREE.Object3D();
let grassIndex = 0;
let attempts = 0;
while (grassIndex < grassCount && attempts < grassCount * 10) {
attempts++;
const x = (random() - 0.5) * 50;
const z = (random() - 0.5) * 40;
const pondDistance = Math.sqrt(
Math.pow(x / 5.8, 2) +
Math.pow((z + 1) / 4.1, 2)
);
if (distanceToRoute(x, z) < 1.9 || pondDistance < 1.08) {
continue;
}
dummy.position.set(x, terrainHeight(x, z) + 0.02, z);
dummy.rotation.set(0, random() * Math.PI * 2, 0);
const scale = 0.55 + random() * 0.95;
dummy.scale.set(scale, scale, scale);
dummy.updateMatrix();
grass.setMatrixAt(grassIndex, dummy.matrix);
grass.setColorAt(
grassIndex,
new THREE.Color().setHSL(
0.14 + random() * 0.035,
0.18,
0.38 + random() * 0.09
)
);
grassIndex++;
}
grass.instanceMatrix.needsUpdate = true;
if (grass.instanceColor) grass.instanceColor.needsUpdate = true;
grass.receiveShadow = true;
scene.add(grass);
// Restrained perimeter vegetation, kept low and outside the route.
const shrubGeometry = new THREE.DodecahedronGeometry(1, 0);
const shrubLocations = [
[-20, 8], [-17, -8], [-10, 13], [-3, 14],
[10, 13], [20, 6], [19, -13], [8, -16],
[-3, -16], [-16, -13], [14, 10]
];
shrubLocations.forEach(([x, z], index) => {
const shrub = new THREE.Mesh(
shrubGeometry,
new THREE.MeshStandardMaterial({
color: new THREE.Color().setHSL(
0.16,
0.16,
0.34 + index * 0.006
),
roughness: 1,
flatShading: true
})
);
shrub.position.set(x, terrainHeight(x, z) + 0.33, z);
shrub.scale.set(0.7 + random() * 0.4, 0.38, 0.6 + random() * 0.3);
shrub.rotation.y = random() * Math.PI;
shrub.castShadow = true;
shrub.receiveShadow = true;
scene.add(shrub);
});
// A faceted sun and a few quiet cloud forms.
const sunDisc = new THREE.Mesh(
new THREE.IcosahedronGeometry(1.55, 1),
new THREE.MeshBasicMaterial({ color: 0xf3d89a, fog: false })
);
sunDisc.position.set(-19, 15, -28);
scene.add(sunDisc);
const cloudMaterial = new THREE.MeshStandardMaterial({
color: 0xe9e5d4,
roughness: 1,
flatShading: true,
transparent: true,
opacity: 0.72,
depthWrite: false
});
[
[-11, 11, -23, 1.0],
[4, 13, -25, 1.2],
[16, 10, -21, 0.85]
].forEach(([x, y, z, scale]) => {
const cloud = new THREE.Group();
for (let i = 0; i < 3; i++) {
const puff = new THREE.Mesh(
new THREE.DodecahedronGeometry(1, 0),
cloudMaterial
);
puff.position.set((i - 1) * 0.75, Math.abs(i - 1) * 0.18, 0);
puff.scale.set(0.85, 0.38, 0.48);
cloud.add(puff);
}
cloud.position.set(x, y, z);
cloud.scale.setScalar(scale);
scene.add(cloud);
});
// Small stones edge the exposed route.
const stoneGeometry = new THREE.DodecahedronGeometry(1, 0);
const stoneCount = 88;
const stones = new THREE.InstancedMesh(
stoneGeometry,
new THREE.MeshStandardMaterial({
color: 0x9c8b6e,
roughness: 1,
flatShading: true
}),
stoneCount
);
for (let i = 0; i < stoneCount; i++) {
const u = random();
const point = routeCurve.getPointAt(u);
const tangent = routeCurve.getTangentAt(u);
const perpendicular = new THREE.Vector3(-tangent.z, 0, tangent.x).normalize();
const side = random() > 0.5 ? 1 : -1;
const offset = routeWidth(u) + 0.08 + random() * 0.25;
const x = point.x + perpendicular.x * offset * side;
const z = point.z + perpendicular.z * offset * side;
dummy.position.set(x, terrainHeight(x, z) + 0.045, z);
dummy.rotation.set(random(), random() * Math.PI, random());
dummy.scale.set(
0.035 + random() * 0.075,
0.025 + random() * 0.045,
0.04 + random() * 0.08
);
dummy.updateMatrix();
stones.setMatrixAt(i, dummy.matrix);
}
stones.instanceMatrix.needsUpdate = true;
stones.castShadow = true;
scene.add(stones);
// ------------------------------------------------------------
// Procedural jaguar: one species, no imported model or textures.
// ------------------------------------------------------------
const furMaterial = new THREE.MeshStandardMaterial({
color: 0xb97b39,
roughness: 0.92,
flatShading: true
});
const paleFurMaterial = new THREE.MeshStandardMaterial({
color: 0xd4bb8e,
roughness: 0.95,
flatShading: true
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x27221d,
roughness: 0.95,
flatShading: true
});
const spotMaterial = new THREE.MeshStandardMaterial({
color: 0x211d19,
roughness: 1,
flatShading: true,
side: THREE.DoubleSide
});
const bodySphere = new THREE.SphereGeometry(1, 10, 6);
const smallSphere = new THREE.SphereGeometry(1, 8, 5);
function ellipsoid(parent, material, position, scale, geometry = bodySphere) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(position[0], position[1], position[2]);
mesh.scale.set(scale[0], scale[1], scale[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const jaguarRoot = new THREE.Group();
const jaguarModel = new THREE.Group();
jaguarRoot.add(jaguarModel);
scene.add(jaguarRoot);
ellipsoid(
jaguarModel,
furMaterial,
[0, 0.98, 0],
[1.35, 0.52, 0.61]
);
ellipsoid(
jaguarModel,
furMaterial,
[0.94, 1.0, 0],
[0.62, 0.48, 0.49]
);
const head = new THREE.Group();
head.position.set(1.43, 1.12, 0);
jaguarModel.add(head);
ellipsoid(
head,
furMaterial,
[0, 0, 0],
[0.56, 0.46, 0.46]
);
ellipsoid(
head,
paleFurMaterial,
[0.46, -0.11, 0],
[0.34, 0.22, 0.29],
smallSphere
);
ellipsoid(
head,
darkMaterial,
[0.76, -0.06, 0],
[0.105, 0.075, 0.11],
smallSphere
);
// Ears remain compact and natural, without decorative treatment.
[-1, 1].forEach((side) => {
const ear = new THREE.Mesh(
new THREE.ConeGeometry(0.16, 0.29, 4),
furMaterial
);
ear.position.set(-0.15, 0.43, side * 0.29);
ear.rotation.z = -0.12;
ear.castShadow = true;
head.add(ear);
const earBack = new THREE.Mesh(
new THREE.ConeGeometry(0.095, 0.18, 4),
darkMaterial
);
earBack.position.set(-0.11, 0.46, side * 0.345);
earBack.rotation.z = -0.12;
head.add(earBack);
});
// Eyes are positioned laterally and remain small.
[-1, 1].forEach((side) => {
const eye = ellipsoid(
head,
darkMaterial,
[0.25, 0.11, side * 0.385],
[0.045, 0.045, 0.028],
smallSphere
);
eye.rotation.y = side > 0 ? 0 : Math.PI;
});
// Black rosettes are flattened geometric patches on both flanks.
for (let side = -1; side <= 1; side += 2) {
for (let i = 0; i < 11; i++) {
const x = lerp(-1.08, 1.04, random());
const y = 0.78 + random() * 0.36;
const normalizedX = x / 1.35;
const normalizedY = (y - 0.98) / 0.52;
const surface = Math.sqrt(
Math.max(0.08, 1 - normalizedX * normalizedX - normalizedY * normalizedY)
);
const patch = new THREE.Mesh(
new THREE.CircleGeometry(0.07 + random() * 0.055, 7),
spotMaterial
);
patch.position.set(x, y, side * 0.615 * surface);
patch.rotation.y = side > 0 ? 0 : Math.PI;
jaguarModel.add(patch);
}
for (let i = 0; i < 4; i++) {
const patch = new THREE.Mesh(
new THREE.CircleGeometry(0.055 + random() * 0.035, 7),
spotMaterial
);
patch.position.set(
-0.28 + random() * 0.65,
-0.19 + random() * 0.35,
side * 0.44
);
patch.rotation.y = side > 0 ? 0 : Math.PI;
head.add(patch);
}
}
// Four simple walking limbs; the animation is a generic transit gait.
const legs = [];
const legDefinitions = [
{ x: 0.83, z: 0.43, phase: 0 },
{ x: 0.83, z: -0.43, phase: Math.PI },
{ x: -0.83, z: 0.43, phase: Math.PI },
{ x: -0.83, z: -0.43, phase: 0 }
];
legDefinitions.forEach((definition, index) => {
const pivot = new THREE.Group();
pivot.position.set(definition.x, 0.88, definition.z);
jaguarModel.add(pivot);
const upper = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.17, 0.42, 5),
furMaterial
);
upper.position.y = -0.21;
upper.castShadow = true;
pivot.add(upper);
const lower = new THREE.Group();
lower.position.y = -0.39;
pivot.add(lower);
const lowerMesh = new THREE.Mesh(
new THREE.CylinderGeometry(0.095, 0.12, 0.36, 5),
furMaterial
);
lowerMesh.position.y = -0.18;
lowerMesh.castShadow = true;
lower.add(lowerMesh);
const paw = ellipsoid(
lower,
darkMaterial,
[0.065, -0.37, 0],
[0.18, 0.11, 0.16],
smallSphere
);
paw.castShadow = true;
// Small flank markings on the upper legs.
const side = Math.sign(definition.z);
const legPatch = new THREE.Mesh(
new THREE.CircleGeometry(0.043, 6),
spotMaterial
);
legPatch.position.set(0, -0.23, side * 0.151);
legPatch.rotation.y = side > 0 ? 0 : Math.PI;
pivot.add(legPatch);
legs.push({
pivot,
lower,
phase: definition.phase,
index
});
});
// A tapered, segmented tail with subtle geometric markings.
const tailRoot = new THREE.Group();
tailRoot.position.set(-1.28, 1.0, 0);
jaguarModel.add(tailRoot);
const tailJoints = [];
let tailParent = tailRoot;
for (let i = 0; i < 5; i++) {
const joint = new THREE.Group();
if (i > 0) joint.position.x = -0.34;
tailParent.add(joint);
const length = 0.34;
const topRadius = 0.115 - i * 0.016;
const bottomRadius = 0.097 - i * 0.016;
const segment = new THREE.Mesh(
new THREE.CylinderGeometry(topRadius, bottomRadius, length, 5),
furMaterial
);
segment.rotation.z = Math.PI / 2;
segment.position.x = -length / 2;
segment.castShadow = true;
joint.add(segment);
const band = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius * 1.025,
topRadius * 1.025,
0.045,
5
),
spotMaterial
);
band.rotation.z = Math.PI / 2;
band.position.x = -length * 0.67;
joint.add(band);
tailJoints.push(joint);
tailParent = joint;
}
// ------------------------------------------------------------
// Camera controls implemented directly, without an addon.
// ------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0, 0.3, 0),
desiredTarget: new THREE.Vector3(0, 0.3, 0),
distance: 31,
desiredDistance: 31,
azimuth: 0.72,
polar: 1.03
};
let cameraMode = "overview";
function setOverview() {
cameraMode = "overview";
cameraState.desiredTarget.set(0, 0.3, 0);
cameraState.desiredDistance = 31;
cameraState.polar = 1.03;
cameraState.azimuth = 0.72;
followButton.textContent = "Follow jaguar";
followButton.classList.remove("active");
followButton.setAttribute("aria-pressed", "false");
}
function toggleFollow() {
if (cameraMode === "follow") {
setOverview();
return;
}
cameraMode = "follow";
cameraState.desiredDistance = 10.5;
cameraState.polar = 1.02;
const tangent = routeCurve.getTangentAt(routeTime);
cameraState.azimuth = Math.atan2(-tangent.z, -tangent.x);
followButton.textContent = "Overview";
followButton.classList.add("active");
followButton.setAttribute("aria-pressed", "true");
}
const pointers = new Map();
let previousPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
previousPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const current = { x: event.clientX, y: event.clientY };
pointers.set(event.pointerId, current);
if (pointers.size === 1) {
const dx = current.x - previous.x;
const dy = current.y - previous.y;
cameraState.azimuth -= dx * 0.005;
cameraState.polar = clamp(
cameraState.polar + dy * 0.004,
0.35,
1.43
);
} else if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const pinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
if (previousPinchDistance > 0) {
cameraState.desiredDistance = clamp(
cameraState.desiredDistance *
previousPinchDistance / pinchDistance,
5.5,
46
);
}
previousPinchDistance = pinchDistance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.desiredDistance = clamp(
cameraState.desiredDistance * Math.exp(event.deltaY * 0.001),
5.5,
46
);
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
let motionPlaying = !matchMedia("(prefers-reduced-motion: reduce)").matches;
function updatePauseButton() {
pauseButton.textContent = motionPlaying ? "Pause motion" : "Resume motion";
pauseButton.setAttribute("aria-pressed", String(!motionPlaying));
pauseButton.classList.toggle("active", !motionPlaying);
}
updatePauseButton();
pauseButton.addEventListener("click", () => {
motionPlaying = !motionPlaying;
updatePauseButton();
});
followButton.addEventListener("click", toggleFollow);
resetButton.addEventListener("click", setOverview);
addEventListener("keydown", (event) => {
if (event.target instanceof HTMLButtonElement ||
event.target instanceof HTMLAnchorElement) return;
if (event.code === "Space") {
event.preventDefault();
motionPlaying = !motionPlaying;
updatePauseButton();
} else if (event.key.toLowerCase() === "f") {
toggleFollow();
} else if (event.key.toLowerCase() === "r") {
setOverview();
}
});
let routeTime = 0.075;
const routeLength = routeCurve.getLength();
const clock = new THREE.Clock();
function updateCamera(delta) {
if (cameraMode === "follow") {
cameraState.desiredTarget.copy(jaguarRoot.position);
cameraState.desiredTarget.y += 0.72;
} else {
cameraState.desiredTarget.set(0, 0.3, 0);
}
const smoothing = 1 - Math.exp(-delta * 3.5);
cameraState.target.lerp(cameraState.desiredTarget, smoothing);
cameraState.distance = lerp(
cameraState.distance,
cameraState.desiredDistance,
smoothing
);
const horizontal = Math.sin(cameraState.polar) * cameraState.distance;
camera.position.set(
cameraState.target.x +
horizontal * Math.cos(cameraState.azimuth),
cameraState.target.y +
Math.cos(cameraState.polar) * cameraState.distance,
cameraState.target.z +
horizontal * Math.sin(cameraState.azimuth)
);
camera.lookAt(cameraState.target);
}
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (motionPlaying) {
routeTime = (routeTime + delta * 0.009) % 1;
}
const point = routeCurve.getPointAt(routeTime);
const tangent = routeCurve.getTangentAt(routeTime);
jaguarRoot.position.set(
point.x,
terrainHeight(point.x, point.z) + 0.015,
point.z
);
// Local +X points forward along the route.
jaguarRoot.rotation.y = Math.atan2(-tangent.z, tangent.x);
const gaitPhase = routeTime * routeLength * 2.15;
legs.forEach((leg) => {
const swing = Math.sin(gaitPhase + leg.phase);
leg.pivot.rotation.z = swing * 0.27;
leg.lower.rotation.z = Math.max(0, -swing) * 0.31;
});
jaguarModel.position.y =
Math.abs(Math.sin(gaitPhase)) * 0.026;
tailJoints.forEach((joint, index) => {
joint.rotation.y =
Math.sin(routeTime * Math.PI * 8 + index * 0.55) * 0.035;
joint.rotation.z =
Math.sin(routeTime * Math.PI * 8 + index * 0.4) * 0.018;
});
const progress = Math.round(routeTime * 100);
routeFill.style.width = `${progress}%`;
routePosition.textContent = `${progress}% along route`;
updateCamera(delta);
renderer.render(scene, camera);
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.75));
}
addEventListener("resize", resize);
resize();
animate();
requestAnimationFrame(() => {
document.body.classList.add("ready");
});
</script>
</body>
</html>
```