Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
414 lines
17 KiB
HTML
414 lines
17 KiB
HTML
<!doctype html>
|
||
<!-- Menivor original loop: pastel layered "kinetic sand" block sliced by a blade.
|
||
Pure 2D canvas with a hand-rolled oblique projection. 4 cuts per 8 s; the
|
||
layer pattern repeats every 4 slices, so the loop is seamless by construction. -->
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<style>html,body{margin:0;background:#000}canvas{display:block}</style>
|
||
</head>
|
||
<body>
|
||
<canvas id="c" width="720" height="1280"></canvas>
|
||
<script>
|
||
const W = 720, H = 1280, FPS = 30, LOOP_S = 8;
|
||
// ?v=1 is the base look; ?v=2..3 change palette, block shape, cut rhythm, layer shape and camera.
|
||
const V = Math.max(1, parseInt(new URLSearchParams(location.search).get('v') || '1', 10) || 1);
|
||
const THEMES = {
|
||
1: {
|
||
cuts: 4, bw: 470, bh: 250, th: 34, phi: 40, psi: 16, cx: 350, cy: 720, style: 'wave',
|
||
layers: ['#f6a9bd', '#ffc9a3', '#fde79c', '#bfe8b4', '#a9dcef', '#b9c3f5', '#d7b5f0', '#f7b3d6'],
|
||
bg: ['#f4ecff', '#fbeef2', '#fff4e8'], tray: '#e9e0f6', lines: 'rgba(160,140,200,0.35)', rim: 'rgba(150,130,190,0.5)',
|
||
shade: '60,40,80', shadow: '90,60,120', seam: 'rgba(120,80,120,0.18)',
|
||
blade: ['#c9d2de', '#eef3f8', '#b7c2d0', '#ffffff'], bladeLine: 'rgba(90,100,130,0.35)', handle: '#8b7fb0', topY: 620,
|
||
},
|
||
2: { // tall ocean-gradient block, 5 quick cuts, zig-zag strata, steeper side view
|
||
cuts: 5, bw: 400, bh: 330, th: 40, phi: 30, psi: 26, cx: 330, cy: 760, style: 'zigzag',
|
||
layers: ['#17506b', '#1f6f8b', '#2d8fa8', '#4fb0bd', '#7fd0c8', '#b3e8d4', '#e2f6dc'],
|
||
bg: ['#e3f7f1', '#d2efec', '#bfe3e6'], tray: '#a9d6d6', lines: 'rgba(40,120,130,0.3)', rim: 'rgba(30,100,115,0.45)',
|
||
shade: '10,50,70', shadow: '20,70,90', seam: 'rgba(10,50,70,0.22)',
|
||
blade: ['#8795a3', '#d5dee6', '#6f7d8b', '#ffffff'], bladeLine: 'rgba(10,40,60,0.45)', handle: '#f2a65a', topY: 700,
|
||
},
|
||
3: { // wide low chocolate-berry slab on a dark plum stage, 3 slow heavy cuts, domed layers, high angle
|
||
cuts: 3, bw: 540, bh: 190, th: 30, phi: 52, psi: 9, cx: 360, cy: 700, style: 'domes',
|
||
layers: ['#4a2a22', '#7a4a33', '#b8744a', '#e7ad7d', '#f8dcc0', '#f07896', '#c2476e'],
|
||
bg: ['#2a1b36', '#3a2546', '#4d2f4f'], tray: '#5a3f63', lines: 'rgba(255,200,230,0.16)', rim: 'rgba(255,190,220,0.3)',
|
||
shade: '30,10,25', shadow: '10,0,15', seam: 'rgba(40,10,20,0.25)',
|
||
blade: ['#e8b89a', '#fbe3d2', '#c98b6c', '#fff6ee'], bladeLine: 'rgba(80,30,20,0.4)', handle: '#f07896', topY: 560,
|
||
},
|
||
};
|
||
const T = THEMES[V] || THEMES[1];
|
||
const CUTS = T.cuts; // cuts per loop
|
||
const CYCLE = LOOP_S / CUTS; // seconds per cut
|
||
const BW = T.bw; // block width (x)
|
||
const BH = T.bh; // block height (y)
|
||
const TH = T.th; // slice thickness (z)
|
||
const DEPTH_PERIOD = CUTS * TH; // material pattern period along z
|
||
const BLOCK_LEN = 520; // visible block length behind the cut
|
||
const SHIFT = BH + 70; // conveyor index distance per cycle
|
||
const PHI = T.phi * Math.PI / 180; // camera elevation
|
||
const PSI = T.psi * Math.PI / 180; // camera yaw (shows the right side face)
|
||
const CX = T.cx, CY = T.cy; // screen position of world origin
|
||
|
||
const LAYERS = T.layers;
|
||
const TOP_COLOR = LAYERS[LAYERS.length - 1];
|
||
|
||
const canvas = document.getElementById('c');
|
||
const ctx = canvas.getContext('2d');
|
||
|
||
function rng(seed) {
|
||
let a = seed >>> 0;
|
||
return () => {
|
||
a = (a + 0x6d2b79f5) >>> 0;
|
||
let t = a;
|
||
t = Math.imul(t ^ (t >>> 15), t | 1);
|
||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||
};
|
||
}
|
||
|
||
// ---------- projection ----------
|
||
function proj(x, y, z) {
|
||
const x1 = x * Math.cos(PSI) - z * Math.sin(PSI);
|
||
const z1 = x * Math.sin(PSI) + z * Math.cos(PSI);
|
||
return [CX + x1, CY - (y * Math.cos(PHI) - z1 * Math.sin(PHI))];
|
||
}
|
||
const VIEW = [Math.sin(PSI) * Math.sin(PHI) * 0 + Math.sin(PSI) * Math.sin(PHI), Math.cos(PHI), Math.cos(PSI) * Math.sin(PHI)];
|
||
// Direction toward the camera in world space (for back-face culling).
|
||
function towardCamera() {
|
||
// camera looks along -view; view dir in world = inverse yaw of (0, sinφ, cosφ)
|
||
const vx = 0, vy = Math.sin(PHI), vz = Math.cos(PHI);
|
||
return [vx * Math.cos(PSI) + vz * Math.sin(PSI), vy, -vx * Math.sin(PSI) + vz * Math.cos(PSI)];
|
||
}
|
||
const CAM = towardCamera();
|
||
|
||
// Draw `img` (iw x ih) onto the parallelogram p0 (img top-left), p1 (img top-right), p2 (img bottom-left).
|
||
function drawQuad(img, iw, ih, p0, p1, p2, shadeAlpha = 0, sx = 0, sy = 0) {
|
||
ctx.save();
|
||
ctx.setTransform((p1[0] - p0[0]) / iw, (p1[1] - p0[1]) / iw, (p2[0] - p0[0]) / ih, (p2[1] - p0[1]) / ih, p0[0], p0[1]);
|
||
ctx.beginPath();
|
||
ctx.rect(0, 0, iw, ih);
|
||
ctx.clip();
|
||
ctx.drawImage(img, sx, sy, iw, ih, 0, 0, iw, ih);
|
||
if (shadeAlpha > 0) {
|
||
ctx.fillStyle = `rgba(${T.shade},${shadeAlpha})`;
|
||
ctx.fillRect(0, 0, iw, ih);
|
||
} else if (shadeAlpha < 0) {
|
||
ctx.fillStyle = `rgba(255,255,255,${-shadeAlpha})`;
|
||
ctx.fillRect(0, 0, iw, ih);
|
||
}
|
||
ctx.restore();
|
||
}
|
||
|
||
// ---------- procedural material ----------
|
||
const grain = document.createElement('canvas');
|
||
// Grain tile is exactly one material period so textures stay periodic along depth.
|
||
grain.width = grain.height = DEPTH_PERIOD;
|
||
{
|
||
const g = grain.getContext('2d');
|
||
const img = g.createImageData(DEPTH_PERIOD, DEPTH_PERIOD);
|
||
const r = rng(5);
|
||
for (let i = 0; i < img.data.length; i += 4) {
|
||
const v = r();
|
||
const c = v < 0.5 ? 0 : 255;
|
||
img.data[i] = img.data[i + 1] = img.data[i + 2] = c;
|
||
img.data[i + 3] = Math.floor(Math.abs(v - 0.5) * 2 * 70);
|
||
}
|
||
g.putImageData(img, 0, 0);
|
||
}
|
||
|
||
// Layer boundary heights at column x and material depth w (periodic in w).
|
||
function boundary(i, x, w) {
|
||
const n = LAYERS.length;
|
||
if (i <= 0) return 0;
|
||
if (i >= n) return BH;
|
||
const base = (i / n) * BH;
|
||
const ph = (2 * Math.PI * w) / DEPTH_PERIOD;
|
||
if (T.style === 'zigzag') {
|
||
// sharp chevron strata (triangle waves), still periodic in material depth
|
||
const tri = (v) => 2 * Math.abs(2 * (v - Math.floor(v + 0.5))) - 1;
|
||
return base + 15 * tri(x / 84 + i * 0.13 + ph / (2 * Math.PI)) + 1.5 * Math.sin(x / 13 + i * 2.1 - ph);
|
||
}
|
||
if (T.style === 'domes') {
|
||
// rounded pillow bumps that swell and shrink with depth
|
||
return base + (6 + 3 * Math.sin(ph + i)) * (2 * Math.abs(Math.sin(x / 42 + i * 0.9 + ph * 0.5 * 2)) - 1) + 2 * Math.sin(x / 9 + i - ph);
|
||
}
|
||
return base
|
||
+ 7 * Math.sin(x / 38 + i * 1.7 + ph)
|
||
+ 4 * Math.sin(x / 17 - i * 0.9 + 2 * ph + 1.3)
|
||
+ 2.5 * Math.sin(x / 7 + i * 2.3 - ph);
|
||
}
|
||
|
||
function paintLayers(g, width, colAt) {
|
||
const n = LAYERS.length;
|
||
for (let i = n - 1; i >= 0; i--) {
|
||
g.fillStyle = LAYERS[i];
|
||
g.beginPath();
|
||
g.moveTo(0, BH);
|
||
for (let c = 0; c <= width; c += 3) g.lineTo(c, BH - colAt(i + 1, c));
|
||
g.lineTo(width, BH);
|
||
g.closePath();
|
||
g.fill();
|
||
}
|
||
// thin darker seams between layers for crispness
|
||
g.lineWidth = 1.2;
|
||
g.strokeStyle = T.seam;
|
||
for (let i = 1; i < n; i++) {
|
||
g.beginPath();
|
||
for (let c = 0; c <= width; c += 3) {
|
||
const y = BH - colAt(i, c);
|
||
c === 0 ? g.moveTo(c, y) : g.lineTo(c, y);
|
||
}
|
||
g.stroke();
|
||
}
|
||
g.globalCompositeOperation = 'overlay';
|
||
g.fillStyle = g.createPattern(grain, 'repeat');
|
||
g.fillRect(0, 0, width, BH);
|
||
g.globalCompositeOperation = 'source-over';
|
||
}
|
||
|
||
// Cut-face texture (x across, y up) for material depth w. Cached per w mod period.
|
||
const faceCache = new Map();
|
||
function faceTexture(w) {
|
||
const key = ((Math.round(w) % DEPTH_PERIOD) + DEPTH_PERIOD) % DEPTH_PERIOD;
|
||
if (faceCache.has(key)) return faceCache.get(key);
|
||
const c = document.createElement('canvas');
|
||
c.width = BW; c.height = BH;
|
||
paintLayers(c.getContext('2d'), BW, (i, col) => boundary(i, col, key));
|
||
// Fresh-cut sheen: slightly smoother, brighter
|
||
faceCache.set(key, c);
|
||
return c;
|
||
}
|
||
|
||
// Side face texture: long strip along depth, 2 periods + block length, sampled at x = BW.
|
||
const SIDE_LEN = BLOCK_LEN + 2 * DEPTH_PERIOD;
|
||
const sideTex = document.createElement('canvas');
|
||
sideTex.width = SIDE_LEN; sideTex.height = BH;
|
||
paintLayers(sideTex.getContext('2d'), SIDE_LEN, (i, col) => boundary(i, BW, col));
|
||
|
||
// Top texture: top-layer color with grain, tileable along depth with DEPTH_PERIOD.
|
||
const TOP_LEN = BLOCK_LEN + 2 * DEPTH_PERIOD;
|
||
const topTex = document.createElement('canvas');
|
||
topTex.width = BW; topTex.height = TOP_LEN;
|
||
{
|
||
const g = topTex.getContext('2d');
|
||
g.fillStyle = TOP_COLOR;
|
||
g.fillRect(0, 0, BW, TOP_LEN);
|
||
// soft hand-pressed dimples, periodic along depth
|
||
const r = rng(9);
|
||
for (let k = 0; k < 40; k++) {
|
||
const x = r() * BW, y0 = r() * DEPTH_PERIOD, rad = 10 + r() * 26;
|
||
for (let y = y0 - DEPTH_PERIOD; y < TOP_LEN + DEPTH_PERIOD; y += DEPTH_PERIOD) {
|
||
const gr = g.createRadialGradient(x, y, 0, x, y, rad);
|
||
gr.addColorStop(0, 'rgba(255,255,255,0.10)');
|
||
gr.addColorStop(1, 'rgba(255,255,255,0)');
|
||
g.fillStyle = gr;
|
||
g.fillRect(x - rad, y - rad, rad * 2, rad * 2);
|
||
}
|
||
}
|
||
g.globalCompositeOperation = 'overlay';
|
||
g.fillStyle = g.createPattern(grain, 'repeat');
|
||
g.fillRect(0, 0, BW, TOP_LEN);
|
||
}
|
||
|
||
// ---------- scene pieces ----------
|
||
const clamp01 = (v) => Math.max(0, Math.min(1, v));
|
||
const ease = (v) => { v = clamp01(v); return v * v * (3 - 2 * v); };
|
||
const easeIn = (v) => { v = clamp01(v); return v * v; };
|
||
|
||
function background(t) {
|
||
const g = ctx.createLinearGradient(0, 0, 0, H);
|
||
g.addColorStop(0, T.bg[0]);
|
||
g.addColorStop(0.5, T.bg[1]);
|
||
g.addColorStop(1, T.bg[2]);
|
||
ctx.fillStyle = g;
|
||
ctx.fillRect(0, 0, W, H);
|
||
// conveyor tray: a soft lilac surface with index lines that move with the slices
|
||
const belt = [[-BW / 2 - 40, 0, -BLOCK_LEN - 200], [BW / 2 + 40, 0, -BLOCK_LEN - 200], [BW / 2 + 40, 0, 1400], [-BW / 2 - 40, 0, 1400]].map((p) => proj(...p));
|
||
ctx.fillStyle = T.tray;
|
||
ctx.beginPath();
|
||
belt.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
|
||
ctx.closePath();
|
||
ctx.fill();
|
||
const off = beltOffset(t);
|
||
ctx.strokeStyle = T.lines;
|
||
ctx.lineWidth = 2;
|
||
for (let z = -SHIFT * 2 + (off % (SHIFT / 4)); z < 1400; z += SHIFT / 4) {
|
||
if (z < 6) continue;
|
||
const a = proj(-BW / 2 - 40, 0, z), b = proj(BW / 2 + 40, 0, z);
|
||
ctx.beginPath(); ctx.moveTo(...a); ctx.lineTo(...b); ctx.stroke();
|
||
}
|
||
// tray rim
|
||
ctx.strokeStyle = T.rim;
|
||
ctx.lineWidth = 3;
|
||
ctx.beginPath(); ctx.moveTo(...belt[1]); ctx.lineTo(...belt[2]); ctx.stroke();
|
||
ctx.beginPath(); ctx.moveTo(...belt[0]); ctx.lineTo(...belt[3]); ctx.stroke();
|
||
}
|
||
|
||
// Conveyor offset: all landed slices index forward by SHIFT during [0.18, 0.46] of each cycle.
|
||
function beltOffset(t) {
|
||
const c = Math.floor(t / CYCLE), u = t / CYCLE - c;
|
||
return (c + ease((u - 0.18) / 0.28)) * SHIFT;
|
||
}
|
||
|
||
function softShadow(pts, blur, alpha) {
|
||
ctx.save();
|
||
ctx.filter = `blur(${blur}px)`;
|
||
ctx.fillStyle = `rgba(${T.shadow},${alpha})`;
|
||
ctx.beginPath();
|
||
pts.forEach(([x, y], i) => (i ? ctx.lineTo(x, y) : ctx.moveTo(x, y)));
|
||
ctx.closePath();
|
||
ctx.fill();
|
||
ctx.restore();
|
||
}
|
||
|
||
// Main block: front face at z = zf, extends back BLOCK_LEN. Front material depth = wFront.
|
||
function drawBlock(zf, wFront) {
|
||
const x0 = -BW / 2, x1 = BW / 2, zb = zf - BLOCK_LEN;
|
||
softShadow([proj(x0 - 6, 0, zf + 14), proj(x1 + 22, 0, zf + 14), proj(x1 + 22, 0, zb), proj(x0 - 6, 0, zb)], 14, 0.28);
|
||
// right side face (x = x1): texture column = material depth
|
||
const sideStart = ((wFront % DEPTH_PERIOD) + DEPTH_PERIOD) % DEPTH_PERIOD;
|
||
drawQuad(sideTex, BLOCK_LEN, BH, proj(x1, BH, zf), proj(x1, BH, zb), proj(x1, 0, zf), 0.2, sideStart, 0);
|
||
// top face: image row 0 at back so rows increase toward the front
|
||
const topStart = DEPTH_PERIOD * 2 - (((wFront % DEPTH_PERIOD) + DEPTH_PERIOD) % DEPTH_PERIOD);
|
||
drawQuad(topTex, BW, BLOCK_LEN, proj(x0, BH, zb), proj(x1, BH, zb), proj(x0, BH, zf), -0.04, 0, topStart);
|
||
// front (cut) face
|
||
drawQuad(faceTexture(wFront), BW, BH, proj(x0, BH, zf), proj(x1, BH, zf), proj(x0, 0, zf), 0.02);
|
||
}
|
||
|
||
// A slice: box x∈[-BW/2, BW/2], y∈[0,BH], z∈[-TH,0] relative to pivot (front-bottom edge),
|
||
// rotated forward by theta about the x axis, then translated by dz along z.
|
||
function slicePoint(x, y, z, theta, dz, lift) {
|
||
const yr = y * Math.cos(theta) - z * Math.sin(theta);
|
||
const zr = y * Math.sin(theta) + z * Math.cos(theta);
|
||
return proj(x, yr + lift, zr + dz);
|
||
}
|
||
function drawSlice(theta, dz, wFrontOfSlice, squash, lift = 0) {
|
||
const x0 = -BW / 2, x1 = BW / 2;
|
||
const h = BH * squash;
|
||
const P = (x, y, z) => slicePoint(x, y, z, theta, dz, lift);
|
||
// shadow on the tray
|
||
const reach = h * Math.sin(theta) + 10;
|
||
const back = dz - TH * Math.cos(theta);
|
||
softShadow([proj(x0 - 4, 0, back), proj(x1 + 16, 0, back), proj(x1 + 16, 0, dz + reach + 12), proj(x0 - 4, 0, dz + reach + 12)], 10, 0.22 + 0.12 * Math.sin(theta));
|
||
// normals after rotation (world): front (0, -sinθ, cosθ), back = -front, top (0, cosθ, sinθ)
|
||
const front = [0, -Math.sin(theta), Math.cos(theta)];
|
||
const top = [0, Math.cos(theta), Math.sin(theta)];
|
||
const dot = (a) => a[0] * CAM[0] + a[1] * CAM[1] + a[2] * CAM[2];
|
||
const faces = [];
|
||
// right side (always toward camera because of yaw): layers seen edge-on as thin bands
|
||
faces.push(() => {
|
||
const img = faceTexture(wFrontOfSlice);
|
||
drawQuad(img, TH, BH, P(x1, h, 0), P(x1, h, -TH), P(x1, 0, 0), 0.2, BW - TH, 0);
|
||
});
|
||
if (dot(top) > 0) faces.push(() => {
|
||
drawQuad(topTex, BW, TH, P(x0, h, -TH), P(x1, h, -TH), P(x0, h, 0), -0.04, 0, 40);
|
||
});
|
||
if (dot(front) > 0) faces.push(() => {
|
||
drawQuad(faceTexture(wFrontOfSlice), BW, BH, P(x0, h, 0), P(x1, h, 0), P(x0, 0, 0), 0.02 + 0.1 * Math.sin(theta));
|
||
});
|
||
if (-dot(front) > 0) faces.push(() => {
|
||
// back face = the fresh cut; mirror not needed since we view it from the back side
|
||
drawQuad(faceTexture(wFrontOfSlice + TH), BW, BH, P(x0, h, -TH), P(x1, h, -TH), P(x0, 0, -TH), -0.06);
|
||
});
|
||
faces.forEach((f) => f());
|
||
}
|
||
|
||
function drawBlade(y, z) {
|
||
const x0 = -BW / 2 - 22, x1 = BW / 2 + 22, bh = 300;
|
||
const a = proj(x0, y + bh, z), b = proj(x1, y + bh, z), c = proj(x1, y, z), d = proj(x0, y, z);
|
||
const g = ctx.createLinearGradient(a[0], a[1], d[0], d[1]);
|
||
g.addColorStop(0, T.blade[0]);
|
||
g.addColorStop(0.55, T.blade[1]);
|
||
g.addColorStop(0.85, T.blade[2]);
|
||
g.addColorStop(1, T.blade[3]);
|
||
ctx.fillStyle = g;
|
||
ctx.beginPath(); ctx.moveTo(...a); ctx.lineTo(...b); ctx.lineTo(...c); ctx.lineTo(...d); ctx.closePath(); ctx.fill();
|
||
ctx.strokeStyle = T.bladeLine;
|
||
ctx.lineWidth = 2; ctx.stroke();
|
||
// bright cutting edge
|
||
ctx.strokeStyle = 'rgba(255,255,255,0.95)';
|
||
ctx.lineWidth = 3;
|
||
ctx.beginPath(); ctx.moveTo(...d); ctx.lineTo(...c); ctx.stroke();
|
||
// handle bar on top
|
||
const h0 = proj(x0 + 40, y + bh + 26, z), h1 = proj(x1 - 40, y + bh + 26, z);
|
||
ctx.strokeStyle = T.handle;
|
||
ctx.lineCap = 'round';
|
||
ctx.lineWidth = 22;
|
||
ctx.beginPath(); ctx.moveTo(...h0); ctx.lineTo(...h1); ctx.stroke();
|
||
ctx.strokeStyle = 'rgba(255,255,255,0.35)';
|
||
ctx.lineWidth = 6;
|
||
ctx.beginPath(); ctx.moveTo(h0[0], h0[1] - 5); ctx.lineTo(h1[0], h1[1] - 5); ctx.stroke();
|
||
ctx.lineCap = 'butt';
|
||
}
|
||
|
||
// Crumbs that pop off when a slice lands (deterministic per slice).
|
||
function crumbs(age, sliceIdx, dz) {
|
||
const since = (age - 0.6) * CYCLE;
|
||
if (since < 0 || since > 0.7) return;
|
||
const r = rng(300 + sliceIdx);
|
||
for (let k = 0; k < 26; k++) {
|
||
const x = (r() - 0.5) * BW;
|
||
const vz = 60 + r() * 140, vy = 80 + r() * 160;
|
||
const y = Math.max(0, vy * since - 500 * since * since);
|
||
const z = dz + BH + vz * since;
|
||
const [sx, sy] = proj(x, y + 4, z);
|
||
const col = LAYERS[Math.floor(r() * LAYERS.length)];
|
||
ctx.fillStyle = col;
|
||
ctx.globalAlpha = 1 - since / 0.7;
|
||
ctx.beginPath(); ctx.arc(sx, sy, 2 + r() * 3, 0, Math.PI * 2); ctx.fill();
|
||
}
|
||
ctx.globalAlpha = 1;
|
||
}
|
||
|
||
// ---------- timeline ----------
|
||
// Per cycle u∈[0,1): blade descends 0.02–0.30, retracts 0.30–0.45; slice tips 0.30–0.60
|
||
// (lands with a soft squash), block pushes forward TH during 0.66–0.92, conveyor indexes 0.18–0.46.
|
||
function render(t) {
|
||
const c = Math.floor(t / CYCLE), u = t / CYCLE - c;
|
||
background(t);
|
||
|
||
const zBlock = -TH + TH * ease((u - 0.66) / 0.26);
|
||
const wBlockFront = (c + 1) * TH; // slice k's front face sits at material depth k*TH
|
||
|
||
drawBlock(zBlock, wBlockFront);
|
||
// Blade parks above the crop band, chops down fast, lifts back out.
|
||
const TOPY = T.topY;
|
||
const bladeY = u < 0.1 ? TOPY : u < 0.3 ? TOPY - (TOPY + 5) * easeIn((u - 0.1) / 0.2) : -5 + (TOPY + 5) * ease((u - 0.34) / 0.3);
|
||
drawBlade(Math.min(TOPY, bladeY), -TH);
|
||
drawSliceAtAge(u, c, 0);
|
||
// Landed slices from earlier cycles, nearest-to-camera last.
|
||
for (let j = 1; j <= 4; j++) {
|
||
const k = c - j;
|
||
const dz = beltOffset(t) - (k + 1) * SHIFT;
|
||
drawSliceAtAge(j + u, k, dz);
|
||
}
|
||
}
|
||
|
||
function drawSliceAtAge(age, k, dz) {
|
||
if (age < 0) return;
|
||
let theta = 0, squash = 1;
|
||
if (age >= 0.3) {
|
||
const f = clamp01((age - 0.3) / 0.3);
|
||
theta = (Math.PI / 2) * easeIn(f);
|
||
}
|
||
const since = (age - 0.6) * CYCLE;
|
||
if (since >= 0) {
|
||
theta = Math.PI / 2;
|
||
squash = 1 - 0.07 * Math.sin(Math.min(1, since / 0.35) * Math.PI) * Math.exp(-since * 2);
|
||
}
|
||
// A just-cut slice is still flush with the block: it stands at z∈[-TH,0].
|
||
drawSlice(theta, dz, k * TH, squash);
|
||
crumbs(age, ((k % CUTS) + CUTS) % CUTS, dz);
|
||
}
|
||
|
||
window.renderFrame = (i) => {
|
||
const t = (i % (FPS * LOOP_S)) / FPS;
|
||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||
render(t);
|
||
return canvas.toDataURL('image/png');
|
||
};
|
||
window.sceneReady = true;
|
||
</script>
|
||
</body>
|
||
</html>
|