Prompt specification
Build or customize the Three.js 3D scene "Household extension cable reel" 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: Household extension cable reel
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/household-extension-cable-reel-x0025
Scene Description Prompt:
A voxel extension-cable reel with layered cable, handle, plug, and socket panel. Build one HTML file with Three.js from cdnjs.
Working Three.js Starter (household-extension-cable-reel-x0025):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Extension-Cable Reel</title>
<style>
:root {
color-scheme: light;
--ink: #1d2a35;
--muted: #617079;
--paper: rgba(248, 246, 238, 0.88);
--line: rgba(29, 42, 53, 0.14);
--accent: #f5a623;
--teal: #159b8c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8efeb;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#app,
canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
canvas {
display: block;
touch-action: none;
outline: none;
}
.overlay {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.card {
position: absolute;
top: 24px;
left: 24px;
width: min(350px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--paper);
box-shadow: 0 16px 42px rgba(36, 52, 59, 0.12);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--accent);
box-shadow: 14px 0 0 var(--teal);
margin-right: 14px;
}
h1 {
margin: 0;
font-size: clamp(24px, 4vw, 38px);
line-height: 0.98;
letter-spacing: -0.045em;
}
.card p {
margin: 12px 0 0;
max-width: 280px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.controls {
position: absolute;
left: 24px;
bottom: 24px;
display: flex;
flex-wrap: wrap;
gap: 8px;
pointer-events: auto;
}
button {
border: 1px solid var(--line);
border-radius: 11px;
padding: 10px 13px;
background: var(--paper);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
box-shadow: 0 8px 20px rgba(36, 52, 59, 0.08);
backdrop-filter: blur(10px);
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
transform: translateY(-2px);
background: #fffdf6;
}
button:active {
transform: translateY(0);
}
.hint {
display: flex;
align-items: center;
border: 1px solid var(--line);
border-radius: 11px;
padding: 10px 13px;
background: rgba(248, 246, 238, 0.74);
color: var(--muted);
font-size: 12px;
backdrop-filter: blur(10px);
}
.key {
display: inline-grid;
place-items: center;
min-width: 21px;
height: 21px;
margin-right: 5px;
border: 1px solid rgba(29, 42, 53, 0.2);
border-bottom-width: 2px;
border-radius: 5px;
background: #fffdf7;
color: var(--ink);
font-size: 10px;
font-weight: 800;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e8efeb;
color: var(--ink);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 600px) {
.card {
top: 14px;
left: 14px;
width: min(300px, calc(100vw - 28px));
padding: 14px 16px;
}
.card p {
display: none;
}
.controls {
left: 14px;
right: 14px;
bottom: 14px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<div class="overlay">
<section class="card">
<div class="eyebrow">Voxel Utility Series</div>
<h1>Extension<br />Cable Reel</h1>
<p>
A layered voxel reel with a reinforced handle, heavy-gauge cable,
inserted plug, and three-outlet socket panel.
</p>
</section>
<div class="controls">
<div class="hint">
<span class="key">↔</span>
Drag to orbit
<span class="key" style="margin-left: 8px">↕</span>
Scroll to zoom
</div>
<button id="reset" type="button">Reset view</button>
</div>
</div>
<div id="loading">Building the reel…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer and scene
// ---------------------------------------------------------------------
const app = document.getElementById("app");
const loading = document.getElementById("loading");
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8efeb);
scene.fog = new THREE.Fog(0xe8efeb, 12, 26);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0.35, 1.28, 0.3);
const desired = {
theta: 0.58,
phi: 1.0,
radius: window.innerWidth < 700 ? 9.2 : 7.8
};
const smooth = {
theta: desired.theta,
phi: desired.phi,
radius: desired.radius
};
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xf5fbff, 0x8a806b, 2.1));
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.3);
keyLight.position.set(4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 24;
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.bias = -0.00015;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb7e7e4, 1.25);
fillLight.position.set(-5, 3, -3);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffd19a, 1.1);
rimLight.position.set(1, 4, -6);
scene.add(rimLight);
// ---------------------------------------------------------------------
// Materials and geometry helpers
// ---------------------------------------------------------------------
const material = (color, roughness = 0.72, metalness = 0.02) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const mat = {
gold: material(0xf5a623),
goldDark: material(0xd9850d),
navy: material(0x1d2a35),
navyLight: material(0x304451),
teal: material(0x159b8c),
tealDark: material(0x10766e),
tealLight: material(0x35b4a4),
cream: material(0xf6f0df),
coral: material(0xf36f56),
black: material(0x10181d),
steel: material(0xb9c4c3, 0.42, 0.48),
green: material(0x65d39b),
floor: material(0xdce7df, 0.94)
};
function addBox(
parent,
size,
position,
boxMaterial,
rotation = [0, 0, 0]
) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
boxMaterial
);
mesh.position.set(position[0], position[1], position[2]);
mesh.rotation.set(rotation[0], rotation[1], rotation[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addVoxelRing(
parent,
radius,
count,
z,
ringMaterial,
depth = 0.16,
radialSize = 0.13,
segmentSize = 0.17,
phase = 0
) {
for (let i = 0; i < count; i++) {
const angle = phase + (i / count) * Math.PI * 2;
addBox(
parent,
[segmentSize, radialSize, depth],
[
Math.cos(angle) * radius,
Math.sin(angle) * radius,
z
],
ringMaterial,
[0, 0, angle + Math.PI / 2]
);
}
}
// ---------------------------------------------------------------------
// Ground
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
mat.floor
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.015;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(
30,
30,
0xaebfb7,
0xc3d1ca
);
grid.position.y = 0.002;
grid.material.transparent = true;
grid.material.opacity = 0.28;
scene.add(grid);
// ---------------------------------------------------------------------
// Main cable reel
// ---------------------------------------------------------------------
const reel = new THREE.Group();
reel.position.set(-0.75, 1.48, -0.05);
scene.add(reel);
// Rear and front outer frames.
addVoxelRing(
reel,
1.07,
48,
-0.43,
mat.goldDark,
0.19,
0.19,
0.19
);
addVoxelRing(
reel,
1.07,
48,
0.43,
mat.gold,
0.19,
0.19,
0.19
);
// Four structural rails bridging the two frame plates.
for (let i = 0; i < 4; i++) {
const angle = Math.PI / 4 + (i * Math.PI) / 2;
addBox(
reel,
[0.17, 0.17, 0.79],
[
Math.cos(angle) * 0.99,
Math.sin(angle) * 0.99,
0
],
mat.navy,
[0, 0, angle]
);
}
// Layered cable winding.
addVoxelRing(
reel,
0.39,
42,
-0.31,
mat.tealDark,
0.17,
0.13,
0.16
);
addVoxelRing(
reel,
0.56,
48,
-0.12,
mat.teal,
0.18,
0.14,
0.17
);
addVoxelRing(
reel,
0.73,
52,
0.07,
mat.tealLight,
0.18,
0.14,
0.17
);
addVoxelRing(
reel,
0.89,
56,
0.26,
mat.teal,
0.17,
0.15,
0.17
);
// Dark winding grooves between the teal cable layers.
for (let i = 0; i < 4; i++) {
const angle = Math.PI / 4 + (i * Math.PI) / 2;
addBox(
reel,
[1.87, 0.075, 0.065],
[0, 0, 0.345],
mat.navy,
[0, 0, angle]
);
}
// Front hub, made from stacked square blocks.
addBox(reel, [0.47, 0.47, 0.19], [0, 0, 0.48], mat.gold);
addBox(reel, [0.34, 0.34, 0.22], [0, 0, 0.57], mat.navy);
addBox(reel, [0.15, 0.15, 0.12], [0, 0, 0.72], mat.coral);
// Square bolts around the front rim.
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
addBox(
reel,
[0.105, 0.105, 0.065],
[
Math.cos(angle) * 1.07,
Math.sin(angle) * 1.07,
0.555
],
mat.cream,
[0, 0, angle]
);
}
// Reinforced carrying handle.
addBox(reel, [0.18, 0.68, 0.22], [-0.66, 1.32, -0.08], mat.navy);
addBox(reel, [0.18, 0.68, 0.22], [0.66, 1.32, -0.08], mat.navy);
addBox(reel, [1.51, 0.20, 0.24], [0, 1.68, -0.08], mat.navy);
addBox(reel, [1.12, 0.235, 0.255], [0, 1.69, -0.08], mat.coral);
// Handle fasteners.
addBox(
reel,
[0.25, 0.25, 0.10],
[-0.66, 1.03, 0.12],
mat.gold
);
addBox(
reel,
[0.25, 0.25, 0.10],
[0.66, 1.03, 0.12],
mat.gold
);
// Cable outlet and strain relief.
addBox(
reel,
[0.28, 0.22, 0.27],
[0.84, -0.69, 0.03],
mat.gold,
[0, 0, -0.25]
);
addBox(
reel,
[0.27, 0.17, 0.20],
[0.95, -0.73, 0.03],
mat.tealDark,
[0, 0, -0.25]
);
// ---------------------------------------------------------------------
// Socket panel
// ---------------------------------------------------------------------
const panel = new THREE.Group();
panel.position.set(2.25, 0.82, 1.25);
scene.add(panel);
// Main housing and stable foot.
addBox(panel, [1.92, 1.43, 0.38], [0, 0, 0], mat.gold);
addBox(panel, [1.68, 1.19, 0.065], [0, 0, 0.215], mat.cream);
addBox(panel, [1.48, 0.12, 0.74], [0, -0.76, -0.03], mat.navy);
// Three outlet modules.
const outletXs = [-0.53, 0, 0.53];
for (const x of outletXs) {
addBox(
panel,
[0.43, 0.56, 0.07],
[x, -0.07, 0.275],
mat.navy
);
// Two vertical slots and lower grounding opening.
addBox(
panel,
[0.055, 0.18, 0.018],
[x - 0.085, 0.01, 0.321],
mat.black
);
addBox(
panel,
[0.055, 0.18, 0.018],
[x + 0.085, 0.01, 0.321],
mat.black
);
addBox(
panel,
[0.10, 0.06, 0.018],
[x, -0.15, 0.321],
mat.black
);
}
// Plug inserted into the left outlet.
addBox(
panel,
[0.39, 0.51, 0.10],
[-0.53, -0.07, 0.32],
mat.goldDark
);
addBox(
panel,
[0.29, 0.41, 0.30],
[-0.53, -0.07, 0.48],
mat.coral
);
addBox(
panel,
[0.16, 0.19, 0.18],
[-0.53, -0.34, 0.45],
mat.tealDark
);
// Small power switch and status light.
addBox(
panel,
[0.32, 0.17, 0.075],
[0.54, 0.43, 0.285],
mat.navy
);
addBox(
panel,
[0.12, 0.09, 0.025],
[0.61, 0.43, 0.334],
mat.green
);
// Faceplate screws.
for (const x of [-0.73, 0.73]) {
for (const y of [-0.49, 0.49]) {
addBox(
panel,
[0.065, 0.065, 0.025],
[x, y, 0.265],
mat.goldDark
);
}
}
// ---------------------------------------------------------------------
// Voxel extension cable from reel to plug
// ---------------------------------------------------------------------
const cableCurve = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(0.17, 0.78, 0.03),
new THREE.Vector3(0.45, 0.56, 0.30),
new THREE.Vector3(0.78, 0.27, 0.72),
new THREE.Vector3(1.10, 0.19, 1.13),
new THREE.Vector3(1.43, 0.25, 1.57),
new THREE.Vector3(1.64, 0.40, 1.76),
new THREE.Vector3(1.72, 0.49, 1.70),
new THREE.Vector3(1.72, 0.48, 1.61)
],
false,
"centripetal"
);
const cableCount = 170;
const cableGeometry = new THREE.BoxGeometry(0.115, 0.115, 0.115);
const cableMesh = new THREE.InstancedMesh(
cableGeometry,
mat.teal,
cableCount
);
const dummy = new THREE.Object3D();
for (let i = 0; i < cableCount; i++) {
const t = i / (cableCount - 1);
const point = cableCurve.getPointAt(t);
const tangent = cableCurve.getTangentAt(t);
dummy.position.copy(point);
dummy.rotation.set(
Math.atan2(tangent.z, tangent.y),
Math.atan2(tangent.x, Math.sqrt(tangent.y ** 2 + tangent.z ** 2)),
0
);
dummy.updateMatrix();
cableMesh.setMatrixAt(i, dummy.matrix);
}
cableMesh.instanceMatrix.needsUpdate = true;
cableMesh.castShadow = true;
cableMesh.receiveShadow = true;
scene.add(cableMesh);
// Small connector collar where the cable meets the plug.
addBox(
panel,
[0.19, 0.10, 0.19],
[-0.53, -0.43, 0.45],
mat.teal
);
// ---------------------------------------------------------------------
// Custom camera controls
// ---------------------------------------------------------------------
const pointers = new Map();
let lastPinchDistance = 0;
function clampDesired() {
desired.phi = THREE.MathUtils.clamp(desired.phi, 0.42, 1.43);
desired.radius = THREE.MathUtils.clamp(desired.radius, 4.6, 13.5);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const values = [...pointers.values()];
lastPinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 1) {
desired.theta -= dx * 0.007;
desired.phi -= dy * 0.006;
} else if (pointers.size === 2) {
const values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (lastPinchDistance > 0 && distance > 0) {
desired.radius *= lastPinchDistance / distance;
}
lastPinchDistance = distance;
}
clampDesired();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius *= Math.exp(event.deltaY * 0.001);
clampDesired();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
desired.theta = 0.58;
desired.phi = 1.0;
desired.radius = window.innerWidth < 700 ? 9.2 : 7.8;
});
document.getElementById("reset").addEventListener("click", () => {
desired.theta = 0.58;
desired.phi = 1.0;
desired.radius = window.innerWidth < 700 ? 9.2 : 7.8;
});
window.addEventListener("keydown", (event) => {
const step = 0.09;
if (event.key === "ArrowLeft") desired.theta += step;
if (event.key === "ArrowRight") desired.theta -= step;
if (event.key === "ArrowUp") desired.phi -= step;
if (event.key === "ArrowDown") desired.phi += step;
if (event.key === "+" || event.key === "=") desired.radius -= 0.35;
if (event.key === "-") desired.radius += 0.35;
clampDesired();
});
// ---------------------------------------------------------------------
// Resize and render loop
// ---------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const damping = 1 - Math.exp(-9 * delta);
smooth.theta += (desired.theta - smooth.theta) * damping;
smooth.phi += (desired.phi - smooth.phi) * damping;
smooth.radius += (desired.radius - smooth.radius) * damping;
const sinPhi = Math.sin(smooth.phi);
camera.position.set(
target.x +
smooth.radius * sinPhi * Math.sin(smooth.theta),
target.y + smooth.radius * Math.cos(smooth.phi),
target.z +
smooth.radius * sinPhi * Math.cos(smooth.theta)
);
camera.lookAt(target);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 350);
});
</script>
</body>
</html>
```