Prompt specification
Build or customize the Three.js 3D scene "Golgi cargo sorting stack" 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: Golgi cargo sorting stack
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/golgi-cargo-sorting-stack-x0873
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: golgi cargo sorting stack. Model curved flattened sacs with budding vesicles and three color-coded cargo types; keep transport direction readable and show that the organelle is a schematic enlargement. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (golgi-cargo-sorting-stack-x0873):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Golgi Cargo Sorting — Schematic Low-Poly Study</title>
<style>
:root {
--bg: #06111d;
--panel: rgba(9, 23, 36, 0.78);
--panel-strong: rgba(8, 20, 32, 0.92);
--line: rgba(173, 213, 231, 0.16);
--text: #edf7f7;
--muted: #91aab5;
--cyan: #48d9ff;
--violet: #b78cff;
--amber: #ffc857;
--coral: #ef8565;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 42%, rgba(35, 76, 93, 0.24), transparent 43%),
linear-gradient(145deg, #071522 0%, #050d17 60%, #07131e 100%);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
#scene canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(15px) saturate(125%);
-webkit-backdrop-filter: blur(15px) saturate(125%);
}
#title-panel {
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 17px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #a8c4ce;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.19em;
text-transform: uppercase;
}
.eyebrow-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 15px rgba(239, 133, 101, 0.85);
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 39px);
font-weight: 640;
line-height: 1.02;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 340px;
margin: 11px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.scale-badge {
display: inline-flex;
align-items: center;
gap: 9px;
margin-top: 14px;
padding: 7px 10px;
border: 1px solid rgba(255, 200, 87, 0.25);
border-radius: 999px;
color: #dbcfae;
background: rgba(255, 200, 87, 0.06);
font-size: 9px;
font-weight: 720;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.scale-badge b {
color: var(--amber);
font-size: 11px;
}
#legend {
top: 24px;
right: 24px;
width: 220px;
padding: 15px 16px 14px;
border-radius: 16px;
pointer-events: none;
}
.panel-kicker {
margin-bottom: 11px;
color: #7895a2;
font-size: 9px;
font-weight: 780;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.cargo-row {
display: grid;
grid-template-columns: 12px 1fr auto;
align-items: center;
gap: 10px;
padding: 7px 0;
border-top: 1px solid rgba(255, 255, 255, 0.055);
font-size: 11px;
}
.cargo-row:first-of-type {
border-top: 0;
}
.cargo-dot {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: 0 0 12px currentColor;
}
.cargo-dot.a {
color: var(--cyan);
background: var(--cyan);
}
.cargo-dot.b {
color: var(--violet);
background: var(--violet);
}
.cargo-dot.c {
color: var(--amber);
background: var(--amber);
}
.cargo-code {
color: #78909a;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.12em;
}
#process {
left: 24px;
bottom: 24px;
min-width: 325px;
padding: 13px 16px 14px;
border-radius: 16px;
pointer-events: none;
}
.direction-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 9px;
color: #d9e8eb;
font-size: 10px;
font-weight: 720;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.direction-arrow {
color: var(--amber);
font-size: 15px;
line-height: 1;
}
.process-caption {
margin-top: 9px;
color: #718b97;
font-size: 9px;
letter-spacing: 0.08em;
}
#controls {
right: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 7px;
padding: 7px;
border-radius: 15px;
}
.control-button {
min-height: 36px;
padding: 0 12px;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 10px;
color: #abc0c9;
background: rgba(255, 255, 255, 0.035);
cursor: pointer;
font-size: 9px;
font-weight: 760;
letter-spacing: 0.1em;
text-transform: uppercase;
transition:
color 160ms ease,
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.control-button:hover {
color: #f1fbfc;
border-color: rgba(255, 255, 255, 0.18);
background: rgba(255, 255, 255, 0.075);
transform: translateY(-1px);
}
.control-button.active {
color: #07131d;
border-color: var(--amber);
background: var(--amber);
}
#interaction-hint {
position: fixed;
left: 50%;
bottom: 25px;
z-index: 8;
transform: translateX(-50%);
color: rgba(188, 211, 220, 0.55);
font-size: 9px;
font-weight: 650;
letter-spacing: 0.11em;
text-transform: uppercase;
pointer-events: none;
white-space: nowrap;
}
.scene-label {
position: fixed;
z-index: 7;
padding: 6px 9px;
transform: translate(-50%, -50%);
border: 1px solid rgba(176, 216, 228, 0.22);
border-radius: 7px;
color: #d7e9ed;
background: rgba(5, 16, 27, 0.76);
box-shadow: 0 7px 20px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(8px);
font-size: 8px;
font-weight: 760;
letter-spacing: 0.13em;
line-height: 1;
text-transform: uppercase;
pointer-events: none;
white-space: nowrap;
opacity: 0;
}
.scene-label::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 13px;
background: linear-gradient(rgba(184, 220, 230, 0.45), transparent);
}
.scene-label.cargo-a {
color: var(--cyan);
border-color: rgba(72, 217, 255, 0.35);
}
.scene-label.cargo-b {
color: var(--violet);
border-color: rgba(183, 140, 255, 0.35);
}
.scene-label.cargo-c {
color: var(--amber);
border-color: rgba(255, 200, 87, 0.35);
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
color: #a9c3cc;
background: #06111d;
font-size: 10px;
font-weight: 760;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
#title-panel {
top: 14px;
left: 14px;
width: calc(100vw - 28px);
padding: 14px 16px;
}
h1 {
font-size: 27px;
}
.subtitle {
display: none;
}
.scale-badge {
margin-top: 10px;
}
#legend {
top: 142px;
right: 14px;
width: 164px;
padding: 11px 12px;
}
.cargo-row {
padding: 5px 0;
font-size: 10px;
}
#process {
left: 14px;
bottom: 65px;
min-width: 0;
padding: 10px 12px;
}
.process-caption {
display: none;
}
#controls {
right: 14px;
bottom: 14px;
}
.control-button {
padding: 0 9px;
font-size: 8px;
}
#interaction-hint {
display: none;
}
.scene-label {
font-size: 7px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="title-panel" class="panel">
<div class="eyebrow">
<span class="eyebrow-dot"></span>
Organelle study · schematic 01
</div>
<h1>Golgi cargo sorting</h1>
<p class="subtitle">
Curved cisternae receive, sort, and export color-coded cargo packets.
Membrane shapes and proportions are intentionally simplified.
</p>
<div class="scale-badge">
Schematic enlargement <b>×1000</b> · not to scale
</div>
</section>
<aside id="legend" class="panel">
<div class="panel-kicker">Cargo key</div>
<div class="cargo-row">
<span class="cargo-dot a"></span>
<span>Cargo A</span>
<span class="cargo-code">A</span>
</div>
<div class="cargo-row">
<span class="cargo-dot b"></span>
<span>Cargo B</span>
<span class="cargo-code">B</span>
</div>
<div class="cargo-row">
<span class="cargo-dot c"></span>
<span>Cargo C</span>
<span class="cargo-code">C</span>
</div>
</aside>
<section id="process" class="panel">
<div class="panel-kicker">Transport direction</div>
<div class="direction-row">
<span>Cis face</span>
<span class="direction-arrow">→</span>
<span>Sorting stack</span>
<span class="direction-arrow">→</span>
<span>Trans face</span>
</div>
<div class="process-caption">
Vesicle intake · cisternal sorting · destination-specific export
</div>
</section>
<nav id="controls" class="panel" aria-label="Scene controls">
<button id="orbit-button" class="control-button" type="button">Auto orbit</button>
<button id="pause-button" class="control-button" type="button">Pause flow</button>
<button id="reset-button" class="control-button" type="button">Reset view</button>
</nav>
<div id="interaction-hint">Drag to orbit · Scroll or pinch to zoom</div>
<div id="label-cis" class="scene-label">Cis face · intake</div>
<div id="label-trans" class="scene-label">Trans face · export</div>
<div id="label-sort" class="scene-label">Cargo sorting zone</div>
<div id="label-bud" class="scene-label">Budding vesicle</div>
<div id="label-a" class="scene-label cargo-a">Destination A</div>
<div id="label-b" class="scene-label cargo-b">Destination B</div>
<div id="label-c" class="scene-label cargo-c">Destination C</div>
<div id="loading">Building schematic…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const mount = document.getElementById("scene");
const loading = document.getElementById("loading");
let renderer;
try {
renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "WebGL could not be initialized";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x06111d, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive low-poly schematic of a Golgi cargo sorting stack"
);
mount.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x07131e, 0.027);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0.35, 1.72, 0);
const cameraView = {
theta: 0.56,
phi: 1.12,
radius: 13.25
};
function updateCamera() {
const sinPhi = Math.sin(cameraView.phi);
const cosPhi = Math.cos(cameraView.phi);
camera.position.set(
cameraTarget.x +
cameraView.radius * sinPhi * Math.sin(cameraView.theta),
cameraTarget.y + cameraView.radius * cosPhi,
cameraTarget.z +
cameraView.radius * sinPhi * Math.cos(cameraView.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
// Lighting
const hemisphere = new THREE.HemisphereLight(0xa7d9ff, 0x101622, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe1c4, 3.4);
keyLight.position.set(5.5, 10, 7.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -8;
keyLight.shadow.camera.right = 8;
keyLight.shadow.camera.top = 9;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0012;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5bcfff, 2.1);
rimLight.position.set(-7, 4.5, -6);
scene.add(rimLight);
const warmPoint = new THREE.PointLight(0xff9877, 13, 10, 2);
warmPoint.position.set(-3, 1.4, 3.8);
scene.add(warmPoint);
// Ground and schematic reference rings
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0x07131e,
roughness: 1,
metalness: 0
});
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(34, 34),
groundMaterial
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -1.22;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(26, 26, 0x284452, 0x132735);
grid.position.y = -1.205;
grid.material.transparent = true;
grid.material.opacity = 0.26;
scene.add(grid);
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0x315667,
transparent: true,
opacity: 0.19,
side: THREE.DoubleSide,
depthWrite: false
});
[3.9, 5.4, 6.8].forEach((radius) => {
const ring = new THREE.Mesh(
new THREE.RingGeometry(radius, radius + 0.012, 96),
ringMaterial
);
ring.rotation.x = -Math.PI / 2;
ring.position.set(0, -1.19, 0);
scene.add(ring);
});
const glowDisc = new THREE.Mesh(
new THREE.CircleGeometry(5.5, 64),
new THREE.MeshBasicMaterial({
color: 0x173c4a,
transparent: true,
opacity: 0.1,
depthWrite: false,
side: THREE.DoubleSide
})
);
glowDisc.rotation.x = -Math.PI / 2;
glowDisc.position.y = -1.18;
scene.add(glowDisc);
// Low-poly atmospheric points
const dustCount = 150;
const dustPositions = new Float32Array(dustCount * 3);
for (let i = 0; i < dustCount; i++) {
const radius = 7 + Math.random() * 11;
const angle = Math.random() * Math.PI * 2;
const height = -0.5 + Math.random() * 10;
dustPositions[i * 3] = Math.cos(angle) * radius;
dustPositions[i * 3 + 1] = height;
dustPositions[i * 3 + 2] = Math.sin(angle) * radius;
}
const dustGeometry = new THREE.BufferGeometry();
dustGeometry.setAttribute(
"position",
new THREE.BufferAttribute(dustPositions, 3)
);
const dust = new THREE.Points(
dustGeometry,
new THREE.PointsMaterial({
color: 0x93c9d9,
size: 0.025,
transparent: true,
opacity: 0.32,
depthWrite: false
})
);
scene.add(dust);
// Cargo palette
const cargoColors = [0x48d9ff, 0xb78cff, 0xffc857];
const cargoCss = ["#48d9ff", "#b78cff", "#ffc857"];
const cargoMaterials = cargoColors.map(
(color) =>
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.5,
roughness: 0.38,
metalness: 0.05,
flatShading: true
})
);
const membraneMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.7,
metalness: 0.015,
flatShading: true
});
const ridgeMaterial = new THREE.MeshStandardMaterial({
color: 0xffc09b,
emissive: 0x7a2e20,
emissiveIntensity: 0.12,
roughness: 0.78,
flatShading: true
});
const noduleGeometry = new THREE.IcosahedronGeometry(0.09, 0);
const noduleMaterial = new THREE.MeshStandardMaterial({
color: 0xffd5b6,
roughness: 0.76,
flatShading: true
});
/*
* A cisterna is represented as a faceted elliptical tube swept along
* a curved centerline. The vertical cross-section is deliberately
* flattened to resemble a membrane sac.
*/
function createCisterna(layerIndex) {
const segments = 18;
const radialSegments = 8;
const length = 7.25 - layerIndex * 0.46;
const halfLength = length * 0.5;
const xOffset = layerIndex * 0.1;
const baseY = layerIndex * 0.76;
const centerAt = (t) => {
const x =
xOffset +
(t - 0.5) * length +
0.2 * Math.sin(Math.PI * 2 * t);
const y = baseY + 0.08 * Math.sin(Math.PI * t);
const z = 0.58 * Math.sin(Math.PI * t) - 0.13;
return new THREE.Vector3(x, y, z);
};
const tangentAt = (t) => {
const epsilon = 0.001;
const a = centerAt(Math.max(0, t - epsilon));
const b = centerAt(Math.min(1, t + epsilon));
return b.sub(a).normalize();
};
const pointAt = (t, angle) => {
const center = centerAt(t);
const tangent = tangentAt(t);
const horizontalNormal = new THREE.Vector3(
-tangent.z,
0,
tangent.x
).normalize();
return center
.addScaledVector(horizontalNormal, Math.cos(angle) * 0.53)
.addScaledVector(new THREE.Vector3(0, 1, 0), Math.sin(angle) * 0.17);
};
const positions = [];
const colors = [];
const topColor = new THREE.Color(0xf5a37d);
const sideColor = new THREE.Color(0xdf7258);
const lowerColor = new THREE.Color(0xb94f43);
const pushColor = (color) => {
colors.push(color.r, color.g, color.b);
};
for (let segment = 0; segment < segments; segment++) {
const t0 = segment / segments;
const t1 = (segment + 1) / segments;
for (let radial = 0; radial < radialSegments; radial++) {
const angle0 = (radial / radialSegments) * Math.PI * 2;
const angle1 = ((radial + 1) / radialSegments) * Math.PI * 2;
const middleAngle = (angle0 + angle1) * 0.5;
const p00 = pointAt(t0, angle0);
const p10 = pointAt(t1, angle0);
const p11 = pointAt(t1, angle1);
const p01 = pointAt(t0, angle1);
const verticalFactor = Math.sin(middleAngle);
let faceColor;
if (verticalFactor > 0.25) {
faceColor = topColor.clone();
} else if (verticalFactor < -0.55) {
faceColor = lowerColor.clone();
} else {
faceColor = sideColor.clone();
}
const facetShift = 0.94 + ((segment + radial) % 3) * 0.035;
faceColor.multiplyScalar(facetShift);
positions.push(
p00.x, p00.y, p00.z,
p10.x, p10.y, p10.z,
p11.x, p11.y, p11.z
);
pushColor(faceColor);
pushColor(faceColor);
pushColor(faceColor);
positions.push(
p00.x, p00.y, p00.z,
p11.x, p11.y, p11.z,
p01.x, p01.y, p01.z
);
pushColor(faceColor);
pushColor(faceColor);
pushColor(faceColor);
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.computeVertexNormals();
const membrane = new THREE.Mesh(geometry, membraneMaterial);
membrane.castShadow = true;
membrane.receiveShadow = true;
scene.add(membrane);
// Pale ridge emphasizes the curvature and flattened upper membrane.
const ridgePoints = [];
for (let i = 0; i <= 28; i++) {
const t = i / 28;
const point = centerAt(t);
point.y += 0.165;
ridgePoints.push(point);
}
const ridgeCurve = new THREE.CatmullRomCurve3(ridgePoints);
const ridge = new THREE.Mesh(
new THREE.TubeGeometry(ridgeCurve, 44, 0.027, 4, false),
ridgeMaterial
);
scene.add(ridge);
// Small low-poly membrane nodules suggest coat proteins.
for (let i = 1; i < 8; i++) {
const t = i / 8;
const point = centerAt(t);
point.y += 0.19;
point.x += (i % 2 ? 1 : -1) * 0.055;
const nodule = new THREE.Mesh(noduleGeometry, noduleMaterial);
nodule.position.copy(point);
nodule.scale.setScalar(0.72 + (i % 3) * 0.12);
nodule.rotation.set(i * 0.3, i * 0.7, i * 0.2);
nodule.castShadow = true;
scene.add(nodule);
}
return { centerAt, length, baseY, xOffset };
}
const cisternae = [];
for (let i = 0; i < 6; i++) {
cisternae.push(createCisterna(i));
}
// Main cis-to-trans transport curve
const mainRoute = new THREE.CatmullRomCurve3([
new THREE.Vector3(-4.65, -0.65, 1.02),
new THREE.Vector3(-3.7, -0.15, 0.95),
new THREE.Vector3(-3.05, 0.62, 0.9),
new THREE.Vector3(-2.35, 1.48, 0.78),
new THREE.Vector3(-1.28, 2.28, 0.62),
new THREE.Vector3(-0.08, 3.02, 0.42),
new THREE.Vector3(1.1, 3.66, 0.17),
new THREE.Vector3(2.25, 4.05, -0.08)
]);
// Distinct export branches make cargo sorting legible.
const outputRoutes = [
new THREE.CatmullRomCurve3([
new THREE.Vector3(2.15, 4.02, -0.05),
new THREE.Vector3(3.25, 4.58, 0.28),
new THREE.Vector3(4.35, 4.82, 0.72),
new THREE.Vector3(5.45, 4.82, 1.05)
]),
new THREE.CatmullRomCurve3([
new THREE.Vector3(2.18, 4.0, -0.06),
new THREE.Vector3(3.38, 4.12, 0.02),
new THREE.Vector3(4.65, 3.9, 0.02),
new THREE.Vector3(5.75, 3.65, 0.02)
]),
new THREE.CatmullRomCurve3([
new THREE.Vector3(2.2, 3.98, -0.08),
new THREE.Vector3(3.4, 3.65, -0.4),
new THREE.Vector3(4.4, 3.1, -0.78),
new THREE.Vector3(5.25, 2.72, -1.05)
])
];
function addDashedRoute(curve, color, opacity = 0.72) {
const geometry = new THREE.BufferGeometry().setFromPoints(
curve.getPoints(110)
);
const material = new THREE.LineDashedMaterial({
color,
dashSize: 0.15,
gapSize: 0.105,
transparent: true,
opacity,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
line.computeLineDistances();
line.renderOrder = 1;
scene.add(line);
return line;
}
function addArrow(curve, t, color, scale = 1) {
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.115 * scale, 0.34 * scale, 5),
new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.3,
roughness: 0.52,
flatShading: true
})
);
arrow.position.copy(curve.getPointAt(t));
arrow.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
curve.getTangentAt(t).normalize()
);
arrow.castShadow = true;
scene.add(arrow);
}
addDashedRoute(mainRoute, 0xf8d58d, 0.82);
[0.12, 0.31, 0.5, 0.69, 0.87].forEach((t) => {
addArrow(mainRoute, t, 0xffd58a, 1);
});
outputRoutes.forEach((route, index) => {
addDashedRoute(route, cargoColors[index], 0.84);
addArrow(route, 0.57, cargoColors[index], 0.9);
});
// Vesicle shell and cargo packet
const shellGeometry = new THREE.IcosahedronGeometry(0.27, 1);
const shellEdgesGeometry = new THREE.EdgesGeometry(shellGeometry, 24);
const cargoGeometry = new THREE.IcosahedronGeometry(0.115, 0);
const shellMaterial = new THREE.MeshStandardMaterial({
color: 0xffd6c0,
emissive: 0x6b3327,
emissiveIntensity: 0.12,
transparent: true,
opacity: 0.37,
roughness: 0.28,
metalness: 0.02,
depthWrite: false,
flatShading: true
});
const shellEdgeMaterial = new THREE.LineBasicMaterial({
color: 0xffe1cc,
transparent: true,
opacity: 0.58,
depthWrite: false
});
function createCargoVesicle(cargoType, scale = 1) {
const group = new THREE.Group();
const shell = new THREE.Mesh(shellGeometry, shellMaterial);
shell.renderOrder = 2;
group.add(shell);
const edges = new THREE.LineSegments(
shellEdgesGeometry,
shellEdgeMaterial
);
edges.renderOrder = 3;
group.add(edges);
const cargo = new THREE.Mesh(
cargoGeometry,
cargoMaterials[cargoType]
);
cargo.renderOrder = 1;
group.add(cargo);
group.scale.setScalar(scale);
group.userData.cargo = cargo;
return group;
}
// Cargo moving through the central intake and sorting route.
const movingCargo = [];
const mixedTypes = [0, 1, 2, 1, 0, 2, 0, 1];
mixedTypes.forEach((type, index) => {
const vesicle = createCargoVesicle(type, 0.83 + (index % 3) * 0.05);
scene.add(vesicle);
movingCargo.push({
group: vesicle,
offset: index / mixedTypes.length,
speed: 0.027 + (index % 2) * 0.003
});
});
// Cargo packets moving along the three separated export paths.
const outputCargo = [];
outputRoutes.forEach((route, type) => {
for (let i = 0; i < 2; i++) {
const vesicle = createCargoVesicle(type, 0.92);
scene.add(vesicle);
outputCargo.push({
group: vesicle,
route,
offset: i * 0.48 + type * 0.09,
speed: 0.047 + type * 0.004
});
}
});
// Vesicles that grow from the cisternal surface before detaching.
const buds = [
{
start: new THREE.Vector3(-3.58, 0.08, 0.05),
end: new THREE.Vector3(-4.35, 0.32, 1.05),
type: 0,
phase: 0.05
},
{
start: new THREE.Vector3(3.35, 0.87, 0.03),
end: new THREE.Vector3(4.22, 1.0, 1.1),
type: 2,
phase: 0.34
},
{
start: new THREE.Vector3(-3.05, 1.61, 0.03),
end: new THREE.Vector3(-4.02, 1.78, 1.08),
type: 1,
phase: 0.62
},
{
start: new THREE.Vector3(2.83, 2.37, 0.03),
end: new THREE.Vector3(4.08, 2.55, 1.18),
type: 0,
phase: 0.83
}
];
buds.forEach((bud) => {
bud.group = createCargoVesicle(bud.type, 0.9);
scene.add(bud.group);
const site = new THREE.Mesh(
new THREE.TorusGeometry(0.2, 0.045, 5, 12),
ridgeMaterial
);
site.position.copy(bud.start);
site.rotation.x = Math.PI * 0.5;
scene.add(site);
});
// Tiny directional particles reinforce continuous movement.
const flowParticles = [];
const particleGeometry = new THREE.IcosahedronGeometry(0.035, 0);
const particleMaterial = new THREE.MeshBasicMaterial({
color: 0xffe1a2,
transparent: true,
opacity: 0.7
});
for (let i = 0; i < 18; i++) {
const particle = new THREE.Mesh(
particleGeometry,
particleMaterial
);
scene.add(particle);
flowParticles.push({
mesh: particle,
offset: i / 18,
speed: 0.055 + (i % 3) * 0.008
});
}
// Projected HTML labels
const labelSpecs = [
{
element: document.getElementById("label-cis"),
position: new THREE.Vector3(-3.75, -0.08, 0.95),
offset: [-8, 26]
},
{
element: document.getElementById("label-trans"),
position: new THREE.Vector3(2.45, 4.34, -0.03),
offset: [22, -13]
},
{
element: document.getElementById("label-sort"),
position: new THREE.Vector3(-0.55, 2.05, 1.03),
offset: [0, -31]
},
{
element: document.getElementById("label-bud"),
dynamic: true,
offset: [34, -5]
},
{
element: document.getElementById("label-a"),
position: outputRoutes[0].getPointAt(1),
offset: [31, -3]
},
{
element: document.getElementById("label-b"),
position: outputRoutes[1].getPointAt(1),
offset: [33, 0]
},
{
element: document.getElementById("label-c"),
position: outputRoutes[2].getPointAt(1),
offset: [29, 4]
}
];
const projected = new THREE.Vector3();
function updateLabels() {
labelSpecs.forEach((spec) => {
const position = spec.dynamic
? buds[1].group.position
: spec.position;
projected.copy(position).project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.12 &&
Math.abs(projected.y) < 1.12;
spec.element.style.opacity = visible ? "1" : "0";
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
spec.element.style.left = `${x + spec.offset[0]}px`;
spec.element.style.top = `${y + spec.offset[1]}px`;
});
}
// Direct camera controls: no addons are imported.
const pointers = new Map();
let pinchDistance = 0;
function currentPinchDistance() {
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
);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
renderer.domElement.setPointerCapture(event.pointerId);
if (pointers.size === 2) {
pinchDistance = currentPinchDistance();
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const current = { x: event.clientX, y: event.clientY };
pointers.set(event.pointerId, current);
if (pointers.size === 1) {
const dx = current.x - previous.x;
const dy = current.y - previous.y;
cameraView.theta -= dx * 0.006;
cameraView.phi -= dy * 0.005;
cameraView.phi = THREE.MathUtils.clamp(
cameraView.phi,
0.48,
1.47
);
} else if (pointers.size === 2) {
const nextDistance = currentPinchDistance();
const delta = nextDistance - pinchDistance;
cameraView.radius = THREE.MathUtils.clamp(
cameraView.radius * Math.exp(-delta * 0.006),
7.2,
20
);
pinchDistance = nextDistance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) pinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraView.radius = THREE.MathUtils.clamp(
cameraView.radius * Math.exp(event.deltaY * 0.001),
7.2,
20
);
},
{ passive: false }
);
let autoOrbit = false;
let flowPaused = false;
let flowTime = 0;
const orbitButton = document.getElementById("orbit-button");
const pauseButton = document.getElementById("pause-button");
const resetButton = document.getElementById("reset-button");
orbitButton.addEventListener("click", () => {
autoOrbit = !autoOrbit;
orbitButton.classList.toggle("active", autoOrbit);
orbitButton.textContent = autoOrbit ? "Orbiting" : "Auto orbit";
});
pauseButton.addEventListener("click", () => {
flowPaused = !flowPaused;
pauseButton.classList.toggle("active", flowPaused);
pauseButton.textContent = flowPaused ? "Resume flow" : "Pause flow";
});
resetButton.addEventListener("click", () => {
cameraView.theta = 0.56;
cameraView.phi = 1.12;
cameraView.radius = 13.25;
cameraTarget.set(0.35, 1.72, 0);
updateCamera();
});
function smoothstep(min, max, value) {
const x = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return x * x * (3 - 2 * x);
}
function updateFlow() {
movingCargo.forEach((item, index) => {
const t = (flowTime * item.speed + item.offset) % 1;
item.group.position.copy(mainRoute.getPointAt(t));
item.group.rotation.y = flowTime * 0.45 + index;
item.group.rotation.x = Math.sin(flowTime * 0.7 + index) * 0.13;
});
outputCargo.forEach((item) => {
const t = (flowTime * item.speed + item.offset) % 1;
item.group.position.copy(item.route.getPointAt(t));
item.group.rotation.y = flowTime * 0.55;
});
buds.forEach((bud) => {
const cycle = (flowTime * 0.075 + bud.phase) % 1;
const growth = smoothstep(0, 0.24, cycle);
const departure = smoothstep(0.2, 0.94, cycle);
bud.group.position.lerpVectors(bud.start, bud.end, departure);
bud.group.scale.setScalar(0.55 + growth * 0.45);
bud.group.rotation.y = flowTime * 0.6 + bud.phase * 6;
});
flowParticles.forEach((particle, index) => {
const t = (flowTime * particle.speed + particle.offset) % 1;
particle.mesh.position.copy(mainRoute.getPointAt(t));
particle.mesh.scale.setScalar(0.8 + Math.sin(flowTime * 4 + index) * 0.18);
});
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const delta = Math.min(clock.getDelta(), 0.05);
if (!flowPaused) {
flowTime += delta;
}
if (autoOrbit) {
cameraView.theta += delta * 0.075;
}
dust.rotation.y += delta * 0.012;
dust.position.y = Math.sin(flowTime * 0.18) * 0.08;
updateFlow();
updateCamera();
updateLabels();
renderer.render(scene, camera);
});
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 400);
</script>
</body>
</html>
```