Prompt specification
Build or customize the Three.js 3D scene "Marine clock beside a local-noon marker" 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: Marine clock beside a local-noon marker
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/marine-clock-beside-a-local-noon-marker-x2485
Scene Description Prompt:
Create a standalone stylized scene in one HTML file using Three.js from cdnjs. Place a marine chronometer model beside a sun-shadow marker. Label reference time and local solar noon separately so the two measurements are not treated as identical.
Working Three.js Starter (marine-clock-beside-a-local-noon-marker-x2485):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Marine Chronometer & Local Solar Noon</title>
<style>
:root {
--ink: #14363b;
--paper: #f6efd9;
--brass: #d6a94f;
--cyan: #64d7d2;
--coral: #e47c61;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #b8d5d1;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
background:
radial-gradient(circle at 50% 45%, transparent 45%, rgba(17, 52, 58, .12) 100%);
}
header {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
max-width: 430px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
color: #42666a;
font-size: 11px;
font-weight: 800;
letter-spacing: .19em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 2px;
background: var(--coral);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(29px, 4vw, 52px);
font-weight: 500;
line-height: .98;
letter-spacing: -.035em;
color: #153b40;
}
header p {
max-width: 380px;
margin: 13px 0 0;
color: #486a6d;
font-size: 13px;
line-height: 1.5;
}
.measure {
position: fixed;
z-index: 6;
width: 218px;
padding: 14px 15px 13px;
border: 1px solid rgba(255,255,255,.7);
border-radius: 12px;
background: rgba(249, 244, 224, .88);
box-shadow: 0 12px 36px rgba(24, 58, 62, .16);
backdrop-filter: blur(10px);
pointer-events: none;
transform: translate(-50%, calc(-100% - 30px));
transition: opacity .2s ease;
}
.measure::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 24px;
background: rgba(20,54,59,.52);
}
.measure::before {
content: "";
position: absolute;
left: calc(50% - 4px);
top: calc(100% + 21px);
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(255,255,255,.65);
}
.measure.reference { --accent: var(--coral); }
.measure.solar { --accent: var(--cyan); }
.measure .kind {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 6px;
color: #527074;
font-size: 9px;
font-weight: 800;
letter-spacing: .16em;
text-transform: uppercase;
}
.measure .kind i {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
}
.measure h2 {
margin: 0 0 5px;
color: #173c41;
font-size: 11px;
font-weight: 850;
letter-spacing: .12em;
text-transform: uppercase;
}
.measure .value {
margin: 0;
color: #12383d;
font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
font-size: 25px;
font-weight: 700;
letter-spacing: -.045em;
font-variant-numeric: tabular-nums;
}
.measure .detail {
margin-top: 5px;
color: #5c7476;
font-size: 10px;
line-height: 1.35;
}
.clarifier {
position: fixed;
z-index: 5;
left: 30px;
bottom: 25px;
max-width: 470px;
padding: 12px 15px;
border-left: 3px solid var(--coral);
background: rgba(247, 242, 222, .78);
backdrop-filter: blur(8px);
color: #476568;
font-size: 11px;
line-height: 1.45;
pointer-events: none;
}
.clarifier strong {
color: #173b40;
}
.controls {
position: fixed;
z-index: 5;
right: 28px;
bottom: 27px;
color: rgba(20,54,59,.62);
font-size: 10px;
font-weight: 700;
letter-spacing: .08em;
text-transform: uppercase;
pointer-events: none;
}
@media (max-width: 760px) {
header {
top: 18px;
left: 18px;
max-width: calc(100vw - 36px);
}
h1 {
max-width: 310px;
font-size: 31px;
}
header p {
display: none;
}
.measure {
position: fixed;
width: calc(50vw - 25px);
min-width: 150px;
padding: 11px 12px;
transform: none;
}
.measure::before,
.measure::after {
display: none;
}
.measure.reference {
left: 13px !important;
top: auto !important;
bottom: 70px;
}
.measure.solar {
right: 13px !important;
left: auto !important;
top: auto !important;
bottom: 70px;
}
.measure .value {
font-size: 19px;
}
.measure .detail {
font-size: 9px;
}
.clarifier {
left: 13px;
right: 13px;
bottom: 13px;
max-width: none;
padding: 8px 11px;
font-size: 9px;
}
.controls {
display: none;
}
}
</style>
</head>
<body>
<div class="vignette"></div>
<header>
<div class="eyebrow">Meridian study · 01</div>
<h1>A clock beside the sun.</h1>
<p>
A stylized marine chronometer and a sun-shadow marker, presented as
independent references rather than a single shared time reading.
</p>
</header>
<article id="referenceLabel" class="measure reference">
<div class="kind"><i></i>Instrument reading</div>
<h2>Reference Time</h2>
<p class="value">11:42:20</p>
<div class="detail">Displayed by the marine chronometer</div>
</article>
<article id="solarLabel" class="measure solar">
<div class="kind"><i></i>Shadow event</div>
<h2>Local Solar Noon</h2>
<p class="value">12:00</p>
<div class="detail">Marked by the sun-shadow gnomon</div>
</article>
<div class="clarifier">
<strong>Two distinct readings:</strong>
the chronometer shows a reference time, while local solar noon identifies
the local meridian event indicated by the shadow marker.
</div>
<div class="controls">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xb8d5d1);
scene.fog = new THREE.Fog(0xb8d5d1, 18, 43);
const camera = new THREE.PerspectiveCamera(
38,
innerWidth / innerHeight,
0.1,
80
);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
document.body.prepend(renderer.domElement);
const maxAnisotropy = renderer.capabilities.getMaxAnisotropy();
const palette = {
sand: 0xd9c99d,
sandLight: 0xeadcb6,
stone: 0xc4ae82,
brass: 0xc89a43,
brassLight: 0xe6c873,
brassDark: 0x80602d,
dial: 0xeee1b9,
navy: 0x173e46,
cyan: 0x63d7d0,
coral: 0xe47c61,
sea: 0x4f8791
};
const material = (color, roughness = 0.72, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const brassMat = material(palette.brass, 0.3, 0.72);
const brassLightMat = material(palette.brassLight, 0.25, 0.7);
const brassDarkMat = material(palette.brassDark, 0.48, 0.58);
const stoneMat = material(palette.stone, 0.93, 0);
const sandMat = material(palette.sand, 1, 0);
// Lighting: the light direction is chosen so the gnomon's real shadow
// points along the highlighted local-noon line.
scene.add(new THREE.HemisphereLight(0xdaf2ed, 0x6f7964, 1.75));
const sunLight = new THREE.DirectionalLight(0xffe2a2, 4.3);
sunLight.position.set(-6, 10, -4);
sunLight.target.position.set(0, 0, 0);
sunLight.castShadow = true;
sunLight.shadow.mapSize.set(2048, 2048);
sunLight.shadow.camera.left = -8;
sunLight.shadow.camera.right = 8;
sunLight.shadow.camera.top = 8;
sunLight.shadow.camera.bottom = -8;
sunLight.shadow.camera.near = 1;
sunLight.shadow.camera.far = 28;
sunLight.shadow.bias = -0.00035;
sunLight.shadow.normalBias = 0.025;
scene.add(sunLight, sunLight.target);
const fill = new THREE.DirectionalLight(0x9adbd6, 1.0);
fill.position.set(7, 4, 8);
scene.add(fill);
// Stylized sea and sandy diorama.
const sea = new THREE.Mesh(
new THREE.PlaneGeometry(100, 100),
material(palette.sea, 0.42, 0.05)
);
sea.rotation.x = -Math.PI / 2;
sea.position.y = -0.51;
sea.receiveShadow = true;
scene.add(sea);
const island = new THREE.Mesh(
new THREE.CylinderGeometry(7, 7.15, 0.45, 96),
sandMat
);
island.position.y = -0.28;
island.receiveShadow = true;
island.castShadow = true;
scene.add(island);
const islandTop = new THREE.Mesh(
new THREE.CylinderGeometry(6.96, 6.99, 0.035, 96),
material(palette.sandLight, 1, 0)
);
islandTop.position.y = -0.04;
islandTop.receiveShadow = true;
scene.add(islandTop);
// Quiet graphic wave lines around the island.
[8.0, 10.0, 12.3, 15.0].forEach((radius, index) => {
const points = [];
for (let i = 0; i < 160; i++) {
const a = (i / 160) * Math.PI * 2;
points.push(new THREE.Vector3(
Math.cos(a) * radius,
-0.485 + index * 0.002,
Math.sin(a) * radius * 0.68
));
}
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const line = new THREE.LineLoop(
geometry,
new THREE.LineBasicMaterial({
color: 0xd8f0e8,
transparent: true,
opacity: 0.18 - index * 0.025
})
);
scene.add(line);
});
// Graphic sun and halo.
const sun = new THREE.Mesh(
new THREE.CircleGeometry(2.55, 64),
new THREE.MeshBasicMaterial({ color: 0xf5c76c, fog: false })
);
sun.position.set(-10.5, 7.2, -18);
scene.add(sun);
const sunHalo = new THREE.Mesh(
new THREE.CircleGeometry(3.5, 64),
new THREE.MeshBasicMaterial({
color: 0xf8dc91,
transparent: true,
opacity: 0.16,
depthWrite: false,
fog: false
})
);
sunHalo.position.set(-10.5, 7.2, -18.15);
scene.add(sunHalo);
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.roundRect(x, y, w, h, r);
ctx.closePath();
}
function makeChronometerDial() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 1024;
const ctx = canvas.getContext("2d");
const gradient = ctx.createRadialGradient(430, 350, 60, 512, 512, 520);
gradient.addColorStop(0, "#fff7d8");
gradient.addColorStop(0.72, "#ead9ae");
gradient.addColorStop(1, "#d4bc85");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 1024, 1024);
ctx.strokeStyle = "#846d45";
ctx.lineWidth = 8;
ctx.beginPath();
ctx.arc(512, 512, 455, 0, Math.PI * 2);
ctx.stroke();
ctx.strokeStyle = "rgba(76,74,57,.48)";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc(512, 512, 410, 0, Math.PI * 2);
ctx.stroke();
const roman = [
["XII", 512, 188],
["III", 804, 512],
["VI", 512, 836],
["IX", 220, 512]
];
ctx.fillStyle = "#203e43";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "600 72px Georgia, serif";
roman.forEach(([text, x, y]) => ctx.fillText(text, x, y));
ctx.fillStyle = "#29494c";
ctx.font = "700 30px Arial, sans-serif";
ctx.fillText("MARINE", 512, 354);
ctx.font = "500 22px Arial, sans-serif";
ctx.fillText("CHRONOMETER", 512, 394);
ctx.font = "500 18px monospace";
ctx.fillText("REFERENCE · GMT", 512, 426);
// Small seconds register.
ctx.strokeStyle = "#7c6949";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.arc(512, 675, 103, 0, Math.PI * 2);
ctx.stroke();
for (let i = 0; i < 12; i++) {
const a = (i / 12) * Math.PI * 2;
const x1 = 512 + Math.sin(a) * 83;
const y1 = 675 - Math.cos(a) * 83;
const x2 = 512 + Math.sin(a) * 94;
const y2 = 675 - Math.cos(a) * 94;
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
}
ctx.fillStyle = "#29494c";
ctx.font = "500 18px Arial, sans-serif";
ctx.fillText("60", 512, 593);
ctx.fillText("30", 512, 758);
ctx.strokeStyle = "#b94e3e";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(512, 675);
ctx.lineTo(540, 630);
ctx.stroke();
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = maxAnisotropy;
return texture;
}
function makeSundialDial() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 1024;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 1024);
ctx.fillStyle = "#173e46";
ctx.beginPath();
ctx.arc(512, 512, 495, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = "rgba(113,216,207,.72)";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.arc(512, 512, 450, 0, Math.PI * 2);
ctx.stroke();
ctx.strokeStyle = "rgba(238,230,195,.22)";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(512, 512, 410, 0, Math.PI * 2);
ctx.stroke();
ctx.fillStyle = "rgba(238,230,195,.86)";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "700 30px Arial, sans-serif";
ctx.fillText("LOCAL", 512, 446);
ctx.fillText("MERIDIAN", 512, 486);
ctx.font = "500 21px monospace";
ctx.fillStyle = "rgba(112,218,209,.9)";
ctx.fillText("SUN-SHADOW MARKER", 512, 541);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = maxAnisotropy;
return texture;
}
function makeCompassTexture() {
const canvas = document.createElement("canvas");
canvas.width = canvas.height = 512;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 512, 512);
ctx.strokeStyle = "rgba(67,95,87,.45)";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc(256, 256, 213, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(256, 256, 180, 0, Math.PI * 2);
ctx.stroke();
for (let i = 0; i < 32; i++) {
const a = (i / 32) * Math.PI * 2;
const inner = i % 4 === 0 ? 158 : 173;
ctx.beginPath();
ctx.moveTo(256 + Math.sin(a) * inner, 256 - Math.cos(a) * inner);
ctx.lineTo(256 + Math.sin(a) * 191, 256 - Math.cos(a) * 191);
ctx.stroke();
}
ctx.fillStyle = "rgba(55,86,80,.7)";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "700 38px Georgia, serif";
ctx.fillText("N", 256, 66);
ctx.fillText("S", 256, 446);
ctx.fillText("E", 446, 256);
ctx.fillText("W", 66, 256);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = maxAnisotropy;
return texture;
}
function makePlaqueTexture(title, value, accent, subtitle) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 320;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 320);
roundedRect(ctx, 8, 8, 1008, 304, 28);
ctx.fillStyle = "rgba(244,235,204,.97)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 12;
roundedRect(ctx, 18, 18, 988, 284, 22);
ctx.stroke();
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = "#5b6d69";
ctx.font = "700 31px Arial, sans-serif";
ctx.fillText(title, 55, 69);
ctx.fillStyle = "#173b40";
ctx.font = "700 83px monospace";
ctx.fillText(value, 52, 166);
ctx.fillStyle = "#627571";
ctx.font = "500 25px Arial, sans-serif";
ctx.fillText(subtitle, 55, 253);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = maxAnisotropy;
return texture;
}
function makeTextSprite(text, accent = "#63d7d0") {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 180;
const ctx = canvas.getContext("2d");
roundedRect(ctx, 8, 8, 496, 164, 28);
ctx.fillStyle = "rgba(20,57,63,.93)";
ctx.fill();
ctx.strokeStyle = accent;
ctx.lineWidth = 8;
roundedRect(ctx, 14, 14, 484, 152, 22);
ctx.stroke();
ctx.fillStyle = accent;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "800 56px Arial, sans-serif";
ctx.fillText(text, 256, 91);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(0.9, 0.32, 1);
return sprite;
}
function addPlaque(parent, radius, title, value, accent, subtitle, width = 1.9) {
const texture = makePlaqueTexture(title, value, accent, subtitle);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(width, width / 3.2),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
plaque.position.set(0, 0.28, radius + 0.025);
parent.add(plaque);
}
function addPlinth(x, radius, height, plaqueData) {
const group = new THREE.Group();
group.position.x = x;
const base = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius * 1.03, height, 72),
stoneMat
);
base.position.y = height / 2;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 0.97, radius, 0.09, 72),
material(0xe2d2a8, 0.92, 0)
);
cap.position.y = height + 0.025;
cap.castShadow = true;
cap.receiveShadow = true;
group.add(cap);
addPlaque(group, radius, ...plaqueData);
scene.add(group);
return group;
}
const chronometerPlinth = addPlinth(
-2.3,
1.47,
0.54,
[
"REFERENCE TIME",
"11:42:20",
"#e47c61",
"CHRONOMETER DISPLAY",
1.9
]
);
const sundialPlinth = addPlinth(
2.3,
1.35,
0.52,
[
"LOCAL SOLAR NOON",
"12:00",
"#63d7d0",
"SUN-SHADOW EVENT",
1.9
]
);
// Marine chronometer.
const watch = new THREE.Group();
watch.position.set(-2.3, 1.57, 0);
watch.scale.setScalar(0.9);
watch.rotation.y = 0.08;
const caseBody = new THREE.Mesh(
new THREE.CylinderGeometry(1.055, 1.055, 0.34, 80),
brassMat
);
caseBody.rotation.x = Math.PI / 2;
caseBody.castShadow = true;
caseBody.receiveShadow = true;
watch.add(caseBody);
const rearCase = new THREE.Mesh(
new THREE.CylinderGeometry(0.96, 1.02, 0.18, 80),
brassDarkMat
);
rearCase.rotation.x = Math.PI / 2;
rearCase.position.z = -0.22;
rearCase.castShadow = true;
watch.add(rearCase);
const bezel = new THREE.Mesh(
new THREE.TorusGeometry(1.015, 0.085, 18, 96),
brassLightMat
);
bezel.position.z = 0.195;
bezel.castShadow = true;
watch.add(bezel);
const dial = new THREE.Mesh(
new THREE.CircleGeometry(0.93, 96),
new THREE.MeshStandardMaterial({
map: makeChronometerDial(),
roughness: 0.82,
metalness: 0
})
);
dial.position.z = 0.205;
watch.add(dial);
// Minute and hour indices.
const minuteTickMat = material(0x29494c, 0.75, 0.12);
const hourTickMat = material(0x203e43, 0.65, 0.18);
for (let i = 0; i < 60; i++) {
const isHour = i % 5 === 0;
const a = (i / 60) * Math.PI * 2;
const radius = isHour ? 0.765 : 0.805;
const tick = new THREE.Mesh(
new THREE.BoxGeometry(
isHour ? 0.035 : 0.014,
isHour ? 0.14 : 0.075,
0.012
),
isHour ? hourTickMat : minuteTickMat
);
tick.position.set(
Math.sin(a) * radius,
Math.cos(a) * radius,
0.224
);
tick.rotation.z = -a;
watch.add(tick);
}
function addHand(length, width, color, z, angle, tail = 0.08) {
const pivot = new THREE.Group();
pivot.position.z = z;
pivot.rotation.z = -angle;
const hand = new THREE.Mesh(
new THREE.BoxGeometry(width, length + tail, 0.014),
new THREE.MeshStandardMaterial({
color,
roughness: 0.35,
metalness: 0.55
})
);
hand.position.y = (length - tail) / 2;
hand.castShadow = true;
pivot.add(hand);
watch.add(pivot);
return pivot;
}
const refHours = 11;
const refMinutes = 42;
const refSeconds = 20;
const hourAngle =
((refHours % 12) + refMinutes / 60 + refSeconds / 3600) / 12 * Math.PI * 2;
const minuteAngle =
(refMinutes + refSeconds / 60) / 60 * Math.PI * 2;
const secondAngle = refSeconds / 60 * Math.PI * 2;
addHand(0.43, 0.055, 0x193b42, 0.246, hourAngle, 0.09);
addHand(0.62, 0.034, 0x193b42, 0.263, minuteAngle, 0.11);
addHand(0.69, 0.014, 0xc95542, 0.281, secondAngle, 0.16);
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(0.07, 0.07, 0.035, 32),
brassDarkMat
);
hub.rotation.x = Math.PI / 2;
hub.position.z = 0.299;
watch.add(hub);
const glass = new THREE.Mesh(
new THREE.CircleGeometry(0.935, 96),
new THREE.MeshPhysicalMaterial({
color: 0xffffff,
transparent: true,
opacity: 0.12,
roughness: 0.08,
metalness: 0,
depthWrite: false,
side: THREE.DoubleSide
})
);
glass.position.z = 0.322;
glass.renderOrder = 4;
watch.add(glass);
// Winding crown and ridges.
const crown = new THREE.Mesh(
new THREE.CylinderGeometry(0.145, 0.145, 0.28, 32),
brassLightMat
);
crown.rotation.z = Math.PI / 2;
crown.position.set(1.16, 0, 0);
crown.castShadow = true;
watch.add(crown);
[1.075, 1.145, 1.215, 1.255].forEach((x) => {
const ridge = new THREE.Mesh(
new THREE.TorusGeometry(0.145, 0.012, 8, 40),
brassDarkMat
);
ridge.rotation.y = Math.PI / 2;
ridge.position.x = x;
watch.add(ridge);
});
// Pendant and case hardware.
const pendant = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.035, 12, 40),
brassLightMat
);
pendant.position.set(0, 1.14, 0);
pendant.castShadow = true;
watch.add(pendant);
[-0.45, 0.45].forEach((y) => {
const hinge = new THREE.Mesh(
new THREE.BoxGeometry(0.16, 0.22, 0.21),
brassDarkMat
);
hinge.position.set(-1.08, y, 0);
hinge.castShadow = true;
watch.add(hinge);
});
[-0.78, 0.78].forEach((x) => {
const lug = new THREE.Mesh(
new THREE.BoxGeometry(0.22, 0.3, 0.26),
brassMat
);
lug.position.set(x, -0.96, 0);
lug.rotation.z = x < 0 ? -0.16 : 0.16;
lug.castShadow = true;
watch.add(lug);
});
scene.add(watch);
// Sun-shadow marker / sundial.
const sundial = new THREE.Group();
sundial.position.set(2.3, 0, 0);
const dialPlate = new THREE.Mesh(
new THREE.CylinderGeometry(1.02, 1.02, 0.085, 80),
brassDarkMat
);
dialPlate.position.y = 0.61;
dialPlate.castShadow = true;
dialPlate.receiveShadow = true;
sundial.add(dialPlate);
const sundialFace = new THREE.Mesh(
new THREE.CircleGeometry(0.965, 96),
new THREE.MeshStandardMaterial({
map: makeSundialDial(),
roughness: 0.74,
metalness: 0.06
})
);
sundialFace.rotation.x = -Math.PI / 2;
sundialFace.position.y = 0.658;
sundialFace.receiveShadow = true;
sundial.add(sundialFace);
const sundialRim = new THREE.Mesh(
new THREE.TorusGeometry(1.01, 0.043, 12, 96),
brassLightMat
);
sundialRim.rotation.x = Math.PI / 2;
sundialRim.position.y = 0.665;
sundialRim.castShadow = true;
sundial.add(sundialRim);
// Hour scale.
for (let i = 0; i < 12; i++) {
const a = (i / 12) * Math.PI * 2;
const tick = new THREE.Mesh(
new THREE.BoxGeometry(0.028, 0.022, i % 3 === 0 ? 0.18 : 0.11),
i === 4 ? material(palette.cyan, 0.4, 0.15) : material(0xe9dfbd, 0.72, 0)
);
tick.position.set(Math.sin(a) * 0.88, 0.682, Math.cos(a) * 0.88);
tick.rotation.y = a;
sundial.add(tick);
}
// The highlighted noon direction is opposite the light's horizontal
// source vector, matching the gnomon's cast shadow.
const noonAngle = Math.atan2(4, 6);
const noonDirection = new THREE.Vector3(
Math.sin(noonAngle),
0,
Math.cos(noonAngle)
);
const noonLine = new THREE.Mesh(
new THREE.BoxGeometry(0.82, 0.015, 0.032),
new THREE.MeshBasicMaterial({ color: palette.cyan })
);
noonLine.position.set(
noonDirection.x * 0.42,
0.686,
noonDirection.z * 0.42
);
noonLine.rotation.y = -noonAngle;
sundial.add(noonLine);
const noonPoint = new THREE.Mesh(
new THREE.CylinderGeometry(0.055, 0.055, 0.025, 24),
new THREE.MeshBasicMaterial({ color: palette.cyan })
);
noonPoint.position.set(
noonDirection.x * 0.88,
0.7,
noonDirection.z * 0.88
);
sundial.add(noonPoint);
// Triangular prism gnomon.
const t = 0.055;
const gnomonGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([
-t, 0.00, -0.42, // 0
-t, 0.00, 0.42, // 1
-t, 0.95, 0.10, // 2
t, 0.00, -0.42, // 3
t, 0.00, 0.42, // 4
t, 0.95, 0.10 // 5
]);
gnomonGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
gnomonGeometry.setIndex([
0, 2, 1,
3, 4, 5,
0, 1, 4, 0, 4, 3,
1, 2, 5, 1, 5, 4,
0, 3, 5, 0, 5, 2
]);
gnomonGeometry.computeVertexNormals();
const gnomon = new THREE.Mesh(
gnomonGeometry,
new THREE.MeshStandardMaterial({
color: palette.brassLight,
roughness: 0.28,
metalness: 0.72,
side: THREE.DoubleSide
})
);
gnomon.position.y = 0.69;
gnomon.castShadow = true;
gnomon.receiveShadow = true;
sundial.add(gnomon);
const noonSprite = makeTextSprite("12 · N", "#63d7d0");
noonSprite.position.set(
noonDirection.x * 0.88,
1.08,
noonDirection.z * 0.88
);
noonSprite.renderOrder = 5;
sundial.add(noonSprite);
scene.add(sundial);
// Compass graphic between the two instruments.
const compass = new THREE.Mesh(
new THREE.CircleGeometry(1.02, 64),
new THREE.MeshBasicMaterial({
map: makeCompassTexture(),
transparent: true,
depthWrite: false,
opacity: 0.68
})
);
compass.rotation.x = -Math.PI / 2;
compass.position.set(0, -0.018, 0.1);
scene.add(compass);
// Custom camera controls, implemented without external addons.
const target = new THREE.Vector3(0, 1.05, 0);
let yaw = 0;
let pitch = 0.29;
let radius = innerWidth < 760 ? 14.3 : 10.7;
let targetYaw = yaw;
let targetPitch = pitch;
let targetRadius = radius;
let dragging = false;
let lastX = 0;
let lastY = 0;
function resetCamera() {
targetYaw = 0;
targetPitch = 0.29;
targetRadius = innerWidth < 760 ? 14.3 : 10.7;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
targetYaw -= dx * 0.006;
targetPitch = THREE.MathUtils.clamp(targetPitch + dy * 0.0045, 0.10, 1.08);
});
function endDrag(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (event && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
targetRadius = THREE.MathUtils.clamp(
targetRadius + event.deltaY * 0.008,
6.2,
18
);
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
renderer.domElement.style.cursor = "grab";
const referenceAnchor = new THREE.Vector3(-2.3, 2.72, 0);
const solarAnchor = new THREE.Vector3(2.3, 1.85, 0);
const referenceLabel = document.getElementById("referenceLabel");
const solarLabel = document.getElementById("solarLabel");
const projected = new THREE.Vector3();
function placeLabel(element, worldPosition) {
if (innerWidth <= 760) return;
projected.copy(worldPosition).project(camera);
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity = projected.z > 1 ? ".25" : "1";
}
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
addEventListener("resize", resize);
function animate() {
yaw += (targetYaw - yaw) * 0.09;
pitch += (targetPitch - pitch) * 0.09;
radius += (targetRadius - radius) * 0.09;
const horizontalRadius = Math.cos(pitch) * radius;
camera.position.set(
target.x + Math.sin(yaw) * horizontalRadius,
target.y + Math.sin(pitch) * radius,
target.z + Math.cos(yaw) * horizontalRadius
);
camera.lookAt(target);
sunHalo.material.opacity = 0.15 + Math.sin(performance.now() * 0.0008) * 0.015;
placeLabel(referenceLabel, referenceAnchor);
placeLabel(solarLabel, solarAnchor);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```