Prompt specification
Build or customize the Three.js 3D scene "Silver ore and coin beside a route diagram" 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: Silver ore and coin beside a route diagram
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/silver-ore-and-coin-beside-a-route-diagram-x2613
Scene Description Prompt:
A stylized Potosí silver exhibit separates ore, refined metal, and coin beside a trade-route diagram. Three.js from cdnjs, one HTML file.
Working Three.js Starter (silver-ore-and-coin-beside-a-route-diagram-x2613):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Potosí — Silver in Motion</title>
<style>
:root {
--ink: #111511;
--paper: #eee8d8;
--muted: #a8aa9d;
--gold: #d2ad68;
--line: rgba(238, 232, 216, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--paper);
font-family: Inter, Helvetica, Arial, sans-serif;
}
button,
canvas {
-webkit-tap-highlight-color: transparent;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(90deg, rgba(10, 14, 10, 0.56), transparent 38%),
radial-gradient(circle at 56% 46%, transparent 35%, rgba(6, 9, 6, 0.36) 100%);
z-index: 2;
}
.header {
position: fixed;
z-index: 5;
top: clamp(24px, 5vh, 58px);
left: clamp(24px, 5vw, 72px);
width: min(460px, calc(100vw - 48px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 17px;
color: var(--gold);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.24em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 38px;
height: 1px;
background: var(--gold);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(56px, 8vw, 112px);
font-weight: 400;
line-height: 0.83;
letter-spacing: -0.06em;
text-shadow: 0 8px 35px rgba(0, 0, 0, 0.35);
}
.subtitle {
max-width: 360px;
margin: 24px 0 0 3px;
color: rgba(238, 232, 216, 0.76);
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(17px, 2vw, 23px);
font-style: italic;
line-height: 1.35;
}
.edition {
position: fixed;
z-index: 5;
top: clamp(24px, 5vh, 58px);
right: clamp(24px, 4vw, 60px);
color: rgba(238, 232, 216, 0.48);
font-size: 9px;
letter-spacing: 0.22em;
line-height: 1.8;
text-align: right;
text-transform: uppercase;
pointer-events: none;
}
.nav {
position: fixed;
z-index: 6;
left: 50%;
bottom: 26px;
display: flex;
gap: 4px;
max-width: calc(100vw - 28px);
padding: 6px;
overflow-x: auto;
border: 1px solid rgba(238, 232, 216, 0.16);
border-radius: 999px;
background: rgba(17, 21, 17, 0.74);
box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(14px);
transform: translateX(-50%);
scrollbar-width: none;
}
.nav::-webkit-scrollbar {
display: none;
}
.nav button {
flex: 0 0 auto;
padding: 11px 17px;
border: 0;
border-radius: 999px;
background: transparent;
color: rgba(238, 232, 216, 0.58);
font: inherit;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
cursor: pointer;
transition:
color 180ms ease,
background 180ms ease;
}
.nav button:hover,
.nav button.active {
background: rgba(210, 173, 104, 0.14);
color: var(--paper);
}
.nav button.active {
box-shadow: inset 0 0 0 1px rgba(210, 173, 104, 0.25);
}
.hint {
position: fixed;
z-index: 5;
right: 26px;
bottom: 31px;
color: rgba(238, 232, 216, 0.38);
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
pointer-events: none;
}
.hover-label {
position: fixed;
z-index: 8;
display: none;
padding: 9px 12px;
border: 1px solid rgba(210, 173, 104, 0.38);
border-radius: 4px;
background: rgba(15, 18, 14, 0.9);
color: var(--paper);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
pointer-events: none;
transform: translate(14px, 14px);
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: #111511;
color: var(--gold);
font-size: 10px;
letter-spacing: 0.28em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 850px) {
.edition,
.hint {
display: none;
}
.header {
top: 22px;
left: 22px;
}
.subtitle {
max-width: 250px;
margin-top: 15px;
font-size: 16px;
}
.nav {
bottom: 14px;
}
.nav button {
padding: 10px 13px;
font-size: 9px;
}
}
@media (max-width: 520px) {
.eyebrow {
margin-bottom: 12px;
}
h1 {
font-size: 56px;
}
.subtitle {
font-size: 14px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="vignette"></div>
<header class="header">
<div class="eyebrow">Silver routes · 1545–1800</div>
<h1>Potosí</h1>
<p class="subtitle">A mountain of ore became a currency that moved across an empire.</p>
</header>
<div class="edition">
Museum of the Andes<br />
Collection 07 / American Silver
</div>
<nav class="nav" aria-label="Exhibit views">
<button class="active" data-view="overview">Overview</button>
<button data-view="ore">01 · Ore</button>
<button data-view="silver">02 · Refined metal</button>
<button data-view="coin">03 · Coin</button>
<button data-view="routes">Trade routes</button>
</nav>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<div id="hoverLabel" class="hover-label"></div>
<div id="loading" class="loading">Preparing the exhibit</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneRoot = document.getElementById("scene");
const loading = document.getElementById("loading");
const hoverLabel = document.getElementById("hoverLabel");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x171b16);
scene.fog = new THREE.FogExp2(0x171b16, 0.028);
const camera = new THREE.PerspectiveCamera(
39,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneRoot.appendChild(renderer.domElement);
// Seeded randomness keeps the exhibit consistent between reloads.
let seed = 8137;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
function createEnvironment() {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 512;
const ctx = canvas.getContext("2d");
const gradient = ctx.createLinearGradient(0, 0, 1024, 0);
gradient.addColorStop(0, "#111510");
gradient.addColorStop(0.18, "#485044");
gradient.addColorStop(0.38, "#d7c49b");
gradient.addColorStop(0.55, "#6e766c");
gradient.addColorStop(0.76, "#b7b7a7");
gradient.addColorStop(1, "#181c17");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1024, 512);
const glow = ctx.createRadialGradient(270, 170, 10, 270, 170, 260);
glow.addColorStop(0, "rgba(255,246,218,.95)");
glow.addColorStop(0.25, "rgba(255,239,197,.42)");
glow.addColorStop(1, "rgba(255,255,255,0)");
ctx.fillStyle = glow;
ctx.fillRect(0, 0, 1024, 512);
const texture = new THREE.CanvasTexture(canvas);
texture.mapping = THREE.EquirectangularReflectionMapping;
texture.colorSpace = THREE.SRGBColorSpace;
const pmrem = new THREE.PMREMGenerator(renderer);
const environment = pmrem.fromEquirectangular(texture);
scene.environment = environment.texture;
texture.dispose();
pmrem.dispose();
}
createEnvironment();
const ambient = new THREE.HemisphereLight(0xd9dfcc, 0x30271d, 1.45);
scene.add(ambient);
const key = new THREE.DirectionalLight(0xffedcb, 3.2);
key.position.set(-4, 8, 6);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -10;
key.shadow.camera.right = 10;
key.shadow.camera.top = 9;
key.shadow.camera.bottom = -5;
key.shadow.bias = -0.0002;
scene.add(key);
const rim = new THREE.DirectionalLight(0xb8d5dc, 2.1);
rim.position.set(7, 5, -3);
scene.add(rim);
const warmSpot = new THREE.SpotLight(0xffd69a, 42, 18, 0.55, 0.7, 1.2);
warmSpot.position.set(-3.5, 7, 5);
warmSpot.target.position.set(-1.5, 1, 0);
warmSpot.castShadow = true;
warmSpot.shadow.mapSize.set(1024, 1024);
scene.add(warmSpot, warmSpot.target);
const coolSpot = new THREE.SpotLight(0xe5edff, 34, 17, 0.6, 0.75, 1.4);
coolSpot.position.set(6, 6, 4);
coolSpot.target.position.set(3, 1.5, 0);
scene.add(coolSpot, coolSpot.target);
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0x77766b,
roughness: 0.86,
metalness: 0.02
}),
wall: new THREE.MeshStandardMaterial({
color: 0x292d27,
roughness: 0.94
}),
stone: new THREE.MeshStandardMaterial({
color: 0xc4bca7,
roughness: 0.76,
metalness: 0.02
}),
stoneEdge: new THREE.MeshStandardMaterial({
color: 0x817b6d,
roughness: 0.8
}),
dark: new THREE.MeshStandardMaterial({
color: 0x1d211d,
roughness: 0.55,
metalness: 0.25
}),
brass: new THREE.MeshStandardMaterial({
color: 0xa27d3c,
roughness: 0.34,
metalness: 0.82
}),
silver: new THREE.MeshStandardMaterial({
color: 0xdce1df,
roughness: 0.22,
metalness: 0.93
}),
silverDark: new THREE.MeshStandardMaterial({
color: 0x9ca6a6,
roughness: 0.3,
metalness: 0.88
}),
silverEdge: new THREE.MeshStandardMaterial({
color: 0x697171,
roughness: 0.42,
metalness: 0.82
}),
gold: new THREE.MeshStandardMaterial({
color: 0xd2ad68,
roughness: 0.3,
metalness: 0.76,
emissive: 0x3a2105,
emissiveIntensity: 0.25
})
};
function roundedShape(width, height, radius) {
const x = -width / 2;
const y = -height / 2;
const shape = new THREE.Shape();
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + height - radius);
shape.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
shape.lineTo(x + radius, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
return shape;
}
function roundedSlab(width, height, depth, radius, material) {
const geometry = new THREE.ExtrudeGeometry(roundedShape(width, height, radius), {
depth,
bevelEnabled: true,
bevelSegments: 3,
steps: 1,
bevelSize: 0.025,
bevelThickness: 0.025,
curveSegments: 8
});
geometry.translate(0, 0, -depth / 2);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function createLabelTexture(number, title, subtitle) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#252923";
ctx.fillRect(0, 0, 768, 256);
ctx.strokeStyle = "#b89656";
ctx.lineWidth = 4;
ctx.strokeRect(8, 8, 752, 240);
ctx.fillStyle = "#d2ad68";
ctx.font = "700 30px Arial";
ctx.fillText(number, 35, 57);
ctx.fillStyle = "#eee8d8";
ctx.font = "42px Georgia";
ctx.fillText(title, 35, 122);
ctx.fillStyle = "#9fa397";
ctx.font = "22px Arial";
ctx.fillText(subtitle, 35, 177);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function addPlaque(number, title, subtitle, x, z) {
const texture = createLabelTexture(number, title, subtitle);
const material = new THREE.MeshBasicMaterial({ map: texture });
const plaque = new THREE.Mesh(new THREE.PlaneGeometry(1.62, 0.54), material);
plaque.position.set(x, 0.83, z);
scene.add(plaque);
}
// Gallery architecture.
const floor = new THREE.Mesh(new THREE.PlaneGeometry(30, 30), materials.floor);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const wall = new THREE.Mesh(new THREE.PlaneGeometry(30, 11), materials.wall);
wall.position.set(0, 5, -4.2);
wall.receiveShadow = true;
scene.add(wall);
for (let i = -4; i <= 4; i++) {
const seam = new THREE.Mesh(
new THREE.BoxGeometry(0.012, 8, 0.015),
new THREE.MeshBasicMaterial({ color: 0x151914 })
);
seam.position.set(i * 1.35, 4, -4.17);
scene.add(seam);
}
const platform = roundedSlab(8.65, 0.16, 2.7, 0.07, materials.stoneEdge);
platform.position.set(0.15, 0.09, 0.55);
scene.add(platform);
const stationX = [-2.65, 0, 2.65];
stationX.forEach((x) => {
const plinth = roundedSlab(1.86, 1.35, 1.36, 0.08, materials.stone);
plinth.position.set(x, 0.835, 0.55);
scene.add(plinth);
const top = roundedSlab(1.9, 0.07, 1.4, 0.06, materials.stoneEdge);
top.position.set(x, 1.52, 0.55);
scene.add(top);
});
addPlaque("01", "MENA", "Silver-bearing ore", stationX[0], 1.235);
addPlaque("02", "PLATA REFINADA", "Refined metal", stationX[1], 1.235);
addPlaque("03", "MONEDA", "Eight reales · 1783", stationX[2], 1.235);
const interactiveMeshes = [];
function markInteractive(group, view) {
group.traverse((child) => {
if (child.isMesh) {
child.userData.view = view;
interactiveMeshes.push(child);
}
});
}
// Ore cluster.
const oreGroup = new THREE.Group();
oreGroup.position.set(stationX[0], 1.58, 0.55);
function createRock(size, material) {
const geometry = new THREE.IcosahedronGeometry(size, 1);
const positions = geometry.attributes.position;
const colors = [];
const color = new THREE.Color();
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const y = positions.getY(i);
const z = positions.getZ(i);
const scale = 0.82 + random() * 0.31;
positions.setXYZ(i, x * scale, y * scale, z * scale);
const shade = 0.34 + random() * 0.24;
color.setHSL(0.095, 0.12, shade);
colors.push(color.r, color.g, color.b);
}
geometry.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
geometry.computeVertexNormals();
const rock = new THREE.Mesh(
geometry,
new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.92,
metalness: 0.08,
flatShading: true
})
);
rock.castShadow = true;
rock.receiveShadow = true;
return rock;
}
const rockData = [
[-0.42, 0.32, 0.03, 0.55],
[0.25, 0.27, -0.16, 0.49],
[0.08, 0.73, -0.02, 0.43],
[0.51, 0.58, 0.14, 0.31]
];
rockData.forEach(([x, y, z, size]) => {
const rock = createRock(size);
rock.position.set(x, y, z);
rock.rotation.set(random() * 2, random() * 2, random() * 2);
oreGroup.add(rock);
});
const fleckGeometry = new THREE.TetrahedronGeometry(0.045);
const fleckMaterial = new THREE.MeshStandardMaterial({
color: 0xe2e8e7,
roughness: 0.25,
metalness: 0.9
});
for (let i = 0; i < 25; i++) {
const fleck = new THREE.Mesh(fleckGeometry, fleckMaterial);
const angle = random() * Math.PI * 2;
const radius = random() * 0.62;
fleck.position.set(
Math.cos(angle) * radius,
0.22 + random() * 0.7,
Math.sin(angle) * radius * 0.55
);
fleck.rotation.set(random() * 3, random() * 3, random() * 3);
fleck.scale.setScalar(0.45 + random() * 0.75);
fleck.castShadow = true;
oreGroup.add(fleck);
}
scene.add(oreGroup);
markInteractive(oreGroup, "ore");
// Refined silver bars.
const silverGroup = new THREE.Group();
silverGroup.position.set(stationX[1], 1.58, 0.55);
function ingotGeometry(width, height, depth) {
const shape = new THREE.Shape();
shape.moveTo(-width / 2, -height / 2);
shape.lineTo(width / 2, -height / 2);
shape.lineTo(width * 0.39, height / 2);
shape.lineTo(-width * 0.39, height / 2);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.045,
bevelThickness: 0.045,
steps: 1
});
geometry.translate(0, 0, -depth / 2);
return geometry;
}
const ingotPositions = [
[-0.4, 0.24, 0.05, -0.06],
[0.4, 0.24, -0.04, 0.06],
[0, 0.64, 0.01, -0.025]
];
ingotPositions.forEach(([x, y, z, rotation], index) => {
const ingot = new THREE.Mesh(
ingotGeometry(1.03, 0.53, 0.82),
index === 1 ? materials.silverDark : materials.silver
);
ingot.position.set(x, y, z);
ingot.rotation.y = rotation;
ingot.castShadow = true;
ingot.receiveShadow = true;
silverGroup.add(ingot);
});
scene.add(silverGroup);
markInteractive(silverGroup, "silver");
// Eight reales coin.
function createCoinTexture() {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 768;
const ctx = canvas.getContext("2d");
const radial = ctx.createRadialGradient(330, 280, 30, 384, 384, 380);
radial.addColorStop(0, "#f4f1e8");
radial.addColorStop(0.55, "#c7c9c3");
radial.addColorStop(1, "#747d7c");
ctx.fillStyle = radial;
ctx.fillRect(0, 0, 768, 768);
ctx.strokeStyle = "#737976";
ctx.lineWidth = 8;
ctx.beginPath();
ctx.arc(384, 384, 342, 0, Math.PI * 2);
ctx.stroke();
ctx.strokeStyle = "#e4e3db";
ctx.lineWidth = 3;
for (let i = 0; i < 120; i++) {
const a = (i / 120) * Math.PI * 2;
const x1 = 384 + Math.cos(a) * 319;
const y1 = 384 + Math.sin(a) * 319;
const x2 = 384 + Math.cos(a) * (i % 2 ? 330 : 335);
const y2 = 384 + Math.sin(a) * (i % 2 ? 330 : 335);
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
}
ctx.fillStyle = "#69706d";
ctx.textAlign = "center";
ctx.font = "700 47px Georgia";
ctx.fillText("POTOSÍ", 384, 142);
ctx.font = "28px Georgia";
ctx.fillText("VIII REALES", 384, 181);
// Crown.
ctx.fillStyle = "#626a67";
ctx.beginPath();
ctx.moveTo(290, 280);
ctx.lineTo(305, 225);
ctx.lineTo(340, 257);
ctx.lineTo(382, 210);
ctx.lineTo(426, 257);
ctx.lineTo(462, 225);
ctx.lineTo(478, 280);
ctx.closePath();
ctx.fill();
// Crossed colonial flags.
ctx.lineWidth = 13;
ctx.strokeStyle = "#676e6a";
ctx.beginPath();
ctx.moveTo(300, 320);
ctx.lineTo(468, 495);
ctx.moveTo(468, 320);
ctx.lineTo(300, 495);
ctx.stroke();
// Two simplified heraldic lions.
ctx.fillStyle = "#666d69";
ctx.beginPath();
ctx.ellipse(330, 395, 46, 24, -0.25, 0, Math.PI * 2);
ctx.ellipse(438, 395, 46, 24, 0.25, 0, Math.PI * 2);
ctx.fill();
// Central silver pots.
for (const x of [345, 423]) {
ctx.beginPath();
ctx.moveTo(x - 28, 440);
ctx.lineTo(x + 28, 440);
ctx.lineTo(x + 19, 486);
ctx.lineTo(x - 19, 486);
ctx.closePath();
ctx.fill();
ctx.fillRect(x - 33, 435, 66, 9);
}
ctx.fillStyle = "#626965";
ctx.font = "700 31px Georgia";
ctx.fillText("· 1783 ·", 384, 564);
ctx.font = "21px Georgia";
ctx.fillText("POTOSÍ · BOLIVIA", 384, 610);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const coinGroup = new THREE.Group();
coinGroup.position.set(stationX[2], 2.34, 0.64);
coinGroup.rotation.y = -0.1;
const coinBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.72, 0.72, 0.15, 96),
[
materials.silverEdge,
materials.silverDark,
materials.silverDark
]
);
coinBody.rotation.x = Math.PI / 2;
coinBody.castShadow = true;
coinGroup.add(coinBody);
const coinFace = new THREE.Mesh(
new THREE.CircleGeometry(0.665, 96),
new THREE.MeshStandardMaterial({
map: createCoinTexture(),
color: 0xffffff,
roughness: 0.3,
metalness: 0.75
})
);
coinFace.position.z = 0.079;
coinFace.castShadow = true;
coinGroup.add(coinFace);
const coinRim = new THREE.Mesh(
new THREE.TorusGeometry(0.635, 0.026, 12, 96),
materials.silver
);
coinRim.position.z = 0.086;
coinGroup.add(coinRim);
const standStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.045, 0.83, 16),
materials.brass
);
standStem.position.set(0, -0.94, -0.1);
standStem.castShadow = true;
coinGroup.add(standStem);
const standBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.38, 0.45, 0.08, 48),
materials.dark
);
standBase.position.set(0, -1.35, -0.1);
standBase.castShadow = true;
coinGroup.add(standBase);
scene.add(coinGroup);
markInteractive(coinGroup, "coin");
// Stylized trade-route map.
function createMapTexture() {
const canvas = document.createElement("canvas");
canvas.width = 900;
canvas.height = 1150;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#1d2825";
ctx.fillRect(0, 0, 900, 1150);
const vignette = ctx.createRadialGradient(450, 530, 100, 450, 530, 650);
vignette.addColorStop(0, "#30403a");
vignette.addColorStop(1, "#17211f");
ctx.fillStyle = vignette;
ctx.fillRect(0, 0, 900, 1150);
ctx.strokeStyle = "rgba(206,190,147,.09)";
ctx.lineWidth = 1;
for (let x = 50; x < 900; x += 55) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, 1150);
ctx.stroke();
}
for (let y = 55; y < 1150; y += 55) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(900, y);
ctx.stroke();
}
ctx.textAlign = "center";
ctx.fillStyle = "#e7dec5";
ctx.font = "42px Georgia";
ctx.fillText("RUTAS DE LA PLATA", 450, 88);
ctx.fillStyle = "#c7a45f";
ctx.font = "18px Arial";
ctx.fillText("UNA MONEDA, UN CONTINENTE", 450, 127);
ctx.strokeStyle = "rgba(210,173,104,.45)";
ctx.beginPath();
ctx.moveTo(190, 158);
ctx.lineTo(710, 158);
ctx.stroke();
// Simplified South America.
ctx.beginPath();
ctx.moveTo(254, 265);
ctx.bezierCurveTo(300, 220, 407, 246, 446, 321);
ctx.bezierCurveTo(474, 382, 438, 438, 493, 503);
ctx.bezierCurveTo(538, 555, 553, 637, 514, 698);
ctx.bezierCurveTo(478, 752, 536, 783, 530, 850);
ctx.bezierCurveTo(522, 910, 477, 967, 426, 969);
ctx.bezierCurveTo(380, 970, 354, 918, 378, 862);
ctx.bezierCurveTo(401, 806, 350, 761, 335, 706);
ctx.bezierCurveTo(316, 642, 267, 610, 286, 548);
ctx.bezierCurveTo(303, 493, 250, 434, 273, 382);
ctx.bezierCurveTo(294, 334, 215, 310, 254, 265);
ctx.closePath();
ctx.fillStyle = "rgba(177,184,149,.13)";
ctx.fill();
ctx.strokeStyle = "rgba(207,198,163,.42)";
ctx.lineWidth = 2;
ctx.stroke();
// Topographic contour lines.
ctx.strokeStyle = "rgba(190,196,167,.16)";
ctx.lineWidth = 1.5;
for (let i = 0; i < 9; i++) {
ctx.beginPath();
ctx.ellipse(
385 + Math.sin(i * 0.7) * 15,
535 + i * 18,
120 - i * 7,
65 - i * 3,
-0.1,
0,
Math.PI * 2
);
ctx.stroke();
}
const nodes = {
potosi: [449, 600],
callao: [286, 428],
lima: [303, 440],
oruro: [411, 502],
asuncion: [492, 772],
santiago: [407, 818],
buenosAires: [473, 910],
montevideo: [521, 920]
};
function route(points, dashed = false) {
ctx.save();
ctx.strokeStyle = "#d2ad68";
ctx.lineWidth = 4;
ctx.setLineDash(dashed ? [12, 10] : []);
ctx.shadowColor = "rgba(210,173,104,.55)";
ctx.shadowBlur = 10;
ctx.beginPath();
points.forEach(([x, y], index) => {
if (index === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.stroke();
ctx.restore();
}
route([nodes.potosi, nodes.orrero || nodes.oruro]);
route([nodes.oruro, nodes.lima, nodes.callao]);
route([nodes.potosi, nodes.asuncion]);
route([nodes.potosi, nodes.santiago]);
route([nodes.potosi, nodes.buenosAires, nodes.montevideo]);
route([nodes.buenosAires, [720, 785], [795, 530], [785, 245]], true);
function node(x, y, label, major = false) {
ctx.beginPath();
ctx.arc(x, y, major ? 9 : 6, 0, Math.PI * 2);
ctx.fillStyle = major ? "#f2dfae" : "#d2ad68";
ctx.fill();
ctx.strokeStyle = major ? "#d2ad68" : "#806e45";
ctx.lineWidth = 3;
ctx.stroke();
ctx.textAlign = "left";
ctx.fillStyle = "#e5deca";
ctx.font = major ? "700 24px Arial" : "18px Arial";
ctx.fillText(label, x + 14, y + 6);
}
node(...nodes.potosi, "POTOSÍ", true);
node(...nodes.orrero || nodes.oruro, "ORURO");
node(...nodes.lima, "LIMA");
node(...nodes.callao, "CALLAO · PACIFIC PORT");
node(...nodes.asuncion, "ASUNCIÓN");
node(...nodes.santiago, "SANTIAGO");
node(...nodes.buenosAires, "BUENOS AIRES", true);
node(...nodes.montevideo, "MONTEVIDEO");
ctx.save();
ctx.translate(765, 215);
ctx.textAlign = "center";
ctx.fillStyle = "#d9d0b7";
ctx.font = "italic 20px Georgia";
ctx.fillText("CÁDIZ", 0, 0);
ctx.font = "14px Arial";
ctx.fillStyle = "#9fa89e";
ctx.fillText("ATLANTIC", 0, 29);
ctx.restore();
ctx.fillStyle = "rgba(231,222,197,.5)";
ctx.font = "italic 19px Georgia";
ctx.textAlign = "left";
ctx.fillText("PACIFIC OCEAN", 80, 610);
ctx.fillText("ATLANTIC OCEAN", 625, 655);
ctx.strokeStyle = "rgba(210,173,104,.45)";
ctx.beginPath();
ctx.moveTo(92, 1005);
ctx.lineTo(808, 1005);
ctx.stroke();
ctx.textAlign = "left";
ctx.fillStyle = "#d2ad68";
ctx.font = "700 16px Arial";
ctx.fillText("MERCANTIL · SIGLOS XVI–XVIII", 92, 1044);
ctx.fillStyle = "#9fa89e";
ctx.font = "16px Arial";
ctx.fillText("Mine → refinery → mint → port → empire", 92, 1080);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const mapGroup = new THREE.Group();
mapGroup.position.set(5.28, 2.45, -1.62);
mapGroup.rotation.y = -0.16;
const frame = new THREE.Mesh(
new THREE.BoxGeometry(3.36, 4.48, 0.22),
materials.brass
);
frame.castShadow = true;
frame.receiveShadow = true;
mapGroup.add(frame);
const mapPlane = new THREE.Mesh(
new THREE.PlaneGeometry(3.08, 4.15),
new THREE.MeshStandardMaterial({
map: createMapTexture(),
roughness: 0.86,
metalness: 0.02
})
);
mapPlane.position.z = 0.116;
mapPlane.receiveShadow = true;
mapGroup.add(mapPlane);
const routePin = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 20, 20),
new THREE.MeshStandardMaterial({
color: 0xf1d48f,
emissive: 0xd39b3d,
emissiveIntensity: 1.4,
roughness: 0.25,
metalness: 0.65
})
);
routePin.position.set(-0.006, -0.16, 0.14);
mapGroup.add(routePin);
const pinRing = new THREE.Mesh(
new THREE.TorusGeometry(0.09, 0.009, 8, 40),
new THREE.MeshBasicMaterial({
color: 0xd2ad68,
transparent: true,
opacity: 0.8
})
);
pinRing.position.copy(routePin.position);
mapGroup.add(pinRing);
scene.add(mapGroup);
markInteractive(mapGroup, "routes");
// A small wall inscription.
const wallLabelCanvas = document.createElement("canvas");
wallLabelCanvas.width = 1024;
wallLabelCanvas.height = 180;
const wallLabelContext = wallLabelCanvas.getContext("2d");
wallLabelContext.clearRect(0, 0, 1024, 180);
wallLabelContext.textAlign = "center";
wallLabelContext.fillStyle = "rgba(224,214,190,.34)";
wallLabelContext.font = "30px Georgia";
wallLabelContext.fillText("CASA DE LA MONEDA / POTOSÍ", 512, 74);
wallLabelContext.fillStyle = "rgba(210,173,104,.38)";
wallLabelContext.font = "15px Arial";
wallLabelContext.fillText("THE MOUNTAIN, THE MINT AND THE MARKET", 512, 117);
const wallLabelTexture = new THREE.CanvasTexture(wallLabelCanvas);
wallLabelTexture.colorSpace = THREE.SRGBColorSpace;
const wallLabel = new THREE.Mesh(
new THREE.PlaneGeometry(5.2, 0.91),
new THREE.MeshBasicMaterial({
map: wallLabelTexture,
transparent: true,
depthWrite: false
})
);
wallLabel.position.set(0.3, 4.42, -4.16);
scene.add(wallLabel);
// Suspended dust gives the gallery a warm, atmospheric depth.
const dustGeometry = new THREE.BufferGeometry();
const dustPositions = [];
for (let i = 0; i < 220; i++) {
dustPositions.push(
(random() - 0.5) * 13,
random() * 6.5 + 0.3,
(random() - 0.5) * 7 + 0.5
);
}
dustGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xe6d6ad,
size: 0.018,
transparent: true,
opacity: 0.32,
depthWrite: false
})
);
scene.add(dust);
// Custom camera controls: no external controls module is used.
const controls = {
target: new THREE.Vector3(0.8, 1.5, 0.15),
goalTarget: new THREE.Vector3(0.8, 1.5, 0.15),
radius: 14.4,
goalRadius: 14.4,
theta: 0.035,
goalTheta: 0.035,
phi: 1.35,
goalPhi: 1.35
};
const views = {
overview: {
target: new THREE.Vector3(0.8, 1.5, 0.15),
radius: 14.4,
theta: 0.035,
phi: 1.35
},
ore: {
target: new THREE.Vector3(-2.65, 1.85, 0.55),
radius: 5.1,
theta: 0.08,
phi: 1.34
},
silver: {
target: new THREE.Vector3(0, 1.85, 0.55),
radius: 5.0,
theta: 0.02,
phi: 1.35
},
coin: {
target: new THREE.Vector3(2.65, 2.25, 0.6),
radius: 4.5,
theta: -0.08,
phi: 1.42
},
routes: {
target: new THREE.Vector3(5.28, 2.45, -1.55),
radius: 6.7,
theta: 0.12,
phi: 1.43
}
};
function selectView(name) {
const view = views[name];
if (!view) return;
controls.goalTarget.copy(view.target);
controls.goalRadius = view.radius;
controls.goalTheta = view.theta;
controls.goalPhi = view.phi;
document.querySelectorAll(".nav button").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll(".nav button").forEach((button) => {
button.addEventListener("click", () => selectView(button.dataset.view));
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let dragging = false;
let moved = false;
let pointerX = 0;
let pointerY = 0;
function updatePointer(event) {
pointer.x = (event.clientX / innerWidth) * 2 - 1;
pointer.y = -(event.clientY / innerHeight) * 2 + 1;
}
function pickedView(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveMeshes, false);
return hits.length ? hits[0].object.userData.view : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
moved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
controls.goalTheta -= dx * 0.005;
controls.goalPhi = THREE.MathUtils.clamp(
controls.goalPhi - dy * 0.004,
0.58,
1.5
);
} else {
const view = pickedView(event);
renderer.domElement.style.cursor = view ? "pointer" : "grab";
if (view) {
const labels = {
ore: "01 · Silver-bearing ore",
silver: "02 · Refined silver",
coin: "03 · Eight reales, 1783",
routes: "Trade routes of silver"
};
hoverLabel.textContent = labels[view];
hoverLabel.style.display = "block";
hoverLabel.style.left = `${event.clientX}px`;
hoverLabel.style.top = `${event.clientY}px`;
} else {
hoverLabel.style.display = "none";
}
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (!moved) {
const view = pickedView(event);
if (view) selectView(view);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener("pointerleave", () => {
hoverLabel.style.display = "none";
if (!dragging) renderer.domElement.style.cursor = "grab";
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.goalRadius = THREE.MathUtils.clamp(
controls.goalRadius + event.deltaY * 0.012,
4.1,
18
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => selectView("overview"));
addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") controls.goalTheta += 0.12;
if (event.key === "ArrowRight") controls.goalTheta -= 0.12;
if (event.key === "ArrowUp") controls.goalPhi -= 0.08;
if (event.key === "ArrowDown") controls.goalPhi += 0.08;
if (event.key.toLowerCase() === "r") selectView("overview");
});
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
if (innerWidth < 700) {
controls.goalRadius = Math.max(controls.goalRadius, 15.5);
}
}
addEventListener("resize", resize);
const clock = new THREE.Clock();
const spherical = new THREE.Spherical();
const cameraOffset = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const damping = 1 - Math.pow(0.001, delta);
controls.radius = THREE.MathUtils.lerp(
controls.radius,
controls.goalRadius,
damping
);
controls.theta = THREE.MathUtils.lerp(
controls.theta,
controls.goalTheta,
damping
);
controls.phi = THREE.MathUtils.lerp(
controls.phi,
controls.goalPhi,
damping
);
controls.target.lerp(controls.goalTarget, damping);
spherical.set(controls.radius, controls.phi, controls.theta);
cameraOffset.setFromSpherical(spherical);
camera.position.copy(controls.target).add(cameraOffset);
camera.lookAt(controls.target);
dust.rotation.y = elapsed * 0.012;
dust.position.y = Math.sin(elapsed * 0.16) * 0.035;
const pulse = 1 + Math.sin(elapsed * 2.6) * 0.18;
routePin.scale.setScalar(pulse);
pinRing.scale.setScalar(1 + Math.sin(elapsed * 2.6) * 0.34);
pinRing.material.opacity = 0.52 + Math.sin(elapsed * 2.6) * 0.2;
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```