Prompt specification
Build or customize the Three.js 3D scene "Calibrated ruler beside an unmarked rod" 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: Calibrated ruler beside an unmarked rod
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/calibrated-ruler-beside-an-unmarked-rod-x2333
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts early modern scientific instruments and calibration. Place a divided measuring rule next to an equal-length unmarked rod. Highlight how a shared unit allows repeated lengths to be compared and recorded. Stylized solid forms.
Working Three.js Starter (calibrated-ruler-beside-an-unmarked-rod-x2333):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Early Modern Scientific Instruments and Calibration</title>
<style>
:root {
color-scheme: light;
--ink: #272820;
--paper: rgba(244, 234, 208, 0.94);
--teal: #197c78;
--brass: #b6812d;
--line: rgba(52, 45, 33, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8c7aa;
font-family: Georgia, "Times New Roman", serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(70, 53, 34, 0.28);
box-shadow:
0 18px 45px rgba(62, 42, 22, 0.16),
inset 0 0 0 4px rgba(255, 255, 255, 0.25);
backdrop-filter: blur(8px);
}
#title-panel {
top: 22px;
left: 22px;
width: min(440px, calc(100vw - 44px));
padding: 20px 22px 18px;
border-radius: 3px 18px 3px 18px;
}
.eyebrow {
margin: 0 0 7px;
color: var(--teal);
font: 700 11px/1.2 Arial, sans-serif;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 38px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
#title-panel p {
margin: 12px 0 0;
max-width: 390px;
color: rgba(39, 40, 32, 0.76);
font: 14px/1.55 Arial, sans-serif;
}
#info-panel {
right: 22px;
bottom: 22px;
width: min(320px, calc(100vw - 44px));
min-height: 126px;
padding: 17px 18px;
border-radius: 18px 3px 18px 3px;
}
#info-title {
margin: 0 0 7px;
font-size: 19px;
font-weight: 600;
}
#info-text {
margin: 0;
color: rgba(39, 40, 32, 0.75);
font: 13px/1.5 Arial, sans-serif;
}
#controls {
position: fixed;
z-index: 20;
left: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
button,
.toggle {
appearance: none;
border: 1px solid rgba(61, 48, 32, 0.34);
border-radius: 999px;
background: rgba(244, 234, 208, 0.94);
color: var(--ink);
padding: 10px 14px;
font: 600 12px/1 Arial, sans-serif;
cursor: pointer;
box-shadow: 0 8px 20px rgba(65, 43, 22, 0.13);
}
button:hover,
.toggle:hover {
background: #fff8e8;
}
button:focus-visible,
.toggle:focus-within {
outline: 2px solid var(--teal);
outline-offset: 2px;
}
.toggle {
display: inline-flex;
align-items: center;
gap: 8px;
user-select: none;
}
.toggle input {
accent-color: var(--teal);
}
#hint {
position: fixed;
z-index: 8;
top: 20px;
right: 22px;
padding: 9px 12px;
border-radius: 999px;
background: rgba(244, 234, 208, 0.78);
color: rgba(39, 40, 32, 0.68);
font: 11px/1 Arial, sans-serif;
letter-spacing: 0.05em;
pointer-events: none;
}
@media (max-width: 700px) {
#title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 15px 16px;
}
#title-panel p {
display: none;
}
#hint {
display: none;
}
#controls {
left: 12px;
bottom: 12px;
}
#info-panel {
right: 12px;
bottom: 68px;
width: min(280px, calc(100vw - 24px));
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive scene of early modern scientific instruments"></main>
<section id="title-panel" class="panel">
<p class="eyebrow">Measurement · Calibration · Record</p>
<h1>One unit, repeatable lengths</h1>
<p>
A divided rule and an unmarked rod share the same span. Repeated copies of
the highlighted unit allow the rod to be compared, copied, and recorded
as <strong>12 units</strong>.
</p>
</section>
<div id="hint">Drag to orbit · Scroll to zoom · Select an instrument</div>
<div id="controls">
<button id="reset" type="button">Reset view</button>
<label class="toggle">
<input id="unit-toggle" type="checkbox" checked>
Show repeated units
</label>
</div>
<aside id="info-panel" class="panel" aria-live="polite">
<h2 id="info-title">Shared-unit comparison</h2>
<p id="info-text">
Select the divided rule, unmarked rod, or calibration standard to
inspect how the common unit is used.
</p>
</aside>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, camera, and manually implemented camera controls
// -------------------------------------------------------------------------
const mount = document.querySelector("#scene");
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.12;
renderer.domElement.setAttribute("aria-label", "Three-dimensional scientific instrument scene");
mount.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d8c7aa");
scene.fog = new THREE.Fog("#d8c7aa", 24, 42);
const camera = new THREE.OrthographicCamera(-10, 10, 8, -8, 0.1, 100);
const controls = {
target: new THREE.Vector3(0.4, 0.35, 0),
radius: 18,
theta: 0.57,
phi: 0.91,
targetTheta: 0.57,
targetPhi: 0.91,
zoom: 1,
targetZoom: 1
};
function updateCamera() {
const { radius, theta, phi, target } = controls;
camera.position.set(
target.x + radius * Math.sin(theta) * Math.cos(phi),
target.y + radius * Math.sin(phi),
target.z + radius * Math.cos(theta) * Math.cos(phi)
);
camera.lookAt(target);
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const halfHeight = 7.5;
camera.left = -halfHeight * aspect;
camera.right = halfHeight * aspect;
camera.top = halfHeight;
camera.bottom = -halfHeight;
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
let dragging = false;
let moved = 0;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
moved = 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;
moved += Math.abs(dx) + Math.abs(dy);
controls.targetTheta -= dx * 0.006;
controls.targetPhi = THREE.MathUtils.clamp(
controls.targetPhi - dy * 0.005,
0.28,
1.28
);
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (moved < 6) selectAt(event.clientX, event.clientY);
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.targetZoom = THREE.MathUtils.clamp(
controls.targetZoom * Math.exp(-event.deltaY * 0.001),
0.65,
2.15
);
},
{ passive: false }
);
document.querySelector("#reset").addEventListener("click", () => {
controls.targetTheta = 0.57;
controls.targetPhi = 0.91;
controls.targetZoom = 1;
controls.target.set(0.4, 0.35, 0);
});
// -------------------------------------------------------------------------
// Lighting and material palette
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight("#fff2d3", "#665042", 2.05));
const key = new THREE.DirectionalLight("#fff0cf", 3.2);
key.position.set(-7, 12, 8);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 11;
key.shadow.camera.bottom = -11;
key.shadow.camera.near = 1;
key.shadow.camera.far = 35;
key.shadow.normalBias = 0.035;
scene.add(key);
const fill = new THREE.DirectionalLight("#9fc9c7", 1.05);
fill.position.set(9, 7, -8);
scene.add(fill);
const materials = {
table: new THREE.MeshStandardMaterial({
color: "#6d4933",
roughness: 0.78,
metalness: 0.02
}),
tableEdge: new THREE.MeshStandardMaterial({
color: "#493025",
roughness: 0.82
}),
ruler: new THREE.MeshStandardMaterial({
color: "#d1ad68",
roughness: 0.48,
metalness: 0.08
}),
rulerEdge: new THREE.MeshStandardMaterial({
color: "#85622f",
roughness: 0.52
}),
rod: new THREE.MeshStandardMaterial({
color: "#4b332c",
roughness: 0.3,
metalness: 0.06
}),
brass: new THREE.MeshStandardMaterial({
color: "#b88735",
roughness: 0.27,
metalness: 0.78
}),
brassDark: new THREE.MeshStandardMaterial({
color: "#75501e",
roughness: 0.34,
metalness: 0.72
}),
steel: new THREE.MeshStandardMaterial({
color: "#9ca19b",
roughness: 0.28,
metalness: 0.72
}),
teal: new THREE.MeshStandardMaterial({
color: "#168985",
roughness: 0.36,
metalness: 0.12,
emissive: "#0b4d4a",
emissiveIntensity: 0.22
}),
tealLight: new THREE.MeshBasicMaterial({
color: "#42c0b5",
transparent: true,
opacity: 0.72,
depthWrite: false
}),
ink: new THREE.MeshStandardMaterial({
color: "#252923",
roughness: 0.68
}),
paper: new THREE.MeshStandardMaterial({
color: "#e7d4ad",
roughness: 0.92
}),
darkWood: new THREE.MeshStandardMaterial({
color: "#3e2b24",
roughness: 0.7
})
};
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function addBox(parent, width, height, depth, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
material,
x = 0,
y = 0,
z = 0,
segments = 24
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(parent, a, b, radius, material, segments = 16) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const mesh = addCylinder(
parent,
radius,
radius,
direction.length(),
material,
midpoint.x,
midpoint.y,
midpoint.z,
segments
);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function addSphere(parent, radius, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, 24, 16),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addTorus(parent, radius, tube, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.TorusGeometry(radius, tube, 12, 64),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + width, y, x + width, y + height, r);
ctx.arcTo(x + width, y + height, x, y + height, r);
ctx.arcTo(x, y + height, x, y, r);
ctx.arcTo(x, y, x + width, y, r);
ctx.closePath();
}
function makeTextTexture(
lines,
{
width = 1024,
height = 256,
foreground = "#292b25",
background = "rgba(244,234,208,0.94)",
border = "rgba(77,59,37,0.24)",
align = "center",
font = "500 64px Georgia",
subtitleFont = "500 35px Arial"
} = {}
) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
if (background) {
ctx.fillStyle = background;
roundedRect(ctx, 4, 4, width - 8, height - 8, 22);
ctx.fill();
if (border) {
ctx.strokeStyle = border;
ctx.lineWidth = 4;
ctx.stroke();
}
}
const list = Array.isArray(lines) ? lines : [lines];
ctx.textAlign = align;
ctx.textBaseline = "middle";
const x = align === "left" ? 58 : width / 2;
const totalHeight = list.length * 78;
let y = height / 2 - totalHeight / 2 + 39;
list.forEach((line, index) => {
ctx.fillStyle = index === 0 ? foreground : "#4d5047";
ctx.font = index === 0 ? font : subtitleFont;
ctx.fillText(line, x, y, width - 100);
y += 78;
});
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function makeTextSprite(
text,
width,
height,
{
foreground = "#292b25",
background = "rgba(244,234,208,0.93)",
font = "600 64px Georgia",
subtitleFont = "500 35px Arial"
} = {}
) {
const texture = makeTextTexture(text, {
foreground,
background,
font,
subtitleFont
});
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, height, 1);
sprite.renderOrder = 10;
return sprite;
}
function labelSprite(parent, lines, x, y, z, width, height, options = {}) {
const sprite = makeTextSprite(lines, width, height, options);
sprite.position.set(x, y, z);
parent.add(sprite);
return sprite;
}
function dashedLine(points, color = "#268f89", dash = 0.12, gap = 0.09) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map((point) => new THREE.Vector3(...point))
);
const material = new THREE.LineDashedMaterial({
color,
dashSize: dash,
gapSize: gap,
transparent: true,
opacity: 0.8
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
scene.add(line);
return line;
}
// -------------------------------------------------------------------------
// Workbench
// -------------------------------------------------------------------------
const bench = new THREE.Group();
scene.add(bench);
addBox(
bench,
18.6,
0.38,
10.8,
materials.tableEdge,
0,
-0.23,
0
);
addBox(
bench,
18.4,
0.12,
10.6,
materials.table,
0,
0.02,
0
);
// Subtle board seams.
for (let z = -4.2; z <= 4.2; z += 1.4) {
const seam = addBox(
bench,
18.1,
0.006,
0.014,
materials.tableEdge,
0,
0.084,
z
);
seam.castShadow = false;
seam.receiveShadow = false;
}
// -------------------------------------------------------------------------
// Main comparison: divided measuring rule and equal-length unmarked rod
// -------------------------------------------------------------------------
const ruleLength = 5.6;
const unitLength = ruleLength / 12;
const startX = -5.1;
const endX = startX + ruleLength;
const ruleZ = -0.75;
const rodZ = 0.65;
const ruleGroup = new THREE.Group();
ruleGroup.userData.info = {
title: "Divided measuring rule",
text:
"Twelve equal intervals establish a reproducible unit. The first interval is highlighted as one standard unit, making every later division directly traceable to it."
};
scene.add(ruleGroup);
addBox(
ruleGroup,
ruleLength,
0.2,
1.05,
materials.ruler,
(startX + endX) / 2,
0.18,
ruleZ
);
addBox(
ruleGroup,
ruleLength + 0.08,
0.08,
0.12,
materials.rulerEdge,
(startX + endX) / 2,
0.12,
ruleZ - 0.48
);
// The first unit is an inset teal panel beneath the graduations.
addBox(
ruleGroup,
unitLength - 0.035,
0.035,
0.72,
materials.teal,
startX + unitLength / 2,
0.296,
ruleZ + 0.12
);
// Physical graduations: major, medium, and minor divisions.
for (let i = 0; i <= 12; i++) {
const x = startX + i * unitLength;
const isMajor = i % 4 === 0;
const isMedium = i % 2 === 0;
const length = isMajor ? 0.43 : isMedium ? 0.29 : 0.17;
addBox(
ruleGroup,
0.025,
0.035,
length,
materials.ink,
x,
0.315,
ruleZ - 0.37
);
if (i % 2 === 0 || i === 1) {
const number = makeTextSprite(
String(i),
0.24,
0.19,
{
foreground: "#34352d",
background: "rgba(0,0,0,0)",
font: "700 56px Arial"
}
);
number.position.set(x, 0.42, ruleZ + 0.24);
ruleGroup.add(number);
}
}
const ruleLabel = labelSprite(
ruleGroup,
["DIVIDED RULE", "12 equal divisions"],
(startX + endX) / 2,
0.95,
ruleZ - 0.35,
2.45,
0.58,
{
foreground: "#27322d",
background: "rgba(239,225,195,0.94)"
}
);
ruleLabel.renderOrder = 11;
const rodGroup = new THREE.Group();
rodGroup.userData.info = {
title: "Unmarked rod",
text:
"The rod carries no regular divisions. Its length is nevertheless known by laying off the rule's unit repeatedly, then recording the result as 12 units."
};
scene.add(rodGroup);
const rod = addCylinder(
rodGroup,
0.17,
0.17,
ruleLength,
materials.rod,
(startX + endX) / 2,
0.37,
rodZ,
48
);
rod.rotation.z = Math.PI / 2;
// Restrained collars emphasize that the rod itself remains ungraduated.
for (const x of [startX + 0.08, endX - 0.08]) {
const collar = addCylinder(
rodGroup,
0.175,
0.175,
0.08,
materials.brassDark,
x,
0.37,
rodZ,
32
);
collar.rotation.z = Math.PI / 2;
}
const rodLabel = labelSprite(
rodGroup,
["UNMARKED ROD", "same total span as the rule"],
(startX + endX) / 2,
0.91,
rodZ + 0.12,
3.1,
0.58,
{
foreground: "#28302c",
background: "rgba(239,225,195,0.94)"
}
);
rodLabel.renderOrder = 11;
// Endpoint alignment guides.
dashedLine(
[
[startX, 0.59, ruleZ + 0.54],
[startX, 0.59, rodZ - 0.2]
],
"#2b928c"
);
dashedLine(
[
[endX, 0.59, ruleZ + 0.54],
[endX, 0.59, rodZ - 0.2]
],
"#2b928c"
);
// -------------------------------------------------------------------------
// Shared-unit annotation: one unit becomes a repeatable digital overlay
// -------------------------------------------------------------------------
const unitOverlay = new THREE.Group();
unitOverlay.userData.info = {
title: "Shared unit overlay",
text:
"The teal overlay is not a mark on the rod. It is a visual copy of the rule's unit, repeated twelve times. The repeated module makes an abstract length concrete and comparable."
};
scene.add(unitOverlay);
for (let i = 0; i < 12; i++) {
const x = startX + (i + 0.5) * unitLength;
const segment = addBox(
unitOverlay,
unitLength * 0.9,
0.025,
0.055,
i === 0 ? materials.teal : materials.tealLight,
x,
0.96,
rodZ
);
segment.castShadow = false;
segment.receiveShadow = false;
if (i < 11) {
const separator = addBox(
unitOverlay,
0.018,
0.13,
0.018,
materials.teal,
startX + (i + 1) * unitLength,
0.96,
rodZ
);
separator.castShadow = false;
}
}
// Bracket over the first interval on the rule.
const unitBracket = new THREE.Group();
unitOverlay.add(unitBracket);
const bracketX = startX + unitLength / 2;
addBox(
unitBracket,
unitLength,
0.045,
0.045,
materials.teal,
bracketX,
0.63,
ruleZ
);
for (const x of [startX, startX + unitLength]) {
addBox(
unitBracket,
0.045,
0.38,
0.045,
materials.teal,
x,
0.43,
ruleZ
);
}
const unitLabel = labelSprite(
unitOverlay,
["1 UNIT", "shared reference"],
bracketX,
0.95,
ruleZ,
1.25,
0.45,
{
foreground: "#116a66",
background: "rgba(226,244,232,0.95)",
font: "700 57px Arial",
subtitleFont: "500 31px Arial"
}
);
unitLabel.renderOrder = 12;
const repeatedLabel = labelSprite(
unitOverlay,
["12 × UNIT", "rod = 12 u"],
endX + 0.2,
1.2,
rodZ,
1.55,
0.52,
{
foreground: "#116a66",
background: "rgba(226,244,232,0.95)",
font: "700 55px Arial",
subtitleFont: "600 31px Arial"
}
);
repeatedLabel.renderOrder = 12;
// -------------------------------------------------------------------------
// Calibration standard: a physical one-unit bar on a small stand
// -------------------------------------------------------------------------
const standardGroup = new THREE.Group();
standardGroup.userData.info = {
title: "Calibration standard",
text:
"A preserved one-unit bar anchors the scale. Instruments are calibrated against this reference before the full rod is measured."
};
scene.add(standardGroup);
addBox(
standardGroup,
1.42,
0.24,
0.78,
materials.darkWood,
2.75,
0.19,
-2.75
);
addBox(
standardGroup,
1.16,
0.11,
0.16,
materials.brassDark,
2.75,
0.36,
-2.75
);
// The standard is exactly the same module as one rule interval.
addBox(
standardGroup,
unitLength,
0.12,
0.17,
materials.brass,
2.75,
0.61,
-2.75
);
for (const x of [2.75 - unitLength / 2, 2.75 + unitLength / 2]) {
addBox(
standardGroup,
0.035,
0.16,
0.2,
materials.steel,
x,
0.61,
-2.75
);
}
labelSprite(
standardGroup,
["UNIT STANDARD", "1 u"],
2.75,
1.08,
-2.75,
1.55,
0.52,
{
foreground: "#3d321f",
background: "rgba(240,223,183,0.95)",
font: "700 53px Arial",
subtitleFont: "600 32px Arial"
}
);
// -------------------------------------------------------------------------
// Dividers / compass
// -------------------------------------------------------------------------
const dividersGroup = new THREE.Group();
dividersGroup.userData.info = {
title: "Dividing compass",
text:
"The brass dividers transfer the shared unit from the rule to another surface. Its points can mark repeated intervals without drawing a full graduated scale."
};
dividersGroup.position.set(-1.35, 0.11, 3.15);
dividersGroup.rotation.y = -0.18;
scene.add(dividersGroup);
cylinderBetween(
dividersGroup,
[0, 0.22, 0],
[-0.92, 0.08, 1.25],
0.047,
materials.brass
);
cylinderBetween(
dividersGroup,
[0, 0.22, 0],
[0.92, 0.08, 1.25],
0.047,
materials.brass
);
cylinderBetween(
dividersGroup,
[0, 0.22, 0],
[-0.22, 0.22, -0.82],
0.07,
materials.darkWood
);
cylinderBetween(
dividersGroup,
[0, 0.22, 0],
[0.22, 0.22, -0.82],
0.07,
materials.darkWood
);
addSphere(dividersGroup, 0.12, materials.brassDark, 0, 0.22, 0);
const hinge = addTorus(
dividersGroup,
0.14,
0.025,
materials.steel,
0,
0.22,
0
);
hinge.rotation.x = Math.PI / 2;
labelSprite(
dividersGroup,
["DIVIDING COMPASS"],
0,
0.76,
-0.2,
1.75,
0.34,
{
foreground: "#332e25",
background: "rgba(239,225,195,0.93)",
font: "700 48px Arial"
}
);
// -------------------------------------------------------------------------
// Sliding caliper
// -------------------------------------------------------------------------
const caliperGroup = new THREE.Group();
caliperGroup.userData.info = {
title: "Sliding caliper",
text:
"A sliding jaw compares an external span against a fixed scale. Like the dividers, it relies on calibrated graduations and a common standard."
};
caliperGroup.position.set(-5.25, 0.18, 3.05);
caliperGroup.rotation.y = 0.08;
scene.add(caliperGroup);
addBox(caliperGroup, 3.7, 0.12, 0.28, materials.steel, 0, 0, 0);
addBox(caliperGroup, 0.16, 0.6, 1.08, materials.brass, -1.7, 0.18, -0.36);
addBox(caliperGroup, 0.2, 0.52, 0.95, materials.brassDark, 0.35, 0.14, -0.3);
addBox(caliperGroup, 0.12, 0.62, 1.02, materials.brass, 0.35, 0.16, -0.31);
for (let i = 0; i < 18; i++) {
addBox(
caliperGroup,
0.018,
0.025,
i % 5 === 0 ? 0.17 : 0.1,
materials.ink,
-1.5 + i * 0.18,
0.075,
0.03
);
}
labelSprite(
caliperGroup,
["SLIDING CALIPER"],
-0.1,
0.72,
0,
1.85,
0.34,
{
foreground: "#332e25",
background: "rgba(239,225,195,0.93)",
font: "700 48px Arial"
}
);
// -------------------------------------------------------------------------
// Astrolabe
// -------------------------------------------------------------------------
const astrolabeGroup = new THREE.Group();
astrolabeGroup.userData.info = {
title: "Astrolabe",
text:
"The astrolabe is a scientific instrument for relating angular and celestial observations to calibrated scales. Its circular plate echoes the shared idea of a measured, repeatable division."
};
astrolabeGroup.position.set(6.55, 1.55, -2.35);
scene.add(astrolabeGroup);
const disk = addCylinder(
astrolabeGroup,
1.05,
1.05,
0.14,
materials.brass,
0,
0,
0,
64
);
disk.rotation.x = Math.PI / 2;
addTorus(astrolabeGroup, 0.96, 0.055, materials.brassDark, 0, 0, 0.1);
addTorus(astrolabeGroup, 0.72, 0.028, materials.brassDark, 0, 0, 0.115);
cylinderBetween(
astrolabeGroup,
[-0.76, 0, 0.15],
[0.76, 0, 0.15],
0.025,
materials.steel
);
addSphere(astrolabeGroup, 0.1, materials.brassDark, 0, 0, 0.18);
for (let i = 0; i < 18; i++) {
const angle = (i / 17) * Math.PI;
const tick = addBox(
astrolabeGroup,
0.025,
i % 3 === 0 ? 0.14 : 0.085,
0.025,
materials.ink,
Math.cos(angle) * 0.86,
Math.sin(angle) * 0.86,
0.13
);
tick.rotation.z = angle - Math.PI / 2;
}
// Small stand.
addBox(
astrolabeGroup,
1.45,
0.18,
0.68,
materials.darkWood,
0,
-1.48,
-0.12
);
cylinderBetween(
astrolabeGroup,
[-0.4, -1.38, -0.1],
[-0.4, -0.83, 0],
0.055,
materials.brassDark
);
cylinderBetween(
astrolabeGroup,
[0.4, -1.38, -0.1],
[0.4, -0.83, 0],
0.055,
materials.brassDark
);
labelSprite(
astrolabeGroup,
["ASTROLABE"],
0,
1.38,
0,
1.6,
0.35,
{
foreground: "#332e25",
background: "rgba(239,225,195,0.93)",
font: "700 49px Arial"
}
);
// -------------------------------------------------------------------------
// Balance and calibration weights
// -------------------------------------------------------------------------
const balanceGroup = new THREE.Group();
balanceGroup.userData.info = {
title: "Balance and standard weights",
text:
"Balances connect measured length with mass calibration. Standard weights let an instrument maker verify that a constructed or repaired scale remains faithful to its reference."
};
balanceGroup.position.set(7.15, 0.08, 2.25);
scene.add(balanceGroup);
addCylinder(balanceGroup, 0.08, 0.11, 2.55, materials.brassDark, 0, 1.25, 0);
addBox(balanceGroup, 1.25, 0.18, 0.85, materials.darkWood, 0, 0.08, 0);
cylinderBetween(
balanceGroup,
[-1.0, 2.32, 0],
[1.0, 2.32, 0],
0.04,
materials.brass
);
addSphere(balanceGroup, 0.11, materials.brass, 0, 2.32, 0);
for (const x of [-1.0, 1.0]) {
cylinderBetween(
balanceGroup,
[x, 2.3, 0],
[x - 0.17, 1.42, 0],
0.012,
materials.ink
);
cylinderBetween(
balanceGroup,
[x, 2.3, 0],
[x + 0.17, 1.42, 0],
0.012,
materials.ink
);
const pan = addCylinder(
balanceGroup,
0.48,
0.3,
0.08,
materials.brass,
x,
1.38,
0,
40
);
pan.scale.z = 0.78;
}
addCylinder(balanceGroup, 0.13, 0.16, 0.3, materials.brassDark, 1.0, 1.57, 0);
addCylinder(balanceGroup, 0.1, 0.12, 0.22, materials.brass, -0.8, 1.5, 0);
labelSprite(
balanceGroup,
["BALANCE", "standard weights"],
0,
2.95,
0,
1.95,
0.5,
{
foreground: "#332e25",
background: "rgba(239,225,195,0.93)",
font: "700 49px Arial",
subtitleFont: "500 29px Arial"
}
);
// -------------------------------------------------------------------------
// Ledger: written record of the comparison
// -------------------------------------------------------------------------
const ledgerGroup = new THREE.Group();
ledgerGroup.userData.info = {
title: "Calibration ledger",
text:
"The written entry turns a physical comparison into transferable knowledge: one standard unit, twelve divisions, and a rod recorded as twelve units."
};
ledgerGroup.position.set(3.45, 0.08, 2.75);
ledgerGroup.rotation.y = -0.1;
scene.add(ledgerGroup);
addBox(
ledgerGroup,
3.75,
0.12,
2.55,
materials.darkWood,
0,
0.02,
0
);
const ledgerCanvas = document.createElement("canvas");
ledgerCanvas.width = 1024;
ledgerCanvas.height = 720;
const ledgerContext = ledgerCanvas.getContext("2d");
ledgerContext.fillStyle = "#ead9b5";
ledgerContext.fillRect(0, 0, 1024, 720);
ledgerContext.strokeStyle = "rgba(74, 55, 35, 0.34)";
ledgerContext.lineWidth = 4;
ledgerContext.strokeRect(30, 30, 964, 660);
ledgerContext.fillStyle = "#29312c";
ledgerContext.textAlign = "left";
ledgerContext.font = "700 48px Georgia";
ledgerContext.fillText("CALIBRATION LEDGER", 72, 100);
ledgerContext.fillStyle = "#7f3e2e";
ledgerContext.font = "italic 28px Georgia";
ledgerContext.fillText("Comparison of an unmarked rod", 72, 145);
ledgerContext.strokeStyle = "rgba(65, 76, 69, 0.22)";
ledgerContext.lineWidth = 2;
for (let y = 235; y <= 570; y += 66) {
ledgerContext.beginPath();
ledgerContext.moveTo(72, y);
ledgerContext.lineTo(950, y);
ledgerContext.stroke();
}
ledgerContext.textAlign = "right";
ledgerContext.fillStyle = "#2e3933";
ledgerContext.font = "600 35px Arial";
ledgerContext.fillText("STANDARD", 285, 211);
ledgerContext.fillText("1 u", 920, 211);
ledgerContext.fillText("RULE", 285, 278);
ledgerContext.fillText("12 divisions", 920, 278);
ledgerContext.fillText("ROD", 285, 345);
ledgerContext.fillText("12 u", 920, 345);
ledgerContext.fillText("RECORDED", 285, 412);
ledgerContext.fillText("12 units", 920, 412);
ledgerContext.textAlign = "left";
ledgerContext.fillStyle = "#1f756f";
ledgerContext.font = "700 31px Arial";
ledgerContext.fillText("✓ MATCH", 72, 600);
ledgerContext.fillStyle = "rgba(65,53,37,0.65)";
ledgerContext.font = "italic 27px Georgia";
ledgerContext.fillText("A shared unit makes separate lengths comparable.", 72, 648);
const ledgerTexture = new THREE.CanvasTexture(ledgerCanvas);
ledgerTexture.colorSpace = THREE.SRGBColorSpace;
ledgerTexture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
const ledgerPage = new THREE.Mesh(
new THREE.PlaneGeometry(3.55, 2.35),
new THREE.MeshBasicMaterial({ map: ledgerTexture })
);
ledgerPage.rotation.x = -Math.PI / 2;
ledgerPage.position.y = 0.09;
ledgerPage.receiveShadow = true;
ledgerGroup.add(ledgerPage);
// Stylized quill and inkwell.
addCylinder(
ledgerGroup,
0.18,
0.22,
0.28,
materials.ink,
1.95,
0.18,
0.62
);
cylinderBetween(
ledgerGroup,
[1.92, 0.25, 0.62],
[1.25, 0.28, 1.35],
0.025,
materials.paper
);
const feather = addBox(
ledgerGroup,
0.11,
0.035,
0.65,
materials.paper,
1.1,
0.29,
1.43
);
feather.rotation.y = -0.65;
labelSprite(
ledgerGroup,
["RECORD", "rod = 12 units"],
-0.45,
0.7,
-1.08,
2.05,
0.5,
{
foreground: "#27332d",
background: "rgba(239,225,195,0.94)",
font: "700 52px Arial",
subtitleFont: "600 31px Arial"
}
);
// -------------------------------------------------------------------------
// Extra drafting triangle and ruler for a workshop-like setting
// -------------------------------------------------------------------------
const triangle = new THREE.Group();
triangle.position.set(4.75, 0.12, 0.05);
triangle.rotation.set(-Math.PI / 2, 0, -0.18);
scene.add(triangle);
const triangleShape = new THREE.Shape();
triangleShape.moveTo(-0.65, -0.65);
triangleShape.lineTo(0.85, -0.65);
triangleShape.lineTo(-0.65, 0.85);
triangleShape.closePath();
const triangleGeometry = new THREE.ExtrudeGeometry(triangleShape, {
depth: 0.08,
bevelEnabled: true,
bevelSize: 0.025,
bevelThickness: 0.025,
bevelSegments: 2
});
const triangleMesh = new THREE.Mesh(
triangleGeometry,
new THREE.MeshStandardMaterial({
color: "#b18a52",
roughness: 0.45,
metalness: 0.08
})
);
triangleMesh.castShadow = true;
triangleMesh.receiveShadow = true;
triangle.add(triangleMesh);
// -------------------------------------------------------------------------
// Selection
// -------------------------------------------------------------------------
const selectable = [
ruleGroup,
rodGroup,
unitOverlay,
standardGroup,
dividersGroup,
caliperGroup,
astrolabeGroup,
balanceGroup,
ledgerGroup
];
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const infoTitle = document.querySelector("#info-title");
const infoText = document.querySelector("#info-text");
function selectAt(clientX, clientY) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(selectable, true);
if (!hits.length) {
infoTitle.textContent = "Shared-unit comparison";
infoText.textContent =
"Select the divided rule, unmarked rod, or calibration standard to inspect how the common unit is used.";
return;
}
let object = hits[0].object;
while (object && !object.userData.info) {
object = object.parent;
}
if (!object) return;
infoTitle.textContent = object.userData.info.title;
infoText.textContent = object.userData.info.text;
}
document.querySelector("#unit-toggle").addEventListener("change", (event) => {
unitOverlay.visible = event.target.checked;
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
controls.theta += (controls.targetTheta - controls.theta) * (1 - Math.exp(-10 * delta));
controls.phi += (controls.targetPhi - controls.phi) * (1 - Math.exp(-10 * delta));
controls.zoom += (controls.targetZoom - controls.zoom) * (1 - Math.exp(-10 * delta));
camera.zoom = controls.zoom;
camera.updateProjectionMatrix();
updateCamera();
// A restrained pulse makes the repeated unit visible without resembling
// physical marks on the rod.
const pulse = 0.72 + Math.sin(clock.elapsedTime * 1.7) * 0.08;
materials.tealLight.opacity = pulse;
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```