Prompt specification
Build or customize the Three.js 3D scene "Slatted divider sightline model" 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: Slatted divider sightline model
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/slatted-divider-sightline-model-x0213
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing room dividers. Show a short slatted screen between two colored markers; rotate the screen to reveal how gaps alternately expose and hide the far marker from one viewpoint. Voxel style.
Working Three.js Starter (slatted-divider-sightline-model-x0213):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Room Dividers — Voxel Parallax Study</title>
<style>
:root {
--ink: #18302b;
--paper: #f4f0e7;
--coral: #f36b4d;
--cyan: #08b9bb;
--panel: rgba(247, 244, 235, 0.91);
--line: rgba(24, 48, 43, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce5df;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#stage {
position: fixed;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.edge-frame {
position: fixed;
inset: 12px;
z-index: 2;
border: 1px solid rgba(24, 48, 43, 0.22);
pointer-events: none;
}
.header {
position: fixed;
top: 34px;
left: 36px;
z-index: 4;
width: min(360px, calc(100vw - 72px));
pointer-events: none;
}
.eyebrow,
.micro-label {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow {
display: inline-block;
margin-bottom: 13px;
padding: 7px 9px 6px;
border: 1px solid var(--ink);
background: var(--panel);
box-shadow: 3px 3px 0 var(--ink);
}
h1 {
margin: 0;
max-width: 330px;
font-size: clamp(44px, 5.5vw, 78px);
font-weight: 950;
line-height: 0.83;
letter-spacing: -0.075em;
text-transform: uppercase;
}
.intro {
max-width: 305px;
margin: 18px 0 0;
font-size: 13px;
font-weight: 650;
line-height: 1.45;
}
.legend {
position: fixed;
top: 36px;
left: 50%;
z-index: 4;
display: flex;
gap: 8px;
transform: translateX(-50%);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 10px;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 2px 2px 0 rgba(24, 48, 43, 0.18);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.dot {
width: 10px;
height: 10px;
background: var(--coral);
box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.15);
}
.dot.cyan {
background: var(--cyan);
}
.readout {
position: fixed;
top: 34px;
right: 36px;
z-index: 4;
width: 226px;
padding: 16px;
border: 1px solid var(--ink);
background: var(--panel);
box-shadow: 5px 5px 0 var(--ink);
pointer-events: none;
}
.readout-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
}
#visibility-state {
margin-top: 9px;
font-size: 28px;
font-weight: 950;
line-height: 1;
letter-spacing: -0.045em;
color: #a13c2d;
transition: color 120ms ease;
}
#visibility-state.exposed {
color: #008b8f;
}
#visibility-state.partial {
color: #a86817;
}
.meter {
height: 9px;
margin: 13px 0 8px;
overflow: hidden;
border: 1px solid var(--ink);
background: rgba(24, 48, 43, 0.1);
}
.meter > span {
display: block;
width: 100%;
height: 100%;
transform: scaleX(0);
transform-origin: left center;
background: var(--cyan);
transition: transform 90ms linear;
}
#visibility-percent {
display: block;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.05em;
}
.angle-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 15px;
padding-top: 12px;
border-top: 1px solid var(--line);
}
#angle-value {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 15px;
font-weight: 900;
}
.controls {
position: fixed;
bottom: 35px;
left: 50%;
z-index: 6;
width: min(650px, calc(100vw - 48px));
padding: 13px 14px 14px;
border: 1px solid var(--ink);
background: var(--panel);
box-shadow: 6px 6px 0 var(--ink);
transform: translateX(-50%);
}
.controls-top {
display: grid;
grid-template-columns: auto 1fr auto;
align-items: center;
gap: 16px;
}
.button-row {
display: flex;
gap: 8px;
}
button {
min-height: 35px;
padding: 0 12px;
border: 1px solid var(--ink);
border-radius: 0;
background: transparent;
color: var(--ink);
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.07em;
text-transform: uppercase;
}
button:hover {
background: var(--ink);
color: var(--paper);
}
button.primary {
background: var(--ink);
color: var(--paper);
}
button.primary:hover {
background: #2b5047;
}
.slider-wrap {
display: grid;
grid-template-columns: auto 1fr;
align-items: center;
gap: 10px;
}
input[type="range"] {
width: 100%;
height: 5px;
margin: 0;
border: 0;
border-radius: 0;
appearance: none;
background: rgba(24, 48, 43, 0.2);
cursor: ew-resize;
}
input[type="range"]::-webkit-slider-thumb {
width: 18px;
height: 18px;
border: 2px solid var(--ink);
border-radius: 0;
appearance: none;
background: var(--paper);
box-shadow: 2px 2px 0 var(--ink);
}
input[type="range"]::-moz-range-thumb {
width: 16px;
height: 16px;
border: 2px solid var(--ink);
border-radius: 0;
background: var(--paper);
box-shadow: 2px 2px 0 var(--ink);
}
.hint {
position: fixed;
bottom: 20px;
left: 36px;
z-index: 4;
max-width: 220px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 9px;
font-weight: 700;
line-height: 1.5;
letter-spacing: 0.06em;
text-transform: uppercase;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #e1e8e2;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
}
@media (max-width: 850px) {
.legend {
display: none;
}
.header {
top: 25px;
left: 25px;
}
h1 {
font-size: 44px;
}
.intro {
display: none;
}
.readout {
top: 24px;
right: 24px;
width: 180px;
padding: 12px;
}
#visibility-state {
font-size: 23px;
}
.controls {
bottom: 22px;
width: calc(100vw - 34px);
}
.controls-top {
grid-template-columns: 1fr auto;
gap: 10px;
}
.slider-wrap {
grid-column: 1 / -1;
grid-row: 2;
}
.hint {
display: none;
}
}
@media (max-width: 560px) {
.edge-frame {
inset: 7px;
}
.header {
top: 20px;
left: 20px;
}
.eyebrow {
margin-bottom: 9px;
padding: 5px 7px;
font-size: 8px;
}
h1 {
font-size: 36px;
}
.readout {
top: 18px;
right: 18px;
width: 145px;
}
.readout .micro-label {
font-size: 8px;
}
#visibility-state {
font-size: 20px;
}
.controls {
bottom: 15px;
width: calc(100vw - 28px);
padding: 10px;
}
button {
padding: 0 9px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="edge-frame"></div>
<header class="header">
<div class="eyebrow">Spatial Study / 01</div>
<h1>Room<br />Dividers</h1>
<p class="intro">
One fixed viewpoint. One rotating slatted screen. Watch the cyan marker
alternately appear and disappear through the changing gaps.
</p>
</header>
<div class="legend" aria-hidden="true">
<div class="legend-item"><span class="dot"></span>A · Near marker</div>
<div class="legend-item"><span class="dot cyan"></span>B · Far marker</div>
</div>
<aside class="readout" aria-label="Visibility readout">
<div class="micro-label">Visibility from fixed eye</div>
<div id="visibility-state" aria-live="polite">HIDDEN</div>
<div class="meter"><span id="visibility-fill"></span></div>
<small id="visibility-percent">0% exposed</small>
<div class="angle-row">
<span class="micro-label">Divider rotation</span>
<strong id="angle-value">+30°</strong>
</div>
</aside>
<section class="controls" aria-label="Divider controls">
<div class="controls-top">
<div class="button-row">
<button id="sweep-button" class="primary" type="button">Pause sweep</button>
<button id="reset-button" type="button">Reset</button>
</div>
<div></div>
<div class="slider-wrap">
<label class="micro-label" for="rotation">Rotate</label>
<input
id="rotation"
type="range"
min="-32"
max="32"
step="0.1"
value="30"
aria-label="Divider rotation"
/>
</div>
</div>
</section>
<div class="hint">
Drag the divider to rotate it<br />
← → keys also rotate<br />
Space toggles the sweep
</div>
<div id="loading">Building voxel room…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const loading = document.querySelector("#loading");
const angleInput = document.querySelector("#rotation");
const angleValue = document.querySelector("#angle-value");
const visibilityState = document.querySelector("#visibility-state");
const visibilityFill = document.querySelector("#visibility-fill");
const visibilityPercent = document.querySelector("#visibility-percent");
const sweepButton = document.querySelector("#sweep-button");
const resetButton = document.querySelector("#reset-button");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const backgroundColor = new THREE.Color(0xdce5df);
scene.background = backgroundColor;
scene.fog = new THREE.Fog(backgroundColor, 12, 23);
// The viewpoint is intentionally locked so the changing occlusion is caused
// only by the divider's rotation.
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
60
);
camera.position.set(0, 3.7, 8.5);
camera.lookAt(0, 0.65, -0.15);
const hemisphere = new THREE.HemisphereLight(0xffffff, 0x718177, 2.35);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2d8, 3.1);
sun.position.set(-4.5, 8, 5.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -7;
sun.shadow.camera.right = 7;
sun.shadow.camera.top = 8;
sun.shadow.camera.bottom = -6;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 24;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fillLight = new THREE.DirectionalLight(0xb9e8e5, 1.1);
fillLight.position.set(5, 3, -3);
scene.add(fillLight);
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
});
}
function addBox(parent, width, height, depth, material, x, y, z, cast = true, receive = true) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
// ---------- Voxel room ----------
const floorBaseMaterial = standardMaterial(0xc5cbc3);
addBox(
scene,
10.5,
0.18,
7.8,
floorBaseMaterial,
0,
-0.13,
0.45,
false,
true
);
const tileMaterials = [
standardMaterial(0xe8e4d8),
standardMaterial(0xdfddd2),
standardMaterial(0xeee9dd),
standardMaterial(0xd8ddd4)
];
let tileSeed = 17;
function seededRandom() {
tileSeed = (tileSeed * 16807) % 2147483647;
return (tileSeed - 1) / 2147483646;
}
for (let x = 0; x < 10; x++) {
for (let z = 0; z < 7; z++) {
const index = Math.floor(seededRandom() * tileMaterials.length);
addBox(
scene,
0.96,
0.08,
0.96,
tileMaterials[index],
-4.5 + x,
-0.025,
-2.5 + z,
false,
true
);
}
}
const wallMaterials = [
standardMaterial(0xbac9c0),
standardMaterial(0xc5d1c8),
standardMaterial(0xd1dbd3),
standardMaterial(0xb4c3ba)
];
for (let column = 0; column < 10; column++) {
for (let row = 0; row < 5; row++) {
const material = wallMaterials[(column + row * 2) % wallMaterials.length];
addBox(
scene,
1.04,
0.66,
0.18,
material,
-4.95 + column * 1.1,
0.35 + row * 0.68,
-3.45,
false,
true
);
}
}
const sideWallMaterial = standardMaterial(0xc8d3cb);
for (let z = 0; z < 7; z++) {
addBox(
scene,
0.18,
3.35,
0.96,
sideWallMaterial,
-5.1,
1.68,
-2.5 + z,
false,
true
);
}
// Secondary block partitions establish the room-divider theme without
// competing with the main animated screen.
const partitionMaterialA = standardMaterial(0xaebdb4);
const partitionMaterialB = standardMaterial(0x9eafa5);
for (let i = 0; i < 3; i++) {
addBox(
scene,
0.64,
1.42 - i * 0.1,
0.7,
i % 2 ? partitionMaterialA : partitionMaterialB,
-3.72 + i * 0.67,
(1.42 - i * 0.1) / 2,
-2.55,
true,
true
);
}
for (let i = 0; i < 3; i++) {
addBox(
scene,
0.64,
1.18 - i * 0.08,
0.7,
i % 2 ? partitionMaterialB : partitionMaterialA,
3.22 + i * 0.67,
(1.18 - i * 0.08) / 2,
-2.6,
true,
true
);
}
// ---------- Main rotating divider ----------
const screenGroup = new THREE.Group();
screenGroup.name = "Rotating slatted divider";
scene.add(screenGroup);
const screenOccluders = [];
const frameMaterial = standardMaterial(0x765039);
const slatMaterials = [
standardMaterial(0xc69762),
standardMaterial(0xba8754),
standardMaterial(0xd0a66f)
];
function addScreenPart(width, height, depth, material, x, y, z = 0) {
const mesh = addBox(
screenGroup,
width,
height,
depth,
material,
x,
y,
z,
true,
true
);
screenOccluders.push(mesh);
return mesh;
}
// Two substantial end stiles and narrow internal slats create a wide gap
// on one side. Rotation carries the far marker from that gap into a stile.
addScreenPart(0.34, 2.64, 0.34, frameMaterial, -1.95, 1.32);
addScreenPart(0.34, 2.64, 0.34, frameMaterial, 1.95, 1.32);
const interiorSlatX = [-1.45, -1.0, -0.55, -0.1, 0.35, 0.8, 1.25];
interiorSlatX.forEach((x, index) => {
addScreenPart(
0.16,
2.48,
0.24,
slatMaterials[index % slatMaterials.length],
x,
1.28
);
});
addScreenPart(4.24, 0.18, 0.3, frameMaterial, 0, 2.57);
addScreenPart(4.24, 0.16, 0.3, frameMaterial, 0, 0.14);
addScreenPart(0.5, 0.12, 0.78, frameMaterial, -1.95, 0.06);
addScreenPart(0.5, 0.12, 0.78, frameMaterial, 1.95, 0.06);
addScreenPart(4.48, 0.08, 0.56, frameMaterial, 0, 0.04);
// ---------- Markers ----------
const pedestalMaterial = standardMaterial(0xd2cec2);
const coralMaterial = standardMaterial(0xf36b4d, {
roughness: 0.6,
emissive: 0x5e1308,
emissiveIntensity: 0.18
});
const cyanMaterial = standardMaterial(0x08b9bb, {
roughness: 0.46,
emissive: 0x007f82,
emissiveIntensity: 0.52
});
// Near marker: a coral voxel stack.
addBox(scene, 1.12, 0.24, 0.95, pedestalMaterial, -1.45, 0.12, 1.55, false, true);
addBox(scene, 0.74, 0.18, 0.74, coralMaterial, -1.45, 0.33, 1.55);
addBox(scene, 0.58, 0.38, 0.58, coralMaterial, -1.45, 0.61, 1.55);
addBox(scene, 0.4, 0.16, 0.4, coralMaterial, -1.45, 0.88, 1.55);
// Far marker: narrow enough to fit fully behind a slat or inside the gap.
const farMarkerX = 1.72;
const farMarkerZ = -1.7;
const farMarkerWidth = 0.18;
const farMarkerHeight = 1.05;
const farMarkerDepth = 0.18;
addBox(scene, 0.88, 0.22, 0.72, pedestalMaterial, farMarkerX, 0.11, farMarkerZ, false, true);
const farMarker = addBox(
scene,
farMarkerWidth,
farMarkerHeight,
farMarkerDepth,
cyanMaterial,
farMarkerX,
0.22 + farMarkerHeight / 2,
farMarkerZ
);
// ---------- Interaction and animation ----------
const MAX_ANGLE = 32;
let angle = 30;
let sweeping = true;
let sweepTime = Math.asin(angle / MAX_ANGLE);
let dragging = false;
let dragStartX = 0;
let dragStartAngle = angle;
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
const samplePoint = new THREE.Vector3();
const sampleDirection = new THREE.Vector3();
function setSweeping(value) {
sweeping = value;
sweepButton.textContent = sweeping ? "Pause sweep" : "Start sweep";
sweepButton.classList.toggle("primary", sweeping);
if (sweeping) {
sweepTime = Math.asin(THREE.MathUtils.clamp(angle / MAX_ANGLE, -0.999, 0.999));
}
}
function setAngle(value) {
angle = THREE.MathUtils.clamp(value, -MAX_ANGLE, MAX_ANGLE);
angleInput.value = angle.toFixed(1);
angleValue.textContent = `${angle >= 0 ? "+" : ""}${Math.round(angle)}°`;
}
angleInput.addEventListener("input", () => {
setSweeping(false);
setAngle(Number(angleInput.value));
});
sweepButton.addEventListener("click", () => {
setSweeping(!sweeping);
});
resetButton.addEventListener("click", () => {
setSweeping(false);
setAngle(30);
});
function updatePointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
updatePointer(event);
scene.updateMatrixWorld(true);
raycaster.setFromCamera(pointer, camera);
if (raycaster.intersectObject(screenGroup, true).length > 0) {
dragging = true;
dragStartX = event.clientX;
dragStartAngle = angle;
setSweeping(false);
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
updatePointer(event);
if (dragging) {
const delta = event.clientX - dragStartX;
setAngle(dragStartAngle + delta * 0.22);
return;
}
scene.updateMatrixWorld(true);
raycaster.setFromCamera(pointer, camera);
const hoveringScreen = raycaster.intersectObject(screenGroup, true).length > 0;
renderer.domElement.style.cursor = hoveringScreen ? "grab" : "default";
});
function stopDragging() {
dragging = false;
renderer.domElement.style.cursor = "default";
}
window.addEventListener("pointerup", stopDragging);
window.addEventListener("pointercancel", stopDragging);
window.addEventListener("keydown", (event) => {
if (event.code === "ArrowLeft") {
event.preventDefault();
setSweeping(false);
setAngle(angle - 1.5);
} else if (event.code === "ArrowRight") {
event.preventDefault();
setSweeping(false);
setAngle(angle + 1.5);
} else if (event.code === "Space") {
event.preventDefault();
setSweeping(!sweeping);
}
});
function updateVisibility() {
let visibleSamples = 0;
let totalSamples = 0;
const columns = 5;
const rows = 9;
const frontZ = farMarkerZ + farMarkerDepth / 2 + 0.004;
for (let column = 0; column < columns; column++) {
for (let row = 0; row < rows; row++) {
samplePoint.set(
farMarkerX - farMarkerWidth / 2 + (farMarkerWidth * column) / (columns - 1),
0.22 + (farMarkerHeight * row) / (rows - 1),
frontZ
);
sampleDirection.subVectors(samplePoint, camera.position);
const targetDistance = sampleDirection.length();
sampleDirection.normalize();
raycaster.set(camera.position, sampleDirection);
raycaster.near = 0;
raycaster.far = targetDistance - 0.015;
const hits = raycaster.intersectObjects(screenOccluders, false);
if (hits.length === 0) visibleSamples++;
totalSamples++;
}
}
const ratio = visibleSamples / totalSamples;
const percent = Math.round(ratio * 100);
visibilityFill.style.transform = `scaleX(${ratio})`;
visibilityPercent.textContent = `${percent}% exposed`;
visibilityState.classList.remove("exposed", "partial");
if (ratio < 0.08) {
visibilityState.textContent = "HIDDEN";
} else if (ratio > 0.92) {
visibilityState.textContent = "EXPOSED";
visibilityState.classList.add("exposed");
} else {
visibilityState.textContent = "PARTIAL";
visibilityState.classList.add("partial");
}
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (sweeping) {
sweepTime += delta * 0.72;
setAngle(Math.sin(sweepTime) * MAX_ANGLE);
}
screenGroup.rotation.y = THREE.MathUtils.degToRad(angle);
scene.updateMatrixWorld(true);
updateVisibility();
renderer.render(scene, camera);
}
setAngle(angle);
setSweeping(true);
resize();
animate();
loading.remove();
</script>
</body>
</html>
```