Prompt specification
Build or customize the Three.js 3D scene "Narrow utility room access" 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: Narrow utility room access
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/narrow-utility-room-access-x0235
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows sliding and hinged doors. Build a utility room with shelves, laundry basket, and sliding entrance; compare basket movement through the doorway with the panel parked open or partly closed. Stylized solid forms.
Working Three.js Starter (narrow-utility-room-access-x0235):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Utility Room — Sliding Door Study</title>
<style>
:root {
--ink: #203036;
--muted: #68787c;
--panel: rgba(250, 249, 244, 0.92);
--line: rgba(32, 48, 54, 0.14);
--teal: #287c78;
--teal-dark: #185c59;
--orange: #e8893d;
--green: #4b9b73;
--amber: #d69a3b;
--shadow: 0 18px 50px rgba(37, 54, 58, 0.15);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cdd8d5;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button:focus-visible,
input:focus-visible {
outline: 3px solid rgba(40, 124, 120, 0.28);
outline-offset: 3px;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.card {
position: fixed;
z-index: 5;
border: 1px solid rgba(255, 255, 255, 0.65);
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.intro {
top: 22px;
left: 22px;
width: min(340px, calc(100vw - 44px));
padding: 20px 21px 18px;
border-radius: 20px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--teal-dark);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--orange);
content: "";
box-shadow: 0 0 0 4px rgba(232, 137, 61, 0.13);
}
h1 {
margin: 0;
font-size: clamp(25px, 2.7vw, 36px);
line-height: 1.02;
letter-spacing: -0.045em;
}
.intro p {
margin: 12px 0 17px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.metric {
display: flex;
align-items: flex-end;
justify-content: space-between;
padding-top: 14px;
border-top: 1px solid var(--line);
}
.metric strong {
font-size: 29px;
line-height: 1;
letter-spacing: -0.04em;
}
.metric span {
max-width: 125px;
color: var(--muted);
font-size: 11px;
line-height: 1.35;
text-align: right;
}
.status {
display: flex;
align-items: center;
gap: 8px;
margin-top: 14px;
color: var(--ink);
font-size: 11px;
font-weight: 700;
}
.status-dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--green);
transition: background 180ms ease;
}
.compare {
top: 22px;
right: 22px;
width: 326px;
padding: 16px;
border-radius: 20px;
pointer-events: none;
}
.compare-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.compare-heading strong {
font-size: 12px;
letter-spacing: 0.02em;
}
.compare-heading span {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.compare-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
}
.compare-option {
padding: 10px 9px 9px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.52);
transition:
border-color 180ms ease,
background 180ms ease,
transform 180ms ease;
}
.compare-option.active {
border-color: rgba(40, 124, 120, 0.55);
background: rgba(226, 241, 235, 0.72);
transform: translateY(-2px);
}
.compare-option strong {
display: block;
margin-bottom: 4px;
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.compare-option svg {
display: block;
width: 100%;
height: auto;
overflow: visible;
}
.compare-option small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 9px;
text-align: right;
}
.compare-option.partial small {
color: #9a6b25;
font-weight: 700;
}
.controls {
position: fixed;
z-index: 8;
bottom: 22px;
left: 50%;
width: min(820px, calc(100vw - 36px));
padding: 13px 14px;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 20px;
background: rgba(249, 248, 243, 0.94);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
transform: translateX(-50%);
}
.control-row {
display: grid;
grid-template-columns: auto minmax(180px, 1fr) auto;
align-items: center;
gap: 18px;
}
.segmented {
display: flex;
gap: 4px;
padding: 4px;
border-radius: 12px;
background: #e7e8e2;
}
.preset {
min-height: 38px;
padding: 0 13px;
border: 0;
border-radius: 9px;
background: transparent;
color: #526166;
cursor: pointer;
font-size: 11px;
font-weight: 750;
white-space: nowrap;
transition:
color 160ms ease,
background 160ms ease,
box-shadow 160ms ease;
}
.preset.active {
background: #fff;
color: var(--teal-dark);
box-shadow: 0 3px 12px rgba(39, 56, 60, 0.1);
}
.travel {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.07em;
text-transform: uppercase;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 999px;
appearance: none;
background:
linear-gradient(
to right,
var(--teal) 0%,
var(--teal) var(--range, 0%),
#d4d9d5 var(--range, 0%),
#d4d9d5 100%
);
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 17px;
height: 17px;
border: 3px solid white;
border-radius: 50%;
appearance: none;
background: var(--teal);
box-shadow: 0 2px 8px rgba(25, 61, 61, 0.28);
}
input[type="range"]::-moz-range-thumb {
width: 13px;
height: 13px;
border: 3px solid white;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 2px 8px rgba(25, 61, 61, 0.28);
}
#travelValue {
width: 38px;
color: var(--ink);
text-align: right;
font-variant-numeric: tabular-nums;
}
#crossButton {
min-width: 158px;
min-height: 44px;
padding: 0 18px;
border: 0;
border-radius: 12px;
background: var(--teal);
color: white;
cursor: pointer;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.04em;
transition:
transform 150ms ease,
background 150ms ease,
opacity 150ms ease;
}
#crossButton:hover:not(:disabled) {
background: var(--teal-dark);
transform: translateY(-1px);
}
#crossButton:disabled {
cursor: wait;
opacity: 0.68;
}
.progress-track {
height: 3px;
margin: 10px 2px 0;
overflow: hidden;
border-radius: 99px;
background: #dfe2dc;
}
#progressFill {
width: 0%;
height: 100%;
border-radius: inherit;
background: var(--orange);
transition: width 80ms linear;
}
.hint {
position: fixed;
z-index: 4;
right: 22px;
bottom: 22px;
padding: 9px 12px;
border-radius: 999px;
background: rgba(249, 248, 243, 0.76);
color: var(--muted);
font-size: 10px;
font-weight: 700;
pointer-events: none;
backdrop-filter: blur(10px);
}
#clearanceTag {
position: fixed;
z-index: 4;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 8px;
background: rgba(34, 48, 52, 0.84);
color: white;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.04em;
pointer-events: none;
transform: translate(-50%, -50%);
white-space: nowrap;
box-shadow: 0 5px 18px rgba(22, 40, 43, 0.16);
}
@media (max-width: 900px) {
.compare {
display: none;
}
.hint {
display: none;
}
}
@media (max-width: 680px) {
.intro {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 16px;
}
.intro p {
display: none;
}
.metric {
padding-top: 10px;
}
.metric strong {
font-size: 24px;
}
.status {
margin-top: 10px;
}
.controls {
bottom: 12px;
width: calc(100vw - 24px);
padding: 10px;
}
.control-row {
grid-template-columns: 1fr;
gap: 9px;
}
.segmented {
width: 100%;
}
.preset {
flex: 1;
padding: 0 7px;
}
.travel {
grid-template-columns: auto 1fr 35px;
}
#crossButton {
width: 100%;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive 3D utility room with a sliding entrance door"></div>
<section class="card intro">
<div class="eyebrow">Interactive spatial study / 01</div>
<h1>Sliding utility room</h1>
<p>
Move the entrance panel and send the laundry basket through to compare
a fully parked opening with a tighter, partly closed position.
</p>
<div class="metric">
<strong id="clearanceValue">2.30 m</strong>
<span>current clear opening</span>
</div>
<div class="status">
<span class="status-dot" id="statusDot"></span>
<span id="statusText">Panel parked fully open</span>
</div>
</section>
<aside class="card compare">
<div class="compare-heading">
<strong>Basket clearance comparison</strong>
<span>Top view</span>
</div>
<div class="compare-grid">
<div class="compare-option active" id="compareOpen">
<strong>Parked open</strong>
<svg viewBox="0 0 140 62" aria-label="Open sliding panel plan">
<path
d="M111 6V18 M111 45V55"
fill="none"
stroke="#8e9a99"
stroke-width="3"
stroke-linecap="round"
/>
<path
d="M111 18V45"
fill="none"
stroke="#4b9b73"
stroke-width="3"
stroke-linecap="round"
/>
<rect x="115" y="6" width="7" height="12" rx="2" fill="#287c78" />
<rect x="78" y="27" width="23" height="9" rx="3" fill="#e8893d" />
<path d="M98 31.5H107" stroke="#fff" stroke-width="1.5" />
<path d="M104 28.5L108 31.5L104 34.5" fill="none" stroke="#fff" />
</svg>
<small>2.30 m clear</small>
</div>
<div class="compare-option partial" id="comparePartial">
<strong>Partly closed</strong>
<svg viewBox="0 0 140 62" aria-label="Partly closed sliding panel plan">
<path
d="M111 6V18 M111 45V55"
fill="none"
stroke="#8e9a99"
stroke-width="3"
stroke-linecap="round"
/>
<path
d="M111 38V45"
fill="none"
stroke="#d69a3b"
stroke-width="3"
stroke-linecap="round"
/>
<rect x="115" y="6" width="7" height="32" rx="2" fill="#287c78" />
<rect x="78" y="37" width="23" height="7" rx="3" fill="#e8893d" />
<path d="M98 40.5H107" stroke="#fff" stroke-width="1.5" />
<path d="M104 37.5L108 40.5L104 43.5" fill="none" stroke="#fff" />
</svg>
<small>1.07 m clear</small>
</div>
</div>
</aside>
<section class="controls" aria-label="Door and basket controls">
<div class="control-row">
<div class="segmented" aria-label="Door presets">
<button class="preset active" id="openPreset" type="button">
Parked open
</button>
<button class="preset" id="partialPreset" type="button">
Partly closed
</button>
</div>
<label class="travel">
Panel position
<input
id="doorRange"
type="range"
min="0"
max="100"
value="0"
aria-label="Sliding panel position"
>
<span id="travelValue">0%</span>
</label>
<button id="crossButton" type="button">Send basket through</button>
</div>
<div class="progress-track" aria-hidden="true">
<div id="progressFill"></div>
</div>
</section>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<div id="clearanceTag">2.30 m clear</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xcdd8d5);
scene.fog = new THREE.Fog(0xcdd8d5, 15, 30);
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.08;
sceneHost.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
39,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraTarget = new THREE.Vector3(0.55, 1.0, 0.05);
const spherical = {
radius: 11.8,
theta: 0.67,
phi: 0.93
};
function updateCamera() {
const sinPhi = Math.sin(spherical.phi);
camera.position.set(
cameraTarget.x +
spherical.radius * sinPhi * Math.sin(spherical.theta),
cameraTarget.y + spherical.radius * Math.cos(spherical.phi),
cameraTarget.z +
spherical.radius * sinPhi * Math.cos(spherical.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const material = {
wall: new THREE.MeshStandardMaterial({
color: 0xeee9de,
roughness: 0.86
}),
floor: new THREE.MeshStandardMaterial({
color: 0xd8d4c8,
roughness: 0.92
}),
seam: new THREE.MeshBasicMaterial({
color: 0xbab8af
}),
dark: new THREE.MeshStandardMaterial({
color: 0x26363a,
roughness: 0.62
}),
black: new THREE.MeshStandardMaterial({
color: 0x182326,
roughness: 0.74
}),
teal: new THREE.MeshStandardMaterial({
color: 0x287c78,
roughness: 0.58
}),
tealLight: new THREE.MeshStandardMaterial({
color: 0x79aaa4,
roughness: 0.65
}),
orange: new THREE.MeshStandardMaterial({
color: 0xe8893d,
roughness: 0.56
}),
cream: new THREE.MeshStandardMaterial({
color: 0xf2d59d,
roughness: 0.72
}),
blue: new THREE.MeshStandardMaterial({
color: 0x789eae,
roughness: 0.72
}),
red: new THREE.MeshStandardMaterial({
color: 0xc86d5d,
roughness: 0.7
}),
white: new THREE.MeshStandardMaterial({
color: 0xf8f6ee,
roughness: 0.64
}),
wood: new THREE.MeshStandardMaterial({
color: 0xb99167,
roughness: 0.84
}),
metal: new THREE.MeshStandardMaterial({
color: 0xaeb7b4,
roughness: 0.34,
metalness: 0.52
})
};
function box(
width,
height,
depth,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
castShadow = true
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
radius,
height,
mat,
x = 0,
y = 0,
z = 0,
parent = scene,
segments = 24
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, height, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Lighting and ground
// ---------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(
0xf8fbff,
0x77817b,
2.05
);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff5e7, 3.4);
sun.position.set(-4.5, 9.5, 6.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 28;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xcce7e8, 1.1);
fill.position.set(6, 4, -5);
scene.add(fill);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({
color: 0xb9c5c0,
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.22;
ground.receiveShadow = true;
scene.add(ground);
// ---------------------------------------------------------------------
// Room shell
// ---------------------------------------------------------------------
box(7.55, 0.18, 5.55, material.floor, 0, -0.09, 0);
// Subtle tile seams.
for (let x = -3; x <= 3; x += 1) {
box(0.012, 0.004, 5.35, material.seam, x, 0.006, 0, scene, false);
}
for (let z = -2; z <= 2; z += 1) {
box(7.32, 0.004, 0.012, material.seam, 0, 0.007, z, scene, false);
}
// Back and left walls.
box(7.55, 3.05, 0.16, material.wall, 0, 1.525, -2.75);
box(0.16, 3.05, 5.55, material.wall, -3.75, 1.525, 0);
// Right wall, leaving a doorway between z = -0.15 and z = 2.15.
const openingStart = -0.15;
const openingEnd = 2.15;
box(
0.16,
3.05,
openingStart - (-2.75),
material.wall,
3.75,
1.525,
(-2.75 + openingStart) / 2
);
box(
0.16,
3.05,
2.75 - openingEnd,
material.wall,
3.75,
1.525,
(openingEnd + 2.75) / 2
);
box(
0.16,
0.48,
openingEnd - openingStart,
material.wall,
3.75,
2.81,
(openingStart + openingEnd) / 2
);
// Baseboards.
box(7.38, 0.13, 0.05, material.white, 0, 0.065, -2.645);
box(0.05, 0.13, 5.38, material.white, -3.645, 0.065, 0);
box(
0.05,
0.13,
2.46,
material.white,
3.645,
0.065,
(-2.75 + openingStart) / 2
);
box(
0.05,
0.13,
0.48,
material.white,
3.645,
0.065,
(openingEnd + 2.75) / 2
);
// Door frame and threshold.
box(0.12, 2.58, 0.09, material.dark, 3.84, 1.29, openingStart);
box(0.12, 2.58, 0.09, material.dark, 3.84, 1.29, openingEnd);
box(0.12, 0.10, 2.42, material.dark, 3.84, 2.55, 1.0);
box(0.32, 0.045, 2.38, material.metal, 3.80, 0.027, 1.0);
// Exterior landing.
box(1.5, 0.16, 2.55, material.floor, 4.48, -0.08, 1.0);
box(1.55, 0.055, 2.60, material.seam, 4.48, 0.008, 1.0, scene, false);
// ---------------------------------------------------------------------
// Open shelving and utility objects
// ---------------------------------------------------------------------
const shelfX = -1.35;
const shelfZ = -2.22;
const shelfWidth = 3.48;
for (const x of [-3.02, -1.78, -0.54, 0.3]) {
box(0.075, 2.58, 0.075, material.teal, x, 1.31, shelfZ - 0.29);
box(0.075, 2.58, 0.075, material.teal, x, 1.31, shelfZ + 0.29);
}
for (const y of [0.44, 1.13, 1.82, 2.51]) {
box(shelfWidth, 0.09, 0.66, material.wood, shelfX, y, shelfZ);
box(shelfWidth - 0.06, 0.055, 0.035, material.teal, shelfX, y - 0.065, shelfZ + 0.31);
}
function bottle(x, y, z, bodyMat, scale = 1) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
cylinder(0.13, 0.34, bodyMat, 0, 0.17, 0, group);
cylinder(0.065, 0.10, bodyMat, 0, 0.39, 0, group);
cylinder(0.075, 0.055, material.dark, 0, 0.465, 0, group);
box(0.17, 0.12, 0.012, material.white, 0, 0.2, 0.128, group, false);
scene.add(group);
return group;
}
// Bottles on lower shelves.
bottle(-2.75, 1.185, -2.18, material.tealLight, 0.9);
bottle(-2.43, 1.185, -2.18, material.orange, 0.86);
bottle(-2.1, 1.185, -2.18, material.blue, 0.92);
bottle(-1.62, 0.495, -2.18, material.red, 0.92);
bottle(-1.29, 0.495, -2.18, material.cream, 0.84);
// Folded towels.
box(0.66, 0.12, 0.43, material.blue, -2.42, 1.25, -2.17);
box(0.61, 0.11, 0.4, material.cream, -2.39, 1.36, -2.15);
box(0.64, 0.12, 0.43, material.tealLight, -0.93, 1.25, -2.18);
box(0.58, 0.11, 0.4, material.white, -0.92, 1.36, -2.15);
// Storage boxes.
box(0.68, 0.35, 0.45, material.cream, -2.47, 2.05, -2.18);
box(0.70, 0.055, 0.46, material.orange, -2.47, 2.23, -2.17);
box(0.58, 0.33, 0.44, material.blue, -0.92, 2.04, -2.18);
box(0.61, 0.05, 0.46, material.teal, -0.92, 2.22, -2.17);
// Small upper containers.
cylinder(0.19, 0.36, material.teal, -1.82, 2.69, -2.16);
cylinder(0.19, 0.36, material.orange, -1.35, 2.69, -2.16);
box(0.43, 0.28, 0.4, material.cream, -0.54, 2.65, -2.17);
// Washing machine.
box(1.18, 1.06, 0.94, material.white, 1.22, 0.56, -2.14);
box(1.18, 0.12, 0.94, material.teal, 1.22, 1.12, -2.14);
box(0.33, 0.10, 0.025, material.dark, 0.91, 0.93, -1.655);
const washerRim = cylinder(0.33, 0.07, material.teal, 1.25, 0.54, -1.655);
washerRim.rotation.x = Math.PI / 2;
const washerGlass = cylinder(0.255, 0.075, material.dark, 1.25, 0.54, -1.61);
washerGlass.rotation.x = Math.PI / 2;
const washerInner = cylinder(0.16, 0.078, material.blue, 1.25, 0.54, -1.565);
washerInner.rotation.x = Math.PI / 2;
const controlKnob = cylinder(0.055, 0.035, material.orange, 1.62, 0.94, -1.65);
controlKnob.rotation.x = Math.PI / 2;
// Wall-mounted utility rail.
box(0.08, 0.08, 1.55, material.teal, -3.63, 1.86, -0.3);
for (const z of [-0.88, -0.3, 0.28]) {
const hook = cylinder(0.035, 0.2, material.metal, -3.56, 1.82, z);
hook.rotation.z = Math.PI / 2;
}
// Small cleaning brush.
box(0.08, 0.5, 0.12, material.wood, -3.48, 1.42, -0.88);
box(0.12, 0.22, 0.25, material.orange, -3.47, 1.05, -0.88);
// ---------------------------------------------------------------------
// Sliding panel and rail
// ---------------------------------------------------------------------
const DOOR_OPEN_CENTER = -1.65;
const DOOR_CLOSED_CENTER = 0.90;
const DOOR_HALF_WIDTH = 1.25;
const doorPanel = new THREE.Group();
doorPanel.position.set(3.86, 0, DOOR_OPEN_CENTER);
scene.add(doorPanel);
box(0.14, 2.50, 2.50, material.teal, 0, 1.25, 0, doorPanel);
box(0.035, 1.45, 1.90, material.tealLight, 0.086, 1.43, 0, doorPanel);
box(0.045, 1.32, 1.77, material.cream, 0.108, 1.43, 0, doorPanel);
// Two solid inset bands keep the panel graphic and minimal.
box(0.022, 0.055, 1.78, material.tealLight, 0.132, 1.47, 0, doorPanel, false);
box(0.022, 0.055, 1.78, material.tealLight, 0.132, 1.13, 0, doorPanel, false);
// Handle.
box(0.07, 0.42, 0.08, material.dark, 0.17, 1.17, 0.87, doorPanel);
box(0.12, 0.07, 0.10, material.dark, 0.12, 1.17, 0.87, doorPanel);
// Roller hardware.
for (const z of [-0.88, 0.88]) {
const roller = cylinder(0.09, 0.07, material.dark, 0, 2.55, z, doorPanel, 20);
roller.rotation.z = Math.PI / 2;
}
box(0.16, 0.10, 5.28, material.metal, 3.86, 2.64, -0.25);
box(0.07, 0.055, 5.15, material.dark, 3.94, 2.56, -0.25);
// ---------------------------------------------------------------------
// Basket
// ---------------------------------------------------------------------
const basket = new THREE.Group();
basket.position.set(1.15, 0.015, 1.58);
scene.add(basket);
box(0.96, 0.10, 0.64, material.orange, 0, 0.18, 0, basket);
// Corner uprights.
for (const x of [-0.45, 0.45]) {
for (const z of [-0.30, 0.30]) {
box(0.075, 0.58, 0.075, material.orange, x, 0.47, z, basket);
}
}
// Horizontal basket rails.
for (const y of [0.30, 0.47, 0.65, 0.77]) {
box(0.99, 0.065, 0.065, material.orange, 0, y, 0.33, basket);
box(0.99, 0.065, 0.065, material.orange, 0, y, -0.33, basket);
box(0.065, 0.065, 0.61, material.orange, 0.47, y, 0, basket);
box(0.065, 0.065, 0.61, material.orange, -0.47, y, 0, basket);
}
// Solid rim.
box(1.02, 0.09, 0.075, material.orange, 0, 0.80, 0.33, basket);
box(1.02, 0.09, 0.075, material.orange, 0, 0.80, -0.33, basket);
box(0.075, 0.09, 0.66, material.orange, 0.49, 0.80, 0, basket);
box(0.075, 0.09, 0.66, material.orange, -0.49, 0.80, 0, basket);
// Raised handle.
box(0.075, 0.31, 0.075, material.orange, 0.43, 0.94, 0, basket);
box(0.075, 0.31, 0.075, material.orange, -0.43, 0.94, 0, basket);
box(0.93, 0.075, 0.075, material.orange, 0, 1.09, 0, basket);
// Casters.
const wheels = [];
for (const x of [-0.35, 0.35]) {
for (const z of [-0.25, 0.25]) {
const wheel = cylinder(0.09, 0.065, material.black, x, 0.09, z, basket, 20);
wheel.rotation.x = Math.PI / 2;
wheels.push(wheel);
}
}
// Laundry as simple solid blobs.
const clothA = new THREE.Mesh(
new THREE.SphereGeometry(0.22, 18, 12),
material.blue
);
clothA.position.set(-0.16, 0.73, 0.05);
clothA.scale.set(1.35, 0.62, 1.08);
clothA.castShadow = true;
basket.add(clothA);
const clothB = new THREE.Mesh(
new THREE.SphereGeometry(0.20, 18, 12),
material.cream
);
clothB.position.set(0.20, 0.75, -0.08);
clothB.scale.set(1.15, 0.68, 1.25);
clothB.castShadow = true;
basket.add(clothB);
const clothC = new THREE.Mesh(
new THREE.SphereGeometry(0.18, 16, 10),
material.red
);
clothC.position.set(0.02, 0.84, 0.10);
clothC.scale.set(1.1, 0.58, 1.0);
clothC.castShadow = true;
basket.add(clothC);
// ---------------------------------------------------------------------
// Movement route and clearance marker
// ---------------------------------------------------------------------
const routeGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0.40, 0.027, 1.58),
new THREE.Vector3(5.58, 0.027, 1.58)
]);
const route = new THREE.Line(
routeGeometry,
new THREE.LineDashedMaterial({
color: 0x708784,
dashSize: 0.16,
gapSize: 0.11,
transparent: true,
opacity: 0.8
})
);
route.computeLineDistances();
scene.add(route);
const routeArrow = new THREE.Mesh(
new THREE.ConeGeometry(0.14, 0.36, 18),
material.teal
);
routeArrow.rotation.z = -Math.PI / 2;
routeArrow.position.set(5.72, 0.035, 1.58);
routeArrow.castShadow = true;
scene.add(routeArrow);
const laneMaterial = new THREE.MeshBasicMaterial({
color: 0x4b9b73,
transparent: true,
opacity: 0.12,
depthWrite: false
});
const clearanceLane = new THREE.Mesh(
new THREE.BoxGeometry(2.35, 0.012, 0.93),
laneMaterial
);
clearanceLane.position.set(4.25, 0.018, 1.58);
scene.add(clearanceLane);
const gapPositions = new Float32Array(18);
const gapGeometry = new THREE.BufferGeometry();
gapGeometry.setAttribute(
"position",
new THREE.BufferAttribute(gapPositions, 3)
);
const gapMaterial = new THREE.LineBasicMaterial({
color: 0x4b9b73
});
const gapLine = new THREE.LineSegments(gapGeometry, gapMaterial);
scene.add(gapLine);
// ---------------------------------------------------------------------
// UI state and interaction
// ---------------------------------------------------------------------
const openPreset = document.getElementById("openPreset");
const partialPreset = document.getElementById("partialPreset");
const doorRange = document.getElementById("doorRange");
const travelValue = document.getElementById("travelValue");
const crossButton = document.getElementById("crossButton");
const progressFill = document.getElementById("progressFill");
const clearanceValue = document.getElementById("clearanceValue");
const statusText = document.getElementById("statusText");
const statusDot = document.getElementById("statusDot");
const compareOpen = document.getElementById("compareOpen");
const comparePartial = document.getElementById("comparePartial");
const clearanceTag = document.getElementById("clearanceTag");
const PARTIAL_PRESET = 58;
let doorProgress = 0;
let doorTarget = 0;
const BASKET_START_X = 1.15;
const BASKET_END_X = 5.22;
const BASKET_STOP_X = 2.94;
const BASKET_Z = 1.58;
const BASKET_HALF_DEPTH = 0.34;
let basketX = BASKET_START_X;
let crossing = false;
let crossingBlocked = false;
let crossingElapsed = 0;
let pendingCross = false;
let lastResult = "";
const CROSS_DURATION = 4.5;
const BLOCKED_DURATION = 1.75;
function panelCenter(progress) {
return THREE.MathUtils.lerp(
DOOR_OPEN_CENTER,
DOOR_CLOSED_CENTER,
progress
);
}
function panelFront(progress) {
return panelCenter(progress) + DOOR_HALF_WIDTH;
}
function currentGap(progress) {
const gapStart = Math.max(openingStart, panelFront(progress));
return Math.max(0, openingEnd - gapStart);
}
function doorCanPass(progress) {
return panelFront(progress) <= BASKET_Z - BASKET_HALF_DEPTH - 0.025;
}
function setStatus(message, tone = "green") {
statusText.textContent = message;
const colors = {
green: "#4b9b73",
amber: "#d69a3b",
orange: "#e8893d"
};
statusDot.style.background = colors[tone] || colors.green;
}
function resetBasket() {
crossing = false;
crossingBlocked = false;
pendingCross = false;
crossingElapsed = 0;
basketX = BASKET_START_X;
basket.position.x = basketX;
progressFill.style.width = "0%";
crossButton.disabled = false;
crossButton.textContent = "Send basket through";
lastResult = "";
}
function updatePresetClasses() {
const percent = doorTarget * 100;
openPreset.classList.toggle("active", percent < 0.5);
partialPreset.classList.toggle(
"active",
Math.abs(percent - PARTIAL_PRESET) < 0.5
);
compareOpen.classList.toggle("active", percent < 0.5);
comparePartial.classList.toggle(
"active",
Math.abs(percent - PARTIAL_PRESET) < 0.5
);
}
function setDoorPosition(percent) {
doorTarget = THREE.MathUtils.clamp(percent / 100, 0, 1);
resetBasket();
doorRange.value = String(Math.round(percent));
travelValue.textContent = `${Math.round(percent)}%`;
doorRange.style.setProperty("--range", `${percent}%`);
updatePresetClasses();
if (percent < 0.5) {
setStatus("Panel parked fully open");
} else if (Math.abs(percent - PARTIAL_PRESET) < 0.5) {
setStatus("Partly closed — basket has a narrow path", "amber");
} else if (!doorCanPass(doorTarget)) {
setStatus("Panel overlaps the basket route", "orange");
} else {
setStatus("Panel adjusted — ready to test", "amber");
}
}
function beginCrossing() {
crossingBlocked = !doorCanPass(doorTarget);
crossing = true;
crossingElapsed = 0;
basketX = BASKET_START_X;
basket.position.x = basketX;
crossButton.disabled = true;
crossButton.textContent = crossingBlocked
? "Testing clearance..."
: "Basket crossing...";
setStatus(
crossingBlocked
? "Basket approaching the panel"
: "Basket moving through the doorway",
crossingBlocked ? "orange" : "amber"
);
}
function requestCrossing() {
if (crossing || pendingCross) return;
if (Math.abs(doorProgress - doorTarget) > 0.012) {
pendingCross = true;
crossButton.disabled = true;
crossButton.textContent = "Positioning panel...";
setStatus("Positioning the sliding panel", "amber");
return;
}
beginCrossing();
}
openPreset.addEventListener("click", () => setDoorPosition(0));
partialPreset.addEventListener("click", () =>
setDoorPosition(PARTIAL_PRESET)
);
doorRange.addEventListener("input", (event) => {
setDoorPosition(Number(event.target.value));
});
crossButton.addEventListener("click", requestCrossing);
// ---------------------------------------------------------------------
// Direct camera controls: orbit, zoom, and reset
// ---------------------------------------------------------------------
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;
spherical.theta -= deltaX * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - deltaY * 0.005,
0.34,
1.36
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
spherical.radius = THREE.MathUtils.clamp(
spherical.radius + event.deltaY * 0.008,
6.5,
18
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
spherical.radius = 11.8;
spherical.theta = 0.67;
spherical.phi = 0.93;
cameraTarget.set(0.55, 1.0, 0.05);
updateCamera();
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
const projectedPoint = new THREE.Vector3();
function easeInOutCubic(t) {
return t < 0.5
? 4 * t * t * t
: 1 - Math.pow(-2 * t + 2, 3) / 2;
}
function easeOutCubic(t) {
return 1 - Math.pow(1 - t, 3);
}
function updateGapMarker(gap, front) {
const start = Math.max(openingStart, front);
const middle = (start + openingEnd) / 2;
const x = 4.12;
const y = 0.047;
const points = [
x, y, start,
x, y, openingEnd,
x - 0.13, y, start,
x + 0.13, y, start,
x - 0.13, y, openingEnd,
x + 0.13, y, openingEnd
];
for (let i = 0; i < points.length; i++) {
gapPositions[i] = points[i];
}
gapGeometry.attributes.position.needsUpdate = true;
const tone =
gap > 1.7 ? 0x4b9b73 : gap > 0.85 ? 0xd69a3b : 0xe8893d;
gapMaterial.color.setHex(tone);
laneMaterial.color.setHex(tone);
projectedPoint.set(4.28, 0.22, middle).project(camera);
const screenX = (projectedPoint.x * 0.5 + 0.5) * window.innerWidth;
const screenY = (-projectedPoint.y * 0.5 + 0.5) * window.innerHeight;
clearanceTag.style.left = `${screenX}px`;
clearanceTag.style.top = `${screenY}px`;
clearanceTag.textContent = `${gap.toFixed(2)} m clear`;
}
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
// Smoothly move the sliding panel.
doorProgress = THREE.MathUtils.damp(
doorProgress,
doorTarget,
6.5,
delta
);
if (Math.abs(doorProgress - doorTarget) < 0.0001) {
doorProgress = doorTarget;
}
const center = panelCenter(doorProgress);
doorPanel.position.z = center;
const gap = currentGap(doorProgress);
const front = panelFront(doorProgress);
clearanceValue.textContent = `${gap.toFixed(2)} m`;
updateGapMarker(gap, front);
if (pendingCross && Math.abs(doorProgress - doorTarget) < 0.012) {
pendingCross = false;
beginCrossing();
}
if (crossing) {
crossingElapsed += delta;
if (crossingBlocked) {
const t = Math.min(crossingElapsed / BLOCKED_DURATION, 1);
basketX = THREE.MathUtils.lerp(
BASKET_START_X,
BASKET_STOP_X,
easeOutCubic(t)
);
basket.rotation.z = Math.sin(crossingElapsed * 17) * 0.025 * (1 - t);
progressFill.style.width = `${t * 100}%`;
if (t >= 1) {
crossing = false;
crossButton.disabled = false;
crossButton.textContent = "Try again";
setStatus("Blocked — slide the panel farther open", "orange");
lastResult = "blocked";
}
} else {
const t = Math.min(crossingElapsed / CROSS_DURATION, 1);
const eased = easeInOutCubic(t);
basketX = THREE.MathUtils.lerp(
BASKET_START_X,
BASKET_END_X,
eased
);
basket.rotation.z = Math.sin(crossingElapsed * 11) * 0.018;
basket.rotation.y = Math.sin(crossingElapsed * 5) * 0.025;
progressFill.style.width = `${t * 100}%`;
if (t >= 1) {
crossing = false;
crossButton.disabled = false;
crossButton.textContent = "Replay crossing";
setStatus("Basket cleared the doorway", "green");
lastResult = "clear";
}
}
} else if (lastResult === "clear") {
basket.rotation.z = THREE.MathUtils.damp(
basket.rotation.z,
0,
5,
delta
);
basket.rotation.y = THREE.MathUtils.damp(
basket.rotation.y,
0,
5,
delta
);
}
basket.position.x = basketX;
// Very subtle movement in the laundry.
clothA.position.y = 0.73 + Math.sin(clock.elapsedTime * 2.2) * 0.006;
clothB.position.y = 0.75 + Math.sin(clock.elapsedTime * 2.2 + 1.7) * 0.006;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(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));
});
setDoorPosition(0);
</script>
</body>
</html>
```