Prompt specification
Build or customize the Three.js 3D scene "Festival booth and backup-location card" 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: Festival booth and backup-location card
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/festival-booth-and-backup-location-card-x3857
Scene Description Prompt:
Display a folded booth, activity materials, and two location cards for plaza and hall; matching symbols show that the same activity can move between sites. Build this with Three.js from cdnjs as a stylized scene in one self-contained HTML file.
Working Three.js Starter (festival-booth-and-backup-location-card-x3857):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>One Activity, Two Locations</title>
<style>
:root {
--ink: #243039;
--muted: #66747c;
--paper: #fffdf7;
--coral: #ef6957;
--line: rgba(36, 48, 57, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #ece8de;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.header {
position: fixed;
z-index: 10;
top: 28px;
left: 30px;
max-width: 440px;
pointer-events: none;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
padding: 7px 11px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 253, 247, 0.72);
backdrop-filter: blur(12px);
color: #536168;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.eyebrow::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--coral);
content: "";
}
h1 {
margin: 0;
max-width: 410px;
font-size: clamp(31px, 4vw, 57px);
line-height: 0.98;
letter-spacing: -0.055em;
}
.subtitle {
max-width: 390px;
margin: 14px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.panel {
position: fixed;
z-index: 10;
right: 24px;
top: 24px;
display: flex;
align-items: center;
gap: 14px;
padding: 11px 13px;
border: 1px solid var(--line);
border-radius: 18px;
background: rgba(255, 253, 247, 0.82);
box-shadow: 0 12px 35px rgba(43, 51, 52, 0.08);
backdrop-filter: blur(14px);
}
.symbol {
display: grid;
flex: 0 0 auto;
width: 42px;
height: 42px;
place-items: center;
border-radius: 50%;
background: var(--coral);
color: white;
box-shadow: 0 5px 14px rgba(239, 105, 87, 0.25);
}
.symbol svg {
width: 28px;
height: 28px;
}
.legend strong,
.legend span {
display: block;
}
.legend strong {
font-size: 12px;
letter-spacing: 0.02em;
}
.legend span {
margin-top: 2px;
color: var(--muted);
font-size: 11px;
}
.view-controls {
position: fixed;
z-index: 10;
bottom: 24px;
left: 50%;
display: flex;
gap: 6px;
padding: 6px;
transform: translateX(-50%);
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 253, 247, 0.86);
box-shadow: 0 12px 35px rgba(43, 51, 52, 0.09);
backdrop-filter: blur(14px);
}
.view-controls button {
min-width: 74px;
padding: 9px 15px;
border: 0;
border-radius: 999px;
background: transparent;
color: #617078;
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition:
color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.view-controls button:hover {
color: var(--ink);
transform: translateY(-1px);
}
.view-controls button.active {
background: var(--ink);
color: #fffdf7;
}
.hint {
position: fixed;
z-index: 10;
left: 28px;
bottom: 31px;
color: rgba(36, 48, 57, 0.62);
font-size: 11px;
font-weight: 650;
letter-spacing: 0.02em;
pointer-events: none;
}
@media (max-width: 800px) {
.header {
top: 18px;
left: 18px;
max-width: 310px;
}
h1 {
font-size: 35px;
}
.subtitle {
max-width: 280px;
font-size: 12px;
}
.panel {
top: auto;
right: 15px;
bottom: 82px;
padding: 8px 10px;
}
.symbol {
width: 34px;
height: 34px;
}
.symbol svg {
width: 23px;
height: 23px;
}
.legend span {
display: none;
}
.hint {
display: none;
}
.view-controls {
bottom: 15px;
}
}
@media (max-width: 500px) {
.eyebrow {
font-size: 9px;
}
.subtitle {
display: none;
}
.panel {
display: none;
}
.view-controls button {
min-width: 66px;
padding: 9px 12px;
}
}
</style>
</head>
<body>
<header class="header">
<div class="eyebrow">Portable community activity</div>
<h1>One activity.<br />Two places.</h1>
<p class="subtitle">
A folded booth and a shared activity kit connect the plaza and the hall.
Matching symbols identify the same session in either location.
</p>
</header>
<aside class="panel" aria-label="Activity matching legend">
<div class="symbol">
<svg viewBox="0 0 48 48" aria-hidden="true">
<g
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="4"
>
<path d="M24 24 13 15M24 24l11-10M24 24l1 13" />
</g>
<g fill="currentColor">
<circle cx="13" cy="15" r="4" />
<circle cx="35" cy="14" r="4" />
<circle cx="25" cy="37" r="4" />
<circle cx="24" cy="24" r="3.5" />
</g>
</svg>
</div>
<div class="legend">
<strong>Same activity symbol</strong>
<span>Shared session · portable kit</span>
</div>
</aside>
<nav class="view-controls" aria-label="Camera views">
<button type="button" data-focus="plaza">Plaza</button>
<button type="button" data-focus="hall">Hall</button>
<button type="button" data-focus="all" class="active">All</button>
</nav>
<div class="hint">Drag to orbit · Scroll or pinch to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xece8de);
scene.fog = new THREE.Fog(0xece8de, 19, 34);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("role", "img");
renderer.domElement.setAttribute(
"aria-label",
"Stylized three-dimensional scene with a folded booth, activity materials, a plaza card, and a hall card."
);
document.body.prepend(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
const hemi = new THREE.HemisphereLight(0xfff8e9, 0x77848b, 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d4, 4.4);
sun.position.set(-4, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0003;
sun.shadow.normalBias = 0.025;
scene.add(sun);
scene.add(sun.target);
const rim = new THREE.DirectionalLight(0xbad9e6, 1.2);
rim.position.set(8, 5, -7);
scene.add(rim);
// -------------------------------------------------------------------------
// Materials and helpers
// -------------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
...options
});
const M = {
base: material(0xf8f3e8),
baseEdge: material(0xe2dacb),
ground: material(0xece8de),
ink: material(0x26343d),
dark: material(0x35434b),
white: material(0xfffdf7),
wood: material(0xc98f58),
woodDark: material(0x9c623d),
coral: material(0xef6957),
teal: material(0x4e9c91),
mustard: material(0xe3b84d),
blue: material(0x568ca8),
sage: material(0x8ead78),
plaza: material(0xe8d5ad),
hall: material(0xb8ced5),
hallWall: material(0xe4ecec),
paper: material(0xfffbf0),
black: material(0x273139)
};
function addBox(parent, size, position, mat, rotation = null) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
if (rotation) {
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
}
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
position,
mat,
segments = 24
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(position[0], position[1], position[2]);
parent.add(mesh);
return mesh;
}
function cylinderBetween(parent, a, b, radius, mat, segments = 12) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radius,
radius,
length,
segments
),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
parent.add(mesh);
return mesh;
}
function roundedRectPath(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function roundedSlab(width, depth, height, radius) {
const shape = new THREE.Shape();
const x = -width / 2;
const y = -depth / 2;
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 + depth - radius);
shape.quadraticCurveTo(
x + width,
y + depth,
x + width - radius,
y + depth
);
shape.lineTo(x + radius, y + depth);
shape.quadraticCurveTo(
x,
y + depth,
x,
y + depth - radius
);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
bevelEnabled: true,
bevelSegments: 3,
steps: 1,
bevelSize: 0.06,
bevelThickness: 0.05,
curveSegments: 12
});
geometry.rotateX(-Math.PI / 2);
return geometry;
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function textPlane(
parent,
text,
width,
height,
position,
options = {}
) {
const canvas = document.createElement("canvas");
canvas.width = options.canvasWidth || 768;
canvas.height = options.canvasHeight || 192;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (options.background) {
ctx.fillStyle = options.background;
roundedRectPath(
ctx,
8,
8,
canvas.width - 16,
canvas.height - 16,
options.radius || 28
);
ctx.fill();
}
ctx.fillStyle = options.color || "#26343d";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font =
options.font ||
`800 ${options.fontSize || 72}px system-ui, sans-serif`;
ctx.fillText(
text,
canvas.width / 2,
canvas.height / 2 + (options.offsetY || 0)
);
const mat = new THREE.MeshBasicMaterial({
map: canvasTexture(canvas),
transparent: true,
depthWrite: false,
toneMapped: false,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
mat
);
mesh.position.set(position[0], position[1], position[2]);
if (options.rotation) {
mesh.rotation.set(
options.rotation[0],
options.rotation[1],
options.rotation[2]
);
}
parent.add(mesh);
return mesh;
}
function drawActivitySymbol(ctx, cx, cy, radius) {
ctx.save();
ctx.fillStyle = "#ef6957";
ctx.beginPath();
ctx.arc(cx, cy, radius, 0, Math.PI * 2);
ctx.fill();
const points = [
[cx - radius * 0.48, cy - radius * 0.38],
[cx + radius * 0.50, cy - radius * 0.43],
[cx + radius * 0.04, cy + radius * 0.57]
];
ctx.strokeStyle = "#fffdf7";
ctx.fillStyle = "#fffdf7";
ctx.lineWidth = radius * 0.105;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.beginPath();
ctx.moveTo(cx, cy);
ctx.lineTo(points[0][0], points[0][1]);
ctx.moveTo(cx, cy);
ctx.lineTo(points[1][0], points[1][1]);
ctx.moveTo(cx, cy);
ctx.lineTo(points[2][0], points[2][1]);
ctx.stroke();
for (const [x, y] of points) {
ctx.beginPath();
ctx.arc(x, y, radius * 0.12, 0, Math.PI * 2);
ctx.fill();
}
ctx.beginPath();
ctx.arc(cx, cy, radius * 0.085, 0, Math.PI * 2);
ctx.fill();
ctx.restore();
}
function makeSymbolTexture() {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 256;
const ctx = canvas.getContext("2d");
drawActivitySymbol(ctx, 128, 128, 112);
return canvasTexture(canvas);
}
const symbolTexture = makeSymbolTexture();
function makeCardTexture(title, accent, number) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 640;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#fffdf7";
roundedRectPath(ctx, 18, 18, 988, 604, 36);
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 12;
roundedRectPath(ctx, 24, 24, 976, 592, 31);
ctx.stroke();
ctx.fillStyle = accent;
roundedRectPath(ctx, 70, 62, 245, 58, 28);
ctx.fill();
ctx.fillStyle = "#fffdf7";
ctx.font = "800 27px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(`LOCATION ${number}`, 192, 92);
ctx.textAlign = "left";
ctx.fillStyle = "#26343d";
ctx.font = "850 104px system-ui, sans-serif";
ctx.fillText(title, 68, 210);
ctx.fillStyle = "#748087";
ctx.font = "650 29px system-ui, sans-serif";
ctx.fillText("ACTIVITY DESTINATION", 72, 270);
ctx.strokeStyle = "#e4ddd0";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(70, 307);
ctx.lineTo(954, 307);
ctx.stroke();
drawActivitySymbol(ctx, 245, 445, 94);
ctx.fillStyle = "#26343d";
ctx.font = "850 51px system-ui, sans-serif";
ctx.fillText("COLLAB", 405, 416);
ctx.fillText("CRAFT", 405, 474);
ctx.fillStyle = "#ef6957";
ctx.font = "800 23px system-ui, sans-serif";
ctx.fillText("SAME ACTIVITY KIT", 405, 525);
ctx.fillStyle = "#748087";
ctx.font = "600 22px system-ui, sans-serif";
ctx.fillText("READY TO MOVE BETWEEN SITES", 72, 575);
return canvasTexture(canvas);
}
// -------------------------------------------------------------------------
// Platform and ground
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 60),
M.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.04;
ground.receiveShadow = true;
scene.add(ground);
const base = new THREE.Mesh(
roundedSlab(12, 8, 0.25, 0.38),
M.base
);
base.position.y = 0.02;
base.castShadow = true;
base.receiveShadow = true;
world.add(base);
const G = 0.34;
// A slim edge under the platform gives the diorama a crafted, model-like base.
const lowerBase = new THREE.Mesh(
roundedSlab(11.78, 7.78, 0.12, 0.34),
M.baseEdge
);
lowerBase.position.y = -0.03;
lowerBase.receiveShadow = true;
world.add(lowerBase);
// -------------------------------------------------------------------------
// Plaza site
// -------------------------------------------------------------------------
const plaza = new THREE.Group();
plaza.position.set(-3.35, G, -0.48);
world.add(plaza);
addCylinder(plaza, 1.72, 1.72, 0.08, [0, 0.02, 0], M.plaza, 64);
const plazaRing = new THREE.Mesh(
new THREE.RingGeometry(1.33, 1.43, 64),
material(0xc9ad79)
);
plazaRing.rotation.x = -Math.PI / 2;
plazaRing.position.y = 0.065;
plaza.add(plazaRing);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const seam = addBox(
plaza,
[0.025, 0.012, 1.22],
[
Math.sin(angle) * 0.69,
0.073,
Math.cos(angle) * 0.69
],
material(0xd3bb8f)
);
seam.rotation.y = angle;
}
// Stylized tree at the edge of the plaza.
addCylinder(
plaza,
0.11,
0.15,
1.45,
[-1.12, 0.74, -0.63],
M.woodDark,
12
);
const leafMaterial = material(0x8fac78, { flatShading: true });
const leaf1 = new THREE.Mesh(
new THREE.SphereGeometry(0.57, 12, 9),
leafMaterial
);
leaf1.position.set(-1.12, 1.65, -0.63);
leaf1.scale.set(1.0, 1.13, 0.93);
plaza.add(leaf1);
const leaf2 = new THREE.Mesh(
new THREE.SphereGeometry(0.42, 12, 9),
material(0x9fba83, { flatShading: true })
);
leaf2.position.set(-0.73, 1.48, -0.51);
plaza.add(leaf2);
const leaf3 = new THREE.Mesh(
new THREE.SphereGeometry(0.39, 12, 9),
material(0x789c70, { flatShading: true })
);
leaf3.position.set(-1.48, 1.42, -0.34);
plaza.add(leaf3);
// Bench.
addBox(plaza, [1.15, 0.12, 0.34], [0.84, 0.48, 0.83], M.wood);
addBox(
plaza,
[1.15, 0.42, 0.10],
[0.84, 0.76, 0.99],
M.wood,
[-0.13, 0, 0]
);
for (const x of [0.40, 1.28]) {
addBox(
plaza,
[0.10, 0.43, 0.10],
[x, 0.22, 0.83],
M.ink
);
}
// -------------------------------------------------------------------------
// Hall site
// -------------------------------------------------------------------------
const hall = new THREE.Group();
hall.position.set(3.38, G, -0.48);
world.add(hall);
addBox(hall, [3.35, 0.10, 2.62], [0, 0.03, 0], M.hall);
addBox(
hall,
[3.24, 2.55, 0.12],
[0, 1.30, -1.18],
M.hallWall
);
for (const x of [-1.54, 1.54]) {
addBox(
hall,
[0.16, 2.62, 0.18],
[x, 1.31, -1.08],
M.white
);
addBox(
hall,
[0.16, 2.62, 0.18],
[x, 1.31, 1.10],
M.white
);
}
addBox(hall, [3.38, 0.18, 0.20], [0, 2.59, -1.08], M.white);
addBox(hall, [3.38, 0.18, 0.20], [0, 2.59, 1.10], M.white);
// Blue wall band and a small hall plaque.
addBox(
hall,
[3.02, 0.22, 0.025],
[0, 1.16, -1.108],
M.blue
);
textPlane(
hall,
"COMMUNITY HALL",
1.78,
0.38,
[0, 2.13, -1.105],
{
fontSize: 58,
color: "#3f6f86"
}
);
// -------------------------------------------------------------------------
// Folded booth
// -------------------------------------------------------------------------
const booth = new THREE.Group();
booth.position.set(0, G, -0.43);
world.add(booth);
// Rug beneath the booth.
const rug = new THREE.Mesh(
new THREE.CircleGeometry(1.65, 64),
material(0xf2dfc3)
);
rug.rotation.x = -Math.PI / 2;
rug.position.y = 0.035;
booth.add(rug);
// Counter and legs.
addBox(
booth,
[2.70, 0.14, 1.08],
[0, 1.17, 0.04],
M.wood
);
for (const x of [-1.17, 1.17]) {
for (const z of [-0.38, 0.45]) {
addBox(
booth,
[0.10, 1.10, 0.10],
[x, 0.57, z],
M.ink
);
}
}
// Foldable X braces on the front.
cylinderBetween(
booth,
[-1.16, 0.10, 0.505],
[1.16, 1.10, 0.505],
0.035,
M.woodDark
);
cylinderBetween(
booth,
[1.16, 0.10, 0.505],
[-1.16, 1.10, 0.505],
0.035,
M.woodDark
);
// Upright rear panel.
const rearPanel = addBox(
booth,
[2.45, 1.02, 0.08],
[0, 1.70, -0.48],
M.teal,
[-0.08, 0, 0]
);
// Side panels folded inward.
const leftWing = addBox(
booth,
[1.00, 1.00, 0.07],
[-1.16, 1.70, -0.20],
M.mustard,
[0, 0.67, 0]
);
const rightWing = addBox(
booth,
[1.00, 1.00, 0.07],
[1.16, 1.70, -0.20],
M.coral,
[0, -0.67, 0]
);
// Folded canopy sections, stacked toward the rear.
for (let i = 0; i < 3; i++) {
addBox(
booth,
[0.88, 0.075, 0.86],
[(i - 1) * 0.73, 2.23 + i * 0.045, -0.46],
i === 1 ? M.coral : M.mustard,
[0.40 + i * 0.06, 0, (i - 1) * 0.035]
);
}
// Hinges make the folding construction legible.
for (const x of [-1.16, 1.16]) {
const hinge = addCylinder(
booth,
0.08,
0.08,
0.13,
[x, 1.70, -0.38],
M.ink,
16
);
hinge.rotation.z = Math.PI / 2;
}
textPlane(
booth,
"FOLDED BOOTH",
1.45,
0.30,
[0, 1.17, 0.585],
{
background: "#fffdf7",
color: "#39464d",
fontSize: 60,
radius: 24
}
);
// -------------------------------------------------------------------------
// Activity materials
// -------------------------------------------------------------------------
// Paper and card stacks on the counter.
for (let i = 0; i < 4; i++) {
addBox(
booth,
[0.62 - i * 0.025, 0.035, 0.46],
[-0.72 + i * 0.008, 1.28 + i * 0.036, 0.10],
i % 2 === 0 ? M.paper : M.blue,
[0, (i - 1.5) * 0.04, 0]
);
}
// Color blocks.
const blockColors = [M.coral, M.mustard, M.teal, M.blue];
for (let i = 0; i < 4; i++) {
addBox(
booth,
[0.25, 0.25, 0.25],
[-0.27 + (i % 2) * 0.29, 1.39 + Math.floor(i / 2) * 0.26, -0.13],
blockColors[i],
[0, i * 0.12, 0]
);
}
// Stacked activity cups.
const cupColors = [M.coral, M.white, M.teal];
for (let i = 0; i < 3; i++) {
addCylinder(
booth,
0.12,
0.095,
0.24,
[0.51, 1.35 + i * 0.12, -0.12],
cupColors[i],
18
);
}
// Colored rings.
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.18, 0.045, 10, 28),
[M.coral, M.blue, M.mustard][i]
);
ring.rotation.x = Math.PI / 2;
ring.position.set(0.57, 1.35 + i * 0.075, 0.22);
booth.add(ring);
}
// The same matching symbol appears on a physical activity token.
const tableToken = new THREE.Mesh(
new THREE.CircleGeometry(0.27, 48),
new THREE.MeshBasicMaterial({
map: symbolTexture,
transparent: true,
side: THREE.DoubleSide,
toneMapped: false
})
);
tableToken.rotation.x = -Math.PI / 2;
tableToken.position.set(-0.18, 1.28, 0.33);
booth.add(tableToken);
// Activity crate.
const crate = new THREE.Group();
crate.position.set(-1.86, G, 0.73);
world.add(crate);
addBox(crate, [0.88, 0.55, 0.72], [0, 0.30, 0], M.wood);
addBox(crate, [0.93, 0.08, 0.77], [0, 0.61, 0], M.woodDark);
for (let i = 0; i < 4; i++) {
addBox(
crate,
[0.14, 0.15, 0.14],
[-0.28 + i * 0.18, 0.72, 0.05],
[M.coral, M.teal, M.mustard, M.blue][i],
[0, i * 0.1, 0]
);
}
// Small rolling activity cart.
const cart = new THREE.Group();
cart.position.set(1.70, G, 0.70);
world.add(cart);
addBox(cart, [1.08, 0.10, 0.68], [0, 0.78, 0], M.white);
addBox(cart, [1.02, 0.08, 0.60], [0, 0.39, 0], M.wood);
for (const x of [-0.42, 0.42]) {
for (const z of [-0.22, 0.22]) {
const wheel = addCylinder(
cart,
0.14,
0.14,
0.08,
[x, 0.15, z],
M.ink,
16
);
wheel.rotation.x = Math.PI / 2;
}
}
addBox(cart, [0.30, 0.30, 0.30], [-0.23, 0.98, 0.03], M.coral);
addBox(cart, [0.24, 0.24, 0.24], [0.16, 0.95, -0.03], M.blue);
addCylinder(
cart,
0.14,
0.12,
0.34,
[0.31, 1.00, 0.16],
M.mustard,
18
);
// -------------------------------------------------------------------------
// Route between plaza and hall
// -------------------------------------------------------------------------
const routeCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-3.30, 0.43, -0.42),
new THREE.Vector3(-2.55, 0.43, 0.95),
new THREE.Vector3(-0.80, 0.43, 1.55),
new THREE.Vector3(1.00, 0.43, 1.55),
new THREE.Vector3(2.55, 0.43, 0.95),
new THREE.Vector3(3.30, 0.43, -0.42)
]);
const routeLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(
routeCurve.getPoints(120)
),
new THREE.LineDashedMaterial({
color: 0xef6957,
dashSize: 0.18,
gapSize: 0.13,
transparent: true,
opacity: 0.85
})
);
routeLine.computeLineDistances();
world.add(routeLine);
for (const t of [0.18, 0.50, 0.82]) {
const point = routeCurve.getPointAt(t);
const tangent = routeCurve.getTangentAt(t);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.105, 0.28, 12),
M.coral
);
arrow.position.set(point.x, 0.52, point.z);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
tangent.normalize()
);
world.add(arrow);
}
// Moving symbol token reinforces that the activity can travel.
const routeToken = new THREE.Sprite(
new THREE.SpriteMaterial({
map: symbolTexture,
transparent: true,
depthTest: false,
toneMapped: false
})
);
routeToken.scale.set(0.68, 0.68, 1);
routeToken.renderOrder = 5;
world.add(routeToken);
const routeShadow = new THREE.Mesh(
new THREE.RingGeometry(0.19, 0.27, 32),
new THREE.MeshBasicMaterial({
color: 0x344149,
transparent: true,
opacity: 0.12,
side: THREE.DoubleSide
})
);
routeShadow.rotation.x = -Math.PI / 2;
world.add(routeShadow);
// -------------------------------------------------------------------------
// Location cards
// -------------------------------------------------------------------------
function createLocationCard(title, accent, number, x) {
const group = new THREE.Group();
group.position.set(x, G, 2.22);
world.add(group);
// Stand.
addCylinder(
group,
0.055,
0.075,
1.12,
[0, 0.56, -0.04],
M.ink,
14
);
addBox(
group,
[0.68, 0.08, 0.40],
[0, 0.06, 0.03],
M.ink
);
// White card frame.
addBox(
group,
[2.38, 1.50, 0.10],
[0, 1.43, 0],
M.white
);
// Printed card surface.
const card = new THREE.Mesh(
new THREE.PlaneGeometry(2.24, 1.40),
new THREE.MeshBasicMaterial({
map: makeCardTexture(title, accent, number),
toneMapped: false
})
);
card.position.set(0, 1.43, 0.057);
group.add(card);
// Small matching token mounted at the foot of the card.
const token = new THREE.Mesh(
new THREE.CircleGeometry(0.18, 40),
new THREE.MeshBasicMaterial({
map: symbolTexture,
transparent: true,
side: THREE.DoubleSide,
toneMapped: false
})
);
token.position.set(-0.89, 0.62, 0.09);
group.add(token);
return group;
}
createLocationCard("PLAZA", "#d6a238", "01", -3.35);
createLocationCard("HALL", "#4f83a5", "02", 3.38);
// -------------------------------------------------------------------------
// Shadows and finishing
// -------------------------------------------------------------------------
world.traverse((object) => {
if (object.isMesh && object !== routeToken) {
object.castShadow = true;
object.receiveShadow = true;
}
});
ground.receiveShadow = true;
// -------------------------------------------------------------------------
// Direct camera controls: orbit, wheel zoom, and pinch zoom
// -------------------------------------------------------------------------
const state = {
target: new THREE.Vector3(0, 1.02, 0),
radius: 13.2,
theta: 0.52,
phi: 1.04
};
let transition = null;
const pointers = new Map();
let pinchDistance = 0;
const presets = {
plaza: {
target: new THREE.Vector3(-3.25, 1.12, 0.05),
radius: 8.4,
theta: 0.36,
phi: 1.04
},
hall: {
target: new THREE.Vector3(3.30, 1.15, 0.05),
radius: 8.4,
theta: 0.68,
phi: 1.04
},
all: {
target: new THREE.Vector3(0, 1.02, 0),
radius: 13.2,
theta: 0.52,
phi: 1.04
}
};
function shortestAngleDifference(a, b) {
let difference = b - a;
while (difference > Math.PI) difference -= Math.PI * 2;
while (difference < -Math.PI) difference += Math.PI * 2;
return difference;
}
function focusView(name) {
const preset = presets[name];
transition = {
start: performance.now(),
duration: 760,
from: {
target: state.target.clone(),
radius: state.radius,
theta: state.theta,
phi: state.phi
},
to: {
target: preset.target.clone(),
radius: preset.radius,
theta:
state.theta +
shortestAngleDifference(state.theta, preset.theta),
phi: preset.phi
}
};
document.querySelectorAll("[data-focus]").forEach((button) => {
button.classList.toggle("active", button.dataset.focus === name);
});
}
document.querySelectorAll("[data-focus]").forEach((button) => {
button.addEventListener("click", () => {
focusView(button.dataset.focus);
});
});
function pointerDistance() {
const points = [...pointers.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].clientX - points[1].clientX,
points[0].clientY - points[1].clientY
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
pinchDistance = pointerDistance();
}
transition = null;
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
state.theta -= dx * 0.006;
state.phi = THREE.MathUtils.clamp(
state.phi - dy * 0.005,
0.38,
1.42
);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
} else if (pointers.size === 2) {
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
const distance = pointerDistance();
if (pinchDistance > 0) {
state.radius = THREE.MathUtils.clamp(
state.radius + (pinchDistance - distance) * 0.018,
6.2,
18
);
}
pinchDistance = distance;
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
transition = null;
state.radius = THREE.MathUtils.clamp(
state.radius + event.deltaY * 0.012,
6.2,
18
);
},
{ passive: false }
);
function updateCamera() {
const aspect = window.innerWidth / window.innerHeight;
const mobileFit = Math.max(1, 1.25 / aspect);
const radius = state.radius * mobileFit;
camera.position.set(
state.target.x +
radius * Math.sin(state.phi) * Math.sin(state.theta),
state.target.y + radius * Math.cos(state.phi),
state.target.z +
radius * Math.sin(state.phi) * Math.cos(state.theta)
);
camera.lookAt(state.target);
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate(now) {
requestAnimationFrame(animate);
if (transition) {
const raw = Math.min(
1,
(now - transition.start) / transition.duration
);
const eased = 1 - Math.pow(1 - raw, 3);
state.target.lerpVectors(
transition.from.target,
transition.to.target,
eased
);
state.radius = THREE.MathUtils.lerp(
transition.from.radius,
transition.to.radius,
eased
);
state.theta = THREE.MathUtils.lerp(
transition.from.theta,
transition.to.theta,
eased
);
state.phi = THREE.MathUtils.lerp(
transition.from.phi,
transition.to.phi,
eased
);
if (raw === 1) transition = null;
}
updateCamera();
// The symbol travels repeatedly from the plaza side to the hall side.
const travel = 0.5 - 0.5 * Math.cos(clock.elapsedTime * 0.48);
const routePosition = routeCurve.getPointAt(travel);
routeToken.position.set(
routePosition.x,
0.80 + Math.sin(clock.elapsedTime * 2.2) * 0.035,
routePosition.z
);
routeShadow.position.set(
routePosition.x,
0.445,
routePosition.z
);
renderer.render(scene, camera);
}
resize();
requestAnimationFrame(animate);
</script>
</body>
</html>
```