Prompt specification
Build or customize the Three.js 3D scene "Compare Two Verified Braille Letters" 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: Compare Two Verified Braille Letters
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/compare-two-verified-braille-letters-x3422
Scene Description Prompt:
Please use Three.js from cdnjs for a stylized scene based on this idea: compare two verified Braille letters. Show two source-checked uncontracted Braille letters as raised cells beside their labels. Let users rotate the display while preserving a visible canonical reading orientation. Return one self-contained HTML file.
Working Three.js Starter (compare-two-verified-braille-letters-x3422):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#07151e">
<title>Braille Comparison — Source-Checked Uncontracted Letters</title>
<style>
:root {
color-scheme: dark;
--bg: #07151e;
--panel: rgba(9, 29, 39, 0.82);
--panel-solid: #0b202b;
--line: rgba(199, 234, 239, 0.16);
--text: #edf7f5;
--muted: #9db8bd;
--teal: #32d8c4;
--coral: #ff806c;
--gold: #f1ca76;
--shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overscroll-behavior: none;
}
button,
select,
summary {
font: inherit;
}
button,
select {
color: var(--text);
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
outline: none;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
#scene:focus-visible {
outline: 2px solid var(--teal);
outline-offset: -4px;
}
.hero {
position: fixed;
z-index: 4;
top: 28px;
left: 30px;
width: min(430px, calc(100vw - 60px));
pointer-events: none;
text-shadow: 0 2px 22px rgba(0, 0, 0, 0.48);
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 9px;
margin-bottom: 13px;
color: #bcd4d7;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--teal);
box-shadow: 0 0 0 5px rgba(50, 216, 196, 0.12);
}
h1 {
margin: 0;
font-size: clamp(34px, 4.1vw, 58px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 760;
}
h1 em {
color: var(--teal);
font-style: normal;
font-weight: 620;
}
.lede {
max-width: 390px;
margin: 15px 0 0;
color: #b7ccd0;
font-size: 14px;
line-height: 1.55;
}
.gesture-hint {
display: flex;
align-items: center;
gap: 9px;
margin-top: 17px;
color: #8eabb0;
font-size: 12px;
}
.gesture-hint svg {
width: 18px;
height: 18px;
flex: 0 0 auto;
}
.panel {
border: 1px solid var(--line);
border-radius: 20px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(20px) saturate(125%);
-webkit-backdrop-filter: blur(20px) saturate(125%);
}
.controls {
position: fixed;
z-index: 6;
top: 28px;
right: 30px;
width: 360px;
padding: 18px;
}
.panel-title {
margin: 0 0 13px;
color: #dbeaec;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.select-row {
display: grid;
grid-template-columns: 1fr 42px 1fr;
gap: 10px;
align-items: end;
}
.field {
display: grid;
gap: 7px;
}
.field > span {
color: var(--muted);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
text-transform: uppercase;
}
select {
width: 100%;
height: 48px;
padding: 0 38px 0 13px;
border: 1px solid rgba(211, 239, 241, 0.2);
border-radius: 12px;
outline: none;
background: #102b36;
font-size: 20px;
font-weight: 760;
cursor: pointer;
}
select:focus {
border-color: var(--teal);
box-shadow: 0 0 0 3px rgba(50, 216, 196, 0.12);
}
#letterA {
border-top-color: rgba(50, 216, 196, 0.65);
}
#letterB {
border-top-color: rgba(255, 128, 108, 0.65);
}
.icon-button {
display: grid;
place-items: center;
width: 42px;
height: 48px;
padding: 0;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(255, 255, 255, 0.045);
cursor: pointer;
transition: background 160ms ease, transform 160ms ease;
}
.icon-button:hover {
background: rgba(255, 255, 255, 0.1);
transform: translateY(-1px);
}
.icon-button svg {
width: 18px;
height: 18px;
}
.comparison-summary {
min-height: 42px;
margin: 14px 0;
padding: 11px 12px;
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 12px;
background: rgba(0, 0, 0, 0.13);
color: #c4d7d9;
font-size: 12px;
line-height: 1.45;
}
.comparison-summary strong {
color: #f3fbf9;
}
.button-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.button {
min-height: 42px;
padding: 9px 12px;
border: 1px solid rgba(211, 239, 241, 0.16);
border-radius: 12px;
background: rgba(255, 255, 255, 0.055);
color: #dcebed;
font-size: 12px;
font-weight: 720;
cursor: pointer;
transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.button:hover {
border-color: rgba(50, 216, 196, 0.45);
background: rgba(50, 216, 196, 0.09);
transform: translateY(-1px);
}
.button.primary {
border-color: rgba(50, 216, 196, 0.35);
color: #eafffb;
background: rgba(50, 216, 196, 0.1);
}
.source-panel {
position: fixed;
z-index: 6;
left: 30px;
bottom: 28px;
width: 390px;
max-width: calc(100vw - 60px);
padding: 0;
overflow: hidden;
}
.source-panel summary {
padding: 15px 18px;
color: #dcebed;
font-size: 12px;
font-weight: 750;
cursor: pointer;
list-style: none;
user-select: none;
}
.source-panel summary::-webkit-details-marker {
display: none;
}
.source-panel summary::after {
content: "+";
float: right;
color: var(--teal);
font-size: 18px;
line-height: 1;
}
.source-panel[open] summary::after {
content: "−";
}
.source-content {
padding: 0 18px 17px;
border-top: 1px solid var(--line);
color: #a9c1c5;
font-size: 12px;
line-height: 1.55;
}
.source-content p {
margin: 13px 0;
}
.source-content a {
display: block;
margin-top: 9px;
color: #d9f7f3;
text-underline-offset: 3px;
}
.source-content a:hover {
color: var(--teal);
}
.source-content code {
color: #f3dba1;
font-size: 11px;
}
.orientation {
position: fixed;
z-index: 7;
right: 30px;
bottom: 28px;
width: 330px;
padding: 15px 17px 16px;
}
.orientation-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 13px;
}
.orientation-title {
color: #dcebed;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.view-readout {
padding: 5px 8px;
border: 1px solid rgba(50, 216, 196, 0.24);
border-radius: 999px;
background: rgba(50, 216, 196, 0.08);
color: #9fe9df;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
white-space: nowrap;
}
.mini-row {
display: grid;
grid-template-columns: 1fr 34px 1fr;
gap: 9px;
align-items: center;
}
.mini-item {
display: grid;
justify-items: center;
gap: 5px;
}
.mini-cell {
display: grid;
grid-template-columns: repeat(2, 27px);
grid-template-rows: repeat(3, 27px);
gap: 7px;
padding: 9px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
background: rgba(0, 0, 0, 0.15);
}
.mini-dot {
display: grid;
place-items: center;
width: 27px;
height: 27px;
border: 1px solid rgba(209, 235, 237, 0.28);
border-radius: 50%;
color: #779198;
font-size: 9px;
font-weight: 800;
}
.mini-dot.active {
border-color: transparent;
color: #06171d;
background: var(--dot-accent, var(--teal));
box-shadow: 0 0 14px color-mix(in srgb, var(--dot-accent, var(--teal)) 35%, transparent);
}
.d1 { grid-area: 1 / 1; }
.d4 { grid-area: 1 / 2; }
.d2 { grid-area: 2 / 1; }
.d5 { grid-area: 2 / 2; }
.d3 { grid-area: 3 / 1; }
.d6 { grid-area: 3 / 2; }
.mini-caption {
color: #a9c1c5;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.read-arrow {
color: var(--gold);
text-align: center;
font-size: 28px;
line-height: 1;
}
.orientation-note {
margin: 12px 0 0;
color: #92adb2;
font-size: 11px;
line-height: 1.45;
}
.orientation-note strong {
color: #d9e9ea;
}
#loading {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
background: #07151e;
transition: opacity 350ms ease, visibility 350ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
.loader {
display: grid;
justify-items: center;
gap: 16px;
color: #b9d0d3;
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.loader-dots {
display: flex;
gap: 8px;
}
.loader-dots i {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--teal);
animation: pulse 900ms ease-in-out infinite alternate;
}
.loader-dots i:nth-child(2) { animation-delay: 150ms; }
.loader-dots i:nth-child(3) { animation-delay: 300ms; }
@keyframes pulse {
from { opacity: 0.25; transform: translateY(3px); }
to { opacity: 1; transform: translateY(-3px); }
}
.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: 900px) {
.hero {
top: 20px;
left: 20px;
}
.controls {
top: 20px;
right: 20px;
width: 330px;
}
.source-panel {
left: 20px;
bottom: 20px;
width: 340px;
}
.orientation {
right: 20px;
bottom: 20px;
width: 300px;
}
}
@media (max-width: 680px) {
.hero {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
}
h1 {
font-size: 31px;
}
.lede,
.gesture-hint {
display: none;
}
.eyebrow {
margin-bottom: 7px;
font-size: 9px;
}
.controls {
top: 105px;
right: 14px;
left: 14px;
width: auto;
padding: 13px;
border-radius: 16px;
}
.panel-title {
margin-bottom: 10px;
}
.comparison-summary {
min-height: 0;
margin: 10px 0;
padding: 8px 10px;
}
.source-panel {
right: 14px;
bottom: 14px;
left: 14px;
width: auto;
max-width: none;
}
.source-content {
max-height: 190px;
overflow: auto;
}
.orientation {
top: 310px;
right: 14px;
bottom: auto;
width: 244px;
padding: 11px;
border-radius: 16px;
}
.mini-cell {
grid-template-columns: repeat(2, 22px);
grid-template-rows: repeat(3, 22px);
gap: 5px;
padding: 7px;
}
.mini-dot {
width: 22px;
height: 22px;
font-size: 8px;
}
.orientation-note {
font-size: 10px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive three-dimensional comparison of two uncontracted Braille letters. Drag or use arrow keys to rotate the view."
></canvas>
<header class="hero">
<div class="eyebrow">
<span class="status-dot"></span>
Braille lab / source-checked
</div>
<h1>Read the shape.<br><em>Rotate the view.</em></h1>
<p class="lede">
Compare two basic English Braille cells as raised dots. The canonical,
front-facing reference remains pinned while the display moves.
</p>
<div class="gesture-hint">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M8 8.5V6a2 2 0 0 1 4 0v2m0 0V5a2 2 0 0 1 4 0v3m0 0V7a2 2 0 0 1 4 0v7.5a6 6 0 0 1-6 6h-1.2a6 6 0 0 1-4.5-2L3.8 15a2 2 0 0 1 3-2.6L8 13.5V8.5Z"
stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Drag to rotate · wheel or pinch to zoom · arrow keys when focused
</div>
</header>
<section class="panel controls" aria-label="Comparison controls">
<h2 class="panel-title">Choose two letters</h2>
<div class="select-row">
<label class="field" for="letterA">
<span>Cell one</span>
<select id="letterA" aria-label="First Braille letter"></select>
</label>
<button class="icon-button" id="swap" type="button" aria-label="Swap the two letters" title="Swap letters">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M7 7h12m0 0-3-3m3 3-3 3M17 17H5m0 0 3 3m-3-3 3-3"
stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<label class="field" for="letterB">
<span>Cell two</span>
<select id="letterB" aria-label="Second Braille letter"></select>
</label>
</div>
<div class="comparison-summary" id="comparisonSummary"></div>
<div class="button-row">
<button class="button primary" id="random" type="button">Surprise me</button>
<button class="button" id="reset" type="button">Canonical view</button>
</div>
</section>
<details class="panel source-panel">
<summary>Sources & verification</summary>
<div class="source-content">
<p>
Every embedded English letter pattern was cross-checked against the
published Unicode Braille Patterns table and MedlinePlus’s Braille
alphabet chart. Unicode values are also recomputed at runtime from the
dot-number mask.
</p>
<a href="https://www.unicode.org/Public/UCD/latest/ucd/BraillePattern.txt"
target="_blank" rel="noopener noreferrer">
Unicode Consortium — Braille Patterns
</a>
<a href="https://www.unicode.org/charts/PDF/U2800.pdf"
target="_blank" rel="noopener noreferrer">
Unicode chart — Braille Patterns U+2800–U+28FF
</a>
<a href="https://medlineplus.gov/braillealphabet.html"
target="_blank" rel="noopener noreferrer">
MedlinePlus — Braille Alphabet
</a>
<p>
These are the basic alphabetic patterns, with contractions omitted.
Braille cells do not encode letter case, so the visible A–Z labels are
display labels; for example, <code>U+2801</code> represents the dot-1
pattern.
</p>
</div>
</details>
<section class="panel orientation" aria-label="Pinned canonical Braille orientation">
<div class="orientation-head">
<span class="orientation-title">Pinned canonical reference</span>
<span class="view-readout" id="viewReadout">CANONICAL VIEW</span>
</div>
<div class="mini-row">
<div class="mini-item">
<div class="mini-cell" id="miniA"></div>
<span class="mini-caption" id="miniCaptionA">A</span>
</div>
<div class="read-arrow" aria-hidden="true">→</div>
<div class="mini-item">
<div class="mini-cell" id="miniB"></div>
<span class="mini-caption" id="miniCaptionB">B</span>
</div>
</div>
<p class="orientation-note">
<strong>Dot 1 is upper-left.</strong> Read cells left → right. This
reference stays front-facing while the 3D display rotates.
</p>
</section>
<div id="announcement" class="sr-only" aria-live="polite"></div>
<div id="loading">
<div class="loader">
<div class="loader-dots"><i></i><i></i><i></i></div>
<span>Preparing raised Braille cells</span>
</div>
</div>
<noscript>This interactive comparison 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 LETTERS = [
{ id: "A", dots: [1] },
{ id: "B", dots: [1, 2] },
{ id: "C", dots: [1, 4] },
{ id: "D", dots: [1, 4, 5] },
{ id: "E", dots: [1, 5] },
{ id: "F", dots: [1, 2, 4] },
{ id: "G", dots: [1, 2, 4, 5] },
{ id: "H", dots: [1, 2, 5] },
{ id: "I", dots: [2, 4] },
{ id: "J", dots: [2, 4, 5] },
{ id: "K", dots: [1, 3] },
{ id: "L", dots: [1, 2, 3] },
{ id: "M", dots: [1, 3, 4] },
{ id: "N", dots: [1, 3, 4, 5] },
{ id: "O", dots: [1, 3, 5] },
{ id: "P", dots: [1, 2, 3, 4] },
{ id: "Q", dots: [1, 2, 3, 4, 5] },
{ id: "R", dots: [1, 2, 3, 5] },
{ id: "S", dots: [2, 3, 4] },
{ id: "T", dots: [2, 3, 4, 5] },
{ id: "U", dots: [1, 3, 6] },
{ id: "V", dots: [1, 2, 3, 6] },
{ id: "W", dots: [2, 4, 5, 6] },
{ id: "X", dots: [1, 3, 4, 6] },
{ id: "Y", dots: [1, 3, 4, 5, 6] },
{ id: "Z", dots: [1, 3, 5, 6] }
];
const LETTER_BY_ID = Object.fromEntries(LETTERS.map((letter) => [letter.id, letter]));
const DOT_POSITIONS = {
1: [-0.43, 0.65],
4: [ 0.43, 0.65],
2: [-0.43, 0.00],
5: [ 0.43, 0.00],
3: [-0.43,-0.65],
6: [ 0.43,-0.65]
};
const canvas = document.querySelector("#scene");
const selectA = document.querySelector("#letterA");
const selectB = document.querySelector("#letterB");
const summary = document.querySelector("#comparisonSummary");
const announcement = document.querySelector("#announcement");
const viewReadout = document.querySelector("#viewReadout");
const loading = document.querySelector("#loading");
const reducedMotion = matchMedia("(prefers-reduced-motion: reduce)").matches;
function maskForDots(dots) {
return dots.reduce((mask, dot) => mask | (1 << (dot - 1)), 0);
}
function unicodeFor(letter) {
return `U+${(0x2800 + maskForDots(letter.dots)).toString(16).toUpperCase().padStart(4, "0")}`;
}
function hexCSS(hex) {
return `#${new THREE.Color(hex).getHexString()}`;
}
LETTERS.forEach((letter) => {
for (const select of [selectA, selectB]) {
const option = document.createElement("option");
option.value = letter.id;
option.textContent = letter.id;
select.append(option);
}
});
selectA.value = "A";
selectB.value = "B";
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.querySelector(".loader span").textContent =
"WebGL is unavailable. Please open this file in a WebGL-capable browser.";
throw error;
}
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07151e);
scene.fog = new THREE.FogExp2(0x07151e, 0.027);
const camera = new THREE.PerspectiveCamera(38, 1, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.05, 0);
let yaw = 0;
let pitch = 0.06;
let radius = 11.2;
let targetYaw = 0;
let targetPitch = 0.06;
let targetRadius = 11.2;
const stage = new THREE.Group();
stage.position.y = 0.05;
scene.add(stage);
const hemisphere = new THREE.HemisphereLight(0xc5f5ff, 0x10202a, 1.75);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.15);
keyLight.position.set(4.5, 8, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const tealLight = new THREE.PointLight(0x36d9c8, 28, 15, 2);
tealLight.position.set(-4.5, 2.5, 4.5);
scene.add(tealLight);
const coralLight = new THREE.PointLight(0xff806c, 26, 14, 2);
coralLight.position.set(4.5, 1.4, 4);
scene.add(coralLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0x081923,
roughness: 0.9,
metalness: 0.05
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.82;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(30, 30, 0x1c4a55, 0x0e2a34);
grid.position.y = -2.805;
grid.material.transparent = true;
grid.material.opacity = 0.48;
scene.add(grid);
const platform = new THREE.Mesh(
new THREE.CylinderGeometry(5.65, 6.05, 0.28, 96),
new THREE.MeshStandardMaterial({
color: 0x102a34,
roughness: 0.52,
metalness: 0.28
})
);
platform.position.y = -2.66;
platform.receiveShadow = true;
platform.castShadow = true;
scene.add(platform);
for (const [ringRadius, opacity] of [[5.15, 0.42], [5.48, 0.18]]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(ringRadius, 0.018, 8, 160),
new THREE.MeshBasicMaterial({
color: 0x43cdbd,
transparent: true,
opacity,
depthWrite: false
})
);
ring.rotation.x = Math.PI / 2;
ring.position.y = -2.50;
scene.add(ring);
}
const backdropRing = new THREE.Mesh(
new THREE.TorusGeometry(5.2, 0.022, 8, 160),
new THREE.MeshBasicMaterial({
color: 0x3bb7ae,
transparent: true,
opacity: 0.13,
depthWrite: false
})
);
backdropRing.position.set(0, 0.15, -2.2);
scene.add(backdropRing);
const particlePositions = new Float32Array(180 * 3);
for (let i = 0; i < 180; i++) {
particlePositions[i * 3] = (Math.random() - 0.5) * 22;
particlePositions[i * 3 + 1] = -2 + Math.random() * 9;
particlePositions[i * 3 + 2] = -3 - Math.random() * 8;
}
const particleGeometry = new THREE.BufferGeometry();
particleGeometry.setAttribute(
"position",
new THREE.BufferAttribute(particlePositions, 3)
);
const particles = new THREE.Points(
particleGeometry,
new THREE.PointsMaterial({
color: 0x9ce7df,
size: 0.026,
transparent: true,
opacity: 0.58,
depthWrite: false
})
);
scene.add(particles);
function roundedBoxGeometry(width, height, depth, radius, bevel = 0.035) {
const w = width;
const h = height;
const r = Math.min(radius, w / 2, h / 2);
const x = -w / 2;
const y = -h / 2;
const shape = new THREE.Shape();
shape.moveTo(x + r, y);
shape.lineTo(x + w - r, y);
shape.quadraticCurveTo(x + w, y, x + w, y + r);
shape.lineTo(x + w, y + h - r);
shape.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
shape.lineTo(x + r, y + h);
shape.quadraticCurveTo(x, y + h, x, y + h - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
steps: 1,
curveSegments: 12,
bevelEnabled: bevel > 0,
bevelSegments: 3,
bevelSize: bevel,
bevelThickness: bevel
});
geometry.center();
geometry.computeVertexNormals();
return geometry;
}
function makeTextPlane(text, {
width,
height,
fontSize = 0.55,
color = "#17323b",
weight = 800,
align = "center"
}) {
const canvasElement = document.createElement("canvas");
canvasElement.width = 1024;
canvasElement.height = Math.max(48, Math.round(1024 * height / width));
const context = canvasElement.getContext("2d");
context.clearRect(0, 0, canvasElement.width, canvasElement.height);
context.fillStyle = color;
context.textAlign = align;
context.textBaseline = "middle";
context.font = `${weight} ${Math.round(canvasElement.height * fontSize)}px Inter, ui-sans-serif, system-ui, sans-serif`;
const x = align === "left"
? canvasElement.width * 0.04
: align === "right"
? canvasElement.width * 0.96
: canvasElement.width * 0.5;
context.fillText(
text,
x,
canvasElement.height * 0.52,
canvasElement.width * 0.92
);
const texture = new THREE.CanvasTexture(canvasElement);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
alphaTest: 0.015,
depthWrite: false,
toneMapped: false
});
return new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
material
);
}
function makeCard(x, accent, cardTint) {
const group = new THREE.Group();
group.position.x = x;
const board = new THREE.Mesh(
roundedBoxGeometry(4.0, 4.65, 0.2, 0.27, 0.055),
new THREE.MeshStandardMaterial({
color: cardTint,
roughness: 0.73,
metalness: 0.04
})
);
board.castShadow = true;
board.receiveShadow = true;
group.add(board);
const accentBar = new THREE.Mesh(
new THREE.BoxGeometry(3.28, 0.035, 0.035),
new THREE.MeshBasicMaterial({ color: accent })
);
accentBar.position.set(0, 1.58, 0.16);
group.add(accentBar);
const verified = makeTextPlane("✓ SOURCE-CHECKED • UNCONTRACTED", {
width: 3.35,
height: 0.24,
fontSize: 0.44,
color: "#426069",
weight: 800
});
verified.position.set(0, 1.91, 0.17);
group.add(verified);
const alphabet = makeTextPlane("ENGLISH ALPHABET", {
width: 3.25,
height: 0.2,
fontSize: 0.42,
color: "#6a7f83",
weight: 700
});
alphabet.position.set(0, -1.92, 0.17);
group.add(alphabet);
const dynamic = new THREE.Group();
group.add(dynamic);
stage.add(group);
return { group, dynamic, accent };
}
const leftCard = makeCard(-2.35, 0x32d8c4, 0xf4efe2);
const rightCard = makeCard(2.35, 0xff806c, 0xf2e8da);
const divider = new THREE.Mesh(
new THREE.BoxGeometry(0.025, 3.4, 0.025),
new THREE.MeshBasicMaterial({
color: 0x8fc5c5,
transparent: true,
opacity: 0.22
})
);
divider.position.set(0, 0.18, 0.12);
stage.add(divider);
const versusDisk = new THREE.Mesh(
new THREE.CylinderGeometry(0.35, 0.35, 0.09, 64),
new THREE.MeshStandardMaterial({
color: 0x102e38,
roughness: 0.4,
metalness: 0.25
})
);
versusDisk.rotation.x = Math.PI / 2;
versusDisk.position.set(0, 0.63, 0.23);
versusDisk.castShadow = true;
stage.add(versusDisk);
const versusText = makeTextPlane("VS", {
width: 0.45,
height: 0.31,
fontSize: 0.52,
color: "#f1ca76",
weight: 900
});
versusText.position.set(0, 0.63, 0.29);
stage.add(versusText);
let dotAnimations = [];
function disposeGroup(group) {
const geometries = new Set();
const materials = new Set();
const textures = new Set();
group.traverse((object) => {
if (object.geometry) geometries.add(object.geometry);
if (object.material) {
const objectMaterials = Array.isArray(object.material)
? object.material
: [object.material];
for (const material of objectMaterials) {
materials.add(material);
if (material.map) textures.add(material.map);
}
}
});
group.clear();
geometries.forEach((geometry) => geometry.dispose());
textures.forEach((texture) => texture.dispose());
materials.forEach((material) => material.dispose());
}
function buildBrailleCard(card, letter) {
disposeGroup(card.dynamic);
const cell = new THREE.Group();
cell.position.set(-0.55, 0.18, 0);
card.dynamic.add(cell);
const plaque = new THREE.Mesh(
roundedBoxGeometry(1.86, 2.34, 0.08, 0.16, 0.025),
new THREE.MeshStandardMaterial({
color: 0xe6dece,
roughness: 0.78,
metalness: 0.03
})
);
plaque.position.z = 0.15;
plaque.castShadow = true;
plaque.receiveShadow = true;
cell.add(plaque);
const socketMaterial = new THREE.MeshBasicMaterial({
color: 0x9ca39c,
transparent: true,
opacity: 0.25,
depthWrite: false
});
const activeBaseMaterial = new THREE.MeshStandardMaterial({
color: card.accent,
roughness: 0.36,
metalness: 0.18,
emissive: card.accent,
emissiveIntensity: 0.035
});
const domeGeometry = new THREE.SphereGeometry(
0.185,
32,
18,
0,
Math.PI * 2,
0,
Math.PI / 2
);
domeGeometry.scale(1, 0.72, 1);
domeGeometry.rotateX(Math.PI / 2);
for (const dotNumber of [1, 2, 3, 4, 5, 6]) {
const [dotX, dotY] = DOT_POSITIONS[dotNumber];
const isActive = letter.dots.includes(dotNumber);
if (!isActive) {
const socket = new THREE.Mesh(
new THREE.CircleGeometry(0.118, 40),
socketMaterial
);
socket.position.set(dotX, dotY, 0.205);
cell.add(socket);
continue;
}
const base = new THREE.Mesh(
new THREE.CircleGeometry(0.19, 40),
activeBaseMaterial
);
base.position.set(dotX, dotY, 0.208);
cell.add(base);
const dome = new THREE.Mesh(domeGeometry, activeBaseMaterial);
dome.position.set(dotX, dotY, 0.21);
dome.castShadow = true;
dome.userData.start = performance.now() + letter.dots.indexOf(dotNumber) * 65;
dome.scale.setScalar(reducedMotion ? 1 : 0.001);
cell.add(dome);
dotAnimations.push(dome);
}
const letterLabel = makeTextPlane(letter.id, {
width: 1.02,
height: 1.24,
fontSize: 0.58,
color: "#17323b",
weight: 850
});
letterLabel.position.set(1.05, 0.69, 0.23);
card.dynamic.add(letterLabel);
const dotsHeading = makeTextPlane("RAISED DOTS", {
width: 1.25,
height: 0.21,
fontSize: 0.48,
color: "#667d82",
weight: 800
});
dotsHeading.position.set(1.05, -0.28, 0.23);
card.dynamic.add(dotsHeading);
const dotsValue = makeTextPlane(letter.dots.join(", "), {
width: 1.25,
height: 0.4,
fontSize: 0.55,
color: hexCSS(card.accent),
weight: 850
});
dotsValue.position.set(1.05, -0.69, 0.23);
card.dynamic.add(dotsValue);
const unicodeLabel = makeTextPlane(unicodeFor(letter), {
width: 1.25,
height: 0.22,
fontSize: 0.46,
color: "#687d81",
weight: 750
});
unicodeLabel.position.set(1.05, -1.18, 0.23);
card.dynamic.add(unicodeLabel);
}
function renderMini(element, letter, accent) {
element.replaceChildren();
for (const dotNumber of [1, 4, 2, 5, 3, 6]) {
const dot = document.createElement("span");
dot.className = `mini-dot d${dotNumber}`;
dot.textContent = dotNumber;
if (letter.dots.includes(dotNumber)) {
dot.classList.add("active");
dot.style.setProperty("--dot-accent", hexCSS(accent));
}
element.append(dot);
}
}
function formatDots(dots) {
return dots.length ? dots.join(", ") : "none";
}
function updateComparison() {
const letterA = LETTER_BY_ID[selectA.value];
const letterB = LETTER_BY_ID[selectB.value];
buildBrailleCard(leftCard, letterA);
buildBrailleCard(rightCard, letterB);
renderMini(document.querySelector("#miniA"), letterA, leftCard.accent);
renderMini(document.querySelector("#miniB"), letterB, rightCard.accent);
document.querySelector("#miniCaptionA").textContent = letterA.id;
document.querySelector("#miniCaptionB").textContent = letterB.id;
const shared = letterA.dots.filter((dot) => letterB.dots.includes(dot));
const onlyA = letterA.dots.filter((dot) => !letterB.dots.includes(dot));
const onlyB = letterB.dots.filter((dot) => !letterA.dots.includes(dot));
summary.innerHTML =
`<strong>${letterA.id}</strong> · dots ${formatDots(letterA.dots)} → ` +
`<strong>${letterB.id}</strong> · dots ${formatDots(letterB.dots)}<br>` +
`Shared: ${formatDots(shared)} · ${letterA.id} only: ${formatDots(onlyA)} · ` +
`${letterB.id} only: ${formatDots(onlyB)}`;
announcement.textContent =
`Showing ${letterA.id}, raised dots ${formatDots(letterA.dots)}, and ` +
`${letterB.id}, raised dots ${formatDots(letterB.dots)}. ` +
`Both use source-checked uncontracted English Braille patterns.`;
}
selectA.addEventListener("change", updateComparison);
selectB.addEventListener("change", updateComparison);
document.querySelector("#swap").addEventListener("click", () => {
const previousA = selectA.value;
selectA.value = selectB.value;
selectB.value = previousA;
updateComparison();
});
document.querySelector("#random").addEventListener("click", () => {
const choices = LETTERS.filter((letter) => letter.id !== selectA.value);
const randomLetter = choices[Math.floor(Math.random() * choices.length)];
selectB.value = randomLetter.id;
updateComparison();
});
function resetView() {
targetYaw = 0;
targetPitch = 0.06;
targetRadius = 11.2;
}
document.querySelector("#reset").addEventListener("click", resetView);
const pointers = new Map();
let previousPinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.focus({ preventScroll: true });
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
previousPinchDistance = pointerDistance();
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
targetYaw = THREE.MathUtils.clamp(targetYaw - dx * 0.0055, -1.15, 1.15);
targetPitch = THREE.MathUtils.clamp(targetPitch + dy * 0.0042, -0.42, 0.52);
} else {
const nextPinchDistance = pointerDistance();
if (previousPinchDistance > 0 && nextPinchDistance > 0) {
targetRadius = THREE.MathUtils.clamp(
targetRadius * previousPinchDistance / nextPinchDistance,
7.4,
15.5
);
}
previousPinchDistance = nextPinchDistance;
}
});
function endPointer(event) {
pointers.delete(event.pointerId);
previousPinchDistance = pointerDistance();
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
targetRadius = THREE.MathUtils.clamp(
targetRadius + event.deltaY * 0.008,
7.4,
15.5
);
},
{ passive: false }
);
canvas.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key) {
case "ArrowLeft":
targetYaw = THREE.MathUtils.clamp(targetYaw + 0.1, -1.15, 1.15);
break;
case "ArrowRight":
targetYaw = THREE.MathUtils.clamp(targetYaw - 0.1, -1.15, 1.15);
break;
case "ArrowUp":
targetPitch = THREE.MathUtils.clamp(targetPitch - 0.08, -0.42, 0.52);
break;
case "ArrowDown":
targetPitch = THREE.MathUtils.clamp(targetPitch + 0.08, -0.42, 0.52);
break;
case "+":
case "=":
targetRadius = THREE.MathUtils.clamp(targetRadius - 0.5, 7.4, 15.5);
break;
case "-":
targetRadius = THREE.MathUtils.clamp(targetRadius + 0.5, 7.4, 15.5);
break;
case "Home":
resetView();
break;
default:
handled = false;
}
if (handled) event.preventDefault();
});
function resize() {
const width = innerWidth;
const height = innerHeight;
const aspect = width / height;
renderer.setSize(width, height, false);
camera.aspect = aspect;
camera.fov = aspect < 0.8 ? 45 : 38;
camera.updateProjectionMatrix();
}
addEventListener("resize", resize);
resize();
function easeOutBack(value) {
const c1 = 1.70158;
const c3 = c1 + 1;
return 1 + c3 * Math.pow(value - 1, 3) + c1 * Math.pow(value - 1, 2);
}
function updateCamera() {
const smoothing = reducedMotion ? 1 : 0.095;
yaw += (targetYaw - yaw) * smoothing;
pitch += (targetPitch - pitch) * smoothing;
radius += (targetRadius - radius) * smoothing;
const aspect = innerWidth / innerHeight;
const framingScale = aspect < 0.9 ? Math.max(1, 1.12 / aspect) : 1;
const effectiveRadius = radius * framingScale;
camera.position.set(
cameraTarget.x + effectiveRadius * Math.sin(yaw) * Math.cos(pitch),
cameraTarget.y + effectiveRadius * Math.sin(pitch),
cameraTarget.z + effectiveRadius * Math.cos(yaw) * Math.cos(pitch)
);
camera.lookAt(cameraTarget);
const canonical =
Math.abs(yaw) < 0.025 &&
Math.abs(pitch - 0.06) < 0.025 &&
Math.abs(radius - 11.2) < 0.16;
viewReadout.textContent = canonical ? "CANONICAL VIEW" : "ROTATED VIEW";
viewReadout.style.borderColor = canonical
? "rgba(50, 216, 196, 0.24)"
: "rgba(241, 202, 118, 0.28)";
viewReadout.style.color = canonical ? "#9fe9df" : "#f1ca76";
}
function animate(now) {
requestAnimationFrame(animate);
updateCamera();
for (const dot of dotAnimations) {
const progress = THREE.MathUtils.clamp(
(now - dot.userData.start) / 460,
0,
1
);
const scale = reducedMotion ? 1 : Math.max(0.001, easeOutBack(progress));
dot.scale.setScalar(scale);
}
particles.rotation.z = now * 0.000018;
particles.rotation.y = Math.sin(now * 0.00008) * 0.025;
renderer.render(scene, camera);
}
updateComparison();
requestAnimationFrame(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
});
</script>
</body>
</html>
```