Prompt specification
Build or customize the Three.js 3D scene "Raincoat seam and coated fabric" 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: Raincoat seam and coated fabric
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/raincoat-seam-and-coated-fabric-x0609
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: raincoat seam and coated fabric. Model a folded raincoat panel with taped seam and droplets resting on its surface; expose a small cross-section separating fabric, coating, and seam tape. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (raincoat-seam-and-coated-fabric-x0609):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Raincoat Seam — Voxel Material Study</title>
<style>
:root {
color-scheme: dark;
--ink: #e8f5fb;
--muted: #8da9b8;
--cyan: #65d9f1;
--amber: #f1b453;
--teal: #38d7cf;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #091119;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.header {
position: absolute;
top: 28px;
left: 32px;
max-width: 420px;
text-shadow: 0 2px 18px #061018;
}
.eyebrow {
color: var(--cyan);
font: 600 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .18em;
text-transform: uppercase;
}
h1 {
margin: 10px 0 7px;
font-size: clamp(28px, 4vw, 48px);
line-height: .98;
letter-spacing: -.055em;
font-weight: 750;
}
.subtitle {
margin: 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.badge {
position: absolute;
top: 30px;
right: 32px;
padding: 9px 12px;
border: 1px solid #284352;
border-radius: 3px;
color: #a9c5d3;
background: #0b1822c9;
font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .13em;
text-transform: uppercase;
}
.legend {
position: absolute;
left: 32px;
bottom: 30px;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: min(620px, calc(100vw - 64px));
}
.legend-item,
.control-hint {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 9px 11px;
border: 1px solid #1d3745;
border-radius: 3px;
background: #0b1822d9;
color: #a9c2cf;
font: 500 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .04em;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 1px;
box-shadow: 0 0 10px currentColor;
}
.swatch.fabric { color: #217a98; background: #217a98; }
.swatch.coating { color: #55e3df; background: #55e3df; }
.swatch.tape { color: var(--amber); background: var(--amber); }
.swatch.drop { color: #75ddf7; background: #75ddf7; }
.control-hint {
position: absolute;
right: 32px;
bottom: 30px;
color: #7898a8;
}
button {
pointer-events: auto;
border: 1px solid #315364;
border-radius: 2px;
padding: 5px 8px;
background: #142a37;
color: #b9d4df;
cursor: pointer;
font: inherit;
}
button:hover {
border-color: var(--cyan);
color: white;
}
#labels {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.tag {
position: absolute;
min-width: 138px;
padding: 8px 10px 8px 12px;
border-left: 2px solid var(--cyan);
border-radius: 0 3px 3px 0;
background: #09151ddb;
box-shadow: 0 8px 24px #03090d66;
transform: translate(12px, -50%);
transition: opacity .15s ease;
}
.tag.left {
border-left: 0;
border-right: 2px solid var(--cyan);
border-radius: 3px 0 0 3px;
transform: translate(calc(-100% - 12px), -50%);
}
.tag strong {
display: block;
color: #dff8ff;
font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .12em;
}
.tag small {
display: block;
margin-top: 4px;
color: #83a5b6;
font: 500 9px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: .04em;
}
.tag.coating { border-color: var(--teal); }
.tag.coating strong { color: var(--teal); }
.tag.tape { border-color: var(--amber); }
.tag.tape strong { color: var(--amber); }
@media (max-width: 760px) {
.header { top: 18px; left: 18px; }
.badge { display: none; }
.legend { left: 18px; bottom: 18px; max-width: calc(100vw - 36px); }
.control-hint { display: none; }
.tag { transform: translate(6px, -50%) scale(.86); transform-origin: left center; }
.tag.left { transform: translate(calc(-100% - 6px), -50%) scale(.86); transform-origin: right center; }
}
</style>
</head>
<body>
<canvas id="scene"></canvas>
<div class="hud">
<header class="header">
<div class="eyebrow">Material study / 03</div>
<h1>Raincoat<br>seam</h1>
<p class="subtitle">
A voxel study of folded coated fabric, a taped seam,
and droplets resting on the hydrophobic surface.
</p>
</header>
<div class="badge">Voxel Three.js / coated textile</div>
<div id="labels">
<div id="tagFabric" class="tag">
<strong>FABRIC</strong>
<small>woven base layer</small>
</div>
<div id="tagCoating" class="tag coating">
<strong>COATING</strong>
<small>hydrophobic film</small>
</div>
<div id="tagTape" class="tag tape">
<strong>SEAM TAPE</strong>
<small>bonded waterproof strip</small>
</div>
<div id="tagSeam" class="tag tape left">
<strong>TAPED SEAM</strong>
<small>continuous vertical bond</small>
</div>
</div>
<div class="legend">
<div class="legend-item"><i class="swatch fabric"></i>base fabric</div>
<div class="legend-item"><i class="swatch coating"></i>coating</div>
<div class="legend-item"><i class="swatch tape"></i>seam tape</div>
<div class="legend-item"><i class="swatch drop"></i>surface droplets</div>
</div>
<div class="control-hint">
drag to orbit · scroll to zoom
<button id="reset" type="button">reset</button>
</div>
</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 canvas = document.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
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;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x091119);
scene.fog = new THREE.Fog(0x091119, 30, 68);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
// Custom camera controls: no external control add-ons.
const controls = {
target: new THREE.Vector3(1.0, 5.8, 0.2),
radius: 29,
theta: 0.48,
phi: 1.17
};
const defaultControls = {
target: controls.target.clone(),
radius: controls.radius,
theta: controls.theta,
phi: controls.phi
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
updateCamera();
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0x9edcff, 0x101820, 1.65));
const keyLight = new THREE.DirectionalLight(0xd9f4ff, 3.1);
keyLight.position.set(-9, 18, 16);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -22;
keyLight.shadow.camera.right = 22;
keyLight.shadow.camera.top = 22;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 55;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x1ac8df, 2.2);
rimLight.position.set(13, 9, -12);
scene.add(rimLight);
const warmFill = new THREE.PointLight(0xffc77d, 1.4, 18, 2);
warmFill.position.set(8, 5, 7);
scene.add(warmFill);
// -------------------------------------------------------------------------
// Ground
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(90, 90),
new THREE.MeshStandardMaterial({
color: 0x0b1820,
roughness: 0.95,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.28;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(48, 48, 0x285064, 0x142b37);
grid.position.y = -0.26;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
const pool = new THREE.Mesh(
new THREE.CircleGeometry(11, 48),
new THREE.MeshBasicMaterial({
color: 0x123745,
transparent: true,
opacity: 0.22,
depthWrite: false
})
);
pool.rotation.x = -Math.PI / 2;
pool.position.set(-2, -0.255, 0.8);
scene.add(pool);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const fabricMaterials = [
new THREE.MeshPhysicalMaterial({
color: 0x176783,
roughness: 0.36,
metalness: 0.03,
clearcoat: 0.55,
clearcoatRoughness: 0.24
}),
new THREE.MeshPhysicalMaterial({
color: 0x1b7590,
roughness: 0.32,
metalness: 0.03,
clearcoat: 0.62,
clearcoatRoughness: 0.2
}),
new THREE.MeshPhysicalMaterial({
color: 0x135a74,
roughness: 0.4,
metalness: 0.02,
clearcoat: 0.48,
clearcoatRoughness: 0.28
})
];
const coatingMaterial = new THREE.MeshPhysicalMaterial({
color: 0x5be3df,
roughness: 0.14,
metalness: 0.04,
clearcoat: 1,
clearcoatRoughness: 0.08,
transparent: true,
opacity: 0.78,
depthWrite: false
});
const tapeMaterial = new THREE.MeshPhysicalMaterial({
color: 0xf1b453,
roughness: 0.28,
metalness: 0.03,
clearcoat: 0.48,
clearcoatRoughness: 0.22
});
const stitchMaterial = new THREE.MeshStandardMaterial({
color: 0xffe1a2,
roughness: 0.55
});
const dropletMaterial = new THREE.MeshPhysicalMaterial({
color: 0x68d8f3,
roughness: 0.06,
metalness: 0.08,
clearcoat: 1,
clearcoatRoughness: 0.04,
transparent: true,
opacity: 0.82,
emissive: 0x082f42,
emissiveIntensity: 0.25
});
const highlightMaterial = new THREE.MeshBasicMaterial({
color: 0xe8fcff,
transparent: true,
opacity: 0.72
});
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x8bcbd6,
transparent: true,
opacity: 0.38
});
function addEdges(mesh, color = 0x8bcbd6, opacity = 0.38) {
const edges = new THREE.EdgesGeometry(mesh.geometry, 25);
const line = new THREE.LineSegments(
edges,
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
line.renderOrder = 2;
mesh.add(line);
return line;
}
// -------------------------------------------------------------------------
// Folded raincoat panel
// -------------------------------------------------------------------------
const panel = new THREE.Group();
panel.position.set(-3.2, 0.28, 0);
panel.rotation.y = -0.075;
scene.add(panel);
const columns = 23;
const rows = 20;
const cellWidth = 0.62;
const cellHeight = 0.62;
// A shallow V-shaped fold around the central seam, with the hem curling forward.
function surfaceZ(x, y) {
const lowerFold = 0.58 * Math.exp(-Math.max(y, 0) * 0.44);
const centerFold = 0.085 * Math.abs(x);
const softFold = 0.09 * Math.sin(y * 0.48 + x * 0.22);
return 0.15 + lowerFold + centerFold + softFold;
}
const cellGeometry = new THREE.BoxGeometry(
cellWidth * 0.965,
cellHeight * 0.965,
0.22
);
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
const x = (column - (columns - 1) / 2) * cellWidth;
let y = (row + 0.5) * cellHeight;
// Slightly imperfect top edge keeps the textile feeling folded, not rigid.
if (row === rows - 1) {
y += Math.sin(x * 0.82) * 0.08;
}
const z = surfaceZ(x, y);
const materialIndex =
(column * 7 + row * 3 + Math.floor(column / 4)) % fabricMaterials.length;
const cell = new THREE.Mesh(cellGeometry, fabricMaterials[materialIndex]);
cell.position.set(x, y, z);
cell.castShadow = true;
cell.receiveShadow = true;
panel.add(cell);
}
}
// Central taped seam: a continuous chain of amber voxel segments.
const seamGeometry = new THREE.BoxGeometry(0.42, cellHeight * 0.91, 0.13);
for (let row = 0; row < rows; row++) {
const x = 0;
let y = (row + 0.5) * cellHeight;
if (row === rows - 1) {
y += Math.sin(x * 0.82) * 0.08;
}
const seam = new THREE.Mesh(seamGeometry, tapeMaterial);
seam.position.set(x, y, surfaceZ(x, y) + 0.175);
seam.castShadow = true;
panel.add(seam);
}
// Small stitch-like voxels along both sides of the tape.
const stitchGeometry = new THREE.BoxGeometry(0.09, 0.085, 0.055);
for (let row = 1; row < rows; row += 2) {
const y = (row + 0.5) * cellHeight;
for (const x of [-0.29, 0.29]) {
const stitch = new THREE.Mesh(stitchGeometry, stitchMaterial);
stitch.position.set(x, y, surfaceZ(x, y) + 0.26);
panel.add(stitch);
}
}
// A reinforced strip at the bottom hem.
const hemGeometry = new THREE.BoxGeometry(
columns * cellWidth * 0.96,
0.18,
0.27
);
const hem = new THREE.Mesh(hemGeometry, fabricMaterials[2]);
hem.position.set(
0,
0.17,
surfaceZ(0, 0.2) + 0.08
);
hem.castShadow = true;
panel.add(hem);
// -------------------------------------------------------------------------
// Voxel droplets resting on the front of the coated surface
// -------------------------------------------------------------------------
function makeDroplet(x, y, size) {
const droplet = new THREE.Group();
const z = surfaceZ(x, y) + 0.13;
const contact = new THREE.Mesh(
new THREE.BoxGeometry(size, size * 0.58, size * 0.22),
dropletMaterial
);
contact.position.set(0, 0, 0.03);
droplet.add(contact);
const body = new THREE.Mesh(
new THREE.BoxGeometry(size * 0.73, size * 0.72, size * 0.55),
dropletMaterial
);
body.position.set(0, size * 0.02, size * 0.22);
body.castShadow = true;
droplet.add(body);
const crown = new THREE.Mesh(
new THREE.BoxGeometry(size * 0.38, size * 0.45, size * 0.32),
dropletMaterial
);
crown.position.set(-size * 0.04, size * 0.12, size * 0.56);
crown.castShadow = true;
droplet.add(crown);
const glint = new THREE.Mesh(
new THREE.BoxGeometry(size * 0.13, size * 0.19, size * 0.08),
highlightMaterial
);
glint.position.set(
-size * 0.16,
size * 0.18,
size * 0.76
);
droplet.add(glint);
droplet.position.set(x, y, z);
panel.add(droplet);
}
[
[-5.15, 8.95, 0.72],
[-4.05, 6.85, 0.48],
[-2.65, 10.25, 0.58],
[-1.25, 4.65, 0.39],
[1.20, 8.20, 0.64],
[2.45, 10.75, 0.44],
[3.65, 6.25, 0.78],
[4.95, 9.10, 0.47],
[5.55, 3.95, 0.55],
[0.82, 2.95, 0.43]
].forEach((drop) => makeDroplet(...drop));
// -------------------------------------------------------------------------
// Exploded material cross-section
// -------------------------------------------------------------------------
const section = new THREE.Group();
section.position.set(7.4, 1.45, 1.0);
section.rotation.y = -0.22;
scene.add(section);
const sectionFabric = new THREE.Mesh(
new THREE.BoxGeometry(4.15, 0.68, 2.65),
new THREE.MeshPhysicalMaterial({
color: 0x176783,
roughness: 0.36,
clearcoat: 0.5,
clearcoatRoughness: 0.24
})
);
sectionFabric.position.set(0, 2.45, 0);
sectionFabric.castShadow = true;
sectionFabric.receiveShadow = true;
section.add(sectionFabric);
addEdges(sectionFabric, 0x67b4c8, 0.34);
const sectionCoating = new THREE.Mesh(
new THREE.BoxGeometry(4.15, 0.16, 2.65),
coatingMaterial
);
sectionCoating.position.set(0, 1.45, 0);
sectionCoating.castShadow = true;
section.add(sectionCoating);
addEdges(sectionCoating, 0x5be3df, 0.65);
const sectionTape = new THREE.Mesh(
new THREE.BoxGeometry(4.15, 0.31, 1.12),
tapeMaterial
);
sectionTape.position.set(0, 0.48, 0.15);
sectionTape.castShadow = true;
section.add(sectionTape);
addEdges(sectionTape, 0xffd27e, 0.52);
// Thin alignment guides make the separated layers read as one cutaway.
const guideMaterial = new THREE.LineDashedMaterial({
color: 0x6b9aaa,
dashSize: 0.16,
gapSize: 0.12,
transparent: true,
opacity: 0.5
});
for (const x of [-2.08, 2.08]) {
const guideGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x, 0.65, -0.95),
new THREE.Vector3(x, 1.28, -0.95),
new THREE.Vector3(x, 1.62, -0.95),
new THREE.Vector3(x, 2.12, -0.95),
new THREE.Vector3(x, 2.78, -0.95)
]);
const guide = new THREE.Line(guideGeometry, guideMaterial);
guide.computeLineDistances();
section.add(guide);
}
// A small sample block under the cutaway anchors the diagram visually.
const sample = new THREE.Mesh(
new THREE.BoxGeometry(4.65, 0.16, 3.05),
new THREE.MeshStandardMaterial({
color: 0x10252f,
roughness: 0.82,
metalness: 0.05
})
);
sample.position.set(0, -0.22, 0);
sample.receiveShadow = true;
section.add(sample);
// -------------------------------------------------------------------------
// HTML callouts anchored to the 3D scene
// -------------------------------------------------------------------------
const tagFabric = document.getElementById("tagFabric");
const tagCoating = document.getElementById("tagCoating");
const tagTape = document.getElementById("tagTape");
const tagSeam = document.getElementById("tagSeam");
const anchors = {
fabric: new THREE.Vector3(),
coating: new THREE.Vector3(),
tape: new THREE.Vector3(),
seam: new THREE.Vector3()
};
function updateAnchors() {
section.updateMatrixWorld(true);
panel.updateMatrixWorld(true);
anchors.fabric.copy(
section.localToWorld(new THREE.Vector3(2.02, 2.45, 0.2))
);
anchors.coating.copy(
section.localToWorld(new THREE.Vector3(2.02, 1.45, 0.2))
);
anchors.tape.copy(
section.localToWorld(new THREE.Vector3(2.02, 0.48, 0.2))
);
anchors.seam.copy(
panel.localToWorld(new THREE.Vector3(0, 7.2, 0.65))
);
}
function positionTag(element, worldPosition) {
const projected = worldPosition.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.opacity = visible ? "1" : "0";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
// -------------------------------------------------------------------------
// Direct orbit / zoom controls
// -------------------------------------------------------------------------
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
controls.theta -= dx * 0.007;
controls.phi = THREE.MathUtils.clamp(
controls.phi + dy * 0.006,
0.55,
1.48
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.018,
17,
43
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", resetCamera);
document.getElementById("reset").addEventListener("click", resetCamera);
function resetCamera() {
controls.target.copy(defaultControls.target);
controls.radius = defaultControls.radius;
controls.theta = defaultControls.theta;
controls.phi = defaultControls.phi;
updateCamera();
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
function animate() {
updateAnchors();
positionTag(tagFabric, anchors.fabric);
positionTag(tagCoating, anchors.coating);
positionTag(tagTape, anchors.tape);
positionTag(tagSeam, anchors.seam);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```