Prompt specification
Build or customize the Three.js 3D scene "Gamete diversity museum diorama" 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: Gamete diversity museum diorama
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/gamete-diversity-museum-diorama-x0931
Scene Description Prompt:
Gamete diversity museum diorama. Compose a central meiosis model surrounded by resulting symbolic gamete panels; distinguish recombination from chromosome assortment and keep chromosome-count labels internally consistent. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (gamete-diversity-museum-diorama-x0931):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Museum of Meiotic Diversity</title>
<style>
:root {
--ink: #eef5ff;
--muted: #9aa9be;
--panel: rgba(12, 19, 34, 0.84);
--line: rgba(159, 190, 224, 0.2);
--maternal: #ff7182;
--paternal: #42d8c6;
--gold: #ffc857;
--purple: #a78bfa;
--cyan: #7dd3fc;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #070b14;
color: var(--ink);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.glass {
border: 1px solid var(--line);
background:
linear-gradient(145deg, rgba(24, 35, 57, 0.92), rgba(8, 13, 25, 0.84));
box-shadow:
0 18px 60px rgba(0, 0, 0, 0.32),
inset 0 1px rgba(255, 255, 255, 0.04);
backdrop-filter: blur(16px);
}
header {
position: fixed;
top: 24px;
left: 26px;
width: min(460px, calc(100vw - 52px));
pointer-events: none;
z-index: 5;
}
.eyebrow {
color: var(--cyan);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 7px 0 7px;
max-width: 440px;
font-size: clamp(25px, 3vw, 43px);
line-height: 0.98;
letter-spacing: -0.045em;
text-transform: uppercase;
text-shadow: 0 5px 30px rgba(0, 0, 0, 0.5);
}
header p {
margin: 0;
max-width: 430px;
color: #b6c4d7;
font-size: 13px;
line-height: 1.55;
}
.legend {
position: fixed;
top: 24px;
right: 26px;
z-index: 6;
padding: 13px 15px;
border-radius: 14px;
display: grid;
gap: 8px;
font-size: 11px;
color: #c9d5e4;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 13px;
height: 13px;
border-radius: 3px;
box-shadow:
inset 0 0 0 1px rgba(255, 255, 255, 0.22),
0 0 12px currentColor;
}
.maternal { color: var(--maternal); background: var(--maternal); }
.paternal { color: var(--paternal); background: var(--paternal); }
.gold { color: var(--gold); background: var(--gold); }
.purple { color: var(--purple); background: var(--purple); }
#explain {
position: fixed;
left: 26px;
bottom: 25px;
z-index: 8;
width: min(435px, calc(100vw - 52px));
padding: 16px 17px 15px;
border-radius: 17px;
}
.tabs {
display: flex;
gap: 7px;
margin-bottom: 12px;
}
button {
border: 1px solid rgba(166, 195, 229, 0.2);
border-radius: 9px;
padding: 8px 11px;
background: rgba(255, 255, 255, 0.045);
color: #b9c7da;
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: 160ms ease;
}
button:hover,
button:focus-visible {
border-color: rgba(125, 211, 252, 0.65);
color: white;
outline: none;
transform: translateY(-1px);
}
button.active {
border-color: var(--gold);
background: rgba(255, 200, 87, 0.13);
color: #ffe3a0;
}
button.active[data-mode="assortment"] {
border-color: var(--purple);
background: rgba(167, 139, 250, 0.14);
color: #d4c7ff;
}
#modeTitle {
margin: 0 0 6px;
font-size: 16px;
letter-spacing: -0.015em;
}
#modeText {
margin: 0;
color: #b8c6d8;
font-size: 12px;
line-height: 1.55;
}
#selectionNote {
margin-top: 12px;
padding: 9px 11px;
border-left: 2px solid var(--cyan);
border-radius: 0 8px 8px 0;
background: rgba(125, 211, 252, 0.065);
color: #d7e3f2;
font-size: 11px;
line-height: 1.5;
}
#audit {
position: fixed;
right: 26px;
bottom: 25px;
z-index: 7;
width: min(485px, calc(100vw - 52px));
padding: 15px 16px;
border-radius: 17px;
}
#audit h3 {
margin: 0 0 11px;
color: #aebdd0;
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.count-flow {
display: grid;
grid-template-columns: 1fr 17px 1fr 17px 1fr;
gap: 7px;
align-items: stretch;
}
.count-step {
min-width: 0;
padding: 9px 8px;
border: 1px solid rgba(157, 186, 220, 0.13);
border-radius: 10px;
background: rgba(255, 255, 255, 0.025);
}
.count-step strong {
display: block;
margin-bottom: 4px;
color: white;
font-size: 11px;
}
.count-step span {
display: block;
color: #9eacc0;
font-size: 9.5px;
line-height: 1.45;
}
.flow-arrow {
display: grid;
place-items: center;
color: var(--gold);
font-weight: 800;
}
#reset {
position: fixed;
right: 26px;
top: 137px;
z-index: 7;
background: rgba(12, 19, 34, 0.84);
backdrop-filter: blur(12px);
}
#hint {
position: fixed;
left: 50%;
bottom: 13px;
transform: translateX(-50%);
z-index: 4;
color: rgba(202, 216, 233, 0.58);
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
white-space: nowrap;
}
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #070b14;
color: #c5d4e7;
font-size: 13px;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
.legend {
top: auto;
right: 16px;
bottom: 16px;
}
#audit {
display: none;
}
#explain {
left: 16px;
bottom: 16px;
width: min(410px, calc(100vw - 150px));
}
#reset {
right: 16px;
top: 16px;
}
header {
top: 17px;
left: 18px;
}
}
@media (max-width: 620px) {
.legend {
display: none;
}
#explain {
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
}
#hint {
display: none;
}
header {
width: calc(100vw - 36px);
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive three-dimensional museum diorama explaining recombination, chromosome assortment, and gamete diversity"
></canvas>
<header>
<div class="eyebrow">Living Cell Exhibit · Specimen 06</div>
<h1>Museum of Meiotic Diversity</h1>
<p>
One diploid cell with <strong>2n = 6</strong>. One crossover.
Four haploid products with <strong>n = 3</strong>.
</p>
</header>
<div class="legend glass" aria-label="Color legend">
<div class="legend-row">
<span class="swatch maternal"></span>
<span>Maternal homolog</span>
</div>
<div class="legend-row">
<span class="swatch paternal"></span>
<span>Paternal homolog</span>
</div>
<div class="legend-row">
<span class="swatch gold"></span>
<span>Recombination / crossover</span>
</div>
<div class="legend-row">
<span class="swatch purple"></span>
<span>Independent assortment</span>
</div>
</div>
<section id="explain" class="glass" aria-live="polite">
<div class="tabs">
<button class="active" data-mode="recombination">1 · Recombination</button>
<button data-mode="assortment">2 · Assortment</button>
</div>
<h2 id="modeTitle">Recombination changes alleles—not chromosome number</h2>
<p id="modeText">
In prophase I, non-sister chromatids exchange corresponding DNA segments.
The gold bridge marks the crossover on chromosome 1.
</p>
<div id="selectionNote">
Click a gamete panel to inspect its chromosome and allele combinations.
</div>
</section>
<section id="audit" class="glass">
<h3>Chromosome-count audit</h3>
<div class="count-flow">
<div class="count-step">
<strong>Prophase I</strong>
<span>2n = 6<br>6 chromosomes · 12 chromatids</span>
</div>
<div class="flow-arrow">→</div>
<div class="count-step">
<strong>Meiosis I</strong>
<span>n = 3 per pole<br>6 chromatids per cell</span>
</div>
<div class="flow-arrow">→</div>
<div class="count-step">
<strong>Gametes</strong>
<span>n = 3 each<br>3 single-chromatid chromosomes</span>
</div>
</div>
</section>
<button id="reset">Reset view · R</button>
<div id="hint">Drag to orbit · Shift-drag to pan · Wheel/pinch to zoom · Click a specimen</div>
<div id="loading">Assembling voxel exhibit…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Scene and renderer
// ---------------------------------------------------------------------
const canvas = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x070b14);
scene.fog = new THREE.Fog(0x070b14, 27, 55);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xb9d8ff, 0x14131d, 1.5);
scene.add(hemisphere);
const key = new THREE.DirectionalLight(0xffffff, 3.0);
key.position.set(9, 17, 11);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -19;
key.shadow.camera.right = 19;
key.shadow.camera.top = 18;
key.shadow.camera.bottom = -18;
key.shadow.camera.near = 1;
key.shadow.camera.far = 48;
key.shadow.bias = -0.0005;
scene.add(key);
const warmLight = new THREE.PointLight(0xffc857, 38, 24, 2);
warmLight.position.set(-6, 7, 4);
scene.add(warmLight);
const coolLight = new THREE.PointLight(0x5eead4, 34, 24, 2);
coolLight.position.set(7, 6, -4);
scene.add(coolLight);
const violetLight = new THREE.PointLight(0xa78bfa, 24, 20, 2);
violetLight.position.set(0, 5, 1);
scene.add(violetLight);
// ---------------------------------------------------------------------
// Shared geometry and materials
// ---------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const COLORS = {
maternal: 0xff7182,
paternal: 0x42d8c6,
gold: 0xffc857,
purple: 0xa78bfa,
cyan: 0x7dd3fc,
white: 0xeef5ff,
ink: 0x111827,
floorA: 0x111827,
floorB: 0x151d2d,
base: 0x28374d,
baseDark: 0x1d293c,
board: 0x152238,
boardEdge: 0x405675,
centromere: 0xd7e4f4
};
function makeMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.68,
metalness: options.metalness ?? 0.08,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 1,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1,
depthWrite: options.depthWrite ?? true,
side: options.side ?? THREE.FrontSide
});
}
const MAT = {
maternal: makeMaterial(COLORS.maternal, { roughness: 0.52 }),
paternal: makeMaterial(COLORS.paternal, { roughness: 0.52 }),
gold: makeMaterial(COLORS.gold, {
roughness: 0.4,
emissive: COLORS.gold,
emissiveIntensity: 0.28
}),
purple: makeMaterial(COLORS.purple, {
roughness: 0.45,
emissive: COLORS.purple,
emissiveIntensity: 0.22
}),
cyan: makeMaterial(COLORS.cyan, {
roughness: 0.45,
emissive: COLORS.cyan,
emissiveIntensity: 0.18
}),
centromere: makeMaterial(COLORS.centromere, { roughness: 0.55 }),
dark: makeMaterial(0x1b2739, { roughness: 0.78 }),
base: makeMaterial(COLORS.base, { roughness: 0.86 }),
baseDark: makeMaterial(COLORS.baseDark, { roughness: 0.9 }),
board: makeMaterial(COLORS.board, { roughness: 0.88 }),
boardEdge: makeMaterial(COLORS.boardEdge, { roughness: 0.72 }),
interior: makeMaterial(0x1b2a42, { roughness: 0.9 })
};
function block(parent, sx, sy, sz, x, y, z, material, options = {}) {
const mat =
typeof material === "number"
? makeMaterial(material)
: material || MAT.base;
const mesh = new THREE.Mesh(unitBox, mat);
mesh.scale.set(sx, sy, sz);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
parent.add(mesh);
return mesh;
}
function addGrid(parent, cols, rows, spacing, size, y, material, zOffset = 0) {
for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const x = (col - (cols - 1) / 2) * spacing;
const z = zOffset + (row - (rows - 1) / 2) * spacing;
block(parent, size, 0.22, size, x, y, z, material);
}
}
}
// ---------------------------------------------------------------------
// Canvas-texture labels. These are core Three.js sprites.
// ---------------------------------------------------------------------
const labelCache = new Map();
function makeLabel(text, width = 3, options = {}) {
const key = [
text,
width,
options.color || "#eef5ff",
options.bg || "transparent",
options.size || 48,
options.weight || 700
].join("|");
if (labelCache.has(key)) {
const cached = labelCache.get(key).clone();
cached.material = labelCache.get(key).material.clone();
return cached;
}
const lines = text.split("\n");
const fontSize = options.size || 48;
const lineHeight = Math.round(fontSize * 1.18);
const padding = options.padding ?? Math.round(fontSize * 0.38);
const font = `${options.weight || 700} ${fontSize}px Inter, Arial, sans-serif`;
const measureCanvas = document.createElement("canvas");
const measureContext = measureCanvas.getContext("2d");
measureContext.font = font;
const textWidth = Math.max(
...lines.map((line) => measureContext.measureText(line).width)
);
const canvasWidth = Math.ceil(textWidth + padding * 2);
const canvasHeight = Math.ceil(lines.length * lineHeight + padding * 2);
const labelCanvas = document.createElement("canvas");
const dpr = 2;
labelCanvas.width = canvasWidth * dpr;
labelCanvas.height = canvasHeight * dpr;
const context = labelCanvas.getContext("2d");
context.scale(dpr, dpr);
context.font = font;
context.textAlign = "center";
context.textBaseline = "middle";
if (options.bg && options.bg !== "transparent") {
context.fillStyle = options.bg;
context.beginPath();
context.roundRect(
1,
1,
canvasWidth - 2,
canvasHeight - 2,
Math.min(18, fontSize * 0.35)
);
context.fill();
if (options.border) {
context.strokeStyle = options.border;
context.lineWidth = 2;
context.stroke();
}
}
context.fillStyle = options.color || "#eef5ff";
context.shadowColor = options.shadow || "rgba(0,0,0,0.55)";
context.shadowBlur = options.shadowBlur ?? 6;
lines.forEach((line, index) => {
const y =
padding + lineHeight * index + lineHeight * 0.5;
context.fillText(line, canvasWidth / 2, y);
});
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: options.depthTest ?? false,
depthWrite: false,
toneMapped: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, width * canvasHeight / canvasWidth, 1);
sprite.renderOrder = options.renderOrder ?? 40;
labelCache.set(key, sprite);
return sprite.clone();
}
function addLabel(
parent,
text,
x,
y,
z,
width = 3,
options = {}
) {
const sprite = makeLabel(text, width, options);
sprite.position.set(x, y, z);
parent.add(sprite);
return sprite;
}
// ---------------------------------------------------------------------
// Voxel floor and central museum plinth
// ---------------------------------------------------------------------
const floorGeometry = new THREE.BoxGeometry(1, 1, 1);
const floorMaterial = makeMaterial(0xffffff, { roughness: 0.95 });
const floorTiles = 29;
const floorSpacing = 0.8;
const floorCount = floorTiles * floorTiles;
const floor = new THREE.InstancedMesh(
floorGeometry,
floorMaterial,
floorCount
);
floor.receiveShadow = true;
floor.castShadow = false;
const dummy = new THREE.Object3D();
const tileColor = new THREE.Color();
let tileIndex = 0;
for (let z = 0; z < floorTiles; z++) {
for (let x = 0; x < floorTiles; x++) {
dummy.position.set(
(x - (floorTiles - 1) / 2) * floorSpacing,
0.035,
(z - (floorTiles - 1) / 2) * floorSpacing
);
dummy.scale.set(0.72, 0.07, 0.72);
dummy.updateMatrix();
floor.setMatrixAt(tileIndex, dummy.matrix);
const shade = 0.5 + 0.5 * Math.sin(x * 12.7 + z * 5.3);
tileColor.setHSL(0.61, 0.25, 0.055 + shade * 0.016);
floor.setColorAt(tileIndex, tileColor);
tileIndex++;
}
}
floor.instanceMatrix.needsUpdate = true;
floor.instanceColor.needsUpdate = true;
scene.add(floor);
const centralBase = new THREE.Group();
scene.add(centralBase);
addGrid(centralBase, 14, 7, 0.74, 0.68, 0.24, MAT.baseDark);
addGrid(centralBase, 12, 5, 0.74, 0.68, 0.39, MAT.base);
addLabel(
centralBase,
"ONE REPRESENTATIVE MEIOSIS · 2n = 6 → n = 3",
0,
0.86,
2.16,
6.2,
{
color: "#dce9f8",
bg: "rgba(7,12,23,0.88)",
border: "rgba(125,211,252,0.34)",
size: 43
}
);
// ---------------------------------------------------------------------
// Cell cages built from visible cubic voxels
// ---------------------------------------------------------------------
function makeVoxelCage(
parent,
center,
dimensions,
spacing,
material
) {
const [nx, ny, nz] = dimensions;
const positions = [];
for (let x = 0; x < nx; x++) {
for (let y = 0; y < ny; y++) {
for (let z = 0; z < nz; z++) {
const boundary =
x === 0 || x === nx - 1 ||
y === 0 || y === ny - 1 ||
z === 0 || z === nz - 1;
if (boundary) {
positions.push([
center[0] + (x - (nx - 1) / 2) * spacing,
center[1] + (y - (ny - 1) / 2) * spacing,
center[2] + (z - (nz - 1) / 2) * spacing
]);
}
}
}
}
const cage = new THREE.InstancedMesh(
unitBox,
material,
positions.length
);
positions.forEach((position, index) => {
dummy.position.set(...position);
dummy.scale.set(spacing * 0.84, spacing * 0.84, spacing * 0.84);
dummy.updateMatrix();
cage.setMatrixAt(index, dummy.matrix);
});
cage.instanceMatrix.needsUpdate = true;
cage.castShadow = false;
cage.receiveShadow = false;
parent.add(cage);
return cage;
}
const cageMaterial = makeMaterial(0x64d8ef, {
transparent: true,
opacity: 0.19,
roughness: 0.3,
depthWrite: false,
side: THREE.DoubleSide
});
// ---------------------------------------------------------------------
// Chromosome / chromatid construction
//
// Each colored allele block sits on a centromere block.
// A duplicated chromosome consists of two parallel chromatids.
// ---------------------------------------------------------------------
function originColor(origin) {
return origin === "maternal"
? COLORS.maternal
: COLORS.paternal;
}
function createChromatid(
parent,
{
x,
z,
alleles,
scale = 1,
baseY = 1.9,
showLetter = true,
collect = null
}
) {
const blockSize = 0.25 * scale;
const alleleStep = 0.36 * scale;
const returned = { blocks: [], materials: [] };
block(
parent,
0.105 * scale,
0.105 * scale,
0.105 * scale,
x,
baseY - 0.34 * scale,
z,
MAT.centromere
);
alleles.forEach((allele, index) => {
const y = baseY + index * alleleStep;
const material = makeMaterial(originColor(allele.origin), {
roughness: 0.5,
metalness: 0.05,
emissive: 0x000000,
emissiveIntensity: 0
});
const voxel = block(
parent,
blockSize,
blockSize,
blockSize * 0.72,
x,
y,
z,
material
);
if (collect) {
collect.push({
mesh: voxel,
material,
locus: collect.locus ?? 0,
letter: allele.letter
});
}
if (showLetter) {
addLabel(
parent,
allele.letter,
x,
y,
z + blockSize * 0.48,
0.25 * scale,
{
size: 48,
weight: 900,
color: "#101827",
shadow: "rgba(255,255,255,0.18)",
shadowBlur: 0
}
);
}
if (index > 0) {
block(
parent,
0.085 * scale,
0.17 * scale,
0.085 * scale,
x,
y - alleleStep * 0.5,
z,
MAT.dark
);
}
returned.blocks.push(voxel);
returned.materials.push(material);
});
return returned;
}
function createArrowX(parent, x, y, z, length, direction, material) {
const shaftLength = Math.max(0.1, length - 0.15);
const centerX = x + direction * shaftLength * 0.5;
block(
parent,
shaftLength,
0.11,
0.11,
centerX,
y,
z,
material
);
const headX = x + direction * (length - 0.08);
block(parent, 0.16, 0.17, 0.16, headX, y, z, material);
block(
parent,
0.13,
0.13,
0.13,
headX - direction * 0.13,
y,
z,
material
);
}
// ---------------------------------------------------------------------
// Exact gamete data from one representative meiosis
//
// Crossover on chromosome 1:
// maternal chromatids: AE and Ae
// paternal chromatids: ae and aE
//
// Selected assortment orientation:
// pole 1 receives B and D; pole 2 receives b and d.
// ---------------------------------------------------------------------
const gametes = [
{
id: "G1",
number: "01",
pole: "Pole 1",
recombinant: false,
tag: "PARENTAL",
chromosomes: [
[
{ letter: "A", origin: "maternal" },
{ letter: "E", origin: "maternal" }
],
[{ letter: "B", origin: "maternal" }],
[{ letter: "D", origin: "maternal" }]
],
note:
"From pole 1. Chromosome 1 retains the parental AE combination; " +
"the selected assortment orientation also delivers maternal B and D. This gamete still has n = 3."
},
{
id: "G2",
number: "02",
pole: "Pole 1",
recombinant: true,
tag: "RECOMBINANT",
chromosomes: [
[
{ letter: "A", origin: "maternal" },
{ letter: "e", origin: "paternal" }
],
[{ letter: "B", origin: "maternal" }],
[{ letter: "D", origin: "maternal" }]
],
note:
"From pole 1. Chromosome 1 is recombinant: A comes from the maternal homolog and e from the paternal homolog after the crossover. B and D assort to this pole. The chromosome count remains n = 3."
},
{
id: "G3",
number: "03",
pole: "Pole 2",
recombinant: false,
tag: "PARENTAL",
chromosomes: [
[
{ letter: "a", origin: "paternal" },
{ letter: "e", origin: "paternal" }
],
[{ letter: "b", origin: "paternal" }],
[{ letter: "d", origin: "paternal" }]
],
note:
"From pole 2. Chromosome 1 retains the parental ae combination; " +
"the selected assortment orientation delivers paternal b and d. This gamete still has n = 3."
},
{
id: "G4",
number: "04",
pole: "Pole 2",
recombinant: true,
tag: "RECOMBINANT",
chromosomes: [
[
{ letter: "a", origin: "paternal" },
{ letter: "E", origin: "maternal" }
],
[{ letter: "b", origin: "paternal" }],
[{ letter: "d", origin: "paternal" }]
],
note:
"From pole 2. Chromosome 1 is recombinant: a comes from the paternal homolog and E from the maternal homolog after the crossover. b and d assort to this pole. The chromosome count remains n = 3."
}
];
// ---------------------------------------------------------------------
// Central phase 1: prophase I
// ---------------------------------------------------------------------
const phase1 = new THREE.Group();
phase1.position.x = -3.25;
centralBase.add(phase1);
makeVoxelCage(
phase1,
[0, 2.05, 0],
[6, 5, 4],
0.43,
cageMaterial
);
// Pair 1: four chromatids after one crossover.
createChromatid(phase1, {
x: -1.10,
z: 0,
alleles: [
{ letter: "A", origin: "maternal" },
{ letter: "E", origin: "maternal" }
],
showLetter: true
});
createChromatid(phase1, {
x: -0.94,
z: 0,
alleles: [
{ letter: "A", origin: "maternal" },
{ letter: "e", origin: "paternal" }
],
showLetter: true
});
createChromatid(phase1, {
x: -0.80,
z: 0,
alleles: [
{ letter: "a", origin: "paternal" },
{ letter: "e", origin: "maternal" }
],
showLetter: true
});
createChromatid(phase1, {
x: -0.64,
z: 0,
alleles: [
{ letter: "a", origin: "paternal" },
{ letter: "e", origin: "paternal" }
],
showLetter: true
});
// Pair 2: B/b.
const pair2Base = 0;
createChromatid(phase1, {
x: pair2Base - 0.22,
z: 0,
alleles: [{ letter: "B", origin: "maternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair2Base - 0.06,
z: 0,
alleles: [{ letter: "B", origin: "maternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair2Base + 0.08,
z: 0,
alleles: [{ letter: "b", origin: "paternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair2Base + 0.24,
z: 0,
alleles: [{ letter: "b", origin: "paternal" }],
showLetter: true
});
// Pair 3: D/d.
const pair3Base = 0.88;
createChromatid(phase1, {
x: pair3Base - 0.22,
z: 0,
alleles: [{ letter: "D", origin: "maternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair3Base - 0.06,
z: 0,
alleles: [{ letter: "D", origin: "maternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair3Base + 0.08,
z: 0,
alleles: [{ letter: "d", origin: "paternal" }],
showLetter: true
});
createChromatid(phase1, {
x: pair3Base + 0.24,
z: 0,
alleles: [{ letter: "d", origin: "paternal" }],
showLetter: true
});
const crossoverGroup = new THREE.Group();
phase1.add(crossoverGroup);
const crossoverMaterial = makeMaterial(COLORS.gold, {
roughness: 0.34,
emissive: COLORS.gold,
emissiveIntensity: 0.52
});
for (let i = 0; i < 5; i++) {
block(
crossoverGroup,
0.065,
0.065,
0.065,
-0.93 + i * 0.055,
2.26,
0.03,
crossoverMaterial
);
}
block(crossoverGroup, 0.09, 0.09, 0.09, -0.87, 2.40, 0.03, crossoverMaterial);
block(crossoverGroup, 0.09, 0.09, 0.09, -0.87, 2.12, 0.03, crossoverMaterial);
addLabel(
phase1,
"1 · PROPHASE I",
0,
3.86,
0,
3.0,
{
color: "#f3f7ff",
bg: "rgba(9,15,28,0.90)",
border: "rgba(255,200,87,0.42)",
size: 47
}
);
addLabel(
phase1,
"2n = 6",
0,
3.30,
0.12,
1.12,
{
color: "#ffe3a1",
bg: "rgba(255,200,87,0.10)",
border: "rgba(255,200,87,0.42)",
size: 50
}
);
addLabel(
phase1,
"6 chromosomes · 12 chromatids",
0,
0.73,
0.25,
2.65,
{
color: "#c7d5e6",
bg: "rgba(9,15,28,0.80)",
size: 37
}
);
addLabel(
phase1,
"chr1: A/a, E/e · chr2: B/b · chr3: D/d",
0,
0.47,
0.25,
3.25,
{
color: "#8fa2b9",
size: 31
}
);
addLabel(
phase1,
"NON-SISTER CHROMATID EXCHANGE",
-0.87,
2.72,
0.12,
2.20,
{
color: "#ffe3a1",
bg: "rgba(40,29,7,0.88)",
border: "rgba(255,200,87,0.42)",
size: 30
}
);
// ---------------------------------------------------------------------
// Central phase 2: meiosis I
// ---------------------------------------------------------------------
const phase2 = new THREE.Group();
centralBase.add(phase2);
makeVoxelCage(
phase2,
[-0.78, 2.0, 0],
[4, 5, 3],
0.38,
cageMaterial
);
makeVoxelCage(
phase2,
[0.78, 2.0, 0],
[4, 5, 3],
0.38,
cageMaterial
);
// Pole 1 receives the maternal homologs.
const pole1Chromosomes = [
[
[
{ letter: "A", origin: "maternal" },
{ letter: "E", origin: "maternal" }
],
[
{ letter: "A", origin: "maternal" },
{ letter: "e", origin: "paternal" }
]
],
[
[{ letter: "B", origin: "maternal" }],
[{ letter: "B", origin: "maternal" }]
],
[
[{ letter: "D", origin: "maternal" }],
[{ letter: "D", origin: "maternal" }]
]
];
const pole2Chromosomes = [
[
[
{ letter: "a", origin: "paternal" },
{ letter: "e", origin: "paternal" }
],
[
{ letter: "a", origin: "paternal" },
{ letter: "E", origin: "maternal" }
]
],
[
[{ letter: "b", origin: "paternal" }],
[{ letter: "b", origin: "paternal" }]
],
[
[{ letter: "d", origin: "paternal" }],
[{ letter: "d", origin: "paternal" }]
]
];
function populatePole(parent, centerX, chromosomes) {
const positions = [-0.38, 0, 0.38];
chromosomes.forEach((chromosome, index) => {
const x = centerX + positions[index];
chromosome.forEach((alleles, chromatidIndex) => {
createChromatid(parent, {
x,
z: -0.09 + chromatidIndex * 0.18,
alleles,
scale: 0.76,
baseY: 1.88,
showLetter: false
});
});
});
}
populatePole(phase2, -0.78, pole1Chromosomes);
populatePole(phase2, 0.78, pole2Chromosomes);
const assortmentMaterial = makeMaterial(COLORS.purple, {
roughness: 0.4,
emissive: COLORS.purple,
emissiveIntensity: 0.32
});
createArrowX(phase2, 0, 3.16, 0.22, 0.5, -1, assortmentMaterial);
createArrowX(phase2, 0, 3.16, 0.22, 0.5, 1, assortmentMaterial);
addLabel(
phase2,
"2 · MEIOSIS I",
0,
3.94,
0,
3.0,
{
color: "#f3f7ff",
bg: "rgba(9,15,28,0.90)",
border: "rgba(167,139,250,0.48)",
size: 47
}
);
addLabel(
phase2,
"POLE 1\nB · D",
-0.78,
3.36,
0.28,
1.50,
{
color: "#d8ccff",
bg: "rgba(27,21,53,0.90)",
border: "rgba(167,139,250,0.42)",
size: 32
}
);
addLabel(
phase2,
"POLE 2\nb · d",
0.78,
3.36,
0.28,
1.50,
{
color: "#d8ccff",
bg: "rgba(27,21,53,0.90)",
border: "rgba(167,139,250,0.42)",
size: 32
}
);
addLabel(
phase2,
"n = 3 per pole · chromosomes still duplicated",
0,
0.73,
0.25,
3.15,
{
color: "#c7d5e6",
bg: "rgba(9,15,28,0.80)",
size: 37
}
);
addLabel(
phase2,
"INDEPENDENT HOMOLOG ORIENTATION",
0,
0.46,
0.25,
3.25,
{
color: "#cbbdff",
size: 31
}
);
// ---------------------------------------------------------------------
// Central phase 3: meiosis II and the four products
// ---------------------------------------------------------------------
const phase3 = new THREE.Group();
phase3.position.x = 3.25;
centralBase.add(phase3);
const productLayout = [
[-0.68, -0.43],
[0.68, -0.43],
[-0.68, 0.43],
[0.68, 0.43]
];
gametes.forEach((gamete, index) => {
const product = new THREE.Group();
product.position.set(productLayout[index][0], 0, productLayout[index][1]);
phase3.add(product);
// A tiny voxel boundary around each product.
const boundary = [
[-0.28, -0.28], [0, -0.28], [0.28, -0.28],
[-0.28, 0], [0.28, 0],
[-0.28, 0.28], [0, 0.28], [0.28, 0.28]
];
boundary.forEach(([x, z]) => {
block(
product,
0.11,
0.11,
0.11,
x,
1.02,
z,
MAT.cyan
);
});
const chromosomePositions = [-0.19, 0, 0.19];
gamete.chromosomes.forEach((alleles, chromosomeIndex) => {
createChromatid(product, {
x: chromosomePositions[chromosomeIndex],
z: 0,
alleles,
scale: 0.49,
baseY: 1.56,
showLetter: true
});
});
addLabel(
product,
gamete.id,
0,
0.78,
0,
0.54,
{
color: gamete.recombinant ? "#ffe3a1" : "#d5e3f4",
bg: "rgba(8,13,24,0.86)",
size: 34
}
);
});
addLabel(
phase3,
"3 · MEIOSIS II",
0,
3.94,
0,
3.0,
{
color: "#f3f7ff",
bg: "rgba(9,15,28,0.90)",
border: "rgba(125,211,252,0.42)",
size: 47
}
);
addLabel(
phase3,
"4 haploid products · n = 3 each",
0,
0.73,
0.25,
2.85,
{
color: "#c7d5e6",
bg: "rgba(9,15,28,0.80)",
size: 37
}
);
addLabel(
phase3,
"SISTER CHROMATIDS SEPARATE",
0,
0.46,
0.25,
2.95,
{
color: "#9ddcf5",
size: 31
}
);
// Small voxel transitions between central phases.
createArrowX(centralBase, -1.96, 0.62, 1.63, 0.64, 1, MAT.cyan);
createArrowX(centralBase, 1.55, 0.62, 1.63, 0.64, 1, MAT.cyan);
// ---------------------------------------------------------------------
// Surrounding gamete display panels
// ---------------------------------------------------------------------
const panels = [];
const pickables = [];
function createGametePanel(gamete, index, position) {
const root = new THREE.Group();
root.position.copy(position);
scene.add(root);
addGrid(root, 5, 5, 0.58, 0.52, 0.14, MAT.baseDark);
addGrid(root, 3, 3, 0.58, 0.52, 0.38, MAT.base);
block(root, 0.48, 0.60, 0.48, 0, 0.77, 0, MAT.base);
block(root, 0.42, 0.36, 0.42, 0, 1.20, 0, MAT.baseDark);
const board = new THREE.Group();
root.add(board);
const borderMaterial = MAT.boardEdge.clone();
borderMaterial.emissive = new THREE.Color(0x000000);
borderMaterial.emissiveIntensity = 0;
const panelData = {
id: gamete.id,
gamete,
root,
board,
borderMaterial,
chromosomeMaterials: [],
pickables: []
};
// Seven by five visible board voxels.
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 7; col++) {
const isBorder = row === 0 || row === 4 || col === 0 || col === 6;
const x = (col - 3) * 0.50;
const y = 1.28 + row * 0.43;
const tile = block(
board,
0.455,
0.385,
0.16,
x,
y,
0,
isBorder ? borderMaterial : MAT.interior
);
tile.userData.panelId = gamete.id;
pickables.push(tile);
panelData.pickables.push(tile);
}
}
const chromosomeXs = [-1.05, 0, 1.05];
gamete.chromosomes.forEach((alleles, chromosomeIndex) => {
const collector = [];
collector.locus = chromosomeIndex;
const chromosome = createChromatid(board, {
x: chromosomeXs[chromosomeIndex],
z: 0.18,
alleles,
scale: 0.86,
baseY: chromosomeIndex === 0 ? 1.78 : 1.93,
showLetter: true,
collect: collector
});
collector.forEach((entry) => {
entry.mesh.userData.panelId = gamete.id;
pickables.push(entry.mesh);
panelData.chromosomeMaterials.push(entry);
});
});
addLabel(
board,
`GAMETE ${gamete.number}`,
0,
3.61,
0.16,
2.85,
{
color: "#f1f7ff",
bg: "rgba(8,13,24,0.92)",
border: "rgba(125,211,252,0.30)",
size: 40
}
);
addLabel(
board,
gamete.tag,
0,
3.24,
0.18,
1.78,
{
color: gamete.recombinant ? "#ffe3a1" : "#b6c7db",
bg: gamete.recombinant
? "rgba(52,38,8,0.92)"
: "rgba(8,13,24,0.90)",
border: gamete.recombinant
? "rgba(255,200,87,0.45)"
: "rgba(159,190,224,0.20)",
size: 30
}
);
addLabel(
board,
"n = 3 chromosomes · 3 chromatids",
0,
0.79,
0.18,
2.95,
{
color: "#a9bdd3",
bg: "rgba(8,13,24,0.86)",
size: 32
}
);
addLabel(
board,
gamete.pole,
0,
0.48,
0.18,
1.45,
{
color: "#879db6",
size: 28
}
);
panels.push(panelData);
return panelData;
}
createGametePanel(
gametes[0],
0,
new THREE.Vector3(-7.15, 0, 4.75)
);
createGametePanel(
gametes[1],
1,
new THREE.Vector3(-7.15, 0, -4.75)
);
createGametePanel(
gametes[2],
2,
new THREE.Vector3(7.15, 0, 4.75)
);
createGametePanel(
gametes[3],
3,
new THREE.Vector3(7.15, 0, -4.75)
);
// ---------------------------------------------------------------------
// Explanation and selection UI
// ---------------------------------------------------------------------
const modeTitle = document.querySelector("#modeTitle");
const modeText = document.querySelector("#modeText");
const selectionNote = document.querySelector("#selectionNote");
const modeButtons = [...document.querySelectorAll("[data-mode]")];
let currentMode = "recombination";
let selectedPanel = null;
const modeCopy = {
recombination: {
title: "Recombination changes alleles—not chromosome number",
text:
"In prophase I, non-sister chromatids exchange corresponding DNA " +
"segments. The gold bridge marks the crossover on chromosome 1, " +
"producing parental AE and ae chromatids plus recombinant Ae and aE " +
"chromatids. Recombination does not add or remove chromosomes."
},
assortment: {
title: "Assortment changes chromosome combinations",
text:
"At metaphase I, each homolog pair orients independently. The " +
"illustrated orientation sends B and D toward pole 1 and b and d " +
"toward pole 2. Reorienting a pair creates other combinations; " +
"every resulting gamete still contains n = 3 chromosomes."
}
};
function applyVisualMode() {
modeButtons.forEach((button) => {
button.classList.toggle("active", button.dataset.mode === currentMode);
});
modeTitle.textContent = modeCopy[currentMode].title;
modeText.textContent = modeCopy[currentMode].text;
crossoverMaterial.emissiveIntensity =
currentMode === "recombination" ? 0.62 : 0.24;
assortmentMaterial.emissiveIntensity =
currentMode === "assortment" ? 0.68 : 0.20;
panels.forEach((panel) => {
const isSelected = selectedPanel === panel.id;
const isRecombinant = panel.gamete.recombinant;
let borderColor = 0x405675;
let borderEmissive = 0x000000;
let borderIntensity = 0;
if (isSelected) {
borderColor = 0x7dd3fc;
borderEmissive = 0x7dd3fc;
borderIntensity = 0.34;
}
if (currentMode === "recombination") {
if (isRecombinant) {
borderColor = 0xffc857;
borderEmissive = 0xffc857;
borderIntensity = 0.52;
} else if (!isSelected) {
borderIntensity = 0.05;
}
}
if (currentMode === "assortment") {
borderColor = isSelected ? 0x7dd3fc : 0xa78bfa;
borderEmissive = isSelected ? 0x7dd3fc : 0xa78bfa;
borderIntensity = isSelected ? 0.48 : 0.30;
}
panel.borderMaterial.color.setHex(borderColor);
panel.borderMaterial.emissive.setHex(borderEmissive);
panel.borderMaterial.emissiveIntensity = borderIntensity;
panel.chromosomeMaterials.forEach((entry) => {
entry.material.emissive.setHex(0x000000);
entry.material.emissiveIntensity = 0;
if (currentMode === "recombination") {
if (isRecombinant && entry.locus === 0) {
entry.material.emissive.setHex(0xffc857);
entry.material.emissiveIntensity = 0.48;
}
}
if (currentMode === "assortment" && entry.locus > 0) {
entry.material.emissive.setHex(0xa78bfa);
entry.material.emissiveIntensity = 0.48;
}
if (
currentMode === "recombination" &&
isSelected &&
isRecombinant &&
entry.locus === 0
) {
entry.material.emissiveIntensity = 0.68;
}
});
});
}
function selectPanel(id) {
const panel = panels.find((entry) => entry.id === id);
if (!panel) return;
selectedPanel = id;
selectionNote.textContent = panel.gamete.note;
applyVisualMode();
}
modeButtons.forEach((button) => {
button.addEventListener("click", () => {
currentMode = button.dataset.mode;
applyVisualMode();
});
});
applyVisualMode();
// ---------------------------------------------------------------------
// Custom camera controls: orbit, pan, wheel zoom, and touch pinch
// ---------------------------------------------------------------------
const controls = {
yaw: 0.48,
pitch: 0.57,
radius: 24.8,
target: new THREE.Vector3(0, 1.45, 0)
};
function updateCamera() {
const horizontalRadius = Math.cos(controls.pitch) * controls.radius;
camera.position.set(
controls.target.x + Math.sin(controls.yaw) * horizontalRadius,
controls.target.y + Math.sin(controls.pitch) * controls.radius,
controls.target.z + Math.cos(controls.yaw) * horizontalRadius
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.yaw = 0.48;
controls.pitch = 0.57;
controls.radius = 24.8;
controls.target.set(0, 1.45, 0);
updateCamera();
}
updateCamera();
const pointers = new Map();
let pinchStartDistance = 0;
let pinchStartRadius = controls.radius;
let pointerTravel = 0;
let pointerStartX = 0;
let pointerStartY = 0;
let panning = false;
const rightVector = new THREE.Vector3();
const upVector = new THREE.Vector3();
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("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 1) {
pointerTravel = 0;
pointerStartX = event.clientX;
pointerStartY = event.clientY;
panning = event.shiftKey || event.button === 2;
}
if (pointers.size === 2) {
pinchStartDistance = pointerDistance();
pinchStartRadius = controls.radius;
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) {
updateHoverCursor(event);
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 });
pointerTravel += Math.hypot(dx, dy);
if (pointers.size === 1) {
if (panning || event.shiftKey) {
camera.updateMatrixWorld();
rightVector.setFromMatrixColumn(camera.matrix, 0);
upVector.setFromMatrixColumn(camera.matrix, 1);
const panScale = controls.radius * 0.0015;
controls.target
.addScaledVector(rightVector, -dx * panScale)
.addScaledVector(upVector, dy * panScale);
} else {
controls.yaw -= dx * 0.0052;
controls.pitch = THREE.MathUtils.clamp(
controls.pitch + dy * 0.0037,
0.22,
1.24
);
}
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (pinchStartDistance > 0 && distance > 0) {
controls.radius = THREE.MathUtils.clamp(
pinchStartRadius * pinchStartDistance / distance,
10,
35
);
}
}
updateCamera();
});
function endPointer(event) {
if (
pointers.size === 1 &&
pointerTravel < 6 &&
Math.hypot(
event.clientX - pointerStartX,
event.clientY - pointerStartY
) < 6
) {
pickPanel(event);
}
pointers.delete(event.pointerId);
panning = false;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", (event) => {
pointers.delete(event.pointerId);
panning = false;
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
10,
35
);
updateCamera();
},
{ passive: false }
);
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
function getIntersections(event) {
const rect = canvas.getBoundingClientRect();
pointerNDC.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
return raycaster.intersectObjects(pickables, false);
}
function pickPanel(event) {
const intersections = getIntersections(event);
if (intersections.length) {
const panelId = intersections[0].object.userData.panelId;
if (panelId) selectPanel(panelId);
}
}
function updateHoverCursor(event) {
const intersections = getIntersections(event);
canvas.style.cursor = intersections.length ? "pointer" : "grab";
}
canvas.addEventListener("pointermove", (event) => {
if (!pointers.size) updateHoverCursor(event);
});
document.querySelector("#reset").addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
if (event.key === "1") {
currentMode = "recombination";
applyVisualMode();
}
if (event.key === "2") {
currentMode = "assortment";
applyVisualMode();
}
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// ---------------------------------------------------------------------
// Animation
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
const boardWorldPosition = new THREE.Vector3();
function animate() {
const elapsed = clock.getElapsedTime();
// Gentle pulse marks the crossover without changing chromosome counts.
const pulse = 1 + Math.sin(elapsed * 3.1) * 0.055;
crossoverGroup.scale.setScalar(pulse);
// Keep surrounding specimen boards readable while orbiting.
panels.forEach((panel) => {
panel.board.getWorldPosition(boardWorldPosition);
const angle = Math.atan2(
camera.position.x - boardWorldPosition.x,
camera.position.z - boardWorldPosition.z
);
panel.board.rotation.set(-0.13, angle, 0);
});
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
});
</script>
</body>
</html>
```