Prompt specification
Build or customize the Three.js 3D scene "Punched data card and field legend" 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: Punched data card and field legend
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/punched-data-card-and-field-legend-x2517
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a punched data card and encoding legend. Display a card with several labeled fields and punched positions. Use fictional records and an explicit encoding scheme rather than reproducing personal historical data. Stylized solid forms.
Working Three.js Starter (punched-data-card-and-field-legend-x2517):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<title>Punch Field — Synthetic Record Card</title>
<style>
:root {
--bg: #0b2729;
--bg-deep: #071c1e;
--paper: #efe5d0;
--paper-dark: #d8cbb4;
--ink: #173638;
--muted: #66756d;
--accent: #ed6a3b;
--accent-dark: #a94026;
--line: rgba(239, 229, 208, 0.22);
--mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
--sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--paper);
font-family: var(--sans);
}
body {
position: relative;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
#scene canvas.dragging {
cursor: grabbing;
}
.brand {
position: fixed;
z-index: 4;
top: 26px;
left: 30px;
pointer-events: none;
text-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}
.brand-kicker {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 8px;
color: #b8c6bc;
font-family: var(--mono);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.brand-kicker::before {
width: 9px;
height: 9px;
content: "";
background: var(--accent);
}
.brand h1 {
margin: 0;
font-size: clamp(24px, 2.5vw, 38px);
font-weight: 750;
letter-spacing: -0.045em;
line-height: 0.95;
}
.brand h1 span {
color: var(--accent);
}
.brand p {
max-width: 340px;
margin: 11px 0 0;
color: #a9bab1;
font-family: var(--mono);
font-size: 10px;
letter-spacing: 0.08em;
line-height: 1.6;
text-transform: uppercase;
}
.legend {
position: fixed;
z-index: 5;
top: 24px;
right: 24px;
width: 342px;
max-height: calc(100vh - 48px);
padding: 26px 25px 24px;
overflow: auto;
color: var(--ink);
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.38);
border-top: 8px solid var(--accent);
box-shadow: 11px 11px 0 var(--bg-deep);
scrollbar-width: thin;
scrollbar-color: var(--accent) var(--paper-dark);
}
.legend-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
margin-bottom: 21px;
}
.legend-kicker {
margin: 0 0 5px;
color: var(--accent-dark);
font-family: var(--mono);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.legend h2 {
margin: 0;
font-size: 25px;
line-height: 1;
letter-spacing: -0.045em;
}
.legend-mark {
display: grid;
flex: 0 0 auto;
width: 42px;
height: 42px;
place-items: center;
color: var(--paper);
background: var(--ink);
font-family: var(--mono);
font-size: 15px;
font-weight: 800;
}
.legend-section {
padding-top: 18px;
border-top: 1px solid rgba(23, 54, 56, 0.18);
}
.legend-section:first-of-type {
padding-top: 0;
border-top: 0;
}
.legend h3 {
margin: 0 0 12px;
color: var(--muted);
font-family: var(--mono);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.field-table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.field-table th {
padding: 0 0 8px;
color: var(--muted);
font-family: var(--mono);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-align: left;
text-transform: uppercase;
}
.field-table th:last-child,
.field-table td:last-child {
text-align: right;
}
.field-table td {
padding: 9px 0;
border-top: 1px solid rgba(23, 54, 56, 0.13);
}
.field-table td:first-child {
width: 28px;
color: var(--accent-dark);
font-family: var(--mono);
font-weight: 800;
}
.field-table td:nth-child(2) {
font-weight: 700;
letter-spacing: 0.02em;
}
.field-table td:last-child {
font-family: var(--mono);
font-weight: 800;
letter-spacing: 0.08em;
}
.bit-guide {
display: grid;
grid-template-columns: 42px 1fr;
gap: 8px 13px;
align-items: center;
margin: 4px 0 15px;
}
.bit-weight {
font-family: var(--mono);
font-size: 12px;
font-weight: 800;
text-align: right;
}
.bit-line {
position: relative;
height: 11px;
border-bottom: 1px solid rgba(23, 54, 56, 0.26);
}
.punch-symbol {
position: absolute;
bottom: -5px;
left: 7px;
width: 9px;
height: 9px;
background: var(--ink);
border-radius: 50%;
box-shadow: inset 0 0 0 2px var(--paper);
}
.legend-copy {
margin: 0;
color: #435650;
font-size: 12px;
line-height: 1.65;
}
.legend-copy strong {
color: var(--ink);
}
.mapping {
margin-top: 12px;
padding: 12px 13px;
color: var(--ink);
background: #dfd3bd;
font-family: var(--mono);
font-size: 11px;
line-height: 1.8;
}
.mapping b {
color: var(--accent-dark);
}
.fiction-note {
margin: 17px 0 0;
padding: 12px 13px 12px 37px;
position: relative;
color: var(--ink);
background: var(--accent);
font-size: 11px;
font-weight: 750;
line-height: 1.45;
}
.fiction-note::before {
position: absolute;
top: 13px;
left: 14px;
width: 11px;
height: 11px;
content: "";
border: 3px solid var(--paper);
border-radius: 50%;
}
.controls {
position: fixed;
z-index: 6;
bottom: 24px;
left: 30px;
display: flex;
align-items: center;
gap: 15px;
pointer-events: none;
}
.control-copy {
color: #9eb1a8;
font-family: var(--mono);
font-size: 10px;
letter-spacing: 0.07em;
text-transform: uppercase;
}
.reset-button {
padding: 9px 13px;
color: var(--paper);
background: var(--bg-deep);
border: 1px solid var(--line);
font-family: var(--mono);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
pointer-events: auto;
}
.reset-button:hover,
.reset-button:focus-visible {
color: var(--bg-deep);
background: var(--accent);
border-color: var(--accent);
outline: none;
}
.loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
color: var(--paper);
background: var(--bg);
font-family: var(--mono);
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 250ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 860px) {
.brand {
top: 17px;
left: 18px;
}
.brand h1 {
font-size: 26px;
}
.brand p {
display: none;
}
.legend {
top: auto;
right: 14px;
bottom: 52px;
left: 14px;
width: auto;
max-height: 35vh;
padding: 20px 20px 18px;
border-top-width: 6px;
box-shadow: 7px 7px 0 var(--bg-deep);
}
.legend-header {
margin-bottom: 14px;
}
.legend h2 {
font-size: 21px;
}
.controls {
right: 14px;
bottom: 12px;
left: 14px;
justify-content: space-between;
}
.control-copy {
font-size: 8px;
}
}
@media (max-width: 430px) {
.brand-kicker {
font-size: 8px;
}
.brand h1 {
font-size: 23px;
}
.legend {
max-height: 33vh;
}
.control-copy {
max-width: 210px;
line-height: 1.5;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="brand">
<div class="brand-kicker">Synthetic record system / 07</div>
<h1>PUNCH<span> /</span> FIELD</h1>
<p>Orbital survey training card · invented records · explicit six-bit encoding</p>
</header>
<aside class="legend" aria-label="Encoding legend">
<div class="legend-header">
<div>
<p class="legend-kicker">Reference / scheme 6B</p>
<h2>Encoding legend</h2>
</div>
<div class="legend-mark" aria-hidden="true">6B</div>
</div>
<section class="legend-section">
<h3>Fictional field map</h3>
<table class="field-table">
<thead>
<tr>
<th>Zone</th>
<th>Field</th>
<th>Decoded</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>RECORD ID</td>
<td>K204</td>
</tr>
<tr>
<td>B</td>
<td>SAMPLE</td>
<td>X7</td>
</tr>
<tr>
<td>C</td>
<td>NODE</td>
<td>L12</td>
</tr>
<tr>
<td>D</td>
<td>STATE</td>
<td>OK</td>
</tr>
</tbody>
</table>
</section>
<section class="legend-section">
<h3>Six-bit vertical character code</h3>
<div class="bit-guide" aria-label="Binary row weights from top to bottom">
<div class="bit-weight">32</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
<div class="bit-weight">16</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
<div class="bit-weight">08</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
<div class="bit-weight">04</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
<div class="bit-weight">02</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
<div class="bit-weight">01</div>
<div class="bit-line"><span class="punch-symbol"></span></div>
</div>
<p class="legend-copy">
Read each character column from <strong>top to bottom</strong>.
A <strong>punched hole means 1</strong>; an empty position means 0.
</p>
<div class="mapping">
<b>CHARACTER MAP</b><br>
A–Z = 01–26<br>
0–9 = 27–36<br>
Example: L = 12 = <strong>001100</strong>
</div>
</section>
<p class="fiction-note">
All names, codes, samples, and orbital nodes on this card are invented.
It does not reproduce personal or historical record data.
</p>
</aside>
<div class="controls">
<div class="control-copy">Drag to orbit · scroll to zoom · double-click to reset</div>
<button class="reset-button" id="reset" type="button">Reset view</button>
</div>
<div class="loading" id="loading">Loading synthetic field card…</div>
<noscript>
<div class="loading">JavaScript is required to display the Three.js card.</div>
</noscript>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const CARD_W = 10;
const CARD_H = 6;
const ROW_WEIGHTS = [32, 16, 8, 4, 2, 1];
const ROW_Y = [0.10, -0.20, -0.50, -0.80, -1.10, -1.40];
const fields = [
{
key: "A",
label: "A · RECORD ID",
value: "K204",
x0: -4.62,
x1: -1.45,
grid: [-4.22, -3.73, -3.24, -2.75]
},
{
key: "B",
label: "B · SAMPLE",
value: "X7",
x0: -1.10,
x1: 0.92,
grid: [-0.72, -0.22]
},
{
key: "C",
label: "C · NODE",
value: "L12",
x0: 1.28,
x1: 3.38,
grid: [1.62, 2.12, 2.62]
},
{
key: "D",
label: "D · STATE",
value: "OK",
x0: 3.72,
x1: 4.64,
grid: [3.96, 4.46]
}
];
function characterCode(character) {
if (character >= "A" && character <= "Z") {
return character.charCodeAt(0) - 64;
}
if (character >= "0" && character <= "9") {
return 27 + Number(character);
}
throw new Error(`Unsupported fictional character: ${character}`);
}
const punches = [];
const allSlots = [];
for (const field of fields) {
field.codes = [...field.value].map(characterCode);
field.value.split("").forEach((character, characterIndex) => {
const code = field.codes[characterIndex];
const x = field.grid[characterIndex];
ROW_WEIGHTS.forEach((weight, rowIndex) => {
const isPunched = (code & weight) !== 0;
const slot = {
x,
y: ROW_Y[rowIndex],
rowIndex,
characterIndex,
isPunched
};
allSlots.push(slot);
if (isPunched) {
punches.push({ x, y: ROW_Y[rowIndex] });
}
});
});
}
const sceneContainer = document.getElementById("scene");
const loading = document.getElementById("loading");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL could not be initialized.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x0b2729, 1);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional punched data card. Drag to orbit and scroll to zoom."
);
renderer.domElement.tabIndex = 0;
sceneContainer.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x0b2729, 24, 48);
const camera = new THREE.PerspectiveCamera(
35,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3();
const clock = new THREE.Clock();
let isMobile = false;
let cardBaseX = -1.45;
let cardBaseY = 0;
let minRadius = 10;
let maxRadius = 24;
let targetTheta = 0.045;
let targetPhi = 1.36;
let targetRadius = 15.8;
let currentTheta = targetTheta;
let currentPhi = targetPhi;
let currentRadius = targetRadius;
const ambient = new THREE.AmbientLight(0xfff5df, 1.35);
scene.add(ambient);
const keyLight = new THREE.DirectionalLight(0xfff0d2, 3.1);
keyLight.position.set(-5, 7, 11);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00025;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x92bfc1, 1.25);
fillLight.position.set(7, -3, 7);
scene.add(fillLight);
const warmLight = new THREE.PointLight(0xed6a3b, 26, 24, 2);
warmLight.position.set(-6, 1.5, 5);
scene.add(warmLight);
// Solid background forms.
const backgroundDisc = new THREE.Mesh(
new THREE.CircleGeometry(4.2, 64),
new THREE.MeshBasicMaterial({ color: 0x123638 })
);
backgroundDisc.position.set(-3.4, 2.5, -3.0);
scene.add(backgroundDisc);
const backgroundBlock = new THREE.Mesh(
new THREE.BoxGeometry(3.6, 3.6, 0.35),
new THREE.MeshBasicMaterial({ color: 0x0f3032 })
);
backgroundBlock.position.set(4.1, -2.4, -3.4);
backgroundBlock.rotation.z = Math.PI * 0.12;
scene.add(backgroundBlock);
const cardGroup = new THREE.Group();
cardGroup.rotation.set(-0.055, -0.075, -0.018);
scene.add(cardGroup);
function roundedRectShape(width, height, radius) {
const shape = new THREE.Shape();
const left = -width / 2;
const right = width / 2;
const bottom = -height / 2;
const top = height / 2;
shape.moveTo(left + radius, bottom);
shape.lineTo(right - radius, bottom);
shape.quadraticCurveTo(right, bottom, right, bottom + radius);
shape.lineTo(right, top - radius);
shape.quadraticCurveTo(right, top, right - radius, top);
shape.lineTo(left + radius, top);
shape.quadraticCurveTo(left, top, left, top - radius);
shape.lineTo(left, bottom + radius);
shape.quadraticCurveTo(left, bottom, left + radius, bottom);
return shape;
}
const cardShape = roundedRectShape(CARD_W, CARD_H, 0.29);
// Real holes are cut from the extruded card shape.
for (const punch of punches) {
const hole = new THREE.Path();
hole.absarc(punch.x, punch.y, 0.105, 0, Math.PI * 2, true);
cardShape.holes.push(hole);
}
// A dark solid backing makes every opening read clearly.
const backingGeometry = new THREE.ExtrudeGeometry(
roundedRectShape(CARD_W, CARD_H, 0.29),
{
depth: 0.08,
bevelEnabled: false,
curveSegments: 24
}
);
const backing = new THREE.Mesh(
backingGeometry,
new THREE.MeshStandardMaterial({
color: 0x153b3d,
roughness: 0.92,
metalness: 0
})
);
backing.position.z = -0.17;
backing.receiveShadow = true;
cardGroup.add(backing);
const cardGeometry = new THREE.ExtrudeGeometry(cardShape, {
depth: 0.26,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.018,
bevelThickness: 0.025,
curveSegments: 24
});
const cardFrontMaterial = new THREE.MeshStandardMaterial({
color: 0xf1e6d2,
roughness: 0.78,
metalness: 0
});
const cardEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0xc6b89d,
roughness: 0.92,
metalness: 0
});
const card = new THREE.Mesh(cardGeometry, [
cardFrontMaterial,
cardEdgeMaterial
]);
card.castShadow = true;
card.receiveShadow = true;
cardGroup.add(card);
// Raised orange index marker.
const indexMarker = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.64, 0.045),
new THREE.MeshStandardMaterial({
color: 0xed6a3b,
roughness: 0.65,
metalness: 0
})
);
indexMarker.position.set(-4.72, 2.47, 0.355);
indexMarker.castShadow = true;
cardGroup.add(indexMarker);
function createCardTexture() {
const canvas = document.createElement("canvas");
canvas.width = 1800;
canvas.height = 1080;
const context = canvas.getContext("2d");
const width = canvas.width;
const height = canvas.height;
const ink = "#173638";
const muted = "#6e776d";
const accent = "#d95730";
const rule = "rgba(23, 54, 56, 0.19)";
const lightRule = "rgba(23, 54, 56, 0.10)";
function px(x) {
return ((x + CARD_W / 2) / CARD_W) * width;
}
function py(y) {
return ((CARD_H / 2 - y) / CARD_H) * height;
}
function scale(value) {
return (value / CARD_W) * width;
}
function text(value, x, y, size, options = {}) {
context.save();
context.fillStyle = options.color || ink;
context.textAlign = options.align || "left";
context.textBaseline = options.baseline || "middle";
context.font =
`${options.weight || 500} ${size}px ${
options.mono
? '"SFMono-Regular", Consolas, "Liberation Mono", monospace'
: 'Inter, system-ui, sans-serif'
}`;
context.fillText(value, px(x), py(y));
context.restore();
}
function line(x0, y0, x1, y1, color = rule, lineWidth = 2) {
context.beginPath();
context.moveTo(px(x0), py(y0));
context.lineTo(px(x1), py(y1));
context.strokeStyle = color;
context.lineWidth = lineWidth;
context.stroke();
}
function roundedRect(x, y, w, h, radius, fill) {
const left = px(x);
const top = py(y + h);
const rectWidth = scale(w);
const rectHeight = scale(h);
const corner = scale(radius);
context.beginPath();
context.moveTo(left + corner, top);
context.lineTo(left + rectWidth - corner, top);
context.quadraticCurveTo(
left + rectWidth,
top,
left + rectWidth,
top + corner
);
context.lineTo(left + rectWidth, top + rectHeight - corner);
context.quadraticCurveTo(
left + rectWidth,
top + rectHeight,
left + rectWidth - corner,
top + rectHeight
);
context.lineTo(left + corner, top + rectHeight);
context.quadraticCurveTo(
left,
top + rectHeight,
left,
top + rectHeight - corner
);
context.lineTo(left, top + corner);
context.quadraticCurveTo(left, top, left + corner, top);
context.closePath();
context.fillStyle = fill;
context.fill();
}
context.clearRect(0, 0, width, height);
// Header.
text("ORBITAL SURVEY ARRAY", -4.34, 2.57, 46, {
weight: 750
});
text(
"SYNTHETIC FIELD CARD · SERIES 07 · SCHEME 6B",
-4.33,
2.13,
21,
{
color: muted,
mono: true,
weight: 700
}
);
text("RECORD / K204", 4.55, 2.58, 22, {
color: accent,
mono: true,
weight: 800,
align: "right"
});
text("TRAINING COPY", 4.55, 2.16, 18, {
color: muted,
mono: true,
weight: 700,
align: "right"
});
line(-4.68, 1.73, 4.68, 1.73, rule, 3);
// Vertical field separators.
[-1.28, 0.99, 3.53].forEach((x) => {
line(x, 1.50, x, -1.70, rule, 2);
});
for (const field of fields) {
const isNarrow = field.key === "D";
if (!isNarrow) {
roundedRect(field.x0, 1.13, 0.25, 0.25, 0.045, ink);
text(field.key, field.x0 + 0.125, 1.255, 18, {
color: "#efe5d0",
mono: true,
weight: 800,
align: "center"
});
text(field.label, field.x0 + 0.38, 1.255, 26, {
color: muted,
weight: 750
});
} else {
text(field.label, field.x0, 1.255, 21, {
color: muted,
weight: 750
});
}
text(field.value, field.x0, 0.78, 44, {
color: ink,
mono: true,
weight: 800
});
// Numeric character codes above their columns.
field.grid.forEach((x, index) => {
text(
String(field.codes[index]).padStart(2, "0"),
x,
0.37,
19,
{
color: accent,
mono: true,
weight: 800,
align: "center"
}
);
});
// Row weights and guide lines.
ROW_Y.forEach((y, rowIndex) => {
text(
String(ROW_WEIGHTS[rowIndex]).padStart(2, "0"),
field.grid[0] - 0.26,
y,
18,
{
color: muted,
mono: true,
weight: 650,
align: "right"
}
);
line(
field.grid[0] - 0.12,
y,
field.grid[field.grid.length - 1] + 0.18,
y,
lightRule,
1.5
);
});
// Faint rings indicate all encoded positions, including blanks.
for (const slot of allSlots) {
if (!field.grid.includes(slot.x)) continue;
context.beginPath();
context.arc(
px(slot.x),
py(slot.y),
scale(0.132),
0,
Math.PI * 2
);
context.strokeStyle = "rgba(23, 54, 56, 0.14)";
context.lineWidth = 1.5;
context.stroke();
}
}
// Footer and scheme reminder.
line(-4.68, -1.86, 4.68, -1.86, rule, 3);
roundedRect(-4.68, -2.47, 0.16, 0.36, 0.035, accent);
text("6-BIT COLUMN", -4.34, -2.28, 22, {
color: ink,
mono: true,
weight: 800
});
text("PUNCH = 1 / BLANK = 0", -2.47, -2.28, 20, {
color: muted,
mono: true,
weight: 700
});
text(
"ALL RECORDS FICTIONAL · READ EACH COLUMN TOP TO BOTTOM",
4.58,
-2.28,
17,
{
color: muted,
mono: true,
weight: 700,
align: "right"
}
);
text(
"ORBITAL SURVEY / INVENTED ARCHIVE / NOT A HISTORICAL PERSON RECORD",
-4.64,
-2.72,
15,
{
color: muted,
mono: true,
weight: 650
}
);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
texture.minFilter = THREE.LinearMipmapLinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.needsUpdate = true;
return texture;
}
const cardTexture = createCardTexture();
const printedLayer = new THREE.Mesh(
new THREE.PlaneGeometry(CARD_W, CARD_H),
new THREE.MeshBasicMaterial({
map: cardTexture,
transparent: true,
alphaTest: 0.01,
depthWrite: false,
polygonOffset: true,
polygonOffsetFactor: -1,
polygonOffsetUnits: -1
})
);
printedLayer.position.z = 0.355;
printedLayer.renderOrder = 3;
cardGroup.add(printedLayer);
function calculateFitRadius() {
const halfFov = THREE.MathUtils.degToRad(camera.fov * 0.5);
const aspect = window.innerWidth / window.innerHeight;
const widthFit = 5.35 / (Math.tan(halfFov) * aspect * 0.88);
const heightFit = 3.35 / Math.tan(halfFov);
return Math.max(widthFit, heightFit);
}
function applyResponsiveLayout(forceReset = false) {
const nextMobile = window.innerWidth <= 860;
const breakpointChanged = nextMobile !== isMobile;
isMobile = nextMobile;
if (isMobile) {
cardBaseX = 0;
cardBaseY = 2.15;
target.set(0, 0.45, 0);
minRadius = 16;
maxRadius = 65;
targetRadius = calculateFitRadius();
} else {
cardBaseX = -1.45;
cardBaseY = 0;
target.set(0, 0, 0);
minRadius = 10;
maxRadius = 24;
targetRadius = 15.8;
}
cardGroup.position.x = cardBaseX;
cardGroup.position.y = cardBaseY;
if (forceReset || breakpointChanged) {
targetTheta = 0.045;
targetPhi = 1.36;
targetRadius = isMobile ? calculateFitRadius() : 15.8;
}
}
function resetView() {
targetTheta = 0.045;
targetPhi = 1.36;
targetRadius = isMobile ? calculateFitRadius() : 15.8;
}
document.getElementById("reset").addEventListener("click", resetView);
let dragging = false;
let activePointer = null;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
activePointer = event.pointerId;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
event.preventDefault();
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging || event.pointerId !== activePointer) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
targetTheta -= deltaX * 0.0055;
targetPhi -= deltaY * 0.0045;
targetPhi = THREE.MathUtils.clamp(targetPhi, 0.88, 1.82);
event.preventDefault();
});
function endDrag(event) {
if (!dragging || event.pointerId !== activePointer) return;
dragging = false;
renderer.domElement.classList.remove("dragging");
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
activePointer = null;
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
targetRadius *= Math.exp(event.deltaY * 0.001);
targetRadius = THREE.MathUtils.clamp(
targetRadius,
minRadius,
maxRadius
);
},
{ passive: false }
);
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
applyResponsiveLayout();
}
window.addEventListener("resize", onResize);
applyResponsiveLayout(true);
currentTheta = targetTheta;
currentPhi = targetPhi;
currentRadius = targetRadius;
const spherical = new THREE.Spherical();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-9 * delta);
currentTheta += (targetTheta - currentTheta) * smoothing;
currentPhi += (targetPhi - currentPhi) * smoothing;
currentRadius += (targetRadius - currentRadius) * smoothing;
cardGroup.position.y =
cardBaseY + Math.sin(clock.elapsedTime * 0.8) * 0.022;
spherical.set(currentRadius, currentPhi, currentTheta);
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 300);
});
</script>
</body>
</html>
```