Prompt specification
Build or customize the Three.js 3D scene "Shared makerspace workstation setup" 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: Shared makerspace workstation setup
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/shared-makerspace-workstation-setup-x0188
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows desk ergonomics. Build three adjustable stations for differently sized stylized visitors; link height and storage controls to visible reach diagrams while keeping shared access routes open. Low-poly.
Working Three.js Starter (shared-makerspace-workstation-setup-x0188):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Common Ground — Desk Ergonomics</title>
<style>
:root {
--ink: #172c35;
--muted: #66777d;
--paper: rgba(255, 255, 255, 0.92);
--line: rgba(23, 44, 53, 0.12);
--teal: #168a88;
--green: #248b65;
--amber: #d58b22;
--red: #cf514b;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background: #dfe9e6;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
header {
position: fixed;
z-index: 10;
top: 22px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 16px;
background: rgba(255,255,255,.82);
box-shadow: 0 10px 35px rgba(36, 61, 67, .10);
backdrop-filter: blur(14px);
}
.brand-mark {
width: 38px;
height: 38px;
border-radius: 12px;
display: grid;
place-items: center;
color: white;
font-weight: 900;
font-size: 18px;
background:
linear-gradient(135deg, rgba(255,255,255,.22), transparent),
var(--teal);
}
.brand h1 {
margin: 0;
font-size: 15px;
line-height: 1.15;
letter-spacing: -.02em;
}
.brand p {
margin: 4px 0 0;
color: var(--muted);
font-size: 11px;
letter-spacing: .05em;
text-transform: uppercase;
}
.toolbar {
display: flex;
gap: 8px;
pointer-events: auto;
}
button {
border: 1px solid var(--line);
border-radius: 12px;
padding: 11px 14px;
color: var(--ink);
background: rgba(255,255,255,.9);
box-shadow: 0 8px 24px rgba(36,61,67,.08);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
button:hover { background: white; transform: translateY(-1px); }
aside {
position: fixed;
z-index: 12;
top: 92px;
right: 24px;
width: 318px;
max-height: calc(100vh - 116px);
overflow: auto;
padding: 16px;
border: 1px solid rgba(255,255,255,.82);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(36,61,67,.14);
backdrop-filter: blur(18px);
scrollbar-width: thin;
}
.panel-heading {
margin-bottom: 12px;
}
.panel-heading h2 {
margin: 0 0 5px;
font-size: 18px;
letter-spacing: -.035em;
}
.panel-heading p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.station-card {
--accent: var(--teal);
margin-top: 10px;
padding: 13px;
border: 1px solid var(--line);
border-radius: 15px;
background: rgba(255,255,255,.68);
transition: border-color .2s, box-shadow .2s, background .2s;
cursor: pointer;
}
.station-card.active {
border-color: color-mix(in srgb, var(--accent) 60%, white);
background: white;
box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 13%, transparent);
}
.station-head {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
}
.station-dot {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
}
.station-head strong {
font-size: 13px;
}
.station-head span {
margin-left: auto;
color: var(--muted);
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .055em;
}
.control {
margin-top: 11px;
}
.control-label {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 7px;
font-size: 11px;
font-weight: 700;
}
.control-label output {
color: var(--accent);
font-variant-numeric: tabular-nums;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 0;
border-radius: 4px;
appearance: none;
background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 18%, white));
outline: none;
}
input[type="range"]::-webkit-slider-thumb {
width: 16px;
height: 16px;
appearance: none;
border: 3px solid white;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 2px 8px rgba(23,44,53,.25);
cursor: ew-resize;
}
input[type="range"]::-moz-range-thumb {
width: 12px;
height: 12px;
border: 3px solid white;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 2px 8px rgba(23,44,53,.25);
cursor: ew-resize;
}
.status-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
margin-top: 11px;
}
.status {
min-width: 0;
padding: 6px 7px;
border-radius: 8px;
background: #edf2f1;
color: var(--muted);
font-size: 9px;
font-weight: 800;
line-height: 1.2;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.status::before {
content: "";
display: inline-block;
width: 6px;
height: 6px;
margin-right: 5px;
border-radius: 50%;
background: currentColor;
vertical-align: 1px;
}
.status[data-state="comfortable"] {
color: var(--green);
background: #e6f3ed;
}
.status[data-state="stretch"] {
color: #aa6910;
background: #fff2d9;
}
.status[data-state="out"] {
color: var(--red);
background: #fbe7e5;
}
.panel-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 13px;
padding-top: 13px;
border-top: 1px solid var(--line);
font-size: 11px;
font-weight: 700;
}
.toggle {
display: flex;
align-items: center;
gap: 7px;
cursor: pointer;
}
.toggle input {
width: 16px;
height: 16px;
accent-color: var(--teal);
}
.legend {
position: fixed;
z-index: 10;
left: 24px;
bottom: 22px;
display: flex;
gap: 13px;
align-items: center;
padding: 10px 13px;
border: 1px solid rgba(255,255,255,.8);
border-radius: 13px;
background: rgba(255,255,255,.83);
box-shadow: 0 8px 30px rgba(36,61,67,.10);
backdrop-filter: blur(12px);
font-size: 10px;
font-weight: 700;
color: var(--muted);
pointer-events: none;
}
.legend span {
display: flex;
align-items: center;
gap: 5px;
white-space: nowrap;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--green);
}
.legend .amber { background: var(--amber); }
.legend .red { background: var(--red); }
.hint {
position: fixed;
z-index: 8;
left: 24px;
bottom: 77px;
padding: 7px 10px;
border-radius: 8px;
color: rgba(23,44,53,.65);
background: rgba(255,255,255,.62);
font-size: 10px;
pointer-events: none;
}
#labels {
position: fixed;
inset: 0;
z-index: 7;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
transform: translate(-50%, -100%);
padding: 5px 8px;
border: 1px solid rgba(255,255,255,.85);
border-radius: 8px;
color: var(--ink);
background: rgba(255,255,255,.88);
box-shadow: 0 5px 16px rgba(36,61,67,.12);
font-size: 10px;
font-weight: 800;
line-height: 1.1;
white-space: nowrap;
backdrop-filter: blur(8px);
}
.station-label {
padding: 7px 10px;
font-size: 11px;
}
.station-label small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .06em;
}
.target-label[data-state="comfortable"] { border-left: 3px solid var(--green); }
.target-label[data-state="stretch"] { border-left: 3px solid var(--amber); }
.target-label[data-state="out"] { border-left: 3px solid var(--red); }
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
color: var(--teal);
background: #e4ece9;
font-size: 13px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
@media (max-width: 760px) {
header { top: 12px; left: 12px; right: 12px; }
.brand { padding: 9px 11px; }
.brand p { display: none; }
.brand-mark { width: 32px; height: 32px; }
aside {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 43vh;
border-radius: 16px;
}
.legend, .hint { display: none; }
.toolbar button { padding: 10px; }
}
</style>
</head>
<body>
<canvas id="scene" tabindex="0" aria-label="Interactive three-dimensional desk ergonomics scene"></canvas>
<div id="labels"></div>
<header>
<div class="brand">
<div class="brand-mark">CG</div>
<div>
<h1>Common Ground</h1>
<p>Ergonomics for every body</p>
</div>
</div>
<div class="toolbar">
<button id="resetCamera" type="button">Reset view</button>
</div>
</header>
<aside>
<div class="panel-heading">
<h2>Tune each workstation</h2>
<p>Raise the work surface or lift its storage. Reach guides and status markers update instantly.</p>
</div>
<div id="stationControls"></div>
<div class="panel-footer">
<label class="toggle">
<input id="reachToggle" type="checkbox" checked>
Show reach guides
</label>
<span style="color:var(--muted);font-size:10px">Storage stays inside each desk bay</span>
</div>
</aside>
<div class="hint">Drag to orbit · Scroll to zoom · Arrow keys to rotate</div>
<div class="legend">
<span><i></i>Comfortable</span>
<span><i class="amber"></i>Stretch</span>
<span><i class="red"></i>Out of reach</span>
</div>
<div id="loading">Building the shared workspace…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
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.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdfe9e6);
scene.fog = new THREE.Fog(0xdfe9e6, 25, 48);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraState = {
target: new THREE.Vector3(0, 0.95, 0.45),
radius: 19.5,
theta: 0.12,
phi: 0.97
};
function updateCamera() {
const { target, radius, theta, phi } = cameraState;
camera.position.set(
target.x + radius * Math.sin(phi) * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * Math.sin(phi) * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
scene.add(new THREE.HemisphereLight(0xf6fbfa, 0x8aa39d, 2.15));
const keyLight = new THREE.DirectionalLight(0xfff4df, 3.4);
keyLight.position.set(-7, 14, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xbde7e4, 1.3);
rimLight.position.set(10, 8, -8);
scene.add(rimLight);
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0xd7e1dc, roughness: 0.94, metalness: 0
}),
wall: new THREE.MeshStandardMaterial({
color: 0xeef1e9, roughness: 1
}),
dark: new THREE.MeshStandardMaterial({
color: 0x24424a, roughness: 0.72, flatShading: true
}),
metal: new THREE.MeshStandardMaterial({
color: 0x91a5a7, roughness: 0.43, metalness: 0.58, flatShading: true
}),
white: new THREE.MeshStandardMaterial({
color: 0xf4f4ed, roughness: 0.78, flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x168a88, roughness: 0.65, flatShading: true
}),
screen: new THREE.MeshStandardMaterial({
color: 0x163f48, roughness: 0.35, metalness: 0.15, flatShading: true
})
};
function makeBox(w, h, d, material, parent, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeCylinder(radius, material, parent, radialSegments = 7) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, 1, radialSegments),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
const up = new THREE.Vector3(0, 1, 0);
const tempA = new THREE.Vector3();
const tempB = new THREE.Vector3();
const tempDir = new THREE.Vector3();
function setBetween(mesh, a, b) {
tempA.fromArray(a);
tempB.fromArray(b);
tempDir.subVectors(tempB, tempA);
const length = tempDir.length();
mesh.position.copy(tempA).add(tempB).multiplyScalar(0.5);
mesh.scale.set(1, length, 1);
mesh.quaternion.setFromUnitVectors(up, tempDir.normalize());
}
function makeLimb(parent, radius, material) {
return makeCylinder(radius, material, parent, 6);
}
// Room
const floor = new THREE.Mesh(new THREE.PlaneGeometry(19, 13), materials.floor);
floor.rotation.x = -Math.PI / 2;
floor.position.set(0, -0.025, 0.9);
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(18, 18, 0x9db5af, 0xb4c4bf);
grid.position.set(0, 0.002, 0.9);
grid.material.transparent = true;
grid.material.opacity = 0.18;
scene.add(grid);
const backWall = makeBox(19, 5.4, 0.16, materials.wall, scene, 0, 2.68, -5.15);
backWall.castShadow = false;
const baseboard = makeBox(19, 0.16, 0.22, materials.teal, scene, 0, 0.08, -5.02);
baseboard.castShadow = false;
// Wall graphic, generated locally with Canvas.
function createWallPoster() {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 512;
const ctx = c.getContext("2d");
ctx.fillStyle = "#173b43";
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = "#4fb2aa";
ctx.fillRect(70, 78, 16, 350);
ctx.fillStyle = "#f4f1e6";
ctx.font = "800 67px Arial";
ctx.fillText("WORK BETTER", 130, 178);
ctx.fillStyle = "#8ed3cb";
ctx.font = "700 31px Arial";
ctx.fillText("ONE SPACE · MANY BODIES", 134, 235);
ctx.fillStyle = "#dce9e5";
ctx.font = "400 25px Arial";
ctx.fillText("Tune the surface. Lift the storage.", 134, 305);
ctx.fillText("Keep the shared route clear.", 134, 347);
ctx.strokeStyle = "#f3b75b";
ctx.lineWidth = 10;
ctx.beginPath();
ctx.arc(815, 247, 116, -1.1, 1.1);
ctx.stroke();
ctx.fillStyle = "#f3b75b";
ctx.beginPath();
ctx.arc(815, 247, 13, 0, Math.PI * 2);
ctx.fill();
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(7.2, 3.6),
new THREE.MeshBasicMaterial({ map: texture })
);
mesh.position.set(0, 2.75, -5.045);
scene.add(mesh);
}
createWallPoster();
// Shared, unobstructed access route.
const route = new THREE.Group();
scene.add(route);
const routeMaterial = new THREE.MeshBasicMaterial({
color: 0x35aaa3,
transparent: true,
opacity: 0.12,
depthWrite: false
});
const routeMesh = new THREE.Mesh(new THREE.PlaneGeometry(17.6, 2.35), routeMaterial);
routeMesh.rotation.x = -Math.PI / 2;
routeMesh.position.set(0, 0.012, 4.05);
route.add(routeMesh);
const routeBorder = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-8.8, 0.025, 2.88),
new THREE.Vector3(8.8, 0.025, 2.88),
new THREE.Vector3(8.8, 0.025, 5.22),
new THREE.Vector3(-8.8, 0.025, 5.22),
new THREE.Vector3(-8.8, 0.025, 2.88)
]),
new THREE.LineDashedMaterial({
color: 0x168a88,
dashSize: 0.28,
gapSize: 0.18,
transparent: true,
opacity: 0.7
})
);
routeBorder.computeLineDistances();
route.add(routeBorder);
function addFloorArrow(x, z) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute([
x + 0.24, 0.03, z,
x - 0.18, 0.03, z - 0.17,
x - 0.18, 0.03, z + 0.17
], 3));
geometry.computeVertexNormals();
const arrow = new THREE.Mesh(
geometry,
new THREE.MeshBasicMaterial({ color: 0x168a88, side: THREE.DoubleSide })
);
route.add(arrow);
}
[-6.4, 0, 6.4].forEach(x => addFloorArrow(x, 4.04));
function createRouteLabel() {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 128;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
ctx.fillStyle = "#277f7c";
ctx.font = "800 48px Arial";
ctx.textAlign = "center";
ctx.fillText("SHARED ACCESS · KEEP CLEAR", 512, 78);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(5.6, 0.7),
new THREE.MeshBasicMaterial({ map: texture, transparent: true, depthWrite: false })
);
mesh.rotation.x = -Math.PI / 2;
mesh.position.set(0, 0.035, 4.06);
route.add(mesh);
}
createRouteLabel();
const stationConfigs = [
{
name: "Mira",
group: "Child · 122 cm",
x: -5.7,
accent: 0xf08b6c,
desk: 0.68,
storage: 0.38,
deskMin: 0.55,
deskMax: 0.82,
storageMin: 0.22,
storageMax: 0.80,
shoulder: 0.93,
reach: 1.06,
width: 2.30,
skin: 0xc98c66,
shirt: 0xe7785f,
hair: 0x3b2d2a
},
{
name: "Ari",
group: "Adult · 168 cm",
x: 0,
accent: 0x2a9d91,
desk: 0.75,
storage: 0.56,
deskMin: 0.64,
deskMax: 0.98,
storageMin: 0.28,
storageMax: 1.05,
shoulder: 1.20,
reach: 1.27,
width: 2.55,
skin: 0x8f5e45,
shirt: 0x258f87,
hair: 0x20292b
},
{
name: "Leo",
group: "Tall adult · 191 cm",
x: 5.7,
accent: 0x5d78bd,
desk: 0.86,
storage: 0.72,
deskMin: 0.72,
deskMax: 1.12,
storageMin: 0.32,
storageMax: 1.20,
shoulder: 1.38,
reach: 1.48,
width: 2.78,
skin: 0xe0ad82,
shirt: 0x6178ba,
hair: 0x8b5d39
}
];
const labelRoot = document.getElementById("labels");
function createWorldLabel(className = "") {
const el = document.createElement("div");
el.className = `world-label ${className}`;
labelRoot.appendChild(el);
return el;
}
function createPerson(config) {
const group = new THREE.Group();
const skin = new THREE.MeshStandardMaterial({
color: config.skin, roughness: 0.88, flatShading: true
});
const shirt = new THREE.MeshStandardMaterial({
color: config.shirt, roughness: 0.82, flatShading: true
});
const hair = new THREE.MeshStandardMaterial({
color: config.hair, roughness: 0.95, flatShading: true
});
const trousers = new THREE.MeshStandardMaterial({
color: 0x344b56, roughness: 0.9, flatShading: true
});
const torsoHeight = config.shoulder - 0.52;
const torso = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.23, 1, 5),
shirt
);
torso.position.set(0, 0.54 + torsoHeight / 2, 1.12);
torso.scale.y = torsoHeight;
torso.castShadow = true;
group.add(torso);
const neck = makeCylinder(0.065, skin, group, 6);
setBetween(neck, [0, config.shoulder - 0.03, 1.10], [0, config.shoulder + 0.10, 1.08]);
const head = new THREE.Mesh(new THREE.IcosahedronGeometry(0.155, 0), skin);
head.position.set(0, config.shoulder + 0.27, 1.05);
head.scale.set(0.92, 1.08, 0.92);
head.castShadow = true;
group.add(head);
const hairCap = new THREE.Mesh(new THREE.IcosahedronGeometry(0.16, 0), hair);
hairCap.position.set(0, config.shoulder + 0.34, 1.065);
hairCap.scale.set(0.96, 0.55, 0.96);
hairCap.castShadow = true;
group.add(hairCap);
const eyeMaterial = new THREE.MeshBasicMaterial({ color: 0x243038 });
[-0.055, 0.055].forEach(x => {
const eye = new THREE.Mesh(new THREE.BoxGeometry(0.018, 0.018, 0.012), eyeMaterial);
eye.position.set(x, config.shoulder + 0.285, 0.913);
group.add(eye);
});
const upperArms = [];
const foreArms = [];
[-1, 1].forEach(side => {
const upper = makeLimb(group, 0.067, shirt);
const fore = makeLimb(group, 0.057, skin);
upperArms.push({ mesh: upper, side });
foreArms.push({ mesh: fore, side });
});
const thighs = [];
const shins = [];
[-1, 1].forEach(side => {
const thigh = makeLimb(group, 0.085, trousers);
const shin = makeLimb(group, 0.068, trousers);
thighs.push({ mesh: thigh, side });
shins.push({ mesh: shin, side });
});
const shoeMaterial = new THREE.MeshStandardMaterial({
color: 0x1f333c, roughness: 0.9, flatShading: true
});
[-1, 1].forEach(side => {
const shoe = makeBox(0.15, 0.09, 0.27, shoeMaterial, group, side * 0.14, 0.07, 0.52);
shoe.castShadow = true;
});
function updateArms(deskHeight) {
[-1, 1].forEach((side, i) => {
const shoulder = [side * 0.21, config.shoulder - 0.07, 1.07];
const elbow = [side * 0.31, config.shoulder - 0.24, 0.69];
const hand = [side * 0.25, deskHeight + 0.075, 0.39];
setBetween(upperArms[i].mesh, shoulder, elbow);
setBetween(foreArms[i].mesh, elbow, hand);
});
}
function updateLegs() {
[-1, 1].forEach((side, i) => {
const hip = [side * 0.12, 0.55, 1.25];
const knee = [side * 0.14, 0.48, 0.72];
const ankle = [side * 0.14, 0.12, 0.59];
setBetween(thighs[i].mesh, hip, knee);
setBetween(shins[i].mesh, knee, ankle);
});
}
updateLegs();
return { group, updateArms };
}
function createChair(config, parent) {
const chair = new THREE.Group();
const chairMaterial = new THREE.MeshStandardMaterial({
color: 0x48636a, roughness: 0.75, flatShading: true
});
makeBox(0.72, 0.11, 0.66, chairMaterial, chair, 0, 0.45, 1.29);
const back = makeBox(0.70, 0.62, 0.10, chairMaterial, chair, 0, 0.78, 1.59);
back.rotation.x = -0.08;
const post = makeCylinder(0.055, materials.metal, chair, 6);
setBetween(post, [0, 0.07, 1.29], [0, 0.43, 1.29]);
const base = makeCylinder(0.045, materials.metal, chair, 6);
setBetween(base, [-0.28, 0.08, 1.29], [0.28, 0.08, 1.29]);
parent.add(chair);
}
function createReachDiagram(config) {
const group = new THREE.Group();
group.position.set(config.x, config.shoulder, 1.02);
scene.add(group);
const R = config.reach;
const angles = [];
const segments = 34;
for (let i = 0; i <= segments; i++) {
angles.push(THREE.MathUtils.degToRad(-42 + i / segments * 112));
}
const vertices = [];
for (let i = 0; i < segments; i++) {
const a1 = angles[i];
const a2 = angles[i + 1];
vertices.push(
0, 0, 0,
0, Math.sin(a1) * R, -Math.cos(a1) * R,
0, Math.sin(a2) * R, -Math.cos(a2) * R
);
}
const fanGeometry = new THREE.BufferGeometry();
fanGeometry.setAttribute("position", new THREE.Float32BufferAttribute(vertices, 3));
const fan = new THREE.Mesh(
fanGeometry,
new THREE.MeshBasicMaterial({
color: 0xe7a23b,
transparent: true,
opacity: 0.075,
depthWrite: false,
depthTest: false,
side: THREE.DoubleSide
})
);
fan.renderOrder = 10;
group.add(fan);
function arcPoints(radius) {
return angles.map(a => new THREE.Vector3(
0,
Math.sin(a) * radius,
-Math.cos(a) * radius
));
}
const maxArc = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(arcPoints(R)),
new THREE.LineBasicMaterial({
color: 0xd79531,
transparent: true,
opacity: 0.72,
depthTest: false,
depthWrite: false
})
);
maxArc.renderOrder = 11;
group.add(maxArc);
const comfortArc = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(arcPoints(R * 0.72)),
new THREE.LineBasicMaterial({
color: 0x248b65,
transparent: true,
opacity: 0.9,
depthTest: false,
depthWrite: false
})
);
comfortArc.renderOrder = 12;
group.add(comfortArc);
const radial = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(),
arcPoints(R)[0]
]),
new THREE.LineBasicMaterial({
color: 0xd79531,
transparent: true,
opacity: 0.42,
depthTest: false,
depthWrite: false
})
);
radial.renderOrder = 11;
group.add(radial);
const shoulder = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.045, 0),
new THREE.MeshBasicMaterial({ color: 0x273f47, depthTest: false })
);
shoulder.renderOrder = 14;
group.add(shoulder);
function makeTarget() {
const line = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]),
new THREE.LineDashedMaterial({
color: 0x248b65,
dashSize: 0.08,
gapSize: 0.045,
transparent: true,
opacity: 0.95,
depthTest: false,
depthWrite: false
})
);
line.renderOrder = 13;
const marker = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.055, 1),
new THREE.MeshBasicMaterial({ color: 0x248b65, depthTest: false })
);
marker.renderOrder = 14;
scene.add(line, marker);
return { line, marker };
}
return {
group,
desk: makeTarget(),
storage: makeTarget(),
shoulderWorld: new THREE.Vector3(config.x, config.shoulder, 1.02)
};
}
function createStation(config, index) {
const root = new THREE.Group();
root.position.x = config.x;
scene.add(root);
const accentMaterial = new THREE.MeshStandardMaterial({
color: config.accent, roughness: 0.7, flatShading: true
});
const deskGroup = new THREE.Group();
root.add(deskGroup);
const desktop = makeBox(
config.width, 0.105, 1.12, materials.white, deskGroup, 0, config.desk, -0.18
);
const frontStrip = makeBox(
config.width, 0.07, 0.035, accentMaterial, deskGroup, 0, config.desk - 0.015, 0.397
);
const mat = makeBox(
config.width - 0.26, 0.012, 0.58,
new THREE.MeshStandardMaterial({ color: 0xb9cbc4, roughness: 0.95 }),
deskGroup, 0, config.desk + 0.06, -0.12
);
const legs = [];
const legXs = [-config.width / 2 + 0.17, config.width / 2 - 0.17];
legXs.forEach(x => {
[-0.59, 0.27].forEach(z => {
const lower = makeCylinder(0.052, materials.metal, deskGroup, 7);
const upper = makeCylinder(0.041, accentMaterial, deskGroup, 7);
legs.push({ x, z, lower, upper });
});
});
const crossbar = makeBox(
config.width - 0.34, 0.065, 0.065, materials.metal, deskGroup,
0, config.desk - 0.15, -0.55
);
// Monitor and desk objects move with the work surface.
const monitorGroup = new THREE.Group();
monitorGroup.position.set(-0.12, config.desk + 0.07, -0.38);
deskGroup.add(monitorGroup);
const stand = makeBox(0.07, 0.25, 0.06, materials.metal, monitorGroup, 0, 0.12, 0);
const screen = makeBox(0.67, 0.42, 0.055, materials.screen, monitorGroup, 0, 0.40, 0);
screen.rotation.x = -0.06;
const screenGlow = makeBox(
0.59, 0.32, 0.012,
new THREE.MeshBasicMaterial({ color: 0x76b9b3 }),
monitorGroup, 0, 0.405, 0.032
);
screenGlow.rotation.x = -0.06;
const keyboard = makeBox(
0.64, 0.025, 0.22,
new THREE.MeshStandardMaterial({ color: 0x60767b, roughness: 0.75 }),
deskGroup, -0.10, config.desk + 0.076, 0.08
);
// Telescoping storage module remains within the desk bay.
const storageRail = makeCylinder(
0.025, materials.metal, root, 6
);
setBetween(storageRail, [0.63, 0.10, 0.22], [0.63, 1.29, 0.22]);
const storageGroup = new THREE.Group();
storageGroup.position.set(0.63, config.storage, 0.22);
root.add(storageGroup);
makeBox(0.38, 0.18, 0.42, accentMaterial, storageGroup);
makeBox(0.15, 0.025, 0.035, materials.white, storageGroup, 0, 0.015, 0.225);
// Height dimension.
const dimension = new THREE.Group();
dimension.position.x = -config.width / 2 - 0.18;
root.add(dimension);
const heightLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, config.desk, 0)
]),
new THREE.LineBasicMaterial({ color: config.accent })
);
dimension.add(heightLine);
const bottomTick = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.08, 0, 0),
new THREE.Vector3(0.08, 0, 0)
]),
new THREE.LineBasicMaterial({ color: config.accent })
);
dimension.add(bottomTick);
const topTick = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-0.08, 0, 0),
new THREE.Vector3(0.08, 0, 0)
]),
new THREE.LineBasicMaterial({ color: config.accent })
);
topTick.position.y = config.desk;
dimension.add(topTick);
createChair(config, root);
const person = createPerson(config);
root.add(person.group);
const reach = createReachDiagram(config);
const stationLabel = createWorldLabel("station-label");
stationLabel.innerHTML = `${config.name}<small>${config.group}</small>`;
stationLabel.style.borderTop = `3px solid #${new THREE.Color(config.accent).getHexString()}`;
const deskLabel = createWorldLabel("target-label");
const storageLabel = createWorldLabel("target-label");
return {
config,
root,
deskGroup,
desktop,
frontStrip,
mat,
legs,
crossbar,
monitorGroup,
keyboard,
storageGroup,
dimension,
heightLine,
topTick,
person,
reach,
stationLabel,
deskLabel,
storageLabel,
active: index === 1
};
}
const stations = stationConfigs.map(createStation);
// Build the interactive station cards.
const controlsRoot = document.getElementById("stationControls");
stationConfigs.forEach((config, index) => {
const card = document.createElement("section");
card.className = `station-card${index === 1 ? " active" : ""}`;
card.style.setProperty("--accent", `#${new THREE.Color(config.accent).getHexString()}`);
card.innerHTML = `
<div class="station-head">
<i class="station-dot"></i>
<strong>${config.name}</strong>
<span>${config.group}</span>
</div>
<div class="control">
<div class="control-label">
<span>Desk height</span>
<output id="deskValue${index}">${Math.round(config.desk * 100)} cm</output>
</div>
<input id="deskSlider${index}" type="range"
min="${config.deskMin}" max="${config.deskMax}" step="0.01" value="${config.desk}">
</div>
<div class="control">
<div class="control-label">
<span>Storage lift</span>
<output id="storageValue${index}">${Math.round(config.storage * 100)} cm</output>
</div>
<input id="storageSlider${index}" type="range"
min="${config.storageMin}" max="${config.storageMax}" step="0.01" value="${config.storage}">
</div>
<div class="status-row">
<div id="deskStatus${index}" class="status" data-state="comfortable">Desk comfortable</div>
<div id="storageStatus${index}" class="status" data-state="comfortable">Storage comfortable</div>
</div>
`;
controlsRoot.appendChild(card);
const deskSlider = card.querySelector(`#deskSlider${index}`);
const storageSlider = card.querySelector(`#storageSlider${index}`);
deskSlider.addEventListener("input", () => {
stations[index].config.desk = Number(deskSlider.value);
setActiveStation(index);
updateStation(index);
});
storageSlider.addEventListener("input", () => {
stations[index].config.storage = Number(storageSlider.value);
setActiveStation(index);
updateStation(index);
});
card.addEventListener("pointerdown", () => {
setActiveStation(index);
});
});
function reachState(ratio) {
if (ratio <= 0.72) return { key: "comfortable", label: "Comfortable", color: 0x248b65 };
if (ratio <= 1) return { key: "stretch", label: "Stretch", color: 0xd58b22 };
return { key: "out", label: "Out of reach", color: 0xcf514b };
}
function setTarget(target, from, to, state) {
target.line.geometry.setFromPoints([from, to]);
target.line.geometry.computeBoundingSphere();
target.line.computeLineDistances();
target.line.material.color.setHex(state.color);
target.marker.position.copy(to);
target.marker.material.color.setHex(state.color);
}
function updateStation(index) {
const station = stations[index];
const config = station.config;
const h = config.desk;
station.desktop.position.y = h;
station.frontStrip.position.y = h - 0.015;
station.mat.position.y = h + 0.058;
station.keyboard.position.y = h + 0.076;
station.monitorGroup.position.y = h + 0.065;
station.crossbar.position.y = h - 0.15;
station.legs.forEach(({ lower, upper, x, z }) => {
setBetween(lower, [x, 0.04, z], [x, 0.38, z]);
setBetween(upper, [x, 0.33, z], [x, h - 0.06, z]);
});
station.heightLine.scale.y = h;
station.topTick.position.y = h;
station.storageGroup.position.y = config.storage;
station.person.updateArms(h);
const shoulder = new THREE.Vector3(config.x, config.shoulder, 1.02);
const deskTarget = new THREE.Vector3(config.x, h + 0.055, 0.39);
const storageTarget = new THREE.Vector3(
config.x + 0.63,
config.storage,
0.22
);
const deskDistance = shoulder.distanceTo(deskTarget);
const storageDistance = shoulder.distanceTo(storageTarget);
const deskState = reachState(deskDistance / config.reach);
const storageState = reachState(storageDistance / config.reach);
setTarget(station.reach.desk, shoulder, deskTarget, deskState);
setTarget(station.reach.storage, shoulder, storageTarget, storageState);
const deskValue = document.getElementById(`deskValue${index}`);
const storageValue = document.getElementById(`storageValue${index}`);
const deskStatus = document.getElementById(`deskStatus${index}`);
const storageStatus = document.getElementById(`storageStatus${index}`);
deskValue.textContent = `${Math.round(h * 100)} cm`;
storageValue.textContent = `${Math.round(config.storage * 100)} cm`;
deskStatus.textContent = `Desk ${deskState.label.toLowerCase()}`;
deskStatus.dataset.state = deskState.key;
storageStatus.textContent = `Storage ${storageState.label.toLowerCase()}`;
storageStatus.dataset.state = storageState.key;
station.deskLabel.textContent = `Desk · ${Math.round(h * 100)} cm · ${deskState.label}`;
station.deskLabel.dataset.state = deskState.key;
station.storageLabel.textContent = `Storage · ${Math.round(config.storage * 100)} cm · ${storageState.label}`;
station.storageLabel.dataset.state = storageState.key;
}
function setActiveStation(index) {
stations.forEach((station, i) => {
station.active = i === index;
station.deskLabel.style.display = station.active ? "block" : "none";
station.storageLabel.style.display = station.active ? "block" : "none";
});
[...controlsRoot.children].forEach((card, i) => {
card.classList.toggle("active", i === index);
});
}
stations.forEach((_, index) => updateStation(index));
setActiveStation(1);
// Custom camera controls — no addons.
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", event => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.focus();
});
canvas.addEventListener("pointermove", event => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.theta -= dx * 0.005;
cameraState.phi = THREE.MathUtils.clamp(cameraState.phi - dy * 0.005, 0.42, 1.35);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
11,
28
);
updateCamera();
}, { passive: false });
canvas.addEventListener("keydown", event => {
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) {
event.preventDefault();
if (event.key === "ArrowLeft") cameraState.theta -= 0.09;
if (event.key === "ArrowRight") cameraState.theta += 0.09;
if (event.key === "ArrowUp") cameraState.phi = Math.max(0.42, cameraState.phi - 0.07);
if (event.key === "ArrowDown") cameraState.phi = Math.min(1.35, cameraState.phi + 0.07);
updateCamera();
}
});
document.getElementById("resetCamera").addEventListener("click", () => {
cameraState.target.set(0, 0.95, 0.45);
cameraState.radius = 19.5;
cameraState.theta = 0.12;
cameraState.phi = 0.97;
updateCamera();
});
const reachToggle = document.getElementById("reachToggle");
reachToggle.addEventListener("change", () => {
stations.forEach(station => {
station.reach.group.visible = reachToggle.checked;
station.reach.desk.line.visible = reachToggle.checked;
station.reach.desk.marker.visible = reachToggle.checked;
station.reach.storage.line.visible = reachToggle.checked;
station.reach.storage.marker.visible = reachToggle.checked;
station.deskLabel.style.display = reachToggle.checked && station.active ? "block" : "none";
station.storageLabel.style.display = reachToggle.checked && station.active ? "block" : "none";
});
});
function positionLabel(element, worldPosition) {
const projected = worldPosition.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
if (!visible) {
element.style.opacity = "0";
return;
}
element.style.opacity = "1";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
stations.forEach(station => {
const pulse = 1 + Math.sin(time * 2.4 + station.config.x) * 0.10;
station.reach.desk.marker.scale.setScalar(pulse);
station.reach.storage.marker.scale.setScalar(pulse);
const labelPosition = new THREE.Vector3(
station.config.x,
Math.max(1.72, station.config.shoulder + 0.72),
0.90
);
positionLabel(station.stationLabel, labelPosition);
const deskPosition = new THREE.Vector3(
station.config.x,
station.config.desk + 0.13,
0.39
);
const storagePosition = new THREE.Vector3(
station.config.x + 0.63,
station.config.storage + 0.16,
0.22
);
positionLabel(station.deskLabel, deskPosition);
positionLabel(station.storageLabel, storagePosition);
});
renderer.render(scene, camera);
}
document.getElementById("loading").remove();
animate();
</script>
</body>
</html>
```