Prompt specification
Build or customize the Three.js 3D scene "Quilted jacket air-pocket section" 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: Quilted jacket air-pocket section
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/quilted-jacket-air-pocket-section-x0577
Scene Description Prompt:
Create a standalone stylized scene in one HTML file using Three.js from cdnjs. Show a jacket panel with outer fabric, inner lining, and puffed compartments; a cutaway reveals air spaces between fibers rather than solid filled blocks.
Working Three.js Starter (quilted-jacket-air-pocket-section-x0577):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cutaway Puffer Panel — Air, Not Fill</title>
<style>
:root {
color-scheme: dark;
--ink: #edf5f4;
--muted: #91a8ad;
--teal: #66d4ce;
--orange: #f0a064;
--panel: rgba(7, 18, 27, 0.78);
--line: rgba(150, 218, 215, 0.25);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 68% 42%, #12313a 0%, #08141e 45%, #050b12 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 5;
}
.intro {
position: absolute;
top: 32px;
left: 34px;
width: min(330px, calc(100vw - 68px));
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 15px;
color: var(--teal);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 1px;
background: currentColor;
content: "";
}
h1 {
margin: 0;
font-size: clamp(32px, 4vw, 58px);
font-weight: 520;
letter-spacing: -0.055em;
line-height: 0.98;
}
.intro p {
max-width: 295px;
margin: 18px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.65;
}
.legend {
display: grid;
gap: 8px;
margin-top: 22px;
}
.legend-item {
display: flex;
align-items: center;
gap: 10px;
color: #b9c9cc;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.swatch {
width: 18px;
height: 8px;
border-radius: 99px;
background: var(--swatch);
box-shadow: 0 0 14px color-mix(in srgb, var(--swatch), transparent 65%);
}
.swatch.fiber {
height: 2px;
background: repeating-linear-gradient(
90deg,
#f6dba8 0 4px,
transparent 4px 7px
);
}
.index {
position: absolute;
top: 35px;
right: 36px;
color: #779196;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.19em;
text-align: right;
line-height: 1.8;
text-transform: uppercase;
}
.controls {
position: absolute;
right: 30px;
bottom: 28px;
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid var(--line);
border-radius: 999px;
padding: 11px 16px;
background: var(--panel);
color: var(--ink);
font: inherit;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
backdrop-filter: blur(14px);
cursor: pointer;
transition:
border-color 160ms ease,
color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
button:hover {
border-color: rgba(102, 212, 206, 0.75);
color: #baf7f1;
transform: translateY(-1px);
}
button.primary {
border-color: rgba(102, 212, 206, 0.46);
background: rgba(30, 91, 91, 0.62);
}
.hint {
position: absolute;
bottom: 34px;
left: 35px;
color: #678086;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#leaders {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
overflow: visible;
}
#leaders line {
stroke: rgba(146, 218, 213, 0.43);
stroke-width: 1;
stroke-dasharray: 3 4;
}
#leaders circle {
fill: #a7e6df;
stroke: rgba(167, 230, 223, 0.35);
stroke-width: 5;
paint-order: stroke;
}
.callout {
position: absolute;
min-width: 138px;
padding: 9px 11px;
border: 1px solid rgba(146, 218, 213, 0.17);
border-radius: 8px;
background: rgba(7, 18, 27, 0.7);
box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
backdrop-filter: blur(10px);
transform: translate(-50%, -50%);
}
.callout strong {
display: block;
color: #d8e9e8;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.callout small {
display: block;
margin-top: 4px;
color: #789399;
font-size: 8px;
letter-spacing: 0.04em;
}
.callout.air strong {
color: #f3d9a4;
}
.callout.lining strong {
color: #f0a064;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #07111a;
color: var(--teal);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.22em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.intro {
top: 22px;
left: 22px;
}
.intro p,
.legend,
.index {
display: none;
}
h1 {
font-size: 36px;
}
.controls {
right: 16px;
bottom: 18px;
}
.hint {
bottom: 22px;
left: 22px;
max-width: 110px;
line-height: 1.7;
}
.callout,
#leaders {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="hud">
<header class="intro">
<div class="eyebrow">Material study / 03</div>
<h1>Air,<br />not fill.</h1>
<p>
A stylized cutaway of a quilted jacket panel. The open section exposes
hollow insulation cells and suspended fibers instead of solid filler.
</p>
<div class="legend">
<div class="legend-item">
<span class="swatch" style="--swatch:#167f89"></span>
Outer quilted fabric
</div>
<div class="legend-item">
<span class="swatch" style="--swatch:#d46e43"></span>
Inner brushed lining
</div>
<div class="legend-item">
<span class="swatch fiber"></span>
Air gaps and loose fibers
</div>
</div>
</header>
<div class="index">
PUffer construction<br />
Section A–A / 1:1.6
</div>
<svg id="leaders" aria-hidden="true">
<line id="leader-outer"></line>
<circle id="dot-outer" r="2.5"></circle>
<line id="leader-air"></line>
<circle id="dot-air" r="2.5"></circle>
<line id="leader-lining"></line>
<circle id="dot-lining" r="2.5"></circle>
</svg>
<div id="label-outer" class="callout">
<strong>01 / Outer shell</strong>
<small>quilted woven nylon</small>
</div>
<div id="label-air" class="callout air">
<strong>03 / Air + fibers</strong>
<small>hollow thermal volume</small>
</div>
<div id="label-lining" class="callout lining">
<strong>02 / Inner lining</strong>
<small>brushed heat-facing layer</small>
</div>
<div class="hint">Drag to orbit<br />Scroll to zoom</div>
<div class="controls">
<button id="cutaway" class="primary" type="button">Close cutaway</button>
<button id="reset" type="button">Reset view</button>
</div>
</div>
<div id="loading">Initializing materials…</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,
alpha: 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;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111a);
scene.fog = new THREE.FogExp2(0x07111a, 0.034);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0.18, 0.03, -0.08);
const desiredCamera = {
yaw: 0.2,
pitch: 0.08,
radius: 9.25
};
const currentCamera = { ...desiredCamera };
function updateCamera() {
const cp = Math.cos(currentCamera.pitch);
camera.position.set(
cameraTarget.x +
Math.sin(currentCamera.yaw) * cp * currentCamera.radius,
cameraTarget.y +
Math.sin(currentCamera.pitch) * currentCamera.radius,
cameraTarget.z +
Math.cos(currentCamera.yaw) * cp * currentCamera.radius
);
camera.lookAt(cameraTarget);
}
updateCamera();
// ---------------------------------------------------------------------
// Procedural textures
// ---------------------------------------------------------------------
function makeTexture(size, painter) {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = size;
const ctx = canvas.getContext("2d");
painter(ctx, size);
const texture = new THREE.CanvasTexture(canvas);
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const outerMap = makeTexture(512, (ctx, size) => {
ctx.fillStyle = "#147e88";
ctx.fillRect(0, 0, size, size);
// Subtle horizontal quilt shading.
for (let y = 0; y < size; y++) {
const wave = Math.sin((y / size) * Math.PI * 6);
const alpha = 0.018 + Math.max(0, wave) * 0.028;
ctx.fillStyle = `rgba(220,255,250,${alpha})`;
ctx.fillRect(0, y, size, 1);
}
// Fine woven grain.
for (let i = 0; i < 18000; i++) {
const v = Math.random() > 0.5 ? 255 : 0;
ctx.fillStyle = `rgba(${v},${v},${v},0.018)`;
ctx.fillRect(
Math.random() * size,
Math.random() * size,
1 + Math.random() * 2,
1
);
}
for (let x = 0; x < size; x += 4) {
ctx.fillStyle = "rgba(4,48,55,0.045)";
ctx.fillRect(x, 0, 1, size);
}
});
outerMap.colorSpace = THREE.SRGBColorSpace;
outerMap.repeat.set(0.55, 0.55);
const quiltBump = makeTexture(512, (ctx, size) => {
ctx.fillStyle = "#777";
ctx.fillRect(0, 0, size, size);
for (let y = 0; y < size; y++) {
const wave = Math.sin((y / size) * Math.PI * 6);
const shade = Math.round(111 + wave * 34);
ctx.fillStyle = `rgb(${shade},${shade},${shade})`;
ctx.fillRect(0, y, size, 1);
}
for (let x = 0; x < size; x += 5) {
ctx.fillStyle = "rgba(35,35,35,0.25)";
ctx.fillRect(x, 0, 1, size);
}
for (let y = 0; y < size; y += 5) {
ctx.fillStyle = "rgba(255,255,255,0.10)";
ctx.fillRect(0, y, size, 1);
}
});
quiltBump.repeat.set(0.18, 0.18);
const liningMap = makeTexture(512, (ctx, size) => {
ctx.fillStyle = "#cf6841";
ctx.fillRect(0, 0, size, size);
for (let i = 0; i < 15000; i++) {
const warm = Math.random() > 0.5;
ctx.fillStyle = warm
? "rgba(255,210,160,0.028)"
: "rgba(70,24,18,0.026)";
ctx.fillRect(
Math.random() * size,
Math.random() * size,
1 + Math.random() * 2,
1
);
}
ctx.lineWidth = 1;
for (let x = -size; x < size * 2; x += 7) {
ctx.strokeStyle = "rgba(255,210,168,0.08)";
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x - size, size);
ctx.stroke();
}
});
liningMap.colorSpace = THREE.SRGBColorSpace;
liningMap.repeat.set(0.8, 0.8);
// ---------------------------------------------------------------------
// Materials and lighting
// ---------------------------------------------------------------------
const outerMaterial = new THREE.MeshPhysicalMaterial({
color: 0x1a8790,
map: outerMap,
bumpMap: quiltBump,
bumpScale: 0.105,
roughness: 0.83,
metalness: 0,
clearcoat: 0.08,
clearcoatRoughness: 0.9,
sheen: 0.35,
sheenColor: new THREE.Color(0x8edbd5),
side: THREE.DoubleSide
});
const liningMaterial = new THREE.MeshPhysicalMaterial({
color: 0xe17b4d,
map: liningMap,
bumpMap: liningMap,
bumpScale: 0.025,
roughness: 0.76,
metalness: 0,
sheen: 0.5,
sheenColor: new THREE.Color(0xffc29a),
side: THREE.DoubleSide
});
const darkMaterial = new THREE.MeshStandardMaterial({
color: 0x0b3038,
roughness: 0.78,
metalness: 0.08
});
const pipingMaterial = new THREE.MeshStandardMaterial({
color: 0x0e5962,
roughness: 0.7
});
const edgeMaterial = new THREE.MeshStandardMaterial({
color: 0xe8a05e,
roughness: 0.58,
metalness: 0.08
});
const metalMaterial = new THREE.MeshStandardMaterial({
color: 0xb4c8c8,
roughness: 0.32,
metalness: 0.75
});
scene.add(new THREE.HemisphereLight(0x9ad9dd, 0x17202a, 1.4));
const keyLight = new THREE.DirectionalLight(0xfff0d7, 3.1);
keyLight.position.set(4.5, 6.5, 7.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -5;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5de2db, 2.7);
rimLight.position.set(-5, 2.5, -3.5);
scene.add(rimLight);
const warmFill = new THREE.PointLight(0xffa262, 19, 8, 2);
warmFill.position.set(2.6, -1.8, 2.5);
scene.add(warmFill);
// ---------------------------------------------------------------------
// Jacket panel geometry
// ---------------------------------------------------------------------
const CUT_X = 0.92;
const CUT_Y = 0.05;
const CUT_RX = 0.66;
const CUT_RY = 1.3;
function createJacketShape(withHole = false) {
const shape = new THREE.Shape();
shape.moveTo(-1.72, -2.65);
shape.lineTo(1.72, -2.65);
shape.quadraticCurveTo(1.98, -2.58, 1.98, -2.25);
shape.lineTo(1.98, 1.68);
shape.quadraticCurveTo(1.95, 2.02, 1.58, 2.24);
shape.lineTo(0.86, 2.55);
shape.quadraticCurveTo(0.54, 2.7, 0.26, 2.49);
shape.lineTo(0, 2.2);
shape.lineTo(-0.26, 2.49);
shape.quadraticCurveTo(-0.54, 2.7, -0.86, 2.55);
shape.lineTo(-1.58, 2.24);
shape.quadraticCurveTo(-1.95, 2.02, -1.98, 1.68);
shape.lineTo(-1.98, -2.25);
shape.quadraticCurveTo(-1.98, -2.58, -1.72, -2.65);
if (withHole) {
const hole = new THREE.Path();
hole.absellipse(
CUT_X,
CUT_Y,
CUT_RX,
CUT_RY,
0,
Math.PI * 2,
true,
0
);
shape.holes.push(hole);
}
return shape;
}
const model = new THREE.Group();
model.position.set(0.28, 0.02, 0);
scene.add(model);
const outerGeometry = new THREE.ExtrudeGeometry(
createJacketShape(true),
{
depth: 0.22,
bevelEnabled: true,
bevelSegments: 3,
steps: 1,
bevelSize: 0.075,
bevelThickness: 0.055,
curveSegments: 48
}
);
const outerShell = new THREE.Mesh(outerGeometry, outerMaterial);
outerShell.position.z = 0.04;
outerShell.castShadow = true;
outerShell.receiveShadow = true;
model.add(outerShell);
// Separate inner lining, set behind the outer shell to reveal the cavity.
const liningGeometry = new THREE.ExtrudeGeometry(
createJacketShape(false),
{
depth: 0.065,
bevelEnabled: true,
bevelSegments: 2,
steps: 1,
bevelSize: 0.035,
bevelThickness: 0.025,
curveSegments: 48
}
);
const lining = new THREE.Mesh(liningGeometry, liningMaterial);
lining.position.z = -0.64;
lining.scale.set(0.955, 0.97, 1);
lining.castShadow = true;
lining.receiveShadow = true;
model.add(lining);
// ---------------------------------------------------------------------
// Helpers for piping, seams and stitched details
// ---------------------------------------------------------------------
function makeTube(points, radius, material, closed = false) {
const curve = new THREE.CatmullRomCurve3(
points,
closed,
"catmullrom",
0.5
);
const geometry = new THREE.TubeGeometry(
curve,
Math.max(32, points.length * 8),
radius,
7,
closed
);
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
return mesh;
}
function makeStitchLine(points, color = 0x9bcac6, opacity = 0.65) {
const curve = new THREE.CatmullRomCurve3(points, false, "catmullrom");
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(Math.max(40, points.length * 10))
);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.055,
gapSize: 0.045,
transparent: true,
opacity
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
return line;
}
function holeHalfWidth(y) {
const normalized = (y - CUT_Y) / CUT_RY;
return CUT_RX * Math.sqrt(Math.max(0, 1 - normalized * normalized));
}
// Horizontal quilt seams, interrupted by the cutaway.
for (const y of [0.68, -0.68]) {
const half = holeHalfWidth(y);
const segments = [
[-1.83, y, 0.29],
[CUT_X - half - 0.07, y, 0.29]
];
const rightEdge = Math.min(1.84, CUT_X + half + 0.07);
if (rightEdge < 1.84) {
segments.push([rightEdge, y, 0.29], [1.84, y, 0.29]);
}
for (const [x1, yy, z1] of segments) {
const points = [];
for (let i = 0; i <= 12; i++) {
const t = i / 12;
points.push(
new THREE.Vector3(
THREE.MathUtils.lerp(x1, rightEdge > x1 ? rightEdge : x1, t),
yy,
z1
)
);
}
// Ensure the left segment terminates at the cut edge.
if (x1 < CUT_X) {
points[points.length - 1].x = CUT_X - half - 0.07;
}
model.add(makeTube(points, 0.026, pipingMaterial));
model.add(makeStitchLine(points));
}
}
// Elliptical cut edge.
const cutEdgePoints = [];
for (let i = 0; i < 96; i++) {
const a = (i / 96) * Math.PI * 2;
cutEdgePoints.push(
new THREE.Vector3(
CUT_X + Math.cos(a) * CUT_RX,
CUT_Y + Math.sin(a) * CUT_RY,
0.285
)
);
}
model.add(makeTube(cutEdgePoints, 0.024, edgeMaterial, true));
// Neck binding.
const neckPoints = [
new THREE.Vector3(-1.58, 2.24, 0.27),
new THREE.Vector3(-0.86, 2.55, 0.28),
new THREE.Vector3(-0.26, 2.49, 0.29),
new THREE.Vector3(0, 2.2, 0.29),
new THREE.Vector3(0.26, 2.49, 0.29),
new THREE.Vector3(0.86, 2.55, 0.28),
new THREE.Vector3(1.58, 2.24, 0.27)
];
model.add(makeTube(neckPoints, 0.052, darkMaterial));
// Hem binding.
const hemPoints = [];
for (let i = 0; i <= 32; i++) {
const t = i / 32;
hemPoints.push(
new THREE.Vector3(
THREE.MathUtils.lerp(-1.74, 1.74, t),
-2.61 + Math.sin(t * Math.PI) * 0.045,
0.285
)
);
}
model.add(makeTube(hemPoints, 0.047, darkMaterial));
// ---------------------------------------------------------------------
// Peeled-back fabric patch
// ---------------------------------------------------------------------
const patchGroup = new THREE.Group();
patchGroup.position.set(CUT_X + CUT_RX, CUT_Y, 0.055);
model.add(patchGroup);
const patchShape = new THREE.Shape();
patchShape.absellipse(0, 0, CUT_RX, CUT_RY, 0, Math.PI * 2, false, 0);
const patchGeometry = new THREE.ExtrudeGeometry(patchShape, {
depth: 0.18,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.055,
bevelThickness: 0.045,
curveSegments: 64
});
// Shift the patch so its right edge is the hinge.
patchGeometry.translate(-CUT_RX, 0, 0);
const patch = new THREE.Mesh(patchGeometry, [
outerMaterial,
liningMaterial
]);
patch.castShadow = true;
patchGroup.add(patch);
const patchBindingPoints = [];
for (let i = 0; i < 96; i++) {
const a = (i / 96) * Math.PI * 2;
patchBindingPoints.push(
new THREE.Vector3(
Math.cos(a) * CUT_RX - CUT_RX,
Math.sin(a) * CUT_RY,
0.215
)
);
}
patchGroup.add(
makeTube(patchBindingPoints, 0.024, edgeMaterial, true)
);
// ---------------------------------------------------------------------
// Zipper and garment details
// ---------------------------------------------------------------------
const zipperStrip = new THREE.Mesh(
new THREE.BoxGeometry(0.105, 4.25, 0.055),
darkMaterial
);
zipperStrip.position.set(-0.055, -0.34, 0.315);
zipperStrip.castShadow = true;
model.add(zipperStrip);
const toothGeometry = new THREE.BoxGeometry(0.13, 0.022, 0.035);
const teeth = new THREE.InstancedMesh(
toothGeometry,
metalMaterial,
54
);
const dummy = new THREE.Object3D();
for (let i = 0; i < 54; i++) {
const y = -2.43 + (i / 53) * 4.25;
dummy.position.set(
-0.055 + (i % 2 === 0 ? -0.035 : 0.035),
y,
0.355
);
dummy.rotation.set(0, 0, i % 2 === 0 ? 0.06 : -0.06);
dummy.updateMatrix();
teeth.setMatrixAt(i, dummy.matrix);
}
teeth.castShadow = true;
model.add(teeth);
const slider = new THREE.Mesh(
new THREE.BoxGeometry(0.17, 0.27, 0.08),
metalMaterial
);
slider.position.set(-0.055, 0.92, 0.39);
slider.castShadow = true;
model.add(slider);
// Small chest welt.
const pocket = new THREE.Mesh(
new THREE.BoxGeometry(0.67, 0.07, 0.045),
darkMaterial
);
pocket.position.set(-1.18, 0.27, 0.315);
pocket.rotation.z = 0.22;
pocket.castShadow = true;
model.add(pocket);
// Small brand tab.
const label = new THREE.Mesh(
new THREE.BoxGeometry(0.61, 0.17, 0.035),
darkMaterial
);
label.position.set(-1.25, 1.47, 0.315);
label.castShadow = true;
model.add(label);
const labelMark = new THREE.Mesh(
new THREE.BoxGeometry(0.23, 0.025, 0.025),
edgeMaterial
);
labelMark.position.set(-1.3, 1.47, 0.345);
model.add(labelMark);
// ---------------------------------------------------------------------
// Hollow puffed compartments
// These are transparent shells, not opaque filler blocks.
// ---------------------------------------------------------------------
const airMaterial = new THREE.MeshPhysicalMaterial({
color: 0x8ce5dc,
transparent: true,
opacity: 0.045,
roughness: 0.9,
metalness: 0,
transmission: 0,
side: THREE.DoubleSide,
depthWrite: false
});
const airContourMaterial = new THREE.LineBasicMaterial({
color: 0x8bd9d3,
transparent: true,
opacity: 0.1,
depthWrite: false
});
const airSphere = new THREE.SphereGeometry(1, 36, 24);
const rowCenters = [1.35, 0, -1.35];
const columnCenters = [-0.9, 0.9];
for (const rowY of rowCenters) {
for (const columnX of columnCenters) {
const envelope = new THREE.Mesh(airSphere, airMaterial);
envelope.position.set(columnX, rowY, -0.36);
envelope.scale.set(1.62, 0.56, 0.215);
model.add(envelope);
const contourPoints = [];
for (let i = 0; i < 80; i++) {
const a = (i / 80) * Math.PI * 2;
contourPoints.push(
new THREE.Vector3(
columnX + Math.cos(a) * 1.62,
rowY + Math.sin(a) * 0.56,
-0.142
)
);
}
const contour = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(contourPoints),
airContourMaterial
);
model.add(contour);
}
}
// ---------------------------------------------------------------------
// Exposed fibers inside the cutaway
// ---------------------------------------------------------------------
const fiberPositions = [];
const fiberColors = [];
const fiberColorA = new THREE.Color(0xf2d49b);
const fiberColorB = new THREE.Color(0xffefd0);
const fiberColorC = new THREE.Color(0x93d8cf);
for (let i = 0; i < 220; i++) {
const angle = Math.random() * Math.PI * 2;
const radial = Math.sqrt(Math.random());
const centerX = CUT_X + Math.cos(angle) * CUT_RX * 0.77 * radial;
const centerY = CUT_Y + Math.sin(angle) * CUT_RY * 0.79 * radial;
const centerZ = -0.2 - Math.random() * 0.33;
const direction = Math.random() * Math.PI * 2;
const length = 0.08 + Math.random() * 0.27;
const bend = (Math.random() - 0.5) * 0.11;
const perpendicular = direction + Math.PI / 2;
const fiberColor =
i % 9 === 0
? fiberColorC
: i % 2 === 0
? fiberColorA
: fiberColorB;
for (let segment = 0; segment < 5; segment++) {
const t0 = segment / 5 - 0.5;
const t1 = (segment + 1) / 5 - 0.5;
function pointAt(t) {
const curve = Math.sin((t + 0.5) * Math.PI) * bend;
return new THREE.Vector3(
centerX +
Math.cos(direction) * length * t +
Math.cos(perpendicular) * curve,
centerY +
Math.sin(direction) * length * t +
Math.sin(perpendicular) * curve,
centerZ + Math.sin(t * Math.PI * 2 + i) * 0.018
);
}
const p0 = pointAt(t0);
const p1 = pointAt(t1);
fiberPositions.push(
p0.x, p0.y, p0.z,
p1.x, p1.y, p1.z
);
for (let n = 0; n < 2; n++) {
fiberColors.push(
fiberColor.r,
fiberColor.g,
fiberColor.b
);
}
}
}
const fiberGeometry = new THREE.BufferGeometry();
fiberGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(fiberPositions, 3)
);
fiberGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(fiberColors, 3)
);
const fiberMaterial = new THREE.LineBasicMaterial({
vertexColors: true,
transparent: true,
opacity: 0.86,
depthWrite: false
});
const fibers = new THREE.LineSegments(
fiberGeometry,
fiberMaterial
);
model.add(fibers);
// Tiny points suggest loose micro-fibers between larger strands.
const fuzzPositions = [];
for (let i = 0; i < 360; i++) {
const angle = Math.random() * Math.PI * 2;
const radial = Math.sqrt(Math.random());
fuzzPositions.push(
CUT_X + Math.cos(angle) * CUT_RX * 0.82 * radial,
CUT_Y + Math.sin(angle) * CUT_RY * 0.83 * radial,
-0.17 - Math.random() * 0.38
);
}
const fuzzGeometry = new THREE.BufferGeometry();
fuzzGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(fuzzPositions, 3)
);
const fuzzMaterial = new THREE.PointsMaterial({
color: 0xf5dfb1,
size: 0.018,
transparent: true,
opacity: 0.7,
depthWrite: false,
sizeAttenuation: true
});
const fuzz = new THREE.Points(fuzzGeometry, fuzzMaterial);
model.add(fuzz);
// Irregular contours suggest separate pockets of trapped air.
for (let i = 0; i < 9; i++) {
const points = [];
const rx = 0.16 + Math.random() * 0.36;
const ry = 0.2 + Math.random() * 0.62;
const rotation = Math.random() * Math.PI;
const centerX = CUT_X + (Math.random() - 0.5) * 0.55;
const centerY = CUT_Y + (Math.random() - 0.5) * 1.35;
const z = -0.18 - Math.random() * 0.27;
for (let j = 0; j < 80; j++) {
const a = (j / 80) * Math.PI * 2;
const lx = Math.cos(a) * rx;
const ly = Math.sin(a) * ry;
points.push(
new THREE.Vector3(
centerX + lx * Math.cos(rotation) - ly * Math.sin(rotation),
centerY + lx * Math.sin(rotation) + ly * Math.cos(rotation),
z
)
);
}
const contour = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color: 0xb4e7df,
transparent: true,
opacity: 0.065,
depthWrite: false
})
);
model.add(contour);
}
// ---------------------------------------------------------------------
// Stage, halo and atmospheric particles
// ---------------------------------------------------------------------
const halo = new THREE.Mesh(
new THREE.CircleGeometry(3.35, 96),
new THREE.MeshBasicMaterial({
color: 0x1a5660,
transparent: true,
opacity: 0.1,
depthWrite: false
})
);
halo.position.set(0.28, 0.2, -2.7);
halo.scale.y = 1.12;
scene.add(halo);
const floor = new THREE.Mesh(
new THREE.CylinderGeometry(3.45, 3.6, 0.12, 96),
new THREE.MeshStandardMaterial({
color: 0x09151d,
roughness: 0.92,
metalness: 0.05
})
);
floor.position.set(0.2, -3.02, -0.25);
floor.receiveShadow = true;
scene.add(floor);
const floorRing = new THREE.Mesh(
new THREE.TorusGeometry(3.33, 0.012, 8, 160),
new THREE.MeshBasicMaterial({
color: 0x59aaa8,
transparent: true,
opacity: 0.22
})
);
floorRing.rotation.x = Math.PI / 2;
floorRing.position.set(0.2, -2.95, -0.25);
scene.add(floorRing);
const shadowTexture = makeTexture(256, (ctx, size) => {
const gradient = ctx.createRadialGradient(
size / 2,
size / 2,
0,
size / 2,
size / 2,
size / 2
);
gradient.addColorStop(0, "rgba(0,0,0,0.62)");
gradient.addColorStop(0.42, "rgba(0,0,0,0.25)");
gradient.addColorStop(1, "rgba(0,0,0,0)");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, size, size);
});
const shadow = new THREE.Mesh(
new THREE.PlaneGeometry(5.4, 3.2),
new THREE.MeshBasicMaterial({
map: shadowTexture,
transparent: true,
depthWrite: false
})
);
shadow.rotation.x = -Math.PI / 2;
shadow.position.set(0.3, -2.945, -0.05);
scene.add(shadow);
const dustPositions = [];
for (let i = 0; i < 180; i++) {
dustPositions.push(
(Math.random() - 0.5) * 11,
(Math.random() - 0.5) * 8,
-1.5 + Math.random() * 5
);
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xb3e4df,
size: 0.018,
transparent: true,
opacity: 0.28,
depthWrite: false
})
);
scene.add(dust);
// ---------------------------------------------------------------------
// Custom camera controls — no external controls addon
// ---------------------------------------------------------------------
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 dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desiredCamera.yaw -= dx * 0.006;
desiredCamera.pitch = THREE.MathUtils.clamp(
desiredCamera.pitch + dy * 0.005,
-0.68,
0.76
);
});
function endDrag(event) {
dragging = false;
if (
renderer.domElement.hasPointerCapture &&
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();
desiredCamera.radius = THREE.MathUtils.clamp(
desiredCamera.radius * Math.exp(event.deltaY * 0.001),
6.6,
13.5
);
},
{ passive: false }
);
function resetView() {
desiredCamera.yaw = 0.2;
desiredCamera.pitch = 0.08;
desiredCamera.radius = 9.25;
}
document.getElementById("reset").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
// ---------------------------------------------------------------------
// Cutaway interaction
// ---------------------------------------------------------------------
let cutawayOpen = true;
let patchAmount = 1;
const cutawayButton = document.getElementById("cutaway");
cutawayButton.addEventListener("click", () => {
cutawayOpen = !cutawayOpen;
cutawayButton.textContent = cutawayOpen
? "Close cutaway"
: "Open cutaway";
});
// ---------------------------------------------------------------------
// Screen-space annotation labels
// ---------------------------------------------------------------------
const annotationData = [
{
id: "outer",
anchor: new THREE.Vector3(-1.28, 1.62, 0.31),
offset: new THREE.Vector2(-132, -48)
},
{
id: "air",
anchor: new THREE.Vector3(0.94, 0.34, -0.27),
offset: new THREE.Vector2(108, -62)
},
{
id: "lining",
anchor: new THREE.Vector3(0.92, -0.92, -0.58),
offset: new THREE.Vector2(102, 74)
}
];
const projected = new THREE.Vector3();
function updateAnnotations() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const item of annotationData) {
projected.copy(item.anchor);
model.localToWorld(projected);
projected.project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const labelX = THREE.MathUtils.clamp(
x + item.offset.x,
90,
width - 90
);
const labelY = THREE.MathUtils.clamp(
y + item.offset.y,
70,
height - 80
);
const line = document.getElementById(`leader-${item.id}`);
const dot = document.getElementById(`dot-${item.id}`);
const label = document.getElementById(`label-${item.id}`);
line.setAttribute("x1", x);
line.setAttribute("y1", y);
line.setAttribute("x2", labelX);
line.setAttribute("y2", labelY);
dot.setAttribute("cx", x);
dot.setAttribute("cy", y);
label.style.left = `${labelX}px`;
label.style.top = `${labelY}px`;
}
}
// ---------------------------------------------------------------------
// Resize and animation
// ---------------------------------------------------------------------
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() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
currentCamera.yaw = THREE.MathUtils.damp(
currentCamera.yaw,
desiredCamera.yaw,
7,
delta
);
currentCamera.pitch = THREE.MathUtils.damp(
currentCamera.pitch,
desiredCamera.pitch,
7,
delta
);
currentCamera.radius = THREE.MathUtils.damp(
currentCamera.radius,
desiredCamera.radius,
7,
delta
);
updateCamera();
const targetPatchAmount = cutawayOpen ? 1 : 0;
patchAmount = THREE.MathUtils.damp(
patchAmount,
targetPatchAmount,
6,
delta
);
patchGroup.rotation.z = patchAmount * 1.72;
patchGroup.rotation.y = -patchAmount * 0.16;
patchGroup.position.z = 0.055 + patchAmount * 0.09;
fiberMaterial.opacity = 0.24 + patchAmount * 0.62;
fuzzMaterial.opacity = 0.18 + patchAmount * 0.52;
airMaterial.opacity = 0.018 + patchAmount * 0.027;
airContourMaterial.opacity = 0.025 + patchAmount * 0.075;
dust.rotation.y = elapsed * 0.012;
dust.rotation.x = Math.sin(elapsed * 0.09) * 0.025;
model.position.y = 0.02 + Math.sin(elapsed * 0.65) * 0.025;
updateAnnotations();
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```