Prompt specification
Build or customize the Three.js 3D scene "Early modern workshop calibrating a quadrant" 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: Early modern workshop calibrating a quadrant
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/early-modern-workshop-calibrating-a-quadrant-x2334
Scene Description Prompt:
A voxel early-modern instrument-maker's bench with quadrant, plumb line, and engraved scale demonstrating schematic angle measurement. One HTML file using Three.js from cdnjs.
Working Three.js Starter (early-modern-workshop-calibrating-a-quadrant-x2334):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Quadrant Bench</title>
<style>
:root {
color-scheme: dark;
--ink: #f0dfb5;
--muted: #b9aa89;
--gold: #d6a84d;
--panel: rgba(24, 22, 17, 0.82);
}
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #171713;
font-family: Georgia, "Times New Roman", serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active { cursor: grabbing; }
.title {
position: fixed;
top: 26px;
left: 30px;
z-index: 5;
pointer-events: none;
max-width: min(430px, calc(100vw - 60px));
text-shadow: 0 2px 14px #000;
}
.eyebrow {
margin: 0 0 8px;
color: var(--gold);
font: 600 11px/1.2 system-ui, sans-serif;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: var(--ink);
font-size: clamp(29px, 4vw, 49px);
font-weight: 400;
line-height: 0.98;
letter-spacing: -0.025em;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font-size: 14px;
font-style: italic;
}
.reading {
position: fixed;
top: 26px;
right: 26px;
z-index: 5;
width: 206px;
padding: 15px 17px;
border: 1px solid rgba(214, 168, 77, 0.38);
border-radius: 3px;
background: var(--panel);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(9px);
pointer-events: none;
}
.reading .label {
color: var(--muted);
font: 600 10px/1.2 system-ui, sans-serif;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.reading .value {
margin: 3px 0 11px;
color: var(--ink);
font-size: 25px;
}
.reading .value.accent { color: #edbd5e; }
.reading hr {
margin: 0 0 11px;
border: 0;
border-top: 1px solid rgba(240, 223, 181, 0.13);
}
.legend {
position: fixed;
left: 30px;
bottom: 24px;
z-index: 5;
display: flex;
align-items: center;
gap: 18px;
padding: 9px 12px;
border: 1px solid rgba(240, 223, 181, 0.12);
border-radius: 3px;
background: rgba(20, 19, 15, 0.68);
color: var(--muted);
font: 11px/1.3 system-ui, sans-serif;
pointer-events: none;
backdrop-filter: blur(8px);
}
.legend span { white-space: nowrap; }
.key {
display: inline-block;
width: 8px;
height: 8px;
margin-right: 6px;
vertical-align: 0;
}
.key.gold { background: #d6a84d; }
.key.ink { background: #5e594d; }
#reset {
position: fixed;
right: 26px;
bottom: 24px;
z-index: 6;
padding: 9px 12px;
border: 1px solid rgba(214, 168, 77, 0.35);
border-radius: 3px;
background: rgba(24, 22, 17, 0.82);
color: var(--ink);
font: 600 10px/1 system-ui, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
cursor: pointer;
}
#reset:hover {
border-color: var(--gold);
color: #fff0c4;
}
@media (max-width: 720px) {
.title { top: 18px; left: 18px; }
.reading {
top: auto;
right: 14px;
bottom: 66px;
width: 170px;
padding: 11px 13px;
}
.reading .value { font-size: 20px; margin-bottom: 7px; }
.legend {
left: 14px;
bottom: 14px;
gap: 9px;
padding: 8px;
}
.legend .desktop { display: none; }
#reset { right: 14px; bottom: 14px; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel workshop scene"></canvas>
<header class="title">
<p class="eyebrow">A study in schematic measurement</p>
<h1>The Quadrant Bench</h1>
<p class="subtitle">Early-modern geometry, reconstructed in voxels.</p>
</header>
<aside class="reading" aria-label="Measurement reading">
<div class="label">Plumb datum</div>
<div class="value">0°</div>
<div class="label">Sight ray</div>
<div class="value accent">38°</div>
<hr>
<div class="label">Scale division</div>
<div class="value">2°</div>
</aside>
<div class="legend">
<span><i class="key gold"></i>Brass instrument</span>
<span><i class="key ink"></i>Plumb line</span>
<span class="desktop">Drag to orbit · Wheel to zoom · Right-drag to pan · R to reset</span>
</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 canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x171713);
scene.fog = new THREE.Fog(0x171713, 15, 31);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const materials = {
oak: new THREE.MeshStandardMaterial({
color: 0x6e3d20, roughness: 0.88, metalness: 0.02
}),
oakLight: new THREE.MeshStandardMaterial({
color: 0x8a542b, roughness: 0.82, metalness: 0.02
}),
oakDark: new THREE.MeshStandardMaterial({
color: 0x3b2417, roughness: 0.92, metalness: 0.01
}),
endGrain: new THREE.MeshStandardMaterial({
color: 0x4c2d1a, roughness: 0.95
}),
brass: new THREE.MeshStandardMaterial({
color: 0xc49a43, roughness: 0.34, metalness: 0.78
}),
brassLight: new THREE.MeshStandardMaterial({
color: 0xe0b85e, roughness: 0.25, metalness: 0.72
}),
brassDark: new THREE.MeshStandardMaterial({
color: 0x765526, roughness: 0.48, metalness: 0.72
}),
iron: new THREE.MeshStandardMaterial({
color: 0x383b39, roughness: 0.58, metalness: 0.76
}),
steel: new THREE.MeshStandardMaterial({
color: 0x89918e, roughness: 0.4, metalness: 0.83
}),
cord: new THREE.MeshStandardMaterial({
color: 0x25251f, roughness: 0.95
}),
slate: new THREE.MeshStandardMaterial({
color: 0x262923, roughness: 0.92
}),
parchment: new THREE.MeshStandardMaterial({
color: 0xc8b183, roughness: 0.9
}),
leather: new THREE.MeshStandardMaterial({
color: 0x552a22, roughness: 0.92
}),
ink: new THREE.MeshStandardMaterial({
color: 0x252018, roughness: 1
}),
wax: new THREE.MeshStandardMaterial({
color: 0xd9c79d, roughness: 0.88
}),
flame: new THREE.MeshStandardMaterial({
color: 0xffb637,
emissive: 0xff7a12,
emissiveIntensity: 3,
roughness: 0.5
}),
wall: new THREE.MeshStandardMaterial({
color: 0x3b382f, roughness: 1
})
};
const floorMaterials = [
new THREE.MeshStandardMaterial({ color: 0x48463e, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x535047, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x403e37, roughness: 1 })
];
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function box(w, h, d, x, y, z, material, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(
a, b, radius, material,
parent = scene,
radialSegments = 8,
radiusB = radius
) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusB, radius, length, radialSegments, 1, false
),
material
);
mesh.position.copy(a).add(b).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;
}
function beamXY(
x1, y1, x2, y2, z, width, depth,
material, parent = scene
) {
const dx = x2 - x1;
const dy = y2 - y1;
const length = Math.hypot(dx, dy);
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, length, depth),
material
);
mesh.position.set((x1 + x2) / 2, (y1 + y2) / 2, z);
mesh.rotation.z = Math.atan2(dy, dx) - Math.PI / 2;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function voxelArc(
cx, cy, z, radius,
startDegrees, endDegrees, count,
size, material, parent = scene
) {
const geometry = new THREE.BoxGeometry(
size * 0.82, size * 0.82, size * 0.58
);
for (let i = 0; i <= count; i++) {
const t = i / count;
const degrees = startDegrees +
(endDegrees - startDegrees) * t;
const angle = THREE.MathUtils.degToRad(degrees);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(
cx + Math.cos(angle) * radius,
cy + Math.sin(angle) * radius,
z
);
mesh.rotation.z = angle;
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
}
}
function textPlane(
text, width, height,
color = "#e6d2a3",
fontSize = 64,
parent = scene
) {
const c = document.createElement("canvas");
c.width = 768;
c.height = 192;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `${fontSize}px Georgia, serif`;
ctx.fillStyle = "rgba(0,0,0,0.45)";
ctx.fillText(text, c.width / 2 + 2, c.height / 2 + 3);
ctx.fillStyle = color;
ctx.fillText(text, c.width / 2, c.height / 2);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
side: THREE.DoubleSide,
toneMapped: false
})
);
mesh.renderOrder = 3;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xb8c5cf, 0x332416, 1.45));
const keyLight = new THREE.DirectionalLight(0xffd59a, 3.0);
keyLight.position.set(5.5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -3;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x8da8bd, 1.05);
fillLight.position.set(-7, 6, 3);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xf2b65f, 0.8);
rimLight.position.set(-2, 8, -7);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Workshop shell and floor
// -------------------------------------------------------------------------
box(18, 10, 0.35, 0, 4.7, -4.35, materials.wall);
// Voxel stone floor.
for (let ix = -5; ix <= 5; ix++) {
for (let iz = -3; iz <= 4; iz++) {
const mat = floorMaterials[(ix + iz + 20) % 3];
box(
2.78, 0.16, 2.78,
ix * 2.82, -0.12, iz * 2.82,
mat
);
}
}
// Back-wall timbers.
for (const x of [-6.6, -3.8, 3.8, 6.6]) {
box(0.22, 9.4, 0.24, x, 4.6, -4.08, materials.oakDark);
}
box(17.5, 0.24, 0.24, 0, 7.5, -4.04, materials.oakDark);
box(17.5, 0.24, 0.24, 0, 2.2, -4.04, materials.oakDark);
// Pegboard.
box(10.8, 3.4, 0.14, -0.2, 5.2, -4.0, materials.oak);
const pegGeometry = new THREE.BoxGeometry(0.055, 0.055, 0.035);
const pegMaterial = new THREE.MeshStandardMaterial({
color: 0x1d1b16, roughness: 1
});
for (let x = -5; x <= 4.6; x += 0.48) {
for (let y = 3.85; y <= 6.55; y += 0.46) {
const peg = new THREE.Mesh(pegGeometry, pegMaterial);
peg.position.set(x, y, -3.91);
scene.add(peg);
}
}
// Shelf.
box(11.2, 0.22, 0.85, -0.2, 7.02, -3.63, materials.oakLight);
box(0.28, 1.25, 0.28, -4.8, 6.38, -3.7, materials.oakDark);
box(0.28, 1.25, 0.28, 4.4, 6.38, -3.7, materials.oakDark);
// -------------------------------------------------------------------------
// Workbench
// -------------------------------------------------------------------------
const bench = new THREE.Group();
scene.add(bench);
// Legs.
for (const x of [-3.55, 3.55]) {
for (const z of [-1.18, 1.18]) {
box(0.58, 2.35, 0.58, x, 1.17, z, materials.oakDark, bench);
box(0.75, 0.22, 0.75, x, 0.08, z, materials.endGrain, bench);
}
}
// Stretchers and aprons.
box(0.42, 0.42, 2.8, -3.55, 0.62, 0, materials.oakDark, bench);
box(0.42, 0.42, 2.8, 3.55, 0.62, 0, materials.oakDark, bench);
box(7.45, 0.55, 0.34, 0, 2.03, -1.35, materials.oakDark, bench);
box(7.45, 0.55, 0.34, 0, 2.03, 1.35, materials.oakDark, bench);
// Five top planks.
for (let i = 0; i < 5; i++) {
const mat = i % 2 ? materials.oakLight : materials.oak;
box(
1.64, 0.34, 3.55,
(i - 2) * 1.66, 2.52, 0,
mat, bench
);
}
// Drawer.
box(6.9, 1.03, 0.28, 0, 1.5, 1.68, materials.oak, bench);
box(6.45, 0.76, 0.08, 0, 1.51, 1.85, materials.oakLight, bench);
for (const x of [-2.0, 0, 2.0]) {
box(0.14, 0.14, 0.14, x, 1.51, 1.96, materials.brassDark, bench);
}
// Bench pegs.
for (const x of [-3.7, 3.7]) {
for (const z of [-1.45, 1.45]) {
const peg = cylinderBetween(
new THREE.Vector3(x, 2.36, z),
new THREE.Vector3(x, 2.36, z + (z > 0 ? 0.22 : -0.22)),
0.1, materials.oakDark, bench, 8
);
peg.rotation.x += Math.PI / 2;
}
}
// -------------------------------------------------------------------------
// Quadrant backboard
// -------------------------------------------------------------------------
const quadrantGroup = new THREE.Group();
scene.add(quadrantGroup);
box(4.35, 3.65, 0.27, 0.48, 4.14, -0.12, materials.oakDark, quadrantGroup);
box(4.08, 3.38, 0.09, 0.48, 4.14, 0.055, materials.slate, quadrantGroup);
// Frame.
box(0.16, 3.65, 0.14, -1.66, 4.14, 0.07, materials.oakLight, quadrantGroup);
box(0.16, 3.65, 0.14, 2.62, 4.14, 0.07, materials.oakLight, quadrantGroup);
box(4.35, 0.16, 0.14, 0.48, 2.39, 0.07, materials.oakLight, quadrantGroup);
box(4.35, 0.16, 0.14, 0.48, 5.89, 0.07, materials.oakLight, quadrantGroup);
// Brass corner straps.
for (const x of [-1.57, 2.53]) {
for (const y of [2.5, 5.78]) {
box(0.28, 0.28, 0.08, x, y, 0.14, materials.brassDark, quadrantGroup);
const rivet = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 8, 6),
materials.brass
);
rivet.position.set(x, y, 0.205);
quadrantGroup.add(rivet);
}
}
// Feet fixing the board to the bench.
box(0.32, 0.28, 1.25, -0.85, 2.67, -0.03, materials.brassDark, quadrantGroup);
box(0.32, 0.28, 1.25, 1.82, 2.67, -0.03, materials.brassDark, quadrantGroup);
const title = textPlane(
"Q U A D R A N T",
3.0, 0.38, "#d6bf8c", 62, quadrantGroup
);
title.position.set(0.48, 5.59, 0.12);
const subtitle = textPlane(
"DIVISION · II · 90°",
2.4, 0.26, "#8f8269", 48, quadrantGroup
);
subtitle.position.set(0.48, 2.68, 0.12);
// -------------------------------------------------------------------------
// Brass quadrant scale
// -------------------------------------------------------------------------
const qx = 0.48;
const qy = 4.96;
const qz = 0.24;
const radius = 1.75;
// Outer and inner brass arcs, assembled from small blocks.
voxelArc(qx, qy, qz, radius, -90, 0, 48, 0.095, materials.brass, quadrantGroup);
voxelArc(qx, qy, qz, radius - 0.17, -90, 0, 44, 0.065, materials.brassDark, quadrantGroup);
// Right-angle frame.
beamXY(qx, qy, qx + radius, qy, qz, 0.065, 0.08, materials.brass, quadrantGroup);
beamXY(qx, qy, qx, qy - radius, qz, 0.065, 0.08, materials.brass, quadrantGroup);
// Engraved radial ticks.
for (let degree = 0; degree <= 90; degree += 2) {
const angle = THREE.MathUtils.degToRad(-90 + degree);
const major = degree % 10 === 0;
const inner = radius - (major ? 0.31 : 0.22);
const outer = radius - 0.045;
beamXY(
qx + Math.cos(angle) * inner,
qy + Math.sin(angle) * inner,
qx + Math.cos(angle) * outer,
qy + Math.sin(angle) * outer,
qz + 0.045,
major ? 0.035 : 0.018,
0.035,
major ? materials.brassLight : materials.brassDark,
quadrantGroup
);
}
// Scale numerals.
for (let degree = 0; degree <= 90; degree += 10) {
const angle = THREE.MathUtils.degToRad(-90 + degree);
const r = radius - 0.55;
const label = textPlane(
String(degree),
0.24, 0.18,
"#cbb98f",
64,
quadrantGroup
);
label.position.set(
qx + Math.cos(angle) * r,
qy + Math.sin(angle) * r,
qz + 0.09
);
}
// Center pivot.
const pivot = new THREE.Mesh(
new THREE.CylinderGeometry(0.16, 0.16, 0.14, 12),
materials.brassLight
);
pivot.rotation.x = Math.PI / 2;
pivot.position.set(qx, qy, qz + 0.10);
pivot.castShadow = true;
quadrantGroup.add(pivot);
const pivotCap = new THREE.Mesh(
new THREE.CylinderGeometry(0.072, 0.072, 0.18, 10),
materials.iron
);
pivotCap.rotation.x = Math.PI / 2;
pivotCap.position.set(qx, qy, qz + 0.13);
quadrantGroup.add(pivotCap);
// -------------------------------------------------------------------------
// Plumb line and stepped brass bob
// -------------------------------------------------------------------------
const plumbTop = new THREE.Vector3(qx, qy - 0.10, qz + 0.16);
const plumbBottom = new THREE.Vector3(qx, 3.16, qz + 0.16);
cylinderBetween(
plumbTop, plumbBottom,
0.012, materials.cord, quadrantGroup, 6
);
const bob = new THREE.Group();
bob.position.set(qx, 3.04, qz + 0.16);
quadrantGroup.add(bob);
const bobBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.115, 0.19, 0.31, 8),
materials.brass
);
bobBody.castShadow = true;
bob.add(bobBody);
const bobTip = new THREE.Mesh(
new THREE.ConeGeometry(0.115, 0.25, 8),
materials.brassLight
);
bobTip.position.y = -0.27;
bobTip.rotation.z = Math.PI;
bobTip.castShadow = true;
bob.add(bobTip);
const bobCap = new THREE.Mesh(
new THREE.CylinderGeometry(0.065, 0.09, 0.13, 8),
materials.brassDark
);
bobCap.position.y = 0.20;
bob.add(bobCap);
// -------------------------------------------------------------------------
// Sight ray and measured angle
// -------------------------------------------------------------------------
const measuredAngle = 38;
const sightAngle = THREE.MathUtils.degToRad(-90 + measuredAngle);
const sightLength = radius - 0.10;
const sightEnd = new THREE.Vector2(
qx + Math.cos(sightAngle) * sightLength,
qy + Math.sin(sightAngle) * sightLength
);
beamXY(
qx, qy,
sightEnd.x, sightEnd.y,
qz + 0.16,
0.055, 0.055,
materials.brassLight,
quadrantGroup
);
// Small sight block at the ray tip.
box(
0.095, 0.23, 0.11,
sightEnd.x, sightEnd.y,
qz + 0.18,
materials.brassLight,
quadrantGroup
);
// Highlighted wedge between the plumb datum and sight ray.
voxelArc(
qx, qy, qz + 0.12,
0.72, -90, -90 + measuredAngle,
13, 0.055,
materials.brassLight,
quadrantGroup
);
const angleLabel = textPlane(
"38°",
0.67, 0.36,
"#f0c66e",
82,
quadrantGroup
);
angleLabel.position.set(1.02, 4.78, qz + 0.19);
const plumbLabel = textPlane(
"PLUMB",
0.72, 0.20,
"#aaa089",
54,
quadrantGroup
);
plumbLabel.position.set(-0.38, 4.05, qz + 0.15);
// -------------------------------------------------------------------------
// Engraved straightedge on the bench
// -------------------------------------------------------------------------
box(3.35, 0.09, 0.38, -0.1, 2.77, 1.25, materials.brass, bench);
for (let i = 0; i <= 34; i++) {
const major = i % 5 === 0;
box(
0.018, 0.012, major ? 0.20 : 0.12,
-1.70 + i * 0.094,
2.821,
1.17,
materials.ink,
bench
);
}
// -------------------------------------------------------------------------
// Hand plane
// -------------------------------------------------------------------------
const planeTool = new THREE.Group();
planeTool.position.set(-2.73, 2.85, 0.63);
planeTool.rotation.y = -0.17;
bench.add(planeTool);
box(1.16, 0.34, 0.66, 0, 0, 0, materials.oakDark, planeTool);
box(1.0, 0.22, 0.55, 0, 0.26, 0, materials.oakLight, planeTool);
// Rear tote and knob.
box(0.28, 0.66, 0.46, -0.42, 0.47, 0, materials.oak, planeTool);
box(0.15, 0.5, 0.15, 0.28, 0.5, 0, materials.oakDark, planeTool);
box(0.28, 0.17, 0.28, 0.28, 0.78, 0, materials.oakLight, planeTool);
// Iron blade and wedge.
const blade = box(
0.67, 0.12, 0.52,
-0.1, 0.29, 0,
materials.steel,
planeTool
);
blade.rotation.z = -0.22;
const wedge = box(
0.3, 0.12, 0.42,
0.03, 0.47, 0,
materials.brassDark,
planeTool
);
wedge.rotation.z = -0.18;
// -------------------------------------------------------------------------
// Mallet, vise and loose tools
// -------------------------------------------------------------------------
const mallet = new THREE.Group();
mallet.position.set(-3.35, 2.88, -0.45);
mallet.rotation.y = 0.35;
bench.add(mallet);
const malletHandle = box(
0.14, 1.45, 0.14,
0, 0, 0,
materials.oakLight,
mallet
);
malletHandle.rotation.z = Math.PI / 2;
box(0.57, 0.43, 0.48, -0.66, 0, 0, materials.oakDark, mallet);
// Front vise.
box(0.9, 0.28, 0.9, -3.65, 2.74, 1.2, materials.iron, bench);
box(0.28, 0.55, 1.05, -3.96, 2.78, 1.45, materials.iron, bench);
box(0.22, 0.4, 0.72, -3.22, 2.78, 1.43, materials.iron, bench);
cylinderBetween(
new THREE.Vector3(-3.18, 2.79, 1.44),
new THREE.Vector3(-2.62, 2.79, 1.44),
0.07, materials.steel, bench, 8
);
// Brass dividers.
const dividerHub = new THREE.Vector3(2.83, 3.05, 0.62);
cylinderBetween(
dividerHub,
new THREE.Vector3(2.40, 2.73, 0.72),
0.045, materials.brass, bench, 6
);
cylinderBetween(
dividerHub,
new THREE.Vector3(3.27, 2.73, 0.72),
0.045, materials.brass, bench, 6
);
box(0.18, 0.13, 0.15, 2.83, 3.09, 0.62, materials.brassDark, bench);
// Small calipers.
const caliperHub = new THREE.Vector3(3.35, 3.03, -0.02);
cylinderBetween(
caliperHub,
new THREE.Vector3(3.04, 2.73, 0.08),
0.034, materials.steel, bench, 6
);
cylinderBetween(
caliperHub,
new THREE.Vector3(3.68, 2.73, 0.08),
0.034, materials.steel, bench, 6
);
// Leather-bound notebooks.
const book1 = box(1.22, 0.18, 0.9, 2.78, 2.83, -0.78, materials.leather, bench);
book1.rotation.y = -0.18;
const book2 = box(1.05, 0.15, 0.78, 2.83, 3.0, -0.77, materials.parchment, bench);
book2.rotation.y = -0.1;
box(1.05, 0.035, 0.78, 2.83, 3.09, -0.77, materials.leather, bench);
// Tool tray.
box(1.22, 0.1, 0.7, 0.3, 2.76, -0.85, materials.brassDark, bench);
for (let i = 0; i < 4; i++) {
const file = box(
0.065, 0.065, 0.92,
-0.08 + i * 0.21, 2.85, -0.84,
i % 2 ? materials.steel : materials.iron,
bench
);
file.rotation.y = -0.15 + i * 0.07;
}
// Rolled drawing.
const roll = new THREE.Mesh(
new THREE.CylinderGeometry(0.16, 0.16, 1.15, 10),
materials.parchment
);
roll.rotation.z = Math.PI / 2;
roll.rotation.y = -0.15;
roll.position.set(-1.55, 2.85, -0.98);
roll.castShadow = true;
bench.add(roll);
// -------------------------------------------------------------------------
// Hanging workshop tools
// -------------------------------------------------------------------------
// Saw at the left.
const saw = new THREE.Group();
saw.position.set(-4.55, 5.2, -3.73);
saw.rotation.z = -0.12;
scene.add(saw);
box(0.34, 0.78, 0.18, -0.46, 0, 0, materials.oakDark, saw);
box(0.94, 0.72, 0.07, 0.42, 0, 0, materials.steel, saw);
for (let i = 0; i < 10; i++) {
box(0.055, 0.08, 0.04, 0.03 + i * 0.09, -0.4, 0.03, materials.steel, saw);
}
// Carpenter's square.
box(0.13, 1.7, 0.1, -4.0, 5.2, -3.72, materials.brassDark);
box(1.0, 0.13, 0.1, -3.58, 5.91, -3.72, materials.brassDark);
// Two hanging dividers.
for (const x of [3.55, 4.5]) {
cylinderBetween(
new THREE.Vector3(x, 6.35, -3.72),
new THREE.Vector3(x - 0.25, 4.95, -3.72),
0.035, materials.brass, scene, 6
);
cylinderBetween(
new THREE.Vector3(x, 6.35, -3.72),
new THREE.Vector3(x + 0.25, 4.95, -3.72),
0.035, materials.brass, scene, 6
);
}
// Shelf jars and books.
for (let i = 0; i < 5; i++) {
box(
0.48, 0.65 + (i % 2) * 0.18, 0.48,
-4.6 + i * 0.72, 7.43,
-3.56,
i % 2 ? materials.leather : materials.parchment
);
box(
0.53, 0.09, 0.53,
-4.6 + i * 0.72, 7.83,
-3.56,
materials.oakDark
);
}
// -------------------------------------------------------------------------
// Candle
// -------------------------------------------------------------------------
const candle = new THREE.Group();
candle.position.set(3.72, 2.75, -0.78);
bench.add(candle);
const candleBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.16, 0.78, 10),
materials.wax
);
candleBody.position.y = 0.4;
candleBody.castShadow = true;
candle.add(candleBody);
const candleHolder = new THREE.Mesh(
new THREE.CylinderGeometry(0.29, 0.33, 0.12, 10),
materials.brassDark
);
candleHolder.position.y = 0.06;
candle.add(candleHolder);
const flame = new THREE.Group();
flame.position.y = 0.9;
candle.add(flame);
box(0.10, 0.22, 0.10, 0, 0, 0, materials.flame, flame);
box(0.055, 0.16, 0.055, 0.01, 0.13, 0, materials.flame, flame);
const candleLight = new THREE.PointLight(0xffa33c, 2.2, 5, 2);
candleLight.position.set(0, 0.92, 0.12);
candle.add(candleLight);
// -------------------------------------------------------------------------
// Suspended dust
// -------------------------------------------------------------------------
const dustCount = 260;
const dustPositions = new Float32Array(dustCount * 3);
let seed = 813;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
for (let i = 0; i < dustCount; i++) {
dustPositions[i * 3] = (random() - 0.5) * 13;
dustPositions[i * 3 + 1] = 0.5 + random() * 7;
dustPositions[i * 3 + 2] = (random() - 0.5) * 8;
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xe8d5a8,
size: 0.035,
transparent: true,
opacity: 0.36,
depthWrite: false
})
);
scene.add(dust);
// -------------------------------------------------------------------------
// Direct camera controls — no external control modules
// -------------------------------------------------------------------------
const home = {
azimuth: 0.27,
polar: 1.17,
radius: 11.8,
target: new THREE.Vector3(0, 3.25, 0)
};
const controls = {
azimuth: home.azimuth,
polar: home.polar,
radius: home.radius,
targetAzimuth: home.azimuth,
targetPolar: home.polar,
targetRadius: home.radius,
target: home.target.clone()
};
const pointers = new Map();
let previousPinchDistance = 0;
let panPointer = null;
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
);
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (event.button === 2) panPointer = event.pointerId;
if (pointers.size === 2) previousPinchDistance = pointerDistance();
});
canvas.addEventListener("pointermove", event => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointers.size === 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0 && distance > 0) {
controls.targetRadius = THREE.MathUtils.clamp(
controls.targetRadius * previousPinchDistance / distance,
6.5, 18
);
}
previousPinchDistance = distance;
return;
}
if (event.pointerId === panPointer || event.buttons === 2) {
controls.target.x = THREE.MathUtils.clamp(
controls.target.x - dx * 0.006,
-4.5, 4.5
);
controls.target.z = THREE.MathUtils.clamp(
controls.target.z + dy * 0.006,
-2.5, 3.5
);
} else {
controls.targetAzimuth -= dx * 0.006;
controls.targetPolar = THREE.MathUtils.clamp(
controls.targetPolar + dy * 0.005,
0.48, 1.52
);
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (event.pointerId === panPointer) panPointer = null;
if (pointers.size < 2) previousPinchDistance = 0;
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("wheel", event => {
event.preventDefault();
controls.targetRadius = THREE.MathUtils.clamp(
controls.targetRadius * Math.exp(event.deltaY * 0.001),
6.5, 18
);
}, { passive: false });
function resetView() {
controls.targetAzimuth = home.azimuth;
controls.targetPolar = home.polar;
controls.targetRadius = home.radius;
controls.target.copy(home.target);
}
document.querySelector("#reset").addEventListener("click", resetView);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") resetView();
});
function updateCamera() {
controls.azimuth = THREE.MathUtils.lerp(
controls.azimuth, controls.targetAzimuth, 0.085
);
controls.polar = THREE.MathUtils.lerp(
controls.polar, controls.targetPolar, 0.085
);
controls.radius = THREE.MathUtils.lerp(
controls.radius, controls.targetRadius, 0.09
);
controls.target.lerp(home.target.clone().add(
controls.target.clone().sub(home.target)
), 0.2);
const sinPolar = Math.sin(controls.polar);
camera.position.set(
controls.target.x +
controls.radius * sinPolar * Math.sin(controls.azimuth),
controls.target.y +
controls.radius * Math.cos(controls.polar),
controls.target.z +
controls.radius * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
updateCamera();
flame.scale.y = 0.93 + Math.sin(time * 12.0) * 0.08;
flame.rotation.z = Math.sin(time * 7.0) * 0.035;
candleLight.intensity = 2.1 + Math.sin(time * 10.0) * 0.16;
dust.rotation.y = Math.sin(time * 0.035) * 0.08;
dust.position.y = Math.sin(time * 0.13) * 0.08;
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```