Prompt specification
Build or customize the Three.js 3D scene "Roller and sieve separation 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: Roller and sieve separation model
Category: Biology & Nature · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/roller-and-sieve-separation-model-x1082
Scene Description Prompt:
Use Three.js from cdnjs to move kernels through schematic rollers and a vibrating screen; separated particle groups enter distinct bins, with the process explicitly presented as a simplified milling illustration. Deliver one self-contained HTML file with low-poly forms.
Working Three.js Starter (roller-and-sieve-separation-model-x1082):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Simplified Milling Illustration</title>
<style>
:root {
--ink: #203238;
--muted: #62757a;
--paper: rgba(250, 249, 244, 0.92);
--line: rgba(32, 50, 56, 0.14);
--coarse: #cf6540;
--medium: #dca43a;
--fine: #5e9e90;
--kernel: #efd49a;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dfe7e7;
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%;
cursor: grab;
touch-action: none;
}
canvas:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.7);
box-shadow: 0 14px 40px rgba(35, 54, 58, 0.13);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
.intro {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 20px 21px 17px;
border-radius: 17px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: #547078;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 22px;
height: 3px;
border-radius: 4px;
background: var(--coarse);
}
h1 {
margin: 0;
font-size: clamp(22px, 2.2vw, 31px);
line-height: 1.05;
letter-spacing: -0.045em;
}
.subtitle {
margin: 7px 0 12px;
color: #365058;
font-size: 13px;
font-weight: 750;
}
.description {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.stages {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 14px;
}
.stage {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border: 1px solid var(--line);
border-radius: 8px;
background: rgba(255, 255, 255, 0.55);
color: #536a70;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
}
.stage b {
color: var(--coarse);
font-size: 9px;
}
.legend {
bottom: 22px;
left: 22px;
padding: 14px 16px;
border-radius: 14px;
}
.legend-title {
margin-bottom: 10px;
color: #6b7d81;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 7px;
color: #40565c;
font-size: 11px;
font-weight: 650;
}
.swatch {
width: 10px;
height: 10px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.controls {
right: 22px;
bottom: 22px;
display: flex;
align-items: center;
gap: 7px;
padding: 9px;
border-radius: 13px;
}
button {
appearance: none;
border: 1px solid var(--line);
border-radius: 9px;
padding: 9px 12px;
background: rgba(255, 255, 255, 0.76);
color: var(--ink);
font: inherit;
font-size: 11px;
font-weight: 750;
cursor: pointer;
transition: transform 120ms ease, background 120ms ease;
}
button:hover {
transform: translateY(-1px);
background: white;
}
button:active { transform: translateY(0); }
.status {
display: flex;
align-items: center;
gap: 6px;
padding: 0 7px 0 3px;
color: #567077;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #59a47e;
box-shadow: 0 0 0 4px rgba(89, 164, 126, 0.12);
}
.status-dot.paused {
background: var(--medium);
box-shadow: 0 0 0 4px rgba(220, 164, 58, 0.13);
}
.hint {
position: fixed;
z-index: 8;
right: 24px;
top: 24px;
padding: 8px 11px;
border-radius: 999px;
background: rgba(250, 249, 244, 0.75);
border: 1px solid rgba(255, 255, 255, 0.75);
color: #65787d;
font-size: 10px;
font-weight: 700;
pointer-events: none;
}
.label {
--c: #536f76;
position: fixed;
z-index: 7;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.84);
border-radius: 9px;
background: rgba(250, 249, 244, 0.88);
box-shadow: 0 6px 18px rgba(35, 54, 58, 0.10);
color: #344b51;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.025em;
white-space: nowrap;
pointer-events: none;
will-change: transform;
}
.label::before {
content: "";
width: 7px;
height: 7px;
flex: 0 0 auto;
border-radius: 2px;
background: var(--c);
}
.label.bin-label {
padding: 7px 10px;
border-bottom: 3px solid var(--c);
}
.loader {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #dfe7e7;
color: #526b72;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
.loader.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.intro {
top: 12px;
left: 12px;
width: min(340px, calc(100vw - 24px));
padding: 15px;
}
.description { display: none; }
.stages { margin-top: 9px; }
.stage { padding: 5px 6px; }
.legend {
left: 12px;
bottom: 12px;
padding: 10px 12px;
}
.legend-title { display: none; }
.legend-row { margin: 4px 0; font-size: 9px; }
.controls {
right: 12px;
bottom: 12px;
padding: 6px;
}
.controls button {
padding: 8px;
font-size: 9px;
}
.status { display: none; }
.hint { display: none; }
.secondary-label { display: none !important; }
}
</style>
</head>
<body>
<div class="loader" id="loader">Building milling schematic…</div>
<section class="panel intro">
<div class="eyebrow">Process study · 01</div>
<h1>Kernel Milling & Separation</h1>
<div class="subtitle">Simplified milling illustration — schematic, not to scale.</div>
<p class="description">
Whole kernels pass between counter-rotating rollers, then move across a
vibrating screen. Coarse, medium and fine fractions are shown leaving
at different positions and collecting in separate bins.
</p>
<div class="stages">
<span class="stage"><b>01</b> FEED</span>
<span class="stage"><b>02</b> ROLL</span>
<span class="stage"><b>03</b> SCREEN</span>
<span class="stage"><b>04</b> COLLECT</span>
</div>
</section>
<section class="panel legend">
<div class="legend-title">Material key</div>
<div class="legend-row">
<span class="swatch" style="background:var(--kernel)"></span>
Whole kernels
</div>
<div class="legend-row">
<span class="swatch" style="background:var(--coarse)"></span>
Coarse fraction
</div>
<div class="legend-row">
<span class="swatch" style="background:var(--medium)"></span>
Medium fraction
</div>
<div class="legend-row">
<span class="swatch" style="background:var(--fine)"></span>
Fine fraction
</div>
</section>
<section class="panel controls">
<div class="status">
<span class="status-dot" id="statusDot"></span>
<span id="statusText">Running</span>
</div>
<button id="pauseButton" type="button">Pause</button>
<button id="restartButton" type="button">Restart</button>
<button id="viewButton" type="button">Top view</button>
</section>
<div class="hint">Drag to orbit · Scroll to zoom · Double-click to reset</div>
<div class="label secondary-label" id="labelHopper" style="--c:#cf6540">
Feed hopper
</div>
<div class="label secondary-label" id="labelRollers" style="--c:#69878d">
Counter-rotating rollers
</div>
<div class="label secondary-label" id="labelScreen" style="--c:#52767c">
Vibrating screen
</div>
<div class="label bin-label" id="labelFine" style="--c:#5e9e90">
Fine bin
</div>
<div class="label bin-label" id="labelMedium" style="--c:#dca43a">
Medium bin
</div>
<div class="label bin-label" id="labelCoarse" style="--c:#cf6540">
Coarse bin
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdfe7e7);
scene.fog = new THREE.Fog(0xdfe7e7, 19, 34);
const camera = new THREE.PerspectiveCamera(
39,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xf7f4e9, 0x718286, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d8, 3.1);
sun.position.set(-5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -7;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0004;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d9de, 1.1);
fill.position.set(8, 4, -8);
scene.add(fill);
const palette = {
ink: 0x263b40,
frame: 0x435b61,
frameLight: 0x71898e,
hopper: 0xc66b4c,
hopperDark: 0x8e4938,
screen: 0x4f7379,
screenEdge: 0x2d4c52,
floor: 0xd7e0df,
coarse: 0xcf6540,
medium: 0xdca43a,
fine: 0x5e9e90,
kernel: 0xefd49a
};
function makeMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.08,
flatShading: true,
...options
});
}
const materials = {
ink: makeMaterial(palette.ink),
frame: makeMaterial(palette.frame),
frameLight: makeMaterial(palette.frameLight),
hopper: makeMaterial(palette.hopper, { side: THREE.DoubleSide }),
hopperDark: makeMaterial(palette.hopperDark),
screen: makeMaterial(palette.screen),
screenEdge: makeMaterial(palette.screenEdge),
coarse: makeMaterial(palette.coarse),
medium: makeMaterial(palette.medium),
fine: makeMaterial(palette.fine),
kernel: makeMaterial(palette.kernel)
};
function addBox(parent, width, height, depth, x, y, z, material, outline = false) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (outline) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry, 24),
new THREE.LineBasicMaterial({
color: 0x203238,
transparent: true,
opacity: 0.28
})
);
mesh.add(edges);
}
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
segments,
x,
y,
z,
material
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments,
1,
false
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Floor and base frame
// -------------------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(36, 28),
makeMaterial(palette.floor, { roughness: 0.95 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -2.2;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(26, 26, 0x9caeb0, 0xb8c6c7);
grid.position.y = -2.185;
grid.material.transparent = true;
grid.material.opacity = 0.19;
scene.add(grid);
const machineFrame = new THREE.Group();
scene.add(machineFrame);
addBox(machineFrame, 9.3, 0.13, 0.18, -0.15, -2.04, -1.17, materials.ink);
addBox(machineFrame, 9.3, 0.13, 0.18, -0.15, -2.04, 1.17, materials.ink);
for (const x of [-4.55, -1.7, 1.2, 3.95]) {
addBox(machineFrame, 0.16, 0.13, 2.45, x, -2.04, 0, materials.frame);
}
// -------------------------------------------------------------------------
// Feed hopper
// -------------------------------------------------------------------------
const hopper = new THREE.Group();
hopper.position.set(-4.15, 0, 0);
scene.add(hopper);
const hopperBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.91, 0.31, 1.25, 4, 1, true),
materials.hopper
);
hopperBody.position.y = 4.73;
hopperBody.rotation.y = Math.PI / 4;
hopperBody.castShadow = true;
hopper.add(hopperBody);
const hopperEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(hopperBody.geometry, 20),
new THREE.LineBasicMaterial({
color: 0x713b30,
transparent: true,
opacity: 0.38
})
);
hopperBody.add(hopperEdges);
// Square top rim.
for (const z of [-0.79, 0.79]) {
addBox(hopper, 1.62, 0.11, 0.11, 0, 5.37, z, materials.hopperDark);
}
for (const x of [-0.79, 0.79]) {
addBox(hopper, 0.11, 0.11, 1.62, x, 5.37, 0, materials.hopperDark);
}
addCylinder(
hopper,
0.28,
0.28,
0.38,
8,
0,
4.02,
0,
materials.hopperDark
);
addBox(hopper, 0.22, 5.3, 0.22, 0, 0.62, -1.28, materials.frame);
addBox(hopper, 1.75, 0.18, 0.18, 0, 3.12, -1.28, materials.frame);
// Small feed-direction arrow.
scene.add(
new THREE.ArrowHelper(
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(-5.25, 5.15, -0.42),
1.05,
palette.coarse,
0.28,
0.18
)
);
// -------------------------------------------------------------------------
// Counter-rotating roller pair
// -------------------------------------------------------------------------
const upperRoller = new THREE.Group();
const lowerRoller = new THREE.Group();
upperRoller.position.set(-4.15, 3.55, 0);
lowerRoller.position.set(-4.15, 2.32, 0);
scene.add(upperRoller, lowerRoller);
function buildRoller(pivot, color) {
const rollerMaterial = makeMaterial(color, {
roughness: 0.58,
metalness: 0.16
});
const drum = new THREE.Mesh(
new THREE.CylinderGeometry(0.54, 0.54, 2.18, 12, 1),
rollerMaterial
);
drum.rotation.x = Math.PI / 2;
drum.castShadow = true;
drum.receiveShadow = true;
pivot.add(drum);
// Low-poly tread rings.
const ringMaterial = makeMaterial(palette.screenEdge);
for (const z of [-0.82, -0.42, 0, 0.42, 0.82]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.535, 0.027, 4, 12),
ringMaterial
);
ring.position.z = z;
pivot.add(ring);
}
// Axle and hubs.
const axle = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.105, 2.72, 10),
materials.ink
);
axle.rotation.x = Math.PI / 2;
pivot.add(axle);
for (const z of [-1.28, 1.28]) {
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(0.22, 0.22, 0.16, 10),
materials.frameLight
);
hub.rotation.x = Math.PI / 2;
hub.position.z = z;
hub.castShadow = true;
pivot.add(hub);
}
}
buildRoller(upperRoller, 0x789197);
buildRoller(lowerRoller, 0x628087);
// Roller support frame behind the machine.
for (const z of [-1.29, 1.29]) {
addBox(machineFrame, 0.20, 4.7, 0.20, -4.15, 0.2, z, materials.frame);
}
addBox(machineFrame, 0.24, 0.22, 2.72, -4.15, 3.53, 0, materials.frame);
addBox(machineFrame, 0.24, 0.22, 2.72, -4.15, 2.3, 0, materials.frame);
// -------------------------------------------------------------------------
// Vibrating screen
// -------------------------------------------------------------------------
const screen = new THREE.Group();
screen.position.set(-0.15, 1.12, 0);
screen.rotation.z = -0.24;
scene.add(screen);
const deck = addBox(
screen,
6.2,
0.12,
2.2,
0,
0,
0,
materials.screen,
true
);
deck.receiveShadow = true;
// Raised side rails and cross members.
for (const z of [-1.08, 1.08]) {
addBox(screen, 6.28, 0.21, 0.12, 0, 0.08, z, materials.screenEdge);
}
for (const x of [-3.06, 3.06]) {
addBox(screen, 0.13, 0.20, 2.2, x, 0.08, 0, materials.screenEdge);
}
for (const x of [-1.55, 0.1]) {
addBox(screen, 0.045, 0.035, 2.04, x, 0.082, 0, materials.frameLight);
}
addBox(screen, 0.07, 0.045, 2.04, 2.95, 0.084, 0, materials.coarse);
// Instanced low-poly apertures.
const holeGeometry = new THREE.CylinderGeometry(0.105, 0.105, 0.022, 8);
const holeMaterial = makeMaterial(0x20383e, {
roughness: 1,
metalness: 0
});
const holePositions = [];
for (const x of [-2.55, -1.82, -1.09, -0.36, 0.37, 1.10, 1.83, 2.56]) {
for (const z of [-0.78, -0.52, -0.26, 0, 0.26, 0.52, 0.78]) {
holePositions.push(new THREE.Vector3(x, 0.073, z));
}
}
const holes = new THREE.InstancedMesh(
holeGeometry,
holeMaterial,
holePositions.length
);
const matrix = new THREE.Matrix4();
holePositions.forEach((position, index) => {
matrix.makeTranslation(position.x, position.y, position.z);
holes.setMatrixAt(index, matrix);
});
holes.instanceMatrix.needsUpdate = true;
screen.add(holes);
// Vertical spring-like supports.
class HelixCurve extends THREE.Curve {
constructor(height, turns = 8) {
super();
this.height = height;
this.turns = turns;
}
getPoint(t, target = new THREE.Vector3()) {
const angle = t * Math.PI * 2 * this.turns;
return target.set(
Math.cos(angle) * 0.13,
t * this.height,
Math.sin(angle) * 0.13
);
}
}
const springMaterial = makeMaterial(0x789095, {
roughness: 0.52,
metalness: 0.28
});
for (const x of [-2.45, 2.15]) {
for (const z of [-0.95, 0.95]) {
const spring = new THREE.Mesh(
new THREE.TubeGeometry(
new HelixCurve(2.72, 8),
40,
0.034,
5,
false
),
springMaterial
);
spring.position.set(x, -2.06, z);
spring.castShadow = true;
scene.add(spring);
}
}
// -------------------------------------------------------------------------
// Collection bins
// -------------------------------------------------------------------------
const binDefinitions = [
{
name: "fine",
x: -1.62,
floorY: -1.95,
width: 1.52,
material: materials.fine
},
{
name: "medium",
x: -0.02,
floorY: -1.95,
width: 1.55,
material: materials.medium
},
{
name: "coarse",
x: 3.48,
floorY: -1.95,
width: 1.68,
material: materials.coarse
}
];
function buildBin(definition) {
const bin = new THREE.Group();
bin.position.x = definition.x;
scene.add(bin);
const width = definition.width;
const depth = 1.48;
const wallHeight = 1.18;
addBox(bin, width, 0.12, depth, 0, definition.floorY, 0, definition.material);
addBox(
bin,
width,
wallHeight,
0.10,
0,
definition.floorY + wallHeight / 2,
-depth / 2,
definition.material
);
for (const x of [-width / 2, width / 2]) {
addBox(
bin,
0.10,
wallHeight,
depth,
x,
definition.floorY + wallHeight / 2,
0,
definition.material
);
}
// Low translucent front wall keeps the contents visible.
const frontMaterial = makeMaterial(definition.material.color, {
transparent: true,
opacity: 0.48,
depthWrite: false
});
addBox(
bin,
width,
0.47,
0.08,
0,
definition.floorY + 0.235,
depth / 2,
frontMaterial
);
// Colored top edges.
addBox(
bin,
width + 0.08,
0.07,
0.09,
0,
definition.floorY + wallHeight,
-depth / 2,
definition.material
);
for (const x of [-width / 2, width / 2]) {
addBox(
bin,
0.09,
0.07,
depth,
x,
definition.floorY + wallHeight,
0,
definition.material
);
}
// Collected low-poly pieces.
const pieceGeometry = new THREE.IcosahedronGeometry(0.13, 0);
const count = 24;
const pieces = new THREE.InstancedMesh(
pieceGeometry,
definition.material,
count
);
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.sqrt(Math.random());
const px = Math.cos(angle) * radius * (width * 0.36);
const pz = Math.sin(angle) * radius * 0.48;
const mound = (1 - radius) * 0.22;
const py = definition.floorY + 0.15 + mound;
const scale = 0.65 + Math.random() * 0.75;
matrix.compose(
new THREE.Vector3(px, py, pz),
new THREE.Quaternion().setFromEuler(
new THREE.Euler(
Math.random() * Math.PI,
Math.random() * Math.PI,
Math.random() * Math.PI
)
),
new THREE.Vector3(scale, scale * 0.65, scale)
);
pieces.setMatrixAt(i, matrix);
}
pieces.instanceMatrix.needsUpdate = true;
pieces.castShadow = true;
pieces.receiveShadow = true;
bin.add(pieces);
}
binDefinitions.forEach(buildBin);
// -------------------------------------------------------------------------
// Animated kernels and separated fractions
// -------------------------------------------------------------------------
const kernelColor = new THREE.Color(palette.kernel);
const classColors = {
coarse: new THREE.Color(palette.coarse),
medium: new THREE.Color(palette.medium),
fine: new THREE.Color(palette.fine)
};
const screenAngle = -0.24;
const screenCenter = new THREE.Vector3(-0.15, 1.12, 0);
function screenPoint(localX, z, localY = 0.11) {
return new THREE.Vector3(
screenCenter.x +
localX * Math.cos(screenAngle) -
localY * Math.sin(screenAngle),
screenCenter.y +
localX * Math.sin(screenAngle) +
localY * Math.cos(screenAngle),
z
);
}
const laneCount = 9;
const lanes = [];
for (let i = 0; i < laneCount; i++) {
const z = THREE.MathUtils.lerp(-0.72, 0.72, i / (laneCount - 1));
lanes.push(z);
}
const feedCurves = lanes.map((z) => {
const points = [
new THREE.Vector3(-4.15, 5.62, z),
new THREE.Vector3(-4.15, 5.08, z),
new THREE.Vector3(-4.15, 4.48, z),
new THREE.Vector3(-4.15, 3.86, z),
new THREE.Vector3(-4.15, 3.24, z),
new THREE.Vector3(-4.15, 2.64, z),
new THREE.Vector3(-4.12, 2.02, z),
new THREE.Vector3(-3.58, 1.70, z),
screenPoint(-2.65, z)
];
return new THREE.CatmullRomCurve3(
points,
false,
"centripetal",
0.5
);
});
const routeCurves = {
coarse: lanes.map((z) => {
const points = [
screenPoint(-2.65, z),
screenPoint(-1.7, z),
screenPoint(-0.65, z),
screenPoint(0.95, z),
screenPoint(2.95, z),
new THREE.Vector3(3.08, 0.18, z),
new THREE.Vector3(3.42, -0.62, z),
new THREE.Vector3(3.48, -1.48, z)
];
return new THREE.CatmullRomCurve3(points, false, "centripetal", 0.5);
}),
medium: lanes.map((z) => {
const points = [
screenPoint(-2.65, z),
screenPoint(-1.55, z),
screenPoint(-0.65, z),
screenPoint(0.1, z),
new THREE.Vector3(-0.02, 0.55, z),
new THREE.Vector3(-0.02, -0.55, z),
new THREE.Vector3(-0.02, -1.48, z)
];
return new THREE.CatmullRomCurve3(points, false, "centripetal", 0.5);
}),
fine: lanes.map((z) => {
const points = [
screenPoint(-2.65, z),
screenPoint(-2.15, z),
screenPoint(-1.55, z),
new THREE.Vector3(-1.62, 0.83, z),
new THREE.Vector3(-1.62, -0.38, z),
new THREE.Vector3(-1.62, -1.48, z)
];
return new THREE.CatmullRomCurve3(points, false, "centripetal", 0.5);
})
};
const particleGeometry = new THREE.IcosahedronGeometry(0.145, 0);
const particles = [];
const particleCounts = {
coarse: 15,
medium: 17,
fine: 19
};
const routeDurations = {
coarse: 5.9,
medium: 4.0,
fine: 3.35
};
const feedDuration = 3.8;
for (const type of ["coarse", "medium", "fine"]) {
for (let i = 0; i < particleCounts[type]; i++) {
const laneIndex = i % laneCount;
const particleMaterial = makeMaterial(palette.kernel);
const mesh = new THREE.Mesh(particleGeometry, particleMaterial);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
particles.push({
mesh,
material: particleMaterial,
type,
laneIndex,
feedCurve: feedCurves[laneIndex],
routeCurve: routeCurves[type][laneIndex],
offset: Math.random() * (feedDuration + routeDurations[type]),
phase: Math.random() * Math.PI * 2
});
}
}
const blendedColor = new THREE.Color();
function updateParticles(time) {
for (const particle of particles) {
const totalDuration = feedDuration + routeDurations[particle.type];
const localTime = (time + particle.offset) % totalDuration;
if (localTime < feedDuration) {
const progress = localTime / feedDuration;
const position = particle.feedCurve.getPointAt(progress);
particle.material.color.copy(kernelColor);
// Squash the kernel while passing through the roller nip.
let verticalScale = 0.82;
if (position.y > 2.35 && position.y < 3.25) {
verticalScale = 0.43;
} else if (position.y >= 3.25 && position.y < 4.05) {
verticalScale = 0.65;
}
particle.mesh.position.copy(position);
particle.mesh.scale.set(1.18, verticalScale, 0.94);
} else {
const routeProgress =
(localTime - feedDuration) / routeDurations[particle.type];
const position = particle.routeCurve.getPointAt(routeProgress);
// Slight vibration while the fraction is still on the screen.
if (position.y > 0.2) {
position.x += Math.sin(time * 32 + particle.phase) * 0.022;
position.y += Math.cos(time * 29 + particle.phase) * 0.008;
}
const colorMix = THREE.MathUtils.smoothstep(
routeProgress,
0.015,
0.095
);
blendedColor.lerpColors(
kernelColor,
classColors[particle.type],
colorMix
);
particle.material.color.copy(blendedColor);
const sizes = {
coarse: 1.12,
medium: 0.83,
fine: 0.60
};
const size = sizes[particle.type];
particle.mesh.position.copy(position);
particle.mesh.scale.set(
size * 1.12,
size * 0.70,
size * 0.86
);
}
particle.mesh.rotation.x += 0.018;
particle.mesh.rotation.y += 0.024;
particle.mesh.rotation.z += 0.012;
}
}
// -------------------------------------------------------------------------
// Labels projected from 3D positions
// -------------------------------------------------------------------------
const labelDefinitions = [
{
element: document.getElementById("labelHopper"),
position: new THREE.Vector3(-4.15, 5.68, 0.25)
},
{
element: document.getElementById("labelRollers"),
position: new THREE.Vector3(-4.15, 3.8, 1.48)
},
{
element: document.getElementById("labelScreen"),
position: new THREE.Vector3(-0.25, 2.2, 1.12)
},
{
element: document.getElementById("labelFine"),
position: new THREE.Vector3(-1.62, -0.47, 0.96)
},
{
element: document.getElementById("labelMedium"),
position: new THREE.Vector3(-0.02, -0.43, 0.96)
},
{
element: document.getElementById("labelCoarse"),
position: new THREE.Vector3(3.48, -0.45, 0.96)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
for (const label of labelDefinitions) {
projected.copy(label.position).project(camera);
const visible = projected.z > -1 && projected.z < 1;
label.element.style.display = visible ? "flex" : "none";
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
label.element.style.transform =
`translate(-50%, -50%) translate(${x}px, ${y}px)`;
}
}
// -------------------------------------------------------------------------
// Custom orbit camera controls — no external control addons
// -------------------------------------------------------------------------
const cameraTarget = new THREE.Vector3(-0.1, 1.25, 0);
const cameraState = {
theta: 0.62,
phi: 1.13,
radius: 15.4
};
function applyCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y +
cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraState.theta = 0.62;
cameraState.phi = 1.13;
cameraState.radius = 15.4;
applyCamera();
}
applyCamera();
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.theta -= deltaX * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi + deltaY * 0.005,
0.34,
1.43
);
applyCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * Math.exp(event.deltaY * 0.001),
9,
23
);
applyCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
// -------------------------------------------------------------------------
// Controls and animation
// -------------------------------------------------------------------------
let paused = false;
let elapsed = 0;
let topView = false;
const pauseButton = document.getElementById("pauseButton");
const restartButton = document.getElementById("restartButton");
const viewButton = document.getElementById("viewButton");
const statusText = document.getElementById("statusText");
const statusDot = document.getElementById("statusDot");
function updateStatus() {
pauseButton.textContent = paused ? "Resume" : "Pause";
statusText.textContent = paused ? "Paused" : "Running";
statusDot.classList.toggle("paused", paused);
}
pauseButton.addEventListener("click", () => {
paused = !paused;
updateStatus();
});
restartButton.addEventListener("click", () => {
elapsed = 0;
paused = false;
updateStatus();
});
viewButton.addEventListener("click", () => {
topView = !topView;
if (topView) {
cameraState.theta = 0.02;
cameraState.phi = 0.35;
cameraState.radius = 14.2;
viewButton.textContent = "Iso view";
} else {
resetCamera();
viewButton.textContent = "Top view";
}
applyCamera();
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
paused = !paused;
updateStatus();
}
if (event.key.toLowerCase() === "r") {
elapsed = 0;
}
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const clock = new THREE.Clock();
const baseScreenPosition = screen.position.clone();
const baseScreenRotation = screen.rotation.z;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
if (!paused) elapsed += delta;
upperRoller.rotation.z = elapsed * 2.35;
lowerRoller.rotation.z = -elapsed * 2.55;
screen.position.x =
baseScreenPosition.x + Math.sin(elapsed * 31) * 0.027;
screen.rotation.z =
baseScreenRotation + Math.sin(elapsed * 27) * 0.0045;
updateParticles(elapsed);
updateLabels();
renderer.render(scene, camera);
}
updateStatus();
animate();
requestAnimationFrame(() => {
document.getElementById("loader").classList.add("hidden");
});
</script>
</body>
</html>
```