Prompt specification
Build or customize the Three.js 3D scene "Two manuscript stands and comparison markers" 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: Two manuscript stands and comparison markers
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/two-manuscript-stands-and-comparison-markers-x2325
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts manuscripts for translation in Abbasid Baghdad. Place two manuscript stands with differently patterned pages and matching reference markers. Use abstract glyphs to represent language differences without fabricating meaningful historical quotations. Voxel style.
Working Three.js Starter (two-manuscript-stands-and-comparison-markers-x2325):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Baghdad — Manuscript Translation</title>
<style>
:root {
--ink: #f5e5c4;
--muted: #cfb890;
--panel: rgba(35, 24, 20, 0.86);
--gold: #e6ad49;
--red: #d95d43;
--blue: #4c91a1;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c99769;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
background: var(--panel);
border: 1px solid rgba(230, 173, 73, 0.38);
box-shadow: 0 14px 42px rgba(28, 15, 10, 0.24);
backdrop-filter: blur(8px);
}
#title {
top: 22px;
left: 22px;
max-width: min(430px, calc(100vw - 44px));
padding: 17px 20px 16px;
border-left: 5px solid var(--gold);
}
#title .eyebrow {
margin-bottom: 7px;
color: var(--gold);
font: 700 11px/1.2 system-ui, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
}
#title h1 {
margin: 0;
font-size: clamp(24px, 3.5vw, 39px);
line-height: 0.98;
letter-spacing: -0.025em;
}
#title p {
margin: 10px 0 0;
color: var(--muted);
font: 13px/1.5 system-ui, sans-serif;
}
#legend {
right: 22px;
top: 22px;
width: min(310px, calc(100vw - 44px));
padding: 16px 18px;
}
#legend h2 {
margin: 0 0 12px;
color: var(--gold);
font: 700 11px/1.2 system-ui, sans-serif;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.legend-row {
display: grid;
grid-template-columns: 39px 1fr;
gap: 10px;
align-items: center;
margin: 10px 0;
color: #ead9b8;
font: 12px/1.35 system-ui, sans-serif;
}
.symbol {
display: flex;
align-items: center;
justify-content: center;
width: 39px;
height: 29px;
border: 1px solid rgba(245, 229, 196, 0.18);
background: rgba(255,255,255,0.035);
}
.angular {
width: 22px;
height: 14px;
background:
linear-gradient(var(--ink), var(--ink)) 2px 8px / 18px 2px no-repeat,
linear-gradient(var(--ink), var(--ink)) 7px 3px / 2px 8px no-repeat,
linear-gradient(var(--ink), var(--ink)) 16px 5px / 2px 6px no-repeat;
}
.stepped {
width: 20px;
height: 18px;
background:
linear-gradient(var(--blue), var(--blue)) 9px 2px / 2px 14px no-repeat,
linear-gradient(var(--blue), var(--blue)) 3px 4px / 5px 5px no-repeat,
linear-gradient(var(--blue), var(--blue)) 12px 11px / 5px 5px no-repeat;
}
.marker-symbol {
position: relative;
width: 15px;
height: 15px;
background: var(--red);
box-shadow: 0 0 0 3px rgba(217,93,67,0.18);
}
.marker-symbol::after {
content: "";
position: absolute;
inset: 5px;
background: #f7dda0;
}
#legend .note {
margin: 14px 0 0;
padding-top: 12px;
border-top: 1px solid rgba(245, 229, 196, 0.13);
color: var(--muted);
font: 11px/1.5 system-ui, sans-serif;
}
#controls {
left: 22px;
bottom: 22px;
padding: 11px 14px;
color: var(--muted);
font: 11px/1.4 system-ui, sans-serif;
}
#controls strong { color: var(--ink); }
#reset {
position: fixed;
z-index: 12;
right: 22px;
bottom: 22px;
padding: 10px 14px;
border: 1px solid rgba(230, 173, 73, 0.5);
border-radius: 0;
background: rgba(35, 24, 20, 0.9);
color: var(--ink);
font: 700 11px/1 system-ui, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
}
#reset:hover { border-color: var(--gold); color: var(--gold); }
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #3c281f;
color: var(--gold);
font: 12px/1 system-ui, sans-serif;
letter-spacing: 0.14em;
text-transform: uppercase;
transition: opacity 0.4s;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
#title {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
}
#legend {
top: auto;
right: 12px;
bottom: 58px;
width: 225px;
padding: 12px;
}
#controls {
left: 12px;
bottom: 12px;
}
#reset {
right: 12px;
bottom: 12px;
}
#legend .note { font-size: 10px; }
}
</style>
</head>
<body>
<div id="loading">Preparing the manuscript court…</div>
<section id="title" class="panel">
<div class="eyebrow">Abbasid Baghdad · Translation court</div>
<h1>Two Manuscripts,<br>Shared References</h1>
<p>A voxel interpretation of a scholarly courtyard and two abstract writing systems being compared.</p>
</section>
<aside id="legend" class="panel">
<h2>Visual Key</h2>
<div class="legend-row">
<div class="symbol"><div class="angular"></div></div>
<div>Manuscript A: angular horizontal strokes and ticks.</div>
</div>
<div class="legend-row">
<div class="symbol"><div class="stepped"></div></div>
<div>Manuscript B: vertical strokes and stepped points.</div>
</div>
<div class="legend-row">
<div class="symbol"><div class="marker-symbol"></div></div>
<div>Matching reference markers joined by gold threads.</div>
</div>
<p class="note">
All manuscript signs are invented abstract glyphs. They are not quotations,
transliterations, or claims about a historical script.
</p>
</aside>
<div id="controls" class="panel">
<strong>Drag</strong> to orbit · <strong>Scroll / pinch</strong> to zoom · <strong>Double-click</strong> to reset
</div>
<button id="reset" type="button">Reset view</button>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer and scene
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc99a70);
scene.fog = new THREE.Fog(0xc99a70, 18, 43);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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 voxel scene of two manuscripts in Abbasid Baghdad");
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xffdfae, 0x4d3940, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffd39b, 3.1);
sun.position.set(-9, 15, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -17;
sun.shadow.camera.right = 17;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 42;
sun.shadow.bias = -0.0005;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x8ab9c7, 0.65);
fill.position.set(10, 8, 4);
scene.add(fill);
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0,
flatShading: true,
...options
});
const M = {
ground: material(0x8d5d40),
ground2: material(0xa06b48),
ground3: material(0x966044),
brick: material(0xb87950),
brickLight: material(0xc58a5c),
brickDark: material(0x8f5039),
recessed: material(0x392a28),
wood: material(0x4d3025),
woodLight: material(0x75503a),
leather: material(0x5c332b),
parchment: material(0xefd39b),
parchment2: material(0xe5c78c),
inkA: material(0x402a26),
inkB: material(0x173b4d),
accentA: material(0x9d3f34),
accentB: material(0x367e82),
marker: material(0xd9573e, {
emissive: 0x5a160b,
emissiveIntensity: 0.35
}),
markerCore: material(0xf5d993, {
emissive: 0x805423,
emissiveIntensity: 0.2
}),
gold: material(0xe6ad49, {
metalness: 0.28,
roughness: 0.48
}),
water: material(0x438d92, {
roughness: 0.32,
metalness: 0.08,
transparent: true,
opacity: 0.86
}),
ripple: material(0x83b9b5, {
emissive: 0x1d4a4d,
emissiveIntensity: 0.15
}),
leaf: material(0x486943),
leafLight: material(0x617d4d),
trunk: material(0x795237),
cloud: material(0xe8c8a0),
sun: new THREE.MeshBasicMaterial({ color: 0xffd276 })
};
function box(parent, w, h, d, mat, x = 0, y = 0, z = 0, 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;
}
let seed = 230519;
function random() {
seed = (1664525 * seed + 1013904223) >>> 0;
return seed / 4294967296;
}
function seeded(seedValue) {
let n = seedValue >>> 0;
return () => {
n = (1664525 * n + 1013904223) >>> 0;
return n / 4294967296;
};
}
// ------------------------------------------------------------
// Voxel courtyard, canal, architecture, and vegetation
// ------------------------------------------------------------
const environment = new THREE.Group();
scene.add(environment);
box(environment, 34, 0.65, 25, M.ground, 0, -0.39, 0, false);
const tileMaterials = [M.ground2, M.ground3, M.brickDark];
for (let x = -13; x <= 13; x += 1.95) {
for (let z = -9; z <= 9; z += 1.95) {
const tile = box(
environment,
1.86,
0.13,
1.86,
tileMaterials[Math.floor(random() * tileMaterials.length)],
x + (random() - 0.5) * 0.08,
0.015,
z + (random() - 0.5) * 0.08,
false
);
tile.rotation.y = (random() - 0.5) * 0.025;
}
}
// Narrow water channel in the foreground.
box(environment, 29, 0.20, 1.80, M.water, 0, 0.12, 4.15, false);
box(environment, 29, 0.28, 0.42, M.brickLight, 0, 0.16, 3.03);
box(environment, 29, 0.28, 0.42, M.brickLight, 0, 0.16, 5.28);
for (let i = 0; i < 28; i++) {
const ripple = box(
environment,
0.42 + random() * 0.65,
0.035,
0.09,
M.ripple,
-13.2 + i,
0.245,
3.83 + random() * 0.65,
false
);
ripple.rotation.y = (random() - 0.5) * 0.08;
}
function building(x, z, w, h, d, tint = M.brick) {
const group = new THREE.Group();
group.position.set(x, 0, z);
environment.add(group);
box(group, w, h, d, tint, 0, h / 2, 0);
box(group, w + 0.18, 0.28, d + 0.18, M.brickLight, 0, 0.14, 0);
const front = d / 2 + 0.035;
for (let y = 0.65; y < h - 0.35; y += 0.72) {
box(group, w - 0.14, 0.035, 0.045, M.brickDark, 0, y, front, false);
}
const windowCount = Math.max(2, Math.floor(w / 2.4));
for (let i = 0; i < windowCount; i++) {
const wx = -w / 2 + (w / (windowCount + 1)) * (i + 1);
const wy = h * 0.61;
box(group, 0.76, 1.12, 0.07, M.recessed, wx, wy, front + 0.035, false);
box(group, 0.91, 0.13, 0.16, M.woodLight, wx, wy + 0.62, front + 0.08);
box(group, 0.05, 1.05, 0.06, M.wood, wx, wy, front + 0.08, false);
box(group, 0.72, 0.05, 0.06, M.wood, wx, wy - 0.12, front + 0.08, false);
}
const crenelCount = Math.floor(w / 0.9);
for (let i = 0; i < crenelCount; i++) {
const cx = -w / 2 + 0.45 + i * ((w - 0.9) / Math.max(1, crenelCount - 1));
box(group, 0.50, 0.38, d + 0.12, tint, cx, h + 0.19, 0);
}
return group;
}
const mainBuilding = building(0, -10.2, 15.5, 5.4, 3.2, M.brick);
building(-10.0, -5.8, 5.2, 4.0, 5.8, M.brickDark);
building(10.0, -6.2, 5.4, 4.5, 5.2, M.brick);
building(-6.9, -8.0, 4.5, 3.7, 4.0, M.brickLight);
building(7.4, -8.5, 4.7, 4.3, 4.4, M.brickDark);
// Stepped, stylized arched recesses on the main facade.
for (const ax of [-5.2, -1.75, 1.75, 5.2]) {
const facadeZ = 1.64;
box(mainBuilding, 1.35, 1.35, 0.07, M.recessed, ax, 0.79, facadeZ, false);
box(mainBuilding, 0.93, 0.30, 0.07, M.recessed, ax, 1.46, facadeZ, false);
box(mainBuilding, 0.48, 0.25, 0.07, M.recessed, ax, 1.69, facadeZ, false);
box(mainBuilding, 0.18, 0.18, 0.07, M.recessed, ax, 1.87, facadeZ, false);
box(mainBuilding, 0.26, 1.85, 0.18, M.brickLight, ax - 0.79, 0.95, facadeZ + 0.03);
box(mainBuilding, 0.26, 1.85, 0.18, M.brickLight, ax + 0.79, 0.95, facadeZ + 0.03);
box(mainBuilding, 1.84, 0.22, 0.18, M.brickLight, ax, 1.87, facadeZ + 0.03);
}
// Low courtyard walls.
for (const side of [-1, 1]) {
for (let i = 0; i < 8; i++) {
box(
environment,
1.05,
0.90,
0.62,
i % 2 ? M.brick : M.brickLight,
side * 7.55,
0.45,
-2.8 + i * 1.08
);
box(
environment,
0.46,
0.25,
0.68,
M.brickDark,
side * 7.55,
1.02,
-2.8 + i * 1.08
);
}
}
function palm(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.08, z);
group.scale.setScalar(scale);
environment.add(group);
let trunkTop = 0;
for (let i = 0; i < 8; i++) {
const block = box(
group,
0.34,
0.36,
0.34,
i % 2 ? M.trunk : M.brickDark,
(i % 2) * 0.035,
0.20 + i * 0.34,
0
);
block.rotation.y = i * 0.08;
trunkTop = 0.38 + i * 0.34;
}
box(group, 0.55, 0.30, 0.55, M.trunk, 0, trunkTop + 0.12, 0);
for (let a = 0; a < 6; a++) {
const frond = new THREE.Group();
frond.position.y = trunkTop + 0.20;
frond.rotation.y = a * Math.PI / 3;
group.add(frond);
for (let i = 0; i < 5; i++) {
const sign = i < 3 ? 1 : -1;
const segment = i < 3 ? i + 1 : 5 - i;
const leaf = box(
frond,
0.48,
0.12,
0.25,
i % 2 ? M.leaf : M.leafLight,
sign * (0.30 + i * 0.34),
-i * 0.13,
0
);
leaf.rotation.z = sign * (0.08 + i * 0.06);
}
}
}
palm(-6.1, 1.25, 1.15);
palm(6.3, 0.7, 1.0);
palm(-9.2, -3.7, 0.88);
palm(9.1, -4.2, 0.92);
// Blocky sun and clouds.
box(environment, 1.8, 1.8, 0.35, M.sun, -9.8, 10.8, -17, false);
function cloud(x, y, z, scale) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
environment.add(group);
box(group, 2.2, 0.45, 0.55, M.cloud, 0, 0, 0, false);
box(group, 1.05, 0.75, 0.55, M.cloud, -0.85, 0.18, 0, false);
box(group, 1.35, 0.95, 0.55, M.cloud, 0.85, 0.25, 0, false);
}
cloud(-6, 10.4, -16, 1.2);
cloud(7, 12, -18, 1.45);
cloud(1, 8.8, -15, 0.8);
// ------------------------------------------------------------
// Abstract manuscript glyphs
// ------------------------------------------------------------
function abstractGlyph(parent, x, y, type, glyphSeed) {
const rnd = seeded(glyphSeed);
const z = 0.267;
if (type === 0) {
// Script A: short horizontal strokes, vertical ticks, offsets.
const width = 0.16 + rnd() * 0.08;
const tickX = -width * 0.32 + rnd() * width * 0.62;
box(parent, width, 0.035, 0.026, M.inkA, x, y - 0.025, z, false);
box(parent, 0.035, 0.105, 0.026, M.inkA, x + tickX, y + 0.020, z, false);
if (rnd() > 0.38) {
box(
parent,
0.08 + rnd() * 0.07,
0.03,
0.026,
M.inkA,
x + (rnd() - 0.5) * 0.12,
y + 0.075,
z,
false
);
}
} else {
// Script B: vertical strokes, offset blocks, and stepped points.
box(parent, 0.035, 0.17, 0.026, M.inkB, x, y, z, false);
box(
parent,
0.065,
0.06,
0.028,
M.inkB,
x + (rnd() - 0.5) * 0.10,
y + 0.065,
z,
false
);
box(
parent,
0.055,
0.055,
0.028,
M.inkB,
x - (rnd() - 0.5) * 0.09,
y - 0.060,
z,
false
);
if (rnd() > 0.5) {
box(
parent,
0.075,
0.035,
0.027,
M.inkB,
x + 0.045,
y + 0.015,
z,
false
);
}
}
}
function referenceMarker(parent, x, y) {
const marker = new THREE.Group();
marker.position.set(x, y, 0.31);
parent.add(marker);
box(marker, 0.15, 0.15, 0.075, M.marker, 0, 0, 0, false);
box(marker, 0.055, 0.055, 0.085, M.markerCore, 0, 0, 0, false);
box(marker, 0.035, 0.09, 0.055, M.marker, 0, -0.11, -0.005, false);
return marker;
}
function manuscriptStand(x, scriptType) {
const stand = new THREE.Group();
stand.position.set(x, 0.10, -0.25);
scene.add(stand);
// Four legs, feet, and crossbars.
for (const lx of [-1.18, 1.18]) {
for (const lz of [-0.50, 0.50]) {
box(stand, 0.18, 2.20, 0.18, M.wood, lx, 1.10, lz);
box(stand, 0.34, 0.16, 0.38, M.woodLight, lx, 0.08, lz);
}
}
box(stand, 2.48, 0.16, 0.16, M.wood, 0, 0.68, 0.49);
box(stand, 2.48, 0.16, 0.16, M.wood, 0, 0.68, -0.49);
box(stand, 0.16, 0.16, 1.12, M.wood, -1.18, 1.73, 0);
box(stand, 0.16, 0.16, 1.12, M.wood, 1.18, 1.73, 0);
const board = new THREE.Group();
board.position.y = 2.63;
board.rotation.x = -0.36;
stand.add(board);
// Wooden frame, leather backing, and an open two-page manuscript.
box(board, 3.22, 2.20, 0.18, M.wood, 0, 0, 0);
box(board, 3.04, 2.02, 0.075, M.leather, 0, 0, 0.12);
box(board, 3.20, 0.18, 0.23, M.woodLight, 0, 1.08, 0.025);
box(board, 3.20, 0.13, 0.23, M.woodLight, 0, -1.08, 0.025);
const pageCenters = [-0.735, 0.735];
for (let p = 0; p < pageCenters.length; p++) {
const px = pageCenters[p];
const pageMat = p === 0 ? M.parchment : M.parchment2;
box(board, 1.40, 1.82, 0.075, pageMat, px, 0, 0.19);
// Different ornamental page structures reinforce the two visual languages.
if (scriptType === 0) {
box(board, 1.13, 0.035, 0.028, M.accentA, px, 0.77, 0.239, false);
box(board, 1.13, 0.035, 0.028, M.accentA, px, -0.77, 0.239, false);
box(board, 0.035, 1.42, 0.028, M.accentA, px - 0.61, 0, 0.239, false);
} else {
box(board, 0.035, 1.42, 0.028, M.accentB, px - 0.61, 0, 0.239, false);
box(board, 0.035, 1.42, 0.028, M.accentB, px + 0.61, 0, 0.239, false);
for (const sy of [-0.76, 0.76]) {
box(board, 0.10, 0.10, 0.028, M.accentB, px - 0.60, sy, 0.24, false);
box(board, 0.10, 0.10, 0.028, M.accentB, px + 0.60, sy, 0.24, false);
}
}
const rowY = [0.57, 0.285, 0, -0.285, -0.57];
for (let row = 0; row < rowY.length; row++) {
for (let col = 0; col < 2; col++) {
const gx = px + (col === 0 ? -0.30 : 0.30);
const gy = rowY[row] + (scriptType === 0 ? (random() - 0.5) * 0.025 : 0);
const glyphSeed = Math.floor(random() * 1000000) + p * 91 + row * 17 + col * 7;
abstractGlyph(board, gx, gy, scriptType, glyphSeed);
}
}
}
box(board, 0.09, 1.82, 0.11, M.woodLight, 0, 0, 0.24);
// Identical markers placed on the facing inner margins.
const markerSide = x < 0 ? 1 : -1;
const markerX = markerSide * 1.29;
const markerY = [0.53, -0.17, -0.68];
return {
stand,
board,
markers: markerY.map(y => referenceMarker(board, markerX, y))
};
}
const manuscriptA = manuscriptStand(-2.45, 0);
const manuscriptB = manuscriptStand(2.45, 1);
// ------------------------------------------------------------
// Central translation table
// ------------------------------------------------------------
const table = new THREE.Group();
table.position.set(0, 0, -0.10);
scene.add(table);
box(table, 1.55, 0.18, 1.05, M.woodLight, 0, 1.02, 0);
for (const x of [-0.60, 0.60]) {
for (const z of [-0.34, 0.34]) {
box(table, 0.14, 1.0, 0.14, M.wood, x, 0.48, z);
}
}
const tablet = box(table, 0.80, 0.09, 0.58, M.parchment, -0.18, 1.16, 0.04);
tablet.rotation.y = -0.14;
box(table, 0.18, 0.18, 0.18, M.gold, 0.48, 1.20, 0.13);
box(table, 0.13, 0.04, 0.13, M.inkA, 0.48, 1.30, 0.13, false);
const stylus = box(table, 0.60, 0.035, 0.035, M.wood, 0.30, 1.17, -0.19);
stylus.rotation.y = 0.36;
// ------------------------------------------------------------
// Correspondence threads between identical reference markers
// ------------------------------------------------------------
scene.updateMatrixWorld(true);
const correspondenceMaterial = new THREE.LineDashedMaterial({
color: 0xe6ad49,
dashSize: 0.12,
gapSize: 0.085,
transparent: true,
opacity: 0.72,
depthTest: true
});
for (let i = 0; i < manuscriptA.markers.length; i++) {
const a = new THREE.Vector3();
const b = new THREE.Vector3();
manuscriptA.markers[i].getWorldPosition(a);
manuscriptB.markers[i].getWorldPosition(b);
const midpoint = a.clone().add(b).multiplyScalar(0.5);
midpoint.y += 0.20 + i * 0.055;
midpoint.z += 0.08;
const curve = new THREE.CatmullRomCurve3([a, midpoint, b]);
const geometry = new THREE.BufferGeometry().setFromPoints(curve.getPoints(28));
const thread = new THREE.Line(geometry, correspondenceMaterial);
thread.computeLineDistances();
scene.add(thread);
}
// ------------------------------------------------------------
// Direct camera controls: orbit, wheel/pinch zoom, double-click reset
// ------------------------------------------------------------
const controls = {
theta: 0.30,
phi: 1.18,
radius: 13.8,
target: new THREE.Vector3(0, 2.15, -0.25)
};
const initialView = {
theta: controls.theta,
phi: controls.phi,
radius: controls.radius
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetView() {
controls.theta = initialView.theta;
controls.phi = initialView.phi;
controls.radius = initialView.radius;
updateCamera();
}
const pointers = new Map();
let pinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
pinchDistance = pointerDistance();
}
});
renderer.domElement.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const distance = pointerDistance();
if (pinchDistance > 0 && distance > 0) {
controls.radius *= pinchDistance / distance;
controls.radius = THREE.MathUtils.clamp(controls.radius, 7.2, 24);
updateCamera();
}
pinchDistance = distance;
} else if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.005, 0.48, 1.43);
updateCamera();
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
pinchDistance = pointers.size === 2 ? pointerDistance() : 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("lostpointercapture", releasePointer);
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
const factor = Math.exp(event.deltaY * 0.001);
controls.radius = THREE.MathUtils.clamp(controls.radius * factor, 7.2, 24);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
document.getElementById("reset").addEventListener("click", resetView);
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
// ------------------------------------------------------------
// Animation
// ------------------------------------------------------------
updateCamera();
const clock = new THREE.Clock();
let firstFrame = true;
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
for (let i = 0; i < manuscriptA.markers.length; i++) {
const pulse = 1 + 0.045 * (0.5 + 0.5 * Math.sin(elapsed * 2.1 + i * 1.3));
manuscriptA.markers[i].scale.setScalar(pulse);
manuscriptB.markers[i].scale.setScalar(pulse);
}
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
document.getElementById("loading").classList.add("hidden");
}
});
</script>
</body>
</html>
```