Prompt specification
Build or customize the Three.js 3D scene "Voxel Resolution Transfer Study" 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: Voxel Resolution Transfer Study
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/voxel-resolution-transfer-study-x3756
Scene Description Prompt:
Create one original character at three voxel resolutions, showing preserved identity cues and lost details. Three.js from cdnjs, one HTML file.
Working Three.js Starter (voxel-resolution-transfer-study-x3756):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mallow — Voxel Identity Study</title>
<style>
:root {
--bg: #071219;
--panel: rgba(9, 25, 33, 0.78);
--line: rgba(146, 220, 225, 0.18);
--text: #edf8f7;
--muted: #8ca8ad;
--cyan: #72f4e8;
--coral: #ff6b5f;
--gold: #ffc35c;
--ivory: #e7d7b3;
--mint: #79c6a5;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.vignette {
position: fixed;
inset: 0;
pointer-events: none;
background:
radial-gradient(
ellipse at 50% 42%,
transparent 35%,
rgba(2, 8, 12, 0.2) 72%,
rgba(2, 8, 12, 0.65) 100%
);
z-index: 2;
}
.header {
position: fixed;
z-index: 5;
top: 28px;
left: 32px;
max-width: 470px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
color: var(--cyan);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.24em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 30px;
height: 1px;
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
h1 {
margin: 0;
font-size: clamp(29px, 3.4vw, 48px);
font-weight: 760;
letter-spacing: -0.045em;
line-height: 0.98;
}
h1 span {
color: var(--muted);
font-weight: 430;
}
.subtitle {
max-width: 430px;
margin: 15px 0 0;
color: #a9bec1;
font-size: 13px;
line-height: 1.6;
}
.identity-panel {
position: fixed;
z-index: 5;
top: 28px;
right: 28px;
width: 272px;
padding: 18px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
backdrop-filter: blur(16px);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
}
.panel-title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 14px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.panel-title span:last-child {
color: var(--cyan);
}
.section-label {
margin: 14px 0 8px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.cue-list {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px 8px;
}
.cue {
display: flex;
align-items: center;
gap: 7px;
color: #d4e3e3;
font-size: 11px;
}
.dot {
width: 8px;
height: 8px;
flex: 0 0 auto;
border-radius: 2px;
box-shadow: 0 0 12px currentColor;
}
.dot.ivory { background: var(--ivory); color: var(--ivory); }
.dot.cyan { background: var(--cyan); color: var(--cyan); }
.dot.coral { background: var(--coral); color: var(--coral); }
.dot.gold { background: var(--gold); color: var(--gold); }
.loss-list {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.loss-list span {
padding: 5px 7px;
border: 1px solid rgba(255, 107, 95, 0.15);
border-radius: 5px;
background: rgba(255, 107, 95, 0.06);
color: #b99a99;
font-size: 9px;
}
.world-label {
position: fixed;
z-index: 4;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
transform: translate(-50%, -100%);
border: 1px solid rgba(141, 225, 227, 0.2);
border-radius: 8px;
background: rgba(5, 19, 26, 0.75);
backdrop-filter: blur(10px);
pointer-events: none;
white-space: nowrap;
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.22);
}
.world-label::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
width: 1px;
height: 17px;
background: linear-gradient(rgba(114, 244, 232, 0.55), transparent);
}
.world-label b {
color: var(--cyan);
font-size: 9px;
letter-spacing: 0.13em;
}
.world-label span {
color: #b8cbce;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.bottom-grid {
position: fixed;
z-index: 5;
left: 50%;
bottom: 67px;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
width: min(960px, calc(100% - 48px));
transform: translateX(-50%);
pointer-events: none;
}
.resolution-card {
min-height: 91px;
padding: 13px 15px;
border: 1px solid var(--line);
border-top: 2px solid var(--accent);
border-radius: 10px;
background: rgba(7, 22, 29, 0.74);
backdrop-filter: blur(12px);
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}
.card-head {
display: flex;
justify-content: space-between;
align-items: baseline;
gap: 8px;
margin-bottom: 5px;
}
.card-head b {
color: var(--accent);
font-size: 10px;
letter-spacing: 0.13em;
}
.card-head span {
color: #67878c;
font-size: 9px;
font-variant-numeric: tabular-nums;
}
.resolution-card p {
margin: 0 0 7px;
color: #d6e5e5;
font-size: 11px;
font-weight: 650;
}
.card-detail {
color: #829da2;
font-size: 9px;
line-height: 1.45;
}
.controls {
position: fixed;
z-index: 6;
left: 50%;
bottom: 17px;
display: flex;
align-items: center;
gap: 8px;
transform: translateX(-50%);
}
button {
padding: 8px 12px;
border: 1px solid rgba(136, 208, 211, 0.2);
border-radius: 7px;
background: rgba(8, 25, 32, 0.86);
color: #bcd1d3;
font: inherit;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
cursor: pointer;
transition:
border-color 160ms ease,
color 160ms ease,
background 160ms ease;
}
button:hover {
border-color: rgba(114, 244, 232, 0.55);
background: rgba(13, 38, 46, 0.95);
color: var(--cyan);
}
.hint {
margin-left: 5px;
color: #607d82;
font-size: 9px;
letter-spacing: 0.04em;
white-space: nowrap;
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
background: var(--bg);
color: var(--cyan);
font-size: 10px;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.identity-panel {
display: none;
}
.header {
top: 20px;
left: 22px;
}
.subtitle {
max-width: 360px;
font-size: 12px;
}
}
@media (max-width: 650px) {
.header {
top: 17px;
left: 18px;
}
h1 {
font-size: 29px;
}
.subtitle {
display: none;
}
.bottom-grid {
bottom: 63px;
width: calc(100% - 24px);
gap: 5px;
}
.resolution-card {
min-height: 72px;
padding: 9px 8px;
}
.card-head {
display: block;
}
.card-head b,
.card-head span {
display: block;
}
.resolution-card p {
font-size: 9px;
}
.card-detail {
display: none;
}
.hint {
display: none;
}
.controls {
bottom: 15px;
}
.world-label {
padding: 5px 7px;
}
.world-label span {
display: none;
}
}
</style>
</head>
<body>
<div class="loading" id="loading">Building the voxel study…</div>
<div class="vignette"></div>
<header class="header">
<div class="eyebrow">Voxel identity study / 01</div>
<h1>MALLOW <span>Comet Courier</span></h1>
<p class="subtitle">
One original character, reconstructed at three voxel resolutions.
Follow the cyan eye, coral scarf, ivory hood, and amber lantern—the
identity survives even as fine construction details disappear.
</p>
</header>
<aside class="identity-panel">
<div class="panel-title">
<span>Identity cues</span>
<span>4 / 4 survive</span>
</div>
<div class="section-label">Preserved at lowest resolution</div>
<div class="cue-list">
<div class="cue"><i class="dot ivory"></i>Hood silhouette</div>
<div class="cue"><i class="dot cyan"></i>Cyan cyclops</div>
<div class="cue"><i class="dot coral"></i>Streaming scarf</div>
<div class="cue"><i class="dot gold"></i>Hand lantern</div>
</div>
<div class="section-label">Lost detail</div>
<div class="loss-list">
<span>stitching</span>
<span>straps</span>
<span>freckles</span>
<span>lattice</span>
</div>
</aside>
<div class="world-label" id="label-high">
<b>HIGH</b><span>30 × 42 × 22</span>
</div>
<div class="world-label" id="label-mid">
<b>MID</b><span>18 × 24 × 12</span>
</div>
<div class="world-label" id="label-low">
<b>LOW</b><span>9 × 13 × 7</span>
</div>
<section class="bottom-grid">
<article class="resolution-card" style="--accent: #72f4e8">
<div class="card-head">
<b>HIGH / 42-LINE</b>
<span>30 × 42 × 22</span>
</div>
<p>Full character construction</p>
<div class="card-detail">
Lens rim, coat seams, straps, freckles, stitching, buckles, and lantern lattice.
</div>
</article>
<article class="resolution-card" style="--accent: #ffc35c">
<div class="card-head">
<b>MID / 24-LINE</b>
<span>18 × 24 × 12</span>
</div>
<p>Micro-detail begins to merge</p>
<div class="card-detail">
Hardware and lantern framing remain; stitching, freckles, and thin seams fade.
</div>
</article>
<article class="resolution-card" style="--accent: #ff6b5f">
<div class="card-head">
<b>LOW / 13-LINE</b>
<span>9 × 13 × 7</span>
</div>
<p>Only bold identity cues survive</p>
<div class="card-detail">
Hood shape, cyan eye, coral scarf, and amber lantern remain instantly readable.
</div>
</article>
</section>
<nav class="controls" aria-label="Scene controls">
<button id="orbitButton" type="button">Auto orbit: on</button>
<button id="resetButton" type="button">Reset view</button>
<span class="hint">Drag to orbit · scroll to zoom · double-click to reset</span>
</nav>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const loading = document.getElementById("loading");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x071219);
scene.fog = new THREE.FogExp2(0x071219, 0.032);
const camera = new THREE.PerspectiveCamera(
37,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xa7e6ee, 0x071017, 1.65);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xffe3b8, 3.2);
key.position.set(5, 9, 7);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -13;
key.shadow.camera.right = 13;
key.shadow.camera.top = 12;
key.shadow.camera.bottom = -5;
key.shadow.camera.near = 0.5;
key.shadow.camera.far = 35;
key.shadow.bias = -0.00035;
scene.add(key);
const rim = new THREE.DirectionalLight(0x58d9df, 2.1);
rim.position.set(-8, 5, -6);
scene.add(rim);
const frontGlow = new THREE.PointLight(0x7ceee7, 14, 18, 2);
frontGlow.position.set(0, 5, 5);
scene.add(frontGlow);
const normalMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.76,
metalness: 0.04
});
const metalMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.34,
metalness: 0.72
});
const eyeMaterial = new THREE.MeshStandardMaterial({
color: 0xbffff8,
emissive: 0x3fffea,
emissiveIntensity: 2.35,
roughness: 0.22,
metalness: 0.08
});
const lanternMaterial = new THREE.MeshStandardMaterial({
color: 0xffe8aa,
emissive: 0xff9f2e,
emissiveIntensity: 2.15,
roughness: 0.36,
metalness: 0.08
});
const palette = {
coat: 0x197e87,
coatDark: 0x0e4d59,
hood: 0xe7d7b3,
hoodShade: 0xc7b486,
skin: 0xda9b74,
freckle: 0x9e5c50,
scarf: 0xf05e52,
scarfDark: 0xa93f48,
dark: 0x152633,
backpack: 0x70b997,
brass: 0xc58a2d,
boot: 0x39434a,
buckle: 0xe4aa43,
button: 0xffd477
};
const metalKeys = new Set(["brass", "buckle", "button"]);
const voxelGeometry = new THREE.BoxGeometry(1, 1, 1);
function inBox(x, y, z, cx, cy, cz, hx, hy, hz) {
return (
Math.abs(x - cx) <= hx &&
Math.abs(y - cy) <= hy &&
Math.abs(z - cz) <= hz
);
}
function inEllipsoid(x, y, z, cx, cy, cz, rx, ry, rz) {
const dx = (x - cx) / rx;
const dy = (y - cy) / ry;
const dz = (z - cz) / rz;
return dx * dx + dy * dy + dz * dz <= 1;
}
function shapeAt(x, y, z) {
const boot =
inBox(x, y, z, -0.28, 0.085, 0.08, 0.13, 0.085, 0.22) ||
inBox(x, y, z, 0.28, 0.085, 0.08, 0.13, 0.085, 0.22);
const leg =
inBox(x, y, z, -0.27, 0.25, 0, 0.095, 0.18, 0.14) ||
inBox(x, y, z, 0.27, 0.25, 0, 0.095, 0.18, 0.14);
const torso = inBox(
x, y, z,
0, 0.475, 0,
0.43, 0.18, 0.225
);
const arm =
inBox(x, y, z, -0.49, 0.49, 0.01, 0.11, 0.14, 0.13) ||
inBox(x, y, z, 0.49, 0.49, 0.01, 0.11, 0.14, 0.13);
const hand =
inEllipsoid(x, y, z, -0.59, 0.40, 0.06, 0.09, 0.08, 0.10) ||
inEllipsoid(x, y, z, 0.61, 0.47, 0.08, 0.09, 0.08, 0.10);
const head = inEllipsoid(
x, y, z,
0, 0.75, 0,
0.31, 0.25, 0.23
);
const hatBrim = inBox(
x, y, z,
0, 0.812, 0.16,
0.45, 0.03, 0.27
);
const tuft = inBox(
x, y, z,
0.19, 0.94, -0.01,
0.12, 0.07, 0.08
);
const scarfBand = inBox(
x, y, z,
0, 0.632, 0.02,
0.39, 0.048, 0.29
);
const scarfTail = inBox(
x, y, z,
-0.43, 0.59, 0.08,
0.15, 0.10, 0.25
);
const backpack = inBox(
x, y, z,
0, 0.46, -0.27,
0.29, 0.14, 0.11
);
const lanternBody = inBox(
x, y, z,
0.73, 0.47, 0.10,
0.10, 0.11, 0.24
);
const lanternHandle = inBox(
x, y, z,
0.73, 0.61, 0.08,
0.045, 0.055, 0.045
);
return {
boot,
leg,
torso,
arm,
hand,
head,
hatBrim,
tuft,
scarfBand,
scarfTail,
backpack,
lanternBody,
lanternHandle
};
}
function classifyVoxel(x, y, z, shape, detail, ix, iy, iz) {
// Lantern: the illuminated core survives every resolution.
if (shape.lanternBody) {
const frame =
detail >= 1 &&
(
Math.abs(x - 0.65) < 0.022 ||
Math.abs(x - 0.81) < 0.022 ||
Math.abs(y - 0.47) < 0.020 ||
Math.abs(y - 0.575) < 0.020
);
return frame ? "brass" : "glow";
}
if (shape.lanternHandle) {
return "brass";
}
// One large central cyclops lens is deliberately robust under sampling.
if (
z > 0.60 &&
y > 0.675 &&
y < 0.790 &&
Math.abs(x) < 0.085
) {
if (detail >= 2 && Math.abs(x) > 0.045) {
return "brass";
}
if (
Math.abs(x) < 0.048 &&
Math.abs(y - 0.735) < 0.052
) {
return "eye";
}
return "coatDark";
}
if (shape.scarfBand || shape.scarfTail) {
if (
detail === 2 &&
z > 0.15 &&
(
Math.abs(y - 0.655) < 0.018 ||
(shape.scarfTail && x < -0.54)
)
) {
return "scarfDark";
}
return "scarf";
}
if (shape.hatBrim) {
if (
detail === 2 &&
y > 0.807 &&
y < 0.826 &&
z > 0.03
) {
return "brass";
}
return "hood";
}
if (shape.tuft) {
return "hood";
}
if (shape.head) {
const face =
z > 0.10 &&
y > 0.63 &&
y < 0.79 &&
Math.abs(x) < 0.28;
if (face) {
if (
detail === 2 &&
z > 0.58 &&
(
(Math.floor((x + 1) * 19) * 13 +
Math.floor(y * 31) * 7) % 29 === 0
)
) {
return "freckle";
}
return "skin";
}
return "hood";
}
if (shape.backpack) {
return "backpack";
}
if (shape.hand) {
return "skin";
}
if (shape.arm) {
if (detail >= 1 && y < 0.405) {
return "coatDark";
}
return "coat";
}
if (shape.torso) {
// Fine straps and center seam exist only in the high-resolution build.
if (
detail === 2 &&
z > 0.13 &&
y > 0.34 &&
y < 0.59 &&
Math.abs(Math.abs(x) - 0.23) < 0.024
) {
return "dark";
}
if (
detail === 2 &&
z > 0.13 &&
y > 0.33 &&
y < 0.59 &&
Math.abs(x - 0.033) < 0.017
) {
return "coatDark";
}
if (
detail === 2 &&
z > 0.13 &&
Math.abs(x - 0.033) < 0.035 &&
(
Math.abs(y - 0.385) < 0.018 ||
Math.abs(y - 0.455) < 0.018 ||
Math.abs(y - 0.525) < 0.018
)
) {
return "button";
}
if (
detail >= 1 &&
z > 0.14 &&
y > 0.345 &&
y < 0.385
) {
return "dark";
}
return "coat";
}
if (shape.boot) {
if (
detail >= 1 &&
z > 0.18 &&
Math.abs(Math.abs(x) - 0.28) < 0.055
) {
return "buckle";
}
return "boot";
}
if (shape.leg) {
return "dark";
}
return "coat";
}
function buildVoxelCharacter(grid, detailLevel) {
const [nx, ny, nz] = grid;
const characterHeight = 3.9;
const cell = characterHeight / ny;
const buckets = new Map();
for (let iy = 0; iy < ny; iy++) {
for (let ix = 0; ix < nx; ix++) {
for (let iz = 0; iz < nz; iz++) {
const x = ((ix + 0.5) / nx) * 2 - 1;
const y = (iy + 0.5) / ny;
const z = ((iz + 0.5) / nz) * 2 - 1;
const shape = shapeAt(x, y, z);
const occupied =
shape.boot ||
shape.leg ||
shape.torso ||
shape.arm ||
shape.hand ||
shape.head ||
shape.hatBrim ||
shape.tuft ||
shape.scarfBand ||
shape.scarfTail ||
shape.backpack ||
shape.lanternBody ||
shape.lanternHandle;
if (!occupied) continue;
const materialKey = classifyVoxel(
x, y, z, shape, detailLevel, ix, iy, iz
);
if (!buckets.has(materialKey)) {
buckets.set(materialKey, []);
}
buckets.get(materialKey).push({
x: (ix - (nx - 1) / 2) * cell,
y: (iy + 0.5) * cell,
z: (iz - (nz - 1) / 2) * cell,
shade: 0.91 + ((ix * 7 + iy * 5 + iz * 3) % 10) * 0.016
});
}
}
}
const group = new THREE.Group();
const matrix = new THREE.Matrix4();
const position = new THREE.Vector3();
const scale = new THREE.Vector3();
const quaternion = new THREE.Quaternion();
const gap = detailLevel === 2 ? 0.91 : detailLevel === 1 ? 0.93 : 0.94;
for (const [key, voxels] of buckets) {
let material;
if (key === "eye") {
material = eyeMaterial;
} else if (key === "glow") {
material = lanternMaterial;
} else if (metalKeys.has(key)) {
material = metalMaterial;
} else {
material = normalMaterial;
}
const mesh = new THREE.InstancedMesh(
voxelGeometry,
material,
voxels.length
);
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.frustumCulled = false;
voxels.forEach((voxel, index) => {
position.set(voxel.x, voxel.y, voxel.z);
scale.setScalar(cell * gap);
matrix.compose(position, quaternion, scale);
mesh.setMatrixAt(index, matrix);
if (key !== "eye" && key !== "glow") {
const color = new THREE.Color(palette[key]);
color.multiplyScalar(voxel.shade);
mesh.setColorAt(index, color);
}
});
mesh.instanceMatrix.needsUpdate = true;
if (mesh.instanceColor) {
mesh.instanceColor.needsUpdate = true;
}
group.add(mesh);
}
return group;
}
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(42, 42),
new THREE.MeshStandardMaterial({
color: 0x08161d,
roughness: 0.95,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.23;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(42, 42, 0x21434c, 0x102a33);
grid.position.y = -0.225;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const pedestalMaterial = new THREE.MeshStandardMaterial({
color: 0x0c2029,
roughness: 0.62,
metalness: 0.25
});
const pedestalTopMaterial = new THREE.MeshStandardMaterial({
color: 0x102b34,
roughness: 0.78,
metalness: 0.08
});
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0x4dc9c8,
transparent: true,
opacity: 0.32,
side: THREE.DoubleSide,
depthWrite: false
});
const specifications = [
{
grid: [30, 42, 22],
detail: 2,
label: document.getElementById("label-high")
},
{
grid: [18, 24, 12],
detail: 1,
label: document.getElementById("label-mid")
},
{
grid: [9, 13, 7],
detail: 0,
label: document.getElementById("label-low")
}
];
const models = [];
const positions = [-4.65, 0, 4.65];
specifications.forEach((specification, index) => {
const x = positions[index];
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(1.58, 1.7, 0.2, 64),
pedestalMaterial
);
pedestal.position.set(x, -0.12, 0);
pedestal.castShadow = true;
pedestal.receiveShadow = true;
scene.add(pedestal);
const top = new THREE.Mesh(
new THREE.CircleGeometry(1.57, 64),
pedestalTopMaterial
);
top.rotation.x = -Math.PI / 2;
top.position.set(x, -0.014, 0);
top.receiveShadow = true;
scene.add(top);
const ring = new THREE.Mesh(
new THREE.RingGeometry(1.43, 1.455, 96),
ringMaterial.clone()
);
ring.rotation.x = -Math.PI / 2;
ring.position.set(x, 0.002, 0);
scene.add(ring);
const character = buildVoxelCharacter(
specification.grid,
specification.detail
);
character.position.set(x, 0.015, 0);
scene.add(character);
models.push({
group: character,
ring,
label: specification.label,
x
});
});
// Sparse atmospheric points.
const particlePositions = new Float32Array(360 * 3);
for (let i = 0; i < 360; i++) {
particlePositions[i * 3] = (Math.random() - 0.5) * 28;
particlePositions[i * 3 + 1] = Math.random() * 9 - 0.1;
particlePositions[i * 3 + 2] = (Math.random() - 0.5) * 18;
}
const particleGeometry = new THREE.BufferGeometry();
particleGeometry.setAttribute(
"position",
new THREE.BufferAttribute(particlePositions, 3)
);
const particles = new THREE.Points(
particleGeometry,
new THREE.PointsMaterial({
color: 0x75d9d7,
size: 0.022,
transparent: true,
opacity: 0.42,
depthWrite: false
})
);
scene.add(particles);
const target = new THREE.Vector3(0, 1.65, 0);
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
let yaw = 0.12;
let pitch = 1.33;
let radius = innerWidth < 650 ? 31.5 : 15.5;
let autoOrbit = !reducedMotion;
let dragging = false;
let pointerX = 0;
let pointerY = 0;
const orbitButton = document.getElementById("orbitButton");
const resetButton = document.getElementById("resetButton");
function updateOrbitButton() {
orbitButton.textContent = `Auto orbit: ${autoOrbit ? "on" : "off"}`;
orbitButton.setAttribute("aria-pressed", String(autoOrbit));
}
function resetView() {
yaw = innerWidth < 650 ? 0 : 0.12;
pitch = 1.33;
radius = innerWidth < 650 ? 31.5 : 15.5;
target.set(0, 1.65, 0);
updateOrbitButton();
}
updateOrbitButton();
orbitButton.addEventListener("click", () => {
autoOrbit = !autoOrbit;
updateOrbitButton();
});
resetButton.addEventListener("click", resetView);
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
autoOrbit = false;
updateOrbitButton();
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
yaw -= deltaX * 0.006;
pitch = THREE.MathUtils.clamp(
pitch + deltaY * 0.005,
0.56,
1.48
);
pointerX = event.clientX;
pointerY = event.clientY;
});
function endDrag(event) {
dragging = false;
if (
renderer.domElement.hasPointerCapture &&
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();
radius = THREE.MathUtils.clamp(
radius + event.deltaY * 0.009,
innerWidth < 650 ? 19 : 9,
40
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
const labelVector = new THREE.Vector3();
function updateLabels() {
for (const model of models) {
labelVector.set(model.x, 4.19, 0).project(camera);
const visible = labelVector.z > -1 && labelVector.z < 1;
model.label.style.opacity = visible ? "1" : "0";
model.label.style.left =
`${(labelVector.x * 0.5 + 0.5) * innerWidth}px`;
model.label.style.top =
`${(-labelVector.y * 0.5 + 0.5) * innerHeight}px`;
}
}
function resize() {
const mobile = innerWidth < 650;
camera.aspect = innerWidth / innerHeight;
camera.fov = mobile ? 48 : 37;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
let previousTime = performance.now();
function animate(now) {
requestAnimationFrame(animate);
const dt = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
const elapsed = clock.getElapsedTime();
if (autoOrbit && !dragging && !reducedMotion) {
yaw += dt * 0.045;
}
const horizontalRadius = Math.sin(pitch) * radius;
camera.position.set(
target.x + Math.sin(yaw) * horizontalRadius,
target.y + Math.cos(pitch) * radius,
target.z + Math.cos(yaw) * horizontalRadius
);
camera.lookAt(target);
models.forEach((model, index) => {
if (!reducedMotion) {
model.group.position.y =
0.015 + Math.sin(elapsed * 1.15 + index * 0.8) * 0.018;
}
model.ring.material.opacity =
0.26 + Math.sin(elapsed * 1.5 + index) * 0.055;
});
eyeMaterial.emissiveIntensity =
2.25 + Math.sin(elapsed * 2.1) * 0.16;
lanternMaterial.emissiveIntensity =
2.05 + Math.sin(elapsed * 1.7 + 0.8) * 0.18;
particles.rotation.y = elapsed * 0.012;
particles.position.y = Math.sin(elapsed * 0.18) * 0.08;
updateLabels();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 450);
});
</script>
</body>
</html>
```