Prompt specification
Build or customize the Three.js 3D scene "Barrier seam comparison model" 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: Barrier seam comparison model
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/barrier-seam-comparison-model-x0814
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring cell junctions. Arrange a sealed epithelial strip beside a strip with a visible gap; animate illustrative tracers respecting the barrier while distinguishing between-cell passage from through-cell transport. Stylized solid forms.
Working Three.js Starter (barrier-seam-comparison-model-x0814):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cell Junction Transport</title>
<style>
:root {
--ink: #17324d;
--muted: #5e7488;
--cyan: #20bfd4;
--gold: #f4b942;
--coral: #ff6b6b;
--paper: rgba(255, 255, 255, 0.88);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 38%, #ffffff 0, #edf3f8 54%, #dfe8f1 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.intro,
.legend,
.controls {
position: fixed;
z-index: 10;
pointer-events: none;
}
.intro {
top: 22px;
left: 24px;
max-width: 430px;
}
.eyebrow {
margin-bottom: 6px;
color: #24869a;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 42px);
line-height: 1.05;
letter-spacing: -0.035em;
}
.intro p {
max-width: 400px;
margin: 10px 0 0;
color: var(--muted);
font-size: 14px;
line-height: 1.5;
}
.legend {
left: 22px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 9px 16px;
max-width: min(760px, calc(100vw - 44px));
padding: 12px 15px;
border: 1px solid rgba(23, 50, 77, 0.1);
border-radius: 14px;
background: var(--paper);
box-shadow: 0 10px 32px rgba(23, 50, 77, 0.08);
backdrop-filter: blur(10px);
color: #3f566b;
font-size: 12px;
font-weight: 650;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
display: inline-block;
width: 11px;
height: 11px;
border-radius: 50%;
box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65);
}
.swatch.cyan {
background: var(--cyan);
}
.swatch.gold {
background: var(--gold);
}
.swatch.coral {
width: 7px;
height: 15px;
border-radius: 3px;
background: var(--coral);
}
.controls {
right: 20px;
bottom: 22px;
padding: 8px 11px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.68);
color: #6d8092;
font-size: 11px;
font-weight: 650;
letter-spacing: 0.01em;
}
#fallback {
position: fixed;
inset: 0;
z-index: 100;
display: none;
place-items: center;
padding: 30px;
background: #edf3f8;
color: var(--ink);
text-align: center;
}
#fallback.visible {
display: grid;
}
@media (max-width: 700px) {
.intro {
top: 15px;
left: 16px;
right: 16px;
}
.intro p {
max-width: 310px;
font-size: 12px;
}
.legend {
left: 12px;
right: 12px;
bottom: 12px;
gap: 8px 12px;
padding: 10px 12px;
font-size: 11px;
}
.controls {
display: none;
}
}
</style>
</head>
<body>
<div class="intro">
<div class="eyebrow">Epithelial barrier comparison</div>
<h1>Cell junction transport</h1>
<p>
A sealed strip blocks between-cell passage while selectively carrying a
through-cell tracer. Beside it, a visible junctional gap permits a
between-cell tracer to pass.
</p>
</div>
<div class="legend" aria-label="Scene legend">
<span class="legend-item">
<span class="swatch cyan"></span>
Between-cell tracer
</span>
<span class="legend-item">
<span class="swatch gold"></span>
Through-cell tracer
</span>
<span class="legend-item">
<span class="swatch coral"></span>
Tight-junction seal
</span>
</div>
<div class="controls">Drag to orbit · Shift-drag to pan · Wheel to zoom · R to reset</div>
<div id="fallback">
<div>
<h2>WebGL is unavailable</h2>
<p>This scene needs a browser with WebGL enabled.</p>
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.createElement("canvas");
document.body.prepend(canvas);
const fallback = document.getElementById("fallback");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
} catch (error) {
fallback.classList.add("visible");
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xedf3f8);
scene.fog = new THREE.Fog(0xedf3f8, 15, 31);
const camera = new THREE.PerspectiveCamera(
40,
window.innerWidth / window.innerHeight,
0.1,
100
);
// Custom orbit/pan/zoom state. No addons are used.
const controls = {
target: new THREE.Vector3(0, 0.35, 0),
theta: 0.23,
phi: 1.18,
radius: window.innerWidth / window.innerHeight < 1 ? 18 : 12.6,
dragging: false,
lastX: 0,
lastY: 0
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.target.set(0, 0.35, 0);
controls.theta = 0.23;
controls.phi = 1.18;
controls.radius =
window.innerWidth / window.innerHeight < 1 ? 18 : 12.6;
updateCamera();
}
updateCamera();
canvas.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
if (event.shiftKey) {
camera.updateMatrixWorld();
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(camera.quaternion);
const up = new THREE.Vector3(0, 1, 0).applyQuaternion(camera.quaternion);
const panScale = controls.radius * 0.0014;
controls.target.addScaledVector(right, -dx * panScale);
controls.target.addScaledVector(up, dy * panScale);
controls.target.x = THREE.MathUtils.clamp(
controls.target.x,
-4.5,
4.5
);
controls.target.y = THREE.MathUtils.clamp(
controls.target.y,
-1.2,
3.2
);
} else {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.65,
1.48
);
}
updateCamera();
});
function endPointer(event) {
controls.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.009,
7.5,
24
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
});
// Lighting
scene.add(new THREE.HemisphereLight(0xffffff, 0x9caec0, 2.15));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(-5, 9, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb9e7ff, 1.1);
fillLight.position.set(7, 3, 2);
scene.add(fillLight);
// Ground
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.MeshStandardMaterial({
color: 0xe1eaf2,
roughness: 0.95,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -3.05;
ground.receiveShadow = true;
scene.add(ground);
function roundedRectPath(ctx, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.quadraticCurveTo(
x + width,
y + height,
x + width - r,
y + height
);
ctx.lineTo(x + r, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function makeLabel(text, background, foreground, width = 3.25) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 768;
labelCanvas.height = 128;
const ctx = labelCanvas.getContext("2d");
roundedRectPath(ctx, 5, 5, 758, 118, 28);
ctx.fillStyle = background;
ctx.fill();
ctx.strokeStyle = "rgba(255,255,255,0.28)";
ctx.lineWidth = 3;
ctx.stroke();
let fontSize = 42;
ctx.font = `800 ${fontSize}px system-ui, sans-serif`;
while (ctx.measureText(text).width > 690 && fontSize > 24) {
fontSize -= 2;
ctx.font = `800 ${fontSize}px system-ui, sans-serif`;
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
ctx.fillText(text, 384, 65);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width / 6, 1);
sprite.renderOrder = 20;
return sprite;
}
const sealedLabel = makeLabel(
"SEALED TIGHT JUNCTIONS",
"#17324d",
"#ffffff",
3.35
);
sealedLabel.position.set(-2.72, 3.42, 0.15);
scene.add(sealedLabel);
const gapLabel = makeLabel(
"VISIBLE JUNCTIONAL GAP",
"#087d91",
"#ffffff",
3.35
);
gapLabel.position.set(2.75, 3.42, 0.15);
scene.add(gapLabel);
const apicalLabel = makeLabel(
"TRACER SIDE",
"#ffffff",
"#61788c",
1.8
);
apicalLabel.position.set(-5.2, 2.55, 0.2);
scene.add(apicalLabel);
const basalLabel = makeLabel(
"TISSUE SIDE",
"#ffffff",
"#61788c",
1.8
);
basalLabel.position.set(-5.2, -2.55, 0.2);
scene.add(basalLabel);
function createCellGeometry(width, height, depth) {
const w = width / 2;
const h = height / 2;
const r = 0.12;
const shape = new THREE.Shape();
shape.moveTo(-w + r, -h);
shape.lineTo(w - r, -h);
shape.quadraticCurveTo(w, -h, w, -h + r);
shape.lineTo(w, h - r);
shape.quadraticCurveTo(w, h, w - r, h);
shape.lineTo(-w + r, h);
shape.quadraticCurveTo(-w, h, -w, h - r);
shape.lineTo(-w, -h + r);
shape.quadraticCurveTo(-w, -h, -w + r, -h);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
steps: 1,
curveSegments: 10,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.045,
bevelThickness: 0.045
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
const cellGeometry = createCellGeometry(0.72, 2.34, 0.76);
const nucleusGeometry = new THREE.SphereGeometry(0.135, 20, 14);
const cellMaterials = [
new THREE.MeshStandardMaterial({
color: 0x91cfc7,
roughness: 0.62,
metalness: 0
}),
new THREE.MeshStandardMaterial({
color: 0xa8dcd4,
roughness: 0.64,
metalness: 0
}),
new THREE.MeshStandardMaterial({
color: 0x82c4c0,
roughness: 0.6,
metalness: 0
})
];
const nucleusMaterial = new THREE.MeshStandardMaterial({
color: 0x31516a,
roughness: 0.55,
metalness: 0
});
const nucleolusMaterial = new THREE.MeshStandardMaterial({
color: 0x183b54,
roughness: 0.5
});
function addCell(x, index) {
const cell = new THREE.Mesh(
cellGeometry,
cellMaterials[index % cellMaterials.length]
);
cell.position.set(x, 0, 0);
cell.castShadow = true;
cell.receiveShadow = true;
scene.add(cell);
const nucleus = new THREE.Mesh(nucleusGeometry, nucleusMaterial);
nucleus.position.set(
x + (index % 2 === 0 ? -0.06 : 0.06),
index % 2 === 0 ? 0.1 : -0.12,
0.445
);
nucleus.scale.set(1, 0.86, 0.42);
scene.add(nucleus);
const nucleolus = new THREE.Mesh(
new THREE.SphereGeometry(0.052, 14, 10),
nucleolusMaterial
);
nucleolus.position.set(
nucleus.position.x + 0.025,
nucleus.position.y + 0.025,
0.495
);
scene.add(nucleolus);
}
// Sealed strip: cells almost touch and coral tight-junction seals
// bridge the tiny seams.
const sealedCenters = [-3.96, -3.12, -2.28, -1.44];
sealedCenters.forEach((x, i) => addCell(x, i));
const sealMaterial = new THREE.MeshStandardMaterial({
color: 0xff6b6b,
roughness: 0.48,
metalness: 0,
emissive: 0x5c1010,
emissiveIntensity: 0.12
});
const sealGeometry = new THREE.CylinderGeometry(
0.055,
0.055,
0.28,
14
);
const sealedSeams = [-3.54, -2.70, -1.86];
for (const seamX of sealedSeams) {
for (const y of [-0.76, 0, 0.76]) {
const seal = new THREE.Mesh(sealGeometry, sealMaterial);
seal.position.set(seamX, y, 0.48);
seal.castShadow = true;
scene.add(seal);
}
}
// Gapped strip: cells are visibly separated.
const gappedCenters = [1.13, 2.21, 3.29, 4.37];
gappedCenters.forEach((x, i) => addCell(x, i + 1));
const gapX = (gappedCenters[0] + gappedCenters[1]) / 2;
const throughCellX = sealedCenters[2];
const blockedSeamX = sealedSeams[0];
// Colored dashed paths clarify the two transport modes.
function makeRoute(x, color, z) {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(x, -2.62, z),
new THREE.Vector3(x, 2.62, z)
]);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.14,
gapSize: 0.12,
transparent: true,
opacity: 0.5
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
scene.add(line);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.115, 0.28, 18),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.16,
roughness: 0.4
})
);
arrow.rotation.z = Math.PI;
arrow.position.set(x, -2.58, z + 0.02);
scene.add(arrow);
return line;
}
makeRoute(gapX, 0x20bfd4, 0.26);
makeRoute(throughCellX, 0xf4b942, 0.52);
// A coral X marks the blocked between-cell route.
const blockedMarker = new THREE.Group();
const markerBarGeometry = new THREE.BoxGeometry(0.065, 0.31, 0.055);
const barA = new THREE.Mesh(markerBarGeometry, sealMaterial);
const barB = new THREE.Mesh(markerBarGeometry, sealMaterial);
barA.rotation.z = Math.PI / 4;
barB.rotation.z = -Math.PI / 4;
blockedMarker.add(barA, barB);
blockedMarker.position.set(blockedSeamX, 1.42, 0.62);
scene.add(blockedMarker);
function createTracer(color, vesicle = false) {
const group = new THREE.Group();
const coreMaterial = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.22,
roughness: 0.34,
metalness: 0,
transparent: true
});
const core = new THREE.Mesh(
new THREE.SphereGeometry(0.12, 24, 16),
coreMaterial
);
group.add(core);
const materials = [coreMaterial];
if (vesicle) {
const ringMaterial = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.12,
roughness: 0.42,
transparent: true
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.175, 0.024, 10, 28),
ringMaterial
);
ring.position.z = 0.015;
group.add(ring);
materials.push(ringMaterial);
}
const trail = [];
for (let i = 0; i < 3; i++) {
const trailMaterial = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.28 - i * 0.065,
depthWrite: false
});
const bead = new THREE.Mesh(
new THREE.SphereGeometry(0.065 - i * 0.012, 14, 10),
trailMaterial
);
scene.add(bead);
trail.push(bead);
materials.push(trailMaterial);
}
scene.add(group);
return {
group,
trail,
materials,
baseOpacities: materials.map((material) => material.opacity)
};
}
const blockedTracer = createTracer(0x20bfd4);
const gapTracer = createTracer(0x20bfd4);
const throughTracer = createTracer(0xf4b942, true);
function setTracer(tracer, x, y, z, direction = 1, fade = 1) {
tracer.group.position.set(x, y, z);
tracer.trail.forEach((bead, i) => {
const offset = (i + 1) * 0.2 * direction;
bead.position.set(
x + Math.sin(i * 2.2 + y) * 0.012,
y + offset,
z - i * 0.008
);
});
tracer.materials.forEach((material, i) => {
material.opacity = tracer.baseOpacities[i] * fade;
});
}
const clock = new THREE.Clock();
function animate() {
const t = clock.getElapsedTime();
// Cyan tracer: travels through the visible gap in the right strip.
const gapPhase = (t / 5.4 + 0.18) % 1;
const gapFade = Math.min(
1,
gapPhase / 0.07,
(1 - gapPhase) / 0.07
);
setTracer(
gapTracer,
gapX + Math.sin(t * 2.3) * 0.015,
2.68 - gapPhase * 5.36,
0.42,
1,
gapFade
);
// Gold vesicle-like tracer: crosses the intact cell body, showing
// through-cell transport rather than passage between cells.
const throughPhase = (t / 6.2 + 0.53) % 1;
const throughFade = Math.min(
1,
throughPhase / 0.07,
(1 - throughPhase) / 0.07
);
setTracer(
throughTracer,
throughCellX + Math.sin(t * 2.1) * 0.025,
2.68 - throughPhase * 5.36,
0.61,
1,
throughFade
);
// Cyan tracer at the sealed strip: approaches a tight junction,
// is rejected, waits, and then returns for another attempt.
const blockedCycle = (t % 7) / 7;
let blockedY;
let blockedDirection = 1;
if (blockedCycle < 0.28) {
const p = blockedCycle / 0.28;
blockedY = 2.68 - p * 1.25;
} else if (blockedCycle < 0.72) {
blockedY = 1.43 + Math.sin((blockedCycle - 0.28) * 20) * 0.035;
} else {
const p = (blockedCycle - 0.72) / 0.28;
blockedY = 1.43 + p * 1.25;
blockedDirection = -1;
}
const blockedFade = Math.min(1, (1 - blockedCycle) / 0.08);
setTracer(
blockedTracer,
blockedSeamX + Math.sin(t * 5) * 0.015,
blockedY,
0.64,
blockedDirection,
blockedFade
);
const markerPulse = 1 + Math.sin(t * 5.5) * 0.075;
blockedMarker.scale.setScalar(markerPulse);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.fov = camera.aspect < 1 ? 54 : 40;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
</script>
</body>
</html>
```