Prompt specification
Build or customize the Three.js 3D scene "Student study desk arrangement" 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: Student study desk arrangement
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/student-study-desk-arrangement-x0051
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows bookmarks and page markers. Arrange notebooks, bookmarks, pencil tray, and desk lamp; a simple study sequence alternates reference pages and notes while each marked section remains easy to locate. Stylized solid forms.
Working Three.js Starter (student-study-desk-arrangement-x0051):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Marked Study Desk</title>
<style>
:root {
--ink: #24343b;
--muted: #718087;
--paper: rgba(255, 253, 248, 0.92);
--line: rgba(36, 52, 59, 0.12);
--mint: #25a6a1;
--coral: #ef6a5b;
--amber: #f2b84b;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e1d4;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene,
#scene canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
}
#scene canvas {
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 28px;
left: 30px;
width: min(360px, calc(100vw - 60px));
padding: 20px 22px;
border: 1px solid rgba(255, 255, 255, 0.54);
border-radius: 20px;
background: var(--paper);
box-shadow: 0 14px 40px rgba(57, 54, 45, 0.11);
backdrop-filter: blur(14px);
}
.eyebrow {
margin-bottom: 9px;
color: var(--mint);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 36px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 1.03;
}
.subtitle {
margin: 11px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.5;
}
.controls-hint {
margin-top: 13px;
color: #8a9598;
font-size: 11px;
letter-spacing: 0.02em;
}
.legend {
position: absolute;
top: 28px;
right: 30px;
display: grid;
gap: 8px;
width: 182px;
padding: 12px;
border: 1px solid rgba(255, 255, 255, 0.52);
border-radius: 17px;
background: var(--paper);
box-shadow: 0 14px 40px rgba(57, 54, 45, 0.1);
backdrop-filter: blur(14px);
pointer-events: auto;
}
.legend-label {
padding: 3px 5px 6px;
color: #899396;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend button {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
padding: 9px 8px;
border: 0;
border-radius: 10px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 12px;
text-align: left;
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.legend button:hover,
.legend button:focus-visible {
background: rgba(36, 52, 59, 0.06);
outline: none;
transform: translateX(-2px);
}
.legend button.active {
background: rgba(36, 52, 59, 0.08);
}
.swatch {
position: relative;
width: 24px;
height: 24px;
flex: 0 0 auto;
border-radius: 8px 8px 8px 2px;
background: var(--marker);
box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.swatch::after {
content: "";
position: absolute;
left: 5px;
bottom: -5px;
width: 4px;
height: 10px;
border-radius: 0 0 2px 2px;
background: var(--marker);
}
.sequence-panel {
position: absolute;
left: 50%;
bottom: 24px;
width: min(620px, calc(100vw - 32px));
padding: 14px 16px 13px;
transform: translateX(-50%);
border: 1px solid rgba(255, 255, 255, 0.56);
border-radius: 19px;
background: var(--paper);
box-shadow: 0 18px 50px rgba(57, 54, 45, 0.15);
backdrop-filter: blur(16px);
pointer-events: auto;
}
.sequence-top {
display: flex;
align-items: center;
gap: 12px;
}
.sequence-copy {
min-width: 0;
flex: 1;
}
#phase-title {
overflow: hidden;
margin: 0;
font-size: 13px;
font-weight: 800;
letter-spacing: 0.055em;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
}
#phase-caption {
margin: 3px 0 0;
color: var(--muted);
font-size: 11px;
}
.transport {
display: flex;
gap: 6px;
}
.transport button {
display: grid;
width: 34px;
height: 34px;
place-items: center;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 255, 255, 0.72);
color: var(--ink);
font: inherit;
font-size: 15px;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
.transport button:hover,
.transport button:focus-visible {
background: white;
outline: none;
transform: translateY(-1px);
}
.transport #play {
border-color: var(--ink);
background: var(--ink);
color: white;
}
.progress-track {
height: 4px;
margin-top: 12px;
overflow: hidden;
border-radius: 4px;
background: rgba(36, 52, 59, 0.09);
}
#progress {
width: 100%;
height: 100%;
transform: scaleX(0);
transform-origin: left center;
border-radius: inherit;
background: var(--active-color, var(--mint));
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #e9e1d4;
color: var(--ink);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.title-card {
top: 14px;
left: 14px;
width: min(285px, calc(100vw - 28px));
padding: 15px 16px;
border-radius: 16px;
}
.subtitle,
.controls-hint {
display: none;
}
.legend {
top: 14px;
right: 14px;
width: 52px;
padding: 7px;
}
.legend-label,
.legend .legend-text {
display: none;
}
.legend button {
justify-content: center;
padding: 5px;
}
.sequence-panel {
bottom: 12px;
padding: 11px 12px;
}
#phase-caption {
display: none;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive three-dimensional study desk"></div>
<div class="ui">
<section class="title-card">
<div class="eyebrow">Desk Study / 01</div>
<h1>Find it. Mark it. Return.</h1>
<p class="subtitle">
A repeating study path between the reference pages and your notes, with every marked section kept in view.
</p>
<div class="controls-hint">Drag to orbit · Scroll to zoom · Click a marker</div>
</section>
<nav class="legend" aria-label="Page markers">
<div class="legend-label">Marker key</div>
<button class="active" data-marker="0" style="--marker: #25a6a1">
<span class="swatch"></span><span class="legend-text">01 · Setup</span>
</button>
<button data-marker="1" style="--marker: #ef6a5b">
<span class="swatch"></span><span class="legend-text">02 · Evidence</span>
</button>
<button data-marker="2" style="--marker: #f2b84b">
<span class="swatch"></span><span class="legend-text">03 · Review</span>
</button>
</nav>
<section class="sequence-panel" aria-label="Study sequence controls">
<div class="sequence-top">
<div class="sequence-copy">
<p id="phase-title">Reference · 01 Setup</p>
<p id="phase-caption">Locate the teal section in the reference pages.</p>
</div>
<div class="transport">
<button id="previous" aria-label="Previous step" title="Previous step">‹</button>
<button id="play" aria-label="Pause sequence" title="Pause sequence">Ⅱ</button>
<button id="next" aria-label="Next step" title="Next step">›</button>
</div>
</div>
<div class="progress-track"><div id="progress"></div></div>
</section>
</div>
<div id="loading">Arranging the study desk…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const loading = document.getElementById("loading");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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.05;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e1d4);
scene.fog = new THREE.Fog(0xe9e1d4, 20, 34);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
70
);
camera.position.set(8.4, 10.2, 13.2);
const hemisphere = new THREE.HemisphereLight(0xfff9ed, 0x8f7664, 1.75);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4dc, 3.3);
keyLight.position.set(-6, 11, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xbdd8e3, 0.85);
fillLight.position.set(8, 6, -6);
scene.add(fillLight);
const material = (color, roughness = 0.72, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const colors = {
desk: material(0xb9855d, 0.82),
deskEdge: material(0x936341, 0.84),
wall: material(0xe8dfd1, 0.95),
cream: material(0xf7f0df, 0.88),
creamEdge: material(0xdfd4bf, 0.9),
navy: material(0x294b64, 0.76),
navyLight: material(0x365e78, 0.78),
sage: material(0x789487, 0.8),
sageDark: material(0x5f7e70, 0.82),
graphite: material(0x5d696b, 0.9),
faint: material(0xb9b4a9, 0.95),
brass: material(0xd29b45, 0.42, 0.32),
lamp: material(0xd56f58, 0.56, 0.08),
lampDark: material(0x9c4d42, 0.7, 0.08),
white: material(0xfffdf7, 0.84),
wood: material(0xd1a36d, 0.82),
woodDark: material(0xa87447, 0.86),
black: material(0x344044, 0.7),
pencilMint: material(0x3aa69d, 0.62),
pencilCoral: material(0xe56e5d, 0.62),
pencilAmber: material(0xe6ae43, 0.62)
};
const markerDefinitions = [
{ hex: 0x25a6a1, css: "#25a6a1", name: "Setup" },
{ hex: 0xef6a5b, css: "#ef6a5b", name: "Evidence" },
{ hex: 0xf2b84b, css: "#f2b84b", name: "Review" }
];
function addBox(w, h, d, mat, x, y, z, parent = scene, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinderBetween(a, b, radius, mat, parent = scene, segments = 20) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, segments),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Desk and background.
addBox(12, 0.32, 8, colors.desk, 0, -0.18, 0);
addBox(12.08, 0.18, 0.22, colors.deskEdge, 0, -0.33, 3.88);
addBox(12.08, 0.18, 0.22, colors.deskEdge, 0, -0.33, -3.88);
addBox(0.22, 0.18, 7.8, colors.deskEdge, -5.93, -0.33, 0);
addBox(0.22, 0.18, 7.8, colors.deskEdge, 5.93, -0.33, 0);
addBox(12.5, 5.5, 0.18, colors.wall, 0, 2.25, -4.18, scene, false);
// Subtle desk-edge bands.
const grainMaterial = new THREE.MeshStandardMaterial({
color: 0x9d6e4e,
roughness: 0.95,
transparent: true,
opacity: 0.18
});
for (let i = 0; i < 7; i++) {
addBox(0.025, 0.012, 6.8, grainMaterial, -4.8 + i * 1.58, -0.012, 0, scene, false);
}
function addPageLines(root, xStart, width, depth, count, y, muted = colors.faint) {
for (let i = 0; i < count; i++) {
const lineWidth = width * (i % 4 === 0 ? 0.72 : i % 3 === 0 ? 0.83 : 0.92);
addBox(
lineWidth,
0.018,
0.025,
muted,
xStart - width * 0.08 + lineWidth * 0.5,
y,
depth * 0.28 - i * 0.22,
root,
false
);
}
}
function createOpenBook({
x,
z,
w,
d,
coverMaterial,
pageMaterial,
rotation = 0,
marked = false
}) {
const root = new THREE.Group();
root.position.set(x, 0, z);
root.rotation.y = rotation;
scene.add(root);
addBox(w, 0.14, d, coverMaterial, 0, 0.055, 0, root);
addBox(w - 0.08, 0.08, d - 0.06, colors.creamEdge, 0, 0.155, 0, root);
const pageWidth = w * 0.475;
addBox(pageWidth, 0.17, d - 0.18, pageMaterial, -w * 0.25, 0.245, 0, root);
addBox(pageWidth, 0.17, d - 0.18, pageMaterial, w * 0.25, 0.245, 0, root);
addBox(0.07, 0.025, d - 0.22, colors.creamEdge, 0, 0.337, 0, root, false);
addPageLines(root, -w * 0.25, pageWidth, d, 8, 0.346);
addPageLines(root, w * 0.25, pageWidth, d, 8, 0.346);
addBox(pageWidth * 0.65, 0.025, 0.09, colors.graphite, -w * 0.25, 0.347, d * 0.32, root, false);
addBox(pageWidth * 0.48, 0.025, 0.07, colors.graphite, w * 0.25, 0.347, d * 0.32, root, false);
if (!marked) {
const ribbon = material(0x3b8f91, 0.7);
addBox(0.13, 0.035, d * 0.72, ribbon, -0.18, 0.37, d * 0.18, root, false);
addBox(0.13, 0.025, 0.8, ribbon, -0.18, 0.19, d * 0.57, root, false);
}
return root;
}
// Central working notebook.
createOpenBook({
x: -1.2,
z: -0.05,
w: 4.7,
d: 3.35,
coverMaterial: colors.sageDark,
pageMaterial: colors.cream,
rotation: -0.075,
marked: false
});
// Open reference book.
const referenceBook = createOpenBook({
x: 3.35,
z: -1.95,
w: 4.65,
d: 3.1,
coverMaterial: colors.navy,
pageMaterial: colors.white,
rotation: 0.055,
marked: true
});
const referenceMarkers = [];
const noteMarkers = [];
const interactiveMarkers = [];
function addReferenceMarkers(root, w, d) {
const positions = [-d * 0.25, 0, d * 0.25];
markerDefinitions.forEach((definition, index) => {
const markerMaterial = material(definition.hex, 0.6);
markerMaterial.emissive = new THREE.Color(definition.hex);
markerMaterial.emissiveIntensity = 0;
const group = new THREE.Group();
root.add(group);
const tab = addBox(
0.36,
0.11,
0.48,
markerMaterial,
w * 0.5 + 0.03,
0.365,
positions[index],
group
);
const ribbonLength = d * 0.51 - positions[index];
const ribbon = addBox(
0.105,
0.032,
Math.max(0.7, ribbonLength),
markerMaterial,
w * 0.39 + index * 0.075,
0.365,
positions[index] + ribbonLength * 0.5,
group,
false
);
const pageBlock = addBox(
0.55,
0.035,
0.12,
markerMaterial,
w * 0.235,
0.365,
positions[index],
group,
false
);
[tab, ribbon, pageBlock].forEach((mesh) => {
mesh.userData.markerIndex = index;
interactiveMarkers.push(mesh);
});
referenceMarkers.push({ tab, ribbon, pageBlock, material: markerMaterial });
});
}
addReferenceMarkers(referenceBook, 4.65, 3.1);
// Notes pad with matching section tabs.
const notesRoot = new THREE.Group();
notesRoot.position.set(-2.65, 0, 2.65);
notesRoot.rotation.y = -0.035;
scene.add(notesRoot);
addBox(4.15, 0.14, 2.85, colors.lampDark, 0, 0.055, 0, notesRoot);
addBox(3.95, 0.16, 2.65, colors.cream, 0.03, 0.2, 0, notesRoot);
addBox(3.82, 0.035, 2.5, colors.white, 0.08, 0.298, 0, notesRoot);
// Spiral binding.
for (let i = 0; i < 9; i++) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.14, 0.033, 10, 28),
colors.brass
);
ring.rotation.y = Math.PI / 2;
ring.position.set(-1.92, 0.27, -1.04 + i * 0.26);
ring.castShadow = true;
notesRoot.add(ring);
}
addPageLines(notesRoot, 0.02, 3.25, 2.5, 7, 0.326, colors.faint);
addBox(1.35, 0.025, 0.075, colors.graphite, -0.48, 0.326, 0.78, notesRoot, false);
markerDefinitions.forEach((definition, index) => {
const markerMaterial = material(definition.hex, 0.6);
markerMaterial.emissive = new THREE.Color(definition.hex);
markerMaterial.emissiveIntensity = 0;
const z = [-0.7, 0, 0.7][index];
const group = new THREE.Group();
notesRoot.add(group);
const tab = addBox(
0.34,
0.11,
0.42,
markerMaterial,
1.99,
0.365,
z,
group
);
const block = addBox(
0.48,
0.034,
0.12,
markerMaterial,
1.35,
0.335,
z,
group,
false
);
const ribbon = addBox(
0.09,
0.03,
0.75,
markerMaterial,
1.72 + index * 0.06,
0.335,
z,
group,
false
);
[tab, block, ribbon].forEach((mesh) => {
mesh.userData.markerIndex = index;
interactiveMarkers.push(mesh);
});
noteMarkers.push({ tab, block, ribbon, material: markerMaterial });
});
// Pencil tray.
const trayRoot = new THREE.Group();
trayRoot.position.set(4.15, 0, 2.4);
trayRoot.rotation.y = 0.035;
scene.add(trayRoot);
addBox(2.85, 0.12, 1.34, colors.woodDark, 0, 0.045, 0, trayRoot);
addBox(2.85, 0.25, 0.11, colors.wood, 0, 0.15, -0.61, trayRoot);
addBox(2.85, 0.25, 0.11, colors.wood, 0, 0.15, 0.61, trayRoot);
addBox(0.11, 0.25, 1.15, colors.wood, -1.37, 0.15, 0, trayRoot);
addBox(0.11, 0.25, 1.15, colors.wood, 1.37, 0.15, 0, trayRoot);
const pencilMaterials = [colors.pencilMint, colors.pencilCoral, colors.pencilAmber];
[-0.82, 0, 0.82].forEach((x, index) => {
const shaft = material(index === 0 ? 0xd9a85f : index === 1 ? 0xe0b87d : 0xd9aa68, 0.75);
addCylinderBetween([x, 0.27, -0.42], [x, 0.27, 0.43], 0.075, shaft, trayRoot);
addCylinderBetween([x, 0.27, -0.42], [x, 0.27, -0.51], 0.078, pencilMaterials[index], trayRoot);
const tip = new THREE.Mesh(
new THREE.ConeGeometry(0.075, 0.22, 18),
colors.cream
);
tip.rotation.x = Math.PI / 2;
tip.position.set(x, 0.27, 0.53);
tip.castShadow = true;
trayRoot.add(tip);
const graphiteTip = new THREE.Mesh(
new THREE.ConeGeometry(0.025, 0.08, 12),
colors.black
);
graphiteTip.rotation.x = Math.PI / 2;
graphiteTip.position.set(x, 0.27, 0.67);
trayRoot.add(graphiteTip);
});
// Desk lamp.
const lampRoot = new THREE.Group();
lampRoot.position.set(-5.05, 0, -2.75);
lampRoot.rotation.y = 0.14;
scene.add(lampRoot);
const lampBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.72, 0.78, 0.22, 36),
colors.lampDark
);
lampBase.position.y = 0.1;
lampBase.castShadow = true;
lampBase.receiveShadow = true;
lampRoot.add(lampBase);
addCylinderBetween([0, 0.2, 0], [0.1, 2.15, 0.05], 0.09, colors.lamp, lampRoot);
addCylinderBetween([0.1, 2.15, 0.05], [1.25, 3.1, 0.78], 0.09, colors.lamp, lampRoot);
const jointGeometry = new THREE.SphereGeometry(0.16, 18, 14);
const jointA = new THREE.Mesh(jointGeometry, colors.lampDark);
jointA.position.set(0.1, 2.15, 0.05);
lampRoot.add(jointA);
const jointB = new THREE.Mesh(jointGeometry, colors.lampDark);
jointB.position.set(1.25, 3.1, 0.78);
lampRoot.add(jointB);
const shade = new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0.68, 0.76, 36, 1, false),
colors.lamp
);
shade.position.set(1.25, 2.91, 0.78);
shade.rotation.z = -0.13;
shade.castShadow = true;
lampRoot.add(shade);
const shadeInner = new THREE.Mesh(
new THREE.CylinderGeometry(0.185, 0.59, 0.04, 36),
material(0xffd98c, 0.55)
);
shadeInner.position.set(1.25, 2.52, 0.78);
shadeInner.rotation.z = -0.13;
lampRoot.add(shadeInner);
const bulb = new THREE.Mesh(
new THREE.SphereGeometry(0.16, 20, 14),
new THREE.MeshStandardMaterial({
color: 0xffe3a0,
emissive: 0xffb63d,
emissiveIntensity: 1.4,
roughness: 0.4
})
);
bulb.position.set(1.25, 2.48, 0.78);
lampRoot.add(bulb);
const lampLight = new THREE.PointLight(0xffbd61, 1.4, 7, 2);
lampLight.position.set(-3.8, 2.5, -1.95);
scene.add(lampLight);
// Locator ring used to make the active marked section obvious.
const locatorMaterial = new THREE.MeshBasicMaterial({
color: markerDefinitions[0].hex,
transparent: true,
opacity: 0.95,
depthTest: false
});
const locator = new THREE.Group();
locator.renderOrder = 20;
const locatorRing = new THREE.Mesh(
new THREE.TorusGeometry(0.31, 0.055, 12, 48),
locatorMaterial
);
locatorRing.rotation.x = Math.PI / 2;
locator.add(locatorRing);
const locatorCore = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 16, 12),
locatorMaterial
);
locatorCore.position.y = 0.12;
locator.add(locatorCore);
scene.add(locator);
const phases = [
{
kind: "reference",
marker: 0,
title: "Reference · 01 Setup",
caption: "Locate the teal section in the reference pages."
},
{
kind: "notes",
marker: 0,
title: "Notes · 01 Setup",
caption: "Carry the teal section into your notes."
},
{
kind: "reference",
marker: 1,
title: "Reference · 02 Evidence",
caption: "Locate the coral section in the reference pages."
},
{
kind: "notes",
marker: 1,
title: "Notes · 02 Evidence",
caption: "Carry the coral section into your notes."
},
{
kind: "reference",
marker: 2,
title: "Reference · 03 Review",
caption: "Locate the amber section in the reference pages."
},
{
kind: "notes",
marker: 2,
title: "Notes · 03 Review",
caption: "Carry the amber section into your notes."
}
];
const phaseTitle = document.getElementById("phase-title");
const phaseCaption = document.getElementById("phase-caption");
const progress = document.getElementById("progress");
const playButton = document.getElementById("play");
const legendButtons = [...document.querySelectorAll(".legend button")];
let currentPhase = 0;
let phaseElapsed = 0;
let globalTime = 0;
let playing = true;
const phaseDuration = 2.65;
const overviewTarget = new THREE.Vector3(0, 0.35, 0);
const referenceTarget = new THREE.Vector3(3.35, 0.35, -1.95);
const notesTarget = new THREE.Vector3(-2.65, 0.3, 2.65);
const cameraTarget = overviewTarget.clone();
let yaw = 0.57;
let pitch = 0.61;
let zoomBias = 0;
function setPhase(index) {
currentPhase = (index + phases.length) % phases.length;
phaseElapsed = 0;
const phase = phases[currentPhase];
phaseTitle.textContent = phase.title;
phaseCaption.textContent = phase.caption;
progress.style.background = markerDefinitions[phase.marker].css;
legendButtons.forEach((button, markerIndex) => {
button.classList.toggle("active", markerIndex === phase.marker);
});
}
function togglePlayback() {
playing = !playing;
playButton.textContent = playing ? "Ⅱ" : "▶";
playButton.setAttribute("aria-label", playing ? "Pause sequence" : "Play sequence");
playButton.setAttribute("title", playing ? "Pause sequence" : "Play sequence");
}
playButton.addEventListener("click", togglePlayback);
document.getElementById("previous").addEventListener("click", () => {
setPhase(currentPhase - 1);
});
document.getElementById("next").addEventListener("click", () => {
setPhase(currentPhase + 1);
});
legendButtons.forEach((button) => {
button.addEventListener("click", () => {
const markerIndex = Number(button.dataset.marker);
setPhase(markerIndex * 2);
});
});
// Direct camera controls, implemented without external controls modules.
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let dragging = false;
let dragMoved = 0;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragMoved = 0;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
dragMoved += Math.abs(dx) + Math.abs(dy);
yaw -= dx * 0.006;
pitch = THREE.MathUtils.clamp(pitch + dy * 0.0045, 0.26, 1.22);
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (dragMoved < 6) {
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;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveMarkers, false);
if (hits.length) {
const markerIndex = hits[0].object.userData.markerIndex;
const clickedReference = referenceMarkers.some((entry) =>
[entry.tab, entry.ribbon, entry.pageBlock].includes(hits[0].object)
);
setPhase(markerIndex * 2 + (clickedReference ? 0 : 1));
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
zoomBias = THREE.MathUtils.clamp(zoomBias + event.deltaY * 0.008, -4, 7);
},
{ passive: false }
);
const tempWorld = new THREE.Vector3();
const desiredTarget = new THREE.Vector3();
const desiredPosition = new THREE.Vector3();
const cameraOffset = new THREE.Vector3();
function updateMarkerAppearance(delta) {
const phase = phases[currentPhase];
const activeMarker = phase.marker;
referenceMarkers.forEach((entry, index) => {
const active = phase.kind === "reference" && index === activeMarker;
entry.material.emissiveIntensity = active ? 0.22 : 0;
const pulse = active ? 1 + Math.sin(globalTime * 6.2) * 0.055 : 1;
entry.tab.scale.setScalar(pulse);
});
noteMarkers.forEach((entry, index) => {
const active = phase.kind === "notes" && index === activeMarker;
entry.material.emissiveIntensity = active ? 0.22 : 0;
const pulse = active ? 1 + Math.sin(globalTime * 6.2) * 0.055 : 1;
entry.tab.scale.setScalar(pulse);
});
const activeSet = phase.kind === "reference" ? referenceMarkers : noteMarkers;
activeSet[activeMarker].tab.getWorldPosition(tempWorld);
tempWorld.y = 0.49;
const follow = 1 - Math.exp(-delta * 10);
locator.position.lerp(tempWorld, follow);
locatorMaterial.color.setHex(markerDefinitions[activeMarker].hex);
locator.scale.setScalar(1 + Math.sin(globalTime * 5.5) * 0.08);
locator.rotation.y += delta * 0.8;
}
function easeInOutCubic(value) {
return value < 0.5
? 4 * value * value * value
: 1 - Math.pow(-2 * value + 2, 3) / 2;
}
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
globalTime += delta;
if (playing) {
phaseElapsed += delta;
if (phaseElapsed >= phaseDuration) {
phaseElapsed -= phaseDuration;
setPhase(currentPhase + 1);
}
}
const phase = phases[currentPhase];
const stageTarget = phase.kind === "reference" ? referenceTarget : notesTarget;
const stageRadius = phase.kind === "reference" ? 9.6 : 8.9;
const intro = easeInOutCubic(THREE.MathUtils.clamp(globalTime / 1.65, 0, 1));
desiredTarget.copy(overviewTarget).lerp(stageTarget, intro);
const desiredRadius = THREE.MathUtils.lerp(15.8, stageRadius, intro) + zoomBias;
const radius = THREE.MathUtils.clamp(desiredRadius, 6.5, 22);
cameraOffset.set(
Math.sin(yaw) * Math.cos(pitch) * radius,
Math.sin(pitch) * radius,
Math.cos(yaw) * Math.cos(pitch) * radius
);
desiredPosition.copy(desiredTarget).add(cameraOffset);
const cameraEase = 1 - Math.exp(-delta * 3.7);
camera.position.lerp(desiredPosition, cameraEase);
cameraTarget.lerp(desiredTarget, 1 - Math.exp(-delta * 4.2));
camera.lookAt(cameraTarget);
updateMarkerAppearance(delta);
const phaseProgress = THREE.MathUtils.clamp(phaseElapsed / phaseDuration, 0, 1);
progress.style.transform = `scaleX(${phaseProgress})`;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
setPhase(0);
updateMarkerAppearance(0);
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
});
</script>
</body>
</html>
```