Prompt specification
Build or customize the Three.js 3D scene "Two Objects Called a Bat" 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: Two Objects Called a Bat
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-objects-called-a-bat-x3361
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows ambiguous words and their surrounding context. Display a stylized flying mammal and a sports bat on separate plinths. Label the shared word while keeping biological and manufactured structures unmistakably distinct. Low-poly.
Verify the behavior against the actual geometry and data in each relevant state. Use schematic labels for deliberately synthetic elements.
Technical checks: Center each object on its labeled plinth. Apply the group offset once so the sports bat stays on its red plinth.
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 (two-objects-called-a-bat-x3361):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BAT — Two Contexts, Two Structures</title>
<style>
:root {
--ink: #202827;
--muted: #66716e;
--paper: #f5f2ea;
--bio: #28778a;
--bio-soft: #e1f0ef;
--made: #bd493f;
--made-soft: #f6e5df;
--line: rgba(32, 40, 39, 0.16);
--shadow: 0 18px 55px rgba(40, 42, 36, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
#scene.dragging {
cursor: grabbing;
}
.intro {
position: fixed;
top: 24px;
left: 28px;
z-index: 5;
width: min(370px, calc(100vw - 56px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin: 0 0 8px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 25px;
height: 2px;
background: var(--ink);
}
.intro h1 {
margin: 0;
max-width: 340px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 3vw, 43px);
font-weight: 500;
line-height: 0.98;
letter-spacing: -0.035em;
}
.intro p {
max-width: 310px;
margin: 12px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.mode-panel {
position: fixed;
top: 24px;
right: 26px;
z-index: 7;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 6px;
max-width: min(520px, calc(100vw - 52px));
padding: 6px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(248, 246, 240, 0.88);
box-shadow: 0 8px 26px rgba(44, 48, 42, 0.08);
backdrop-filter: blur(14px);
}
.mode-panel button {
appearance: none;
border: 0;
border-radius: 9px;
padding: 9px 12px;
color: #59635f;
background: transparent;
cursor: pointer;
font-size: 11px;
font-weight: 750;
transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.mode-panel button:hover {
color: var(--ink);
background: rgba(32, 40, 39, 0.07);
}
.mode-panel button:focus-visible {
outline: 2px solid var(--ink);
outline-offset: 2px;
}
.mode-panel button[aria-pressed="true"] {
color: #fff;
background: var(--ink);
}
#labels {
position: fixed;
inset: 0;
z-index: 3;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 220ms ease;
text-align: center;
will-change: left, top;
}
.scene-label.visible {
opacity: 1;
}
.scene-label.is-muted {
opacity: 0.28 !important;
}
#word-label {
color: var(--ink);
white-space: nowrap;
}
#word-label .word {
display: block;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(48px, 6.3vw, 84px);
line-height: 0.85;
letter-spacing: 0.13em;
text-indent: 0.13em;
}
#word-label small {
display: block;
margin-top: 11px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.21em;
text-transform: uppercase;
}
#word-label::after {
content: "";
display: block;
width: 1px;
height: 27px;
margin: 11px auto 0;
background: linear-gradient(var(--ink), transparent);
}
.object-label {
min-width: 150px;
padding: 8px 11px 7px;
border: 1px solid rgba(32, 40, 39, 0.13);
border-top-width: 3px;
border-radius: 8px;
background: rgba(248, 246, 240, 0.9);
box-shadow: 0 8px 22px rgba(39, 42, 37, 0.1);
backdrop-filter: blur(8px);
}
.object-label strong {
display: block;
font-size: 11px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
.object-label small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#bio-label {
border-top-color: var(--bio);
}
#bio-label strong {
color: var(--bio);
}
#made-label {
border-top-color: var(--made);
}
#made-label strong {
color: var(--made);
}
.context-panel {
position: fixed;
left: 50%;
bottom: 18px;
z-index: 6;
width: min(930px, calc(100vw - 32px));
transform: translateX(-50%);
padding: 13px 15px 10px;
border: 1px solid rgba(32, 40, 39, 0.17);
border-radius: 17px;
background: rgba(249, 247, 241, 0.94);
box-shadow: var(--shadow);
backdrop-filter: blur(17px);
}
.context-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 0 2px 10px;
border-bottom: 1px solid var(--line);
}
.context-head .word-lockup {
display: flex;
align-items: baseline;
gap: 10px;
}
.context-head .word-lockup span {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.context-head .word-lockup strong {
font-family: Georgia, "Times New Roman", serif;
font-size: 26px;
font-weight: 500;
letter-spacing: 0.09em;
}
.context-head p {
margin: 0;
color: var(--muted);
font-size: 10px;
line-height: 1.4;
text-align: right;
}
.cards {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-top: 10px;
}
.sense-card {
position: relative;
min-width: 0;
padding: 10px 12px 9px 14px;
border: 1px solid rgba(32, 40, 39, 0.1);
border-left: 4px solid var(--bio);
border-radius: 9px;
background: var(--bio-soft);
transition: opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}
.sense-card[data-sense="man"] {
border-left-color: var(--made);
background: var(--made-soft);
}
.sense-card.focused {
transform: translateY(-1px);
filter: saturate(1.06);
}
.sense-card.muted {
opacity: 0.38;
filter: saturate(0.45);
}
.sense-card .sense-type {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 5px;
color: var(--bio);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.sense-card[data-sense="man"] .sense-type {
color: var(--made);
}
.sense-card .sense-type em {
color: var(--muted);
font-style: normal;
letter-spacing: 0.08em;
}
.sense-card p {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
line-height: 1.35;
}
.sense-card mark {
padding: 0 2px;
color: inherit;
background: transparent;
font-weight: 800;
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 2px;
}
.panel-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 15px;
margin-top: 9px;
padding: 7px 2px 0;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 8px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.audit-status {
display: flex;
align-items: center;
gap: 7px;
min-width: 0;
}
.audit-dot {
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 50%;
background: #3d8d68;
box-shadow: 0 0 0 3px rgba(61, 141, 104, 0.12);
}
.audit-dot.failed {
background: #bd493f;
box-shadow: 0 0 0 3px rgba(189, 73, 63, 0.12);
}
#audit-scope {
color: #3d8d68;
white-space: nowrap;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
color: var(--muted);
background: var(--paper);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
.intro {
top: 16px;
left: 17px;
}
.intro h1 {
max-width: 230px;
font-size: 28px;
}
.intro p {
display: none;
}
.mode-panel {
top: 103px;
right: 12px;
left: 12px;
justify-content: stretch;
max-width: none;
}
.mode-panel button {
flex: 1 1 auto;
padding: 8px 7px;
font-size: 9px;
}
.context-panel {
bottom: 9px;
width: calc(100vw - 18px);
max-height: 43vh;
overflow: auto;
padding: 10px;
}
.context-head {
align-items: flex-start;
}
.context-head p {
max-width: 48%;
font-size: 8px;
}
.cards {
grid-template-columns: 1fr;
}
.sense-card p {
font-size: 12px;
}
.panel-footer {
align-items: flex-start;
}
#audit-scope {
display: none;
}
.object-label {
min-width: 125px;
padding: 6px 8px;
}
.object-label strong {
font-size: 9px;
}
.object-label small {
font-size: 7px;
}
#word-label .word {
font-size: 48px;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly gallery showing a flying mammal and a sports bat on separate plinths"></canvas>
<div id="labels" aria-hidden="true">
<div id="word-label" class="scene-label">
<span class="word">BAT</span>
<small>Shared word · schematic label</small>
</div>
<div id="bio-label" class="scene-label object-label">
<strong>Flying mammal</strong>
<small>Biological sense</small>
</div>
<div id="made-label" class="scene-label object-label">
<strong>Sports bat</strong>
<small>Manufactured sense</small>
</div>
</div>
<header class="intro">
<p class="eyebrow">Context study / 01</p>
<h1>One word.<br>Two structures.</h1>
<p>The surrounding sentence selects a living mammal in one case and a human-made sports implement in the other.</p>
</header>
<nav class="mode-panel" aria-label="Choose the emphasized context">
<button type="button" data-mode="all" aria-pressed="true">Both senses</button>
<button type="button" data-mode="biological" aria-pressed="false">Living mammal</button>
<button type="button" data-mode="manufactured" aria-pressed="false">Sports bat</button>
</nav>
<section class="context-panel" aria-label="Word senses and surrounding context">
<div class="context-head">
<div class="word-lockup">
<span>Shared lexeme</span>
<strong>BAT</strong>
</div>
<p id="mode-summary">Both structures remain visible for direct comparison.</p>
</div>
<div class="cards">
<article id="bio-card" class="sense-card focused" data-sense="bio">
<div class="sense-type">
<span>Biological sense</span>
<em>Living organism</em>
</div>
<p id="bio-context"></p>
</article>
<article id="man-card" class="sense-card focused" data-sense="man">
<div class="sense-type">
<span>Manufactured sense</span>
<em>Human-made object</em>
</div>
<p id="man-context"></p>
</article>
</div>
<footer class="panel-footer">
<span class="audit-status" aria-live="polite">
<i id="audit-dot" class="audit-dot"></i>
<span id="audit-status">Checking geometry and data…</span>
</span>
<span id="audit-scope">0/3 states audited</span>
<span>Drag to orbit · Scroll to zoom · Double-click to reset</span>
</footer>
</section>
<div id="loading">Constructing the two senses</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 scene = new THREE.Scene();
scene.background = new THREE.Color(0xf2efe7);
scene.fog = new THREE.Fog(0xf2efe7, 14, 28);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const camera = new THREE.PerspectiveCamera(
window.innerWidth < 760 ? 47 : 38,
window.innerWidth / window.innerHeight,
0.1,
60
);
const orbit = {
target: new THREE.Vector3(0, 1.72, 0),
theta: 0.18,
phi: 1.12,
radius: 10.7
};
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(0xfffdf5, 0x71827f, 2.05);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1d9, 3.2);
keyLight.position.set(-4.5, 8.5, 6.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -5;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc9e5ef, 1.15);
fillLight.position.set(6, 4.5, -4);
scene.add(fillLight);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(32, 32),
new THREE.MeshStandardMaterial({
color: 0xded8cc,
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.015;
ground.receiveShadow = true;
scene.add(ground);
function standardMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
}
function addMesh(parent, geometry, material, position = [0, 0, 0]) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(parent, start, end, radius, material, radialSegments = 5) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = new THREE.Vector3().subVectors(b, a);
const geometry = new THREE.CylinderGeometry(
radius,
radius,
direction.length(),
radialSegments,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createPlaqueTexture(title, code) {
const plaqueCanvas = document.createElement("canvas");
plaqueCanvas.width = 768;
plaqueCanvas.height = 192;
const ctx = plaqueCanvas.getContext("2d");
ctx.fillStyle = "#f4efe4";
ctx.fillRect(0, 0, plaqueCanvas.width, plaqueCanvas.height);
ctx.strokeStyle = "#24302e";
ctx.lineWidth = 5;
ctx.strokeRect(10, 10, plaqueCanvas.width - 20, plaqueCanvas.height - 20);
ctx.fillStyle = "#24302e";
ctx.font = "800 42px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(title, plaqueCanvas.width / 2, 77);
ctx.fillStyle = "#6b7470";
ctx.font = "700 24px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.fillText(`${code} · DISPLAY SUPPORT`, plaqueCanvas.width / 2, 132);
const texture = new THREE.CanvasTexture(plaqueCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function createPlinth(baseColor, capColor, plaqueTitle, plaqueCode) {
const group = new THREE.Group();
const base = addMesh(
group,
new THREE.BoxGeometry(3.35, 0.78, 2.55),
standardMaterial(baseColor, { roughness: 0.9 }),
[0, 0.39, 0]
);
const capMaterial = standardMaterial(capColor, {
roughness: 0.82,
emissive: 0x000000,
emissiveIntensity: 0.18
});
const cap = addMesh(
group,
new THREE.BoxGeometry(3.48, 0.18, 2.68),
capMaterial,
[0, 0.87, 0]
);
const underside = addMesh(
group,
new THREE.BoxGeometry(3.02, 0.08, 2.25),
standardMaterial(0x263230, { roughness: 1 }),
[0, 0.04, 0]
);
underside.castShadow = false;
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(1.75, 0.44),
new THREE.MeshBasicMaterial({
map: createPlaqueTexture(plaqueTitle, plaqueCode),
transparent: true
})
);
plaque.position.set(0, 0.43, 1.281);
group.add(plaque);
return { group, base, cap, capMaterial, top: 0.96 };
}
const leftExhibit = new THREE.Group();
leftExhibit.position.set(-2.65, 0, 0);
scene.add(leftExhibit);
const rightExhibit = new THREE.Group();
rightExhibit.position.set(2.65, 0, 0);
scene.add(rightExhibit);
const leftPlinth = createPlinth(0x24576b, 0x33839a, "SYNTHETIC PLINTH A", "A");
leftExhibit.add(leftPlinth.group);
const rightPlinth = createPlinth(0x9f3934, 0xd65b4e, "SYNTHETIC PLINTH B", "B");
rightExhibit.add(rightPlinth.group);
// Biological sense: a deliberately stylized flying mammal.
const mammal = new THREE.Group();
mammal.position.set(0, 1.9, 0);
mammal.rotation.y = -0.08;
leftExhibit.add(mammal);
const fur = standardMaterial(0x493244, { roughness: 0.96 });
const wingMaterial = standardMaterial(0x56304f, {
roughness: 0.92,
side: THREE.DoubleSide
});
const wingBoneMaterial = standardMaterial(0x8b6175, { roughness: 0.85 });
const tan = standardMaterial(0xb97f61, { roughness: 0.95 });
const darkTan = standardMaterial(0x74493e, { roughness: 0.96 });
const eyeMaterial = standardMaterial(0x111918, { roughness: 0.45 });
const body = addMesh(
mammal,
new THREE.IcosahedronGeometry(0.62, 1),
fur,
[0, 0, 0]
);
body.scale.set(0.72, 1, 0.68);
const chest = addMesh(
mammal,
new THREE.IcosahedronGeometry(0.45, 1),
tan,
[0, -0.03, 0.38]
);
chest.scale.set(0.62, 0.85, 0.31);
const head = addMesh(
mammal,
new THREE.IcosahedronGeometry(0.43, 1),
fur,
[0, 0.48, 0.27]
);
head.scale.set(0.82, 0.8, 0.82);
const muzzle = addMesh(
mammal,
new THREE.IcosahedronGeometry(0.26, 1),
tan,
[0, 0.37, 0.62]
);
muzzle.scale.set(1, 0.62, 0.72);
for (const side of [-1, 1]) {
const ear = addMesh(
mammal,
new THREE.ConeGeometry(0.18, 0.48, 3),
fur,
[side * 0.24, 0.93, 0.22]
);
ear.rotation.z = side * -0.15;
ear.rotation.x = 0.08;
const innerEar = addMesh(
mammal,
new THREE.ConeGeometry(0.105, 0.29, 3),
tan,
[side * 0.24, 0.91, 0.315]
);
innerEar.rotation.z = side * -0.15;
innerEar.rotation.x = 0.08;
const eye = addMesh(
mammal,
new THREE.IcosahedronGeometry(0.067, 1),
eyeMaterial,
[side * 0.22, 0.56, 0.57]
);
eye.scale.set(1, 1.15, 0.65);
cylinderBetween(
mammal,
[side * 0.18, -0.3, 0.05],
[side * 0.25, -0.72, 0.22],
0.055,
darkTan,
5
);
const foot = addMesh(
mammal,
new THREE.SphereGeometry(0.095, 6, 4),
tan,
[side * 0.25, -0.75, 0.24]
);
foot.scale.set(0.8, 0.55, 1.25);
}
addMesh(
mammal,
new THREE.IcosahedronGeometry(0.075, 1),
eyeMaterial,
[0, 0.38, 0.79]
);
function createWing(side) {
const wing = new THREE.Group();
wing.position.set(side * 0.34, 0.08, -0.1);
wing.scale.x = side;
const shape = new THREE.Shape();
shape.moveTo(0, 0);
shape.lineTo(0.36, 0.53);
shape.lineTo(1.18, 0.39);
shape.lineTo(1.48, -0.16);
shape.lineTo(0.83, -0.48);
shape.lineTo(0.28, -0.34);
shape.closePath();
const membrane = new THREE.Mesh(
new THREE.ShapeGeometry(shape),
wingMaterial
);
membrane.castShadow = true;
membrane.receiveShadow = true;
wing.add(membrane);
cylinderBetween(wing, [0, 0, 0.03], [0.36, 0.53, 0.03], 0.037, wingBoneMaterial);
cylinderBetween(wing, [0, 0, 0.03], [1.18, 0.39, 0.04], 0.032, wingBoneMaterial);
cylinderBetween(wing, [0, 0, 0.03], [1.48, -0.16, 0.03], 0.029, wingBoneMaterial);
cylinderBetween(wing, [0, 0, 0.03], [0.83, -0.48, 0.03], 0.029, wingBoneMaterial);
mammal.add(wing);
return wing;
}
const leftWing = createWing(-1);
const rightWing = createWing(1);
const tailGeometry = new THREE.BufferGeometry();
tailGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
-0.2, -0.3, -0.18,
0.2, -0.3, -0.18,
0, -0.68, -0.52
], 3)
);
tailGeometry.setIndex([0, 1, 2]);
tailGeometry.computeVertexNormals();
const tail = new THREE.Mesh(
tailGeometry,
standardMaterial(0x56304f, { side: THREE.DoubleSide })
);
tail.castShadow = true;
mammal.add(tail);
// Manufactured sense: a low-poly wooden sports bat.
const sportsBat = new THREE.Group();
sportsBat.position.set(0, 2.28, 0);
sportsBat.rotation.set(0.08, 0, -0.42);
rightExhibit.add(sportsBat);
const wood = standardMaterial(0xd8a35f, { roughness: 0.72 });
const woodLight = standardMaterial(0xe4b978, { roughness: 0.68 });
const grip = standardMaterial(0x28302f, { roughness: 0.94 });
const accent = standardMaterial(0xb84538, { roughness: 0.72 });
const profile = [
new THREE.Vector2(0, -1.2),
new THREE.Vector2(0.075, -1.2),
new THREE.Vector2(0.09, -1.1),
new THREE.Vector2(0.09, -0.65),
new THREE.Vector2(0.13, -0.42),
new THREE.Vector2(0.23, -0.08),
new THREE.Vector2(0.28, 0.35),
new THREE.Vector2(0.25, 0.65),
new THREE.Vector2(0.18, 0.87),
new THREE.Vector2(0.08, 0.98),
new THREE.Vector2(0, 1.02)
];
addMesh(
sportsBat,
new THREE.LatheGeometry(profile, 8),
woodLight
);
addMesh(
sportsBat,
new THREE.CylinderGeometry(0.105, 0.105, 0.52, 8),
grip,
[0, -0.86, 0]
);
addMesh(
sportsBat,
new THREE.CylinderGeometry(0.14, 0.14, 0.09, 8),
grip,
[0, -1.145, 0]
);
const barrelBand = addMesh(
sportsBat,
new THREE.TorusGeometry(0.252, 0.018, 4, 12),
accent,
[0, 0.15, 0]
);
barrelBand.rotation.x = Math.PI / 2;
const makerMark = addMesh(
sportsBat,
new THREE.CircleGeometry(0.071, 8),
accent,
[0, 0.39, 0.268]
);
makerMark.castShadow = false;
function collectFocusMaterials(object) {
const materials = new Set();
object.traverse((child) => {
if (child.isMesh && child.material) {
materials.add(child.material);
}
});
return [...materials].map((material) => ({
material,
opacity: material.opacity,
transparent: material.transparent,
depthWrite: material.depthWrite
}));
}
const exhibits = {
bio: {
key: "bio",
root: leftExhibit,
object: mammal,
plinth: leftPlinth,
label: document.getElementById("bio-label"),
card: document.getElementById("bio-card"),
materials: collectFocusMaterials(mammal)
},
man: {
key: "man",
root: rightExhibit,
object: sportsBat,
plinth: rightPlinth,
label: document.getElementById("made-label"),
card: document.getElementById("man-card"),
materials: collectFocusMaterials(sportsBat)
}
};
const senses = {
bio: {
name: "Flying mammal",
meaning: "a nocturnal flying mammal",
context: "A <mark>bat</mark> circled the old oak, its leathery wings cutting through the dusk."
},
man: {
name: "Sports bat",
meaning: "a hand-held sports implement",
context: "The batter checked the <mark>bat</mark>, stepped toward the plate, and watched the pitch."
}
};
const modes = {
all: {
active: ["bio", "man"],
summary: "Both structures remain visible for direct comparison."
},
biological: {
active: ["bio"],
summary: "The living mammal is emphasized; the manufactured example remains visible."
},
manufactured: {
active: ["man"],
summary: "The sports equipment is emphasized; the living example remains visible."
}
};
document.getElementById("bio-context").innerHTML = senses.bio.context;
document.getElementById("man-context").innerHTML = senses.man.context;
function setObjectFocus(exhibit, focused) {
for (const entry of exhibit.materials) {
const material = entry.material;
material.opacity = focused ? entry.opacity : 0.28;
material.transparent = focused ? entry.transparent : true;
material.depthWrite = focused ? entry.depthWrite : false;
material.needsUpdate = true;
}
exhibit.plinth.capMaterial.emissive.setHex(focused ? 0x102a2f : 0x000000);
exhibit.plinth.capMaterial.emissiveIntensity = focused ? 0.24 : 0;
exhibit.label.classList.toggle("is-muted", !focused);
}
function setModeVisual(mode) {
const active = modes[mode].active;
for (const key of Object.keys(exhibits)) {
const focused = active.includes(key);
setObjectFocus(exhibits[key], focused);
exhibits[key].card.classList.toggle("focused", focused);
exhibits[key].card.classList.toggle(
"muted",
mode !== "all" && !focused
);
}
for (const button of document.querySelectorAll(".mode-panel button")) {
button.setAttribute("aria-pressed", String(button.dataset.mode === mode));
}
document.getElementById("mode-summary").textContent = modes[mode].summary;
}
const auditStatus = document.getElementById("audit-status");
const auditScope = document.getElementById("audit-scope");
const auditDot = document.getElementById("audit-dot");
function validateState(mode) {
setModeVisual(mode);
scene.updateMatrixWorld(true);
const active = modes[mode].active;
let geometryAligned = true;
let dataMatched = true;
let focusMatched = true;
const details = [];
for (const key of Object.keys(exhibits)) {
const exhibit = exhibits[key];
const worldPosition = new THREE.Vector3();
exhibit.object.getWorldPosition(worldPosition);
// The object root must not have its own horizontal translation.
// The exhibit root is the sole horizontal translation owner.
const localHorizontalOffset = Math.abs(exhibit.object.position.x);
const worldCenterAligned =
Math.abs(worldPosition.x - exhibit.root.position.x) < 0.0001;
const bounds = new THREE.Box3().setFromObject(exhibit.object);
const fullyAbovePlinth = bounds.min.y > exhibit.plinth.top + 0.015;
const objectAligned =
localHorizontalOffset < 0.0001 &&
worldCenterAligned &&
fullyAbovePlinth;
geometryAligned = geometryAligned && objectAligned;
const expectedOpacity = active.includes(key) ? 1 : 0.28;
const opacityMatched = exhibit.materials.every((entry) =>
Math.abs(entry.material.opacity - expectedOpacity) < 0.02
);
focusMatched = focusMatched && opacityMatched;
details.push({
object: key,
localHorizontalOffset: Number(localHorizontalOffset.toFixed(6)),
worldX: Number(worldPosition.x.toFixed(3)),
lowestY: Number(bounds.min.y.toFixed(3)),
aligned: objectAligned
});
}
for (const key of active) {
const card = exhibits[key].card;
const visibleText = card.textContent.toLowerCase();
const sourceText = senses[key].context.toLowerCase();
const cardMatched =
visibleText.includes("bat") &&
sourceText.includes("bat") &&
visibleText.length > 35 &&
card.classList.contains("focused") &&
!card.classList.contains("muted");
dataMatched = dataMatched && cardMatched;
}
return {
mode,
pass: geometryAligned && dataMatched && focusMatched,
geometryAligned,
dataMatched,
focusMatched,
details
};
}
function updateAudit(result) {
auditStatus.textContent = result.pass
? `✓ ${result.mode === "all" ? "All senses" : result.mode}: 2 objects aligned · context and focus matched`
: `× Audit failed in ${result.mode}: geometry/data mismatch`;
auditDot.classList.toggle("failed", !result.pass);
}
const modeButtons = [...document.querySelectorAll(".mode-panel button")];
for (const button of modeButtons) {
button.addEventListener("click", () => {
const mode = button.dataset.mode;
setModeVisual(mode);
updateAudit(validateState(mode));
});
}
// Audit every meaningful state against the actual scene graph, world-space
// bounds, rendered context text, and focus behavior.
const audits = {};
let passedStates = 0;
for (const mode of Object.keys(modes)) {
audits[mode] = validateState(mode);
if (audits[mode].pass) passedStates += 1;
}
setModeVisual("all");
updateAudit(validateState("all"));
auditScope.textContent = `${passedStates}/3 states audited`;
console.info("[BAT gallery] Geometry and data audit:", audits);
// Custom pointer orbit controls; no pointer lock and no camera addons.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.classList.add("dragging");
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
orbit.theta -= deltaX * 0.0055;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - deltaY * 0.0045, 0.54, 1.43);
updateCamera();
});
function stopDragging(event) {
dragging = false;
canvas.classList.remove("dragging");
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.007,
7.3,
14.2
);
updateCamera();
}, { passive: false });
canvas.addEventListener("dblclick", () => {
orbit.theta = 0.18;
orbit.phi = 1.12;
orbit.radius = 10.7;
updateCamera();
});
window.addEventListener("resize", () => {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.fov = width < 760 ? 47 : 38;
camera.updateProjectionMatrix();
});
const labelDefinitions = [
{
element: document.getElementById("word-label"),
position: new THREE.Vector3(0, 4.12, 0)
},
{
element: document.getElementById("bio-label"),
position: new THREE.Vector3(-2.65, 3.16, 0)
},
{
element: document.getElementById("made-label"),
position: new THREE.Vector3(2.65, 3.66, 0)
}
];
const projected = new THREE.Vector3();
function positionLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labelDefinitions) {
projected.copy(label.position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.2 &&
projected.x < 1.2 &&
projected.y > -1.2 &&
projected.y < 1.2;
label.element.classList.toggle("visible", visible);
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
label.element.style.left = `${x}px`;
label.element.style.top = `${y}px`;
}
}
}
const clock = new THREE.Clock();
function animate() {
const time = clock.getElapsedTime();
const flap = Math.sin(time * 2.15) * 0.075;
leftWing.rotation.x = -flap;
rightWing.rotation.x = flap;
mammal.rotation.y = -0.08 + Math.sin(time * 0.7) * 0.018;
positionLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
requestAnimationFrame(() => loading.classList.add("hidden"));
</script>
</body>
</html>
```