Prompt specification
Build or customize the Three.js 3D scene "Organelle evidence comparison cabinet" 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: Organelle evidence comparison cabinet
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/organelle-evidence-comparison-cabinet-x0841
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts endosymbiosis. Arrange simplified mitochondrion and bacterial cell models beside separate symbolic DNA and membrane markers; label the features as lines of evidence rather than a complete proof diagram. Low-poly.
Working Three.js Starter (organelle-evidence-comparison-cabinet-x0841):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Endosymbiosis — Lines of Evidence</title>
<style>
:root {
--bg: #07111f;
--panel: rgba(10, 25, 40, 0.82);
--text: #eef7ff;
--muted: #9fb2c4;
--mito: #ff8a5c;
--bacteria: #43e2cc;
--dna: #c9ff67;
--membrane: #ffd166;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
position: fixed;
inset: 0;
display: block;
z-index: 0;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
#vignette {
position: fixed;
inset: 0;
z-index: 1;
pointer-events: none;
background:
radial-gradient(circle at 50% 44%, transparent 32%, rgba(2, 8, 16, 0.42) 100%),
linear-gradient(180deg, rgba(2, 8, 16, 0.16), transparent 25%, transparent 75%, rgba(2, 8, 16, 0.35));
}
#leaders {
position: fixed;
inset: 0;
z-index: 2;
width: 100%;
height: 100%;
pointer-events: none;
overflow: visible;
}
#leaders path,
#leaders line {
fill: none;
stroke-width: 1.35;
vector-effect: non-scaling-stroke;
}
#leaders circle {
stroke-width: 1.2;
vector-effect: non-scaling-stroke;
}
#ui {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
}
header {
position: absolute;
top: 28px;
left: 32px;
max-width: 530px;
}
.eyebrow {
margin-bottom: 8px;
color: #7fdacf;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(34px, 5vw, 62px);
font-weight: 760;
line-height: 0.95;
letter-spacing: -0.055em;
}
.subtitle {
max-width: 470px;
margin: 13px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.45;
}
.subtitle strong {
color: #d9e9f7;
font-weight: 650;
}
.scene-stamp {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 15px;
padding: 7px 10px;
border: 1px solid rgba(127, 218, 207, 0.28);
border-radius: 999px;
background: rgba(11, 29, 44, 0.64);
color: #b5d9d5;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.scene-stamp::before {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--bacteria);
box-shadow: 0 0 12px var(--bacteria);
content: "";
}
.center-caption {
position: absolute;
top: 35px;
left: 50%;
transform: translateX(-50%);
color: rgba(190, 212, 229, 0.58);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.2em;
text-align: center;
text-transform: uppercase;
white-space: nowrap;
}
.center-caption::before {
display: block;
width: 44px;
height: 1px;
margin: 0 auto 9px;
background: rgba(190, 212, 229, 0.32);
content: "";
}
.callout {
position: absolute;
width: 235px;
padding: 13px 14px 14px;
border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
border-left: 3px solid var(--accent);
border-radius: 9px;
background:
linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 55%),
var(--panel);
box-shadow: 0 12px 38px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(12px);
}
.callout.left {
left: clamp(14px, 3vw, 42px);
}
.callout.right {
right: clamp(14px, 3vw, 42px);
}
#evidence-1 { top: 27%; }
#evidence-2 { top: 50%; }
#evidence-3 { top: 73%; }
#evidence-4 { top: 31%; }
#evidence-5 { top: 57%; }
.callout .number {
color: var(--accent);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.callout h2 {
margin: 5px 0 5px;
color: #f3f8fc;
font-size: 13px;
font-weight: 780;
letter-spacing: 0.015em;
line-height: 1.15;
}
.callout p {
margin: 0;
color: #aabccb;
font-size: 11px;
line-height: 1.42;
}
.marker-tag,
.model-tag {
position: absolute;
transform: translate(-50%, -50%);
white-space: nowrap;
text-align: center;
}
.marker-tag {
min-width: 106px;
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.14);
border-radius: 6px;
background: rgba(7, 17, 31, 0.86);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
.marker-tag strong {
display: block;
color: var(--tag-color);
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.marker-tag span {
display: block;
margin-top: 3px;
color: #9eb1c2;
font-size: 9px;
}
.model-tag {
color: rgba(235, 246, 255, 0.78);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.model-tag span {
display: block;
margin-top: 4px;
color: rgba(159, 178, 196, 0.7);
font-size: 8px;
font-weight: 600;
letter-spacing: 0.07em;
text-transform: none;
}
.controls {
position: absolute;
right: 32px;
bottom: 28px;
color: rgba(184, 207, 222, 0.66);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.11em;
text-transform: uppercase;
}
footer {
position: absolute;
bottom: 27px;
left: 32px;
max-width: 470px;
color: rgba(159, 178, 196, 0.68);
font-size: 10px;
line-height: 1.45;
}
footer strong {
color: rgba(215, 231, 242, 0.85);
font-weight: 700;
}
@media (max-width: 900px) {
header {
top: 20px;
left: 20px;
}
.center-caption {
display: none;
}
.callout {
width: 178px;
padding: 10px 11px;
}
.callout p {
display: none;
}
.callout h2 {
font-size: 11px;
}
.controls {
right: 20px;
bottom: 20px;
}
footer {
bottom: 20px;
left: 20px;
max-width: 300px;
}
}
@media (max-width: 620px) {
h1 {
font-size: 36px;
}
.subtitle {
max-width: 310px;
font-size: 11px;
}
.scene-stamp {
display: none;
}
.callout {
width: 126px;
padding: 8px 9px;
}
.callout .number {
font-size: 7px;
}
.callout h2 {
margin-top: 4px;
font-size: 9px;
}
#evidence-1 { top: 30%; }
#evidence-2 { top: 53%; }
#evidence-3 { top: 76%; }
#evidence-4 { top: 33%; }
#evidence-5 { top: 59%; }
.marker-tag {
min-width: 84px;
padding: 5px 7px;
}
.marker-tag strong {
font-size: 7px;
}
.marker-tag span {
font-size: 7px;
}
.model-tag {
font-size: 7px;
}
.model-tag span {
display: none;
}
footer {
max-width: 245px;
font-size: 8px;
}
.controls {
display: none;
}
}
</style>
</head>
<body>
<div id="vignette"></div>
<svg id="leaders" aria-hidden="true"></svg>
<div id="ui">
<header>
<div class="eyebrow">Biological visualization / 01</div>
<h1>Endosymbiosis</h1>
<p class="subtitle">
Comparing a mitochondrion with a bacterial cell.
<strong>Each label marks a line of evidence</strong>—not a complete proof diagram.
</p>
<div class="scene-stamp">Low-poly comparative study</div>
</header>
<div class="center-caption">Separate comparative cues</div>
<article
id="evidence-1"
class="callout left"
data-anchor="mitoDna"
style="--accent: #c9ff67"
>
<div class="number">Line of evidence 01</div>
<h2>Mitochondrial DNA</h2>
<p>A distinct compact loop appears inside the simplified organelle.</p>
</article>
<article
id="evidence-2"
class="callout left"
data-anchor="mitoMembrane"
style="--accent: #ff8a5c"
>
<div class="number">Line of evidence 02</div>
<h2>Two boundary layers</h2>
<p>Inner and outer membranes distinguish the organelle from a typical bacterium.</p>
</article>
<article
id="evidence-3"
class="callout left"
data-anchor="mitoRibosomes"
style="--accent: #ffd166"
>
<div class="number">Line of evidence 03</div>
<h2>Ribosome-like particles</h2>
<p>Small internal particles echo the bacterial ribosome cue.</p>
</article>
<article
id="evidence-4"
class="callout right"
data-anchor="bacterialDna"
style="--accent: #c9ff67"
>
<div class="number">Line of evidence 04</div>
<h2>Circular bacterial DNA</h2>
<p>The partner cell contains a compact chromosome-like loop.</p>
</article>
<article
id="evidence-5"
class="callout right"
data-anchor="bacterialDivision"
style="--accent: #43e2cc"
>
<div class="number">Line of evidence 05</div>
<h2>Division by fission</h2>
<p>A central waist suggests the splitting process used by many bacteria.</p>
</article>
<div
id="dnaMarkerTag"
class="marker-tag"
style="--tag-color: #c9ff67"
>
<strong>DNA cue</strong>
<span>loop + helix</span>
</div>
<div
id="membraneMarkerTag"
class="marker-tag"
style="--tag-color: #ffd166"
>
<strong>Membrane cue</strong>
<span>one vs. two layers</span>
</div>
<div id="mitoModelTag" class="model-tag">
Mitochondrion
<span>simplified host organelle</span>
</div>
<div id="bactModelTag" class="model-tag">
Bacterial cell
<span>simplified cellular partner</span>
</div>
<footer>
<strong>Schematic, not to scale.</strong>
These selected similarities support discussion of endosymbiotic origin;
they do not form a complete proof diagram.
</footer>
<div class="controls">Drag to orbit · scroll to zoom · double-click to reset</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, and camera
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true });
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;
renderer.setClearColor(0x07111f, 1);
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x07111f, 13, 29);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
theta: 0.03,
phi: Math.PI / 2 - 0.08,
radius: 11.2,
target: new THREE.Vector3(0, 0.05, 0),
dragging: false,
previousX: 0,
previousY: 0
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.radius * sinPhi * Math.sin(controls.theta),
controls.radius * Math.cos(controls.phi),
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
updateCamera();
// Direct, dependency-free camera controls.
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.previousX;
const dy = event.clientY - controls.previousY;
controls.previousX = event.clientX;
controls.previousY = event.clientY;
controls.theta -= dx * 0.005;
controls.phi = THREE.MathUtils.clamp(
controls.phi + dy * 0.005,
0.48,
2.25
);
});
function endDrag(event) {
controls.dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
7.5,
19
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
controls.theta = 0.03;
controls.phi = Math.PI / 2 - 0.08;
controls.radius = window.innerWidth < 620 ? 16.8 : 11.2;
});
// -------------------------------------------------------------------------
// Lighting and shared helpers
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xbddfff, 0x172131, 2.25));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(5.5, 8, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x43e2cc, 18, 14, 2);
cyanLight.position.set(4.5, 1.5, 4);
scene.add(cyanLight);
const orangeLight = new THREE.PointLight(0xff784d, 20, 13, 2);
orangeLight.position.set(-4.5, 1, 4);
scene.add(orangeLight);
const rimLight = new THREE.DirectionalLight(0x84bfff, 1.2);
rimLight.position.set(-3, 2, -6);
scene.add(rimLight);
let randomSeed = 93241;
function random() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function lowPolyMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.62,
metalness: 0.04,
flatShading: true,
...options
});
}
function cylinderBetween(a, b, radius, material, radialSegments = 5) {
const direction = b.clone().sub(a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
radialSegments,
1
);
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.normalize()
);
return mesh;
}
function addAnchor(parent, name, x, y, z) {
const anchor = new THREE.Object3D();
anchor.name = name;
anchor.position.set(x, y, z);
parent.add(anchor);
return anchor;
}
const anchors = {};
// -------------------------------------------------------------------------
// Floor, pedestals, and subtle spatial grid
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.CircleGeometry(11, 64),
lowPolyMaterial(0x091725, { roughness: 0.96 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.46;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(14, 28, 0x244357, 0x142c3e);
grid.position.y = -1.445;
grid.material.transparent = true;
grid.material.opacity = 0.2;
scene.add(grid);
function makePedestal(x, accent) {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(1.72, 1.8, 0.11, 32),
lowPolyMaterial(0x102434, { roughness: 0.84 })
);
base.position.set(x, -1.39, 0);
base.receiveShadow = true;
group.add(base);
const ring = new THREE.Mesh(
new THREE.TorusGeometry(1.58, 0.015, 4, 64),
lowPolyMaterial(accent, {
emissive: accent,
emissiveIntensity: 0.4
})
);
ring.rotation.x = Math.PI / 2;
ring.position.set(x, -1.325, 0);
group.add(ring);
scene.add(group);
}
makePedestal(-3.05, 0xff8a5c);
makePedestal(3.05, 0x43e2cc);
// -------------------------------------------------------------------------
// Low-poly mitochondrion
// -------------------------------------------------------------------------
function makeBeanGeometry() {
const geometry = new THREE.SphereGeometry(1, 18, 11).toNonIndexed();
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const sx = positions.getX(i);
const sy = positions.getY(i);
const sz = positions.getZ(i);
let x = sx * 1.52;
let y = sy * 0.76;
let z = sz * 0.64;
const upperDent =
0.25 *
Math.exp(-Math.pow((x - 0.42) / 0.46, 2)) *
Math.max(sy, 0);
y -= upperDent;
y += 0.055 * Math.sin(x * 1.8) * (1 - Math.abs(sy));
z *= 1 - 0.11 * Math.exp(-Math.pow((x + 0.2) / 0.55, 2));
positions.setXYZ(i, x, y, z);
}
geometry.computeVertexNormals();
return geometry;
}
const mitochondrion = new THREE.Group();
mitochondrion.position.set(-3.05, 0.13, 0);
scene.add(mitochondrion);
const mitoOuterMaterial = lowPolyMaterial(0xff8055, {
transparent: true,
opacity: 0.39,
side: THREE.DoubleSide,
depthWrite: false
});
const mitoInnerMaterial = lowPolyMaterial(0xd94c38, {
transparent: true,
opacity: 0.24,
side: THREE.DoubleSide,
depthWrite: false
});
const mitoGeometry = makeBeanGeometry();
const mitoInner = new THREE.Mesh(mitoGeometry, mitoInnerMaterial);
mitoInner.scale.set(0.86, 0.86, 0.86);
mitoInner.castShadow = true;
mitochondrion.add(mitoInner);
const mitoOuter = new THREE.Mesh(mitoGeometry, mitoOuterMaterial);
mitoOuter.renderOrder = 4;
mitochondrion.add(mitoOuter);
const mitoEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(mitoGeometry, 34),
new THREE.LineBasicMaterial({
color: 0xffa175,
transparent: true,
opacity: 0.3
})
);
mitoEdges.renderOrder = 5;
mitochondrion.add(mitoEdges);
// Folded internal membrane forms.
const cristaMaterial = lowPolyMaterial(0xffb55e, {
emissive: 0xff6d3e,
emissiveIntensity: 0.17
});
const cristaPositions = [-0.9, -0.57, -0.23, 0.12, 0.48, 0.82];
cristaPositions.forEach((x, index) => {
const crista = new THREE.Mesh(
new THREE.TorusGeometry(
0.34 + (index % 2) * 0.025,
0.052,
4,
12,
Math.PI * (1.28 + (index % 3) * 0.1)
),
cristaMaterial
);
crista.rotation.y = Math.PI / 2;
crista.rotation.z = index * 0.29;
crista.position.set(x, 0.015 + Math.sin(index) * 0.035, 0.02);
crista.scale.set(1, 1.02, 0.78);
mitochondrion.add(crista);
});
// Distinct circular DNA-like loop.
const dnaMaterial = lowPolyMaterial(0xc9ff67, {
emissive: 0x75d52a,
emissiveIntensity: 0.42
});
const mitoDna = new THREE.Mesh(
new THREE.TorusGeometry(0.25, 0.023, 5, 32),
dnaMaterial
);
mitoDna.position.set(0.02, 0.02, 0.47);
mitoDna.scale.set(1.38, 0.7, 1);
mitochondrion.add(mitoDna);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const bead = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.035, 0),
dnaMaterial
);
bead.position.set(
0.02 + Math.cos(angle) * 0.345,
0.02 + Math.sin(angle) * 0.175,
0.47
);
mitochondrion.add(bead);
}
// Ribosome-like particles.
const ribosomeMaterial = lowPolyMaterial(0xffefbc, {
emissive: 0xb98c45,
emissiveIntensity: 0.2
});
const ribosomePositions = [
[-0.58, 0.26, 0.38],
[-0.2, -0.22, 0.44],
[0.28, 0.2, 0.4],
[0.62, -0.16, 0.36],
[-0.82, -0.02, 0.18],
[0.9, 0.1, 0.12],
[-0.36, 0.34, 0.2],
[0.48, -0.33, 0.22]
];
ribosomePositions.forEach((position) => {
const particle = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.052, 0),
ribosomeMaterial
);
particle.position.set(...position);
mitochondrion.add(particle);
});
anchors.mitoDna = addAnchor(
mitochondrion, "mitoDna", 0.02, 0.02, 0.53
);
anchors.mitoMembrane = addAnchor(
mitochondrion, "mitoMembrane", -1.26, 0.24, 0.35
);
anchors.mitoRibosomes = addAnchor(
mitochondrion, "mitoRibosomes", 0.28, 0.2, 0.46
);
anchors.mitoLabel = addAnchor(
mitochondrion, "mitoLabel", 0, -1.06, 0
);
// -------------------------------------------------------------------------
// Low-poly bacterial cell with a fission-like constriction
// -------------------------------------------------------------------------
function makeBacteriumGeometry() {
const geometry = new THREE.CapsuleGeometry(0.6, 1.12, 4, 10);
geometry.rotateZ(Math.PI / 2);
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const x = positions.getX(i);
const y = positions.getY(i);
const z = positions.getZ(i);
const neck = 1 - 0.19 * Math.exp(-Math.pow(x / 0.14, 2));
positions.setXYZ(i, x, y * neck, z * neck);
}
geometry.scale(1, 0.94, 0.82);
geometry.computeVertexNormals();
return geometry;
}
const bacterium = new THREE.Group();
bacterium.position.set(3.05, 0.13, 0);
scene.add(bacterium);
const bacteriaOuterMaterial = lowPolyMaterial(0x35d9c5, {
transparent: true,
opacity: 0.42,
side: THREE.DoubleSide,
depthWrite: false
});
const bacteriaBodyMaterial = lowPolyMaterial(0x138c8d, {
transparent: true,
opacity: 0.29,
side: THREE.DoubleSide,
depthWrite: false
});
const bacteriumGeometry = makeBacteriumGeometry();
const bacteriaBody = new THREE.Mesh(
bacteriumGeometry,
bacteriaBodyMaterial
);
bacteriaBody.scale.set(0.93, 0.91, 0.9);
bacteriaBody.castShadow = true;
bacterium.add(bacteriaBody);
const bacteriaOuter = new THREE.Mesh(
bacteriumGeometry,
bacteriaOuterMaterial
);
bacteriaOuter.renderOrder = 4;
bacterium.add(bacteriaOuter);
const bacteriaEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(bacteriumGeometry, 38),
new THREE.LineBasicMaterial({
color: 0x7af2df,
transparent: true,
opacity: 0.28
})
);
bacteriaEdges.renderOrder = 5;
bacterium.add(bacteriaEdges);
// Darker central waist emphasizes the division cue.
const divisionRing = new THREE.Mesh(
new THREE.TorusGeometry(0.46, 0.026, 4, 20),
lowPolyMaterial(0x08736f, {
emissive: 0x0a4948,
emissiveIntensity: 0.25
})
);
divisionRing.rotation.y = Math.PI / 2;
divisionRing.scale.set(1, 1, 0.84);
bacterium.add(divisionRing);
const bacteriaDna = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.024, 5, 36),
dnaMaterial
);
bacteriaDna.position.set(-0.13, 0.03, 0.46);
bacteriaDna.scale.set(1.18, 0.66, 1);
bacterium.add(bacteriaDna);
for (let i = 0; i < 14; i++) {
const angle = (i / 14) * Math.PI * 2;
const bead = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.034, 0),
dnaMaterial
);
bead.position.set(
-0.13 + Math.cos(angle) * 0.425,
0.03 + Math.sin(angle) * 0.238,
0.46
);
bacterium.add(bead);
}
const bacteriaRibosomePositions = [
[-0.78, 0.26, 0.33],
[-0.46, -0.27, 0.37],
[0.24, 0.28, 0.35],
[0.61, -0.2, 0.35],
[0.86, 0.15, 0.17],
[-0.9, -0.08, 0.15]
];
bacteriaRibosomePositions.forEach((position) => {
const particle = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.048, 0),
lowPolyMaterial(0xffb4cf, {
emissive: 0x7d3155,
emissiveIntensity: 0.18
})
);
particle.position.set(...position);
bacterium.add(particle);
});
// Low-poly flagellum.
const flagellumCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(1.16, 0, 0),
new THREE.Vector3(1.48, 0.1, -0.02),
new THREE.Vector3(1.78, -0.08, 0.04),
new THREE.Vector3(2.05, 0.14, 0),
new THREE.Vector3(2.33, 0.02, -0.05),
new THREE.Vector3(2.57, 0.18, 0)
]);
const flagellum = new THREE.Mesh(
new THREE.TubeGeometry(flagellumCurve, 18, 0.018, 5, false),
lowPolyMaterial(0x75f0d9, {
emissive: 0x1b8e82,
emissiveIntensity: 0.25
})
);
bacterium.add(flagellum);
// Short pili around the bacterial surface.
const piliMaterial = lowPolyMaterial(0x4bc8ba, {
emissive: 0x13645d,
emissiveIntensity: 0.15
});
const piliAngles = [-2.35, -1.65, -0.75, 0.2, 1.0, 2.0];
piliAngles.forEach((angle, index) => {
const x = -0.65 + index * 0.27;
const start = new THREE.Vector3(
x,
Math.sin(angle) * 0.45,
Math.cos(angle) * 0.4
);
const end = start.clone().multiplyScalar(1.32);
end.y += 0.06;
bacterium.add(
cylinderBetween(start, end, 0.012, piliMaterial, 5)
);
});
anchors.bacterialDna = addAnchor(
bacterium, "bacterialDna", -0.13, 0.03, 0.52
);
anchors.bacterialDivision = addAnchor(
bacterium, "bacterialDivision", 0.02, 0.02, 0.52
);
anchors.bacterialLabel = addAnchor(
bacterium, "bacterialLabel", 0, -1.06, 0
);
// -------------------------------------------------------------------------
// Separate symbolic DNA marker
// -------------------------------------------------------------------------
const dnaMarker = new THREE.Group();
dnaMarker.position.set(0, 1.17, 0.35);
scene.add(dnaMarker);
const strandMaterials = [
lowPolyMaterial(0xc9ff67, {
emissive: 0x6fbd25,
emissiveIntensity: 0.28
}),
lowPolyMaterial(0xff8a5c, {
emissive: 0x9f3922,
emissiveIntensity: 0.22
})
];
const strandCurves = [[], []];
for (let i = 0; i <= 48; i++) {
const t = i / 48;
const angle = t * Math.PI * 6;
const y = (t - 0.5) * 1.42;
strandCurves[0].push(
new THREE.Vector3(
Math.cos(angle) * 0.22,
y,
Math.sin(angle) * 0.22
)
);
strandCurves[1].push(
new THREE.Vector3(
Math.cos(angle + Math.PI) * 0.22,
y,
Math.sin(angle + Math.PI) * 0.22
)
);
}
strandCurves.forEach((points, index) => {
const curve = new THREE.CatmullRomCurve3(points);
const strand = new THREE.Mesh(
new THREE.TubeGeometry(curve, 48, 0.032, 5, false),
strandMaterials[index]
);
dnaMarker.add(strand);
});
const rungMaterial = lowPolyMaterial(0xf1f6d2, {
emissive: 0x8c9a51,
emissiveIntensity: 0.1
});
for (let i = 2; i < 47; i += 4) {
dnaMarker.add(
cylinderBetween(
strandCurves[0][i],
strandCurves[1][i],
0.015,
rungMaterial,
5
)
);
}
const dnaHalo = new THREE.Mesh(
new THREE.TorusGeometry(0.52, 0.01, 4, 48),
new THREE.MeshBasicMaterial({
color: 0xc9ff67,
transparent: true,
opacity: 0.22
})
);
dnaHalo.rotation.x = Math.PI / 2;
dnaHalo.position.y = -0.05;
dnaMarker.add(dnaHalo);
anchors.dnaMarker = addAnchor(dnaMarker, "dnaMarker", 0, 0, 0);
// -------------------------------------------------------------------------
// Separate symbolic membrane marker: two layers versus one layer
// -------------------------------------------------------------------------
const membraneMarker = new THREE.Group();
membraneMarker.position.set(0, -0.9, 0.35);
scene.add(membraneMarker);
function membraneRing(color, x, y, radius) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.035, 5, 36),
lowPolyMaterial(color, {
emissive: color,
emissiveIntensity: 0.22
})
);
ring.rotation.x = Math.PI / 2;
ring.position.set(x, y, 0);
ring.scale.z = 0.7;
membraneMarker.add(ring);
return ring;
}
membraneRing(0xff8a5c, -0.43, 0.075, 0.4);
membraneRing(0xffc078, -0.43, -0.075, 0.4);
membraneRing(0x43e2cc, 0.43, 0, 0.4);
const membraneDivider = new THREE.Mesh(
new THREE.BoxGeometry(0.012, 0.88, 0.012),
new THREE.MeshBasicMaterial({
color: 0xa8bfce,
transparent: true,
opacity: 0.28
})
);
membraneDivider.position.set(0, 0, -0.04);
membraneMarker.add(membraneDivider);
anchors.membraneMarker = addAnchor(
membraneMarker, "membraneMarker", 0, 0, 0
);
// -------------------------------------------------------------------------
// Projected HTML labels and SVG leader lines
// -------------------------------------------------------------------------
const svg = document.getElementById("leaders");
const SVG_NS = "http://www.w3.org/2000/svg";
const callouts = [...document.querySelectorAll(".callout")];
const calloutVisuals = callouts.map((element) => {
const path = document.createElementNS(SVG_NS, "path");
const dot = document.createElementNS(SVG_NS, "circle");
const accent = getComputedStyle(element)
.getPropertyValue("--accent")
.trim();
path.setAttribute("stroke", accent);
path.setAttribute("opacity", "0.72");
dot.setAttribute("fill", "#07111f");
dot.setAttribute("stroke", accent);
dot.setAttribute("r", "3.5");
svg.append(path, dot);
return { element, path, dot, accent };
});
const markerVisuals = [
{
element: document.getElementById("dnaMarkerTag"),
anchor: anchors.dnaMarker,
offset: new THREE.Vector2(86, -22),
color: "#c9ff67"
},
{
element: document.getElementById("membraneMarkerTag"),
anchor: anchors.membraneMarker,
offset: new THREE.Vector2(94, 21),
color: "#ffd166"
}
].map((item) => {
const path = document.createElementNS(SVG_NS, "path");
const dot = document.createElementNS(SVG_NS, "circle");
path.setAttribute("stroke", item.color);
path.setAttribute("opacity", "0.62");
dot.setAttribute("fill", "#07111f");
dot.setAttribute("stroke", item.color);
dot.setAttribute("r", "3");
svg.append(path, dot);
return { ...item, path, dot };
});
function projectWorldPosition(worldPosition) {
const projected = worldPosition.clone().project(camera);
return {
x: (projected.x * 0.5 + 0.5) * window.innerWidth,
y: (-projected.y * 0.5 + 0.5) * window.innerHeight,
visible: projected.z > -1 && projected.z < 1
};
}
function anchorPosition(anchor) {
const position = new THREE.Vector3();
anchor.getWorldPosition(position);
return projectWorldPosition(position);
}
function updateCalloutLines() {
calloutVisuals.forEach((visual) => {
const anchorName = visual.element.dataset.anchor;
const end = anchorPosition(anchors[anchorName]);
const rect = visual.element.getBoundingClientRect();
const start = {
x: visual.element.classList.contains("left")
? rect.right
: rect.left,
y: rect.top + rect.height * 0.5
};
const direction = visual.element.classList.contains("left") ? 1 : -1;
const bend = start.x + direction * Math.max(22, Math.abs(end.x - start.x) * 0.28);
visual.path.setAttribute(
"d",
`M ${start.x.toFixed(1)} ${start.y.toFixed(1)}
L ${bend.toFixed(1)} ${start.y.toFixed(1)}
L ${end.x.toFixed(1)} ${end.y.toFixed(1)}`
);
visual.dot.setAttribute("cx", end.x);
visual.dot.setAttribute("cy", end.y);
visual.path.style.display = end.visible ? "" : "none";
visual.dot.style.display = end.visible ? "" : "none";
});
}
function updateMarkerLabels() {
markerVisuals.forEach((visual) => {
const end = anchorPosition(visual.anchor);
const compact = window.innerWidth < 620;
const offsetScale = compact ? 0.68 : 1;
const x = THREE.MathUtils.clamp(
end.x + visual.offset.x * offsetScale,
62,
window.innerWidth - 62
);
const y = THREE.MathUtils.clamp(
end.y + visual.offset.y * offsetScale,
95,
window.innerHeight - 75
);
visual.element.style.left = `${x}px`;
visual.element.style.top = `${y}px`;
const rect = visual.element.getBoundingClientRect();
const start = {
x: x < end.x ? rect.left : rect.right,
y: rect.top + rect.height * 0.5
};
visual.path.setAttribute(
"d",
`M ${end.x.toFixed(1)} ${end.y.toFixed(1)}
L ${start.x.toFixed(1)} ${start.y.toFixed(1)}`
);
visual.dot.setAttribute("cx", end.x);
visual.dot.setAttribute("cy", end.y);
});
}
function updateModelLabels() {
const labelData = [
[document.getElementById("mitoModelTag"), anchors.mitoLabel],
[document.getElementById("bactModelTag"), anchors.bacterialLabel]
];
labelData.forEach(([element, anchor]) => {
const point = anchorPosition(anchor);
element.style.left = `${point.x}px`;
element.style.top = `${point.y + 8}px`;
});
}
// -------------------------------------------------------------------------
// Resize and animation
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
if (width < 620) {
controls.radius = Math.max(controls.radius, 16.8);
controls.target.y = 0.08;
} else {
controls.radius = Math.min(controls.radius, 12.3);
controls.target.y = 0.05;
}
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
dnaMarker.rotation.y = 0.45 + Math.sin(elapsed * 0.32) * 0.18;
dnaMarker.rotation.z = Math.sin(elapsed * 0.23) * 0.035;
dnaHalo.rotation.z = elapsed * 0.12;
membraneMarker.rotation.y = -0.18 + Math.sin(elapsed * 0.25) * 0.06;
mitochondrion.rotation.y = -0.045 + Math.sin(elapsed * 0.25) * 0.025;
bacterium.rotation.y = 0.045 + Math.sin(elapsed * 0.25 + 1.4) * 0.025;
mitochondrion.position.y = 0.13 + Math.sin(elapsed * 0.5) * 0.035;
bacterium.position.y = 0.13 + Math.sin(elapsed * 0.5 + 1.1) * 0.035;
updateCamera();
scene.updateMatrixWorld(true);
updateCalloutLines();
updateMarkerLabels();
updateModelLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```