Prompt specification
Build or customize the Three.js 3D scene "Cell membrane cup around a particle" 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: Cell membrane cup around a particle
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/cell-membrane-cup-around-a-particle-x0865
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a low-poly cell beginning to engulf a particle. A rounded membrane rises into an open cup around one pale debris sphere. Cut away a narrow section of the cell so the membrane thickness and continuous inner space are visible. Keep a gap at the cup's rim: the particle has not yet been enclosed. Use a muted translucent blue for the membrane, a warmer interior, and a contrasting particle. Place the cup toward the camera, with the rest of the cell curving behind it. A small side view should make surface attachment and partial enclosure distinguishable.
Working Three.js Starter (cell-membrane-cup-around-a-particle-x0865):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Partial Engulfment — Low-Poly Cell</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 43%, #173440 0%, #0c2029 42%, #071219 100%);
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.vignette {
position: absolute;
inset: 0;
z-index: 2;
pointer-events: none;
background:
radial-gradient(circle at 48% 45%, transparent 38%, rgba(2, 9, 13, 0.18) 72%,
rgba(2, 8, 12, 0.58) 100%);
}
.title-block {
position: absolute;
top: 28px;
left: 32px;
z-index: 3;
max-width: 390px;
pointer-events: none;
color: #dcebed;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}
.eyebrow {
margin-bottom: 8px;
color: #8eb8c0;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3.4vw, 46px);
font-weight: 520;
letter-spacing: -0.035em;
line-height: 1.02;
}
.subtitle {
margin: 12px 0 0;
color: #9eb8bd;
font-size: 12px;
line-height: 1.55;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 17px;
margin-top: 17px;
color: #b6c9cc;
font-size: 10px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 7px;
height: 7px;
border-radius: 50%;
box-shadow: 0 0 10px currentColor;
}
.swatch.blue {
color: #76aaba;
background: currentColor;
}
.swatch.warm {
color: #d18b63;
background: currentColor;
}
.swatch.pale {
color: #f2ddbd;
background: currentColor;
}
.instructions {
position: absolute;
left: 32px;
bottom: 25px;
z-index: 3;
color: rgba(190, 216, 220, 0.62);
font-size: 10px;
letter-spacing: 0.11em;
text-transform: uppercase;
pointer-events: none;
}
#insetFrame {
position: absolute;
right: 22px;
bottom: 22px;
z-index: 4;
width: clamp(190px, 20vw, 250px);
height: clamp(140px, 14.5vw, 178px);
border: 1px solid rgba(168, 211, 216, 0.45);
border-radius: 3px;
box-shadow:
0 14px 45px rgba(0, 0, 0, 0.36),
inset 0 0 0 1px rgba(255, 255, 255, 0.035);
pointer-events: none;
}
#insetFrame::before {
content: "Side profile";
position: absolute;
top: -25px;
left: 0;
color: #a9c8cc;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#insetFrame::after {
content: "surface attachment · open rim";
position: absolute;
right: 0;
bottom: -21px;
color: rgba(170, 202, 205, 0.58);
font-size: 8px;
letter-spacing: 0.11em;
text-transform: uppercase;
}
@media (max-width: 680px) {
.title-block {
top: 20px;
left: 20px;
max-width: calc(100vw - 40px);
}
.subtitle {
max-width: 290px;
}
.legend {
display: none;
}
.instructions {
left: 20px;
bottom: 17px;
}
#insetFrame {
right: 14px;
bottom: 37px;
width: 166px;
height: 121px;
}
#insetFrame::after {
display: none;
}
}
</style>
</head>
<body>
<main id="app">
<canvas id="scene" aria-label="Interactive low-poly cell partially engulfing a debris particle"></canvas>
<div class="vignette"></div>
<header class="title-block">
<div class="eyebrow">Cellular uptake · stage 01</div>
<h1>Partial engulfment</h1>
<p class="subtitle">
A membrane cup rises around the debris while a narrow cutaway reveals its
thickness and warm, continuous inner space.
</p>
<div class="legend" aria-hidden="true">
<span><i class="swatch blue"></i>Membrane</span>
<span><i class="swatch warm"></i>Interior</span>
<span><i class="swatch pale"></i>Debris</span>
</div>
</header>
<div class="instructions">Drag to orbit · scroll to zoom</div>
<div id="insetFrame" aria-hidden="true"></div>
</main>
<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.querySelector("#scene");
const insetFrame = document.querySelector("#insetFrame");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x0a1b23, 0.035);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 0.35, 0.05);
let azimuth = 0.50;
let polar = 1.15;
let distance = 8.8;
function updateMainCamera() {
const horizontal = Math.sin(polar) * distance;
camera.position.set(
target.x + Math.sin(azimuth) * horizontal,
target.y + Math.cos(polar) * distance,
target.z + Math.cos(azimuth) * horizontal
);
camera.lookAt(target);
}
updateMainCamera();
// A separate orthographic camera is rendered into the small side-profile inset.
const sideCamera = new THREE.OrthographicCamera(-3.4, 3.4, 2.35, -2.35, 0.1, 50);
sideCamera.position.set(8, 2.8, 0.15);
sideCamera.lookAt(0, 0.42, -0.35);
const hemisphere = new THREE.HemisphereLight(0xb8dce5, 0x241811, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffefd9, 3.1);
keyLight.position.set(4.5, 7, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -5;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x5d9fba, 2.25);
rimLight.position.set(-4, 3.2, -4.5);
scene.add(rimLight);
const interiorLight = new THREE.PointLight(0xffa168, 7.5, 4.2, 2);
interiorLight.position.set(0, 0.9, 0.25);
scene.add(interiorLight);
const membraneMaterial = new THREE.MeshStandardMaterial({
color: 0x6699aa,
roughness: 0.64,
metalness: 0,
transparent: true,
opacity: 0.48,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const bodyMaterial = new THREE.MeshStandardMaterial({
color: 0x5e91a2,
roughness: 0.7,
metalness: 0,
transparent: true,
opacity: 0.38,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const innerMaterial = new THREE.MeshStandardMaterial({
color: 0xc47d57,
roughness: 0.86,
metalness: 0,
transparent: true,
opacity: 0.68,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const edgeMaterial = new THREE.MeshStandardMaterial({
color: 0x9bc1c1,
roughness: 0.78,
metalness: 0,
transparent: true,
opacity: 0.74,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const lineMaterial = new THREE.LineBasicMaterial({
color: 0xb3d6d3,
transparent: true,
opacity: 0.55,
depthWrite: false
});
// The larger cell body sits behind the forward-projecting cup.
const bodyGeometry = new THREE.IcosahedronGeometry(1, 1);
const bodyPositions = bodyGeometry.attributes.position;
for (let i = 0; i < bodyPositions.count; i++) {
const x = bodyPositions.getX(i);
const y = bodyPositions.getY(i);
const z = bodyPositions.getZ(i);
const variation =
1 +
0.045 * Math.sin(x * 4.1 + z * 2.3) +
0.025 * Math.cos(y * 5.0 - x * 1.7);
bodyPositions.setXYZ(i, x * variation, y * variation, z * variation);
}
bodyGeometry.computeVertexNormals();
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.set(0, -0.78, -1.18);
body.scale.set(2.5, 1.43, 2.05);
body.renderOrder = 1;
scene.add(body);
// A very soft warm core behind the translucent shell suggests a continuous lumen.
const warmCoreMaterial = new THREE.MeshStandardMaterial({
color: 0xb86e4d,
roughness: 0.95,
transparent: true,
opacity: 0.14,
side: THREE.BackSide,
depthWrite: false,
flatShading: true
});
const warmCore = new THREE.Mesh(bodyGeometry, warmCoreMaterial);
warmCore.position.copy(body.position);
warmCore.scale.copy(body.scale).multiplyScalar(0.94);
warmCore.renderOrder = 0;
scene.add(warmCore);
const cupGroup = new THREE.Group();
scene.add(cupGroup);
const CUP_Z = 0.36;
const ANGULAR_SEGMENTS = 48;
const VERTICAL_SEGMENTS = 11;
const ANGLE_STEP = (Math.PI * 2) / ANGULAR_SEGMENTS;
// The cutaway faces the main camera. The notch is offset so that the cutaway
// and the still-open rim can be read as two separate features.
const CUT_START = 0.29;
const CUT_END = 0.73;
const NOTCH_CENTER = 1.72;
const NOTCH_WIDTH = 0.255;
const MEMBRANE_THICKNESS = 0.13;
function angleDifference(a, b) {
return Math.atan2(Math.sin(a - b), Math.cos(a - b));
}
function rimHeight(theta) {
const d = angleDifference(theta, NOTCH_CENTER);
const notch = Math.exp(-Math.pow(Math.abs(d) / NOTCH_WIDTH, 1.65));
const gentleVariation = 0.035 * Math.sin(theta * 3.0 + 0.4);
return 2.07 - 1.49 * notch + gentleVariation;
}
function radiusAtHeight(y) {
const t = THREE.MathUtils.clamp(y / 1.58, 0, 1);
return 0.69 + 0.49 * Math.sin(t * Math.PI * 0.5);
}
function cupPoint(theta, v, inner = false) {
const height = rimHeight(theta);
const y = v * height;
const outerRadius = radiusAtHeight(y);
const radius = inner
? Math.max(0.48, outerRadius - MEMBRANE_THICKNESS)
: outerRadius;
return new THREE.Vector3(
radius * Math.cos(theta),
y,
CUP_Z + radius * Math.sin(theta)
);
}
function buildCupSurface(inner) {
const positions = [];
const indices = [];
for (let row = 0; row <= VERTICAL_SEGMENTS; row++) {
const v = row / VERTICAL_SEGMENTS;
for (let col = 0; col <= ANGULAR_SEGMENTS; col++) {
const theta = col * ANGLE_STEP;
const p = cupPoint(theta, v, inner);
positions.push(p.x, p.y, p.z);
}
}
const rowWidth = ANGULAR_SEGMENTS + 1;
for (let row = 0; row < VERTICAL_SEGMENTS; row++) {
for (let col = 0; col < ANGULAR_SEGMENTS; col++) {
const midpoint = (col + 0.5) * ANGLE_STEP;
// Remove a narrow wedge, exposing the wall thickness and inner surface.
if (midpoint > CUT_START && midpoint < CUT_END) {
continue;
}
const a = row * rowWidth + col;
const b = a + 1;
const c = (row + 1) * rowWidth + col;
const d = c + 1;
if (inner) {
indices.push(a, b, c, b, d, c);
} else {
indices.push(a, c, b, b, c, d);
}
}
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const outerCup = new THREE.Mesh(buildCupSurface(false), membraneMaterial);
outerCup.renderOrder = 3;
cupGroup.add(outerCup);
const innerCup = new THREE.Mesh(buildCupSurface(true), innerMaterial);
innerCup.renderOrder = 2;
cupGroup.add(innerCup);
// Build visible top thickness and the two walls exposed by the cutaway.
const edgePositions = [];
function addQuad(a, b, c, d) {
edgePositions.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z,
a.x, a.y, a.z,
c.x, c.y, c.z,
d.x, d.y, d.z
);
}
for (let col = 0; col < ANGULAR_SEGMENTS; col++) {
const midpoint = (col + 0.5) * ANGLE_STEP;
if (midpoint > CUT_START && midpoint < CUT_END) continue;
const thetaA = col * ANGLE_STEP;
const thetaB = (col + 1) * ANGLE_STEP;
addQuad(
cupPoint(thetaA, 1, false),
cupPoint(thetaB, 1, false),
cupPoint(thetaB, 1, true),
cupPoint(thetaA, 1, true)
);
}
const cutStartColumn = Math.ceil(CUT_START / ANGLE_STEP);
const cutEndColumn = Math.ceil(CUT_END / ANGLE_STEP);
for (const col of [cutStartColumn, cutEndColumn]) {
const theta = col * ANGLE_STEP;
for (let row = 0; row < VERTICAL_SEGMENTS; row++) {
const v0 = row / VERTICAL_SEGMENTS;
const v1 = (row + 1) / VERTICAL_SEGMENTS;
addQuad(
cupPoint(theta, v0, false),
cupPoint(theta, v1, false),
cupPoint(theta, v1, true),
cupPoint(theta, v0, true)
);
}
}
const edgeGeometry = new THREE.BufferGeometry();
edgeGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(edgePositions, 3)
);
edgeGeometry.computeVertexNormals();
const cutEdges = new THREE.Mesh(edgeGeometry, edgeMaterial);
cutEdges.renderOrder = 4;
cupGroup.add(cutEdges);
// Fine polygon edges clarify the low-poly construction without adding visual clutter.
const rimLinePositions = [];
for (let col = 0; col < ANGULAR_SEGMENTS; col++) {
const midpoint = (col + 0.5) * ANGLE_STEP;
if (midpoint > CUT_START && midpoint < CUT_END) continue;
const a = cupPoint(col * ANGLE_STEP, 1, false);
const b = cupPoint((col + 1) * ANGLE_STEP, 1, false);
rimLinePositions.push(a.x, a.y, a.z, b.x, b.y, b.z);
}
for (const col of [cutStartColumn, cutEndColumn]) {
const theta = col * ANGLE_STEP;
const a = cupPoint(theta, 0, false);
const b = cupPoint(theta, 1, false);
rimLinePositions.push(a.x, a.y, a.z, b.x, b.y, b.z);
}
const rimLineGeometry = new THREE.BufferGeometry();
rimLineGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(rimLinePositions, 3)
);
const rimLines = new THREE.LineSegments(rimLineGeometry, lineMaterial);
rimLines.renderOrder = 5;
cupGroup.add(rimLines);
// A single pale, faceted debris particle. Subtle warm facets add contrast.
const particleGroup = new THREE.Group();
particleGroup.position.set(0.02, 1.10, 0.39);
scene.add(particleGroup);
let particleGeometry = new THREE.IcosahedronGeometry(0.59, 2);
if (particleGeometry.index) {
particleGeometry = particleGeometry.toNonIndexed();
}
const particleColors = new Float32Array(
particleGeometry.attributes.position.count * 3
);
const cream = new THREE.Color(0xf1d9b6);
const palePeach = new THREE.Color(0xe9c6a3);
const softCoral = new THREE.Color(0xc98270);
const color = new THREE.Color();
for (let i = 0; i < particleColors.length; i += 9) {
const r = Math.sin(i * 12.9898 + 78.233) * 43758.5453;
const random = r - Math.floor(r);
if (random > 0.88) {
color.copy(softCoral).lerp(palePeach, random * 0.38);
} else {
color.copy(cream).lerp(palePeach, random * 0.32);
}
for (let vertex = 0; vertex < 3; vertex++) {
const offset = i + vertex * 3;
particleColors[offset] = color.r;
particleColors[offset + 1] = color.g;
particleColors[offset + 2] = color.b;
}
}
particleGeometry.setAttribute(
"color",
new THREE.BufferAttribute(particleColors, 3)
);
particleGeometry.computeVertexNormals();
const particleMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.91,
metalness: 0,
flatShading: true
});
const particle = new THREE.Mesh(particleGeometry, particleMaterial);
particle.castShadow = true;
particleGroup.add(particle);
// Subtle grounding shadow beneath the floating cell.
const shadowMaterial = new THREE.MeshBasicMaterial({
color: 0x02090d,
transparent: true,
opacity: 0.2,
depthWrite: false
});
const shadow = new THREE.Mesh(new THREE.CircleGeometry(1, 48), shadowMaterial);
shadow.rotation.x = -Math.PI / 2;
shadow.position.set(0, -2.24, -0.75);
shadow.scale.set(2.6, 1.65, 1);
scene.add(shadow);
// Direct camera controls: drag to orbit and wheel/pinch to zoom.
let dragging = false;
let pointerX = 0;
let pointerY = 0;
const activePointers = new Map();
let pinchDistance = 0;
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 1) {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
} else if (activePointers.size === 2) {
const points = [...activePointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 2) {
const points = [...activePointers.values()];
const nextDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
distance = THREE.MathUtils.clamp(
distance * (pinchDistance / Math.max(nextDistance, 1)),
5.8,
12
);
updateMainCamera();
}
pinchDistance = nextDistance;
return;
}
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
azimuth -= dx * 0.006;
polar = THREE.MathUtils.clamp(polar + dy * 0.005, 0.64, 1.43);
updateMainCamera();
});
function endPointer(event) {
activePointers.delete(event.pointerId);
if (activePointers.size < 2) pinchDistance = 0;
if (activePointers.size === 0) dragging = false;
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
distance = THREE.MathUtils.clamp(
distance + event.deltaY * 0.006,
5.8,
12
);
updateMainCamera();
},
{ passive: false }
);
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function renderInset() {
const rect = insetFrame.getBoundingClientRect();
const x = Math.round(rect.left);
const y = Math.round(window.innerHeight - rect.bottom);
const width = Math.round(rect.width);
const height = Math.round(rect.height);
const aspect = width / height;
const verticalSpan = 4.7;
sideCamera.left = (-verticalSpan * aspect) / 2;
sideCamera.right = (verticalSpan * aspect) / 2;
sideCamera.top = verticalSpan / 2;
sideCamera.bottom = -verticalSpan / 2;
sideCamera.updateProjectionMatrix();
renderer.setScissorTest(true);
renderer.setViewport(x, y, width, height);
renderer.setScissor(x, y, width, height);
renderer.setClearColor(0x0a1921, 1);
renderer.clear(true, true, true);
renderer.render(scene, sideCamera);
renderer.setScissorTest(false);
}
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
const breathing = 1 + Math.sin(time * 0.72) * 0.012;
body.scale.set(2.5 * breathing, 1.43 * breathing, 2.05 * breathing);
warmCore.scale.copy(body.scale).multiplyScalar(0.94);
cupGroup.scale.y = 1 + Math.sin(time * 0.9) * 0.014;
cupGroup.rotation.y = Math.sin(time * 0.18) * 0.006;
particleGroup.position.y = 1.10 + Math.sin(time * 1.35) * 0.035;
particleGroup.position.x = 0.02 + Math.sin(time * 0.81) * 0.018;
particle.rotation.x = time * 0.075;
particle.rotation.y = time * 0.11;
interiorLight.intensity = 7.2 + Math.sin(time * 1.2) * 0.65;
renderer.setViewport(0, 0, window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.clear(true, true, true);
renderer.render(scene, camera);
renderInset();
}
animate();
</script>
</body>
</html>
```