Prompt specification
Build or customize the Three.js 3D scene "Neighborhood festival relocation story" 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: Neighborhood festival relocation story
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-festival-relocation-story-x3859
Scene Description Prompt:
A stylized neighborhood festival moves from a plaza into the adjacent hall; visitors follow updated signs. One HTML file with Three.js from cdnjs.
Working Three.js Starter (neighborhood-festival-relocation-story-x3859):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Neighborhood Days — Festival Route</title>
<style>
:root {
--ink: #173b3d;
--paper: #fffaf0;
--gold: #f2b84b;
--coral: #ef6f61;
--teal: #269f96;
--shadow: rgba(23, 59, 61, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8e5e1;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255, 255, 255, 0.75);
background: rgba(255, 250, 240, 0.9);
box-shadow: 0 12px 35px var(--shadow);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#title-card {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 20px 22px;
border-radius: 22px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: var(--teal);
font-size: 11px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 5px rgba(239, 111, 97, 0.15);
animation: breathe 1.8s ease-in-out infinite;
}
@keyframes breathe {
50% {
box-shadow: 0 0 0 8px rgba(239, 111, 97, 0.04);
}
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 39px);
line-height: 0.98;
letter-spacing: -0.045em;
}
#title-card p {
margin: 10px 0 0;
color: #557071;
font-size: 14px;
line-height: 1.45;
}
#views {
top: 22px;
right: 22px;
display: flex;
gap: 7px;
padding: 8px;
border-radius: 16px;
}
button {
appearance: none;
border: 0;
border-radius: 11px;
padding: 10px 13px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 800;
cursor: pointer;
transition:
background 160ms ease,
color 160ms ease,
transform 160ms ease;
}
button:hover {
background: rgba(38, 159, 150, 0.11);
transform: translateY(-1px);
}
button.active {
background: var(--ink);
color: var(--paper);
}
#route-card {
bottom: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 20px;
border-radius: 20px;
pointer-events: none;
}
#route-card .route-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
#phase-number {
color: var(--coral);
font-size: 11px;
font-weight: 950;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#countdown {
color: #789;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#phase-title {
margin: 0 0 5px;
font-size: 21px;
line-height: 1.05;
letter-spacing: -0.025em;
}
#phase-copy {
margin: 0;
color: #607475;
font-size: 13px;
line-height: 1.4;
}
.progress-track {
height: 5px;
margin-top: 14px;
overflow: hidden;
border-radius: 99px;
background: rgba(23, 59, 61, 0.1);
}
#progress {
width: 0%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
transition: width 120ms linear;
}
#hint {
position: fixed;
z-index: 10;
right: 22px;
bottom: 22px;
padding: 11px 15px;
border-radius: 99px;
color: rgba(23, 59, 61, 0.75);
font-size: 11px;
font-weight: 750;
pointer-events: none;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
background: #d8e5e1;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
.loader {
display: flex;
align-items: center;
gap: 12px;
font-size: 13px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.loader::before {
content: "";
width: 24px;
height: 24px;
border: 3px solid rgba(23, 59, 61, 0.15);
border-top-color: var(--coral);
border-radius: 50%;
animation: spin 700ms linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 720px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 17px;
}
#title-card p {
display: none;
}
#views {
top: 116px;
right: 12px;
flex-direction: column;
}
#route-card {
bottom: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
#hint {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive 3D neighborhood festival"></canvas>
<section id="title-card" class="panel">
<div class="eyebrow">
<span class="live-dot"></span>
Live festival wayfinding
</div>
<h1>Neighborhood Days</h1>
<p>Follow the updated signs from the festival plaza into the neighboring community hall.</p>
</section>
<nav id="views" class="panel" aria-label="Camera views">
<button class="active" data-view="overview">Overview</button>
<button data-view="plaza">Plaza</button>
<button data-view="hall">Hall</button>
<button data-view="route">Route</button>
</nav>
<section id="route-card" class="panel">
<div class="route-top">
<span id="phase-number">Sign 01</span>
<span id="countdown">Next update in 7s</span>
</div>
<h2 id="phase-title">Festival Plaza</h2>
<p id="phase-copy">The community hall opens next.</p>
<div class="progress-track"><div id="progress"></div></div>
</section>
<div id="hint" class="panel">Drag to orbit · Scroll to zoom · Click a sign to update</div>
<div id="loading">
<div class="loader">Building the neighborhood</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
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.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8e5e1");
scene.fog = new THREE.Fog("#d8e5e1", 28, 58);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight("#fff8e8", "#52736d", 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff2d6", 3.1);
sun.position.set(-8, 16, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -24;
sun.shadow.camera.right = 24;
sun.shadow.camera.top = 18;
sun.shadow.camera.bottom = -18;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 50;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#9fd9d4", 0.8);
fill.position.set(14, 8, -10);
scene.add(fill);
const materialCache = new Map();
function mat(color, options = {}) {
const key = color + JSON.stringify(options);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
...options
})
);
}
return materialCache.get(key);
}
function addMesh(parent, geometry, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(parent, w, h, d, color, x = 0, y = 0, z = 0, options = {}) {
return addMesh(
parent,
new THREE.BoxGeometry(w, h, d),
mat(color, options),
x,
y,
z
);
}
function cylinder(
parent,
top,
bottom,
height,
color,
x = 0,
y = 0,
z = 0,
segments = 24,
options = {}
) {
return addMesh(
parent,
new THREE.CylinderGeometry(top, bottom, height, segments),
mat(color, options),
x,
y,
z
);
}
function sphere(parent, radius, color, x = 0, y = 0, z = 0, options = {}) {
return addMesh(
parent,
new THREE.SphereGeometry(radius, 18, 12),
mat(color, options),
x,
y,
z
);
}
function makeCanvasTexture(width, height) {
const c = document.createElement("canvas");
c.width = width;
c.height = height;
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return { canvas: c, context: c.getContext("2d"), texture };
}
function roundedRect(ctx, x, y, w, h, radius) {
const r = Math.min(radius, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
// ---------------------------------------------------------------------
// World and architecture
// ---------------------------------------------------------------------
const world = new THREE.Group();
scene.add(world);
box(world, 28, 0.7, 18, "#789b86", 0, -0.48, 0);
box(world, 27.6, 0.12, 17.6, "#8eae93", 0, -0.08, 0);
// Plaza.
cylinder(world, 6.5, 6.5, 0.2, "#e7d8b8", -6.1, 0.01, 0, 64);
cylinder(world, 5.9, 5.9, 0.05, "#efe2c6", -6.1, 0.13, 0, 64);
// Decorative paving rings.
for (const radius of [2.2, 4.15]) {
const ring = addMesh(
world,
new THREE.RingGeometry(radius - 0.045, radius + 0.045, 96),
mat("#d8c49d"),
-6.1,
0.165,
0
);
ring.rotation.x = -Math.PI / 2;
ring.castShadow = false;
}
// Hall floor and cutaway walls.
box(world, 10, 0.2, 11, "#d9b99a", 7, 0, 0);
box(world, 10, 4.1, 0.3, "#ef9b78", 7, 2.05, -5.5);
box(world, 0.3, 4.1, 11, "#f3b58c", 12, 2.05, 0);
box(world, 0.25, 3.6, 8.4, "#e78f6d", 2, 1.8, -1.25);
// Front columns and exposed roof beams create a readable cutaway.
for (const x of [2, 7, 12]) {
cylinder(world, 0.17, 0.2, 4.25, "#fff0d4", x, 2.12, 5.15, 16);
}
for (const z of [-5.35, 0, 5.15]) {
box(world, 10.3, 0.22, 0.22, "#704d43", 7, 4.2, z);
}
for (const x of [2, 7, 12]) {
box(world, 0.2, 0.2, 10.8, "#704d43", x, 4.2, 0);
}
box(world, 10.3, 0.24, 2.1, "#f6d8a3", 7, 4.35, -4.45);
box(world, 10.3, 0.35, 0.22, "#fff0d4", 7, 4.05, 5.15);
// ---------------------------------------------------------------------
// Hall lettering
// ---------------------------------------------------------------------
function createWallLabel() {
const { canvas: c, context: ctx, texture } = makeCanvasTexture(1024, 256);
ctx.fillStyle = "#fff2d6";
roundedRect(ctx, 0, 0, 1024, 256, 28);
ctx.fill();
ctx.strokeStyle = "#d36f55";
ctx.lineWidth = 14;
ctx.stroke();
ctx.fillStyle = "#d36f55";
ctx.font = "900 30px Arial, sans-serif";
ctx.textAlign = "center";
ctx.fillText("NEIGHBORHOOD DAYS", 512, 58);
ctx.fillStyle = "#24494a";
ctx.font = "900 78px Arial, sans-serif";
ctx.fillText("COMMUNITY HALL", 512, 151);
ctx.font = "700 25px Arial, sans-serif";
ctx.fillStyle = "#6f7770";
ctx.fillText("FOOD • MUSIC • MARKET", 512, 211);
const panel = new THREE.Mesh(
new THREE.PlaneGeometry(7.4, 1.85),
new THREE.MeshBasicMaterial({ map: texture })
);
panel.position.set(7, 2.65, -5.31);
world.add(panel);
}
createWallLabel();
// ---------------------------------------------------------------------
// Trees, fountain, benches and festival booths
// ---------------------------------------------------------------------
function tree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.13, z);
group.scale.setScalar(scale);
world.add(group);
cylinder(group, 0.62, 0.7, 0.34, "#b87c61", 0, 0.17, 0, 18);
cylinder(group, 0.15, 0.22, 1.55, "#815744", 0, 0.98, 0, 12);
const foliage = ["#3d8d69", "#55a977", "#6cba7b"];
sphere(group, 0.92, foliage[0], 0, 2.15, 0);
sphere(group, 0.68, foliage[1], -0.5, 1.95, 0.1);
sphere(group, 0.7, foliage[2], 0.52, 2.02, -0.08);
}
[
[-11.6, -4.7, 1.05],
[-2.1, -5.7, 0.9],
[-11.7, 4.7, 0.9],
[-1.2, 5.8, 0.82],
[13.1, -4.6, 0.9]
].forEach((args) => tree(...args));
function fountain(x, z) {
const group = new THREE.Group();
group.position.set(x, 0.15, z);
world.add(group);
cylinder(group, 1.45, 1.55, 0.28, "#d8c7a5", 0, 0.14, 0, 40);
cylinder(group, 1.25, 1.25, 0.08, "#65b8bd", 0, 0.32, 0, 40);
cylinder(group, 0.28, 0.4, 1.15, "#ddcfb0", 0, 0.85, 0, 24);
cylinder(group, 0.78, 0.42, 0.22, "#e7d8b8", 0, 1.35, 0, 32);
sphere(group, 0.18, "#f3d477", 0, 1.62, 0, {
emissive: "#f3c04b",
emissiveIntensity: 0.25
});
}
fountain(-7.15, -0.35);
function bench(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.14, z);
group.rotation.y = rotation;
world.add(group);
box(group, 2.3, 0.13, 0.55, "#9c624d", 0, 0.52, 0);
box(group, 2.3, 0.55, 0.12, "#a86b51", 0, 0.9, -0.23);
box(group, 0.13, 0.5, 0.45, "#485c55", -0.83, 0.25, 0);
box(group, 0.13, 0.5, 0.45, "#485c55", 0.83, 0.25, 0);
}
bench(-10, 1.4, 0.2);
bench(-4.4, -3.6, -0.2);
bench(10.6, 3.9, Math.PI / 2);
bench(5.1, -4.4, 0);
function booth(x, z, color, title, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0.15, z);
group.rotation.y = rotation;
world.add(group);
box(group, 2.6, 1.05, 1.25, "#f0d8ad", 0, 0.53, 0);
box(group, 2.8, 0.18, 1.4, color, 0, 2.13, 0);
for (const px of [-1.25, 1.25]) {
cylinder(group, 0.06, 0.06, 2.1, "#775044", px, 1.05, -0.5, 10);
cylinder(group, 0.06, 0.06, 2.1, "#775044", px, 1.05, 0.5, 10);
}
for (let i = 0; i < 6; i++) {
const stripe = box(
group,
0.43,
0.08,
1.42,
i % 2 ? "#fff3d7" : color,
-1.05 + i * 0.42,
2.25,
0
);
stripe.rotation.z = 0;
}
const labelTexture = makeCanvasTexture(512, 128);
labelTexture.context.fillStyle = "#fff8e8";
labelTexture.context.fillRect(0, 0, 512, 128);
labelTexture.context.fillStyle = color;
labelTexture.context.font = "900 52px Arial, sans-serif";
labelTexture.context.textAlign = "center";
labelTexture.context.fillText(title, 256, 79);
labelTexture.texture.needsUpdate = true;
const label = new THREE.Mesh(
new THREE.PlaneGeometry(2.25, 0.55),
new THREE.MeshBasicMaterial({ map: labelTexture.texture })
);
label.position.set(0, 1.4, 0.64);
group.add(label);
for (let i = 0; i < 4; i++) {
sphere(group, 0.13, ["#ef6f61", "#f2b84b", "#6bb775"][i % 3],
-0.75 + i * 0.5, 1.28, 0.67);
}
}
booth(-9.3, -4.8, "#ef6f61", "SNACKS", 0.08);
booth(-5.6, -5.4, "#269f96", "BAKERY", -0.05);
booth(10.4, -1.7, "#8c70c6", "CRAFTS", Math.PI / 2);
booth(9.7, 2.6, "#ef9b5b", "FLOWERS", Math.PI / 2);
// Small stage.
box(world, 4.2, 0.42, 2.1, "#a85f50", 8.2, 0.3, -4.15);
box(world, 4.0, 2.5, 0.16, "#264d4c", 8.2, 1.75, -5.18);
box(world, 1.1, 1.1, 0.65, "#243b3d", 6.6, 1.15, -4.25);
box(world, 1.1, 1.1, 0.65, "#243b3d", 9.8, 1.15, -4.25);
// Performer and a simple guitar silhouette.
const performer = new THREE.Group();
performer.position.set(8.2, 0.54, -4.05);
world.add(performer);
cylinder(performer, 0.18, 0.22, 0.62, "#f2b84b", 0, 0.66, 0, 12);
sphere(performer, 0.2, "#d99b76", 0, 1.13, 0);
box(performer, 0.28, 0.55, 0.1, "#8a4f43", 0.2, 0.6, 0.18);
// Cafe tables.
function table(x, z, color) {
cylinder(world, 0.76, 0.76, 0.12, color, x, 0.86, z, 24);
cylinder(world, 0.09, 0.12, 0.78, "#5d6258", x, 0.45, z, 12);
for (let i = 0; i < 3; i++) {
const angle = (i / 3) * Math.PI * 2;
const tx = x + Math.cos(angle) * 1.12;
const tz = z + Math.sin(angle) * 1.12;
cylinder(world, 0.28, 0.28, 0.13, color, tx, 0.5, tz, 16);
cylinder(world, 0.06, 0.08, 0.46, "#5d6258", tx, 0.24, tz, 10);
}
}
table(-10.1, 3.3, "#ef8b74");
table(-3.8, 2.6, "#f2bd58");
// ---------------------------------------------------------------------
// String lights and bunting
// ---------------------------------------------------------------------
function stringLights(a, b, count = 12) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const points = [];
for (let i = 0; i <= 40; i++) {
const t = i / 40;
const p = start.clone().lerp(end, t);
p.y -= Math.sin(t * Math.PI) * 0.9;
points.push(p);
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.Line(
geometry,
new THREE.LineBasicMaterial({ color: "#4a514b" })
);
world.add(line);
const bulbMaterial = mat("#ffe58a", {
emissive: "#ffc84c",
emissiveIntensity: 1.6,
roughness: 0.35
});
for (let i = 1; i < count; i++) {
const t = i / count;
const p = start.clone().lerp(end, t);
p.y -= Math.sin(t * Math.PI) * 0.9;
addMesh(world, new THREE.SphereGeometry(0.105, 10, 8), bulbMaterial,
p.x, p.y - 0.12, p.z);
}
}
stringLights([-11.7, 3.7, -4.9], [-1.3, 3.7, -4.9], 13);
stringLights([-11.7, 3.7, 4.9], [-1.3, 3.7, 4.9], 13);
stringLights([2.1, 3.75, 3.8], [11.8, 3.75, 3.8], 14);
function bunting(a, b, count = 12) {
const colors = ["#ef6f61", "#f2b84b", "#269f96", "#8c70c6"];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(
[-0.2, 0, 0, 0.2, 0, 0, 0, -0.42, 0],
3
)
);
geometry.computeVertexNormals();
for (let i = 0; i < count; i++) {
const t = (i + 0.5) / count;
const x = a[0] + (b[0] - a[0]) * t;
const z = a[2] + (b[2] - a[2]) * t;
const y = a[1] + (b[1] - a[1]) * t - Math.sin(t * Math.PI) * 0.4;
const flag = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({
color: colors[i % colors.length],
side: THREE.DoubleSide
})
);
flag.position.set(x, y, z);
flag.rotation.y = Math.atan2(b[0] - a[0], b[2] - a[2]);
world.add(flag);
}
}
bunting([2, 3.85, 4.9], [11.8, 3.85, 4.9], 15);
bunting([2.2, 3.9, -4.8], [11.8, 3.9, -4.8], 15);
// ---------------------------------------------------------------------
// Visitor route, stepping stones and animated direction arrows
// ---------------------------------------------------------------------
const route = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(-10.2, 0, 2.0),
new THREE.Vector3(-8.1, 0, 2.7),
new THREE.Vector3(-5.5, 0, 2.7),
new THREE.Vector3(-2.6, 0, 1.9),
new THREE.Vector3(-0.1, 0, 3.5),
new THREE.Vector3(2.25, 0, 5.0),
new THREE.Vector3(4.1, 0, 4.05),
new THREE.Vector3(6.2, 0, 2.5),
new THREE.Vector3(8.2, 0, 1.25)
],
false,
"catmullrom",
0.45
);
for (let i = 0; i < 18; i++) {
const t = 0.06 + (i / 17) * 0.84;
const p = route.getPointAt(t);
const tangent = route.getTangentAt(t);
const stone = box(
world,
0.9,
0.055,
1.1,
i % 2 ? "#d8c397" : "#e8d6aa",
p.x,
0.17,
p.z
);
stone.rotation.y = -Math.atan2(tangent.z, tangent.x);
}
const arrowShape = new THREE.Shape();
arrowShape.moveTo(-0.5, -0.18);
arrowShape.lineTo(0.08, -0.18);
arrowShape.lineTo(0.08, -0.46);
arrowShape.lineTo(0.66, 0);
arrowShape.lineTo(0.08, 0.46);
arrowShape.lineTo(0.08, 0.18);
arrowShape.lineTo(-0.5, 0.18);
arrowShape.closePath();
const arrowGeometry = new THREE.ShapeGeometry(arrowShape);
arrowGeometry.rotateX(-Math.PI / 2);
const routeArrows = [];
for (let i = 0; i < 11; i++) {
const t = 0.24 + (i / 10) * 0.66;
const p = route.getPointAt(t);
const tangent = route.getTangentAt(t).normalize();
const arrow = new THREE.Mesh(
arrowGeometry,
new THREE.MeshStandardMaterial({
color: "#f2b84b",
emissive: "#f2a932",
emissiveIntensity: 0.35,
roughness: 0.55,
side: THREE.DoubleSide
})
);
arrow.position.set(p.x, 0.225, p.z);
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(tangent.x, 0, tangent.z).normalize()
);
arrow.castShadow = false;
world.add(arrow);
routeArrows.push(arrow);
}
// ---------------------------------------------------------------------
// Changeable wayfinding signs
// ---------------------------------------------------------------------
const stages = [
{
number: "01",
label: "PLAZA OPEN",
title: "FESTIVAL PLAZA",
sub: "The community hall opens next.",
accent: "#ef6f61",
flow: 0.2
},
{
number: "02",
label: "LIVE PROGRAM",
title: "MUSIC IN THE HALL",
sub: "Follow the golden arrows.",
accent: "#e5a936",
flow: 0.82
},
{
number: "03",
label: "MARKET TIME",
title: "ENTER THE MARKET HALL",
sub: "Shop, taste and meet your neighbors.",
accent: "#269f96",
flow: 1.15
},
{
number: "04",
label: "NOW BOARDING",
title: "THE HALL IS OPEN",
sub: "Everyone is welcome inside.",
accent: "#8c70c6",
flow: 0.96
}
];
const signs = [];
const clickableSigns = [];
function drawSign(sign, stage) {
const { canvas: c, context: ctx, texture } = sign;
ctx.clearRect(0, 0, c.width, c.height);
ctx.fillStyle = "#fffaf0";
roundedRect(ctx, 0, 0, c.width, c.height, 34);
ctx.fill();
ctx.strokeStyle = stage.accent;
ctx.lineWidth = 16;
ctx.stroke();
ctx.fillStyle = stage.accent;
ctx.font = "900 29px Arial, sans-serif";
ctx.textAlign = "left";
ctx.fillText(`LIVE WAYFINDING • ${stage.label}`, 62, 61);
ctx.fillStyle = "#173b3d";
ctx.font = "900 54px Arial, sans-serif";
ctx.fillText(stage.title, 60, 178, 760);
ctx.fillStyle = "#667a77";
ctx.font = "700 32px Arial, sans-serif";
ctx.fillText(stage.sub, 62, 260, 760);
// Large right-facing arrow.
ctx.strokeStyle = stage.accent;
ctx.fillStyle = stage.accent;
ctx.lineWidth = 24;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.beginPath();
ctx.moveTo(832, 130);
ctx.lineTo(932, 190);
ctx.lineTo(832, 250);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(790, 190);
ctx.lineTo(932, 190);
ctx.stroke();
texture.needsUpdate = true;
}
function makeSign(x, z, rotation, width = 4.15) {
const group = new THREE.Group();
group.position.set(x, 0.14, z);
group.rotation.y = rotation;
world.add(group);
for (const px of [-width * 0.34, width * 0.34]) {
cylinder(group, 0.075, 0.09, 2.55, "#4b625d", px, 1.25, 0, 12);
sphere(group, 0.11, "#f2b84b", px, 2.58, 0);
}
const boardGroup = new THREE.Group();
boardGroup.position.y = 2.65;
group.add(boardGroup);
const frame = box(boardGroup, width, 1.58, 0.17, "#ef6f61", 0, 0, 0);
const signData = makeCanvasTexture(1024, 384);
const panel = new THREE.Mesh(
new THREE.PlaneGeometry(width - 0.18, 1.39),
new THREE.MeshBasicMaterial({ map: signData.texture })
);
panel.position.z = 0.091;
panel.userData.isSign = true;
boardGroup.add(panel);
clickableSigns.push(panel);
const sign = {
group,
boardGroup,
frame,
...signData,
pulse: 0
};
signs.push(sign);
return sign;
}
makeSign(-3.05, 3.55, 0.2, 4.15);
makeSign(0.35, 5.55, -0.08, 4.0);
// ---------------------------------------------------------------------
// Stylized visitors
// ---------------------------------------------------------------------
const skinColors = ["#e0a27f", "#bd795e", "#f1c39e", "#8e5a47"];
const shirtColors = [
"#ef6f61",
"#f2b84b",
"#269f96",
"#8c70c6",
"#497f9f",
"#f28e77",
"#5da765",
"#fff0cf"
];
const headGeometry = new THREE.SphereGeometry(0.22, 14, 10);
const bodyGeometry = new THREE.CylinderGeometry(0.24, 0.29, 0.65, 10);
const legGeometry = new THREE.CylinderGeometry(0.075, 0.085, 0.48, 8);
const armGeometry = new THREE.CylinderGeometry(0.06, 0.07, 0.46, 8);
const hairGeometry = new THREE.SphereGeometry(
0.225,
14,
8,
0,
Math.PI * 2,
0,
Math.PI / 2
);
const visitors = [];
function makeVisitor(shirtColor, skinColor, isRouteVisitor = false) {
const group = new THREE.Group();
world.add(group);
const body = new THREE.Mesh(bodyGeometry, mat(shirtColor));
body.position.y = 0.86;
body.castShadow = true;
group.add(body);
const head = new THREE.Mesh(headGeometry, mat(skinColor));
head.position.y = 1.4;
head.castShadow = true;
group.add(head);
const hair = new THREE.Mesh(
hairGeometry,
mat(Math.random() > 0.5 ? "#3d302c" : "#76513d")
);
hair.position.y = 1.4;
hair.castShadow = true;
group.add(hair);
const nose = new THREE.Mesh(
new THREE.SphereGeometry(0.038, 8, 6),
mat(skinColor)
);
nose.position.set(0, 1.39, 0.215);
group.add(nose);
const eyeMaterial = mat("#283536");
for (const ex of [-0.073, 0.073]) {
const eye = new THREE.Mesh(
new THREE.SphereGeometry(0.018, 7, 5),
eyeMaterial
);
eye.position.set(ex, 1.445, 0.197);
group.add(eye);
}
const legs = [];
for (const lx of [-0.105, 0.105]) {
const pivot = new THREE.Group();
pivot.position.set(lx, 0.53, 0);
group.add(pivot);
const leg = new THREE.Mesh(legGeometry, mat("#40585b"));
leg.position.y = -0.24;
leg.castShadow = true;
pivot.add(leg);
legs.push(pivot);
}
const arms = [];
for (const ax of [-0.29, 0.29]) {
const pivot = new THREE.Group();
pivot.position.set(ax, 1.08, 0);
group.add(pivot);
const arm = new THREE.Mesh(armGeometry, mat(skinColor));
arm.position.y = -0.23;
arm.castShadow = true;
pivot.add(arm);
arms.push(pivot);
}
if (Math.random() > 0.55) {
const bag = box(
group,
0.28,
0.32,
0.14,
Math.random() > 0.5 ? "#f2b84b" : "#269f96",
0.37,
0.73,
0
);
bag.rotation.z = -0.08;
}
const visitor = {
group,
legs,
arms,
route: isRouteVisitor,
progress: Math.random(),
lateral: (Math.random() - 0.5) * 0.58,
phase: Math.random() * Math.PI * 2,
speed: 0.85 + Math.random() * 0.35
};
visitors.push(visitor);
return visitor;
}
for (let i = 0; i < 27; i++) {
makeVisitor(
shirtColors[i % shirtColors.length],
skinColors[i % skinColors.length],
true
);
}
const staticVisitors = [
[-9.5, -2.9],
[-6.2, -3.2],
[-3.4, -1.9],
[-10.2, 0.2],
[-4.6, -4.4],
[-6.5, 4.1],
[4.8, -1.2],
[7.8, -1.8],
[10.2, 1.0],
[4.3, 3.0],
[7.3, 3.7]
];
staticVisitors.forEach(([x, z], index) => {
const visitor = makeVisitor(
shirtColors[(index + 3) % shirtColors.length],
skinColors[index % skinColors.length],
false
);
visitor.group.position.set(x, 0.15, z);
visitor.group.rotation.y = Math.random() * Math.PI * 2;
visitor.baseY = 0.15;
});
// ---------------------------------------------------------------------
// UI and changing signs
// ---------------------------------------------------------------------
const phaseNumber = document.querySelector("#phase-number");
const phaseTitle = document.querySelector("#phase-title");
const phaseCopy = document.querySelector("#phase-copy");
const countdown = document.querySelector("#countdown");
const progressBar = document.querySelector("#progress");
let stageIndex = 0;
let stageElapsed = 0;
const stageDuration = 7;
function applyStage(index) {
stageIndex = index % stages.length;
stageElapsed = 0;
const stage = stages[stageIndex];
signs.forEach((sign) => {
drawSign(sign, stage);
sign.frame.material.color.set(stage.accent);
sign.pulse = 1;
});
phaseNumber.textContent = `Sign ${stage.number}`;
phaseTitle.textContent = stage.title;
phaseCopy.textContent = stage.sub;
}
applyStage(0);
// ---------------------------------------------------------------------
// Custom orbit controls, camera presets and sign clicking
// ---------------------------------------------------------------------
const cameraState = {
radius: 27,
theta: 0.7,
phi: 0.75,
target: new THREE.Vector3(0, 0.5, 0)
};
let cameraTween = null;
let pointerDown = false;
let pointerMoved = 0;
let previousPointer = { x: 0, y: 0 };
const viewPresets = {
overview: {
radius: 27,
theta: 0.7,
phi: 0.75,
target: new THREE.Vector3(0, 0.5, 0)
},
plaza: {
radius: 13.5,
theta: 0.75,
phi: 0.78,
target: new THREE.Vector3(-6.3, 0.7, 0)
},
hall: {
radius: 15,
theta: 0.62,
phi: 0.76,
target: new THREE.Vector3(7.1, 0.8, -0.2)
},
route: {
radius: 18.5,
theta: 0.56,
phi: 0.86,
target: new THREE.Vector3(-0.2, 0.5, 3.0)
}
};
function shortestAngleDifference(from, to) {
let difference = (to - from) % (Math.PI * 2);
if (difference > Math.PI) difference -= Math.PI * 2;
if (difference < -Math.PI) difference += Math.PI * 2;
return difference;
}
function goToView(name) {
const preset = viewPresets[name];
if (!preset) return;
cameraTween = {
elapsed: 0,
duration: 1.15,
startRadius: cameraState.radius,
endRadius: preset.radius,
startTheta: cameraState.theta,
endTheta: cameraState.theta +
shortestAngleDifference(cameraState.theta, preset.theta),
startPhi: cameraState.phi,
endPhi: preset.phi,
startTarget: cameraState.target.clone(),
endTarget: preset.target.clone()
};
document.querySelectorAll("#views button").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll("#views button").forEach((button) => {
button.addEventListener("click", () => goToView(button.dataset.view));
});
function updateCamera(dt) {
if (cameraTween) {
cameraTween.elapsed += dt;
const raw = Math.min(cameraTween.elapsed / cameraTween.duration, 1);
const eased = raw < 0.5
? 4 * raw * raw * raw
: 1 - Math.pow(-2 * raw + 2, 3) / 2;
cameraState.radius = THREE.MathUtils.lerp(
cameraTween.startRadius, cameraTween.endRadius,
eased
);
cameraState.theta = THREE.MathUtils.lerp(
cameraTween.startTheta, cameraTween.endTheta,
eased
);
cameraState.phi = THREE.MathUtils.lerp(
cameraTween.startPhi, cameraTween.endPhi,
eased
);
cameraState.target.lerpVectors(
cameraTween.startTarget, cameraTween.endTarget,
eased
);
if (raw === 1) cameraTween = null;
}
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
canvas.addEventListener("pointerdown", (event) => {
pointerDown = true;
pointerMoved = 0;
previousPointer = { x: event.clientX, y: event.clientY };
cameraTween = null;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerDown) return;
const dx = event.clientX - previousPointer.x;
const dy = event.clientY - previousPointer.y;
pointerMoved += Math.abs(dx) + Math.abs(dy);
previousPointer = { x: event.clientX, y: event.clientY };
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.005,
0.35,
1.35
);
});
canvas.addEventListener("pointerup", (event) => {
pointerDown = false;
canvas.style.cursor = "grab";
if (pointerMoved < 7) {
const pointer = new THREE.Vector2(
(event.clientX / window.innerWidth) * 2 - 1,
-(event.clientY / window.innerHeight) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(clickableSigns, false)[0];
if (hit) {
applyStage(stageIndex + 1);
}
}
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
canvas.style.cursor = "grab";
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.018,
10,
38
);
},
{ passive: false }
);
canvas.style.cursor = "grab";
// ---------------------------------------------------------------------
// Animation loop
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
const routePoint = new THREE.Vector3();
const routeTangent = new THREE.Vector3();
const lateralOffset = new THREE.Vector3();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
stageElapsed += dt;
if (stageElapsed >= stageDuration) {
applyStage(stageIndex + 1);
}
const stage = stages[stageIndex];
const flow = stage.flow;
// Signs gently acknowledge each update.
signs.forEach((sign, index) => {
sign.pulse = Math.max(0, sign.pulse - dt * 1.8);
const bounce = Math.sin(sign.pulse * Math.PI * 4) * sign.pulse;
sign.boardGroup.scale.set(
1 + bounce * 0.025,
1 + bounce * 0.055,
1
);
sign.boardGroup.rotation.z = bounce * 0.015;
});
// Moving visitors accelerate when the signs change.
visitors.forEach((visitor) => {
const walk = Math.sin(elapsed * 7 * visitor.speed + visitor.phase);
if (visitor.route) {
visitor.progress += dt * 0.006 * flow * visitor.speed;
if (visitor.progress >= 1) visitor.progress -= 1;
route.getPointAt(visitor.progress, routePoint);
route.getTangentAt(visitor.progress, routeTangent).normalize();
lateralOffset.set(routeTangent.z, 0, -routeTangent.x)
.multiplyScalar(visitor.lateral);
visitor.group.position.copy(routePoint).add(lateralOffset);
visitor.group.position.y =
0.17 + Math.abs(walk) * 0.026;
visitor.group.rotation.y = Math.atan2(
routeTangent.x,
routeTangent.z
);
const appearIn = THREE.MathUtils.clamp(
visitor.progress / 0.045,
0,
1
);
const appearOut = THREE.MathUtils.clamp(
(1 - visitor.progress) / 0.045,
0,
1
);
visitor.group.scale.setScalar(
Math.min(appearIn, appearOut)
);
} else {
visitor.group.position.y =
visitor.baseY + Math.abs(Math.sin(elapsed * 1.5 + visitor.phase)) * 0.012;
}
visitor.legs[0].rotation.x = walk * 0.5 * (visitor.route ? 1 : 0.08);
visitor.legs[1].rotation.x = -walk * 0.5 * (visitor.route ? 1 : 0.08);
visitor.arms[0].rotation.x = -walk * 0.35 * (visitor.route ? 1 : 0.08);
visitor.arms[1].rotation.x = walk * 0.35 * (visitor.route ? 1 : 0.08);
});
// Floor arrows pulse and travel visually along the route.
routeArrows.forEach((arrow, index) => {
const pulse =
0.35 +
flow * 0.55 +
Math.sin(elapsed * 3.5 - index * 0.65) * 0.22;
arrow.material.emissiveIntensity = Math.max(0.15, pulse);
const scale = 0.94 + Math.sin(elapsed * 3.5 - index * 0.65) * 0.06;
arrow.scale.set(scale, scale, scale);
});
// Fountain water shimmer.
const fountainWater = world.children.find(
(child) => child.type === "Group" && child.children.length === 6
);
if (fountainWater) {
fountainWater.rotation.y = Math.sin(elapsed * 0.18) * 0.03;
}
countdown.textContent = `Next update in ${Math.max(
0,
Math.ceil(stageDuration - stageElapsed)
)}s`;
progressBar.style.width =
`${Math.min(100, (stageElapsed / stageDuration) * 100)}%`;
updateCamera(dt);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera(0);
renderer.render(scene, camera);
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
animate();
</script>
</body>
</html>
```