Prompt specification
Build or customize the Three.js 3D scene "Two cells with distinct junction insets" 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 cells with distinct junction insets
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/two-cells-with-distinct-junction-insets-x0813
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring cell junctions. Model adjacent simplified cells with separate enlarged tight, anchoring, and gap-junction regions; label their different roles and avoid presenting their microscopic geometry at one scale. Low-poly.
Working Three.js Starter (two-cells-with-distinct-junction-insets-x0813):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cell Junctions — Interactive Low-Poly Atlas</title>
<style>
:root {
color-scheme: dark;
--bg: #06131c;
--panel: #0b1c27;
--panel-2: #102633;
--line: #244452;
--text: #edf8fa;
--muted: #9bb5bd;
--tight: #ffb454;
--anchor: #74d69a;
--gap: #52c7ff;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
height: 100dvh;
overflow: hidden;
}
button {
font: inherit;
}
.app-header {
height: 72px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
padding: 0 24px;
border-bottom: 1px solid rgba(129, 196, 210, 0.16);
background: rgba(6, 19, 28, 0.96);
}
.brand {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.brand-mark {
width: 38px;
height: 38px;
position: relative;
flex: 0 0 auto;
border: 1px solid #376170;
border-radius: 11px;
background:
radial-gradient(circle at 30% 32%, #57bad0 0 5px, transparent 6px),
radial-gradient(circle at 70% 65%, #8f72d2 0 5px, transparent 6px);
}
.brand-mark::after {
content: "";
position: absolute;
left: 17px;
top: 10px;
width: 5px;
height: 18px;
border-radius: 4px;
background: linear-gradient(var(--tight), var(--anchor), var(--gap));
box-shadow: 0 0 10px rgba(82, 199, 255, 0.25);
}
.brand strong {
display: block;
font-size: 13px;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.brand small {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 12px;
}
.header-tag {
flex: 0 0 auto;
padding: 8px 11px;
border: 1px solid #294b58;
border-radius: 999px;
color: #b8d1d8;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
background: #0a1b25;
}
.main {
height: calc(100dvh - 72px);
display: grid;
grid-template-columns: minmax(0, 1fr) 370px;
min-height: 0;
}
#viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
isolation: isolate;
background:
radial-gradient(circle at 45% 40%, rgba(24, 74, 88, 0.22), transparent 45%),
#06131c;
}
#viewport::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
pointer-events: none;
box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.35);
}
#viewport canvas {
position: absolute;
inset: 0;
z-index: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#viewport canvas:active {
cursor: grabbing;
}
.viewport-top {
position: absolute;
z-index: 5;
top: 18px;
left: 18px;
right: 18px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
pointer-events: none;
}
.viewport-title {
display: flex;
align-items: center;
gap: 8px;
color: #c8dde2;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
text-shadow: 0 1px 8px #000;
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #74d69a;
box-shadow: 0 0 12px rgba(116, 214, 154, 0.8);
}
.ghost-button {
pointer-events: auto;
padding: 8px 11px;
border: 1px solid rgba(128, 191, 204, 0.28);
border-radius: 8px;
color: #d7e9ed;
background: rgba(8, 26, 35, 0.72);
backdrop-filter: blur(8px);
cursor: pointer;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.ghost-button:hover,
.ghost-button:focus-visible {
border-color: #69c7dc;
outline: none;
}
#scene-labels {
position: absolute;
inset: 0;
z-index: 4;
pointer-events: none;
}
.scene-label {
position: absolute;
left: 0;
top: 0;
opacity: 0;
will-change: transform, opacity;
transition: opacity 160ms ease;
text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
}
.model-label {
width: 174px;
padding: 8px 10px;
border-left: 2px solid var(--accent);
border-radius: 2px 8px 8px 2px;
background: rgba(5, 18, 26, 0.84);
backdrop-filter: blur(9px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.model-label strong {
display: block;
color: #f1fbfc;
font-size: 10px;
letter-spacing: 0.11em;
line-height: 1.25;
text-transform: uppercase;
}
.model-label span {
display: block;
margin-top: 3px;
color: var(--accent);
font-size: 11px;
font-weight: 700;
}
.model-label small {
display: block;
margin-top: 4px;
color: #8faab2;
font-size: 8px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.overview-label {
padding: 8px 10px;
border: 1px solid rgba(133, 194, 207, 0.24);
border-radius: 8px;
background: rgba(5, 18, 26, 0.76);
backdrop-filter: blur(8px);
}
.overview-label strong,
.cell-chip strong {
display: block;
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.overview-label small,
.cell-chip small {
display: block;
margin-top: 3px;
color: #8faab2;
font-size: 8px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.cell-chip {
padding: 5px 8px;
border: 1px solid rgba(128, 190, 204, 0.2);
border-radius: 999px;
color: #cbe5ea;
background: rgba(5, 18, 26, 0.68);
text-align: center;
}
.pin-label {
width: 25px;
height: 25px;
display: grid;
place-items: center;
border: 2px solid var(--accent);
border-radius: 50%;
color: #07131b;
background: var(--accent);
box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent);
font-size: 11px;
font-weight: 900;
}
.viewport-bottom {
position: absolute;
z-index: 5;
left: 18px;
right: 18px;
bottom: 16px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 14px;
pointer-events: none;
}
.scale-note {
max-width: 560px;
padding: 9px 11px;
border: 1px solid rgba(126, 185, 198, 0.18);
border-radius: 8px;
color: #a9c2c9;
background: rgba(5, 18, 26, 0.76);
backdrop-filter: blur(8px);
font-size: 10px;
line-height: 1.45;
}
.scale-note strong {
color: #e1f1f3;
}
.gesture-note {
color: #79969f;
font-size: 9px;
letter-spacing: 0.07em;
text-transform: uppercase;
white-space: nowrap;
}
.sidebar {
min-height: 0;
overflow-y: auto;
padding: 25px 24px 30px;
border-left: 1px solid rgba(129, 196, 210, 0.16);
background:
linear-gradient(180deg, rgba(14, 36, 47, 0.84), rgba(8, 25, 34, 0.97)),
var(--panel);
scrollbar-width: thin;
scrollbar-color: #31525e transparent;
}
.eyebrow {
margin: 0 0 9px;
color: #6fbbce;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
max-width: 310px;
font-size: clamp(28px, 3vw, 38px);
line-height: 1.03;
letter-spacing: -0.045em;
}
.intro {
margin: 14px 0 22px;
color: #a8c0c7;
font-size: 13px;
line-height: 1.62;
}
.section-title {
display: flex;
align-items: center;
gap: 9px;
margin: 0 0 10px;
color: #829fa8;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.section-title::after {
content: "";
height: 1px;
flex: 1;
background: #294651;
}
.junction-list {
display: grid;
gap: 9px;
}
.junction-card {
width: 100%;
padding: 14px;
border: 1px solid #284652;
border-radius: 11px;
color: inherit;
background: rgba(7, 24, 33, 0.72);
text-align: left;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease,
box-shadow 160ms ease;
}
.junction-card:hover,
.junction-card:focus-visible {
transform: translateY(-1px);
border-color: #557b87;
outline: none;
}
.junction-card.active {
border-color: var(--accent);
background: #102630;
box-shadow:
inset 3px 0 0 var(--accent),
0 9px 24px rgba(0, 0, 0, 0.15);
}
.card-head {
display: flex;
align-items: center;
gap: 10px;
}
.card-number {
width: 28px;
height: 28px;
display: grid;
place-items: center;
flex: 0 0 auto;
border: 1px solid var(--accent);
border-radius: 8px;
color: var(--accent);
background: color-mix(in srgb, var(--accent) 9%, transparent);
font-size: 10px;
font-weight: 900;
}
.card-title {
flex: 1;
min-width: 0;
}
.card-title strong {
display: block;
font-size: 13px;
letter-spacing: 0.02em;
}
.card-title span {
display: block;
margin-top: 2px;
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.card-role {
margin: 10px 0 0;
color: #b4cbd0;
font-size: 11.5px;
line-height: 1.52;
}
.card-elements {
display: block;
margin-top: 9px;
padding-top: 8px;
border-top: 1px solid rgba(115, 164, 176, 0.14);
color: #718f98;
font-size: 9px;
line-height: 1.4;
}
.scale-key {
margin-top: 18px;
padding: 14px;
border: 1px solid #31515d;
border-radius: 11px;
background:
linear-gradient(135deg, rgba(82, 199, 255, 0.07), transparent 65%),
#0a202a;
}
.scale-key h2 {
margin: 0 0 7px;
color: #d9edf1;
font-size: 12px;
letter-spacing: 0.02em;
}
.scale-key p {
margin: 0;
color: #91abb3;
font-size: 10.5px;
line-height: 1.55;
}
.scale-key strong {
color: #b9d5dc;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 920px) {
body {
height: auto;
min-height: 100dvh;
overflow: auto;
}
.app-header {
position: sticky;
top: 0;
z-index: 20;
height: 64px;
padding: 0 16px;
}
.main {
height: auto;
display: block;
}
#viewport {
height: 70vh;
min-height: 540px;
}
.sidebar {
overflow: visible;
border-top: 1px solid rgba(129, 196, 210, 0.16);
border-left: 0;
padding: 24px 20px 34px;
}
h1 {
max-width: 600px;
}
}
@media (max-width: 560px) {
.brand small,
.header-tag,
.gesture-note {
display: none;
}
.brand strong {
font-size: 11px;
}
.viewport-top {
top: 12px;
left: 12px;
right: 12px;
}
.viewport-bottom {
left: 12px;
right: 12px;
bottom: 12px;
}
.scale-note {
max-width: 100%;
font-size: 9px;
}
.model-label {
width: 145px;
padding: 6px 8px;
}
.model-label strong {
font-size: 8px;
}
.model-label span {
font-size: 9px;
}
}
</style>
</head>
<body>
<header class="app-header">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<strong>Junction Atlas</strong>
<small>Interactive cell-contact schematic</small>
</div>
</div>
<div class="header-tag">Low-poly · conceptual · not to scale</div>
</header>
<main class="main">
<section id="viewport" aria-label="Interactive three-dimensional cell junction diagram">
<div class="viewport-top">
<div class="viewport-title">
<span class="live-dot" aria-hidden="true"></span>
Cell neighborhood / interactive view
</div>
<button id="reset-camera" class="ghost-button" type="button">
Reset view
</button>
</div>
<div id="scene-labels" aria-hidden="true">
<div id="label-overview" class="scene-label overview-label">
<strong>Cell overview</strong>
<small>Relative placement only</small>
</div>
<div id="label-cell-a" class="scene-label cell-chip">
<strong>Cell A</strong>
<small>Schematic body</small>
</div>
<div id="label-cell-b" class="scene-label cell-chip">
<strong>Cell B</strong>
<small>Schematic body</small>
</div>
<div id="label-tight" class="scene-label model-label" style="--accent:#ffb454">
<strong>Tight junction</strong>
<span>Barrier seal</span>
<small>Enlarged · independent view</small>
</div>
<div id="label-anchor" class="scene-label model-label" style="--accent:#74d69a">
<strong>Anchoring junction</strong>
<span>Mechanical link</span>
<small>Enlarged · independent view</small>
</div>
<div id="label-gap" class="scene-label model-label" style="--accent:#52c7ff">
<strong>Gap junction</strong>
<span>Direct channel</span>
<small>Enlarged · independent view</small>
</div>
<div id="pin-tight" class="scene-label pin-label" style="--accent:#ffb454">A</div>
<div id="pin-anchor" class="scene-label pin-label" style="--accent:#74d69a">B</div>
<div id="pin-gap" class="scene-label pin-label" style="--accent:#52c7ff">C</div>
</div>
<div class="viewport-bottom">
<div class="scale-note">
<strong>Scale is intentionally separated.</strong>
The cell overview shows neighborhood placement only. A–C are
independent schematic enlargements; dimensions, spacing, protein
counts, and panel sizes are not quantitative.
</div>
<div class="gesture-note">Drag to orbit · scroll to zoom · R to reset</div>
</div>
</section>
<aside class="sidebar" aria-label="Cell junction roles">
<p class="eyebrow">Cell–cell contacts</p>
<h1>Cells can seal, hold, and talk.</h1>
<p class="intro">
Three specialized junction types organize neighboring cells.
Select a card or a colored marker to inspect its conceptual role.
</p>
<div class="section-title">Junction types</div>
<div class="junction-list">
<button
class="junction-card active"
type="button"
data-junction="tight"
style="--accent:#ffb454"
aria-pressed="true"
>
<div class="card-head">
<span class="card-number">A</span>
<span class="card-title">
<strong>Tight junction</strong>
<span>Barrier / selective seal</span>
</span>
</div>
<p class="card-role">
Seals the route between neighboring cells, maintaining barrier
integrity and strongly restricting paracellular movement.
</p>
<span class="card-elements">
Representative components: claudins and occludins
</span>
</button>
<button
class="junction-card"
type="button"
data-junction="anchor"
style="--accent:#74d69a"
aria-pressed="false"
>
<div class="card-head">
<span class="card-number">B</span>
<span class="card-title">
<strong>Anchoring junction</strong>
<span>Shape / force coupling</span>
</span>
</div>
<p class="card-role">
Couples the cytoskeletons of adjacent cells so tension and
deformation can be shared, helping tissues resist stress.
</p>
<span class="card-elements">
Representative components: cadherins linked to actin
</span>
</button>
<button
class="junction-card"
type="button"
data-junction="gap"
style="--accent:#52c7ff"
aria-pressed="false"
>
<div class="card-head">
<span class="card-number">C</span>
<span class="card-title">
<strong>Gap junction</strong>
<span>Cell-to-cell communication</span>
</span>
</div>
<p class="card-role">
Forms direct intercellular channels for ions and small molecules,
enabling electrical and metabolic coupling.
</p>
<span class="card-elements">
Representative components: paired connexons
</span>
</button>
</div>
<section class="scale-key">
<h2>How to read the model</h2>
<p>
<strong>Overview:</strong> simplified cell bodies establish where
contacts occur. <strong>Enlargements:</strong> each junction is
explained in a separate visual language and at its own schematic
magnification. Molecular shapes are illustrative, not literal.
</p>
</section>
<div id="selection-status" class="sr-only" aria-live="polite"></div>
</aside>
</main>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.querySelector("#viewport");
const sceneLabels = document.querySelector("#scene-labels");
const junctionMeta = {
tight: {
color: 0xffb454,
css: "#ffb454",
name: "Tight junction",
role: "Barrier seal"
},
anchor: {
color: 0x74d69a,
css: "#74d69a",
name: "Anchoring junction",
role: "Mechanical link"
},
gap: {
color: 0x52c7ff,
css: "#52c7ff",
name: "Gap junction",
role: "Direct channel"
}
};
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("role", "img");
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly diagram of two adjacent cells and three enlarged cell junctions"
);
viewport.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x06131c);
scene.fog = new THREE.Fog(0x06131c, 19, 34);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const cameraState = {
theta: 0.025,
phi: 1.49,
radius: 12.6,
target: new THREE.Vector3(-0.2, 0, 0)
};
let viewportWidth = 1;
let viewportHeight = 1;
let userAdjustedZoom = false;
let activeJunction = "tight";
const hemi = new THREE.HemisphereLight(0xb7ecff, 0x071018, 2.25);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(-4, 8, 11);
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x4fc3ff, 26, 22, 2);
rimLight.position.set(5, -3, 8);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffbd73, 13, 17, 2);
warmLight.position.set(-5, 4, 5);
scene.add(warmLight);
const materialCache = {
cellA: new THREE.MeshStandardMaterial({
color: 0x28798a,
roughness: 0.43,
metalness: 0.03,
transparent: true,
opacity: 0.57,
depthWrite: false,
side: THREE.DoubleSide,
flatShading: true
}),
cellB: new THREE.MeshStandardMaterial({
color: 0x426c9b,
roughness: 0.43,
metalness: 0.03,
transparent: true,
opacity: 0.57,
depthWrite: false,
side: THREE.DoubleSide,
flatShading: true
}),
cellEdge: new THREE.LineBasicMaterial({
color: 0x9edce6,
transparent: true,
opacity: 0.42
}),
nucleusA: new THREE.MeshStandardMaterial({
color: 0x9c75cf,
roughness: 0.58,
metalness: 0.02,
flatShading: true
}),
nucleusB: new THREE.MeshStandardMaterial({
color: 0x786ac1,
roughness: 0.58,
metalness: 0.02,
flatShading: true
}),
organelle: new THREE.MeshStandardMaterial({
color: 0xbbe9df,
roughness: 0.7,
flatShading: true
}),
membrane: new THREE.MeshStandardMaterial({
color: 0x2d7083,
roughness: 0.55,
metalness: 0.04,
flatShading: true
}),
tight: new THREE.MeshStandardMaterial({
color: 0xffb454,
emissive: 0x6c2f00,
emissiveIntensity: 0.42,
roughness: 0.48,
flatShading: true
}),
anchor: new THREE.MeshStandardMaterial({
color: 0x74d69a,
emissive: 0x174d2d,
emissiveIntensity: 0.38,
roughness: 0.5,
flatShading: true
}),
gap: new THREE.MeshStandardMaterial({
color: 0x52c7ff,
emissive: 0x104e72,
emissiveIntensity: 0.48,
roughness: 0.38,
flatShading: true
}),
actin: new THREE.MeshStandardMaterial({
color: 0xe4c56b,
emissive: 0x45320a,
emissiveIntensity: 0.16,
roughness: 0.65,
flatShading: true
}),
ion: new THREE.MeshStandardMaterial({
color: 0xffe47b,
emissive: 0x8f5a00,
emissiveIntensity: 0.75,
roughness: 0.35,
flatShading: true
})
};
function cylinderBetween(parent, a, b, radius, material, segments = 8) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius,
radius,
length,
segments,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
parent.add(mesh);
return mesh;
}
function makeExtrudedCell(points, material, edgeMaterial) {
const shape = new THREE.Shape();
shape.moveTo(...points[0]);
for (let i = 1; i < points.length; i++) {
shape.lineTo(...points[i]);
}
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.64,
steps: 1,
bevelEnabled: true,
bevelSegments: 1,
bevelSize: 0.055,
bevelThickness: 0.055,
curveSegments: 1
});
geometry.translate(0, 0, -0.32);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.renderOrder = 1;
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 25),
edgeMaterial
);
edges.renderOrder = 2;
const group = new THREE.Group();
group.add(mesh, edges);
return group;
}
const overview = new THREE.Group();
scene.add(overview);
const leftCellPoints = [
[-4.70, -1.75],
[-4.27, 1.78],
[-2.83, 2.43],
[-1.75, 1.90],
[-1.75, -1.60],
[-2.54, -2.25]
];
const rightCellPoints = [
[-1.75, 1.90],
[-1.22, 2.48],
[0.20, 2.03],
[0.95, 0.87],
[0.84, -1.50],
[-0.10, -2.27],
[-1.75, -1.60]
];
overview.add(
makeExtrudedCell(leftCellPoints, materialCache.cellA, materialCache.cellEdge)
);
overview.add(
makeExtrudedCell(rightCellPoints, materialCache.cellB, materialCache.cellEdge)
);
function addNucleus(parent, position, material, scale = 1) {
const nucleus = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.48, 1),
material
);
nucleus.position.set(...position);
nucleus.scale.set(scale, scale * 1.08, 0.42);
nucleus.rotation.set(0.25, -0.35, 0.12);
nucleus.castShadow = true;
parent.add(nucleus);
const halo = new THREE.LineSegments(
new THREE.EdgesGeometry(nucleus.geometry),
new THREE.LineBasicMaterial({
color: 0xe2c9ff,
transparent: true,
opacity: 0.26
})
);
nucleus.add(halo);
}
addNucleus(
overview,
[-3.28, 0.43, 0.48],
materialCache.nucleusA,
1.05
);
addNucleus(
overview,
[-0.39, -0.17, 0.48],
materialCache.nucleusB,
0.88
);
const organellePositions = [
[-3.85, 1.15, 0.45],
[-2.75, 1.25, 0.42],
[-3.12, -1.22, 0.44],
[-2.55, -1.28, 0.42],
[0.36, 1.25, 0.45],
[-0.15, 1.04, 0.42],
[0.48, -1.25, 0.44],
[-0.88, -1.34, 0.42]
];
for (const position of organellePositions) {
const organelle = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.085, 0),
materialCache.organelle
);
organelle.position.set(...position);
organelle.scale.set(1.7, 0.8, 0.8);
organelle.rotation.z = Math.random() * Math.PI;
overview.add(organelle);
}
const seamGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(-1.75, -1.60, 0.42),
new THREE.Vector3(-1.75, 1.90, 0.42)
]);
const seam = new THREE.Line(
seamGeometry,
new THREE.LineBasicMaterial({
color: 0xd3f2f5,
transparent: true,
opacity: 0.54
})
);
overview.add(seam);
// Local schematic details at the shared cell boundary.
const tightY = 1.18;
const anchorY = 0.05;
const gapY = -1.17;
const boundaryZ = 0.56;
for (const y of [tightY - 0.12, tightY + 0.12]) {
cylinderBetween(
overview,
[-1.99, y, boundaryZ],
[-1.51, y, boundaryZ],
0.065,
materialCache.tight,
6
);
const seal = new THREE.Mesh(
new THREE.OctahedronGeometry(0.115, 0),
materialCache.tight
);
seal.position.set(-1.75, y, boundaryZ + 0.03);
seal.scale.x = 1.15;
overview.add(seal);
}
for (const offset of [-0.18, 0, 0.18]) {
cylinderBetween(
overview,
[-1.97, anchorY + offset, boundaryZ],
[-1.53, anchorY + offset, boundaryZ],
0.055,
materialCache.anchor,
6
);
}
for (const offset of [-0.10, 0.10]) {
cylinderBetween(
overview,
[-1.94, anchorY + offset, boundaryZ + 0.02],
[-2.48, anchorY + offset * 1.5, boundaryZ + 0.05],
0.025,
materialCache.actin,
6
);
cylinderBetween(
overview,
[-1.56, anchorY + offset, boundaryZ + 0.02],
[-1.00, anchorY + offset * 1.5, boundaryZ + 0.05],
0.025,
materialCache.actin,
6
);
}
cylinderBetween(
overview,
[-1.97, gapY, boundaryZ],
[-1.75, gapY, boundaryZ],
0.11,
materialCache.gap,
8
);
cylinderBetween(
overview,
[-1.75, gapY, boundaryZ],
[-1.53, gapY, boundaryZ],
0.11,
materialCache.gap,
8
);
for (const x of [-1.86, -1.69, -1.56]) {
const ion = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.055, 0),
materialCache.ion
);
ion.position.set(x, gapY, boundaryZ + 0.08);
overview.add(ion);
}
const markerRecords = [];
const hitTargets = [];
const panelRecords = {};
function addMarker(key, position) {
const group = new THREE.Group();
group.position.set(...position);
const color = junctionMeta[key].color;
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.27, 0.035, 6, 20),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.8,
depthTest: false
})
);
ring.renderOrder = 8;
const core = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 0),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.72,
roughness: 0.4,
flatShading: true
})
);
core.renderOrder = 9;
const hit = new THREE.Mesh(
new THREE.SphereGeometry(0.38, 10, 8),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
colorWrite: false
})
);
hit.userData.junction = key;
group.add(ring, core, hit);
scene.add(group);
const record = {
key,
group,
ring,
core,
hit,
targetScale: 1
};
markerRecords.push(record);
hitTargets.push(hit);
return record;
}
addMarker("tight", [-1.75, tightY, 0.69]);
addMarker("anchor", [-1.75, anchorY, 0.69]);
addMarker("gap", [-1.75, gapY, 0.69]);
function createFrame(key, y) {
const group = new THREE.Group();
group.position.set(2.66, y, 0);
const backingMaterial = new THREE.MeshStandardMaterial({
color: 0x0a202a,
roughness: 0.9,
metalness: 0.02,
emissive: junctionMeta[key].color,
emissiveIntensity: 0.025
});
const backing = new THREE.Mesh(
new THREE.BoxGeometry(3.12, 1.68, 0.11),
backingMaterial
);
backing.position.z = -0.36;
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x345763,
transparent: true,
opacity: 0.48
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(backing.geometry),
edgeMaterial
);
edges.position.copy(backing.position);
const accent = new THREE.Mesh(
new THREE.BoxGeometry(0.055, 1.52, 0.055),
new THREE.MeshBasicMaterial({
color: junctionMeta[key].color,
transparent: true,
opacity: 0.8
})
);
accent.position.set(-1.48, 0, -0.285);
const hit = new THREE.Mesh(
new THREE.BoxGeometry(3.08, 1.62, 0.72),
new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false,
colorWrite: false
})
);
hit.position.z = 0;
hit.userData.junction = key;
group.add(backing, edges, accent, hit);
scene.add(group);
const record = {
key,
group,
backingMaterial,
edgeMaterial,
hit
};
panelRecords[key] = record;
hitTargets.push(hit);
return record;
}
function addMembranePair(parent, x = 0.62) {
const left = new THREE.Mesh(
new THREE.BoxGeometry(0.14, 1.08, 0.52),
materialCache.membrane
);
left.position.set(-x, 0, 0.05);
const right = left.clone();
right.position.x = x;
parent.add(left, right);
}
const tightPanel = createFrame("tight", 2.65);
addMembranePair(tightPanel.group);
for (const y of [-0.36, -0.12, 0.12, 0.36]) {
for (const z of [-0.13, 0.15]) {
cylinderBetween(
tightPanel.group,
[-0.62, y, z],
[-0.13, y, z],
0.065,
materialCache.tight,
6
);
cylinderBetween(
tightPanel.group,
[0.13, y, z],
[0.62, y, z],
0.065,
materialCache.tight,
6
);
const seal = new THREE.Mesh(
new THREE.OctahedronGeometry(0.13, 0),
materialCache.tight
);
seal.position.set(0, y, z);
seal.scale.x = 1.12;
tightPanel.group.add(seal);
}
}
const anchorPanel = createFrame("anchor", 0);
addMembranePair(anchorPanel.group);
for (const y of [-0.23, 0.20]) {
cylinderBetween(
anchorPanel.group,
[-0.62, y, 0.06],
[-0.10, y, 0.06],
0.075,
materialCache.anchor,
6
);
cylinderBetween(
anchorPanel.group,
[0.10, y, 0.06],
[0.62, y, 0.06],
0.075,
materialCache.anchor,
6
);
const linker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.14, 0),
materialCache.anchor
);
linker.position.set(0, y, 0.06);
anchorPanel.group.add(linker);
}
for (const offset of [-0.28, -0.04, 0.20]) {
cylinderBetween(
anchorPanel.group,
[-0.60, offset, 0.05],
[-1.38, offset * 0.72, 0.10],
0.027,
materialCache.actin,
6
);
cylinderBetween(
anchorPanel.group,
[0.60, offset, 0.05],
[1.38, offset * 0.72, 0.10],
0.027,
materialCache.actin,
6
);
}
const gapPanel = createFrame("gap", -2.65);
addMembranePair(gapPanel.group);
cylinderBetween(
gapPanel.group,
[-0.62, 0, 0.06],
[0, 0, 0.06],
0.15,
materialCache.gap,
8
);
cylinderBetween(
gapPanel.group,
[0, 0, 0.06],
[0.62, 0, 0.06],
0.15,
materialCache.gap,
8
);
for (const x of [-0.18, 0.18]) {
const channelRing = new THREE.Mesh(
new THREE.TorusGeometry(0.20, 0.055, 6, 12),
materialCache.gap
);
channelRing.position.set(x, 0, 0.18);
gapPanel.group.add(channelRing);
}
for (const x of [-0.42, -0.10, 0.20, 0.43]) {
const ion = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.07, 0),
materialCache.ion
);
ion.position.set(x, Math.sin(x * 5) * 0.05, 0.19);
gapPanel.group.add(ion);
}
function addLeader(start, end, color) {
const curve = new THREE.CatmullRomCurve3([
start.clone(),
new THREE.Vector3(0.25, start.y, -0.20),
new THREE.Vector3(0.80, end.y, -0.25),
end.clone()
]);
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(64)
);
const line = new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
color,
transparent: true,
opacity: 0.28,
dashSize: 0.09,
gapSize: 0.10,
depthWrite: false
})
);
line.computeLineDistances();
scene.add(line);
}
addLeader(
new THREE.Vector3(-1.75, tightY, 0.67),
new THREE.Vector3(1.09, 2.65, -0.2),
junctionMeta.tight.color
);
addLeader(
new THREE.Vector3(-1.75, anchorY, 0.67),
new THREE.Vector3(1.09, 0, -0.2),
junctionMeta.anchor.color
);
addLeader(
new THREE.Vector3(-1.75, gapY, 0.67),
new THREE.Vector3(1.09, -2.65, -0.2),
junctionMeta.gap.color
);
const cards = [...document.querySelectorAll(".junction-card")];
const status = document.querySelector("#selection-status");
function setActiveJunction(key, announce = true) {
activeJunction = key;
const meta = junctionMeta[key];
for (const card of cards) {
const selected = card.dataset.junction === key;
card.classList.toggle("active", selected);
card.setAttribute("aria-pressed", String(selected));
}
for (const marker of markerRecords) {
const selected = marker.key === key;
marker.targetScale = selected ? 1.20 : 1;
marker.ring.material.opacity = selected ? 1 : 0.62;
marker.core.material.emissiveIntensity = selected ? 1.05 : 0.58;
}
for (const panel of Object.values(panelRecords)) {
const selected = panel.key === key;
panel.backingMaterial.emissiveIntensity = selected ? 0.11 : 0.025;
panel.edgeMaterial.color.setHex(
selected ? junctionMeta[panel.key].color : 0x345763
);
panel.edgeMaterial.opacity = selected ? 0.9 : 0.48;
}
if (announce) {
status.textContent = `${meta.name} selected. Role: ${meta.role}.`;
}
}
for (const card of cards) {
card.addEventListener("click", () => {
setActiveJunction(card.dataset.junction);
});
}
setActiveJunction("tight", false);
// HTML labels are positioned from projected Three.js world coordinates.
const labelEntries = [];
function registerLabel(id, getPosition, mode = "center") {
const element = document.getElementById(id);
labelEntries.push({ element, getPosition, mode });
}
registerLabel(
"label-overview",
() => new THREE.Vector3(-3.18, 2.72, 0.72),
"top-left"
);
registerLabel(
"label-cell-a",
() => new THREE.Vector3(-3.27, -1.80, 0.70)
);
registerLabel(
"label-cell-b",
() => new THREE.Vector3(-0.31, -1.83, 0.70)
);
registerLabel(
"label-tight",
() => tightPanel.group.localToWorld(new THREE.Vector3(-1.43, 0.94, 0.12)),
"top-left"
);
registerLabel(
"label-anchor",
() => anchorPanel.group.localToWorld(new THREE.Vector3(-1.43, 0.94, 0.12)),
"top-left"
);
registerLabel(
"label-gap",
() => gapPanel.group.localToWorld(new THREE.Vector3(-1.43, 0.94, 0.12)),
"top-left"
);
for (const marker of markerRecords) {
registerLabel(
`pin-${marker.key}`,
() => marker.group.getWorldPosition(new THREE.Vector3())
);
}
const projected = new THREE.Vector3();
function updateLabels() {
for (const entry of labelEntries) {
projected.copy(entry.getPosition()).project(camera);
const x = (projected.x * 0.5 + 0.5) * viewportWidth;
const y = (-projected.y * 0.5 + 0.5) * viewportHeight;
const visible =
projected.z > -1 &&
projected.z < 1 &&
x > -80 &&
x < viewportWidth + 80 &&
y > -80 &&
y < viewportHeight + 80;
entry.element.style.opacity = visible ? "1" : "0";
if (entry.mode === "top-left") {
entry.element.style.transform =
`translate3d(${x}px, ${y}px, 0) translate(-7%, -112%)`;
} else {
entry.element.style.transform =
`translate3d(${x}px, ${y}px, 0) translate(-50%, -50%)`;
}
}
}
function fitRadius() {
const halfFov = THREE.MathUtils.degToRad(camera.fov * 0.5);
const horizontalSpan = 9.3;
const verticalSpan = 7.4;
const radiusForWidth =
horizontalSpan / (2 * Math.tan(halfFov) * camera.aspect);
const radiusForHeight =
verticalSpan / (2 * Math.tan(halfFov));
return Math.max(
11.5,
Math.min(22, Math.max(radiusForWidth, radiusForHeight) * 1.06)
);
}
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
const cosPhi = Math.cos(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * cosPhi,
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
}
function resize() {
const rect = viewport.getBoundingClientRect();
viewportWidth = Math.max(1, rect.width);
viewportHeight = Math.max(1, rect.height);
renderer.setSize(viewportWidth, viewportHeight, false);
camera.aspect = viewportWidth / viewportHeight;
camera.updateProjectionMatrix();
if (!userAdjustedZoom) {
cameraState.radius = fitRadius();
}
updateCamera();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(viewport);
function resetCamera() {
cameraState.theta = 0.025;
cameraState.phi = 1.49;
userAdjustedZoom = false;
cameraState.radius = fitRadius();
updateCamera();
}
document.querySelector("#reset-camera").addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
// Direct camera controls: orbit, zoom, and click-to-select.
let dragging = false;
let moved = false;
let pointerX = 0;
let pointerY = 0;
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0) return;
dragging = true;
moved = false;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (Math.abs(dx) + Math.abs(dy) > 2) {
moved = true;
}
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + dy * 0.005,
0.78,
2.22
);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (!dragging) return;
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (!moved) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(hitTargets, false);
if (intersections.length > 0) {
const key = intersections[0].object.userData.junction;
if (key) setActiveJunction(key);
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
9.5,
24
);
userAdjustedZoom = true;
updateCamera();
},
{ passive: false }
);
function animate(time) {
requestAnimationFrame(animate);
for (let i = 0; i < markerRecords.length; i++) {
const marker = markerRecords[i];
const targetScale = marker.targetScale;
marker.group.scale.x +=
(targetScale - marker.group.scale.x) * 0.12;
marker.group.scale.y =
marker.group.scale.x;
marker.group.scale.z =
marker.group.scale.x;
const pulse = 1 + Math.sin(time * 0.0028 + i * 1.7) * 0.055;
marker.ring.scale.setScalar(pulse);
}
scene.updateMatrixWorld(true);
updateCamera();
updateLabels();
renderer.render(scene, camera);
}
resize();
requestAnimationFrame(animate);
</script>
</body>
</html>
```