Prompt specification
Build or customize the Three.js 3D scene "Document folio for the 1888 abolition law" 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: Document folio for the 1888 abolition law
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/document-folio-for-the-1888-abolition-law-x2425
Scene Description Prompt:
Create a standalone stylized scene in one HTML file using Three.js from cdnjs. Model a document folio and writing instruments labeled with Brazil's 1888 abolition law. Use sourced text only when provided and avoid invented signatures or decorative pseudo-quotations.
Working Three.js Starter (document-folio-for-the-1888-abolition-law-x2425):
```html
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="Cena tridimensional contemporânea inspirada na Lei Áurea, lei brasileira de 1888 que aboliu a escravidão."
/>
<title>Lei Áurea — Brasil, 1888</title>
<style>
:root {
color-scheme: dark;
--cream: #efe5cf;
--muted: #b9b09f;
--gold: #c9a66b;
--panel: rgba(19, 20, 19, 0.76);
--line: rgba(239, 229, 207, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #151614;
color: var(--cream);
font-family: Georgia, "Times New Roman", serif;
}
body {
isolation: isolate;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.grain {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
opacity: 0.16;
mix-blend-mode: soft-light;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
}
.vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
radial-gradient(circle at 50% 48%, transparent 42%, rgba(4, 5, 4, 0.54) 100%),
linear-gradient(180deg, rgba(6, 7, 6, 0.32), transparent 28%);
}
header {
position: fixed;
top: clamp(22px, 4vw, 52px);
left: clamp(22px, 4vw, 58px);
z-index: 5;
max-width: min(560px, calc(100vw - 44px));
pointer-events: none;
text-shadow: 0 2px 22px rgba(0, 0, 0, 0.55);
}
.eyebrow {
display: flex;
align-items: center;
gap: 11px;
margin-bottom: 13px;
color: var(--gold);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.25em;
text-transform: uppercase;
}
.eyebrow::before {
width: 34px;
height: 1px;
content: "";
background: currentColor;
}
h1 {
margin: 0;
font-size: clamp(42px, 7vw, 88px);
font-weight: 400;
line-height: 0.88;
letter-spacing: -0.045em;
}
.subtitle {
margin: 16px 0 0;
color: var(--cream);
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.rule {
width: 112px;
height: 1px;
margin: 21px 0 15px;
background: linear-gradient(90deg, var(--gold), transparent);
}
.summary {
max-width: 455px;
margin: 0;
color: var(--muted);
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 1.65;
}
.panel {
position: fixed;
z-index: 5;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
}
.controls {
right: clamp(18px, 3vw, 44px);
bottom: clamp(62px, 8vh, 92px);
display: flex;
gap: 5px;
padding: 6px;
border-radius: 4px;
}
button {
appearance: none;
border: 1px solid transparent;
border-radius: 2px;
padding: 10px 13px;
background: transparent;
color: var(--muted);
cursor: pointer;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
transition:
color 160ms ease,
border-color 160ms ease,
background 160ms ease;
}
button:hover,
button:focus-visible {
color: var(--cream);
border-color: var(--line);
outline: none;
}
button.active {
color: #181712;
border-color: var(--gold);
background: var(--gold);
}
.source {
left: clamp(22px, 4vw, 58px);
bottom: clamp(20px, 3vw, 38px);
max-width: min(650px, calc(100vw - 44px));
padding: 12px 15px;
border-radius: 3px;
color: var(--muted);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
line-height: 1.55;
}
.source strong {
color: var(--cream);
font-weight: 600;
}
.source a {
color: var(--gold);
text-decoration-color: rgba(201, 166, 107, 0.45);
text-underline-offset: 3px;
}
.hint {
position: fixed;
right: clamp(20px, 3vw, 44px);
bottom: clamp(22px, 3vw, 40px);
z-index: 5;
color: rgba(239, 229, 207, 0.56);
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
letter-spacing: 0.14em;
text-transform: uppercase;
pointer-events: none;
}
.hotspot {
position: fixed;
top: 0;
left: 0;
z-index: 4;
display: flex;
align-items: center;
gap: 8px;
pointer-events: none;
opacity: 0;
transform: translate(-999px, -999px);
transition: opacity 200ms ease;
will-change: transform;
}
.hotspot.visible {
opacity: 1;
}
.hotspot .dot {
position: relative;
width: 8px;
height: 8px;
border: 1px solid var(--gold);
border-radius: 50%;
background: rgba(201, 166, 107, 0.2);
box-shadow: 0 0 0 5px rgba(201, 166, 107, 0.08);
}
.hotspot .label {
padding: 6px 8px;
border-left: 1px solid rgba(201, 166, 107, 0.65);
background: rgba(12, 13, 12, 0.48);
color: rgba(239, 229, 207, 0.82);
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
letter-spacing: 0.11em;
text-transform: uppercase;
white-space: nowrap;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #151614;
color: var(--gold);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
letter-spacing: 0.25em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
header {
top: 22px;
}
.summary {
display: none;
}
.rule {
margin-bottom: 0;
}
.controls {
right: 14px;
bottom: 68px;
left: 14px;
justify-content: center;
}
button {
flex: 1;
padding: 10px 7px;
font-size: 9px;
}
.source {
right: 14px;
bottom: 14px;
left: 14px;
max-width: none;
}
.hint {
display: none;
}
.hotspot .label {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Cena tridimensional de um fólio e instrumentos de escrita"></canvas>
<div class="vignette"></div>
<div class="grain"></div>
<header>
<div class="eyebrow">Estudo visual · documento</div>
<h1>Lei Áurea</h1>
<p class="subtitle">Brasil · 1888</p>
<div class="rule"></div>
<p class="summary">
Uma interpretação contemporânea de um fólio e seus instrumentos de escrita,
dedicada ao diploma que aboliu a escravidão no Brasil.
</p>
</header>
<nav class="panel controls" aria-label="Controles da câmera">
<button class="active" data-view="overview">Conjunto</button>
<button data-view="detail">Detalhe</button>
<button data-view="top">Superior</button>
</nav>
<aside class="panel source">
<strong>Identificação:</strong> Lei nº 3.353, de 13 de maio de 1888.
Representação visual interpretativa, sem facsimile, assinatura ou selo oficial.
<a
href="https://www.planalto.gov.br/ccivil_03/leis/lim/L3353.htm"
target="_blank"
rel="noreferrer"
>Consultar a referência oficial</a>.
</aside>
<div class="hint">Arraste para orbitar · role para aproximar · toque para explorar</div>
<div id="hotspots" aria-hidden="true"></div>
<div id="loading" class="loading">Preparando a cena</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const hotspotContainer = document.querySelector("#hotspots");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 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.05;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x151614);
scene.fog = new THREE.FogExp2(0x151614, 0.037);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const views = {
overview: {
yaw: -0.56,
pitch: 0.64,
distance: 14.4,
target: new THREE.Vector3(0, 0.6, 0.2)
},
detail: {
yaw: -0.24,
pitch: 0.49,
distance: 8.8,
target: new THREE.Vector3(0.35, 0.75, 0.55)
},
top: {
yaw: 0,
pitch: 1.37,
distance: 12.6,
target: new THREE.Vector3(0, 0.35, 0.2)
}
};
const orbit = {
yaw: views.overview.yaw,
pitch: views.overview.pitch,
distance: views.overview.distance,
target: views.overview.target.clone(),
desiredYaw: views.overview.yaw,
desiredPitch: views.overview.pitch,
desiredDistance: views.overview.distance,
desiredTarget: views.overview.target.clone()
};
const pointerMap = new Map();
let lastPointer = null;
let pinchDistance = 0;
function setView(name) {
const view = views[name];
if (!view) return;
orbit.desiredYaw = view.yaw;
orbit.desiredPitch = view.pitch;
orbit.desiredDistance = view.distance;
orbit.desiredTarget.copy(view.target);
document.querySelectorAll("[data-view]").forEach((button) => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointerMap.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerMap.size === 1) {
lastPointer = {
x: event.clientX,
y: event.clientY
};
} else if (pointerMap.size === 2) {
pinchDistance = getPinchDistance();
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerMap.has(event.pointerId)) return;
pointerMap.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (pointerMap.size === 1 && lastPointer) {
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
orbit.desiredYaw -= dx * 0.0055;
orbit.desiredPitch = THREE.MathUtils.clamp(
orbit.desiredPitch + dy * 0.0042,
0.18,
1.48
);
lastPointer = {
x: event.clientX,
y: event.clientY
};
} else if (pointerMap.size === 2) {
const nextDistance = getPinchDistance();
if (pinchDistance > 0) {
orbit.desiredDistance = THREE.MathUtils.clamp(
orbit.desiredDistance * (pinchDistance / nextDistance),
6.5,
23
);
}
pinchDistance = nextDistance;
}
});
function endPointer(event) {
pointerMap.delete(event.pointerId);
if (pointerMap.size === 1) {
const remaining = [...pointerMap.values()][0];
lastPointer = { ...remaining };
} else {
lastPointer = null;
pinchDistance = 0;
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.desiredDistance = THREE.MathUtils.clamp(
orbit.desiredDistance * Math.exp(event.deltaY * 0.001),
6.5,
23
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => setView("overview"));
function getPinchDistance() {
const points = [...pointerMap.values()];
if (points.length < 2) return 0;
return Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
// Lighting
scene.add(new THREE.HemisphereLight(0xdde6df, 0x28241d, 1.25));
const key = new THREE.DirectionalLight(0xffe2af, 4.2);
key.position.set(-4.5, 9, 5.5);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -10;
key.shadow.camera.right = 10;
key.shadow.camera.top = 10;
key.shadow.camera.bottom = -10;
key.shadow.camera.near = 1;
key.shadow.camera.far = 30;
key.shadow.bias = -0.0004;
scene.add(key);
const fill = new THREE.DirectionalLight(0x91aeb5, 1.3);
fill.position.set(7, 4, -5);
scene.add(fill);
const warm = new THREE.PointLight(0xff9d54, 22, 12, 2);
warm.position.set(1.5, 4.5, 3.5);
scene.add(warm);
const rim = new THREE.PointLight(0x7da9b5, 16, 11, 2);
rim.position.set(-5, 3.3, -4);
scene.add(rim);
// Materials
const materials = {
walnut: new THREE.MeshStandardMaterial({
color: 0x3b2419,
roughness: 0.67,
metalness: 0.03
}),
walnutEdge: new THREE.MeshStandardMaterial({
color: 0x1b100c,
roughness: 0.72
}),
felt: new THREE.MeshStandardMaterial({
color: 0x1e2925,
roughness: 1
}),
leather: new THREE.MeshStandardMaterial({
color: 0x4b1820,
roughness: 0.62,
metalness: 0.03
}),
leatherEdge: new THREE.MeshStandardMaterial({
color: 0x260e14,
roughness: 0.76
}),
paperEdge: new THREE.MeshStandardMaterial({
color: 0xc7b58f,
roughness: 0.95
}),
brass: new THREE.MeshStandardMaterial({
color: 0xb28a43,
roughness: 0.3,
metalness: 0.82
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x152b2c,
roughness: 0.26,
metalness: 0.68
}),
gold: new THREE.MeshStandardMaterial({
color: 0xc6a15c,
roughness: 0.25,
metalness: 0.8
}),
pencil: new THREE.MeshStandardMaterial({
color: 0xbc8437,
roughness: 0.58
}),
wood: new THREE.MeshStandardMaterial({
color: 0xc99e67,
roughness: 0.8
}),
graphite: new THREE.MeshStandardMaterial({
color: 0x252422,
roughness: 0.5
}),
eraser: new THREE.MeshStandardMaterial({
color: 0xa95750,
roughness: 0.84
}),
feather: new THREE.MeshStandardMaterial({
color: 0xe4d8bd,
roughness: 0.91,
side: THREE.DoubleSide
}),
ribbon: new THREE.MeshStandardMaterial({
color: 0x8c2531,
roughness: 0.76
}),
glass: new THREE.MeshPhysicalMaterial({
color: 0x496d70,
roughness: 0.12,
metalness: 0.02,
transparent: true,
opacity: 0.56,
transmission: 0.2,
thickness: 0.4
}),
ink: new THREE.MeshStandardMaterial({
color: 0x071b24,
roughness: 0.18,
metalness: 0.15
})
};
function mesh(geometry, material, position, parent = scene) {
const object = new THREE.Mesh(geometry, material);
if (position) object.position.set(...position);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(size, material, position, parent = scene) {
return mesh(
new THREE.BoxGeometry(...size),
material,
position,
parent
);
}
// Desk and room
box([15.8, 0.48, 10.6], materials.walnut, [0, 0, 0]);
box([15.9, 0.12, 10.7], materials.walnutEdge, [0, -0.25, 0]);
box([10.9, 0.035, 7.4], materials.felt, [0, 0.257, 0.25]);
for (const x of [-6.6, 6.6]) {
for (const z of [-4.2, 4.2]) {
box([0.72, 5.7, 0.72], materials.walnutEdge, [x, -2.95, z]);
}
}
const floor = mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({
color: 0x111411,
roughness: 0.96
}),
[0, -5.86, 0]
);
floor.rotation.x = -Math.PI / 2;
floor.castShadow = false;
const backWall = mesh(
new THREE.PlaneGeometry(60, 28),
new THREE.MeshStandardMaterial({
color: 0x1b201d,
roughness: 1
}),
[0, 6, -14]
);
backWall.castShadow = false;
// Seeded noise keeps page textures stable between reloads.
function seededRandom(seed) {
let value = seed >>> 0;
return () => {
value = (value * 1664525 + 1013904223) >>> 0;
return value / 4294967296;
};
}
function trackedText(
context,
text,
centerX,
y,
tracking,
align = "center"
) {
const characters = [...text];
const widths = characters.map((character) =>
context.measureText(character).width
);
const total =
widths.reduce((sum, width) => sum + width, 0) +
tracking * Math.max(0, characters.length - 1);
let x =
align === "center"
? centerX - total / 2
: align === "right"
? centerX - total
: centerX;
context.textAlign = "left";
characters.forEach((character, index) => {
context.fillText(character, x, y);
x += widths[index] + tracking;
});
}
function makePageTexture(side) {
const pageCanvas = document.createElement("canvas");
pageCanvas.width = 1024;
pageCanvas.height = 1408;
const context = pageCanvas.getContext("2d");
const random = seededRandom(side === "left" ? 1888 : 3353);
const gradient = context.createRadialGradient(
470,
470,
80,
512,
700,
900
);
gradient.addColorStop(0, "#eadcb9");
gradient.addColorStop(0.55, "#dfcda3");
gradient.addColorStop(1, "#bda477");
context.fillStyle = gradient;
context.fillRect(0, 0, 1024, 1408);
for (let index = 0; index < 8500; index += 1) {
const x = random() * 1024;
const y = random() * 1408;
const radius = random() * 1.5 + 0.2;
context.fillStyle = `rgba(77, 49, 23, ${random() * 0.055})`;
context.beginPath();
context.arc(x, y, radius, 0, Math.PI * 2);
context.fill();
}
for (let index = 0; index < 24; index += 1) {
const x = random() * 1024;
const y = random() * 1408;
context.strokeStyle = `rgba(93, 58, 28, ${random() * 0.025})`;
context.lineWidth = random() * 3 + 0.4;
context.beginPath();
context.moveTo(x, y);
context.bezierCurveTo(
x + 80,
y - 25,
x + 180,
y + 35,
x + 260,
y - 15
);
context.stroke();
}
context.strokeStyle = "rgba(82, 55, 31, 0.52)";
context.lineWidth = 3;
context.strokeRect(66, 66, 892, 1276);
context.strokeStyle = "rgba(148, 108, 50, 0.45)";
context.lineWidth = 1;
context.strokeRect(78, 78, 868, 1252);
context.fillStyle = "#3d2b1d";
context.strokeStyle = "rgba(66, 45, 27, 0.62)";
if (side === "left") {
context.textAlign = "center";
context.font = "600 25px Arial";
trackedText(context, "BRASIL", 512, 174, 12);
context.font = "400 53px Georgia";
context.fillText("LEI", 512, 276);
context.font = "400 93px Georgia";
context.fillText("ÁUREA", 512, 380);
context.beginPath();
context.moveTo(318, 425);
context.lineTo(706, 425);
context.stroke();
context.font = "600 30px Arial";
trackedText(context, "LEI Nº 3.353", 512, 491, 4);
context.font = "400 24px Georgia";
trackedText(context, "13 DE MAIO DE 1888", 512, 543, 3);
context.strokeStyle = "rgba(75, 51, 31, 0.38)";
context.beginPath();
context.moveTo(220, 602);
context.lineTo(804, 602);
context.stroke();
context.textAlign = "left";
context.fillStyle = "rgba(62, 42, 28, 0.74)";
context.font = "600 18px Arial";
trackedText(context, "IDENTIFICAÇÃO", 222, 657, 5, "left");
const rows = [
["Diploma", "Lei nº 3.353"],
["Data", "13 de maio de 1888"],
["Tema", "Abolição da escravidão"],
["Cenário", "Brasil"]
];
rows.forEach((row, index) => {
const y = 719 + index * 76;
context.strokeStyle = "rgba(75, 51, 31, 0.26)";
context.beginPath();
context.moveTo(222, y + 25);
context.lineTo(802, y + 25);
context.stroke();
context.fillStyle = "rgba(62, 42, 28, 0.56)";
context.font = "17px Arial";
context.fillText(row[0].toUpperCase(), 222, y);
context.fillStyle = "rgba(48, 32, 22, 0.88)";
context.font = "22px Georgia";
context.fillText(row[1], 222, y + 48);
});
context.fillStyle = "rgba(62, 42, 28, 0.53)";
context.font = "italic 19px Georgia";
context.fillText("Identificação editorial, sem transcrição integral.", 222, 1138);
context.font = "15px Arial";
trackedText(
context,
"DOCUMENTO INTERPRETATIVO · SEM FACSIMILE",
512,
1258,
2
);
} else {
context.textAlign = "center";
context.font = "400 142px Georgia";
context.fillText("1888", 512, 310);
context.font = "600 24px Arial";
trackedText(context, "DOCUMENTO · BRASIL", 512, 375, 6);
context.beginPath();
context.moveTo(278, 438);
context.lineTo(746, 438);
context.stroke();
context.font = "400 61px Georgia";
context.fillText("ABOLIÇÃO", 512, 570);
context.font = "400 46px Georgia";
context.fillText("DA ESCRAVIDÃO", 512, 633);
context.strokeStyle = "rgba(75, 51, 31, 0.38)";
context.strokeRect(205, 742, 614, 344);
context.fillStyle = "rgba(62, 42, 28, 0.68)";
context.font = "600 18px Arial";
trackedText(context, "FÓLIO INTERPRETATIVO", 512, 805, 5);
context.font = "25px Georgia";
context.fillText("Sem texto integral reproduzido", 512, 886);
context.fillText("Sem facsimile ou selo oficial", 512, 932);
context.fillText("Sem assinatura reproduzida", 512, 978);
context.fillStyle = "rgba(62, 42, 28, 0.48)";
context.font = "italic 19px Georgia";
context.fillText(
"Uma leitura visual contemporânea do documento.",
512,
1136
);
context.font = "15px Arial";
trackedText(
context,
"BRASIL · LEI Nº 3.353 · 1888",
512,
1258,
2
);
}
const texture = new THREE.CanvasTexture(pageCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
function makeCurvedPage(width, height, texture, innerSign) {
const geometry = new THREE.PlaneGeometry(width, height, 36, 44);
geometry.rotateX(-Math.PI / 2);
const positions = geometry.attributes.position;
const halfWidth = width / 2;
for (let index = 0; index < positions.count; index += 1) {
const x = positions.getX(index);
const z = positions.getZ(index);
const innerFactor = THREE.MathUtils.clamp(
(x * innerSign + halfWidth) / (2 * halfWidth),
0,
1
);
const spineLift = 0.045 * Math.pow(1 - innerFactor, 4);
const edgeLift = 0.015 * Math.pow(
Math.abs(z) / (height / 2),
5
);
positions.setY(index, spineLift + edgeLift);
}
positions.needsUpdate = true;
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.96,
metalness: 0,
side: THREE.DoubleSide
});
return mesh(geometry, material);
}
// Open folio
const folio = new THREE.Group();
folio.position.set(0, 0.285, 0.05);
folio.rotation.y = -0.065;
scene.add(folio);
box([7.85, 0.18, 5.58], materials.leatherEdge, [0, 0.02, 0], folio);
box([7.68, 0.14, 5.43], materials.leather, [0, 0.13, 0], folio);
const leftStack = box(
[3.58, 0.16, 4.95],
materials.paperEdge,
[-1.8, 0.285, 0.02],
folio
);
leftStack.rotation.y = -0.012;
const rightStack = box(
[3.58, 0.16, 4.95],
materials.paperEdge,
[1.8, 0.285, 0.02],
folio
);
rightStack.rotation.y = 0.012;
box([7.25, 0.012, 4.93], materials.leatherEdge, [0, 0.225, 0], folio);
const leftPage = makeCurvedPage(
3.48,
4.83,
makePageTexture("left"),
1
);
leftPage.position.set(-1.8, 0.405, 0.02);
folio.add(leftPage);
const rightPage = makeCurvedPage(
3.48,
4.83,
makePageTexture("right"),
-1
);
rightPage.position.set(1.8, 0.405, 0.02);
folio.add(rightPage);
const spine = mesh(
new THREE.CylinderGeometry(0.18, 0.2, 5.03, 24),
materials.leather,
[0, 0.31, 0.02],
folio
);
spine.rotation.x = Math.PI / 2;
// Small brass corner protectors
for (const x of [-3.76, 3.76]) {
for (const z of [-2.64, 2.64]) {
const horizontal = box(
[0.62, 0.035, 0.19],
materials.brass,
[x, 0.235, z],
folio
);
horizontal.rotation.y = x < 0
? (z < 0 ? -0.06 : 0.06)
: (z < 0 ? 0.06 : -0.06);
const vertical = box(
[0.19, 0.035, 0.62],
materials.brass,
[x, 0.235, z],
folio
);
vertical.rotation.y = x < 0
? (z < 0 ? 0.04 : -0.04)
: (z < 0 ? -0.04 : 0.04);
}
}
// Bookmark ribbon
box([0.12, 0.026, 1.6], materials.ribbon, [1.75, 0.43, 3.02], folio);
box([0.32, 0.018, 0.18], materials.ribbon, [1.75, 0.44, 3.74], folio);
// Front desk plaque
function makePlaqueTexture() {
const plaqueCanvas = document.createElement("canvas");
plaqueCanvas.width = 1024;
plaqueCanvas.height = 160;
const context = plaqueCanvas.getContext("2d");
context.fillStyle = "#161713";
context.fillRect(0, 0, 1024, 160);
context.strokeStyle = "#9e7c43";
context.lineWidth = 3;
context.strokeRect(10, 10, 1004, 140);
context.fillStyle = "#d2b77d";
context.font = "600 39px Georgia";
context.textAlign = "center";
trackedText(context, "BRASIL · LEI ÁUREA · 1888", 512, 92, 5);
const texture = new THREE.CanvasTexture(plaqueCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = 8;
return texture;
}
const plaqueMaterial = new THREE.MeshStandardMaterial({
map: makePlaqueTexture(),
roughness: 0.46,
metalness: 0.4
});
const plaque = mesh(
new THREE.PlaneGeometry(4.4, 0.69),
plaqueMaterial,
[0, 0.294, 4.62]
);
plaque.rotation.x = -Math.PI / 2;
// Helpers for writing instruments
function alignYAxisTo(group, direction) {
const normalized = direction.clone().normalize();
group.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
normalized
);
}
function cylinderBetween(start, end, radius, material, radialSegments = 20) {
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments
);
const object = mesh(geometry, material);
object.position.copy(start).add(end).multiplyScalar(0.5);
object.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return object;
}
// Quill
const quill = new THREE.Group();
const quillStart = new THREE.Vector3(-5.25, 0.48, 1.95);
const quillEnd = new THREE.Vector3(-3.25, 0.63, -0.5);
quill.position.copy(quillStart);
alignYAxisTo(quill, quillEnd.clone().sub(quillStart));
scene.add(quill);
const quillShaft = mesh(
new THREE.CylinderGeometry(0.035, 0.055, 1.85, 12),
new THREE.MeshStandardMaterial({
color: 0x6c5132,
roughness: 0.8
}),
[0, 0.72, 0],
quill
);
const featherShape = new THREE.Shape();
featherShape.moveTo(0, 0);
featherShape.bezierCurveTo(-0.48, 0.3, -0.61, 1.22, -0.14, 2.13);
featherShape.bezierCurveTo(0.03, 2.34, 0.25, 2.52, 0.39, 2.72);
featherShape.bezierCurveTo(0.18, 1.93, 0.47, 0.52, 0, 0);
const featherGeometry = new THREE.ShapeGeometry(featherShape, 20);
const feather = mesh(
featherGeometry,
materials.feather,
[0, 1.43, 0],
quill
);
feather.rotation.y = -0.12;
const featherVein = mesh(
new THREE.CylinderGeometry(0.013, 0.022, 2.45, 8),
new THREE.MeshStandardMaterial({
color: 0x9f8760,
roughness: 0.9
}),
[0.03, 2.67, 0.012],
quill
);
featherVein.rotation.z = -0.08;
const quillNib = mesh(
new THREE.ConeGeometry(0.085, 0.34, 16),
materials.graphite,
[0, -0.16, 0],
quill
);
quillNib.rotation.z = Math.PI;
// Fountain pen
const pen = new THREE.Group();
const penStart = new THREE.Vector3(4.85, 0.46, 2.45);
const penEnd = new THREE.Vector3(2.45, 0.46, 1.2);
pen.position.copy(penStart);
alignYAxisTo(pen, penEnd.clone().sub(penStart));
scene.add(pen);
mesh(
new THREE.CylinderGeometry(0.145, 0.13, 2.05, 28),
materials.darkMetal,
[0, 1.08, 0],
pen
);
const penCap = mesh(
new THREE.CylinderGeometry(0.17, 0.145, 0.72, 28),
materials.darkMetal,
[0, 2.0, 0],
pen
);
const penBand = mesh(
new THREE.TorusGeometry(0.155, 0.027, 10, 32),
materials.gold,
[0, 1.58, 0],
pen
);
penBand.rotation.x = Math.PI / 2;
const penNib = mesh(
new THREE.ConeGeometry(0.13, 0.45, 24),
materials.gold,
[0, -0.21, 0],
pen
);
penNib.rotation.z = Math.PI;
const nibSlit = box(
[0.014, 0.27, 0.01],
materials.graphite,
[0, -0.23, 0.108],
pen
);
nibSlit.rotation.x = 0.08;
const penClip = box(
[0.045, 0.62, 0.08],
materials.gold,
[0.16, 2.03, 0],
pen
);
penClip.rotation.z = -0.06;
// Hexagonal pencil
const pencil = new THREE.Group();
const pencilStart = new THREE.Vector3(-4.65, 0.45, -1.62);
const pencilEnd = new THREE.Vector3(-2.05, 0.45, -2.1);
pencil.position.copy(pencilStart);
alignYAxisTo(pencil, pencilEnd.clone().sub(pencilStart));
scene.add(pencil);
mesh(
new THREE.CylinderGeometry(0.115, 0.115, 2.15, 6),
materials.pencil,
[0, 1.07, 0],
pencil
);
const pencilWood = mesh(
new THREE.ConeGeometry(0.115, 0.34, 6),
materials.wood,
[0, 2.29, 0],
pencil
);
mesh(
new THREE.ConeGeometry(0.045, 0.18, 12),
materials.graphite,
[0, 2.53, 0],
pencil
);
const eraser = mesh(
new THREE.CylinderGeometry(0.115, 0.115, 0.18, 20),
materials.eraser,
[0, -0.04, 0],
pencil
);
const pencilFerrule = mesh(
new THREE.CylinderGeometry(0.12, 0.12, 0.18, 20),
materials.brass,
[0, 0.14, 0],
pencil
);
// Ink bottle
const inkwell = new THREE.Group();
inkwell.position.set(4.72, 0.27, -1.65);
scene.add(inkwell);
mesh(
new THREE.CylinderGeometry(0.49, 0.54, 0.58, 36),
materials.glass,
[0, 0.29, 0],
inkwell
);
mesh(
new THREE.CylinderGeometry(0.39, 0.41, 0.26, 32),
materials.ink,
[0, 0.19, 0],
inkwell
);
mesh(
new THREE.CylinderGeometry(0.25, 0.31, 0.19, 32),
materials.glass,
[0, 0.66, 0],
inkwell
);
mesh(
new THREE.TorusGeometry(0.26, 0.028, 10, 32),
materials.brass,
[0, 0.74, 0],
inkwell
).rotation.x = Math.PI / 2;
function makeInkLabel() {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 512;
labelCanvas.height = 512;
const context = labelCanvas.getContext("2d");
context.clearRect(0, 0, 512, 512);
context.fillStyle = "#d6c39a";
context.beginPath();
context.arc(256, 256, 235, 0, Math.PI * 2);
context.fill();
context.strokeStyle = "#695232";
context.lineWidth = 8;
context.stroke();
context.fillStyle = "#35291e";
context.textAlign = "center";
context.font = "600 47px Georgia";
trackedText(context, "TINTA", 256, 255, 7);
context.font = "25px Arial";
trackedText(context, "1888", 256, 319, 5);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
const inkLabel = mesh(
new THREE.CircleGeometry(0.18, 40),
new THREE.MeshStandardMaterial({
map: makeInkLabel(),
roughness: 0.84,
transparent: true
}),
[0, 0.32, 0.527],
inkwell
);
// Atmospheric dust
const dustGeometry = new THREE.BufferGeometry();
const dustPositions = new Float32Array(420 * 3);
const dustRandom = seededRandom(1888);
for (let index = 0; index < 420; index += 1) {
dustPositions[index * 3] = (dustRandom() - 0.5) * 19;
dustPositions[index * 3 + 1] = dustRandom() * 7 + 0.4;
dustPositions[index * 3 + 2] = (dustRandom() - 0.5) * 17;
}
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0xd8c7a3,
size: 0.022,
transparent: true,
opacity: 0.33,
depthWrite: false
})
);
scene.add(dust);
// Screen-space annotations
const hotspotDefinitions = [
{
label: "Fólio · Lei nº 3.353",
anchor: new THREE.Vector3(0, 1.15, 0.1)
},
{
label: "Quilha",
anchor: new THREE.Vector3(-4.2, 1.0, 0.35)
},
{
label: "Pena-tinteiro",
anchor: new THREE.Vector3(3.5, 0.9, 1.75)
},
{
label: "Lápis",
anchor: new THREE.Vector3(-3.3, 0.75, -1.9)
},
{
label: "Tinteiro",
anchor: new THREE.Vector3(4.7, 1.18, -1.65)
}
];
const hotspots = hotspotDefinitions.map((definition) => {
const element = document.createElement("div");
element.className = "hotspot";
element.innerHTML = `
<span class="dot"></span>
<span class="label">${definition.label}</span>
`;
hotspotContainer.appendChild(element);
return {
...definition,
element
};
});
const projected = new THREE.Vector3();
function updateHotspots() {
const width = window.innerWidth;
const height = window.innerHeight;
hotspots.forEach((hotspot) => {
projected.copy(hotspot.anchor).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.08 &&
Math.abs(projected.y) < 1.08;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
hotspot.element.style.transform = `translate(${x}px, ${y}px)`;
hotspot.element.classList.toggle("visible", visible);
});
}
// Resize
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
// Animation
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
const damping = 1 - Math.pow(0.001, 1 / 60);
orbit.yaw += (orbit.desiredYaw - orbit.yaw) * damping;
orbit.pitch += (orbit.desiredPitch - orbit.pitch) * damping;
orbit.distance += (orbit.desiredDistance - orbit.distance) * damping;
orbit.target.lerp(orbit.desiredTarget, damping);
const horizontalDistance = Math.cos(orbit.pitch) * orbit.distance;
camera.position.set(
orbit.target.x + horizontalDistance * Math.sin(orbit.yaw),
orbit.target.y + Math.sin(orbit.pitch) * orbit.distance,
orbit.target.z + horizontalDistance * Math.cos(orbit.yaw)
);
camera.lookAt(orbit.target);
dust.rotation.y = elapsed * 0.012;
dust.position.y = Math.sin(elapsed * 0.15) * 0.04;
warm.intensity = 22 + Math.sin(elapsed * 0.7) * 0.6;
updateHotspots();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```