Prompt specification
Build or customize the Three.js 3D scene "Kiosk button grouping panel" 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: Kiosk button grouping panel
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/kiosk-button-grouping-panel-x0477
Scene Description Prompt:
Please make a voxel Three.js scene in one standalone HTML file using cdnjs. Model a tilted kiosk with three large buttons, tactile separators, and matching destination icons; arrange related controls together so their grouping is visually clear.
Working Three.js Starter (kiosk-button-grouping-panel-x0477):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Wayfinding Kiosk</title>
<style>
:root {
--ink: #17343d;
--paper: #f7f1e4;
--accent: #ff6b5f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce7e4;
color: var(--ink);
font-family: "Courier New", Courier, monospace;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.brand {
position: absolute;
top: 24px;
left: 24px;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px 10px 10px;
border: 2px solid rgba(23, 52, 61, 0.85);
background: rgba(247, 241, 228, 0.92);
box-shadow: 6px 6px 0 rgba(23, 52, 61, 0.14);
backdrop-filter: blur(8px);
}
.brand-mark {
display: grid;
grid-template-columns: repeat(2, 8px);
grid-template-rows: repeat(2, 8px);
gap: 3px;
}
.brand-mark i {
display: block;
width: 8px;
height: 8px;
background: var(--ink);
}
.brand-mark i:last-child {
background: var(--accent);
}
.brand-text {
font-size: 11px;
font-weight: 700;
letter-spacing: 0.16em;
line-height: 1.35;
}
h1 {
position: absolute;
top: 96px;
left: 26px;
margin: 0;
max-width: 440px;
font-size: clamp(24px, 4vw, 48px);
line-height: 0.98;
letter-spacing: -0.06em;
text-transform: uppercase;
}
.subtitle {
position: absolute;
top: 164px;
left: 28px;
max-width: 370px;
margin: 0;
font-size: 12px;
line-height: 1.6;
opacity: 0.72;
}
#readout {
position: absolute;
left: 24px;
bottom: 24px;
width: min(360px, calc(100vw - 48px));
padding: 15px 17px;
border-left: 5px solid var(--accent);
background: rgba(247, 241, 228, 0.94);
box-shadow: 6px 6px 0 rgba(23, 52, 61, 0.14);
backdrop-filter: blur(8px);
}
#readout .eyebrow {
margin-bottom: 6px;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
opacity: 0.58;
}
#readout-title {
font-size: 17px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
#readout-detail {
margin-top: 5px;
font-size: 11px;
line-height: 1.5;
opacity: 0.72;
}
#hint {
position: absolute;
right: 24px;
bottom: 24px;
padding: 10px 12px;
border: 1px solid rgba(23, 52, 61, 0.35);
background: rgba(247, 241, 228, 0.75);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #dce7e4;
transition: opacity 350ms ease;
}
#loading span {
padding: 14px 18px;
border: 2px solid var(--ink);
background: var(--paper);
box-shadow: 6px 6px 0 rgba(23, 52, 61, 0.15);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.15em;
}
body.ready #loading {
opacity: 0;
pointer-events: none;
}
@media (max-width: 700px) {
.brand {
top: 14px;
left: 14px;
}
h1 {
top: 78px;
left: 16px;
max-width: 260px;
}
.subtitle {
display: none;
}
#readout {
left: 14px;
bottom: 14px;
width: calc(100vw - 28px);
}
#hint {
display: none;
}
}
</style>
</head>
<body>
<canvas
id="scene"
aria-label="Interactive voxel wayfinding kiosk with museum, metro, and cafe destination buttons"
></canvas>
<div class="hud">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<i></i><i></i><i></i><i></i>
</div>
<div class="brand-text">
CIVIC WAYFIND<br />
TERMINAL 03
</div>
</div>
<h1>Choose your destination.</h1>
<p class="subtitle">
Three tactile destination pods connect civic landmarks, transit, and amenities.
</p>
<div id="readout" aria-live="polite">
<div class="eyebrow">Kiosk status</div>
<div id="readout-title">Select a destination</div>
<div id="readout-detail">
Hover over a button, then click to preview the route.
</div>
</div>
<div id="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
</div>
<div id="loading"><span>ASSEMBLING WAYFINDER</span></div>
<noscript>This scene requires JavaScript.</noscript>
<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 readout = document.querySelector("#readout");
const readoutTitle = document.querySelector("#readout-title");
const readoutDetail = document.querySelector("#readout-detail");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce7e4);
scene.fog = new THREE.Fog(0xdce7e4, 15, 30);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
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.12;
const camera = new THREE.OrthographicCamera(-6, 6, 4, -4, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 2.55, 0);
const orbit = {
theta: 0.53,
phi: 1.12,
radius: 11,
zoom: 1
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
cameraTarget.x + sinPhi * Math.sin(orbit.theta) * orbit.radius,
cameraTarget.y + Math.cos(orbit.phi) * orbit.radius,
cameraTarget.z + sinPhi * Math.cos(orbit.theta) * orbit.radius
);
camera.lookAt(cameraTarget);
camera.zoom = orbit.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const aspect = window.innerWidth / window.innerHeight;
const viewHeight = Math.max(7.8, 7.1 / aspect);
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
resize();
updateCamera();
// Lighting
const hemisphere = new THREE.HemisphereLight(0xf7fff9, 0x829895, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff3d9, 3.5);
sun.position.set(7, 11, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 28;
sun.shadow.bias = -0.0008;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xaed9ff, 1.15);
fill.position.set(-6, 5, -4);
scene.add(fill);
// Shared geometry keeps the many voxels inexpensive.
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.02,
...options
});
}
function block(parent, width, height, depth, x, y, z, color, customMaterial) {
const mesh = new THREE.Mesh(
unitBox,
customMaterial || material(color)
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// Pixel-style lettering built from tiny cubes.
const glyphs = {
A: ["01110", "10001", "10001", "11111", "10001", "10001", "10001"],
C: ["01111", "10000", "10000", "10000", "10000", "10000", "01111"],
D: ["11110", "10001", "10001", "10001", "10001", "10001", "11110"],
E: ["11111", "10000", "10000", "11110", "10000", "10000", "11111"],
F: ["11111", "10000", "10000", "11110", "10000", "10000", "10000"],
G: ["01111", "10000", "10000", "10111", "10001", "10001", "01111"],
I: ["11111", "00100", "00100", "00100", "00100", "00100", "11111"],
M: ["10001", "11011", "10101", "10101", "10001", "10001", "10001"],
N: ["10001", "11001", "11001", "10101", "10011", "10011", "10001"],
O: ["01110", "10001", "10001", "10001", "10001", "10001", "01110"],
R: ["11110", "10001", "10001", "11110", "10100", "10010", "10001"],
S: ["01111", "10000", "10000", "01110", "00001", "00001", "11110"],
T: ["11111", "00100", "00100", "00100", "00100", "00100", "00100"],
U: ["10001", "10001", "10001", "10001", "10001", "10001", "01110"],
" ": ["00000", "00000", "00000", "00000", "00000", "00000", "00000"]
};
const pixelDarkMaterial = material(0x183942, {
roughness: 0.66
});
const pixelCreamMaterial = material(0xfff6df, {
roughness: 0.64
});
function pixelText(text, parent, centerX, centerY, z, cell, pixelMaterial) {
const characters = [...text];
const totalWidth = (characters.length * 6 - 1) * cell;
let cursorX = centerX - totalWidth / 2;
characters.forEach((character) => {
const pattern = glyphs[character] || glyphs[" "];
for (let row = 0; row < pattern.length; row++) {
for (let column = 0; column < pattern[row].length; column++) {
if (pattern[row][column] !== "1") continue;
const cube = new THREE.Mesh(unitBox, pixelMaterial);
cube.scale.set(cell * 0.84, cell * 0.84, 0.042);
cube.position.set(
cursorX + column * cell,
centerY + (3 - row) * cell,
z
);
cube.castShadow = true;
parent.add(cube);
}
}
cursorX += cell * 6;
});
}
function pixelIcon(pattern, parent, centerX, centerY, z, cell, pixelMaterial) {
const rows = pattern.length;
const columns = pattern[0].length;
for (let row = 0; row < rows; row++) {
for (let column = 0; column < columns; column++) {
if (pattern[row][column] !== "1") continue;
const cube = new THREE.Mesh(unitBox, pixelMaterial);
cube.scale.set(cell * 0.9, cell * 0.9, 0.07);
cube.position.set(
centerX + (column - (columns - 1) / 2) * cell,
centerY + ((rows - 1) / 2 - row) * cell,
z
);
cube.castShadow = true;
parent.add(cube);
}
}
}
// Tiled voxel ground.
const floorMaterial = material(0xffffff, { roughness: 0.96 });
const floor = new THREE.InstancedMesh(unitBox, floorMaterial, 21 * 17);
floor.receiveShadow = true;
const dummy = new THREE.Object3D();
const floorColors = [0xc8d6d2, 0xd0dcd8, 0xc1d1cd, 0xd8e1dd];
let floorIndex = 0;
for (let x = -10; x <= 10; x++) {
for (let z = -9; z <= 7; z++) {
dummy.position.set(x, -0.14, z);
dummy.scale.set(0.97, 0.18, 0.97);
dummy.updateMatrix();
floor.setMatrixAt(floorIndex, dummy.matrix);
floor.setColorAt(
floorIndex,
new THREE.Color(floorColors[Math.abs((x * 7 + z * 3)) % floorColors.length])
);
floorIndex++;
}
}
floor.instanceMatrix.needsUpdate = true;
if (floor.instanceColor) floor.instanceColor.needsUpdate = true;
scene.add(floor);
// Raised tiled plinth.
const platformMaterial = material(0xffffff, { roughness: 0.9 });
const platform = new THREE.InstancedMesh(unitBox, platformMaterial, 7 * 5);
platform.receiveShadow = true;
platform.castShadow = true;
let platformIndex = 0;
for (let x = -3; x <= 3; x++) {
for (let z = -2; z <= 2; z++) {
dummy.position.set(x, 0.015, z);
dummy.scale.set(0.98, 0.2, 0.98);
dummy.updateMatrix();
platform.setMatrixAt(platformIndex, dummy.matrix);
platform.setColorAt(
platformIndex,
new THREE.Color(
Math.abs(x + z) % 2 === 0 ? 0xe8e0cd : 0xf1ead9
)
);
platformIndex++;
}
}
platform.instanceMatrix.needsUpdate = true;
if (platform.instanceColor) platform.instanceColor.needsUpdate = true;
scene.add(platform);
// Small colored floor inlays echo the three destination pods.
const inlayColors = [0xff6b5f, 0x31b7d1, 0xf4b63e];
for (let route = 0; route < 3; route++) {
const inlayMaterial = material(inlayColors[route], {
roughness: 0.8
});
for (let step = 0; step < 6; step++) {
block(
scene,
0.28,
0.035,
0.28,
(route - 1) * 1.72,
-0.055,
2.9 + step * 0.48,
inlayColors[route],
inlayMaterial
);
}
}
// Kiosk base and block-built support.
const kiosk = new THREE.Group();
scene.add(kiosk);
const darkFrameMaterial = material(0x183942, {
roughness: 0.7
});
block(kiosk, 4.8, 0.36, 3.0, 0, 0.2, 0.05, 0x17343d, darkFrameMaterial);
block(kiosk, 4.35, 0.12, 2.6, 0, 0.43, 0.05, 0xf2e8d3);
const supportMaterials = [
material(0xe8dfc9),
material(0xf0e8d6),
material(0xd9d1bf)
];
for (let level = 0; level < 2; level++) {
for (let x = 0; x < 4; x++) {
for (let z = 0; z < 2; z++) {
block(
kiosk,
0.52,
0.52,
0.58,
(x - 1.5) * 0.58,
0.68 + level * 0.5,
(z - 0.5) * 0.62 - 0.12,
0xffffff,
supportMaterials[(x + z + level) % supportMaterials.length]
);
}
}
}
// Tilted kiosk face.
const panel = new THREE.Group();
panel.position.set(0, 3.25, 0.15);
panel.rotation.x = -0.13;
kiosk.add(panel);
block(panel, 5.8, 4.3, 0.68, 0, 0, 0, 0x183942, darkFrameMaterial);
block(panel, 5.88, 0.18, 0.82, 0, 2.08, 0.03, 0x102d35, darkFrameMaterial);
block(panel, 5.88, 0.18, 0.82, 0, -2.08, 0.03, 0x102d35, darkFrameMaterial);
// The facade itself is a grid of individual voxel tiles.
const facadeMaterials = [
material(0xe9e2d1),
material(0xf1ead9),
material(0xe1dac9),
material(0xf5eddc)
];
for (let row = 0; row < 8; row++) {
for (let column = 0; column < 11; column++) {
const tile = block(
panel,
0.475,
0.475,
0.07,
(column - 5) * 0.5,
(row - 3.5) * 0.5,
0.365,
0xffffff,
facadeMaterials[(column * 3 + row) % facadeMaterials.length]
);
tile.castShadow = false;
}
}
pixelText(
"DESTINATIONS",
panel,
0,
1.68,
0.465,
0.045,
pixelDarkMaterial
);
// Destination data.
const destinations = [
{
name: "MUSEUM",
color: 0xff6b5f,
css: "#ff6b5f",
detail: "Civic Museum · Main entrance on Level 2",
icon: [
"0011100",
"0111110",
"1101011",
"1111111",
"0010100",
"0010100",
"0010100"
]
},
{
name: "METRO",
color: 0x31b7d1,
css: "#31b7d1",
detail: "Central Station · Follow the blue line to Exit A",
icon: [
"0011100",
"0111110",
"1101011",
"1111111",
"0111110",
"0100010",
"0011100"
]
},
{
name: "CAFE",
color: 0xf4b63e,
css: "#f4b63e",
detail: "Atrium Café · Espresso bar beside the information desk",
icon: [
"1110110",
"1010110",
"1010110",
"1111111",
"0111110",
"0011100",
"0100010"
]
}
];
const separatorMaterial = material(0xfff1d6, {
roughness: 0.62
});
const buttonRecords = [];
const interactiveMeshes = [];
destinations.forEach((destination, index) => {
const pod = new THREE.Group();
pod.position.x = (index - 1) * 1.72;
panel.add(pod);
// Each icon, button, and label is enclosed in its own tactile pod.
const cardMaterial = material(0x284b54, {
roughness: 0.84
});
const card = block(
pod,
1.48,
2.68,
0.12,
0,
-0.15,
0.47,
0x284b54,
cardMaterial
);
// Raised separator rails.
block(pod, 0.07, 2.68, 0.2, -0.74, -0.15, 0.6, 0xfff1d6, separatorMaterial);
block(pod, 0.07, 2.68, 0.2, 0.74, -0.15, 0.6, 0xfff1d6, separatorMaterial);
block(pod, 1.48, 0.07, 0.2, 0, 1.19, 0.6, 0xfff1d6, separatorMaterial);
block(pod, 1.48, 0.07, 0.2, 0, -1.49, 0.6, 0xfff1d6, separatorMaterial);
// Small raised bumps make the separators visibly tactile.
for (let bump = 0; bump < 12; bump++) {
const bumpY = -1.28 + bump * 0.215;
block(pod, 0.115, 0.09, 0.12, -0.74, bumpY, 0.735, 0xfff1d6, separatorMaterial);
block(pod, 0.115, 0.09, 0.12, 0.74, bumpY, 0.735, 0xfff1d6, separatorMaterial);
}
// Matching destination icon plaque.
const accentMaterial = material(destination.color, {
roughness: 0.62
});
block(
pod,
0.86,
0.86,
0.16,
0,
0.67,
0.63,
destination.color,
accentMaterial
);
pixelIcon(
destination.icon,
pod,
0,
0.67,
0.755,
0.105,
pixelDarkMaterial
);
// Large physical button.
const buttonGroup = new THREE.Group();
buttonGroup.position.set(0, -0.35, 0);
pod.add(buttonGroup);
const buttonBase = block(
buttonGroup,
1.18,
0.92,
0.2,
0,
0,
0.66,
0x102f38,
darkFrameMaterial
);
buttonBase.castShadow = true;
const capMaterial = material(destination.color, {
roughness: 0.52,
metalness: 0.04,
emissive: destination.color,
emissiveIntensity: 0
});
const cap = block(
buttonGroup,
1.06,
0.8,
0.2,
0,
0,
0.8,
destination.color,
capMaterial
);
cap.userData.destinationIndex = index;
interactiveMeshes.push(cap);
pixelText(
"GO",
buttonGroup,
0,
0,
0.922,
0.052,
pixelCreamMaterial
);
// Destination label beneath the button.
pixelText(
destination.name,
pod,
0,
-1.16,
0.565,
0.038,
pixelCreamMaterial
);
buttonRecords.push({
group: buttonGroup,
cap,
capMaterial,
cardMaterial,
index,
hover: false,
pressed: false,
selected: false
});
});
// Background voxel architecture.
const backgroundMaterialA = material(0x91afb0, { roughness: 0.94 });
const backgroundMaterialB = material(0xa8bfbd, { roughness: 0.94 });
const buildings = [
[-6.0, 0.75, -6.4, 1.8, 1.5, 1.5],
[-4.7, 1.2, -6.7, 1.4, 2.4, 1.4],
[-3.7, 0.55, -6.2, 1.3, 1.1, 1.4],
[4.6, 0.7, -6.3, 1.8, 1.4, 1.6],
[6.0, 1.05, -6.5, 1.3, 2.1, 1.4]
];
buildings.forEach((data, index) => {
block(
scene,
data[3],
data[4],
data[5],
data[0],
data[1],
data[2],
0xffffff,
index % 2 ? backgroundMaterialA : backgroundMaterialB
);
});
// A small block planter.
const planterMaterial = material(0xd7b77d);
const leafMaterials = [
material(0x4f8b69),
material(0x66a078),
material(0x3f765d)
];
block(scene, 1.05, 0.65, 1.05, 4.8, 0.3, 0.4, 0xd7b77d, planterMaterial);
block(scene, 0.18, 0.8, 0.18, 4.8, 0.95, 0.4, 0x6e6249);
const leafPositions = [
[4.55, 1.35, 0.4, 0.46],
[5.02, 1.35, 0.42, 0.46],
[4.78, 1.68, 0.4, 0.44],
[4.78, 1.35, 0.15, 0.42],
[4.78, 1.35, 0.66, 0.42]
];
leafPositions.forEach((leaf, index) => {
block(
scene,
leaf[3],
leaf[3],
leaf[3],
leaf[0],
leaf[1],
leaf[2],
0xffffff,
leafMaterials[index % leafMaterials.length]
);
});
// Pointer interaction and custom camera controls.
const pointer = new THREE.Vector2(10, 10);
const raycaster = new THREE.Raycaster();
let pointerDown = false;
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
let dragDistance = 0;
function updatePointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function getHoveredDestination() {
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(interactiveMeshes, false);
if (!intersections.length) return -1;
return intersections[0].object.userData.destinationIndex;
}
function setHover(index) {
buttonRecords.forEach((record) => {
record.hover = record.index === index;
});
canvas.style.cursor = index >= 0 ? "pointer" : "grab";
}
function selectDestination(index) {
const destination = destinations[index];
buttonRecords.forEach((record) => {
record.selected = record.index === index;
});
readout.style.setProperty("--accent", destination.css);
readoutTitle.textContent = destination.name;
readoutDetail.textContent = destination.detail;
}
canvas.addEventListener("pointerdown", (event) => {
pointerDown = true;
dragging = false;
dragDistance = 0;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
updatePointer(event);
if (pointerDown) {
const deltaX = event.clientX - lastPointerX;
const deltaY = event.clientY - lastPointerY;
dragDistance += Math.abs(deltaX) + Math.abs(deltaY);
if (dragDistance > 5) dragging = true;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - deltaY * 0.005,
0.68,
1.42
);
lastPointerX = event.clientX;
lastPointerY = event.clientY;
updateCamera();
} else {
setHover(getHoveredDestination());
}
});
canvas.addEventListener("pointerup", (event) => {
updatePointer(event);
if (!dragging && dragDistance < 6) {
const selected = getHoveredDestination();
if (selected >= 0) {
const record = buttonRecords[selected];
record.pressed = true;
selectDestination(selected);
window.setTimeout(() => {
record.pressed = false;
}, 180);
}
}
pointerDown = false;
dragging = false;
canvas.style.cursor = getHoveredDestination() >= 0 ? "pointer" : "grab";
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
dragging = false;
setHover(-1);
});
canvas.addEventListener("pointerleave", () => {
if (!pointerDown) setHover(-1);
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.zoom = THREE.MathUtils.clamp(
orbit.zoom * Math.exp(-event.deltaY * 0.001),
0.72,
1.85
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => {
orbit.theta = 0.53;
orbit.phi = 1.12;
orbit.zoom = 1;
updateCamera();
});
// Animation loop.
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
buttonRecords.forEach((record) => {
const targetZ =
(record.pressed ? -0.075 : 0) +
(record.hover ? 0.075 : 0);
record.group.position.z = THREE.MathUtils.damp(
record.group.position.z,
targetZ,
14,
delta
);
const targetEmissive = record.selected
? 0.24
: record.hover
? 0.13
: 0;
record.capMaterial.emissiveIntensity = THREE.MathUtils.damp(
record.capMaterial.emissiveIntensity,
targetEmissive,
12,
delta
);
const targetCardEmissive = record.selected ? 0.12 : 0;
record.cardMaterial.emissive.setHex(0x7bd6db);
record.cardMaterial.emissiveIntensity = THREE.MathUtils.damp(
record.cardMaterial.emissiveIntensity,
targetCardEmissive,
10,
delta
);
});
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
requestAnimationFrame(() => {
document.body.classList.add("ready");
});
</script>
</body>
</html>
```