Prompt specification
Build or customize the Three.js 3D scene "One Arrangement Two Symbol Labels" 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: One Arrangement Two Symbol Labels
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/one-arrangement-two-symbol-labels-x3429
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows equivalent meaning across languages and representations. Place a sphere above a cube and show two explicitly defined symbol phrases for that relation. Keep the spatial scene fixed while the label system changes. Low-poly.
Working Three.js Starter (one-arrangement-two-symbol-labels-x3429):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Same Meaning · Three.js</title>
<style>
:root {
color-scheme: dark;
--bg: #070b12;
--panel: #0d1420;
--panel-2: #111a28;
--line: rgba(184, 200, 230, 0.14);
--line-strong: rgba(184, 200, 230, 0.25);
--text: #eef3fb;
--muted: #94a1b7;
--violet: #9290ff;
--coral: #ff8a68;
--mint: #72d7bd;
--blue: #7eb8ff;
}
* {
box-sizing: border-box;
}
html,
body {
min-height: 100%;
margin: 0;
}
body {
overflow-x: hidden;
background:
radial-gradient(circle at 18% 0%, rgba(85, 100, 190, 0.16), transparent 32rem),
radial-gradient(circle at 90% 100%, rgba(255, 116, 80, 0.08), transparent 28rem),
var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
button:focus-visible {
outline: 2px solid var(--blue);
outline-offset: 3px;
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.topbar {
min-height: 76px;
padding: 16px 26px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
border-bottom: 1px solid var(--line);
background: rgba(7, 11, 18, 0.78);
backdrop-filter: blur(16px);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
position: relative;
width: 36px;
height: 36px;
flex: 0 0 auto;
}
.brand-mark::before {
content: "";
position: absolute;
top: 2px;
left: 9px;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 22px rgba(255, 138, 104, 0.28);
}
.brand-mark::after {
content: "";
position: absolute;
bottom: 1px;
left: 3px;
width: 20px;
height: 20px;
border: 2px solid var(--violet);
background: rgba(146, 144, 255, 0.12);
transform: rotate(8deg);
}
.brand-copy strong {
display: block;
font-size: 14px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.brand-copy span {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 12px;
}
.header-actions {
display: flex;
align-items: center;
gap: 12px;
}
.lock-badge,
.reset-button {
min-height: 38px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 255, 255, 0.035);
color: var(--muted);
font-size: 12px;
}
.lock-badge {
display: flex;
align-items: center;
gap: 8px;
padding: 0 13px;
}
.lock-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 10px rgba(114, 215, 189, 0.75);
}
.reset-button {
padding: 0 15px;
cursor: pointer;
transition:
border-color 160ms ease,
color 160ms ease,
background 160ms ease;
}
.reset-button:hover {
border-color: var(--line-strong);
background: rgba(255, 255, 255, 0.065);
color: var(--text);
}
.layout {
width: min(1600px, 100%);
margin: 0 auto;
padding: 20px;
display: grid;
grid-template-columns: minmax(0, 1fr) 400px;
gap: 20px;
flex: 1;
}
.visual-card {
position: relative;
min-height: 650px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 24px;
background: #08111d;
box-shadow:
0 28px 80px rgba(0, 0, 0, 0.25),
inset 0 1px rgba(255, 255, 255, 0.035);
}
.scene-wrap {
position: absolute;
inset: 0;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active {
cursor: grabbing;
}
.scene-vignette {
position: absolute;
inset: 0;
pointer-events: none;
background:
radial-gradient(circle at 50% 48%, transparent 35%, rgba(4, 8, 15, 0.42) 100%),
linear-gradient(180deg, rgba(3, 7, 13, 0.18), transparent 24%, transparent 74%, rgba(3, 7, 13, 0.35));
}
.scene-chip {
position: absolute;
z-index: 4;
top: 22px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(7, 13, 23, 0.68);
color: var(--muted);
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
backdrop-filter: blur(10px);
pointer-events: none;
}
.scene-chip.left {
left: 22px;
}
.scene-chip.right {
right: 22px;
}
.scene-chip strong {
color: var(--text);
font-weight: 600;
}
.chip-index {
color: var(--violet);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.object-label {
position: absolute;
z-index: 5;
min-width: 58px;
padding: 7px 11px;
border: 1px solid rgba(184, 200, 230, 0.24);
border-radius: 9px;
background: rgba(8, 15, 26, 0.82);
color: var(--text);
font-size: 13px;
font-weight: 650;
text-align: center;
white-space: nowrap;
transform: translate(-50%, -50%);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(8px);
pointer-events: none;
transition: opacity 120ms ease;
}
.object-label.sphere {
border-color: rgba(255, 138, 104, 0.5);
color: #ffc2ae;
}
.object-label.cube {
border-color: rgba(146, 144, 255, 0.5);
color: #c5c3ff;
}
.object-label.relation {
padding: 6px 10px;
border-color: rgba(114, 215, 189, 0.4);
color: #a7ead8;
font-size: 12px;
letter-spacing: 0.02em;
}
.scene-bottom {
position: absolute;
z-index: 4;
right: 20px;
bottom: 20px;
left: 20px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 16px;
pointer-events: none;
}
.coordinate-card {
padding: 12px 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(7, 13, 23, 0.72);
backdrop-filter: blur(10px);
}
.coordinate-card header {
margin-bottom: 8px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.coordinates {
display: flex;
gap: 17px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
}
.coordinates span {
color: var(--muted);
}
.coordinates b {
color: var(--text);
font-weight: 600;
}
.camera-hint {
color: rgba(190, 202, 222, 0.65);
font-size: 11px;
text-align: right;
text-shadow: 0 2px 8px #000;
}
.panel {
min-height: 650px;
padding: 22px;
overflow: auto;
border: 1px solid var(--line);
border-radius: 24px;
background:
linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 30%),
var(--panel);
box-shadow:
0 28px 80px rgba(0, 0, 0, 0.18),
inset 0 1px rgba(255, 255, 255, 0.035);
}
.panel-kicker {
margin: 0 0 8px;
color: var(--mint);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.panel h1 {
margin: 0;
font-size: 25px;
line-height: 1.15;
letter-spacing: -0.025em;
}
.panel-intro > p:last-child {
margin: 10px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 22px 0 10px;
color: #c5cedc;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.section-label span {
color: var(--muted);
font-size: 9px;
font-weight: 500;
letter-spacing: 0.04em;
text-transform: none;
}
.system-tabs {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.system-button {
min-height: 35px;
padding: 0 12px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255, 255, 255, 0.025);
color: var(--muted);
cursor: pointer;
font-size: 12px;
transition:
border-color 150ms ease,
background 150ms ease,
color 150ms ease;
}
.system-button:hover {
border-color: var(--line-strong);
color: var(--text);
}
.system-button.active {
border-color: rgba(146, 144, 255, 0.62);
background: rgba(146, 144, 255, 0.13);
color: #d8d7ff;
}
.reading-card {
margin-top: 13px;
padding: 17px;
border: 1px solid rgba(146, 144, 255, 0.23);
border-radius: 16px;
background:
radial-gradient(circle at 100% 0%, rgba(146, 144, 255, 0.12), transparent 55%),
var(--panel-2);
}
.reading-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.reading-top span {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.reading-top strong {
color: var(--violet);
font-size: 11px;
font-weight: 600;
}
.current-phrase {
min-height: 54px;
margin-top: 13px;
font-size: 24px;
font-weight: 650;
line-height: 1.3;
letter-spacing: -0.025em;
}
.current-meaning {
margin-top: 7px;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.phrase-stack {
display: grid;
gap: 9px;
}
.phrase-card {
width: 100%;
padding: 13px 14px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.025);
color: var(--text);
text-align: left;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.phrase-card:hover {
border-color: var(--line-strong);
background: rgba(255, 255, 255, 0.045);
transform: translateY(-1px);
}
.phrase-card.active {
border-color: rgba(114, 215, 189, 0.55);
background: rgba(114, 215, 189, 0.065);
}
.phrase-card header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.phrase-card header span {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.phrase-card header b {
color: var(--mint);
font-size: 10px;
font-weight: 600;
}
.phrase-code {
display: block;
margin: 9px 0 7px;
color: #f2f5fb;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 20px;
font-weight: 600;
letter-spacing: 0.03em;
}
.phrase-card p {
margin: 0;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.phrase-card p strong {
color: #c8d1df;
font-weight: 600;
}
.invariant {
margin-top: 18px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(0, 0, 0, 0.14);
}
.invariant header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.invariant header span {
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.invariant header b {
color: var(--mint);
font-size: 10px;
font-weight: 600;
}
.equation {
margin-top: 10px;
color: #e8edf5;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 14px;
line-height: 1.65;
}
.equation .purple {
color: #bdbbff;
}
.equation .coral {
color: #ffad93;
}
.fixed-note {
display: flex;
gap: 10px;
margin-top: 14px;
padding: 0 2px;
color: var(--muted);
font-size: 11px;
line-height: 1.5;
}
.fixed-note::before {
content: "";
width: 2px;
flex: 0 0 2px;
border-radius: 2px;
background: var(--violet);
}
@media (max-width: 1050px) {
.layout {
grid-template-columns: minmax(0, 1fr) 360px;
gap: 14px;
padding: 14px;
}
.panel {
padding: 18px;
}
}
@media (max-width: 820px) {
.topbar {
padding: 14px 16px;
}
.brand-copy span,
.lock-badge {
display: none;
}
.layout {
grid-template-columns: 1fr;
}
.visual-card {
min-height: 570px;
}
.panel {
min-height: auto;
}
}
@media (max-width: 520px) {
.scene-chip.right,
.camera-hint {
display: none;
}
.scene-chip.left {
top: 14px;
left: 14px;
}
.scene-bottom {
right: 14px;
bottom: 14px;
left: 14px;
}
.visual-card {
min-height: 520px;
border-radius: 18px;
}
.panel {
border-radius: 18px;
}
.current-phrase {
font-size: 21px;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div class="brand-copy">
<strong>Meaning / Equivalence</strong>
<span>One fixed scene, many representations</span>
</div>
</div>
<div class="header-actions">
<div class="lock-badge">
<span class="lock-dot" aria-hidden="true"></span>
Spatial scene fixed
</div>
<button class="reset-button" id="resetView" type="button">
Reset view
</button>
</div>
</header>
<main class="layout">
<section class="visual-card" aria-label="Three-dimensional spatial scene">
<div class="scene-wrap" id="sceneWrap">
<canvas
id="scene"
tabindex="0"
aria-label="A low-poly sphere positioned above a low-poly cube. Drag to orbit and scroll to zoom."
></canvas>
</div>
<div class="scene-vignette" aria-hidden="true"></div>
<div class="scene-chip left">
<span class="chip-index">01</span>
<strong>Low-poly relation</strong>
</div>
<div class="scene-chip right">
<span class="lock-dot" aria-hidden="true"></span>
Object transforms locked
</div>
<div
class="object-label sphere"
id="sphereLabel"
aria-hidden="true"
>sphere</div>
<div
class="object-label relation"
id="relationLabel"
aria-hidden="true"
>above</div>
<div
class="object-label cube"
id="cubeLabel"
aria-hidden="true"
>cube</div>
<div class="scene-bottom">
<div class="coordinate-card">
<header>Fixed world coordinates</header>
<div class="coordinates">
<div><span>Sphere</span> <b>y +2.80</b></div>
<div><span>Cube</span> <b>y 0.00</b></div>
<div><span>Relation</span> <b>Y↑</b></div>
</div>
</div>
<div class="camera-hint">
Drag to orbit · Scroll to zoom<br>
Label changes do not reset the camera
</div>
</div>
</section>
<aside class="panel">
<div class="panel-intro">
<p class="panel-kicker">Representation Lab</p>
<h1>The same relation,<br>read differently.</h1>
<p>
Switch languages or symbolic systems. The spatial objects remain
exactly where they are; only their labels and readings change.
</p>
</div>
<div class="section-label">
Label system
<span>DOM-only change</span>
</div>
<div class="system-tabs" role="group" aria-label="Choose a label system">
<button class="system-button active" data-system="english" type="button">
English
</button>
<button class="system-button" data-system="japanese" type="button">
日本語
</button>
<button class="system-button" data-system="arabic" type="button">
العربية
</button>
<button class="system-button" data-system="symbolA" type="button">
Symbol A
</button>
<button class="system-button" data-system="symbolB" type="button">
Symbol B
</button>
</div>
<div class="reading-card">
<div class="reading-top">
<span>Current reading</span>
<strong id="systemName">English</strong>
</div>
<div
class="current-phrase"
id="currentPhrase"
dir="ltr"
aria-live="polite"
>
The sphere is above the cube.
</div>
<div class="current-meaning" id="currentMeaning">
The sphere has a greater vertical Y coordinate than the cube.
</div>
</div>
<div class="section-label">
Two defined symbol phrases
<span>Select either to apply it</span>
</div>
<div class="phrase-stack">
<button
class="phrase-card"
data-system="symbolA"
type="button"
aria-pressed="false"
>
<header>
<span>Symbol phrase A</span>
<b>Geometric glyphs</b>
</header>
<code class="phrase-code">● above ▣</code>
<p>
<strong>Definition:</strong> ● means sphere; ▣ means cube;
“above” means the first item has a greater Y coordinate
than the second.
</p>
</button>
<button
class="phrase-card"
data-system="symbolB"
type="button"
aria-pressed="false"
>
<header>
<span>Symbol phrase B</span>
<b>Outline glyphs</b>
</header>
<code class="phrase-code">○ over □</code>
<p>
<strong>Definition:</strong> ○ means sphere; □ means cube;
“over” means the first item has a greater Y coordinate
than the second.
</p>
</button>
</div>
<div class="invariant">
<header>
<span>Meaning invariant</span>
<b>Same in every system</b>
</header>
<div class="equation">
<span class="coral">Y(sphere) = +2.80</span><br>
<span class="purple">Y(cube) = 0.00</span><br>
Y(sphere) > Y(cube)
</div>
</div>
<div class="fixed-note">
Switching systems updates only text labels and the displayed reading.
The cube geometry, sphere geometry, world positions, and current camera
pose are not changed.
</div>
</aside>
</main>
</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 sceneWrap = document.querySelector("#sceneWrap");
const sphereLabel = document.querySelector("#sphereLabel");
const cubeLabel = document.querySelector("#cubeLabel");
const relationLabel = document.querySelector("#relationLabel");
const currentPhrase = document.querySelector("#currentPhrase");
const currentMeaning = document.querySelector("#currentMeaning");
const systemName = document.querySelector("#systemName");
const resetViewButton = document.querySelector("#resetView");
const systems = {
english: {
name: "English",
phrase: "The sphere is above the cube.",
meaning: "The sphere has a greater vertical Y coordinate than the cube.",
sphere: "sphere",
cube: "cube",
relation: "above",
lang: "en",
dir: "ltr"
},
japanese: {
name: "Japanese",
phrase: "球は立方体の上にある。",
meaning:
"球の縦方向のY座標は、立方体より大きいことを示しています。",
sphere: "球",
cube: "立方体",
relation: "上",
lang: "ja",
dir: "ltr"
},
arabic: {
name: "Arabic",
phrase: "الكرة فوق المكعب.",
meaning:
"تشير العبارة إلى أن الكرة 具有 إحداثي رأسي أكبر من المكعب.",
sphere: "الكرة",
cube: "المكعب",
relation: "فوق",
lang: "ar",
dir: "rtl"
},
symbolA: {
name: "Symbol phrase A",
phrase: "● above ▣",
meaning:
"● is the sphere, ▣ is the cube, and above means a greater Y coordinate.",
sphere: "●",
cube: "▣",
relation: "above",
lang: "en",
dir: "ltr"
},
symbolB: {
name: "Symbol phrase B",
phrase: "○ over □",
meaning:
"○ is the sphere, □ is the cube, and over means a greater Y coordinate.",
sphere: "○",
cube: "□",
relation: "over",
lang: "en",
dir: "ltr"
}
};
// The scene is built once. Label switching never modifies these objects.
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.setClearColor(0x08111d, 1);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x08111d, 12, 27);
const camera = new THREE.PerspectiveCamera(
38,
1,
0.1,
100
);
const orbit = {
radius: 9.2,
theta: 0.58,
phi: 1.22,
target: new THREE.Vector3(0, 1.25, 0)
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(
0xa8c5ff,
0x080c14,
1.7
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -6;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0xff795e, 38, 13, 2);
rimLight.position.set(-4.5, 3.6, -3.5);
scene.add(rimLight);
const blueLight = new THREE.PointLight(0x667dff, 25, 12, 2);
blueLight.position.set(4, 2, -2);
scene.add(blueLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0x0a1421,
roughness: 0.94,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.08;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(
18,
18,
0x536887,
0x2a3950
);
grid.position.y = -1.065;
grid.material.transparent = true;
grid.material.opacity = 0.22;
grid.material.depthWrite = false;
scene.add(grid);
const cube = new THREE.Mesh(
new THREE.BoxGeometry(2.1, 2.1, 2.1),
new THREE.MeshStandardMaterial({
color: 0x7778dc,
roughness: 0.68,
metalness: 0.12,
flatShading: true
})
);
cube.position.set(0, 0, 0);
cube.castShadow = true;
cube.receiveShadow = true;
scene.add(cube);
const cubeEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(cube.geometry),
new THREE.LineBasicMaterial({
color: 0xc5c3ff,
transparent: true,
opacity: 0.72
})
);
cubeEdges.scale.setScalar(1.001);
cube.add(cubeEdges);
const sphere = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.95, 1),
new THREE.MeshStandardMaterial({
color: 0xff805e,
roughness: 0.7,
metalness: 0.08,
flatShading: true
})
);
sphere.position.set(0, 2.8, 0);
sphere.castShadow = true;
sphere.receiveShadow = true;
scene.add(sphere);
const relationGuide = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0, 1.06, 0),
new THREE.Vector3(0, 1.83, 0)
]),
new THREE.LineDashedMaterial({
color: 0xa8ead9,
dashSize: 0.11,
gapSize: 0.09,
transparent: true,
opacity: 0.72
})
);
relationGuide.computeLineDistances();
scene.add(relationGuide);
const guideTip = new THREE.Mesh(
new THREE.ConeGeometry(0.065, 0.2, 5),
new THREE.MeshBasicMaterial({ color: 0xa8ead9 })
);
guideTip.position.set(0, 1.79, 0);
scene.add(guideTip);
const projected = new THREE.Vector3();
function placeLabel(element, worldPosition, offsetX, offsetY) {
projected.copy(worldPosition).project(camera);
const width = sceneWrap.clientWidth;
const height = sceneWrap.clientHeight;
const x = (projected.x * 0.5 + 0.5) * width + offsetX;
const y = (-projected.y * 0.5 + 0.5) * height + offsetY;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.opacity =
projected.z > -1 && projected.z < 1 ? "1" : "0";
}
function updateOverlayLabels() {
placeLabel(sphereLabel, sphere.position, 105, -38);
placeLabel(cubeLabel, cube.position, 100, 72);
placeLabel(relationLabel, relationGuide.geometry.attributes.position.getY(0)
? new THREE.Vector3(0, 1.46, 0)
: new THREE.Vector3(0, 1.46, 0), 146, -5);
}
function setSystem(key) {
const system = systems[key];
if (!system) return;
// Only text-related DOM is updated here.
// The scene graph, object transforms, and camera remain untouched.
currentPhrase.textContent = system.phrase;
currentMeaning.textContent = system.meaning;
systemName.textContent = system.name;
currentPhrase.dir = system.dir;
currentMeaning.dir = system.dir;
sphereLabel.textContent = system.sphere;
cubeLabel.textContent = system.cube;
relationLabel.textContent = system.relation;
sphereLabel.dir = system.dir;
cubeLabel.dir = system.dir;
relationLabel.dir = system.dir;
document.documentElement.lang = system.lang;
document.querySelectorAll("[data-system]").forEach((button) => {
const active = button.dataset.system === key;
button.classList.toggle("active", active);
if (button.classList.contains("phrase-card")) {
button.setAttribute("aria-pressed", String(active));
}
});
}
document.querySelectorAll("[data-system]").forEach((button) => {
button.addEventListener("click", () => {
setSystem(button.dataset.system);
});
});
// Small, self-contained orbit controls. No Three.js addons are used.
let dragging = false;
let previousX = 0;
let previousY = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
orbit.theta -= deltaX * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - deltaY * 0.005,
0.45,
1.43
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
if (
event.pointerId !== undefined &&
canvas.hasPointerCapture(event.pointerId)
) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.006,
6.4,
12.5
);
updateCamera();
},
{ passive: false }
);
resetViewButton.addEventListener("click", () => {
orbit.radius = 9.2;
orbit.theta = 0.58;
orbit.phi = 1.22;
updateCamera();
});
function resize() {
const width = sceneWrap.clientWidth;
const height = sceneWrap.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / Math.max(height, 1);
camera.updateProjectionMatrix();
updateOverlayLabels();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(sceneWrap);
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
updateOverlayLabels();
}
setSystem("english");
resize();
render();
</script>
</body>
</html>
```