Prompt specification
Build or customize the Three.js 3D scene "Garden wedding setup and arrival" 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: Garden wedding setup and arrival
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/garden-wedding-setup-and-arrival-x3919
Scene Description Prompt:
A stylized garden wedding moves from arranging chairs, flowers, and musicians to guests arriving. Three.js from cdnjs, one HTML file.
Working Three.js Starter (garden-wedding-setup-and-arrival-x3919):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Willow & Bloom — A Garden Wedding</title>
<style>
:root {
--ink: #263b35;
--cream: #fffaf0;
--gold: #d9b77a;
--rose: #d98d91;
--glass: rgba(255, 250, 240, 0.78);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8e7;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(180deg, rgba(31, 52, 46, 0.08), transparent 25%),
radial-gradient(circle at center, transparent 52%, rgba(31, 52, 46, 0.18));
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
header {
position: absolute;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
padding: clamp(20px, 4vw, 52px);
}
.brand {
max-width: 440px;
text-shadow: 0 1px 15px rgba(255, 255, 255, 0.5);
}
.eyebrow {
margin: 0 0 8px;
color: #547065;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.24em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(36px, 5.4vw, 72px);
font-weight: 400;
line-height: 0.9;
letter-spacing: -0.045em;
}
.brand p {
margin: 13px 0 0;
color: #4b625a;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
letter-spacing: 0.06em;
}
.chapter {
width: min(330px, 35vw);
padding: 20px 22px;
border: 1px solid rgba(255, 255, 255, 0.52);
border-radius: 18px;
background: var(--glass);
box-shadow: 0 16px 50px rgba(50, 72, 63, 0.12);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#chapterNumber {
color: #9f6d70;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.2em;
}
.chapter h2 {
margin: 7px 0 8px;
font-size: clamp(22px, 2.4vw, 32px);
font-weight: 400;
line-height: 1;
}
.chapter p {
margin: 0;
color: #5b6d66;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 1.55;
}
.hint {
position: absolute;
right: clamp(20px, 4vw, 52px);
bottom: 156px;
color: rgba(38, 59, 53, 0.68);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.transport {
position: absolute;
left: 50%;
bottom: clamp(16px, 3vw, 34px);
width: min(980px, calc(100vw - 32px));
transform: translateX(-50%);
padding: 14px 18px 15px;
border: 1px solid rgba(255, 255, 255, 0.56);
border-radius: 20px;
background: rgba(255, 250, 240, 0.84);
box-shadow: 0 18px 60px rgba(45, 68, 58, 0.18);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
pointer-events: auto;
}
.transport-top {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 12px;
}
.play,
.replay {
flex: 0 0 auto;
height: 34px;
border: 0;
border-radius: 999px;
cursor: pointer;
color: var(--cream);
background: var(--ink);
transition: transform 0.2s ease, background 0.2s ease;
}
.play {
min-width: 78px;
padding: 0 16px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.replay {
width: 34px;
color: var(--ink);
background: transparent;
border: 1px solid rgba(38, 59, 53, 0.18);
font-size: 18px;
}
.play:hover,
.replay:hover {
transform: translateY(-1px);
background: #3d5a50;
}
.replay:hover {
color: var(--ink);
background: rgba(38, 59, 53, 0.08);
}
.progress {
position: relative;
flex: 1;
height: 3px;
overflow: hidden;
border-radius: 999px;
background: rgba(38, 59, 53, 0.12);
}
#progressFill {
position: absolute;
inset: 0 auto 0 0;
width: 0;
border-radius: inherit;
background: linear-gradient(90deg, #789789, var(--rose));
}
#time {
min-width: 76px;
color: #61736b;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
text-align: right;
letter-spacing: 0.08em;
}
.timeline {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}
.moment {
position: relative;
min-height: 54px;
padding: 10px 12px;
border: 0;
border-radius: 12px;
text-align: left;
color: #718078;
background: transparent;
cursor: pointer;
transition: color 0.25s ease, background 0.25s ease;
}
.moment:hover {
color: var(--ink);
background: rgba(38, 59, 53, 0.05);
}
.moment.active {
color: var(--ink);
background: rgba(217, 141, 145, 0.12);
}
.moment span {
display: block;
margin-bottom: 3px;
color: #ad7b7e;
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.16em;
}
.moment strong {
font-size: 15px;
font-weight: 400;
}
@media (max-width: 700px) {
header {
padding: 18px;
}
.brand p,
.hint {
display: none;
}
.brand h1 {
font-size: 38px;
}
.chapter {
width: 44vw;
min-width: 150px;
padding: 14px;
border-radius: 14px;
}
.chapter h2 {
font-size: 20px;
}
.chapter p {
display: none;
}
.transport {
padding: 11px;
}
.moment {
min-height: 47px;
padding: 8px 5px;
text-align: center;
}
.moment strong {
font-size: 12px;
}
.moment span {
font-size: 8px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive stylized garden wedding scene"></canvas>
<div class="vignette"></div>
<div class="ui">
<header>
<div class="brand">
<p class="eyebrow">Garden stories · No. 01</p>
<h1>Willow & Bloom</h1>
<p>An afternoon in four little moments</p>
</div>
<section class="chapter" aria-live="polite">
<span id="chapterNumber">01 / 04</span>
<h2 id="chapterTitle">Making room</h2>
<p id="chapterCopy">Chairs find their places along the garden aisle.</p>
</section>
</header>
<div class="hint">Drag to look around · Scroll to zoom</div>
<section class="transport" aria-label="Wedding story controls">
<div class="transport-top">
<button class="play" id="playButton" type="button">Pause</button>
<button class="replay" id="replayButton" type="button" aria-label="Replay story">↻</button>
<div class="progress"><i id="progressFill"></i></div>
<span id="time">0:00 / 0:32</span>
</div>
<nav class="timeline" aria-label="Story chapters">
<button class="moment active" data-phase="0" type="button">
<span>01</span><strong>Chairs</strong>
</button>
<button class="moment" data-phase="1" type="button">
<span>02</span><strong>Flowers</strong>
</button>
<button class="moment" data-phase="2" type="button">
<span>03</span><strong>Music</strong>
</button>
<button class="moment" data-phase="3" type="button">
<span>04</span><strong>Guests</strong>
</button>
</nav>
</section>
</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, camera
// -------------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce8e7);
scene.fog = new THREE.Fog(0xdce8e7, 27, 62);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xf5fbff, 0x738b58, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffedcb, 3.25);
sun.position.set(-12, 20, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -22;
sun.shadow.camera.right = 22;
sun.shadow.camera.top = 22;
sun.shadow.camera.bottom = -22;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.00025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbdd9dd, 0.75);
fill.position.set(15, 8, -12);
scene.add(fill);
// Shared geometries keep the scene lightweight.
const geometry = {
box: new THREE.BoxGeometry(1, 1, 1),
sphere: new THREE.IcosahedronGeometry(1, 1),
cylinder: new THREE.CylinderGeometry(1, 1, 1, 12),
cone: new THREE.ConeGeometry(1, 1, 9),
petal: new THREE.IcosahedronGeometry(1, 0)
};
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
}
function mesh(parent, geo, mat, position, scale, rotation) {
const object = new THREE.Mesh(geo, mat);
if (position) object.position.set(...position);
if (scale) object.scale.set(...scale);
if (rotation) object.rotation.set(...rotation);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
let seed = 8417;
function random() {
seed = (seed * 1664525 + 1013904223) >>> 0;
return seed / 4294967296;
}
function range(min, max) {
return min + (max - min) * random();
}
function clamp(value, min = 0, max = 1) {
return Math.min(max, Math.max(min, value));
}
function smooth01(value) {
const x = clamp(value);
return x * x * (3 - 2 * x);
}
function smoothRange(value, min, max) {
return smooth01((value - min) / (max - min));
}
// -------------------------------------------------------------------------
// Garden landscape
// -------------------------------------------------------------------------
const lawnMaterial = material(0x8fae72);
const lawnLight = material(0x9bb77c);
const lawnDark = material(0x789b65);
const lawn = mesh(
scene,
new THREE.CircleGeometry(34, 96),
lawnMaterial,
[0, -0.08, 0],
null,
[-Math.PI / 2, 0, 0]
);
mesh(
scene,
new THREE.CircleGeometry(14, 64),
lawnLight,
[-10, -0.065, 6],
[1.2, 0.65, 1],
[-Math.PI / 2, 0, 0]
);
mesh(
scene,
new THREE.CircleGeometry(15, 64),
lawnDark,
[12, -0.06, -3],
[1.25, 0.75, 1],
[-Math.PI / 2, 0, 0]
);
const aisleMaterial = material(0xe7d4b5);
const runnerMaterial = material(0xf5ead5);
mesh(scene, geometry.box, aisleMaterial, [0, -0.015, 1], [2.55, 0.09, 25]);
const runner = mesh(
scene,
geometry.box,
runnerMaterial,
[0, 0.04, 1.7],
[1.72, 0.025, 20.5]
);
runner.castShadow = false;
const stoneMaterial = material(0xb9aa91);
for (let z = -8; z <= 11; z += 1.55) {
for (const side of [-1, 1]) {
const stone = mesh(
scene,
geometry.sphere,
stoneMaterial,
[side * 1.43, 0.05, z],
[0.24, 0.075, 0.31],
[0, range(-0.25, 0.25), 0]
);
stone.castShadow = false;
}
}
const trunkMaterial = material(0x79583e);
const leafMaterials = [
material(0x557d50),
material(0x6d925a),
material(0x789f62)
];
function createTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
mesh(tree, geometry.cylinder, trunkMaterial, [0, 1.65, 0], [0.22, 3.3, 0.22]);
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2;
mesh(
tree,
geometry.sphere,
leafMaterials[i % leafMaterials.length],
[
Math.cos(angle) * 0.65,
3.25 + range(-0.2, 0.35),
Math.sin(angle) * 0.65
],
[range(1.25, 1.65), range(1.2, 1.6), range(1.2, 1.6)]
);
}
scene.add(tree);
}
[
[-13, -9, 1.2], [-15, 3, 1.35], [-12, 12, 1.1],
[13, -10, 1.25], [15, 2, 1.4], [12, 12, 1.15],
[-18, -17, 1.35], [18, -17, 1.3], [-20, 15, 1.15],
[20, 16, 1.2]
].forEach(([x, z, s]) => createTree(x, z, s));
const hedgeMaterials = [
material(0x54784a),
material(0x638653),
material(0x73945c)
];
for (const side of [-1, 1]) {
for (let z = -12; z <= 14; z += 1.15) {
const hedge = mesh(
scene,
geometry.sphere,
hedgeMaterials[Math.floor(random() * hedgeMaterials.length)],
[side * range(9.5, 10.4), range(0.35, 0.55), z],
[range(0.65, 0.95), range(0.55, 0.8), range(0.8, 1.15)]
);
hedge.rotation.y = range(0, Math.PI);
}
}
// Ceremony stage.
const stageMaterial = material(0xb9976a);
const stageCloth = material(0xefe2c9);
mesh(scene, geometry.box, stageMaterial, [0, 0.22, -10.5], [10.5, 0.44, 4.1]);
mesh(scene, geometry.box, stageCloth, [0, 0.46, -10.45], [9.8, 0.05, 3.55]);
// Floral ceremony arch.
const archMaterial = material(0xf1dfbd);
const archAccent = material(0xc6a96c);
mesh(scene, geometry.cylinder, archMaterial, [-2.85, 2.18, -8.9], [0.13, 4.36, 0.13]);
mesh(scene, geometry.cylinder, archMaterial, [2.85, 2.18, -8.9], [0.13, 4.36, 0.13]);
const archTop = mesh(
scene,
new THREE.TorusGeometry(2.85, 0.13, 10, 64, Math.PI),
archMaterial,
[0, 4.36, -8.9]
);
for (const side of [-1, 1]) {
mesh(scene, geometry.box, archAccent, [side * 2.85, 0.12, -8.9], [0.65, 0.18, 0.65]);
mesh(scene, geometry.sphere, archAccent, [side * 2.85, 3.6, -8.73], [0.2, 0.28, 0.2]);
}
// A small reception table off to the side.
const table = new THREE.Group();
table.position.set(8.4, 0, 2);
scene.add(table);
mesh(table, geometry.cylinder, material(0x6d5139), [0, 0.65, 0], [0.17, 1.3, 0.17]);
mesh(table, geometry.cylinder, material(0xf3e6d0), [0, 1.28, 0], [1.15, 0.08, 1.15]);
mesh(table, geometry.cylinder, material(0xd8c7a7), [0, 0.76, 0], [0.62, 0.72, 0.62]);
// -------------------------------------------------------------------------
// Flowers
// -------------------------------------------------------------------------
const flowerUnits = [];
const aislePetals = [];
const flowerColors = [
0xeaa3a6, 0xf1c5bd, 0xcf7890, 0xf5dfae, 0xb985a8
];
function flowerHead(color, size = 1) {
const group = new THREE.Group();
const petalMaterial = material(color);
const centerMaterial = material(0xe4b84f);
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
const petal = mesh(
group,
geometry.petal,
petalMaterial,
[Math.cos(angle) * 0.16, 0, Math.sin(angle) * 0.16],
[0.13, 0.055, 0.095],
[0, -angle, 0]
);
petal.castShadow = false;
}
mesh(
group,
geometry.sphere,
centerMaterial,
[0, 0.045, 0],
[0.09, 0.07, 0.09]
);
group.scale.setScalar(size);
return group;
}
function bouquet(color, withPot = false) {
const group = new THREE.Group();
const stemMaterial = material(0x56794c);
if (withPot) {
mesh(group, geometry.cylinder, material(0xc9856c), [0, 0.28, 0], [0.38, 0.56, 0.38]);
mesh(group, geometry.cylinder, material(0x6d8a56), [0, 0.57, 0], [0.33, 0.04, 0.33]);
}
for (let i = 0; i < 5; i++) {
const x = range(-0.32, 0.32);
const z = range(-0.26, 0.26);
const top = withPot ? range(0.78, 1.25) : range(-0.12, 0.18);
const bottom = withPot ? 0.55 : -0.45;
mesh(
group,
geometry.cylinder,
stemMaterial,
[x * 0.45, (top + bottom) * 0.5, z * 0.45],
[0.025, top - bottom, 0.025]
);
const leaf = mesh(
group,
geometry.cone,
stemMaterial,
[x * 0.55, bottom + 0.2, z * 0.55],
[0.11, 0.32, 0.07],
[0, range(0, Math.PI), range(-0.8, 0.8)]
);
leaf.castShadow = false;
const head = flowerHead(i % 3 === 0 ? 0xf4cfba : color, range(0.75, 1.05));
head.position.set(x, top, z);
head.rotation.set(range(-0.35, 0.35), range(0, Math.PI), range(-0.3, 0.3));
group.add(head);
}
group.scale.setScalar(0.001);
return group;
}
for (let i = 0; i < 13; i++) {
const angle = ((i + 0.5) / 13) * Math.PI;
const unit = bouquet(flowerColors[i % flowerColors.length]);
unit.position.set(
Math.cos(angle) * 2.88,
4.37 + Math.sin(angle) * 2.88,
-8.76
);
unit.rotation.z = angle - Math.PI / 2;
unit.userData.delay = i * 0.045;
unit.userData.maxScale = range(0.7, 0.95);
scene.add(unit);
flowerUnits.push(unit);
}
for (const side of [-1, 1]) {
for (let i = 0; i < 3; i++) {
const unit = bouquet(flowerColors[(i + 2) % flowerColors.length]);
unit.position.set(side * 2.82, 0.9 + i * 0.85, -8.7);
unit.userData.delay = 0.1 + i * 0.06;
unit.userData.maxScale = range(0.62, 0.82);
scene.add(unit);
flowerUnits.push(unit);
}
}
for (const side of [-1, 1]) {
const pot = bouquet(0xd98d91, true);
pot.position.set(side * 2.03, 0, -7.4);
pot.userData.delay = 0.2;
pot.userData.maxScale = 1.05;
scene.add(pot);
flowerUnits.push(pot);
}
const petalMaterial = material(0xe7a2a5);
for (let i = 0; i < 26; i++) {
const petal = mesh(
scene,
geometry.petal,
petalMaterial,
[range(-1.05, 1.05), 0.08, range(-7.2, 8.6)],
[range(0.035, 0.065), 0.018, range(0.055, 0.1)],
[0, range(0, Math.PI), 0]
);
petal.castShadow = false;
petal.scale.setScalar(0.001);
aislePetals.push(petal);
}
// -------------------------------------------------------------------------
// String lights
// -------------------------------------------------------------------------
const poleMaterial = material(0x75553d);
const bulbMaterial = material(0xffdda0, {
emissive: 0xffc46d,
emissiveIntensity: 1.6,
roughness: 0.4
});
for (const side of [-1, 1]) {
for (const z of [5, -4]) {
mesh(scene, geometry.cylinder, poleMaterial, [side * 8.4, 2.9, z], [0.075, 5.8, 0.075]);
}
}
function makeLightString(z) {
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-8.4, 5.7, z),
new THREE.Vector3(-4, 4.75, z),
new THREE.Vector3(0, 4.55, z),
new THREE.Vector3(4, 4.75, z),
new THREE.Vector3(8.4, 5.7, z)
]);
const tube = new THREE.Mesh(
new THREE.TubeGeometry(curve, 64, 0.018, 5, false),
material(0x4d4439)
);
scene.add(tube);
for (let i = 1; i < 18; i++) {
const point = curve.getPoint(i / 18);
const bulb = mesh(
scene,
geometry.sphere,
bulbMaterial,
[point.x, point.y - 0.12, point.z],
[0.065, 0.09, 0.065]
);
bulb.castShadow = false;
}
}
makeLightString(5);
makeLightString(-4);
// -------------------------------------------------------------------------
// Chairs
// -------------------------------------------------------------------------
const chairs = [];
const chairFabric = material(0xf4ead7);
const chairFrame = material(0xb89a62);
function createChair(target, delay) {
const group = new THREE.Group();
const targetPosition = target.clone();
const seat = mesh(group, geometry.box, chairFabric, [0, 0.57, 0], [0.72, 0.13, 0.65]);
const back = mesh(group, geometry.box, chairFabric, [0, 1.02, 0.29], [0.68, 0.58, 0.11]);
back.rotation.x = -0.08;
for (const x of [-0.29, 0.29]) {
for (const z of [-0.24, 0.24]) {
mesh(group, geometry.box, chairFrame, [x, 0.28, z], [0.055, 0.56, 0.055]);
}
mesh(group, geometry.box, chairFrame, [x, 1.0, 0.29], [0.045, 0.75, 0.045]);
}
mesh(group, geometry.box, chairFrame, [0, 1.33, 0.29], [0.67, 0.055, 0.055]);
const start = new THREE.Vector3(
targetPosition.x + (targetPosition.x > 0 ? 1 : -1) * range(4.5, 9),
0,
targetPosition.z + range(-3, 3)
);
group.position.copy(start);
group.rotation.y = range(-1.2, 1.2);
group.userData = {
start,
target: targetPosition,
startRotation: group.rotation.y,
targetRotation: range(-0.07, 0.07),
delay
};
scene.add(group);
chairs.push(group);
return group;
}
let chairIndex = 0;
for (let row = 0; row < 5; row++) {
const z = 5.8 - row * 2.7;
for (const side of [-1, 1]) {
for (let seat = 0; seat < 2; seat++) {
const x = side * (3.0 + seat * 1.35);
createChair(
new THREE.Vector3(x, 0, z),
row * 0.085 + seat * 0.035 + (side > 0 ? 0.045 : 0)
);
chairIndex++;
}
}
}
// -------------------------------------------------------------------------
// Stylized people
// -------------------------------------------------------------------------
function createPerson({
shirt = 0xd98d91,
pants = 0x465a62,
skin = 0xd6a17e,
hair = 0x49362e
} = {}) {
const root = new THREE.Group();
const shirtMaterial = material(shirt);
const pantsMaterial = material(pants);
const skinMaterial = material(skin);
const hairMaterial = material(hair);
const shoeMaterial = material(0x40372f);
mesh(root, geometry.cylinder, shirtMaterial, [0, 1.14, 0], [0.29, 0.68, 0.22]);
mesh(root, geometry.cylinder, skinMaterial, [0, 1.52, 0], [0.095, 0.16, 0.095]);
mesh(root, geometry.sphere, skinMaterial, [0, 1.72, 0], [0.235, 0.255, 0.235]);
mesh(root, geometry.sphere, hairMaterial, [0, 1.88, -0.015], [0.25, 0.13, 0.245]);
const arms = [];
for (const side of [-1, 1]) {
const arm = new THREE.Group();
arm.position.set(side * 0.31, 1.38, 0);
mesh(arm, geometry.cylinder, shirtMaterial, [0, -0.19, 0], [0.075, 0.4, 0.075]);
mesh(arm, geometry.sphere, skinMaterial, [0, -0.43, 0], [0.08, 0.095, 0.08]);
root.add(arm);
arms.push(arm);
}
const thighs = [];
const knees = [];
for (const side of [-1, 1]) {
const thigh = new THREE.Group();
thigh.position.set(side * 0.13, 0.78, 0);
mesh(thigh, geometry.cylinder, pantsMaterial, [0, -0.18, 0], [0.09, 0.36, 0.09]);
const knee = new THREE.Group();
knee.position.y = -0.36;
mesh(knee, geometry.cylinder, pantsMaterial, [0, -0.18, 0], [0.08, 0.36, 0.08]);
mesh(knee, geometry.box, shoeMaterial, [0, -0.36, 0.045], [0.16, 0.09, 0.25]);
thigh.add(knee);
root.add(thigh);
thighs.push(thigh);
knees.push(knee);
}
root.userData.parts = { arms, thighs, knees };
return root;
}
// -------------------------------------------------------------------------
// Musicians
// -------------------------------------------------------------------------
const musicians = [];
function createMusician(kind, colors, finalX) {
const person = createPerson(colors);
const instrument = new THREE.Group();
if (kind === "guitar") {
mesh(instrument, geometry.sphere, material(0xa9673f), [0, 1.04, 0.33], [0.31, 0.4, 0.11]);
mesh(instrument, geometry.box, material(0x69412f), [0.19, 1.23, 0.36], [0.11, 0.7, 0.07], [0, 0, -0.58]);
person.userData.parts.arms[0].rotation.z = -0.5;
person.userData.parts.arms[1].rotation.z = 0.65;
}
if (kind === "violin") {
mesh(instrument, geometry.sphere, material(0xbf7445), [0.02, 1.28, 0.31], [0.22, 0.13, 0.08]);
mesh(instrument, geometry.box, material(0x69412f), [0.23, 1.32, 0.31], [0.55, 0.045, 0.045], [0, 0, -0.18]);
mesh(instrument, geometry.box, material(0xe8d3a6), [0.23, 1.23, 0.39], [0.75, 0.015, 0.015], [0, 0, -0.1]);
person.userData.parts.arms[0].rotation.x = -0.9;
person.userData.parts.arms[1].rotation.x = -1.15;
}
if (kind === "drum") {
const drum = mesh(instrument, geometry.cylinder, material(0xb97855), [0, 1.02, 0.47], [0.53, 0.4, 0.53], [Math.PI / 2, 0, 0]);
drum.castShadow = true;
mesh(instrument, geometry.cylinder, material(0xf3e7d0), [0, 1.02, 0.68], [0.48, 0.018, 0.48], [Math.PI / 2, 0, 0]);
mesh(instrument, geometry.box, material(0xe4d0a8), [-0.22, 1.31, 0.55], [0.025, 0.75, 0.025], [0.55, 0, 0.25]);
mesh(instrument, geometry.box, material(0xe4d0a8), [0.22, 1.31, 0.55], [0.025, 0.75, 0.025], [0.55, 0, -0.25]);
person.userData.parts.arms[0].rotation.x = -0.8;
person.userData.parts.arms[1].rotation.x = -0.8;
}
person.add(instrument);
person.position.set(finalX, 0.46, -10.35);
person.scale.setScalar(0.001);
person.visible = false;
person.userData.kind = kind;
person.userData.instrument = instrument;
person.userData.finalX = finalX;
person.userData.offset = kind === "violin" ? 6 : -6;
person.userData.delay = kind === "guitar" ? 0 : kind === "violin" ? 0.18 : 0.36;
scene.add(person);
musicians.push(person);
return person;
}
createMusician("guitar", {
shirt: 0xe9d7bd,
pants: 0x52665b,
skin: 0xc88f69,
hair: 0x392c26
}, -3.05);
createMusician("violin", {
shirt: 0x91a8a3,
pants: 0x384a52,
skin: 0xe0b18e,
hair: 0x72503b
}, 0);
createMusician("drum", {
shirt: 0xc98187,
pants: 0x4a5664,
skin: 0x9e6b4d,
hair: 0x28221f
}, 3.05);
// -------------------------------------------------------------------------
// Guests
// -------------------------------------------------------------------------
const guests = [];
const guestShirts = [
0xd89196, 0xe3b47e, 0x90aaa4, 0xf0e5d4,
0x738ba0, 0xb28ca6, 0xa7b98b, 0xd6a66e
];
const guestPants = [0x445761, 0x626c62, 0x3d4858, 0x756b5b];
const skinTones = [0xe2b18d, 0xc98d67, 0x9b694b, 0x744b37, 0xf0c9a6];
const hairTones = [0x302722, 0x51372a, 0x745139, 0xb18b55, 0xdad2c2];
const guestChairs = chairs.filter((_, index) => index % 2 === 0).slice(0, 24);
guestChairs.forEach((chair, index) => {
const guest = createPerson({
shirt: guestShirts[index % guestShirts.length],
pants: guestPants[index % guestPants.length],
skin: skinTones[index % skinTones.length],
hair: hairTones[index % hairTones.length]
});
const start = new THREE.Vector3(
range(-6.7, 6.7),
0,
range(15.5, 20.5)
);
const target = chair.userData.target.clone();
guest.position.copy(start);
guest.scale.setScalar(0.001);
guest.visible = false;
guest.userData.start = start;
guest.userData.target = target;
guest.userData.delay = (index / guestChairs.length) * 0.28;
guest.userData.arc = (index % 2 === 0 ? 1 : -1) * range(0.6, 2.2);
guest.userData.walkPhase = range(0, Math.PI * 2);
scene.add(guest);
guests.push(guest);
});
// -------------------------------------------------------------------------
// Floating petals
// -------------------------------------------------------------------------
const floatingPetals = [];
const floatingMaterial = material(0xf0b0b4);
for (let i = 0; i < 34; i++) {
const petal = mesh(
scene,
geometry.petal,
floatingMaterial,
[range(-13, 13), range(1, 8), range(-10, 13)],
[range(0.035, 0.065), 0.015, range(0.055, 0.095)],
[range(0, 1), range(0, Math.PI), range(0, 1)]
);
petal.castShadow = false;
petal.userData.speed = range(0.16, 0.38);
petal.userData.phase = range(0, Math.PI * 2);
floatingPetals.push(petal);
}
// -------------------------------------------------------------------------
// Custom camera controls — no addons
// -------------------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1.1, -0.5),
desiredTarget: new THREE.Vector3(0, 1.1, -0.5),
theta: 0.48,
desiredTheta: 0.48,
phi: 1.13,
desiredPhi: 1.13,
radius: 25.5,
desiredRadius: 25.5,
dragging: false,
lastX: 0,
lastY: 0
};
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
controls.desiredTheta -= dx * 0.006;
controls.desiredPhi = clamp(controls.desiredPhi - dy * 0.005, 0.5, 1.42);
});
function releasePointer(event) {
controls.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
controls.desiredRadius = clamp(
controls.desiredRadius + event.deltaY * 0.012,
15,
38
);
}, { passive: false });
// -------------------------------------------------------------------------
// Story timeline
// -------------------------------------------------------------------------
const phaseDurations = [8, 7, 7, 10];
const totalDuration = phaseDurations.reduce((sum, duration) => sum + duration, 0);
const chapters = [
{
title: "Making room",
copy: "Chairs find their places along the garden aisle."
},
{
title: "A little wild",
copy: "Peonies, petals, and color settle into the garden."
},
{
title: "First notes",
copy: "The musicians take the stage as afternoon turns gold."
},
{
title: "Here comes everyone",
copy: "Guests arrive, take their seats, and the day begins."
}
];
let storyTime = 0;
let playing = true;
let currentPhase = 0;
const playButton = document.querySelector("#playButton");
const replayButton = document.querySelector("#replayButton");
const progressFill = document.querySelector("#progressFill");
const timeLabel = document.querySelector("#time");
const chapterNumber = document.querySelector("#chapterNumber");
const chapterTitle = document.querySelector("#chapterTitle");
const chapterCopy = document.querySelector("#chapterCopy");
const phaseButtons = [...document.querySelectorAll(".moment")];
function formatTime(seconds) {
const whole = Math.floor(seconds);
return `0:${String(whole).padStart(2, "0")}`;
}
function updateInterface(phase) {
phaseButtons.forEach((button, index) => {
button.classList.toggle("active", index === phase);
if (index === phase) {
button.setAttribute("aria-current", "step");
} else {
button.removeAttribute("aria-current");
}
});
chapterNumber.textContent = `${String(phase + 1).padStart(2, "0")} / 04`;
chapterTitle.textContent = chapters[phase].title;
chapterCopy.textContent = chapters[phase].copy;
progressFill.style.width = `${clamp(storyTime / totalDuration) * 100}%`;
timeLabel.textContent = `${formatTime(storyTime)} / ${formatTime(totalDuration)}`;
playButton.textContent = playing ? "Pause" : "Play";
}
playButton.addEventListener("click", () => {
if (!playing && storyTime >= totalDuration) storyTime = 0;
playing = !playing;
updateInterface(currentPhase);
});
replayButton.addEventListener("click", () => {
storyTime = 0;
playing = true;
updateInterface(currentPhase);
});
phaseButtons.forEach((button) => {
button.addEventListener("click", () => {
const phase = Number(button.dataset.phase);
const starts = [0, 8, 15, 22];
storyTime = starts[phase] + 0.02;
playing = true;
currentPhase = phase;
updateInterface(phase);
});
});
// -------------------------------------------------------------------------
// Story animation
// -------------------------------------------------------------------------
function updateStory(elapsed) {
const chairProgress = clamp(storyTime / phaseDurations[0]);
const flowerProgress = clamp((storyTime - 8) / phaseDurations[1]);
const musicProgress = clamp((storyTime - 15) / phaseDurations[2]);
const guestProgress = clamp((storyTime - 22) / phaseDurations[3]);
// Chairs are arranged in staggered rows.
for (const chair of chairs) {
const local = clamp(
(chairProgress - chair.userData.delay) /
Math.max(0.001, 1 - chair.userData.delay)
);
const amount = smooth01(local);
chair.position.lerpVectors(
chair.userData.start,
chair.userData.target,
amount
);
chair.rotation.y = THREE.MathUtils.lerp(
chair.userData.startRotation,
chair.userData.targetRotation,
amount
);
}
// Flowers bloom into place.
for (const flower of flowerUnits) {
const local = clamp(
(flowerProgress - flower.userData.delay) /
Math.max(0.001, 1 - flower.userData.delay)
);
const amount = smooth01(local);
const scale = Math.max(0.001, flower.userData.maxScale * amount);
flower.scale.setScalar(scale);
}
for (let i = 0; i < aislePetals.length; i++) {
const local = clamp((flowerProgress - i * 0.018) / 0.62);
const scale = smooth01(local);
const petal = aislePetals[i];
petal.scale.set(
petal.userData.baseX ?? (petal.userData.baseX = petal.scale.x),
petal.userData.baseY ?? (petal.userData.baseY = petal.scale.y),
petal.userData.baseZ ?? (petal.userData.baseZ = petal.scale.z)
);
petal.scale.multiplyScalar(Math.max(0.001, scale));
}
// Musicians enter and begin playing.
musicians.forEach((musician, index) => {
const local = clamp(
(musicProgress - musician.userData.delay) /
Math.max(0.001, 1 - musician.userData.delay)
);
const amount = smooth01(local);
musician.visible = amount > 0.001;
musician.scale.setScalar(Math.max(0.001, amount));
musician.position.x =
musician.userData.finalX +
(1 - amount) * musician.userData.offset;
musician.rotation.z = Math.sin(elapsed * 2.1 + index) * 0.022;
musician.userData.instrument.position.z =
(musician.userData.kind === "drum" ? 0 : 0) +
Math.sin(elapsed * 2.5 + index) * 0.018;
});
// Guests walk in and settle into the chairs.
for (const guest of guests) {
const local = clamp(
(guestProgress - guest.userData.delay) /
Math.max(0.001, 1 - guest.userData.delay)
);
guest.visible = local > 0.001;
if (!guest.visible) continue;
const walk = smooth01(local / 0.72);
const seated = smoothRange(local, 0.66, 0.94);
const walkWeight = 1 - seated;
const swing = Math.sin(elapsed * 7.8 + guest.userData.walkPhase);
const start = guest.userData.start;
const target = guest.userData.target;
guest.position.x =
THREE.MathUtils.lerp(start.x, target.x, walk) +
Math.sin(Math.PI * walk) * guest.userData.arc;
guest.position.z = THREE.MathUtils.lerp(start.z, target.z, walk);
guest.position.y =
Math.abs(swing) * 0.045 * walkWeight - 0.12 * seated;
guest.scale.setScalar(Math.min(1, 0.15 + local * 8));
const parts = guest.userData.parts;
parts.thighs[0].rotation.x = swing * 0.52 * walkWeight + Math.PI / 2 * seated;
parts.thighs[1].rotation.x = -swing * 0.52 * walkWeight + Math.PI / 2 * seated;
parts.knees[0].rotation.x = Math.max(0, -swing) * 0.68 * walkWeight - Math.PI / 2 * seated;
parts.knees[1].rotation.x = Math.max(0, swing) * 0.68 * walkWeight - Math.PI / 2 * seated;
parts.arms[0].rotation.x = -swing * 0.42 * walkWeight - 0.2 * seated;
parts.arms[1].rotation.x = swing * 0.42 * walkWeight - 0.2 * seated;
guest.rotation.z = swing * 0.018 * walkWeight;
}
}
// -------------------------------------------------------------------------
// Animation loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (playing) {
storyTime += delta;
if (storyTime >= totalDuration) {
storyTime = totalDuration;
playing = false;
}
}
const phaseStarts = [0, 8, 15, 22];
let phase = 0;
for (let i = 0; i < phaseStarts.length; i++) {
if (storyTime >= phaseStarts[i]) phase = i;
}
if (phase !== currentPhase) {
currentPhase = phase;
}
updateStory(elapsed);
updateInterface(currentPhase);
// Gentle camera focus changes follow the four moments.
const focusTargets = [
new THREE.Vector3(0, 0.9, 0),
new THREE.Vector3(0, 2.0, -4.5),
new THREE.Vector3(0, 1.6, -7.4),
new THREE.Vector3(0, 0.9, -0.7)
];
controls.desiredTarget.copy(focusTargets[currentPhase]);
controls.target.lerp(controls.desiredTarget, 0.025);
controls.theta += (controls.desiredTheta - controls.theta) * 0.08;
controls.phi += (controls.desiredPhi - controls.phi) * 0.08;
controls.radius += (controls.desiredRadius - controls.radius) * 0.08;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
// Ambient petals drift through the garden.
for (const petal of floatingPetals) {
petal.position.y -= petal.userData.speed * delta;
petal.position.x += Math.sin(elapsed * 0.7 + petal.userData.phase) * delta * 0.12;
petal.rotation.x += delta * 0.25;
petal.rotation.z += delta * 0.18;
if (petal.position.y < 0.1) {
petal.position.y = range(6.5, 9);
petal.position.x = range(-13, 13);
petal.position.z = range(-10, 13);
}
}
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight, false);
});
updateInterface(0);
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```