Prompt specification
Build or customize the Three.js 3D scene "Potter selling cups in a Greek square" 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: Potter selling cups in a Greek square
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/potter-selling-cups-in-a-greek-square-x2270
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring an ancient Greek agora and its shared uses. Create a small stylized Greek market stall with stacked cups, buyer, and measured payment counters. Show one exchange using an explicitly illustrative price system. Low-poly.
Working Three.js Starter (potter-selling-cups-in-a-greek-square-x2270):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Shared Agora — An Illustrative Greek Market Exchange</title>
<style>
:root {
color-scheme: light;
--ink: #243331;
--paper: #f3e9d1;
--paper-soft: rgba(248, 239, 215, 0.91);
--terra: #b75d3e;
--bronze: #9b6a28;
--blue: #315f70;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c9d9d7;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active { cursor: grabbing; }
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(30, 49, 50, 0.12), transparent 28%),
linear-gradient(0deg, rgba(30, 49, 50, 0.18), transparent 32%);
}
.panel {
background: var(--paper-soft);
border: 1px solid rgba(77, 64, 43, 0.22);
box-shadow: 0 12px 40px rgba(32, 48, 45, 0.16);
backdrop-filter: blur(10px);
}
#story {
position: fixed;
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 4px 18px 18px 18px;
pointer-events: none;
}
.eyebrow {
color: var(--terra);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 6px 0 5px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
#story p {
margin: 10px 0 13px;
max-width: 330px;
color: #52605b;
font-size: 13px;
line-height: 1.45;
}
#uses {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
#uses span {
padding: 5px 8px;
border: 1px solid rgba(49, 95, 112, 0.25);
border-radius: 999px;
background: rgba(49, 95, 112, 0.08);
color: #315f70;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
}
#controls {
position: fixed;
top: 22px;
right: 22px;
display: flex;
gap: 6px;
padding: 6px;
border-radius: 12px;
pointer-events: auto;
}
#controls button {
border: 0;
border-radius: 8px;
padding: 9px 11px;
background: transparent;
color: #3c4c48;
cursor: pointer;
font: 700 11px/1 inherit;
letter-spacing: 0.04em;
}
#controls button:hover,
#controls button.active {
background: var(--terra);
color: #fff8e9;
}
#exchange {
position: fixed;
left: 50%;
bottom: 22px;
width: min(690px, calc(100vw - 32px));
transform: translateX(-50%);
padding: 15px 18px;
border-radius: 16px;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 16px;
pointer-events: auto;
}
.exchange-top {
display: flex;
align-items: baseline;
gap: 10px;
flex-wrap: wrap;
}
.exchange-top strong {
color: var(--terra);
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#status {
color: #4d5c57;
font-size: 12px;
}
.rate {
margin-top: 7px;
font-family: Georgia, "Times New Roman", serif;
font-size: 16px;
}
.disclaimer {
margin-top: 4px;
color: #727a73;
font-size: 10px;
line-height: 1.35;
}
#replay {
border: 1px solid rgba(183, 93, 62, 0.35);
border-radius: 999px;
padding: 10px 15px;
background: rgba(183, 93, 62, 0.1);
color: #9b462d;
cursor: pointer;
white-space: nowrap;
font: 800 11px/1 inherit;
letter-spacing: 0.06em;
text-transform: uppercase;
}
#replay:hover {
background: var(--terra);
color: white;
}
#hint {
position: fixed;
right: 23px;
bottom: 24px;
color: rgba(255, 250, 235, 0.88);
font-size: 10px;
letter-spacing: 0.08em;
text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
pointer-events: none;
}
.tag {
position: fixed;
z-index: 3;
transform: translate(-50%, -100%);
padding: 6px 9px;
border: 1px solid rgba(255, 249, 230, 0.7);
border-radius: 999px;
background: rgba(37, 53, 51, 0.84);
color: #fff7e5;
box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
}
.tag::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 12px;
background: rgba(255, 249, 230, 0.75);
}
@media (max-width: 760px) {
#story {
top: 12px;
left: 12px;
width: min(320px, calc(100vw - 24px));
padding: 13px 15px;
}
#story p, #uses { display: none; }
#controls {
top: auto;
right: 12px;
bottom: 130px;
flex-direction: column;
}
#controls button { padding: 8px 9px; }
#exchange {
bottom: 12px;
padding: 13px;
grid-template-columns: 1fr;
gap: 10px;
}
#replay {
justify-self: start;
padding: 8px 12px;
}
#hint, .tag { display: none !important; }
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive low-poly ancient Greek agora"></main>
<div class="vignette"></div>
<header id="story" class="panel">
<div class="eyebrow">A shared civic space</div>
<h1>THE GREEK AGORA</h1>
<p>
A marketplace is only one part of the agora: people also gathered for
announcements, water, offerings, conversation, and public business.
</p>
<div id="uses">
<span>Trade</span>
<span>Notices</span>
<span>Water</span>
<span>Civic talk</span>
<span>Offerings</span>
</div>
</header>
<nav id="controls" class="panel" aria-label="Camera views">
<button data-view="market" class="active">Market</button>
<button data-view="exchange">Exchange</button>
<button data-view="agora">Shared uses</button>
</nav>
<div id="tags" aria-hidden="true">
<div id="tag-payment" class="tag">Measured payment · 3 obols</div>
<div id="tag-cups" class="tag">Two-cup set</div>
<div id="tag-notices" class="tag">Public notices</div>
<div id="tag-water" class="tag">Common water</div>
</div>
<section id="exchange" class="panel" aria-live="polite">
<div>
<div class="exchange-top">
<strong>Illustrative exchange</strong>
<span id="status">Buyer selects three obols from the pouch.</span>
</div>
<div class="rate">Buyer gives 3 obols → seller gives 2 cups</div>
<div class="disclaimer">
Teaching rate: 1 drachma = 6 obols. This price system is explicitly
illustrative and is not presented as a historical market quotation.
</div>
</div>
<button id="replay">Replay exchange</button>
</section>
<div id="hint">DRAG TO ORBIT · SCROLL TO ZOOM · ARROW KEYS TO PAN</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and lighting
// -------------------------------------------------------------------------
const mount = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc9d9d7);
scene.fog = new THREE.Fog(0xc9d9d7, 25, 58);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute(
"aria-label",
"Low-poly ancient Greek agora with an animated market exchange"
);
mount.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xe8f3ef, 0x8f7555, 2.0);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe2b5, 3.1);
sun.position.set(-11, 18, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const warmFill = new THREE.DirectionalLight(0xf6b783, 0.45);
warmFill.position.set(13, 7, -9);
scene.add(warmFill);
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
flatShading: true,
...options
});
const M = {
stone: material(0xd9c8a7),
paleStone: material(0xe6d8ba),
darkStone: material(0xa99b82),
wood: material(0x75492f),
darkWood: material(0x4c3328),
cream: material(0xf0dfba),
red: material(0xb85b3d),
deepRed: material(0x884630),
blue: material(0x376779),
paleBlue: material(0x729ba0),
skin: material(0xb97855),
skinLight: material(0xd49a72),
hair: material(0x382c25),
bronze: material(0xa97932, {
metalness: 0.5,
roughness: 0.52
}),
darkBronze: material(0x65471f, {
metalness: 0.42,
roughness: 0.62
}),
olive: material(0x687653),
oliveLight: material(0x82906a),
water: material(0x6da5aa, {
roughness: 0.2,
metalness: 0.08,
transparent: true,
opacity: 0.82
}),
black: material(0x202823)
};
function addMesh(parent, geometry, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, w, h, d, x, y, z, mat) {
return addMesh(
parent,
new THREE.BoxGeometry(w, h, d),
mat,
x,
y,
z
);
}
function addCylinder(
parent,
rTop,
rBottom,
h,
x,
y,
z,
mat,
segments = 8
) {
return addMesh(
parent,
new THREE.CylinderGeometry(rTop, rBottom, h, segments),
mat,
x,
y,
z
);
}
function cylinderBetween(parent, a, b, radius, mat, segments = 7) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = addCylinder(
parent,
radius,
radius,
length,
0,
0,
0,
mat,
segments
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function makeSign(parent, width, height, x, y, z, draw) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 560;
const ctx = canvas.getContext("2d");
draw(ctx, canvas.width, canvas.height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const sign = addMesh(
parent,
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
toneMapped: false
}),
x,
y,
z
);
sign.castShadow = false;
return sign;
}
// -------------------------------------------------------------------------
// Paved agora
// -------------------------------------------------------------------------
const tileGeometry = new THREE.BoxGeometry(1.76, 0.14, 1.76);
const tileMaterial = material(0xffffff);
const tileCount = 17 * 17;
const tiles = new THREE.InstancedMesh(tileGeometry, tileMaterial, tileCount);
tiles.receiveShadow = true;
const matrix = new THREE.Matrix4();
const quaternion = new THREE.Quaternion();
const scale = new THREE.Vector3(1, 1, 1);
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let ix = -8; ix <= 8; ix++) {
for (let iz = -8; iz <= 8; iz++) {
const jitter = Math.sin(ix * 19.17 + iz * 7.31) * 0.025;
matrix.compose(
new THREE.Vector3(ix * 1.8, -0.07 + jitter, iz * 1.8),
quaternion,
scale
);
tiles.setMatrixAt(tileIndex, matrix);
const shade = 0.88 + Math.sin(ix * 5.4 + iz * 2.1) * 0.045;
tileColor.setRGB(
0.76 * shade,
0.70 * shade,
0.59 * shade
);
tiles.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
tiles.instanceMatrix.needsUpdate = true;
tiles.instanceColor.needsUpdate = true;
scene.add(tiles);
const inlay = addMesh(
scene,
new THREE.RingGeometry(5.8, 5.96, 40),
material(0xa88f69),
0,
0.012,
0
);
inlay.rotation.x = -Math.PI / 2;
inlay.castShadow = false;
// -------------------------------------------------------------------------
// Background stoa and civic architecture
// -------------------------------------------------------------------------
addBox(scene, 28, 0.5, 3.6, 0, 0.25, -10.7, M.darkStone);
addBox(scene, 28, 5.8, 0.5, 0, 3.25, -12.1, M.paleStone);
addBox(scene, 29, 0.42, 2.2, 0, 6.25, -11.1, M.red);
addBox(scene, 29.3, 0.28, 2.5, 0, 5.72, -10.95, M.paleStone);
function makeColumn(x, z) {
addBox(scene, 0.95, 0.22, 0.95, x, 0.61, z, M.paleStone);
addCylinder(scene, 0.3, 0.36, 4.6, x, 3.0, z, M.paleStone, 8);
addBox(scene, 0.83, 0.24, 0.83, x, 5.42, z, M.paleStone);
addBox(scene, 0.9, 0.13, 0.9, x, 0.46, z, M.darkStone);
}
for (let x = -12; x <= 12; x += 3) {
makeColumn(x, -10.2);
}
makeSign(scene, 3.8, 1.15, 0, 4.5, -11.77, (ctx, w, h) => {
ctx.fillStyle = "#e6d4aa";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#765536";
ctx.lineWidth = 18;
ctx.strokeRect(20, 20, w - 40, h - 40);
ctx.fillStyle = "#354a49";
ctx.font = "bold 72px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("PUBLIC HALL", w / 2, h / 2);
});
// A small temple-like pavilion at the far end of the stoa.
addBox(scene, 8.2, 0.45, 5.4, 0, 6.55, -10.7, M.paleStone);
const pedimentShape = new THREE.Shape();
pedimentShape.moveTo(-4.0, 0);
pedimentShape.lineTo(0, 2.1);
pedimentShape.lineTo(4.0, 0);
pedimentShape.closePath();
const pediment = addMesh(
scene,
new THREE.ExtrudeGeometry(pedimentShape, {
depth: 4.3,
bevelEnabled: false
}),
M.red,
0,
6.75,
-12.85
);
pediment.castShadow = true;
// -------------------------------------------------------------------------
// Props: amphorae, trees, notice board, fountain, altar
// -------------------------------------------------------------------------
function makeAmphora(parent, x, y, z, mat, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
const points = [
[0.00, 0.00],
[0.27, 0.00],
[0.39, 0.13],
[0.50, 0.55],
[0.47, 0.91],
[0.27, 1.16],
[0.19, 1.39],
[0.26, 1.50],
[0.21, 1.56],
[0.15, 1.42],
[0.17, 1.17],
[0.36, 0.84],
[0.30, 0.27],
[0.00, 0.20]
].map(([px, py]) => new THREE.Vector2(px, py));
addMesh(group, new THREE.LatheGeometry(points, 9), mat);
for (const side of [-1, 1]) {
const handle = addMesh(
group,
new THREE.TorusGeometry(0.23, 0.055, 5, 8),
mat,
side * 0.36,
1.05,
0
);
handle.rotation.y = Math.PI / 2;
handle.scale.y = 1.2;
}
return group;
}
function makeOliveTree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
addCylinder(group, 0.17, 0.25, 2.4, 0, 1.2, 0, M.wood, 7);
const crown = addMesh(
group,
new THREE.DodecahedronGeometry(1.25, 0),
M.olive,
0,
2.7,
0
);
crown.scale.set(1.1, 0.9, 1.0);
const crown2 = addMesh(
group,
new THREE.DodecahedronGeometry(0.8, 0),
M.oliveLight,
0.7,
2.45,
0.1
);
crown2.scale.set(1.0, 0.75, 1.1);
}
makeOliveTree(-14.4, -5.7, 1.12);
makeOliveTree(14.1, -7.2, 1.0);
makeOliveTree(-14.8, 8.0, 0.9);
makeOliveTree(14.5, 7.8, 0.88);
makeAmphora(scene, -5.1, 0, 1.8, M.red, 1.05);
makeAmphora(scene, -5.8, 0, 2.3, M.darkRed, 0.8);
makeAmphora(scene, 5.6, 0, -2.7, M.red, 1.15);
makeAmphora(scene, 6.4, 0, -3.2, M.cream, 0.8);
// Public notice board.
const noticeGroup = new THREE.Group();
noticeGroup.position.set(-8.1, 0, 1.0);
scene.add(noticeGroup);
addBox(noticeGroup, 0.18, 3.2, 0.18, -1.55, 1.6, 0, M.wood);
addBox(noticeGroup, 0.18, 3.2, 0.18, 1.55, 1.6, 0, M.wood);
addBox(noticeGroup, 3.5, 2.0, 0.18, 0, 2.05, 0, M.darkWood);
addBox(noticeGroup, 4.0, 0.18, 1.2, 0, 3.3, 0.2, M.red);
const noticeColors = [0xf3e4c4, 0xe8d9b8, 0xf1dfbd];
for (let i = 0; i < 3; i++) {
const parchment = makeSign(
noticeGroup,
0.78,
1.35,
-1.08 + i * 1.08,
2.05,
0.101,
(ctx, w, h) => {
ctx.fillStyle = "#f0dfba";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#745c42";
for (let line = 0; line < 8; line++) {
const lineWidth = 170 + ((line * 53) % 180);
ctx.fillRect(45, 85 + line * 42, lineWidth, 10);
}
ctx.fillStyle = "#a5573d";
ctx.fillRect(45, 35, 180, 20);
}
);
parchment.rotation.z = (i - 1) * 0.045;
}
makeSign(noticeGroup, 3.0, 0.65, 0, 3.3, 0.22, (ctx, w, h) => {
ctx.fillStyle = "#e5d3aa";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#4a4334";
ctx.font = "bold 60px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("PUBLIC NOTICES", w / 2, h / 2);
});
// Common fountain.
const fountain = new THREE.Group();
fountain.position.set(7.7, 0, -1.5);
scene.add(fountain);
addCylinder(fountain, 2.15, 2.35, 0.48, 0, 0.24, 0, M.stone, 8);
addCylinder(fountain, 1.82, 1.82, 0.08, 0, 0.51, 0, M.water, 8);
addCylinder(fountain, 0.32, 0.52, 1.45, 0, 1.16, 0, M.paleStone, 8);
addCylinder(fountain, 0.95, 0.42, 0.28, 0, 1.92, 0, M.paleStone, 8);
addCylinder(fountain, 0.08, 0.08, 0.75, 0, 2.36, 0, M.bronze, 8);
// Small offering altar.
addBox(scene, 1.8, 0.8, 1.6, -7.0, 0.4, -5.1, M.paleStone);
addBox(scene, 2.1, 0.18, 1.9, -7.0, 0.88, -5.1, M.paleStone);
addCylinder(scene, 0.28, 0.22, 0.5, -7.0, 1.2, -5.1, M.red, 8);
// -------------------------------------------------------------------------
// Market stall
// -------------------------------------------------------------------------
const stall = new THREE.Group();
scene.add(stall);
// Counter and shelves.
addBox(stall, 8.2, 0.22, 1.5, 0, 1.40, 1.55, M.wood);
addBox(stall, 7.9, 0.78, 0.16, 0, 0.92, 2.25, M.darkWood);
for (const x of [-3.55, -1.2, 1.2, 3.55]) {
addBox(stall, 0.22, 1.35, 0.22, x, 0.68, 1.55, M.darkWood);
}
addBox(stall, 7.6, 0.18, 1.15, 0, 1.15, -1.35, M.wood);
addBox(stall, 7.6, 0.16, 0.95, 0, 2.18, -1.45, M.wood);
for (const x of [-3.7, 3.7]) {
for (const z of [-1.75, 2.75]) {
addBox(stall, 0.24, 4.85, 0.24, x, 2.42, z, M.darkWood);
}
}
addBox(stall, 8.0, 0.22, 0.22, 0, 4.65, -1.75, M.darkWood);
addBox(stall, 8.0, 0.22, 0.22, 0, 4.65, 2.75, M.darkWood);
// Striped cloth canopy.
const canopy = new THREE.Group();
canopy.position.set(0, 4.86, 0.45);
canopy.rotation.z = -0.035;
stall.add(canopy);
addBox(canopy, 8.8, 0.16, 4.7, 0, 0, 0, M.cream);
for (let i = 0; i < 8; i++) {
const x = -3.675 + i * 1.05;
addBox(canopy, 0.72, 0.10, 4.72, x, 0.12, 0, M.red);
addBox(canopy, 1.05, 0.57, 0.08, x, -0.37, 2.36, M.red);
}
// Price board with an explicitly illustrative system.
makeSign(stall, 4.45, 2.4, 0, 3.53, -1.79, (ctx, w, h) => {
ctx.fillStyle = "#eee0bb";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#704d31";
ctx.lineWidth = 18;
ctx.strokeRect(18, 18, w - 36, h - 36);
ctx.strokeStyle = "#a65c3c";
ctx.lineWidth = 5;
ctx.strokeRect(38, 38, w - 76, h - 76);
ctx.textAlign = "center";
ctx.fillStyle = "#9f4e35";
ctx.font = "bold 53px Georgia";
ctx.fillText("ILLUSTRATIVE PRICE", w / 2, 106);
ctx.fillStyle = "#303d38";
ctx.font = "bold 48px Georgia";
ctx.fillText("3 OBOLS = 1 TWO-CUP SET", w / 2, 220);
ctx.font = "bold 43px Georgia";
ctx.fillText("1 DRACHMA = 6 OBOLS", w / 2, 302);
ctx.fillStyle = "#736856";
ctx.font = "27px Georgia";
ctx.fillText("Teaching model — not a historical market quote", w / 2, 393);
ctx.fillStyle = "#9f4e35";
ctx.font = "bold 27px sans-serif";
ctx.fillText("MEASURED COUNTER • PUBLIC WEIGHTS", w / 2, 465);
});
addBox(stall, 0.14, 2.7, 0.14, -2.65, 3.25, -1.78, M.darkWood);
addBox(stall, 0.14, 2.7, 0.14, 2.65, 3.25, -1.78, M.darkWood);
// -------------------------------------------------------------------------
// Cups, amphorae, payment tray, and balance
// -------------------------------------------------------------------------
function makeCup(parent, x, y, z, mat, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
parent.add(group);
const points = [
[0.00, 0.00],
[0.18, 0.00],
[0.23, 0.06],
[0.29, 0.43],
[0.31, 0.48],
[0.26, 0.49],
[0.20, 0.10],
[0.00, 0.10]
].map(([px, py]) => new THREE.Vector2(px, py));
addMesh(group, new THREE.LatheGeometry(points, 8), mat);
const handle = addMesh(
group,
new THREE.TorusGeometry(0.115, 0.032, 5, 8),
mat,
0.29,
0.29,
0
);
handle.rotation.y = Math.PI / 2;
handle.scale.y = 1.2;
return group;
}
// Static stacked cups on the rear shelves.
for (let i = 0; i < 4; i++) {
makeCup(stall, -2.65 + i * 0.38, 1.27, -1.35, M.red, 0.95);
makeCup(stall, -2.65 + i * 0.38, 1.52, -1.35, M.red, 0.95);
}
for (let i = 0; i < 3; i++) {
makeCup(stall, 0.05 + i * 0.4, 2.30, -1.45, M.cream, 0.95);
makeCup(stall, 0.05 + i * 0.4, 2.55, -1.45, M.cream, 0.95);
}
makeAmphora(stall, -3.0, 1.26, -1.4, M.red, 0.72);
makeAmphora(stall, 2.95, 1.26, -1.4, M.cream, 0.78);
// Marked payment tray: three circular counters.
const paymentGroup = new THREE.Group();
stall.add(paymentGroup);
addBox(paymentGroup, 2.45, 0.08, 1.08, -2.0, 1.56, 1.52, M.darkBronze);
const paymentRingMaterials = [];
const coinTargets = [];
for (let i = 0; i < 3; i++) {
const ringMat = material(0xd2ad61, {
metalness: 0.45,
roughness: 0.42,
emissive: 0x6e430d,
emissiveIntensity: 0.05
});
paymentRingMaterials.push(ringMat);
const ring = addMesh(
paymentGroup,
new THREE.TorusGeometry(0.17, 0.025, 6, 12),
ringMat,
-2.62 + i * 0.62,
1.615,
1.52
);
ring.rotation.x = -Math.PI / 2;
coinTargets.push(
new THREE.Vector3(-2.62 + i * 0.62, 1.66, 1.52)
);
}
makeSign(
stall,
2.35,
0.58,
-2.0,
1.0,
2.345,
(ctx, w, h) => {
ctx.fillStyle = "#e6d4aa";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = "#8c4c35";
ctx.font = "bold 46px Georgia";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("PAYMENT: 3 OBOLS", w / 2, h / 2);
}
);
// Public balance and standard weights.
const balance = new THREE.Group();
balance.position.set(3.0, 1.53, 1.18);
stall.add(balance);
addBox(balance, 0.95, 0.12, 0.65, 0, 0.06, 0, M.darkBronze);
addCylinder(balance, 0.065, 0.08, 1.25, 0, 0.7, 0, M.bronze, 8);
const beam = new THREE.Group();
beam.position.y = 1.28;
balance.add(beam);
addBox(beam, 1.55, 0.08, 0.1, 0, 0, 0, M.bronze);
for (const side of [-1, 1]) {
const panX = side * 0.68;
cylinderBetween(
beam,
new THREE.Vector3(panX, 0, 0),
new THREE.Vector3(panX, -0.55, 0),
0.018,
M.darkBronze,
5
);
addCylinder(
beam,
0.30,
0.23,
0.10,
panX,
-0.60,
0,
M.bronze,
8
);
}
addCylinder(balance, 0.18, 0.18, 0.28, -0.68, -0.48, 0, M.darkBronze, 8);
addCylinder(balance, 0.14, 0.14, 0.25, 0.68, -0.49, 0, M.darkBronze, 8);
// -------------------------------------------------------------------------
// Low-poly people
// -------------------------------------------------------------------------
function makePerson({
x,
z,
robe,
skin = M.skin,
rotation = 0,
scale = 1,
detailed = true
}) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
addCylinder(group, 0.34, 0.49, 1.05, 0, 1.25, 0, robe, 7);
addCylinder(group, 0.38, 0.38, 0.12, 0, 1.0, 0, M.darkWood, 8);
addCylinder(group, 0.13, 0.14, 0.82, -0.2, 0.42, 0, M.skin, 7);
addCylinder(group, 0.13, 0.14, 0.82, 0.2, 0.42, 0, M.skin, 7);
addBox(group, 0.25, 0.16, 0.42, -0.2, 0.08, 0.08, M.darkWood);
addBox(group, 0.25, 0.16, 0.42, 0.2, 0.08, 0.08, M.darkWood);
const head = addMesh(
group,
new THREE.SphereGeometry(0.29, 8, 6),
skin,
0,
2.02,
0
);
head.scale.set(0.95, 1.08, 0.92);
const hair = addMesh(
group,
new THREE.DodecahedronGeometry(0.30, 0),
M.hair,
0,
2.18,
-0.02
);
hair.scale.set(1.0, 0.62, 1.0);
const shoulderY = 1.63;
cylinderBetween(
group,
new THREE.Vector3(-0.34, shoulderY, 0),
new THREE.Vector3(-0.52, 1.18, 0.1),
0.13,
robe
);
cylinderBetween(
group,
new THREE.Vector3(-0.52, 1.18, 0.1),
new THREE.Vector3(-0.48, 0.98, 0.25),
0.11,
skin
);
cylinderBetween(
group,
new THREE.Vector3(0.34, shoulderY, 0),
new THREE.Vector3(0.56, 1.36, 0.18),
0.13,
robe
);
cylinderBetween(
group,
new THREE.Vector3(0.56, 1.36, 0.18),
new THREE.Vector3(0.69, 1.40, 0.42),
0.11,
skin
);
if (detailed) {
const eyeMat = M.black;
addMesh(group, new THREE.SphereGeometry(0.035, 5, 4), eyeMat, -0.10, 2.05, 0.266);
addMesh(group, new THREE.SphereGeometry(0.035, 5, 4), eyeMat, 0.10, 2.05, 0.266);
addMesh(group, new THREE.ConeGeometry(0.055, 0.13, 5), skin, 0, 1.98, 0.285);
}
return group;
}
const seller = makePerson({
x: 0.65,
z: -0.35,
robe: M.blue,
skin: M.skinLight,
rotation: 0,
scale: 1.03
});
const buyer = makePerson({
x: -1.65,
z: 3.0,
robe: M.red,
skin: M.skin,
rotation: Math.PI,
scale: 1.05
});
// Buyer's pouch and hand anchors.
const pouch = addMesh(
buyer,
new THREE.SphereGeometry(0.24, 7, 5),
M.darkBrown || M.darkWood,
-0.45,
1.0,
0.2
);
pouch.scale.set(1.0, 1.18, 0.65);
const pouchAnchor = new THREE.Object3D();
pouchAnchor.position.set(-0.45, 1.13, 0.28);
buyer.add(pouchAnchor);
const handAnchor = new THREE.Object3D();
handAnchor.position.set(0.43, 1.52, 0.55);
buyer.add(handAnchor);
// Background civic conversations.
makePerson({
x: 8.7,
z: 4.8,
robe: M.cream,
skin: M.skinLight,
rotation: -0.8,
scale: 0.86,
detailed: false
});
makePerson({
x: 9.8,
z: 4.5,
robe: M.deepRed,
skin: M.skin,
rotation: 0.6,
scale: 0.82,
detailed: false
});
makePerson({
x: 9.25,
z: 3.6,
robe: M.paleBlue,
skin: M.skinLight,
rotation: 2.6,
scale: 0.78,
detailed: false
});
// -------------------------------------------------------------------------
// Animated exchange: 3 obols for one two-cup set
// -------------------------------------------------------------------------
function makeCoin() {
const group = new THREE.Group();
scene.add(group);
addCylinder(group, 0.16, 0.16, 0.065, 0, 0, 0, M.bronze, 12);
addCylinder(group, 0.115, 0.115, 0.012, 0, 0.038, 0, M.darkBronze, 12);
// A tiny radial mark suggests the stamped reverse.
const mark = addBox(
group,
0.17,
0.012,
0.035,
0,
0.048,
0
);
mark.castShadow = false;
return group;
}
const coins = [makeCoin(), makeCoin(), makeCoin()];
const exchangedCupSet = new THREE.Group();
scene.add(exchangedCupSet);
makeCup(exchangedCupSet, 0, 0, 0, M.red, 1.05);
makeCup(exchangedCupSet, 0, 0.27, 0, M.red, 1.05);
const cupStart = new THREE.Vector3(1.35, 1.54, 1.55);
const cupMid = new THREE.Vector3(0.95, 2.02, 0.25);
const cupEnd = new THREE.Vector3(-2.02, 1.33, 2.48);
exchangedCupSet.position.copy(cupStart);
scene.updateMatrixWorld(true);
const pouchPosition = new THREE.Vector3();
const handPosition = new THREE.Vector3();
pouchAnchor.getWorldPosition(pouchPosition);
handAnchor.getWorldPosition(handPosition);
const statusElement = document.querySelector("#status");
let exchangeTime = 0;
let previousPhase = "";
function smoothstep(t) {
t = THREE.MathUtils.clamp(t, 0, 1);
return t * t * (3 - 2 * t);
}
function arcPosition(out, start, end, t, height = 0.25) {
out.lerpVectors(start, end, smoothstep(t));
out.y += Math.sin(Math.PI * THREE.MathUtils.clamp(t, 0, 1)) * height;
}
function updateExchange(time) {
for (let i = 0; i < coins.length; i++) {
const coin = coins[i];
const start = new THREE.Vector3(
pouchPosition.x + (i - 1) * 0.055,
pouchPosition.y + i * 0.035,
pouchPosition.z
);
const hand = new THREE.Vector3(
handPosition.x + (i - 1) * 0.045,
handPosition.y + i * 0.025,
handPosition.z
);
const target = coinTargets[i];
if (time < 1.5) {
coin.position.copy(start);
} else if (time < 3.2) {
arcPosition(coin.position, start, hand, (time - 1.5) / 1.7, 0.18);
} else {
const placementStart = 3.2 + i * 0.35;
const placementEnd = placementStart + 0.75;
if (time < placementStart) {
coin.position.copy(hand);
} else if (time < placementEnd) {
arcPosition(
coin.position,
hand,
target,
(time - placementStart) / 0.75,
0.30
);
} else {
coin.position.copy(target);
}
}
coin.rotation.y = time * 2.4 + i;
}
if (time < 5.45) {
exchangedCupSet.position.copy(cupStart);
exchangedCupSet.rotation.y = 0;
} else if (time < 6.2) {
arcPosition(
exchangedCupSet.position,
cupStart,
cupMid,
(time - 5.45) / 0.75,
0.34
);
exchangedCupSet.rotation.y = -0.2 * smoothstep((time - 5.45) / 0.75);
} else if (time < 7.65) {
arcPosition(
exchangedCupSet.position,
cupMid,
cupEnd,
(time - 6.2) / 1.45,
0.72
);
exchangedCupSet.rotation.y =
-0.2 - 0.25 * smoothstep((time - 6.2) / 1.45);
} else {
exchangedCupSet.position.copy(cupEnd);
exchangedCupSet.rotation.y = -0.45;
}
// The balance gives a small confirming movement.
if (time > 3.1 && time < 6.5) {
beam.rotation.z =
Math.sin((time - 3.1) * 8) *
0.025 *
(1 - THREE.MathUtils.clamp((time - 5.2) / 1.3, 0, 1));
} else {
beam.rotation.z *= 0.9;
}
for (let i = 0; i < paymentRingMaterials.length; i++) {
const arrivalTime = 3.95 + i * 0.35;
paymentRingMaterials[i].emissiveIntensity =
time > arrivalTime ? 0.85 : 0.08;
}
let phase;
let message;
if (time < 1.5) {
phase = "select";
message = "Buyer selects three obols from the pouch.";
} else if (time < 3.2) {
phase = "count";
message = "Three bronze obols are counted in the buyer's hand.";
} else if (time < 5.45) {
phase = "pay";
message = "Each obol is placed into a marked payment well.";
} else if (time < 7.65) {
phase = "handover";
message = "The seller releases one two-cup set.";
} else {
phase = "complete";
message = "Exchange complete: 3 obols for 2 cups.";
}
if (phase !== previousPhase) {
statusElement.textContent = message;
previousPhase = phase;
}
}
document.querySelector("#replay").addEventListener("click", () => {
exchangeTime = 0;
previousPhase = "";
});
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, zoom, and view buttons
// -------------------------------------------------------------------------
const desiredCamera = {
target: new THREE.Vector3(0, 1.55, 0.8),
radius: 15.5,
theta: 0.64,
phi: 1.08
};
const currentCamera = {
target: desiredCamera.target.clone(),
radius: desiredCamera.radius,
theta: desiredCamera.theta,
phi: desiredCamera.phi
};
function setView(name) {
if (name === "market") {
desiredCamera.target.set(0, 1.55, 0.8);
desiredCamera.radius = 15.5;
desiredCamera.theta = 0.64;
desiredCamera.phi = 1.08;
} else if (name === "exchange") {
desiredCamera.target.set(-0.45, 1.45, 1.7);
desiredCamera.radius = 8.4;
desiredCamera.theta = 0.48;
desiredCamera.phi = 1.08;
} else {
desiredCamera.target.set(0, 1.05, -0.5);
desiredCamera.radius = 26;
desiredCamera.theta = 0.25;
desiredCamera.phi = 1.13;
}
document.querySelectorAll("#controls button").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll("#controls button").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
let dragging = false;
let lastX = 0;
let lastY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
desiredCamera.theta -= dx * 0.005;
desiredCamera.phi = THREE.MathUtils.clamp(
desiredCamera.phi + dy * 0.004,
0.48,
1.42
);
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
6.5,
36
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
const panAmount = 0.45;
if (event.key === "ArrowLeft") {
desiredCamera.target.x -= panAmount;
} else if (event.key === "ArrowRight") {
desiredCamera.target.x += panAmount;
} else if (event.key === "ArrowUp") {
desiredCamera.target.z -= panAmount;
} else if (event.key === "ArrowDown") {
desiredCamera.target.z += panAmount;
} else if (event.key === "+" || event.key === "=") {
desiredCamera.radius = Math.max(6.5, desiredCamera.radius - 1);
} else if (event.key === "-") {
desiredCamera.radius = Math.min(36, desiredCamera.radius + 1);
}
});
function updateCamera(dt) {
const alpha = 1 - Math.exp(-dt * 6);
currentCamera.target.lerp(desiredCamera.target, alpha);
currentCamera.radius +=
(desiredCamera.radius - currentCamera.radius) * alpha;
currentCamera.theta +=
(desiredCamera.theta - currentCamera.theta) * alpha;
currentCamera.phi +=
(desiredCamera.phi - currentCamera.phi) * alpha;
const sinPhi = Math.sin(currentCamera.phi);
camera.position.set(
currentCamera.target.x +
currentCamera.radius * sinPhi * Math.sin(currentCamera.theta),
currentCamera.target.y + currentCamera.radius * Math.cos(currentCamera.phi),
currentCamera.target.z +
currentCamera.radius * sinPhi * Math.cos(currentCamera.theta)
);
camera.lookAt(currentCamera.target);
camera.updateMatrixWorld();
}
// -------------------------------------------------------------------------
// World-anchored labels
// -------------------------------------------------------------------------
const tagItems = [
{
element: document.querySelector("#tag-payment"),
position: new THREE.Vector3(-2.0, 2.05, 1.55)
},
{
element: document.querySelector("#tag-cups"),
position: new THREE.Vector3(1.35, 2.05, 1.55)
},
{
element: document.querySelector("#tag-notices"),
position: new THREE.Vector3(-8.1, 3.75, 1.0)
},
{
element: document.querySelector("#tag-water"),
position: new THREE.Vector3(7.7, 2.8, -1.5)
}
];
const projected = new THREE.Vector3();
function updateTags() {
for (const tag of tagItems) {
projected.copy(tag.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.05 &&
projected.x < 1.05 &&
projected.y > -1.05 &&
projected.y < 1.05;
tag.element.style.display = visible ? "block" : "none";
if (visible) {
tag.element.style.left =
`${(projected.x * 0.5 + 0.5) * innerWidth}px`;
tag.element.style.top =
`${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
}
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
exchangeTime = Math.min(exchangeTime + dt, 9);
updateExchange(exchangeTime);
updateCamera(dt);
updateTags();
renderer.render(scene, camera);
}
updateExchange(0);
animate();
</script>
</body>
</html>
```