Prompt specification
Build or customize the Three.js 3D scene "Costume silhouette storytelling workshop" 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: Costume silhouette storytelling workshop
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/costume-silhouette-storytelling-workshop-x0616
Scene Description Prompt:
Please use Three.js from cdnjs for a low-poly scene based on this idea: costume silhouette storytelling workshop. Create a stage display where the same simple character wears several scarf arrangements; show how loop placement and hanging lengths alter silhouette while body geometry remains unchanged. Return one self-contained HTML file.
Working Three.js Starter (costume-silhouette-storytelling-workshop-x0616):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#10191e">
<title>Thread / Form — Costume Silhouette Workshop</title>
<style>
:root {
--ink: #10191e;
--panel: rgba(18, 29, 34, 0.82);
--panel-strong: rgba(20, 32, 37, 0.94);
--line: rgba(235, 225, 204, 0.16);
--text: #f3ead9;
--muted: #a7aaa3;
--cream: #dfcfb4;
--coral: #ff715c;
--gold: #efb94f;
--mint: #57d1b2;
--violet: #a78af2;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--ink);
color: var(--text);
font-family: Arial, Helvetica, sans-serif;
}
body {
user-select: none;
}
canvas {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.ui {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
.topbar {
position: absolute;
top: 24px;
left: 28px;
right: 28px;
height: 44px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: auto;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
letter-spacing: 0.16em;
font-size: 12px;
font-weight: 700;
}
.brand-mark {
position: relative;
width: 31px;
height: 31px;
border: 1px solid rgba(239, 185, 79, 0.75);
transform: rotate(45deg);
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
background: var(--gold);
opacity: 0.75;
}
.brand-mark::before {
width: 1px;
height: 42px;
left: 14px;
top: -6px;
}
.brand-mark::after {
height: 1px;
width: 42px;
left: -6px;
top: 14px;
}
.brand small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 8px;
letter-spacing: 0.24em;
}
.header-actions {
display: flex;
align-items: center;
gap: 12px;
}
.status-pill {
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(13, 22, 27, 0.55);
color: var(--muted);
font-size: 9px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 12px rgba(87, 209, 178, 0.7);
}
.text-button {
appearance: none;
border: 1px solid var(--line);
background: rgba(13, 22, 27, 0.65);
border-radius: 999px;
padding: 9px 13px;
color: var(--cream);
cursor: pointer;
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: border-color 160ms ease, background 160ms ease;
}
.text-button:hover {
border-color: rgba(239, 185, 79, 0.65);
background: rgba(239, 185, 79, 0.08);
}
.intro {
position: absolute;
top: 112px;
left: 30px;
width: 300px;
pointer-events: auto;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 15px;
color: var(--gold);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 1px;
background: var(--gold);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(38px, 4vw, 57px);
line-height: 0.98;
font-weight: 400;
letter-spacing: -0.045em;
}
h1 em {
color: var(--gold);
font-weight: 400;
}
.intro-copy {
max-width: 270px;
margin: 20px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.7;
}
.body-lock {
display: inline-flex;
align-items: center;
gap: 9px;
margin-top: 22px;
padding: 10px 12px;
border-left: 2px solid var(--mint);
background: linear-gradient(90deg, rgba(87, 209, 178, 0.1), transparent);
color: #d9ddd5;
font-size: 9px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.body-lock span {
color: var(--mint);
font-size: 14px;
}
.orbit-hint {
position: absolute;
left: 31px;
bottom: 31px;
display: flex;
align-items: center;
gap: 10px;
color: rgba(243, 234, 217, 0.52);
font-size: 9px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.orbit-icon {
width: 25px;
height: 25px;
border: 1px solid rgba(243, 234, 217, 0.25);
border-radius: 50%;
display: grid;
place-items: center;
font-size: 13px;
}
.library {
position: absolute;
top: 104px;
right: 25px;
width: 276px;
padding: 17px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.panel-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin: 1px 2px 14px;
}
.panel-heading strong {
display: block;
font-size: 10px;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.panel-heading small {
display: block;
margin-top: 5px;
color: var(--muted);
font-size: 9px;
}
.study-count {
color: var(--gold);
font-family: Georgia, serif;
font-size: 20px;
font-style: italic;
}
.arrangements {
display: grid;
gap: 8px;
}
.arrangement {
position: relative;
width: 100%;
display: grid;
grid-template-columns: 30px 1fr 24px;
gap: 11px;
align-items: center;
padding: 11px 10px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 8px;
background: rgba(255, 255, 255, 0.025);
text-align: left;
cursor: pointer;
transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.arrangement:hover {
transform: translateX(-3px);
background: rgba(255, 255, 255, 0.055);
}
.arrangement.active {
border-color: var(--accent);
background: color-mix(in srgb, var(--accent) 11%, transparent);
}
.arrangement.active::before {
content: "";
position: absolute;
left: -1px;
top: 13px;
bottom: 13px;
width: 2px;
border-radius: 3px;
background: var(--accent);
}
.swatch {
width: 28px;
height: 28px;
border-radius: 50%;
background: var(--accent);
box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.08);
}
.arrangement strong {
display: block;
font-size: 11px;
font-weight: 600;
letter-spacing: 0.04em;
}
.arrangement small {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 9px;
line-height: 1.3;
}
.arrangement .number {
color: rgba(243, 234, 217, 0.38);
font-family: Georgia, serif;
font-size: 13px;
font-style: italic;
text-align: right;
}
.arrangement.active .number {
color: var(--accent);
}
.library-note {
display: flex;
align-items: center;
gap: 9px;
margin: 14px 2px 1px;
padding-top: 13px;
border-top: 1px solid var(--line);
color: rgba(243, 234, 217, 0.45);
font-size: 8px;
line-height: 1.5;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.library-note::before {
content: "";
flex: 0 0 auto;
width: 13px;
height: 13px;
border: 1px dashed rgba(239, 185, 79, 0.65);
}
.controls {
position: absolute;
left: 360px;
right: 325px;
bottom: 25px;
min-height: 146px;
display: grid;
grid-template-columns: minmax(230px, 1.15fr) minmax(250px, 1fr);
gap: 24px;
padding: 17px 19px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--panel-strong);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.story-block {
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 0;
}
.micro-label {
color: var(--gold);
font-size: 8px;
font-weight: 700;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.story-block h2 {
margin: 6px 0 5px;
font-family: Georgia, serif;
font-size: 21px;
font-weight: 400;
letter-spacing: -0.02em;
}
.story-block p {
max-width: 420px;
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.control-actions {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 11px;
}
.small-button {
appearance: none;
border: 1px solid var(--line);
border-radius: 999px;
padding: 7px 10px;
background: rgba(255, 255, 255, 0.025);
color: #d9d6cd;
cursor: pointer;
font-size: 8px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.small-button:hover,
.small-button.active {
color: var(--gold);
border-color: rgba(239, 185, 79, 0.55);
background: rgba(239, 185, 79, 0.08);
}
.sliders {
display: flex;
flex-direction: column;
justify-content: center;
gap: 20px;
padding-left: 20px;
border-left: 1px solid var(--line);
}
.slider-row {
display: grid;
grid-template-columns: 94px 1fr 70px;
align-items: center;
gap: 10px;
}
.slider-row label {
color: #d8d5cc;
font-size: 8px;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.slider-row output {
color: var(--gold);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
text-align: right;
text-transform: uppercase;
}
input[type="range"] {
width: 100%;
height: 3px;
margin: 0;
appearance: none;
border-radius: 3px;
background: linear-gradient(90deg, var(--gold), rgba(239, 185, 79, 0.18));
cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
width: 13px;
height: 13px;
appearance: none;
border: 2px solid var(--ink);
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 1px var(--gold);
}
input[type="range"]::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid var(--ink);
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 1px var(--gold);
}
.world-label {
position: absolute;
z-index: 2;
transform: translate(-50%, -50%);
padding: 5px 8px;
border: 1px solid rgba(243, 234, 217, 0.16);
border-radius: 4px;
background: rgba(13, 21, 25, 0.72);
color: rgba(243, 234, 217, 0.62);
font-size: 7px;
font-weight: 700;
letter-spacing: 0.13em;
white-space: nowrap;
pointer-events: auto;
cursor: pointer;
opacity: 0.8;
transition: opacity 160ms ease, border-color 160ms ease, color 160ms ease;
}
.world-label:hover,
.world-label.active {
color: var(--accent);
border-color: var(--accent);
opacity: 1;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: var(--ink);
transition: opacity 500ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
.loader-mark {
width: 38px;
height: 38px;
border: 1px solid rgba(239, 185, 79, 0.25);
border-top-color: var(--gold);
border-radius: 50%;
animation: spin 900ms linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@media (max-width: 1120px) {
.intro {
width: 245px;
}
.intro-copy {
max-width: 225px;
font-size: 12px;
}
.library {
width: 245px;
}
.controls {
left: 295px;
right: 285px;
grid-template-columns: 1fr;
gap: 12px;
}
.sliders {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 10px 0 0;
border-left: 0;
border-top: 1px solid var(--line);
gap: 16px;
}
}
@media (max-width: 760px) {
.topbar {
top: 15px;
left: 15px;
right: 15px;
}
.brand {
font-size: 10px;
}
.brand-mark {
width: 24px;
height: 24px;
}
.status-pill {
display: none;
}
.intro {
top: 78px;
left: 16px;
width: 230px;
}
.eyebrow {
margin-bottom: 10px;
}
h1 {
font-size: 34px;
}
.intro-copy,
.body-lock,
.orbit-hint {
display: none;
}
.library {
top: auto;
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
padding: 10px;
}
.panel-heading,
.library-note {
display: none;
}
.arrangements {
display: flex;
overflow-x: auto;
gap: 7px;
scrollbar-width: none;
}
.arrangements::-webkit-scrollbar {
display: none;
}
.arrangement {
flex: 0 0 172px;
padding: 9px;
}
.controls {
left: 12px;
right: 12px;
bottom: 102px;
padding: 12px;
}
.story-block h2 {
font-size: 17px;
}
.story-block p {
display: none;
}
.sliders {
gap: 10px;
}
.slider-row {
grid-template-columns: 72px 1fr;
}
.slider-row output {
display: none;
}
.world-label {
display: none;
}
}
@media (max-width: 480px) {
.controls {
grid-template-columns: 1fr;
}
.sliders {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="loading" id="loading"><div class="loader-mark"></div></div>
<div class="ui">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>THREAD / FORM<small>Costume silhouette laboratory</small></div>
</div>
<div class="header-actions">
<div class="status-pill"><span class="status-dot"></span>Body geometry locked</div>
<button class="text-button" id="resetView">Reset view</button>
</div>
</header>
<section class="intro">
<div class="eyebrow">Workshop study 01</div>
<h1>The shape<br>of a <em>story.</em></h1>
<p class="intro-copy">
Four scarf stories, one unchanged figure. Move the loop and alter the drop to see how a small costume decision changes the entire silhouette.
</p>
<div class="body-lock"><span>◇</span> Same body · four arrangements</div>
</section>
<aside class="library" aria-label="Scarf arrangement library">
<div class="panel-heading">
<div>
<strong>Arrangement library</strong>
<small>Select a study to edit</small>
</div>
<span class="study-count">04</span>
</div>
<div class="arrangements">
<button class="arrangement active" data-index="0" style="--accent: var(--coral)">
<span class="swatch"></span>
<span><strong>High loop</strong><small>Long vertical tail</small></span>
<span class="number">01</span>
</button>
<button class="arrangement" data-index="1" style="--accent: var(--gold)">
<span class="swatch"></span>
<span><strong>Low loop</strong><small>Short, close drop</small></span>
<span class="number">02</span>
</button>
<button class="arrangement" data-index="2" style="--accent: var(--mint)">
<span class="swatch"></span>
<span><strong>Side loop</strong><small>Asymmetric trail</small></span>
<span class="number">03</span>
</button>
<button class="arrangement" data-index="3" style="--accent: var(--violet)">
<span class="swatch"></span>
<span><strong>Twin loop</strong><small>Balanced double fall</small></span>
<span class="number">04</span>
</button>
</div>
<div class="library-note">Click a figure or card to begin a study</div>
</aside>
<section class="controls" aria-label="Workshop controls">
<div class="story-block">
<div>
<div class="micro-label" id="storyIndex">Study 01 / High loop</div>
<h2 id="storyTitle">The long vertical line</h2>
<p id="storyText">
A high loop exposes the shoulder line. The long tail then pulls the eye downward, giving the figure a quiet, elongated entrance.
</p>
</div>
<div class="control-actions">
<button class="small-button" id="storyButton">▶ Run story</button>
<button class="small-button" id="xrayButton">X-ray body</button>
<button class="small-button" id="turntableButton">Turntable</button>
</div>
</div>
<div class="sliders">
<div class="slider-row">
<label for="loopSlider">Loop placement</label>
<input id="loopSlider" type="range" min="0" max="100" value="82" aria-label="Loop placement">
<output id="loopOutput">High / 82%</output>
</div>
<div class="slider-row">
<label for="dropSlider">Hanging length</label>
<input id="dropSlider" type="range" min="55" max="230" value="178" aria-label="Hanging length">
<output id="dropOutput">178 cm</output>
</div>
</div>
</section>
<div class="orbit-hint"><span class="orbit-icon">↻</span> Drag to orbit · Scroll to zoom · 1–4 to select</div>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const loading = document.querySelector("#loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x10191e);
scene.fog = new THREE.Fog(0x10191e, 12, 29);
const camera = new THREE.PerspectiveCamera(39, innerWidth / innerHeight, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute("aria-label", "Interactive low-poly scarf silhouette workshop");
document.body.prepend(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
const palette = {
cream: 0xdfcfb4,
floor: 0x172329,
wall: 0x142127,
dark: 0x0b1317,
gold: 0xefb94f,
mint: 0x57d1b2,
body: 0xcfae8c
};
const studies = [
{
name: "High loop",
label: "HIGH LOOP",
color: 0xff715c,
css: "#ff715c",
x: -3.18,
loop: 0.82,
drop: 178,
style: "high",
story: "The long vertical line",
text: "A high loop exposes the shoulder line. The long tail then pulls the eye downward, giving the figure a quiet, elongated entrance."
},
{
name: "Low loop",
label: "LOW LOOP",
color: 0xefb94f,
css: "#efb94f",
x: -1.06,
loop: 0.18,
drop: 72,
style: "chest",
story: "The compact interruption",
text: "A low loop gathers the neckline into the torso. The short drop keeps the silhouette contained and lets the body read as the first gesture."
},
{
name: "Side loop",
label: "SIDE LOOP",
color: 0x57d1b2,
css: "#57d1b2",
x: 1.06,
loop: 0.72,
drop: 218,
style: "side",
story: "The unexpected trail",
text: "The offset loop breaks bilateral symmetry. Its trailing end creates movement, suggesting a character arriving late or leaving without a word."
},
{
name: "Twin loop",
label: "TWIN LOOP",
color: 0xa78af2,
css: "#a78af2",
x: 3.18,
loop: 0.48,
drop: 132,
style: "twin",
story: "The balanced chorus",
text: "Two even falls stabilize the shape. The repeated vertical rhythm reads as calm, balance, and a character with two equally weighted choices."
}
];
const ambient = new THREE.HemisphereLight(0xdde7e3, 0x202024, 1.45);
scene.add(ambient);
const key = new THREE.DirectionalLight(0xffe6bc, 4.2);
key.position.set(4.5, 9, 7);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -8;
key.shadow.camera.right = 8;
key.shadow.camera.top = 8;
key.shadow.camera.bottom = -3;
key.shadow.camera.near = 1;
key.shadow.camera.far = 25;
key.shadow.bias = -0.0005;
scene.add(key);
const fill = new THREE.DirectionalLight(0x72b7c8, 1.7);
fill.position.set(-6, 4, 5);
scene.add(fill);
const rim = new THREE.PointLight(0xefb94f, 28, 15, 2);
rim.position.set(0, 6, -3.6);
scene.add(rim);
const floorMaterial = new THREE.MeshStandardMaterial({
color: palette.floor,
roughness: 0.95,
metalness: 0.02,
flatShading: true
});
const floor = new THREE.Mesh(new THREE.PlaneGeometry(36, 24), floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.015;
floor.receiveShadow = true;
scene.add(floor);
const wallMaterial = new THREE.MeshStandardMaterial({
color: palette.wall,
roughness: 0.93,
flatShading: true
});
const wall = new THREE.Mesh(new THREE.BoxGeometry(18, 8, 0.25), wallMaterial);
wall.position.set(0, 3.55, -4.15);
wall.receiveShadow = true;
scene.add(wall);
const stageMaterial = new THREE.MeshStandardMaterial({
color: 0x223138,
roughness: 0.82,
metalness: 0.06,
flatShading: true
});
const stage = new THREE.Mesh(new THREE.CylinderGeometry(5.65, 5.9, 0.12, 48), stageMaterial);
stage.position.y = 0.04;
stage.receiveShadow = true;
scene.add(stage);
const stageEdge = new THREE.Mesh(
new THREE.TorusGeometry(5.67, 0.025, 4, 64),
new THREE.MeshStandardMaterial({ color: 0xb99861, roughness: 0.5, metalness: 0.45 })
);
stageEdge.rotation.x = Math.PI / 2;
stageEdge.position.y = 0.11;
scene.add(stageEdge);
const poolMaterial = new THREE.MeshBasicMaterial({
color: 0xefb94f,
transparent: true,
opacity: 0.025,
depthWrite: false
});
for (let i = 0; i < 3; i++) {
const pool = new THREE.Mesh(new THREE.CircleGeometry(2.4 - i * 0.45, 32), poolMaterial.clone());
pool.material.opacity = 0.035 - i * 0.007;
pool.rotation.x = -Math.PI / 2;
pool.position.set(i * 0.2, 0.108, 0.1);
scene.add(pool);
}
const backdropMaterial = new THREE.MeshStandardMaterial({
color: 0x25363c,
roughness: 0.9,
flatShading: true
});
for (const x of [-5.8, -2.9, 0, 2.9, 5.8]) {
const panel = new THREE.Mesh(new THREE.BoxGeometry(2.55, 5.7, 0.16), backdropMaterial);
panel.position.set(x, 3.2, -3.97);
panel.receiveShadow = true;
scene.add(panel);
}
const beam = new THREE.Mesh(
new THREE.BoxGeometry(12.5, 0.13, 0.18),
new THREE.MeshStandardMaterial({ color: 0x8c744d, roughness: 0.65, metalness: 0.35 })
);
beam.position.set(0, 5.35, -3.72);
scene.add(beam);
const threadMaterial = new THREE.LineBasicMaterial({
color: 0xcfb887,
transparent: true,
opacity: 0.24
});
function addThread(x1, y1, z1, x2, y2, z2) {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x1, y1, z1),
new THREE.Vector3(x2, y2, z2)
]);
const line = new THREE.Line(geometry, threadMaterial);
scene.add(line);
}
for (const x of [-4.5, -2.25, 0, 2.25, 4.5]) {
addThread(x, 5.28, -3.66, x * 0.96, 4.05, -3.66);
}
const wallLoopMaterial = new THREE.MeshStandardMaterial({
color: 0x9b8052,
roughness: 0.78,
metalness: 0.05
});
for (let i = 0; i < 5; i++) {
const loop = new THREE.Mesh(new THREE.TorusGeometry(0.43 + (i % 2) * 0.1, 0.025, 3, 12), wallLoopMaterial);
loop.position.set(-4.4 + i * 2.2, 3.35 + (i % 2) * 0.25, -3.74);
loop.scale.y = 1.5 + (i % 3) * 0.25;
scene.add(loop);
}
function makeSpool(x, z, color) {
const group = new THREE.Group();
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
flatShading: true
});
const core = new THREE.Mesh(new THREE.CylinderGeometry(0.19, 0.19, 0.75, 10), material);
group.add(core);
for (const y of [-0.39, 0.39]) {
const flange = new THREE.Mesh(new THREE.CylinderGeometry(0.39, 0.39, 0.08, 12), material);
flange.position.y = y;
group.add(flange);
}
for (let i = 0; i < 6; i++) {
const winding = new THREE.Mesh(new THREE.TorusGeometry(0.25, 0.045, 4, 12), material);
winding.rotation.x = Math.PI / 2;
winding.position.y = -0.28 + i * 0.11;
group.add(winding);
}
group.position.set(x, 0.5, z);
group.rotation.y = x < 0 ? 0.2 : -0.3;
scene.add(group);
}
makeSpool(-5.15, -1.65, 0xb56c4f);
makeSpool(5.15, -1.55, 0x7f6d96);
const bodyGeometry = {
torso: new THREE.CylinderGeometry(0.48, 0.6, 1.12, 6, 1, false),
pelvis: new THREE.CylinderGeometry(0.47, 0.5, 0.34, 6),
neck: new THREE.CylinderGeometry(0.14, 0.16, 0.24, 8),
head: new THREE.DodecahedronGeometry(0.32, 0),
joint: new THREE.DodecahedronGeometry(0.13, 0),
nose: new THREE.ConeGeometry(0.065, 0.18, 3),
foot: new THREE.BoxGeometry(0.28, 0.16, 0.47),
limb: new THREE.CylinderGeometry(0.095, 0.12, 1, 6)
};
function cylinderBetween(a, b, radius, material, radialSegments = 6) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(radius * 0.88, radius, length, radialSegments);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(new THREE.Vector3(0, 1, 0), direction.normalize());
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function makeCharacter(bodyMaterial) {
const group = new THREE.Group();
const torso = new THREE.Mesh(bodyGeometry.torso, bodyMaterial);
torso.position.y = 2.08;
torso.scale.z = 0.73;
torso.rotation.y = Math.PI / 6;
torso.castShadow = true;
torso.receiveShadow = true;
group.add(torso);
const pelvis = new THREE.Mesh(bodyGeometry.pelvis, bodyMaterial);
pelvis.position.y = 1.43;
pelvis.scale.z = 0.76;
pelvis.rotation.y = Math.PI / 6;
pelvis.castShadow = true;
group.add(pelvis);
const neck = new THREE.Mesh(bodyGeometry.neck, bodyMaterial);
neck.position.y = 2.73;
neck.castShadow = true;
group.add(neck);
const head = new THREE.Mesh(bodyGeometry.head, bodyMaterial);
head.position.set(0, 3.15, 0.015);
head.scale.set(0.94, 1.06, 0.91);
head.rotation.y = Math.PI / 12;
head.castShadow = true;
head.receiveShadow = true;
group.add(head);
const nose = new THREE.Mesh(bodyGeometry.nose, bodyMaterial);
nose.position.set(0, 3.13, 0.31);
nose.rotation.x = Math.PI / 2;
nose.castShadow = true;
group.add(nose);
const armSets = [
[
new THREE.Vector3(-0.43, 2.48, 0),
new THREE.Vector3(-0.66, 1.95, 0.015),
new THREE.Vector3(-0.61, 1.48, 0.06)
],
[
new THREE.Vector3(0.43, 2.48, 0),
new THREE.Vector3(0.65, 1.93, 0.01),
new THREE.Vector3(0.59, 1.43, 0.075)
]
];
for (const points of armSets) {
group.add(cylinderBetween(points[0], points[1], 0.115, bodyMaterial));
group.add(cylinderBetween(points[1], points[2], 0.09, bodyMaterial));
const elbow = new THREE.Mesh(bodyGeometry.joint, bodyMaterial);
elbow.position.copy(points[1]);
elbow.scale.setScalar(0.9);
elbow.castShadow = true;
group.add(elbow);
const hand = new THREE.Mesh(bodyGeometry.joint, bodyMaterial);
hand.position.copy(points[2]);
hand.scale.set(0.8, 1.15, 0.7);
hand.castShadow = true;
group.add(hand);
}
const legSets = [
[new THREE.Vector3(-0.22, 1.4, 0), new THREE.Vector3(-0.28, 0.82, 0.01), new THREE.Vector3(-0.3, 0.31, 0.02)],
[new THREE.Vector3(0.22, 1.4, 0), new THREE.Vector3(0.27, 0.82, -0.01), new THREE.Vector3(0.3, 0.31, 0.02)]
];
for (const points of legSets) {
group.add(cylinderBetween(points[0], points[1], 0.16, bodyMaterial));
group.add(cylinderBetween(points[1], points[2], 0.115, bodyMaterial));
const foot = new THREE.Mesh(bodyGeometry.foot, bodyMaterial);
foot.position.set(points[2].x, 0.19, 0.1);
foot.rotation.y = points[2].x < 0 ? -0.08 : 0.08;
foot.castShadow = true;
group.add(foot);
}
return group;
}
function makeRibbon(points, width, material, taper = true) {
const positions = [];
const indices = [];
const sideAxis = new THREE.Vector3(1, 0, 0);
const fallbackNormal = new THREE.Vector3(0, 0, 1);
for (let i = 0; i < points.length; i++) {
const p = points[i];
const previous = points[Math.max(0, i - 1)];
const next = points[Math.min(points.length - 1, i + 1)];
const tangent = new THREE.Vector3().subVectors(next, previous).normalize();
const side = sideAxis.clone().addScaledVector(tangent, -sideAxis.dot(tangent));
if (side.lengthSq() < 0.0001) side.set(0, 0, 1);
side.normalize();
const normal = new THREE.Vector3().crossVectors(tangent, side).normalize();
if (normal.dot(fallbackNormal) < 0) normal.negate();
const t = i / (points.length - 1);
const localWidth = width * (taper ? 1 - t * 0.16 : 1);
const left = p.clone().addScaledVector(side, -localWidth * 0.5);
const ridge = p.clone().addScaledVector(normal, 0.028 * Math.sin(Math.PI * t));
const right = p.clone().addScaledVector(side, localWidth * 0.5);
positions.push(left.x, left.y, left.z, ridge.x, ridge.y, ridge.z, right.x, right.y, right.z);
}
for (let i = 0; i < points.length - 1; i++) {
const a = i * 3;
const b = a + 1;
const c = a + 2;
const d = a + 3;
const e = a + 4;
const f = a + 5;
indices.push(a, b, d, b, e, d, b, c, e, c, f, e);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function tailPath(startX, startY, endX, endY, z, bend = 0.08) {
const direction = Math.sign(endX - startX) || 1;
const distance = Math.abs(startY - endY);
return [
new THREE.Vector3(startX, startY, z),
new THREE.Vector3(startX + direction * bend, startY - distance * 0.18, z + 0.035),
new THREE.Vector3((startX + endX) * 0.5 + direction * bend * 0.72, startY - distance * 0.58, z + 0.02),
new THREE.Vector3(endX, endY, z)
];
}
function disposeGeometry(group) {
group.traverse(object => {
if (object.geometry) object.geometry.dispose();
});
}
function buildScarf(study) {
if (study.scarfGroup) {
study.root.remove(study.scarfGroup);
disposeGeometry(study.scarfGroup);
}
const group = new THREE.Group();
const loopY = 2.46 + study.loop * 0.42;
const endY = 2.72 - study.drop / 100;
const material = study.scarfMaterial;
const loop = new THREE.Mesh(new THREE.TorusGeometry(0.34, 0.09, 4, 12), material);
loop.rotation.x = Math.PI / 2;
loop.position.set(study.style === "side" ? 0.27 : 0, loopY, study.style === "chest" ? 0.13 : 0.02);
loop.scale.set(1.04, 1, 1.12);
loop.castShadow = true;
group.add(loop);
const knot = new THREE.Mesh(new THREE.DodecahedronGeometry(0.15, 0), material);
knot.scale.set(1.05, 0.8, 0.85);
knot.castShadow = true;
if (study.style === "high") {
knot.position.set(0.12, loopY - 0.06, 0.35);
group.add(knot);
group.add(makeRibbon(
tailPath(-0.13, loopY - 0.02, -0.4, endY, 0.44, 0.12),
0.3,
material
));
group.add(makeRibbon(
tailPath(0.13, loopY - 0.04, 0.3, Math.max(1.35, endY + 0.58), 0.43, 0.08),
0.25,
material
));
}
if (study.style === "chest") {
knot.position.set(0.26, loopY + 0.02, 0.43);
group.add(knot);
const sash = [
new THREE.Vector3(-0.43, 2.56, 0.37),
new THREE.Vector3(-0.18, 2.3, 0.44),
new THREE.Vector3(0.11, 2.04, 0.46),
new THREE.Vector3(0.34, 1.72, 0.46)
];
group.add(makeRibbon(sash, 0.34, material, false));
group.add(makeRibbon(
tailPath(0.28, 1.82, 0.39, endY, 0.46, 0.07),
0.27,
material
));
}
if (study.style === "side") {
knot.position.set(0.31, loopY - 0.04, 0.3);
group.add(knot);
group.add(makeRibbon(
tailPath(0.3, loopY - 0.05, 0.66, endY, 0.28, 0.11),
0.32,
material
));
group.add(makeRibbon(
tailPath(0.12, loopY - 0.02, 0.2, Math.max(1.55, endY + 0.55), 0.42, 0.07),
0.23,
material
));
}
if (study.style === "twin") {
knot.position.set(0, loopY - 0.08, 0.39);
group.add(knot);
group.add(makeRibbon(
tailPath(-0.13, loopY - 0.05, -0.37, endY, 0.43, 0.1),
0.28,
material
));
group.add(makeRibbon(
tailPath(0.13, loopY - 0.05, 0.37, endY, 0.43, 0.1),
0.28,
material
));
}
study.scarfGroup = group;
study.root.add(group);
}
const pickMeshes = [];
const worldLabels = [];
for (let i = 0; i < studies.length; i++) {
const study = studies[i];
const root = new THREE.Group();
root.position.set(study.x, 0.18, 0);
world.add(root);
study.root = root;
const bodyMaterial = new THREE.MeshStandardMaterial({
color: palette.body,
roughness: 0.83,
metalness: 0,
flatShading: true
});
study.bodyMaterial = bodyMaterial;
const character = makeCharacter(bodyMaterial);
root.add(character);
study.character = character;
study.scarfMaterial = new THREE.MeshStandardMaterial({
color: study.color,
emissive: study.color,
emissiveIntensity: 0.025,
roughness: 0.72,
metalness: 0.02,
flatShading: true,
side: THREE.DoubleSide
});
buildScarf(study);
const plinth = new THREE.Mesh(
new THREE.CylinderGeometry(0.7, 0.77, 0.18, 12),
new THREE.MeshStandardMaterial({
color: 0x35434a,
roughness: 0.74,
metalness: 0.1,
flatShading: true
})
);
plinth.position.set(study.x, 0.09, 0);
plinth.castShadow = true;
plinth.receiveShadow = true;
world.add(plinth);
const ringMaterial = new THREE.MeshBasicMaterial({
color: study.color,
transparent: true,
opacity: 0.28,
depthWrite: false
});
const ring = new THREE.Mesh(new THREE.TorusGeometry(0.72, 0.018, 3, 48), ringMaterial);
ring.rotation.x = Math.PI / 2;
ring.position.set(study.x, 0.185, 0);
world.add(ring);
study.ring = ring;
const measureMaterial = new THREE.LineBasicMaterial({
color: 0xe6c98e,
transparent: true,
opacity: 0.27
});
const measureVertices = [];
const mastX = study.x + 0.69;
measureVertices.push(mastX, 0.2, -0.08, mastX, 3.5, -0.08);
for (let y = 0.5; y <= 3.5; y += 0.5) {
measureVertices.push(mastX - 0.055, y, -0.08, mastX + 0.055, y, -0.08);
}
const measureGeometry = new THREE.BufferGeometry();
measureGeometry.setAttribute("position", new THREE.Float32BufferAttribute(measureVertices, 3));
world.add(new THREE.LineSegments(measureGeometry, measureMaterial));
const pickMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
colorWrite: false
});
const pickMesh = new THREE.Mesh(new THREE.CylinderGeometry(0.62, 0.62, 3.7, 8), pickMaterial);
pickMesh.position.set(study.x, 1.9, 0);
pickMesh.userData.studyIndex = i;
world.add(pickMesh);
pickMeshes.push(pickMesh);
const label = document.createElement("button");
label.className = "world-label";
label.style.setProperty("--accent", study.css);
label.textContent = `${String(i + 1).padStart(2, "0")} — ${study.label}`;
label.addEventListener("click", () => selectStudy(i));
document.body.appendChild(label);
worldLabels.push({ element: label, study });
}
const cards = [...document.querySelectorAll(".arrangement")];
const loopSlider = document.querySelector("#loopSlider");
const dropSlider = document.querySelector("#dropSlider");
const loopOutput = document.querySelector("#loopOutput");
const dropOutput = document.querySelector("#dropOutput");
const storyIndex = document.querySelector("#storyIndex");
const storyTitle = document.querySelector("#storyTitle");
const storyText = document.querySelector("#storyText");
const storyButton = document.querySelector("#storyButton");
const xrayButton = document.querySelector("#xrayButton");
const turntableButton = document.querySelector("#turntableButton");
let selectedIndex = 0;
let storyTimer = null;
let xray = false;
let turntable = false;
function updateReadouts() {
const study = studies[selectedIndex];
loopOutput.textContent = `${study.loop < 0.35 ? "Low" : study.loop < 0.66 ? "Mid" : "High"} / ${Math.round(study.loop * 100)}%`;
dropOutput.textContent = `${Math.round(study.drop)} cm`;
}
function selectStudy(index, fromStory = false) {
selectedIndex = index;
const study = studies[index];
cards.forEach((card, cardIndex) => card.classList.toggle("active", cardIndex === index));
worldLabels.forEach(label => label.element.classList.toggle("active", label.study === study));
for (const item of studies) {
const active = item === study;
item.scarfMaterial.emissiveIntensity = active ? 0.16 : 0.025;
item.ring.material.opacity = active ? 0.95 : 0.25;
item.ring.scale.setScalar(active ? 1.035 : 1);
}
loopSlider.value = Math.round(study.loop * 100);
dropSlider.value = Math.round(study.drop);
storyIndex.textContent = `Study ${String(index + 1).padStart(2, "0")} / ${study.name}`;
storyTitle.textContent = study.story;
storyText.textContent = study.text;
updateReadouts();
updateXray();
if (!fromStory && storyTimer) {
clearInterval(storyTimer);
storyTimer = null;
storyButton.textContent = "▶ Run story";
storyButton.classList.remove("active");
}
}
function updateXray() {
const study = studies[selectedIndex];
study.bodyMaterial.transparent = xray;
study.bodyMaterial.opacity = xray ? 0.24 : 1;
study.bodyMaterial.depthWrite = !xray;
study.bodyMaterial.needsUpdate = true;
xrayButton.classList.toggle("active", xray);
xrayButton.textContent = xray ? "Solid body" : "X-ray body";
}
cards.forEach((card, index) => {
card.addEventListener("click", () => selectStudy(index));
});
loopSlider.addEventListener("input", () => {
const study = studies[selectedIndex];
study.loop = Number(loopSlider.value) / 100;
buildScarf(study);
updateReadouts();
});
dropSlider.addEventListener("input", () => {
const study = studies[selectedIndex];
study.drop = Number(dropSlider.value);
buildScarf(study);
updateReadouts();
});
storyButton.addEventListener("click", () => {
if (storyTimer) {
clearInterval(storyTimer);
storyTimer = null;
storyButton.textContent = "▶ Run story";
storyButton.classList.remove("active");
} else {
selectStudy((selectedIndex + 1) % studies.length, true);
storyTimer = setInterval(() => {
selectStudy((selectedIndex + 1) % studies.length, true);
}, 2800);
storyButton.textContent = "Ⅱ Pause story";
storyButton.classList.add("active");
}
});
xrayButton.addEventListener("click", () => {
xray = !xray;
updateXray();
});
turntableButton.addEventListener("click", () => {
turntable = !turntable;
turntableButton.classList.toggle("active", turntable);
});
const cameraTarget = new THREE.Vector3(0, 1.55, 0);
let theta = 0.13;
let targetTheta = 0.13;
let phi = 1.16;
let targetPhi = 1.16;
let radius = 12.6;
let targetRadius = 12.6;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
let pointerDistance = 0;
function responsiveRadius() {
const aspect = innerWidth / innerHeight;
if (aspect < 0.85) return 20.5;
if (aspect < 1.25) return 16.8;
return 12.6;
}
function resetCamera() {
targetTheta = 0.13;
targetPhi = 1.16;
targetRadius = responsiveRadius();
cameraTarget.set(0, 1.55, 0);
}
document.querySelector("#resetView").addEventListener("click", resetCamera);
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
pointerDistance = 0;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerDistance += Math.abs(dx) + Math.abs(dy);
pointerX = event.clientX;
pointerY = event.clientY;
targetTheta -= dx * 0.006;
targetPhi = THREE.MathUtils.clamp(targetPhi - dy * 0.005, 0.62, 1.42);
});
renderer.domElement.addEventListener("pointerup", event => {
dragging = false;
if (pointerDistance < 7) {
const pointer = new THREE.Vector2(
(event.clientX / innerWidth) * 2 - 1,
-(event.clientY / innerHeight) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickMeshes, false);
if (hits.length) selectStudy(hits[0].object.userData.studyIndex);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
targetRadius = THREE.MathUtils.clamp(targetRadius + event.deltaY * 0.008, 8.5, 23);
}, { passive: false });
addEventListener("keydown", event => {
if (event.target instanceof HTMLInputElement) return;
if (["1", "2", "3", "4"].includes(event.key)) {
selectStudy(Number(event.key) - 1);
}
if (event.key.toLowerCase() === "x") {
xray = !xray;
updateXray();
}
if (event.code === "Space") {
event.preventDefault();
storyButton.click();
}
});
addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
if (!dragging) targetRadius = responsiveRadius();
});
const clock = new THREE.Clock();
const projected = new THREE.Vector3();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (turntable && !dragging) targetTheta += dt * 0.08;
theta += (targetTheta - theta) * 0.075;
phi += (targetPhi - phi) * 0.075;
radius += (targetRadius - radius) * 0.075;
camera.position.set(
cameraTarget.x + radius * Math.sin(phi) * Math.sin(theta),
cameraTarget.y + radius * Math.cos(phi),
cameraTarget.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(cameraTarget);
for (const label of worldLabels) {
projected.set(label.study.x, 0.26, 1.03).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "block" : "none";
label.element.style.left = `${(projected.x * 0.5 + 0.5) * innerWidth}px`;
label.element.style.top = `${(-projected.y * 0.5 + 0.5) * innerHeight}px`;
}
renderer.render(scene, camera);
}
selectStudy(0);
resetCamera();
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```