Prompt specification
Build or customize the Three.js 3D scene "Bus ticket and delay display" 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: Bus ticket and delay display
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/bus-ticket-and-delay-display-x3853
Scene Description Prompt:
I'd like to see this as a stylized Three.js scene: bus ticket and delay display. Show a ticket with destination symbol beside a stop display announcing a fictional delay; keep the originally expected time and revised time separately visible. Use cdnjs and return one self-contained HTML file.
Verify the behavior against the actual geometry and data in each relevant state. Use schematic labels for deliberately synthetic elements.
Technical checks: Put the destination symbol on the visible ticket face. Make the 18:40 and 19:05 departure times visibly legible on the stop display in the initial view.
Return one complete HTML document. The file must run in a sandbox allowing inline scripts and the cdnjs Three.js r160 module. Construct procedural assets, use local event handlers and avoid remote assets, runtime network requests besides Three.js, pointer lock and native form submission. Keep the main requested geometry visible in the initial view.
Working Three.js Starter (bus-ticket-and-delay-display-x3853):
```html
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bilhete urbano e painel de atraso — cena sintética</title>
<style>
:root {
color-scheme: light;
--ink: #12353d;
--muted: #577078;
--paper: #fffaf0;
--accent: #ef8b3f;
--teal: #197d83;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d9e4df;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.brand {
position: absolute;
top: 22px;
left: 24px;
max-width: 440px;
padding: 15px 18px 14px;
border: 1px solid rgba(18, 53, 61, 0.14);
border-radius: 18px;
background: rgba(255, 250, 240, 0.86);
box-shadow: 0 12px 35px rgba(21, 50, 55, 0.12);
backdrop-filter: blur(12px);
}
.eyebrow {
margin: 0 0 5px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(20px, 2.4vw, 31px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.brand p {
margin: 8px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.35;
}
.data-card {
position: absolute;
top: 22px;
right: 24px;
width: 270px;
padding: 15px 16px;
border: 1px solid rgba(18, 53, 61, 0.14);
border-radius: 18px;
background: rgba(18, 53, 61, 0.91);
color: #fffaf0;
box-shadow: 0 12px 35px rgba(21, 50, 55, 0.17);
backdrop-filter: blur(12px);
}
.data-card .status {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
color: #ffb66e;
font-size: 11px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.status-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: #ff9d45;
box-shadow: 0 0 0 5px rgba(255, 157, 69, 0.15);
}
.data-times {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
}
.data-time {
padding: 10px 11px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 11px;
background: rgba(255, 255, 255, 0.055);
}
.data-time span {
display: block;
margin-bottom: 3px;
color: #a9c2c4;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.data-time strong {
font-size: 23px;
line-height: 1;
font-variant-numeric: tabular-nums;
}
.data-time.revised strong {
color: #ffb66e;
}
.data-card small {
display: block;
margin-top: 10px;
color: #9eb9bc;
font-size: 10px;
line-height: 1.35;
}
.controls {
position: absolute;
left: 50%;
bottom: 22px;
display: flex;
gap: 7px;
padding: 7px;
transform: translateX(-50%);
border: 1px solid rgba(18, 53, 61, 0.15);
border-radius: 16px;
background: rgba(255, 250, 240, 0.9);
box-shadow: 0 12px 35px rgba(21, 50, 55, 0.14);
backdrop-filter: blur(12px);
pointer-events: auto;
}
.controls button {
min-height: 40px;
padding: 0 15px;
border: 0;
border-radius: 11px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 760;
white-space: nowrap;
cursor: pointer;
transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.controls button:hover {
background: rgba(25, 125, 131, 0.09);
}
.controls button:focus-visible {
outline: 3px solid rgba(239, 139, 63, 0.45);
outline-offset: 2px;
}
.controls button[aria-pressed="true"] {
background: var(--ink);
color: #fffaf0;
}
.controls button:active {
transform: translateY(1px);
}
.hint {
position: absolute;
left: 24px;
bottom: 27px;
max-width: 220px;
color: rgba(18, 53, 61, 0.72);
font-size: 11px;
font-weight: 650;
line-height: 1.45;
}
.loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #d9e4df;
transition: opacity 300ms ease, visibility 300ms ease;
}
.loading.hidden {
visibility: hidden;
opacity: 0;
}
.loading div {
padding: 18px 22px;
border-radius: 15px;
background: #fffaf0;
box-shadow: 0 12px 35px rgba(21, 50, 55, 0.12);
font-size: 13px;
font-weight: 750;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 760px) {
.brand {
top: 12px;
left: 12px;
right: 12px;
max-width: none;
padding: 12px 14px;
}
.brand h1 {
font-size: 21px;
}
.brand p {
display: none;
}
.data-card {
top: 108px;
right: 12px;
width: 230px;
padding: 12px;
}
.data-time strong {
font-size: 20px;
}
.controls {
bottom: 12px;
width: calc(100% - 24px);
justify-content: center;
}
.controls button {
flex: 1 1 0;
min-width: 0;
padding: 0 8px;
font-size: 10px;
}
.hint {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
role="img"
aria-label="Cena 3D sintética com um bilhete urbano à esquerda, contendo símbolo de destino e os horários original 18:40 e revisado 19:05, e um painel de parada à direita anunciando atraso sintético de 25 minutos."
></canvas>
<div class="hud">
<header class="brand">
<p class="eyebrow">Maquete urbana · dados sintéticos</p>
<h1>Bilhete & painel de atraso</h1>
<p>O símbolo de destino está no próprio bilhete. Os dois horários permanecem separados no bilhete e no painel.</p>
</header>
<aside class="data-card" aria-label="Dados também representados nos objetos 3D">
<div class="status"><span class="status-dot"></span>Atraso sintético · +25 min</div>
<div class="data-times">
<div class="data-time">
<span>Previsão original</span>
<strong>18:40</strong>
</div>
<div class="data-time revised">
<span>Previsão revisada</span>
<strong>19:05</strong>
</div>
</div>
<small>Parada Demo 42 · Rota Demo 07 · Elementos e horários deliberadamente fictícios.</small>
</aside>
<nav class="controls" aria-label="Vistas da cena">
<button type="button" data-view="general" aria-pressed="true">Vista completa</button>
<button type="button" data-view="ticket" aria-pressed="false">Bilhete</button>
<button type="button" data-view="panel" aria-pressed="false">Painel de atraso</button>
</nav>
<div class="hint">Arraste para orbitar · use a roda para aproximar · teclas 1, 2 e 3</div>
</div>
<div id="loading" class="loading"><div>Construindo a maquete sintética…</div></div>
<div id="live" class="sr-only" aria-live="polite"></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.getElementById("scene");
const loading = document.getElementById("loading");
const live = document.getElementById("live");
const viewButtons = [...document.querySelectorAll("[data-view]")];
const ORIGINAL_TIME = "18:40";
const REVISED_TIME = "19:05";
const DELAY_MINUTES = 25;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd9e4df);
scene.fog = new THREE.Fog(0xd9e4df, 19, 42);
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.querySelector("div").textContent = "Não foi possível iniciar o WebGL neste navegador.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const currentPosition = new THREE.Vector3(0.65, 4.65, 12.8);
const currentTarget = new THREE.Vector3(0.65, 2.55, 0);
const desiredPosition = currentPosition.clone();
const desiredTarget = currentTarget.clone();
camera.position.copy(currentPosition);
camera.lookAt(currentTarget);
function roundedPath(ctx, x, y, w, h, r) {
const radius = Math.min(r, w / 2, h / 2);
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + w - radius, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + radius);
ctx.lineTo(x + w, y + h - radius);
ctx.quadraticCurveTo(x + w, y + h, x + w - radius, y + h);
ctx.lineTo(x + radius, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function roundedShape(width, height, radius) {
const shape = new THREE.Shape();
const x = -width / 2;
const y = -height / 2;
const r = Math.min(radius, width / 2, height / 2);
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
return shape;
}
function makeCanvasTexture(canvasElement) {
const texture = new THREE.CanvasTexture(canvasElement);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
texture.needsUpdate = true;
return texture;
}
function drawTicketTexture() {
const ticketCanvas = document.createElement("canvas");
ticketCanvas.width = 900;
ticketCanvas.height = 1560;
const ctx = ticketCanvas.getContext("2d");
ctx.clearRect(0, 0, 900, 1560);
roundedPath(ctx, 18, 18, 864, 1524, 52);
ctx.save();
ctx.clip();
ctx.fillStyle = "#f5edda";
ctx.fillRect(0, 0, 900, 1560);
ctx.fillStyle = "#123b43";
ctx.fillRect(0, 0, 900, 190);
ctx.fillStyle = "#2a8589";
ctx.fillRect(0, 190, 900, 12);
ctx.fillStyle = "#fffaf0";
ctx.font = "800 50px Arial, sans-serif";
ctx.fillText("BILHETE URBANO", 54, 79);
ctx.font = "700 22px Arial, sans-serif";
ctx.fillStyle = "#b8d7d5";
ctx.fillText("EXEMPLO SINTÉTICO · NÃO VALE PARA EMBARQUE", 56, 126);
ctx.fillStyle = "#ef8b3f";
roundedPath(ctx, 724, 42, 122, 92, 22);
ctx.fill();
ctx.fillStyle = "#123b43";
ctx.font = "900 50px Arial, sans-serif";
ctx.textAlign = "center";
ctx.fillText("07", 785, 105);
ctx.textAlign = "left";
ctx.fillStyle = "#577078";
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText("ROTA DEMO / SENTIDO LESTE", 58, 265);
ctx.fillStyle = "#123b43";
ctx.font = "900 49px Arial, sans-serif";
ctx.fillText("PARADA 42", 58, 328);
ctx.fillStyle = "#577078";
ctx.font = "700 23px Arial, sans-serif";
ctx.fillText("TRAVESSIA SINTÉTICA", 58, 378);
ctx.strokeStyle = "#2a8589";
ctx.lineWidth = 7;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(67, 426);
ctx.lineTo(67, 555);
ctx.stroke();
ctx.fillStyle = "#ef8b3f";
ctx.beginPath();
ctx.arc(67, 430, 13, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#123b43";
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText("DESTINO", 111, 447);
ctx.font = "900 43px Arial, sans-serif";
ctx.fillText("BAIRRO AURORA", 111, 501);
ctx.font = "700 22px Arial, sans-serif";
ctx.fillStyle = "#577078";
ctx.fillText("ZONA DEMO", 111, 541);
// Badge reserva a posição do símbolo 3D aplicado sobre o bilhete.
ctx.fillStyle = "#197d83";
ctx.beginPath();
ctx.arc(730, 345, 132, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = "#b8d7d5";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.arc(730, 345, 110, 0, Math.PI * 2);
ctx.stroke();
ctx.fillStyle = "#577078";
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText("HORÁRIOS DA VIAGEM", 58, 630);
ctx.fillStyle = "#fffaf0";
ctx.strokeStyle = "#b8c7c2";
ctx.lineWidth = 3;
roundedPath(ctx, 48, 670, 382, 248, 25);
ctx.fill();
ctx.stroke();
roundedPath(ctx, 470, 670, 382, 248, 25);
ctx.fill();
ctx.stroke();
ctx.fillStyle = "#577078";
ctx.font = "800 22px Arial, sans-serif";
ctx.fillText("PREVISÃO ORIGINAL", 78, 723);
ctx.fillText("PREVISÃO REVISADA", 500, 723);
ctx.fillStyle = "#123b43";
ctx.font = "900 84px Arial, sans-serif";
ctx.fillText(ORIGINAL_TIME, 76, 824);
ctx.fillStyle = "#d9682d";
ctx.fillText(REVISED_TIME, 498, 824);
ctx.fillStyle = "#ef8b3f";
roundedPath(ctx, 48, 960, 804, 122, 24);
ctx.fill();
ctx.fillStyle = "#123b43";
ctx.font = "900 31px Arial, sans-serif";
ctx.fillText("ATRASO SINTÉTICO", 78, 1014);
ctx.font = "900 38px Arial, sans-serif";
ctx.textAlign = "right";
ctx.fillText(`+${DELAY_MINUTES} MIN`, 818, 1015);
ctx.textAlign = "left";
ctx.fillStyle = "#577078";
ctx.font = "800 20px Arial, sans-serif";
ctx.fillText("BILHETE DEMO / PARADA 42 / EMBARQUE FICTÍCIO", 58, 1140);
ctx.fillText("DADOS SINTÉTICOS · SEM VALIDADE REAL", 58, 1174);
let barcodeX = 58;
let seed = 9182;
ctx.fillStyle = "#123b43";
while (barcodeX < 842) {
seed = (seed * 9301 + 49297) % 233280;
const barWidth = 2 + (seed % 7);
if (seed % 3 !== 0) ctx.fillRect(barcodeX, 1220, barWidth, 168);
barcodeX += barWidth + 2 + (seed % 5);
}
ctx.font = "700 22px Arial, sans-serif";
ctx.fillText("ID SINTÉTICO 024-071", 58, 1435);
ctx.textAlign = "right";
ctx.fillText("EMBARQUE · 07", 842, 1435);
ctx.textAlign = "left";
ctx.restore();
ctx.strokeStyle = "#123b43";
ctx.lineWidth = 5;
roundedPath(ctx, 18, 18, 864, 1524, 52);
ctx.stroke();
return makeCanvasTexture(ticketCanvas);
}
function drawPanelTexture() {
const panelCanvas = document.createElement("canvas");
panelCanvas.width = 1200;
panelCanvas.height = 800;
const ctx = panelCanvas.getContext("2d");
ctx.clearRect(0, 0, 1200, 800);
roundedPath(ctx, 10, 10, 1180, 780, 38);
ctx.save();
ctx.clip();
ctx.fillStyle = "#0c252c";
ctx.fillRect(0, 0, 1200, 800);
ctx.fillStyle = "#197d83";
ctx.fillRect(0, 0, 1200, 112);
ctx.fillStyle = "#fffaf0";
ctx.font = "800 38px Arial, sans-serif";
ctx.fillText("PARADA DEMO 42", 52, 71);
ctx.font = "700 21px Arial, sans-serif";
ctx.fillStyle = "#c4e2df";
ctx.textAlign = "right";
ctx.fillText("ROTA 07 · DADOS SINTÉTICOS", 1148, 69);
ctx.textAlign = "left";
ctx.fillStyle = "#ef8b3f";
ctx.font = "900 64px Arial, sans-serif";
ctx.fillText("ATRASO SINTÉTICO", 52, 205);
ctx.fillStyle = "#173d43";
roundedPath(ctx, 883, 143, 267, 100, 26);
ctx.fill();
ctx.fillStyle = "#ffb66e";
ctx.font = "900 43px Arial, sans-serif";
ctx.textAlign = "center";
ctx.fillText(`+${DELAY_MINUTES} MIN`, 1017, 207);
ctx.textAlign = "left";
ctx.strokeStyle = "#31515a";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(52, 270);
ctx.lineTo(1148, 270);
ctx.stroke();
ctx.fillStyle = "#8fb1b5";
ctx.font = "800 24px Arial, sans-serif";
ctx.fillText("PREVISÃO ORIGINAL", 65, 327);
ctx.fillText("PREVISÃO REVISADA", 630, 327);
ctx.fillStyle = "#fffaf0";
ctx.font = "900 116px Arial, sans-serif";
ctx.fillText(ORIGINAL_TIME, 57, 448);
ctx.fillStyle = "#ffad5f";
ctx.fillText(REVISED_TIME, 622, 448);
ctx.fillStyle = "#18373f";
roundedPath(ctx, 48, 507, 1104, 115, 22);
ctx.fill();
ctx.fillStyle = "#c4e2df";
ctx.font = "700 24px Arial, sans-serif";
ctx.fillText("O horário original e a revisão são exibidos separadamente.", 78, 576);
ctx.fillStyle = "#799ca2";
ctx.font = "700 20px Arial, sans-serif";
ctx.fillText("CENÁRIO ILUSTRATIVO · SEM DADOS OU HORÁRIOS REAIS", 52, 742);
ctx.restore();
ctx.strokeStyle = "#07191e";
ctx.lineWidth = 8;
roundedPath(ctx, 10, 10, 1180, 780, 38);
ctx.stroke();
return makeCanvasTexture(panelCanvas);
}
function drawStopIconTexture() {
const iconCanvas = document.createElement("canvas");
iconCanvas.width = 512;
iconCanvas.height = 512;
const ctx = iconCanvas.getContext("2d");
ctx.clearRect(0, 0, 512, 512);
ctx.fillStyle = "#197d83";
ctx.beginPath();
ctx.arc(256, 256, 242, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#fffaf0";
roundedPath(ctx, 124, 100, 264, 306, 48);
ctx.fill();
ctx.fillStyle = "#123b43";
roundedPath(ctx, 156, 142, 200, 94, 18);
ctx.fill();
ctx.fillStyle = "#77b9ba";
ctx.fillRect(169, 155, 79, 28);
ctx.fillRect(264, 155, 79, 28);
ctx.fillStyle = "#123b43";
ctx.fillRect(151, 275, 210, 21);
ctx.fillStyle = "#ef8b3f";
ctx.fillRect(151, 276, 52, 20);
ctx.fillStyle = "#fffaf0";
ctx.beginPath();
ctx.arc(184, 395, 31, 0, Math.PI * 2);
ctx.arc(328, 395, 31, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = "#123b43";
ctx.beginPath();
ctx.arc(184, 395, 14, 0, Math.PI * 2);
ctx.arc(328, 395, 14, 0, Math.PI * 2);
ctx.fill();
return makeCanvasTexture(iconCanvas);
}
const ticketTexture = drawTicketTexture();
const panelTexture = drawPanelTexture();
const stopIconTexture = drawStopIconTexture();
const inkMaterial = new THREE.MeshStandardMaterial({
color: 0x173b43,
roughness: 0.56,
metalness: 0.18
});
const tealMaterial = new THREE.MeshStandardMaterial({
color: 0x197d83,
roughness: 0.48,
metalness: 0.12
});
const orangeMaterial = new THREE.MeshStandardMaterial({
color: 0xef8b3f,
roughness: 0.52
});
const creamMaterial = new THREE.MeshStandardMaterial({
color: 0xf5edda,
roughness: 0.72
});
const poleMaterial = new THREE.MeshStandardMaterial({
color: 0x294a52,
roughness: 0.38,
metalness: 0.52
});
function roundedExtrusion(width, height, radius, depth, material) {
const geometry = new THREE.ExtrudeGeometry(roundedShape(width, height, radius), {
depth,
steps: 1,
curveSegments: 14,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.035,
bevelThickness: 0.025
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
return mesh;
}
function addBox(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, size.z),
material
);
mesh.position.copy(position);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Cenário-base: plataforma, via e volume de fundo.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(60, 50),
new THREE.MeshStandardMaterial({ color: 0xcbd7d1, roughness: 0.96 })
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.18;
ground.receiveShadow = true;
scene.add(ground);
const platform = addBox(
scene,
new THREE.Vector3(13.5, 0.3, 5.2),
new THREE.Vector3(0.65, -0.02, 0.45),
new THREE.MeshStandardMaterial({ color: 0xe8e5d9, roughness: 0.91 }),
false
);
const platformEdge = addBox(
scene,
new THREE.Vector3(13.5, 0.1, 0.16),
new THREE.Vector3(0.65, 0.11, 3.05),
orangeMaterial,
false
);
const road = new THREE.Mesh(
new THREE.PlaneGeometry(60, 10),
new THREE.MeshStandardMaterial({ color: 0x40575b, roughness: 0.95 })
);
road.rotation.x = -Math.PI / 2;
road.position.set(0, -0.12, -5.1);
road.receiveShadow = true;
scene.add(road);
for (let x = -18; x <= 18; x += 4.2) {
addBox(
scene,
new THREE.Vector3(2.2, 0.025, 0.12),
new THREE.Vector3(x, -0.095, -5.05),
new THREE.MeshBasicMaterial({ color: 0xe7c985 }),
false
);
}
const backdrop = addBox(
scene,
new THREE.Vector3(30, 11, 0.5),
new THREE.Vector3(0, 5.25, -10.4),
new THREE.MeshStandardMaterial({ color: 0xc3d7d3, roughness: 0.94 }),
false
);
for (let i = 0; i < 3; i++) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(1.4 + i * 1.15, 0.055, 10, 72),
new THREE.MeshBasicMaterial({ color: 0x9fc5c1, transparent: true, opacity: 0.55 })
);
ring.position.set(-7.4 + i * 0.42, 4.2 + i * 0.2, -10.1);
scene.add(ring);
}
function addShrub(x, z, scale) {
const shrub = new THREE.Group();
shrub.position.set(x, 0.12, z);
shrub.scale.setScalar(scale);
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.09, 0.12, 1.15, 12),
new THREE.MeshStandardMaterial({ color: 0x7f6a52, roughness: 1 })
);
trunk.position.y = 0.57;
trunk.castShadow = true;
shrub.add(trunk);
const crownMaterial = new THREE.MeshStandardMaterial({
color: 0x4f8d78,
roughness: 0.92,
flatShading: true
});
const crownA = new THREE.Mesh(new THREE.DodecahedronGeometry(0.65, 0), crownMaterial);
crownA.position.set(0, 1.35, 0);
crownA.castShadow = true;
shrub.add(crownA);
const crownB = new THREE.Mesh(new THREE.DodecahedronGeometry(0.48, 0), crownMaterial);
crownB.position.set(0.34, 1.05, 0.08);
crownB.castShadow = true;
shrub.add(crownB);
scene.add(shrub);
}
addShrub(-5.35, -1.35, 1.12);
addShrub(5.75, -1.65, 0.86);
// Bilhete e suporte.
const ticketGroup = new THREE.Group();
ticketGroup.position.set(-2.55, 2.95, 0.42);
ticketGroup.rotation.y = 0.13;
ticketGroup.rotation.z = -0.025;
scene.add(ticketGroup);
const ticketBase = roundedExtrusion(2.5, 4.2, 0.16, 0.1, creamMaterial);
ticketGroup.add(ticketBase);
const ticketFaceMaterial = new THREE.MeshStandardMaterial({
map: ticketTexture,
transparent: true,
alphaTest: 0.03,
roughness: 0.77,
metalness: 0,
side: THREE.FrontSide,
depthWrite: false
});
const ticketFace = new THREE.Mesh(new THREE.PlaneGeometry(2.3, 3.987), ticketFaceMaterial);
ticketFace.position.z = 0.145;
ticketGroup.add(ticketFace);
// Símbolo de destino em relevo, aplicado diretamente sobre o bilhete.
const destinationBadge = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.075, 48),
tealMaterial
);
destinationBadge.rotation.x = Math.PI / 2;
destinationBadge.position.set(0.716, 1.13, 0.215);
destinationBadge.castShadow = true;
ticketGroup.add(destinationBadge);
const pinShape = new THREE.Shape();
pinShape.moveTo(0, -0.27);
pinShape.bezierCurveTo(-0.08, -0.11, -0.22, 0.05, -0.22, 0.19);
pinShape.bezierCurveTo(-0.22, 0.31, -0.12, 0.4, 0, 0.4);
pinShape.bezierCurveTo(0.12, 0.4, 0.22, 0.31, 0.22, 0.19);
pinShape.bezierCurveTo(0.22, 0.05, 0.08, -0.11, 0, -0.27);
const pinHole = new THREE.Path();
pinHole.absarc(0, 0.18, 0.085, 0, Math.PI * 2, true);
pinShape.holes.push(pinHole);
const pinGeometry = new THREE.ExtrudeGeometry(pinShape, {
depth: 0.035,
steps: 1,
bevelEnabled: true,
bevelSegments: 2,
bevelSize: 0.012,
bevelThickness: 0.01,
curveSegments: 16
});
const pin = new THREE.Mesh(pinGeometry, creamMaterial);
pin.position.set(0.73, 1.13, 0.27);
pin.castShadow = true;
ticketGroup.add(pin);
const routeDot = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 20, 12),
creamMaterial
);
routeDot.position.set(0.48, 0.98, 0.275);
ticketGroup.add(routeDot);
const routeBar = addBox(
ticketGroup,
new THREE.Vector3(0.25, 0.045, 0.035),
new THREE.Vector3(0.59, 1.02, 0.275),
creamMaterial
);
routeBar.rotation.z = 0.42;
const ticketStand = new THREE.Group();
ticketStand.position.set(-2.55, 0, 0.27);
scene.add(ticketStand);
const ticketFoot = new THREE.Mesh(
new THREE.CylinderGeometry(0.67, 0.78, 0.16, 40),
poleMaterial
);
ticketFoot.position.y = 0.19;
ticketFoot.castShadow = true;
ticketFoot.receiveShadow = true;
ticketStand.add(ticketFoot);
addBox(
ticketStand,
new THREE.Vector3(0.18, 1.25, 0.18),
new THREE.Vector3(0, 0.82, -0.16),
poleMaterial
);
const ticketClip = addBox(
ticketStand,
new THREE.Vector3(0.82, 0.18, 0.32),
new THREE.Vector3(0, 1.28, -0.12),
orangeMaterial
);
// Painel de atraso e poste.
const displayGroup = new THREE.Group();
displayGroup.position.set(2.55, 3.05, 0.24);
displayGroup.rotation.y = -0.075;
scene.add(displayGroup);
const displayHousing = roundedExtrusion(3.3, 2.4, 0.19, 0.28, inkMaterial);
displayGroup.add(displayHousing);
const displayScreenMaterial = new THREE.MeshStandardMaterial({
map: panelTexture,
emissive: 0xffffff,
emissiveMap: panelTexture,
emissiveIntensity: 1.08,
transparent: true,
alphaTest: 0.025,
roughness: 0.42,
metalness: 0,
side: THREE.FrontSide,
depthWrite: false,
toneMapped: false
});
const displayScreen = new THREE.Mesh(
new THREE.PlaneGeometry(3.02, 2.015),
displayScreenMaterial
);
displayScreen.position.z = 0.31;
displayGroup.add(displayScreen);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0xffa14b,
emissive: 0xff8b35,
emissiveIntensity: 1.4,
roughness: 0.3
});
const beacon = new THREE.Mesh(new THREE.SphereGeometry(0.085, 24, 16), beaconMaterial);
beacon.position.set(1.43, 1.03, 0.39);
displayGroup.add(beacon);
const panelPole = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.16, 2.45, 24),
poleMaterial
);
panelPole.position.set(2.55, 1.2, 0.07);
panelPole.castShadow = true;
scene.add(panelPole);
const panelFoot = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.53, 0.17, 32),
poleMaterial
);
panelFoot.position.set(2.55, 0.22, 0.07);
panelFoot.castShadow = true;
panelFoot.receiveShadow = true;
scene.add(panelFoot);
// Identificador da parada, separado do símbolo de destino do bilhete.
const stopMarker = new THREE.Group();
stopMarker.position.set(4.85, 0, -0.12);
scene.add(stopMarker);
const stopPole = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.095, 3.35, 20),
poleMaterial
);
stopPole.position.y = 1.72;
stopPole.castShadow = true;
stopMarker.add(stopPole);
const stopDisc = new THREE.Mesh(
new THREE.CircleGeometry(0.63, 64),
new THREE.MeshStandardMaterial({
map: stopIconTexture,
transparent: true,
alphaTest: 0.03,
roughness: 0.55,
emissive: 0x0b2227,
emissiveIntensity: 0.22,
side: THREE.DoubleSide
})
);
stopDisc.position.set(0, 3.42, 0.055);
stopDisc.castShadow = true;
stopMarker.add(stopDisc);
const stopBase = new THREE.Mesh(
new THREE.CylinderGeometry(0.3, 0.4, 0.14, 28),
poleMaterial
);
stopBase.position.y = 0.18;
stopBase.castShadow = true;
stopMarker.add(stopBase);
// Iluminação de estúdio.
const hemisphere = new THREE.HemisphereLight(0xfff7df, 0x4d6970, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffedcb, 3.1);
keyLight.position.set(-5.5, 10.5, 8.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xa8d9df, 1.35);
fillLight.position.set(7, 5, 5);
scene.add(fillLight);
const panelGlow = new THREE.PointLight(0xff9e50, 7, 5.5, 2);
panelGlow.position.set(2.6, 3.25, 2.1);
scene.add(panelGlow);
const presets = {
general: {
target: new THREE.Vector3(0.65, 2.55, 0),
position: new THREE.Vector3(0.65, 4.65, 12.8)
},
ticket: {
target: new THREE.Vector3(-2.55, 2.95, 0.42),
position: new THREE.Vector3(-1.95, 3.35, 6.65)
},
panel: {
target: new THREE.Vector3(2.55, 3.05, 0.24),
position: new THREE.Vector3(2.75, 3.55, 6.2)
}
};
let activeView = "general";
function setView(name, announce = true) {
const preset = presets[name];
if (!preset) return;
const target = preset.target.clone();
const position = preset.position.clone();
const offset = position.clone().sub(target);
const aspect = window.innerWidth / window.innerHeight;
const portraitScale = Math.max(1, 0.95 / aspect);
offset.multiplyScalar(portraitScale);
desiredTarget.copy(target);
desiredPosition.copy(target).add(offset);
activeView = name;
viewButtons.forEach((button) => {
button.setAttribute("aria-pressed", String(button.dataset.view === name));
});
if (announce) {
const descriptions = {
general: "Vista completa: bilhete com símbolo de destino e painel de atraso, com previsão original 18:40 e revisada 19:05.",
ticket: "Vista do bilhete: o símbolo de destino está visível e os horários 18:40 e 19:05 aparecem em campos separados.",
panel: "Vista do painel: atraso sintético de 25 minutos, previsão original 18:40 e previsão revisada 19:05."
};
live.textContent = descriptions[name];
}
}
function markCustomView() {
activeView = "custom";
viewButtons.forEach((button) => button.setAttribute("aria-pressed", "false"));
}
viewButtons.forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
window.addEventListener("keydown", (event) => {
if (event.key === "1") setView("general");
if (event.key === "2") setView("ticket");
if (event.key === "3") setView("panel");
});
// Controles de câmera próprios, sem addons e sem pointer lock.
const spherical = new THREE.Spherical();
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.classList.add("dragging");
markCustomView();
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
const offset = desiredPosition.clone().sub(desiredTarget);
spherical.setFromVector3(offset);
spherical.theta = THREE.MathUtils.clamp(spherical.theta - dx * 0.005, -0.65, 0.65);
spherical.phi = THREE.MathUtils.clamp(spherical.phi - dy * 0.004, 0.82, 1.43);
offset.setFromSpherical(spherical);
desiredPosition.copy(desiredTarget).add(offset);
});
function endDrag(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener("lostpointercapture", () => {
dragging = false;
canvas.classList.remove("dragging");
});
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
const offset = desiredPosition.clone().sub(desiredTarget);
spherical.setFromVector3(offset);
spherical.radius = THREE.MathUtils.clamp(
spherical.radius * (1 + event.deltaY * 0.001),
3.4,
19
);
offset.setFromSpherical(spherical);
desiredPosition.copy(desiredTarget).add(offset);
markCustomView();
}, { 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, false);
}
window.addEventListener("resize", onResize);
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const easing = 1 - Math.exp(-dt * 6.2);
currentPosition.lerp(desiredPosition, easing);
currentTarget.lerp(desiredTarget, easing);
camera.position.copy(currentPosition);
camera.lookAt(currentTarget);
beaconMaterial.emissiveIntensity = 1.25 + Math.sin(clock.elapsedTime * 2.6) * 0.35;
panelGlow.intensity = 6.6 + Math.sin(clock.elapsedTime * 2.6) * 0.65;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
live.textContent = "Vista completa: previsão original 18:40 e previsão revisada 19:05 em um atraso sintético de 25 minutos.";
});
</script>
</body>
</html>
```