Prompt specification
Build or customize the Three.js 3D scene "Ventilated laundry basket" 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: Ventilated laundry basket
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/ventilated-laundry-basket-x0045
Scene Description Prompt:
Ventilated laundry basket. Build a tapered basket with rectangular ventilation holes, reinforced rim, and opposing handles; place one folded towel inside without hiding the patterned side walls. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (ventilated-laundry-basket-x0045):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voxel Ventilated Laundry Basket</title>
<style>
:root {
color-scheme: light;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e4da;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.info {
position: fixed;
top: 24px;
left: 24px;
z-index: 2;
max-width: 320px;
padding: 16px 18px;
border: 1px solid rgba(92, 70, 44, 0.18);
border-radius: 14px;
background: rgba(255, 252, 246, 0.78);
box-shadow: 0 12px 35px rgba(76, 58, 36, 0.1);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
margin: 0 0 7px;
color: #9a6b3f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: #463727;
font-size: clamp(20px, 3vw, 29px);
line-height: 1.06;
letter-spacing: -0.035em;
}
.subtitle {
margin: 9px 0 0;
color: #766653;
font-size: 12px;
line-height: 1.45;
}
.controls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 3;
display: flex;
align-items: center;
gap: 12px;
padding: 8px 9px 8px 14px;
border: 1px solid rgba(92, 70, 44, 0.17);
border-radius: 999px;
background: rgba(255, 252, 246, 0.84);
box-shadow: 0 10px 28px rgba(76, 58, 36, 0.1);
backdrop-filter: blur(12px);
color: #746554;
font-size: 11px;
font-weight: 650;
}
button {
appearance: none;
border: 0;
border-radius: 999px;
padding: 9px 13px;
background: #765337;
color: #fffaf1;
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
background: #8b6341;
transform: translateY(-1px);
}
button:active {
transform: translateY(0);
}
@media (max-width: 640px) {
.info {
top: 14px;
left: 14px;
right: 14px;
max-width: none;
}
.subtitle {
display: none;
}
.controls {
right: 14px;
bottom: 14px;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section class="info">
<p class="eyebrow">Voxel Object Study · 01</p>
<h1>Ventilated Laundry Basket</h1>
<p class="subtitle">
Tapered woven walls, true rectangular ventilation openings,
reinforced double rim, and opposing block-built handles.
</p>
</section>
<div class="controls">
<span>Drag to rotate · Scroll to zoom</span>
<button id="reset-view" type="button">Reset view</button>
</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 renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e4da);
scene.fog = new THREE.Fog(0xe9e4da, 15, 32);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 1.55, 0);
const initialView = {
azimuth: 0.68,
elevation: 0.69,
radius: 10.8
};
const view = {
azimuth: initialView.azimuth,
elevation: initialView.elevation,
radius: initialView.radius,
desiredAzimuth: initialView.azimuth,
desiredElevation: initialView.elevation,
desiredRadius: initialView.radius
};
function updateCamera() {
const horizontalRadius = view.radius * Math.cos(view.elevation);
camera.position.set(
cameraTarget.x + horizontalRadius * Math.sin(view.azimuth),
cameraTarget.y + view.radius * Math.sin(view.elevation),
cameraTarget.z + horizontalRadius * Math.cos(view.azimuth)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Lighting
const hemisphere = new THREE.HemisphereLight(0xfff8e9, 0x756d62, 1.65);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1d7, 3.1);
keyLight.position.set(6, 11, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xd9e9ff, 0.85);
fillLight.position.set(-7, 5, -5);
scene.add(fillLight);
// Ground
const groundGeometry = new THREE.PlaneGeometry(40, 40);
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe9e4da,
roughness: 0.96,
metalness: 0
});
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
// All visible basket and fabric geometry is assembled from rectangular blocks.
const blockGeometry = new THREE.BoxGeometry(1, 1, 1);
const blockGroups = {
wood: [],
fabric: []
};
const colorCache = new Map();
function getColor(color) {
if (!colorCache.has(color)) {
colorCache.set(color, new THREE.Color(color));
}
return colorCache.get(color);
}
function addBlock(group, x, y, z, sx, sy, sz, color) {
const matrix = new THREE.Matrix4();
matrix.compose(
new THREE.Vector3(x, y, z),
new THREE.Quaternion(),
new THREE.Vector3(sx, sy, sz)
);
blockGroups[group].push({
matrix,
color: getColor(color)
});
}
const woodPalette = {
light: 0xe4c18a,
pale: 0xefd3a0,
honey: 0xd2a05c,
warm: 0xc38d4d,
frame: 0xa66e3a,
rim: 0x765037,
rimLight: 0xb4824d
};
const fabricPalette = {
coral: 0xd87f69,
coralDark: 0xc96f5d,
coralLight: 0xe89a80,
cream: 0xf1d2b4,
seam: 0xb65e50
};
// Basket base: a low grid of individual voxel blocks.
const baseColsX = 12;
const baseColsZ = 8;
const baseHalfWidth = 2.05;
const baseHalfDepth = 1.48;
const baseCellX = (baseHalfWidth * 2) / baseColsX;
const baseCellZ = (baseHalfDepth * 2) / baseColsZ;
for (let row = 0; row < baseColsZ; row++) {
for (let col = 0; col < baseColsX; col++) {
const x = -baseHalfWidth + (col + 0.5) * baseCellX;
const z = -baseHalfDepth + (row + 0.5) * baseCellZ;
let color = (row + col) % 2 === 0
? woodPalette.warm
: woodPalette.honey;
if (row === 0 || row === baseColsZ - 1) {
color = woodPalette.frame;
}
addBlock(
"wood",
x,
0.18,
z,
baseCellX * 0.92,
0.28,
baseCellZ * 0.92,
color
);
}
}
// Tapered patterned walls.
const wallRows = 7;
const frontCols = 14;
const sideCols = 10;
const rowHeight = 0.36;
const rowStep = 0.385;
const wallBaseY = 0.50;
const bottomHalfWidth = 2.05;
const topHalfWidth = 2.75;
const bottomHalfDepth = 1.48;
const topHalfDepth = 2.10;
const ventRows = new Set([1, 2, 4, 5]);
const frontVentColumns = new Set([2, 3, 6, 7, 10, 11]);
const sideVentColumns = new Set([2, 3, 6, 7]);
function frontIsVent(row, col) {
return ventRows.has(row) && frontVentColumns.has(col);
}
function sideIsVent(row, col) {
return ventRows.has(row) && sideVentColumns.has(col);
}
function wallColor(row, col, isVent, baseA, baseB) {
const neighboringCells = [
[row - 1, col],
[row + 1, col],
[row, col - 1],
[row, col + 1]
];
const touchesOpening = neighboringCells.some(([r, c]) => {
if (r < 0 || r >= wallRows) return false;
return isVent(r, c);
});
if (touchesOpening) return woodPalette.frame;
const base = (row + col) % 2 === 0 ? baseA : baseB;
if ((row * 3 + col * 5) % 11 === 0) {
return woodPalette.pale;
}
return base;
}
for (let row = 0; row < wallRows; row++) {
const t = row / (wallRows - 1);
const halfWidth = THREE.MathUtils.lerp(
bottomHalfWidth,
topHalfWidth,
t
);
const halfDepth = THREE.MathUtils.lerp(
bottomHalfDepth,
topHalfDepth,
t
);
const y = wallBaseY + row * rowStep;
const frontCell = (halfWidth * 2) / frontCols;
const sideCell = (halfDepth * 2) / sideCols;
// Front and rear walls.
for (const side of [-1, 1]) {
for (let col = 0; col < frontCols; col++) {
if (frontIsVent(row, col)) continue;
const x = -halfWidth + (col + 0.5) * frontCell;
const z = side * halfDepth;
addBlock(
"wood",
x,
y,
z,
frontCell * 0.91,
rowHeight,
0.25,
wallColor(
row,
col,
frontIsVent,
woodPalette.light,
woodPalette.honey
)
);
}
}
// Left and right walls.
for (const side of [-1, 1]) {
for (let col = 0; col < sideCols; col++) {
if (sideIsVent(row, col)) continue;
const z = -halfDepth + (col + 0.5) * sideCell;
const x = side * halfWidth;
addBlock(
"wood",
x,
y,
z,
0.25,
rowHeight,
sideCell * 0.91,
wallColor(
row,
col,
sideIsVent,
woodPalette.pale,
woodPalette.warm
)
);
}
}
// Reinforced corner posts.
for (const xSide of [-1, 1]) {
for (const zSide of [-1, 1]) {
addBlock(
"wood",
xSide * (halfWidth - 0.08),
y,
zSide * (halfDepth - 0.08),
0.31,
rowHeight + 0.015,
0.31,
woodPalette.frame
);
}
}
}
// Double reinforced rim.
const rimHalfWidth = topHalfWidth;
const rimHalfDepth = topHalfDepth;
const rimFrontCell = (rimHalfWidth * 2) / frontCols;
const rimSideCell = (rimHalfDepth * 2) / sideCols;
for (let layer = 0; layer < 2; layer++) {
const rimY = layer === 0 ? 3.10 : 3.31;
const rimHeight = layer === 0 ? 0.24 : 0.20;
for (const side of [-1, 1]) {
for (let col = 0; col < frontCols; col++) {
addBlock(
"wood",
-rimHalfWidth + (col + 0.5) * rimFrontCell,
rimY,
side * rimHalfDepth,
rimFrontCell * 0.96,
rimHeight,
0.34,
(col + layer) % 2 === 0
? woodPalette.rimLight
: woodPalette.rim
);
}
for (let col = 0; col < sideCols; col++) {
addBlock(
"wood",
side * rimHalfWidth,
rimY,
-rimHalfDepth + (col + 0.5) * rimSideCell,
0.34,
rimHeight,
rimSideCell * 0.96,
(col + layer + 1) % 2 === 0
? woodPalette.rimLight
: woodPalette.rim
);
}
}
for (const xSide of [-1, 1]) {
for (const zSide of [-1, 1]) {
addBlock(
"wood",
xSide * rimHalfWidth,
rimY,
zSide * rimHalfDepth,
0.39,
rimHeight + 0.025,
0.39,
woodPalette.rim
);
}
}
}
// Opposing stepped handles. Each handle is an open, block-built grip.
for (const side of [-1, 1]) {
for (const z of [-0.62, 0.62]) {
addBlock(
"wood",
side * 2.90,
3.12,
z,
0.46,
0.42,
0.34,
woodPalette.rim
);
addBlock(
"wood",
side * 3.19,
3.46,
z,
0.38,
0.38,
0.34,
woodPalette.rimLight
);
addBlock(
"wood",
side * 3.44,
3.75,
z,
0.38,
0.38,
0.34,
woodPalette.rim
);
}
// Top grip, assembled from five visible blocks.
for (let i = 0; i < 5; i++) {
addBlock(
"wood",
side * 3.44,
3.98,
-0.56 + i * 0.28,
0.38,
0.30,
0.25,
i === 2 ? woodPalette.rimLight : woodPalette.rim
);
}
}
// One folded towel, kept low and toward the rear so the wall
// openings and all four tapered sides remain visible.
const towelUnit = 0.30;
// Lower folded layer.
for (let row = 0; row < 4; row++) {
for (let col = 0; col < 7; col++) {
const x = -0.45 + (col - 3) * towelUnit;
const z = -0.25 + (row - 1.5) * towelUnit;
let color = (row + col) % 2 === 0
? fabricPalette.coral
: fabricPalette.coralDark;
if (col === 2) color = fabricPalette.cream;
if (row === 3 && col === 5) color = fabricPalette.coralLight;
addBlock(
"fabric",
x,
0.48,
z,
0.285,
0.28,
0.285,
color
);
}
}
// Upper folded-over layer.
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 6; col++) {
const x = -0.35 + (col - 2.5) * towelUnit;
const z = -0.10 + (row - 1) * towelUnit;
let color = (row + col) % 2 === 0
? fabricPalette.coralLight
: fabricPalette.coral;
if (col === 1) color = fabricPalette.cream;
if (row === 0 && col === 4) color = fabricPalette.seam;
addBlock(
"fabric",
x,
0.72,
z,
0.285,
0.24,
0.285,
color
);
}
}
// Build the instanced block meshes after all pieces have been placed.
const groupMaterials = {
wood: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.72,
metalness: 0
}),
fabric: new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
metalness: 0
})
};
for (const [groupName, blocks] of Object.entries(blockGroups)) {
const mesh = new THREE.InstancedMesh(
blockGeometry,
groupMaterials[groupName],
blocks.length
);
blocks.forEach((block, index) => {
mesh.setMatrixAt(index, block.matrix);
mesh.setColorAt(index, block.color);
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.computeBoundingSphere();
scene.add(mesh);
}
// Custom orbit controls implemented directly without addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
view.desiredAzimuth -= deltaX * 0.0065;
view.desiredElevation = THREE.MathUtils.clamp(
view.desiredElevation + deltaY * 0.005,
0.38,
1.05
);
});
function stopDragging(event) {
dragging = false;
if (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();
view.desiredRadius = THREE.MathUtils.clamp(
view.desiredRadius * Math.exp(event.deltaY * 0.001),
7.6,
16
);
},
{ passive: false }
);
function resetView() {
view.desiredAzimuth = initialView.azimuth;
view.desiredElevation = initialView.elevation;
view.desiredRadius = initialView.radius;
}
document.getElementById("reset-view").addEventListener(
"click",
resetView
);
window.addEventListener("keydown", (event) => {
if (event.key === "r" || event.key === "R") resetView();
if (event.key === "ArrowLeft") {
view.desiredAzimuth -= 0.12;
}
if (event.key === "ArrowRight") {
view.desiredAzimuth += 0.12;
}
if (event.key === "ArrowUp") {
view.desiredElevation = THREE.MathUtils.clamp(
view.desiredElevation + 0.08,
0.38,
1.05
);
}
if (event.key === "ArrowDown") {
view.desiredElevation = THREE.MathUtils.clamp(
view.desiredElevation - 0.08,
0.38,
1.05
);
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
function animate() {
requestAnimationFrame(animate);
const damping = 0.12;
view.azimuth +=
(view.desiredAzimuth - view.azimuth) * damping;
view.elevation +=
(view.desiredElevation - view.elevation) * damping;
view.radius +=
(view.desiredRadius - view.radius) * damping;
updateCamera();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```