Prompt specification
Build or customize the Three.js 3D scene "Breezy café entrance" 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: Breezy café entrance
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/breezy-caf-entrance-x0011
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts a rubber door wedge. Compose a café threshold with door, floor mat, plants, and wedge; alternate a moving door and held-open state while keeping the pedestrian route unobstructed. Stylized solid forms.
Working Three.js Starter (breezy-caf-entrance-x0011):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Room to Pass — Café Door Wedge</title>
<style>
:root {
--ink: #173a35;
--cream: #f6eddf;
--accent: #d56f4f;
--held: #4d8a70;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9dfd1;
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;
}
.title-card {
position: fixed;
top: 28px;
left: 30px;
z-index: 5;
width: min(390px, calc(100vw - 60px));
pointer-events: none;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: rgba(23, 58, 53, 0.7);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
background: var(--accent);
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(38px, 5vw, 66px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 335px;
margin: 17px 0 0;
color: rgba(23, 58, 53, 0.74);
font-size: 14px;
line-height: 1.55;
}
.controls-hint {
position: fixed;
right: 28px;
top: 28px;
z-index: 5;
padding: 10px 14px;
border: 1px solid rgba(23, 58, 53, 0.12);
border-radius: 999px;
background: rgba(248, 241, 230, 0.72);
color: rgba(23, 58, 53, 0.65);
font-size: 11px;
letter-spacing: 0.03em;
backdrop-filter: blur(10px);
pointer-events: none;
}
.state-card {
position: fixed;
right: 26px;
bottom: 26px;
z-index: 6;
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 13px;
width: min(430px, calc(100vw - 52px));
padding: 15px 16px;
border: 1px solid rgba(23, 58, 53, 0.12);
border-radius: 18px;
background: rgba(249, 243, 233, 0.88);
box-shadow: 0 15px 45px rgba(52, 43, 31, 0.12);
backdrop-filter: blur(14px);
}
.state-dot {
position: relative;
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 5px rgba(213, 111, 79, 0.13);
}
.state-dot::after {
position: absolute;
inset: -5px;
border: 1px solid currentColor;
border-radius: inherit;
content: "";
animation: pulse 1.8s ease-out infinite;
}
.state-dot.held {
color: var(--held);
background: var(--held);
box-shadow: 0 0 0 5px rgba(77, 138, 112, 0.14);
}
@keyframes pulse {
0% {
opacity: 0.7;
transform: scale(0.65);
}
100% {
opacity: 0;
transform: scale(1.45);
}
}
.state-copy {
min-width: 0;
}
.state-label {
margin-bottom: 3px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.state-description {
overflow: hidden;
color: rgba(23, 58, 53, 0.64);
font-size: 12px;
line-height: 1.35;
text-overflow: ellipsis;
white-space: nowrap;
}
button {
border: 0;
border-radius: 999px;
padding: 10px 14px;
background: var(--ink);
color: var(--cream);
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition:
transform 160ms ease,
background 160ms ease;
}
button:hover {
background: #28534c;
transform: translateY(-1px);
}
button:focus-visible {
outline: 3px solid rgba(213, 111, 79, 0.45);
outline-offset: 3px;
}
.wedge-tag {
position: fixed;
z-index: 4;
padding: 6px 9px;
border: 1px solid rgba(23, 58, 53, 0.16);
border-radius: 8px;
background: rgba(250, 246, 237, 0.9);
color: var(--ink);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: none;
transform: translate(14px, -22px);
box-shadow: 0 5px 18px rgba(48, 42, 32, 0.09);
}
.wedge-tag::before {
position: absolute;
top: 50%;
left: -16px;
width: 15px;
height: 1px;
background: rgba(23, 58, 53, 0.42);
content: "";
}
.wedge-tag::after {
position: absolute;
top: calc(50% - 3px);
left: -20px;
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--accent);
content: "";
}
@media (max-width: 700px) {
.title-card {
top: 20px;
left: 20px;
}
.subtitle {
max-width: 280px;
font-size: 12px;
}
.controls-hint {
display: none;
}
.state-card {
right: 16px;
bottom: 16px;
width: calc(100vw - 32px);
}
.state-description {
max-width: 210px;
}
}
</style>
</head>
<body>
<div class="title-card">
<div class="eyebrow">Threshold study 01</div>
<h1>Room<br />to pass.</h1>
<p class="subtitle">
A low-profile rubber wedge holds the café door open while leaving
the walking line clear.
</p>
</div>
<div class="controls-hint">Drag to orbit · Scroll to zoom · Space to pause</div>
<div class="state-card">
<div id="stateDot" class="state-dot"></div>
<div class="state-copy" aria-live="polite">
<div id="stateLabel" class="state-label">Moving door</div>
<div id="stateDescription" class="state-description">
The wedge waits beside the jamb.
</div>
</div>
<button id="pauseButton" type="button" aria-label="Pause animation">Pause</button>
</div>
<div id="wedgeTag" class="wedge-tag">Rubber wedge</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9dfd1);
scene.fog = new THREE.Fog(0xe9dfd1, 13, 27);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
document.body.prepend(renderer.domElement);
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional café threshold with a rubber door wedge"
);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
50
);
const cameraTarget = new THREE.Vector3(0, 1.35, 0.35);
let cameraYaw = 0.62;
let cameraPitch = 0.38;
let cameraDistance = 11.5;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraDistance;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraDistance,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Direct, dependency-free orbit and zoom controls.
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
cameraYaw -= deltaX * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + deltaY * 0.0045,
0.16,
0.95
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraDistance = THREE.MathUtils.clamp(
cameraDistance + event.deltaY * 0.008,
6.5,
16
);
updateCamera();
},
{ passive: false }
);
const hemisphere = new THREE.HemisphereLight(0xfff4df, 0x827665, 2.2);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffead0, 3.1);
sun.position.set(-4, 8, 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 = 24;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbdd7d1, 0.8);
fill.position.set(5, 4, -5);
scene.add(fill);
function material(color, roughness = 0.8, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
}
const plaster = material(0xe4d5c0, 0.95);
const plasterLight = material(0xeee3d0, 0.96);
const deepGreen = material(0x244b45, 0.78);
const darkerGreen = material(0x183b36, 0.85);
const teal = material(0x47786f, 0.72);
const brass = material(0xc69a53, 0.32, 0.62);
const terracotta = material(0xc66f50, 0.88);
const terracottaDark = material(0x9d513b, 0.9);
const soil = material(0x44372e, 1);
const rubber = material(0x202725, 0.98);
const rubberRib = material(0x38413e, 0.95);
const wood = material(0x815f46, 0.87);
const cream = material(0xf2e8d7, 0.9);
const glass = new THREE.MeshStandardMaterial({
color: 0x9fc7c1,
roughness: 0.28,
metalness: 0.04,
transparent: true,
opacity: 0.72,
depthWrite: false
});
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
radiusTop,
radiusBottom,
height,
mat,
x = 0,
y = 0,
z = 0,
segments = 24,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, mat, parent = scene) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = cylinder(
radius,
radius,
length,
mat,
0,
0,
0,
10,
parent
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
// Ground, pavement, and tiled café interior.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
material(0xd8cebf, 1)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.12;
ground.receiveShadow = true;
scene.add(ground);
box(9.4, 0.14, 6.6, material(0xd6cbbb, 0.95), 0, -0.055, 2.72);
box(8.4, 0.14, 4.25, material(0xb8a990, 0.92), 0, -0.055, -2.1);
box(8.4, 4.2, 0.2, plaster, 0, 2.05, -4.25);
const seamMaterial = material(0xb7aa96, 1);
for (const x of [-3, -1.5, 0, 1.5, 3]) {
box(0.018, 0.008, 4.15, seamMaterial, x, 0.022, -2.1);
}
for (const z of [-3.45, -2.75, -2.05, -1.35, -0.65]) {
box(8.25, 0.008, 0.018, seamMaterial, 0, 0.023, z);
}
for (const x of [-3.1, -1.55, 0, 1.55, 3.1]) {
box(0.015, 0.008, 6.4, seamMaterial, x, 0.018, 2.7);
}
for (const z of [1.8, 3.6, 5.4]) {
box(9.2, 0.008, 0.015, seamMaterial, 0, 0.019, z);
}
// Threshold and façade.
box(2.86, 0.055, 0.36, brass, 0, 0.045, 0.035);
box(2.72, 0.055, 0.22, deepGreen, 0, 0.052, 0.035);
box(2.78, 3.72, 0.22, plaster, -2.84, 1.86, -0.1);
box(2.78, 3.72, 0.22, plaster, 2.84, 1.86, -0.1);
box(8.4, 0.72, 0.22, plasterLight, 0, 3.55, -0.1);
box(0.14, 3.22, 0.28, deepGreen, -1.4, 1.61, 0.025);
box(0.14, 3.22, 0.28, deepGreen, 1.4, 1.61, 0.025);
box(2.94, 0.13, 0.28, deepGreen, 0, 3.16, 0.025);
// Café sign generated locally as a canvas texture.
const signCanvas = document.createElement("canvas");
signCanvas.width = 1024;
signCanvas.height = 256;
const signContext = signCanvas.getContext("2d");
signContext.fillStyle = "#244b45";
signContext.fillRect(0, 0, 1024, 256);
signContext.strokeStyle = "rgba(242,232,215,0.3)";
signContext.lineWidth = 5;
signContext.strokeRect(18, 18, 988, 220);
signContext.fillStyle = "#f4ead8";
signContext.textAlign = "center";
signContext.textBaseline = "middle";
signContext.font = "500 118px Georgia, serif";
signContext.fillText("CAFÉ", 512, 135);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
signTexture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(2.3, 0.55),
new THREE.MeshStandardMaterial({
map: signTexture,
roughness: 0.85
})
);
sign.position.set(0, 3.55, 0.026);
scene.add(sign);
// The floor mat is centered on the clear pedestrian line.
const matBase = box(
2.12,
0.045,
0.77,
material(0x4b5149, 0.98),
-0.36,
0.065,
0.69
);
matBase.castShadow = false;
for (let i = 0; i < 7; i++) {
const stripe = box(
0.18,
0.009,
0.62,
material(0x74776b, 0.96),
-1.17 + i * 0.27,
0.091,
0.69
);
stripe.castShadow = false;
}
// Hinged café door.
const DOOR_WIDTH = 2.62;
const OPEN_ANGLE = THREE.MathUtils.degToRad(82);
const CLOSED_ANGLE = 0;
const hingePosition = new THREE.Vector3(1.35, 0.105, 0.025);
const doorPivot = new THREE.Group();
doorPivot.position.copy(hingePosition);
scene.add(doorPivot);
const lowerPanel = box(
DOOR_WIDTH - 0.2,
1.53,
0.085,
teal,
-DOOR_WIDTH / 2,
0.86,
0,
doorPivot
);
lowerPanel.castShadow = true;
const upperGlass = box(
DOOR_WIDTH - 0.2,
1.22,
0.055,
glass,
-DOOR_WIDTH / 2,
2.3,
0,
doorPivot
);
upperGlass.castShadow = false;
box(0.13, 3.03, 0.14, darkerGreen, -0.065, 1.515, 0, doorPivot);
box(0.13, 3.03, 0.14, darkerGreen, -DOOR_WIDTH + 0.065, 1.515, 0, doorPivot);
box(DOOR_WIDTH, 0.13, 0.14, darkerGreen, -DOOR_WIDTH / 2, 0.075, 0, doorPivot);
box(DOOR_WIDTH, 0.13, 0.14, darkerGreen, -DOOR_WIDTH / 2, 1.66, 0, doorPivot);
box(DOOR_WIDTH, 0.13, 0.14, darkerGreen, -DOOR_WIDTH / 2, 3.0, 0, doorPivot);
for (const y of [0.55, 2.57]) {
cylinder(0.055, 0.055, 0.2, brass, 0.01, y, 0, 16, doorPivot);
}
const handle = cylinder(
0.035,
0.035,
0.48,
brass,
-DOOR_WIDTH + 0.28,
1.42,
0.15,
16,
doorPivot
);
handle.castShadow = true;
cylinderBetween(
new THREE.Vector3(-DOOR_WIDTH + 0.28, 1.24, 0.07),
new THREE.Vector3(-DOOR_WIDTH + 0.28, 1.24, 0.15),
0.026,
brass,
doorPivot
);
cylinderBetween(
new THREE.Vector3(-DOOR_WIDTH + 0.28, 1.60, 0.07),
new THREE.Vector3(-DOOR_WIDTH + 0.28, 1.60, 0.15),
0.026,
brass,
doorPivot
);
// Stylized rubber wedge with a sloping face and molded ribs.
const wedgeGroup = new THREE.Group();
scene.add(wedgeGroup);
const wedgeLength = 0.66;
const wedgeHeight = 0.17;
const wedgeDepth = 0.34;
const wedgeShape = new THREE.Shape();
wedgeShape.moveTo(-wedgeLength / 2, 0);
wedgeShape.lineTo(wedgeLength / 2, 0);
wedgeShape.lineTo(wedgeLength / 2, 0.025);
wedgeShape.lineTo(-wedgeLength / 2, wedgeHeight);
wedgeShape.closePath();
const wedgeGeometry = new THREE.ExtrudeGeometry(wedgeShape, {
depth: wedgeDepth,
bevelEnabled: true,
bevelThickness: 0.015,
bevelSize: 0.015,
bevelSegments: 2,
steps: 1
});
wedgeGeometry.translate(0, 0, -wedgeDepth / 2);
const wedge = new THREE.Mesh(wedgeGeometry, rubber);
wedge.castShadow = true;
wedge.receiveShadow = true;
wedgeGroup.add(wedge);
const slope = Math.atan2(0.025 - wedgeHeight, wedgeLength);
for (const x of [-0.2, -0.05, 0.1, 0.23]) {
const topY =
wedgeHeight +
((x + wedgeLength / 2) * (0.025 - wedgeHeight)) / wedgeLength;
const rib = box(
0.035,
0.016,
wedgeDepth * 0.82,
rubberRib,
x,
topY + 0.012,
0,
wedgeGroup
);
rib.rotation.z = slope;
}
const wedgeParkPosition = new THREE.Vector3(1.72, 0.025, 0.18);
const wedgeTargetPosition = new THREE.Vector3(
-DOOR_WIDTH + 0.12,
0,
0.015
)
.applyAxisAngle(new THREE.Vector3(0, 1, 0), OPEN_ANGLE)
.add(hingePosition);
wedgeGroup.position.copy(wedgeParkPosition);
// Sidewall sconces.
for (const x of [-2.25, 2.25]) {
const arm = cylinder(
0.045,
0.045,
0.32,
brass,
x,
2.58,
0.09,
12
);
arm.rotation.x = Math.PI / 2;
const shade = new THREE.Mesh(
new THREE.ConeGeometry(0.24, 0.28, 20, 1, true),
deepGreen
);
shade.position.set(x, 2.48, 0.28);
shade.rotation.x = Math.PI;
shade.castShadow = true;
scene.add(shade);
const bulb = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 16, 12),
new THREE.MeshStandardMaterial({
color: 0xffd89d,
emissive: 0xffb95f,
emissiveIntensity: 1.8
})
);
bulb.position.set(x, 2.4, 0.28);
scene.add(bulb);
}
// Café counter and interior details.
box(2.25, 1.02, 0.78, teal, -2.32, 0.52, -3.35);
box(2.42, 0.12, 0.9, wood, -2.32, 1.08, -3.32);
box(0.58, 0.55, 0.48, darkerGreen, -2.65, 1.4, -3.3);
box(0.7, 0.12, 0.55, brass, -2.65, 1.72, -3.28);
cylinder(0.12, 0.1, 0.22, cream, -1.55, 1.25, -3.27, 20);
cylinder(0.1, 0.1, 0.17, terracotta, -1.23, 1.23, -3.27, 20);
const menuCanvas = document.createElement("canvas");
menuCanvas.width = 512;
menuCanvas.height = 640;
const menuContext = menuCanvas.getContext("2d");
menuContext.fillStyle = "#173b36";
menuContext.fillRect(0, 0, 512, 640);
menuContext.fillStyle = "#f2e7d5";
menuContext.textAlign = "center";
menuContext.font = "600 54px Georgia";
menuContext.fillText("TODAY", 256, 90);
menuContext.font = "28px sans-serif";
menuContext.fillText("ESPRESSO", 256, 200);
menuContext.fillText("FILTER COFFEE", 256, 255);
menuContext.fillText("MINT TEA", 256, 310);
menuContext.fillText("ORANGE SODA", 256, 365);
menuContext.fillText("WARM PASTRY", 256, 420);
menuContext.strokeStyle = "rgba(242,231,213,0.35)";
menuContext.beginPath();
menuContext.moveTo(120, 130);
menuContext.lineTo(392, 130);
menuContext.stroke();
const menuTexture = new THREE.CanvasTexture(menuCanvas);
menuTexture.colorSpace = THREE.SRGBColorSpace;
const menuBoard = new THREE.Mesh(
new THREE.PlaneGeometry(1.15, 1.43),
new THREE.MeshStandardMaterial({
map: menuTexture,
roughness: 0.9
})
);
menuBoard.position.set(-1.2, 2.3, -4.13);
scene.add(menuBoard);
// Simple café table and chairs.
cylinder(0.7, 0.7, 0.08, wood, 2.4, 1.22, -2.25, 32);
cylinder(0.075, 0.075, 1.15, darkerGreen, 2.4, 0.58, -2.25, 16);
cylinder(0.34, 0.34, 0.06, darkerGreen, 2.4, 0.04, -2.25, 20);
box(0.62, 0.08, 0.58, teal, 2.4, 0.67, -3.2);
box(0.62, 0.62, 0.08, teal, 2.4, 0.98, -3.47);
for (const x of [2.17, 2.63]) {
for (const z of [-3.08, -3.32]) {
box(0.055, 0.62, 0.055, darkerGreen, x, 0.33, z);
}
}
// Pendant lights inside the café.
for (const x of [-2.4, 0.6]) {
cylinder(
0.018,
0.018,
1.0,
darkerGreen,
x,
3.65,
-2.25,
10
);
const pendant = new THREE.Mesh(
new THREE.ConeGeometry(0.34, 0.32, 24, 1, true),
terracotta
);
pendant.position.set(x, 3.05, -2.25);
pendant.castShadow = true;
scene.add(pendant);
const glow = new THREE.Mesh(
new THREE.SphereGeometry(0.09, 16, 12),
new THREE.MeshStandardMaterial({
color: 0xffd69a,
emissive: 0xffad55,
emissiveIntensity: 2
})
);
glow.position.set(x, 2.91, -2.25);
scene.add(glow);
}
function createPlant(x, z, scale = 1) {
const plant = new THREE.Group();
plant.position.set(x, 0.02, z);
plant.scale.setScalar(scale);
scene.add(plant);
cylinder(0.36, 0.28, 0.58, terracotta, 0, 0.29, 0, 24, plant);
cylinder(0.315, 0.315, 0.055, soil, 0, 0.59, 0, 24, plant);
cylinder(0.385, 0.365, 0.07, terracottaDark, 0, 0.53, 0, 24, plant);
const leafMaterials = [
material(0x4d7758, 0.95),
material(0x678c65, 0.95),
material(0x3f684e, 0.95)
];
const stemTop = new THREE.Vector3(0.02, 1.45, 0);
cylinderBetween(
new THREE.Vector3(0, 0.57, 0),
stemTop,
0.024,
material(0x486347, 0.96),
plant
);
for (let i = 0; i < 9; i++) {
const angle = (i / 9) * Math.PI * 2 + i * 0.37;
const height = 0.82 + (i % 3) * 0.2;
const reach = 0.34 + (i % 2) * 0.16;
const start = new THREE.Vector3(0, 0.6 + i * 0.055, 0);
const end = new THREE.Vector3(
Math.cos(angle) * reach,
height,
Math.sin(angle) * reach
);
cylinderBetween(start, end, 0.016, leafMaterials[0], plant);
const leaf = new THREE.Mesh(
new THREE.SphereGeometry(1, 14, 9),
leafMaterials[i % leafMaterials.length]
);
leaf.scale.set(0.19, 0.39, 0.075);
leaf.position.copy(end);
leaf.rotation.set(
0.35 * Math.sin(angle),
-angle,
0.62 * Math.cos(angle)
);
leaf.castShadow = true;
plant.add(leaf);
}
return plant;
}
createPlant(-2.65, 0.62, 1.18);
createPlant(3.03, 0.55, 1.02);
createPlant(3.05, -1.25, 1.13);
// Low planter beside the left wall.
box(0.9, 0.46, 0.85, terracotta, -3.58, 0.23, -1.3);
box(0.79, 0.035, 0.74, soil, -3.58, 0.47, -1.3);
createPlant(-3.58, -1.3, 0.72);
// Animation state.
const MOVING_DURATION = 5.2;
const HELD_DURATION = 4.55;
let animationPhase = "moving";
let phaseElapsed = 0;
let paused = false;
let doorAngle = OPEN_ANGLE;
let wedgeAmount = 0;
const stateDot = document.getElementById("stateDot");
const stateLabel = document.getElementById("stateLabel");
const stateDescription = document.getElementById("stateDescription");
const pauseButton = document.getElementById("pauseButton");
function updateStatus() {
const held = animationPhase === "held";
stateDot.classList.toggle("held", held);
stateLabel.textContent = held ? "Held open" : "Moving door";
stateDescription.textContent = held
? "Wedge set at the door tip; the center path stays clear."
: "The wedge waits beside the jamb.";
}
function transitionTo(nextPhase) {
animationPhase = nextPhase;
phaseElapsed = 0;
updateStatus();
}
function togglePause() {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
pauseButton.setAttribute(
"aria-label",
paused ? "Resume animation" : "Pause animation"
);
}
pauseButton.addEventListener("click", togglePause);
window.addEventListener("keydown", (event) => {
if (event.code === "Space" && event.target === document.body) {
event.preventDefault();
togglePause();
}
});
function easeInOut(t) {
t = THREE.MathUtils.clamp(t, 0, 1);
return t * t * (3 - 2 * t);
}
function updateAnimation(delta) {
if (!paused) {
phaseElapsed += delta;
if (animationPhase === "moving") {
wedgeAmount = 0;
if (phaseElapsed < 2.85) {
doorAngle = THREE.MathUtils.lerp(
OPEN_ANGLE,
CLOSED_ANGLE,
easeInOut(phaseElapsed / 2.85)
);
} else if (phaseElapsed < 3.65) {
doorAngle = CLOSED_ANGLE;
} else if (phaseElapsed < MOVING_DURATION) {
doorAngle = THREE.MathUtils.lerp(
CLOSED_ANGLE,
OPEN_ANGLE,
easeInOut((phaseElapsed - 3.65) / (MOVING_DURATION - 3.65))
);
} else {
transitionTo("held");
}
} else {
doorAngle = OPEN_ANGLE;
if (phaseElapsed < 0.9) {
wedgeAmount = easeInOut(phaseElapsed / 0.9);
} else if (phaseElapsed < 3.55) {
wedgeAmount = 1;
} else if (phaseElapsed < HELD_DURATION) {
wedgeAmount =
1 - easeInOut((phaseElapsed - 3.55) / (HELD_DURATION - 3.55));
} else {
transitionTo("moving");
}
}
}
doorPivot.rotation.y = doorAngle;
wedgeGroup.position.lerpVectors(
wedgeParkPosition,
wedgeTargetPosition,
wedgeAmount
);
wedgeGroup.rotation.y = THREE.MathUtils.lerp(0.12, OPEN_ANGLE, wedgeAmount);
}
const wedgeTag = document.getElementById("wedgeTag");
const projectedWedge = new THREE.Vector3();
function updateWedgeTag() {
wedgeGroup.getWorldPosition(projectedWedge);
projectedWedge.y += 0.22;
projectedWedge.project(camera);
const visible =
projectedWedge.z > -1 &&
projectedWedge.z < 1 &&
Math.abs(projectedWedge.x) < 1.08 &&
Math.abs(projectedWedge.y) < 1.08;
wedgeTag.style.display = visible ? "block" : "none";
if (visible) {
wedgeTag.style.left = `${(projectedWedge.x * 0.5 + 0.5) * window.innerWidth}px`;
wedgeTag.style.top = `${(-projectedWedge.y * 0.5 + 0.5) * window.innerHeight}px`;
}
}
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", onResize);
updateStatus();
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
updateAnimation(delta);
renderer.render(scene, camera);
updateWedgeTag();
});
</script>
</body>
</html>
```