cigar-film: a premium corona taken apart - new cigar object, tour, score, timeline; docs + npm run cigar

This commit is contained in:
NIG
2026-11-10 19:20:24 +03:30
parent 331304fd5c
commit 2481fcdd9f
10 changed files with 449 additions and 2 deletions
+2 -1
View File
@@ -33,8 +33,9 @@ Build one, open the HTML, watch it take itself apart. Start a new object from th
| `tarantula-*` | A robotic tarantula on 8 bristled legs, a glass abdomen full of lit coils. | Optics, a front leg coming apart on its servos, the abdomen cage opening, the head plates lifting; two jumps. | A walking body: an alternating tetrapod gait integrated from velocity keys, a jump with a crouch and a tuck. |
| `piranha-*` | A deep-bodied robotic piranha with 2 rows of glass fangs and a glass flank over drive gears. | The eye unscrewing in macro, the tail stalk telescoping, the glass flank opening from above, the jaw dropping from below. | One camera per beat aimed at its own part; a mirrored scene; a lunge at the lens. |
| `wasp-*` | A robotic wasp with frosted wings, a telescoping abdomen and a glass stinger. | Optics, a wing pulled out of its hinge and turned over, thorax gears, the abdomen telescoping. | A slow-motion explode as a warp of film time into scene time; a dive in from above and a climb out of the frame. |
| `cigar-*` | A premium corona whose wrapper is two leaf shutters over a cutaway window; three twisted tripa leaves inside, an HDR ember and banded ash at the foot. It keeps its natural warm palette — the one object here not retinted green. | The cap punched out, the band slid off, the shutters peeled, the binder folded down, the filler spread, the foot lit and one ash ring dropped; a turntable teardown. | A long body with a window instead of limbs; labels for a horizontal subject; a score of leaf rustles, ash rattles and ember puffs. |
Each comes in 3 folders: `<name>-shared/` holds the object, `<name>-film/` the full film (it also opens as a looping page), `<name>-demo/` a 10-second version with its own script.
Each comes in 2 or 3 folders: `<name>-shared/` holds the object, `<name>-film/` the full film (it also opens as a looping page), `<name>-demo/` (the three robots) a 10-second version with its own script.
```
node "$SKILL_DIR/sims/build.mjs" piranha-film # → cutaway-out/dist/piranha-film.html, offline, ~900 KB
+2 -1
View File
@@ -10,7 +10,8 @@
"film": "node film.mjs",
"wasp": "node film.mjs wasp-film --gif",
"piranha": "node film.mjs piranha-film --gif",
"tarantula": "node film.mjs tarantula-film --gif"
"tarantula": "node film.mjs tarantula-film --gif",
"cigar": "node film.mjs cigar-film --gif"
},
"dependencies": {
"@fontsource-variable/inter": "5.3.0",
+3
View File
@@ -0,0 +1,3 @@
import {runCigarGreen} from '../cigar-shared/sim_green.js';
import TL from './timeline.json';
runCigarGreen(TL);
+14
View File
@@ -0,0 +1,14 @@
{
"duration": 22,
"script": [
{"t": 2.8, "act": "cap"},
{"t": 5.4, "act": "band"},
{"t": 7.9, "act": "wrapper"},
{"t": 10.5, "act": "binder"},
{"t": 13.0, "act": "filler"},
{"t": 15.4, "act": "foot"},
{"t": 17.9, "act": "exploded"},
{"t": 19.6, "act": "assemble"},
{"t": 20.7, "act": "hero"}
]
}
+14
View File
@@ -0,0 +1,14 @@
# CR-7 visual checklist
1. Corona silhouette: 6 units long, diameter 1.06 (0.177 of length); rounded cut head, flat lit foot.
2. Capa is rich brown with fine raised veins, a spiral overlap and irregular grain; rough leaf rather than polished plastic.
3. Burgundy band is 0.6 units wide, with four gold borders and an embossed oval cartouche.
4. Cut cap detaches axially and rises; band clears the head before rotating.
5. Two profiled wrapper shutters pivot out around their actual long hinge edges.
6. Olive-brown binder folds below the exposed window, clear of the filler.
7. Three whole-leaf primings each contain ten twisted folds with dark vein lines; tan seco, brown viso, dark ligero.
8. Filler spreads radially with axial stagger, leaving all three materials readable.
9. Foot contains near-black char, orange emissive coals, a hot inner core, banded cracked ash and three thin smoke ribbons.
10. Teardown separates cap, band, fixed wrapper, shutters, binder, filler, foot and ash; assembly restores every transform.
11. Each act changes azimuth, elevation and distance, with 0.85 s camera blends and a push toward its part.
12. At sheet size the subject remains dense and dark, with fine leaf grain and veins visible at full frame. Natural tobacco palette is intentional.
+186
View File
@@ -0,0 +1,186 @@
// Hand-rolled corona: all leaf surfaces, veins, grain, foil and ash are procedural.
// X is the long axis; head at -3, lit foot at +2.35. Every pose is absolute.
import * as THREE from 'three';
import {clamp01, lerp, smooth, rng} from '../kit/util.js';
export const L = 6;
export const BURN_X = 2.35;
const TAU = Math.PI * 2;
const R = 0.53;
export const rAt = (x) => R * (1 + 0.025 * Math.sin((x + 2.6) * 0.8)) * (1 - 0.045 * smooth((x - 0.6) / 2)) * (1 - 0.58 * smooth((-2.53 - x) / 0.47));
const point = (x, a, scale = 1) => new THREE.Vector3(x, rAt(x) * scale * Math.sin(a), rAt(x) * scale * Math.cos(a));
// A profiled cylindrical leaf, with local micro-wrinkles and UVs for tobacco grain.
function shell(x0, x1, a0 = 0, a1 = TAU, scale = 1) {
const p = [], uv = [], ix = [];
const nx = 40, na = Math.max(16, Math.round(72 * (a1 - a0) / TAU));
for (let i = 0; i <= nx; i++) for (let j = 0; j <= na; j++) {
const x = lerp(x0, x1, i / nx), a = lerp(a0, a1, j / na);
const rr = 1 + 0.003 * Math.sin(x * 47 + a * 17) + 0.002 * Math.sin(a * 53 - x * 21);
const v = point(x, a, scale * rr);
p.push(v.x, v.y, v.z); uv.push(i / nx, j / na);
if (i < nx && j < na) {const k = i * (na + 1) + j; ix.push(k, k + 1, k + na + 1, k + 1, k + na + 2, k + na + 1);}
}
const g = new THREE.BufferGeometry();
g.setAttribute('position', new THREE.Float32BufferAttribute(p, 3));
g.setAttribute('uv', new THREE.Float32BufferAttribute(uv, 2));
g.setIndex(ix); g.computeVertexNormals(); return g;
}
function grainTexture() {
const n = 256, random = rng(7341), data = new Uint8Array(n * n * 4);
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) {
const a = (y * n + x) * 4;
const k = 145 + random() * 65 + 17 * Math.sin(y * 0.7 + x * 0.032) + 9 * Math.sin(y * 2.3 + x * 0.11);
data[a] = k; data[a + 1] = k; data[a + 2] = k; data[a + 3] = 255;
}
const t = new THREE.DataTexture(data, n, n); t.wrapS = t.wrapT = THREE.RepeatWrapping;
t.repeat.set(3, 2); t.needsUpdate = true; return t;
}
export function buildCigar() {
const root = new THREE.Group(), anchors = {}, clear = [], random = rng(713);
root.name = 'CR-7 / Torcidora';
const grain = grainTexture();
const leaf = (color, roughness = 0.68) => new THREE.MeshPhysicalMaterial({color, roughness, metalness: 0, clearcoat: 0.12, clearcoatRoughness: 0.55, side: THREE.DoubleSide, map: grain, bumpMap: grain, bumpScale: 0.009});
const M = {
wrapper: leaf(0x7a4a22), veins: leaf(0x402611, 0.8), binder: leaf(0x99804b, 0.82),
seco: leaf(0xb2925b, 0.88), viso: leaf(0x80502c, 0.85), ligero: leaf(0x432916, 0.9),
band: new THREE.MeshPhysicalMaterial({color: 0x6d1428, roughness: 0.42, clearcoat: 0.4, side: THREE.DoubleSide}),
gold: new THREE.MeshStandardMaterial({color: 0xcfa64a, metalness: 0.82, roughness: 0.3}),
char: new THREE.MeshStandardMaterial({color: 0x201a15, roughness: 1}),
ash: new THREE.MeshStandardMaterial({color: 0xbcb7ab, roughness: 1}),
ashDark: new THREE.MeshStandardMaterial({color: 0x68635c, roughness: 1}),
ember: new THREE.MeshStandardMaterial({color: 0x6a2106, emissive: 0xff5a13, emissiveIntensity: 1.8, roughness: 1}),
hot: new THREE.MeshBasicMaterial({color: new THREE.Color(0xff9e38).multiplyScalar(2.2)}),
smoke: new THREE.MeshBasicMaterial({color: 0x8d877d, transparent: true, opacity: 0.19, depthWrite: false, side: THREE.DoubleSide}),
};
const mesh = (parent, geo, mat) => {const m = new THREE.Mesh(geo, mat); parent.add(m); return m;};
const group = (name) => {const g = new THREE.Group(); g.name = name; root.add(g); return g;};
const anchor = (key, obj, at) => anchors[key] = {obj, at: new THREE.Vector3(...at)};
const tube = (parent, pts, radius, mat, segments = 32) => mesh(parent, new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts), segments, radius, 4, false), mat);
const ring = (parent, x, rr, radius, mat) => {const m = mesh(parent, new THREE.TorusGeometry(rr, radius, 8, 80), mat); m.rotation.y = Math.PI / 2; m.position.x = x; return m;};
const disk = (parent, x, rr, mat) => {const m = mesh(parent, new THREE.CircleGeometry(rr, 64), mat); m.rotation.y = Math.PI / 2; m.position.x = x; return m;};
const veins = (g, x0, x1, a0, a1, scale = 1, count = 14) => {
for (let i = 0; i < count; i++) {
const xa = lerp(x0, x1 - 0.18, random()), aa = lerp(a0 + 0.02, a1 - 0.02, random());
const length = Math.min(x1 - xa, 0.28 + random() * 0.75), drift = (random() - 0.5) * 0.4;
const pts = Array.from({length: 9}, (_, j) => point(xa + length * j / 8, Math.max(a0, Math.min(a1, aa + drift * j / 8)), scale * 1.006));
tube(g, pts, 0.0023 + random() * 0.002, M.veins, 12);
}
};
const body = group('Wrapper / fixed shoulder and back');
mesh(body, shell(-2.83, -1.02), M.wrapper); mesh(body, shell(1.45, BURN_X), M.wrapper);
mesh(body, shell(-1.02, 1.45, Math.PI / 2, Math.PI * 1.5), M.wrapper);
veins(body, -2.83, -1.02, 0, TAU, 1, 34); veins(body, 1.45, BURN_X, 0, TAU, 1, 18);
veins(body, -1.02, 1.45, Math.PI / 2, Math.PI * 1.5, 1, 25);
// Fine spiral overlap seam makes the single wrapper leaf legible in the assembled hero.
for (const [a, b] of [[-2.8, -1.03], [1.46, BURN_X]]) {
tube(body, Array.from({length: 110}, (_, i) => {const x = lerp(a, b, i / 109); return point(x, x * 4.2 + 0.6, 1.008);}), 0.003, M.veins, 110);
}
const cap = group('CAP');
mesh(cap, shell(-3, -2.83), M.wrapper); disk(cap, -3, rAt(-3), M.viso);
for (let i = 0; i < 26; i++) {const a = random() * TAU, rr = random() * rAt(-3) * 0.95; const m = mesh(cap, new THREE.SphereGeometry(0.014, 5, 4), [M.seco, M.viso, M.ligero][i % 3]); m.position.set(-3.003, rr * Math.sin(a), rr * Math.cos(a));}
ring(cap, -2.845, rAt(-2.845) * 1.006, 0.005, M.veins);
anchor('CAP', cap, [-2.94, 0.12, 0.12]);
const band = group('BAND');
mesh(band, shell(-2.22, -1.62, 0, TAU, 1.026), M.band);
for (const x of [-2.22, -2.18, -1.66, -1.62]) ring(band, x, rAt(x) * 1.031, 0.009, M.gold);
// Raised oval foil cartouche and embossed monogram, facing the viewing side.
const plaque = mesh(band, new THREE.SphereGeometry(1, 32, 24), M.gold); plaque.scale.set(0.22, 0.24, 0.025); plaque.position.set(-1.92, 0, 0.558);
const inset = mesh(band, new THREE.SphereGeometry(1, 32, 24), M.band); inset.scale.set(0.18, 0.20, 0.024); inset.position.set(-1.92, 0, 0.576);
for (let i = 0; i < 20; i++) {const a = TAU * i / 20; const b = mesh(band, new THREE.SphereGeometry(0.011, 7, 6), M.gold); b.position.set(-1.92 + Math.sin(a) * 0.195, Math.cos(a) * 0.218, 0.583);}
tube(band, [new THREE.Vector3(-1.83, .10, .607), new THREE.Vector3(-1.99, .10, .607), new THREE.Vector3(-2.02, 0, .607), new THREE.Vector3(-1.99, -.10, .607), new THREE.Vector3(-1.83, -.10, .607)], .012, M.gold, 24);
tube(band, [new THREE.Vector3(-1.94, .11, .608), new THREE.Vector3(-1.94, -.11, .608)], .009, M.gold, 8);
for (let i = 0; i < 24; i++) {const a = TAU * i / 24; tube(band, [point(-2.13, a, 1.036), point(-2.07, a + .08, 1.036)], .004, M.gold, 4); tube(band, [point(-1.76, a, 1.036), point(-1.70, a + .08, 1.036)], .004, M.gold, 4);}
anchor('BAND', band, [-1.92, 0.07, 0.6]);
const shutters = [];
for (const sign of [1, -1]) {
const g = group(sign === 1 ? 'Wrapper / upper shutter' : 'Wrapper / lower shutter');
const content = new THREE.Group(); g.add(content);
const hinge = new THREE.Vector3(0, sign * R, 0);
g.position.copy(hinge); content.position.copy(hinge).multiplyScalar(-1);
const a0 = sign === 1 ? 0.006 : -Math.PI / 2, a1 = sign === 1 ? Math.PI / 2 : -0.006;
mesh(content, shell(-1.02, 1.45, a0, a1, 1.002), M.wrapper);
veins(content, -1.02, 1.45, a0, a1, 1.005, 35);
tube(content, Array.from({length: 35}, (_, i) => point(lerp(-1.02, 1.45, i / 34), sign * .035, 1.012)), .004, M.veins, 34);
shutters.push({g, sign, hinge});
if (sign === 1) anchor('WRAPPER', content, [.3, .27, .47]);
}
const binder = group('BINDER');
const binderLeaf = new THREE.Group(); binder.add(binderLeaf); binder.position.y = -R * .91; binderLeaf.position.y = R * .91;
mesh(binderLeaf, shell(-1, 1.43, -Math.PI / 2, Math.PI / 2, .91), M.binder);
veins(binderLeaf, -1, 1.43, -Math.PI / 2, Math.PI / 2, .914, 28);
const binderBack = group('Binder / back'); mesh(binderBack, shell(-2.80, 2.33, Math.PI / 2, Math.PI * 1.5, .91), M.binder);
anchor('BINDER', binderLeaf, [.3, 0, .485]);
const filler = group('FILLER'); anchor('FILLER', filler, [.6, 0, .1]);
const leaves = [];
for (let k = 0; k < 3; k++) {
const g = new THREE.Group(); filler.add(g); g.name = ['SECO', 'VISO', 'LIGERO'][k];
const angle = TAU * k / 3, off = new THREE.Vector3(0, .19 * Math.sin(angle), .19 * Math.cos(angle));
const mat = [M.seco, M.viso, M.ligero][k];
// Irregular folded leaf ribbons, tightly bunched in longitudinal rolls.
for (let n = 0; n < 10; n++) {
const phi = TAU * n / 10, rad = .07 + .09 * random();
const pts = Array.from({length: 38}, (_, j) => {const x = lerp(-2.83 + .02 * k, 2.33 - .025 * n, j / 37), a = phi + .9 * x + k; return new THREE.Vector3(x, off.y + Math.sin(a) * rad, off.z + Math.cos(a) * rad);});
const strand = tube(g, pts, .024 + random() * .02, mat, 55); strand.scale.z = .8;
tube(g, pts.map((p) => p.clone().add(new THREE.Vector3(0, .018, .017))), .0025, M.veins, 45);
}
anchor(['SECO', 'VISO', 'LIGERO'][k], g, [.5, off.y, off.z]); leaves.push({g, angle});
}
const foot = group('FOOT');
mesh(foot, shell(2.29, 2.47, 0, TAU, 1.013), M.char);
disk(foot, 2.48, R * .87, M.char);
ring(foot, 2.43, R * .94, .023, M.ember);
// Coals cluster at the foot rather than glowing across the unburnt wrapper.
for (let i = 0; i < 95; i++) {
const a = random() * TAU, rr = Math.sqrt(random()) * R * .91;
const m = mesh(foot, new THREE.IcosahedronGeometry(.014 + random() * .025, 0), i % 4 === 0 ? M.hot : M.ember);
m.position.set(2.49 + random() * .035, Math.sin(a) * rr, Math.cos(a) * rr); m.scale.x = .4;
}
anchor('FOOT', foot, [2.48, .18, .22]);
const ash = group('ASH');
const ashFixed = group('Ash / attached collar');
const ashSurface = (g, a, b) => {
mesh(g, shell(a, b, 0, TAU, .97), M.ash);
for (let x = a; x <= b; x += .043) ring(g, x, rAt(x) * (.96 + random() * .03), .009 + random() * .006, random() > .6 ? M.ashDark : M.ash);
for (let i = 0; i < 25; i++) {const x = lerp(a, b, random()), th = random() * TAU; tube(g, [point(x, th, .992), point(Math.min(b, x + .08), th + .12, .992), point(Math.min(b, x + .13), th + .06, .992)], .005, M.ashDark, 6);}
};
ashSurface(ashFixed, 2.49, 2.64); ashSurface(ash, 2.65, 3.03); disk(ash, 3.03, rAt(3.03) * .97, M.ashDark);
for (let i = 0; i < 60; i++) {const a = random() * TAU, rr = Math.sqrt(random()) * .46; const m = mesh(ash, new THREE.IcosahedronGeometry(.018 + random() * .025, 0), i % 3 ? M.ash : M.ashDark); m.position.set(3.035, Math.sin(a) * rr, Math.cos(a) * rr); m.scale.x = .2;}
anchor('ASH', ash, [2.86, .14, .36]);
const smoke = group('Smoke ribbons');
const ribbons = [];
for (let k = 0; k < 3; k++) {
const pts = Array.from({length: 48}, (_, j) => {const u = j / 47; return new THREE.Vector3(2.56 + .12 * Math.sin(u * 8 + k), .44 + u * 1.8, .08 * Math.sin(u * 12 + k * 2) + k * .05);});
const m = tube(smoke, pts, .009 + .004 * k, M.smoke, 55); clear.push(m); ribbons.push(m);
}
function pose(s = {}) {
const t = s.t ?? 0, ex = clamp01(s.explode ?? 0), op = (key) => clamp01(s[key] ?? 0);
root.rotation.y = (s.turn ?? 0) * Math.PI / 180;
body.position.x = -1.25 * ex;
cap.rotation.set(0, -.28 * op('cap'), -.25 * op('cap'));
const capPivot = new THREE.Vector3(-2.93, 0, 0), capRotated = capPivot.clone().applyEuler(cap.rotation);
cap.position.copy(capPivot).sub(capRotated).add(new THREE.Vector3(-.64 * op('cap') - 3.06 * ex, .60 * op('cap') + .15 * ex, .18 * op('cap')));
const bandSlide = smooth(op('band') / .72), bandLift = smooth((op('band') - .72) / .28);
band.position.set(-1.65 * bandSlide - 2.375 * ex, .65 * bandLift + .95 * ex, .35 * bandLift); band.rotation.set(.36 * bandLift, 0, -.22 * bandLift);
const wrap = Math.max(op('wrapper'), op('binder'), op('tripa'));
for (const {g, sign, hinge} of shutters) {g.position.copy(hinge); g.position.x = -.65 * ex; g.position.y += sign * .35 * ex; g.rotation.x = -sign * 1.14 * Math.max(wrap, ex);}
binder.position.set(.5 * ex, -R * .91 - .35 * ex, 0); binder.rotation.x = 1.48 * Math.max(op('binder'), op('tripa'), ex);
binderBack.position.x = .5 * ex;
filler.position.x = 2.56 * ex;
leaves.forEach(({g, angle}, k) => {const spread = Math.max(op('tripa'), ex); g.position.set((k - 1) * .26 * spread, Math.sin(angle) * .54 * spread, Math.cos(angle) * .66 * spread); g.rotation.set(0, (k - 1) * .055 * spread, (k - 1) * .035 * spread);});
foot.position.x = 5.19 * ex + .13 * op('foot'); ashFixed.position.x = foot.position.x;
const drop = op('ashDrop'); ash.position.set(6.25 * ex + .24 * drop, -1.12 * drop * drop + .18 * ex, .15 * drop); ash.rotation.z = -.65 * drop;
M.ember.emissiveIntensity = 1 + 2 * clamp01(.35 + .45 * op('ember') + .16 * Math.sin(t * 8.7) + .08 * Math.sin(t * 17.3));
ribbons.forEach((m, i) => {m.position.set(foot.position.x + .06 * Math.sin(t * .9 + i), .025 * Math.sin(t * 1.1 + i), .075 * Math.sin(t * .7 + i)); m.rotation.x = .07 * Math.sin(t * .8 + i); m.scale.y = .95 + .08 * Math.sin(t * .9 + i);});
}
pose(); return {root, anchors, clear, M, pose};
}
+47
View File
@@ -0,0 +1,47 @@
"""Quiet D minor study: brushed keys, paper rustle and a restrained foil/ash accent."""
import os
from sfx.score_kit import airy, bed, chords, hz
from sfx.synth import blip, click, envelope, pad
TIMELINE = os.environ.get('TL', '../cigar-film/timeline.json')
OUT = os.environ.get('OUT', os.path.join(os.environ.get('CUTAWAY_OUT', 'cutaway-out'), 'cigar-score.wav'))
TARGET_LUFS = -14.0
SEED = 713
CHORDS = chords('Dm9:D3 F3 A3 C4 E4/D2', 'Bbmaj7:Bb2 D3 F3 A3/Bb1', 'Gm9:G2 Bb2 D3 F3 A3/G1', 'A7sus:A2 D3 E3 G3/A1')
MOTIF = [(0.5, hz('A5')), (1.5, hz('F5')), (2.5, hz('E5'))]
def score(mix, tl):
dur = tl['duration']
left, right, low, drums = bed(dur, 96, CHORDS, MOTIF, motif_voice='epiano', kicks=(0, 2.5), snares=(1, 3), hats=4, swing=0.08, keys_vel=0.62, keys_lp=3100)
mix.put_stereo(0, left, right, 0.12)
mix.put(0, low, 0.10)
mix.put(0, drums, 0.035)
bar = 4 * 60 / 96
changes = [(0.12 + b * bar, list(CHORDS[b % len(CHORDS)][0][:4])) for b in range(int(dur / bar) + 1)]
pl, pr = pad(dur, changes, volume=envelope([(0, 0), (1, 1), (dur - 1.6, 1), (dur, 0)]), detune=0.8, tremolo=0.12, xfade=0.5)
mix.put_stereo(0, pl, pr, 0.045)
mix.put(0, airy(1.8, 600, 1500, 0.5), 0.012, pan=-0.25)
for e in tl['script']:
t, act = e['t'], e['act']
mix.put(t, click(2400, 0.025), 0.035, pan=0.4)
if act == 'cap':
mix.put(t + .18, click(1200, .04), .025, pan=-.3)
elif act == 'band':
mix.put(t + .2, airy(.65, 1300, 2400, .5), .015, pan=-.2)
mix.put(t + .55, blip(hz('A5'), .2, .06), .009)
elif act in ('wrapper', 'binder', 'filler'):
mix.put(t + .18, airy(.92, 800, 2400, .65), .021, pan=-.15)
mix.put(t + 2.2, airy(.22, 1800, 700, .5), .012)
elif act == 'foot':
for i in range(5):
mix.put(t + 1.02 + .065 * i, click(1500 + i * 270, .025), .011, pan=.2)
mix.put(t + 1.1, airy(.4, 700, 1900, .5), .012, pan=.3)
elif act == 'exploded':
mix.put(t + .12, airy(1.2, 400, 2200, .7), .024)
elif act == 'assemble':
mix.put(t, airy(.8, 2200, 600, .5), .018)
for i in range(3):
mix.put(t + .55 + i * .14, click(1700 + 300 * i, .03), .028, pan=-.2 + .2 * i)
elif act == 'hero':
mix.put(t + .3, airy(.9, 600, 1800, .6), .015, pan=.25)
+52
View File
@@ -0,0 +1,52 @@
import {runSim} from '../kit/runtime.js';
import {createConsole} from '../green/console.js';
import {makeCursor, makeLabels, PAPER_GREEN, SHIFT} from '../green/look.js';
import {createStage, PAPER} from '../wasp-shared/stage.js';
import {buildCigar} from './cigar.js';
import {makeCigarTour, FLOOR_Y} from './tour.js';
const D2R = Math.PI / 180;
Object.assign(PAPER, PAPER_GREEN);
const NAV = [['overview', 'Overview'], ['cap', 'Cap'], ['band', 'Band'], ['wrapper', 'Wrapper'], ['binder', 'Binder'], ['filler', 'Filler'], ['foot', 'Foot'], ['exploded', 'Teardown'], ['hero', 'Release']];
const PAGE = {
name: 'Torcidora', code: 'CR-7', title: 'Premium Cigar, Taken Apart', date: '2026-11-10', nav: NAV, pills: NAV.slice(1),
sub: {overview: ['Whole-leaf corona', 'Hand-rolled construction'], cap: ['Triple cap, clean cut'], band: ['Burgundy + embossed gold'], wrapper: ['Wrapper: 1 leaf, sun-grown'], binder: ['Capote: elastic leaf'], filler: ['Tripa: seco / viso / ligero'], foot: ['Char, ember, mineral ash'], exploded: ['Every layer separated', 'Turntable 325°'], hero: ['Whole leaf, reassembled']},
cards: [{k: 'Heat', kind: 'bar', unit: '°C'}, {k: 'Draw', kind: 'wave', unit: ''}, {k: 'Layers', kind: 'bars', n: 4, unit: ''}, {k: 'Ash', kind: 'bar', unit: '%'}],
};
export function makeCigarGreen(TL, {tour = makeCigarTour} = {}) {
const T = tour(TL);
return async ({canvas, capture}) => {
const app = document.getElementById('app');
const st = createStage({canvas, floorY: FLOOR_Y});
const cigar = buildCigar(); st.addBee(cigar); cigar.root.rotation.order = 'YXZ';
const ui = createConsole(app, PAGE);
const cursorAt = makeCursor(ui, T.SCRIPT);
const labels = makeLabels(st, cigar.anchors, {});
const fit = () => {
const k = Math.min(innerWidth / 1600, innerHeight / 900);
app.style.transform = `scale(${k})`;
};
const resize = () => {
fit();
st.resize(1600, 900, capture ? devicePixelRatio || 1 : Math.min(devicePixelRatio || 1, 2));
};
resize();
window.CIGAR = {st, bee: cigar, T};
return {resize, render(t) {
const s = T.stateAt(t); cigar.pose(s);
const f = s.flight; cigar.root.position.copy(f.pos);
cigar.root.rotation.set(f.roll * D2R, (f.yaw + s.turn) * D2R, f.pitch * D2R);
const c = s.cam;
st.frame({...c, az: c.az * D2R, el: c.el * D2R, sx: c.sx + SHIFT[0], sy: c.sy + SHIFT[1]}, {guides: 0});
const tel = T.telemetry(t, s), opening = Math.max(s.open[s.view] ?? 0, s.explode);
ui.update({time: t, dur: TL.duration, status: tel.status, apart: Math.round(opening * 100), view: s.view === 'intro' ? 'overview' : s.view, callouts: labels(tel.labelSet), cursor: cursorAt(t), cards: [
{v: Math.round(540 + 150 * s.ember + 12 * Math.sin(t * 8.7)), bar: .65 + .2 * s.ember},
{v: (1.18 + .12 * Math.sin(t * 2)).toFixed(2), wave: Array.from({length: 70}, (_, i) => .40 * Math.sin(t * 2.1 - i * .11) + .08 * Math.sin(t * 4.4 - i * .33))},
{bars: [1 - s.wrapper * .8, 1 - s.binder * .8, 1 - s.tripa * .75, 1 - s.explode * .85]},
{v: Math.round(100 * (1 - s.ashDrop)), bar: 1 - s.ashDrop},
]}); return {};
}};
};
}
export const runCigarGreen = (TL, title = 'cigar-film', opts = {}) => runSim({duration: TL.duration, fps: 60, theme: 'light', hud: {enabled: false, title, subtitle: ''}, director: {enabled: false}, watermark: ''}, makeCigarGreen(TL, opts));
+63
View File
@@ -0,0 +1,63 @@
import * as THREE from 'three';
import {clamp01, lerp, prog} from '../kit/util.js';
export const FLOOR_Y = -1.95;
const ACTS = ['cap', 'band', 'wrapper', 'binder', 'filler', 'foot'];
const CAM = {
intro: (u) => [lerp(48, 38, prog(u, 0, 2.6)), lerp(19, 13, prog(u, 0, 2.6)), 7.2, 0, .15, 0, -60, -20],
cap: (u) => [-42 + 3 * u, 22, lerp(6.8, 5.6, prog(u, 0, 1.4)), -3.10, .30, .05, 0, 0],
band: (u) => [-14 + 3 * u, 9, lerp(7.4, 6.6, prog(u, 0, 1.4)), -2.30, .34, .05, 0, 0],
wrapper: (u) => [8 + 2 * u, 27, lerp(8.6, 7.8, prog(u, 0, 1.4)), .2, .08, .28, 0, 0],
binder: (u) => [-12 - 2 * u, -7, lerp(8.1, 7.4, prog(u, 0, 1.4)), .2, -.20, .35, 0, 0],
filler: (u) => [34 + 3 * u, 17, lerp(10.8, 9.8, prog(u, 0, 1.4)), .4, .05, .2, 0, 0],
foot: (u) => [62 + 3 * u, 16, lerp(6.7, 5.9, prog(u, 0, 1.4)), 2.6, -.17, 0, 0, 0],
exploded: (u) => [lerp(18, -50, prog(u, 0, 1.4)), 18, 25.2, .8, .02, 0, 100, 0],
hero: (u) => [46 + 8 * u, 14 + 2 * u, 7.2, 0, .16, 0, -60, -50],
};
const LABELS = {
cap: [['CAP', 'Cut cap', 'triple leaf, clean draw']],
band: [['BAND', 'Band', 'burgundy, gold foil']],
wrapper: [['WRAPPER', 'Capa', 'one sun-grown wrapper leaf']],
binder: [['BINDER', 'Capote', 'elastic binder leaf']],
filler: [['SECO', 'Seco', 'aroma, lower priming'], ['VISO', 'Viso', 'balance, middle priming'], ['LIGERO', 'Ligero', 'strength, upper priming']],
foot: [['FOOT', 'Ember', 'slow combustion'], ['ASH', 'Ash', 'mineral leaf skeleton']],
exploded: [['CAP', 'Cap', 'cut head'], ['BAND', 'Band', 'embossed gold foil'], ['FILLER', 'Tripa', 'three whole-leaf primings'], ['FOOT', 'Foot', 'char and ember']],
};
export function makeCigarTour(TL) {
const SCRIPT = [...TL.script].sort((a, b) => a.t - b.t);
const at = (act) => SCRIPT.find((e) => e.act === act)?.t ?? 999;
const te = at('exploded'), ta = at('assemble'), th = at('hero');
const openOf = (act, t) => {const u = t - at(act); return prog(u, .12, 1.10) * (1 - prog(u, 1.88, 2.38));};
const explodeAt = (t) => prog(t, te + .12, te + 1.4) * (1 - prog(t, ta, ta + .9));
const turnAt = (t) => 325 * prog(t, te + .2, ta + 1.1);
const flightAt = (t) => {
const intro = 1 - prog(t, -.6, 2.5), outro = prog(t, th + .30, TL.duration + .1);
return {pos: new THREE.Vector3(-.6 * intro + .8 * outro, .08 * Math.sin(t * .9) + .3 * intro + .3 * outro, -.45 * intro - .3 * outro), yaw: -12 * intro + 15 * outro, roll: 1.4 * Math.sin(t * .7) - 12 * outro, pitch: .7 * Math.sin(t * .9), calm: 1};
};
const VIEWS = [{t: -1, key: 'intro'}, ...SCRIPT.map((e) => ({t: e.t, key: e.act === 'assemble' ? 'exploded' : e.act}))];
const viewIdx = (t) => {let i = 0; while (i < VIEWS.length - 1 && VIEWS[i + 1].t <= t) i++; return i;};
const camFn = (v, t) => CAM[v.key](t - (v.key === 'intro' ? 0 : v.t));
// Same 0.85 s eased camera handoff and dolly bump as the approved wasp film.
const camAt = (t) => {
const i = viewIdx(t); let o = camFn(VIEWS[i], t);
if (VIEWS[i].key === 'exploded' && i > 0 && VIEWS[i - 1].key === 'exploded') o = camFn(VIEWS[i - 1], t);
else if (i > 0) {
const k = prog(t, VIEWS[i].t, VIEWS[i].t + .85);
if (k < 1) {const a = camFn(VIEWS[i - 1], t), dAz = ((o[0] - a[0] + 540) % 360) - 180; const b = o.map((v, j) => lerp(a[j], v, k)); b[0] = a[0] + dAz * k; b[2] += .7 * Math.sin(Math.PI * k); o = b;}
}
const f = flightAt(t);
return {az: o[0], el: o[1], d: o[2], tx: o[3] + f.pos.x * .8, ty: o[4] + f.pos.y * .8, tz: o[5] + f.pos.z * .8, sx: o[6], sy: o[7]};
};
const stateAt = (t) => {
const open = Object.fromEntries(ACTS.map((a) => [a, openOf(a, t)]));
const u = t - at('foot');
return {t, open, cap: open.cap, band: open.band, wrapper: open.wrapper, binder: open.binder, tripa: open.filler, foot: open.foot, ashDrop: prog(u, 1.0, 1.85) * (1 - prog(u, 2, 2.4)), ember: .3 + .7 * open.foot, explode: explodeAt(t), turn: turnAt(t), flight: flightAt(t), cam: camAt(t), view: VIEWS[viewIdx(t)].key, guides: 0};
};
const telemetry = (t, s) => {
const v = s.view, u = t - at(v);
const opacity = ACTS.includes(v) ? prog(u, .10, .40) * (1 - prog(u, 1.64, 1.88)) : v === 'exploded' ? prog(t, te + .12, te + .45) * (1 - prog(t, ta + .2, ta + .6)) : 0;
return {status: v === 'intro' ? 'Hand-rolled corona' : v === 'hero' ? 'Release' : v === 'exploded' ? (t >= ta ? 'Reassembly' : 'Whole-leaf teardown') : `${v.charAt(0).toUpperCase() + v.slice(1)} study`, freq: 0, stroke: [], lift: 0, battery: .85, servos: [], labelSet: {set: LABELS[v] ?? [], o: opacity}};
};
return {SCRIPT, DURATION: TL.duration, stateAt, telemetry, flightAt, camAt};
}
+66
View File
@@ -0,0 +1,66 @@
// Numerical companion to the rendered beat-sheet review. Does not mutate the scene source.
import {pathToFileURL} from 'node:url';
import path from 'node:path';
import {CHROMIUM, CHROMIUM_ARGS, DIST, playwright} from '../../paths.mjs';
const {chromium} = playwright();
const browser = await chromium.launch({executablePath: CHROMIUM, args: CHROMIUM_ARGS});
const page = await browser.newPage({viewport: {width: 1600, height: 900}, deviceScaleFactor: 1});
const errors = [];
page.on('pageerror', (e) => errors.push(e.message));
await page.addInitScript(() => {window.__CAPTURE = true; window.__SIM_CONFIG = {};});
await page.goto(pathToFileURL(path.join(DIST, 'cigar-film.html')).href);
await page.waitForFunction(() => window.SIM?.ready, null, {timeout: 60000});
const results = await page.evaluate(async () => {
const {bee, T, st} = window.CIGAR;
const rows = [];
const heroBounds = [];
const heroAnchors = [];
for (const t of [0, 21.8]) {
await window.SIM.render(t); bee.root.updateWorldMatrix(true, true);
const box = [Infinity, Infinity, -Infinity, -Infinity];
const bodyParts = ['Wrapper / fixed shoulder and back', 'CAP', 'BAND', 'Wrapper / upper shutter', 'Wrapper / lower shutter', 'BINDER', 'Binder / back'];
for (const part of bee.root.children.filter((g) => bodyParts.includes(g.name))) part.traverse((o) => {
if (!o.isMesh) return;
const p = bee.root.position.clone(), a = o.geometry.attributes.position;
for (let i = 0; i < a.count; i++) {
p.fromBufferAttribute(a, i).applyMatrix4(o.matrixWorld);
const q = st.project(p); if (!q) continue;
box[0] = Math.min(box[0], q[0]); box[1] = Math.min(box[1], q[1]);
box[2] = Math.max(box[2], q[0]); box[3] = Math.max(box[3], q[1]);
}
});
heroBounds.push({t, box: box.map(Math.round), viewportWidthShare: +((box[2] - box[0]) / 1070).toFixed(3), clearOfNavCards: box[0] > 248 && box[2] < 1340 && box[1] > 236 && box[3] < 836});
const points = {};
for (const key of ['CAP', 'BAND', 'WRAPPER']) {
const a = bee.anchors[key]; points[key] = st.project(a.obj.localToWorld(a.at.clone())).map(Math.round);
}
heroAnchors.push({t, points, margins: Object.values(points).every(([x, y]) => x >= 290 && x <= 1280 && y >= 276 && y <= 796)});
}
for (const t of [0, 4.2, 6.8, 9.3, 11.9, 14.4, 16.8, 19.3, 20.6, 21.6]) {
await window.SIM.render(t);
bee.root.updateWorldMatrix(true, true);
const s = T.stateAt(t), tel = T.telemetry(t, s);
const points = {};
for (const [key] of tel.labelSet.set) {
const a = bee.anchors[key], p = a.obj.localToWorld(a.at.clone());
points[key] = st.project(p)?.map((v) => Math.round(v));
}
rows.push({t, view: s.view, cam: [s.cam.az, s.cam.el, s.cam.d].map((v) => +v.toFixed(1)), open: +(s.open[s.view] ?? s.explode).toFixed(2), points});
}
const digest = async (t) => {
await window.SIM.render(t); bee.root.updateWorldMatrix(true, true);
const out = []; bee.root.traverse((o) => {if (o.isMesh) out.push(...o.matrixWorld.elements);}); return out;
};
const a = await digest(14.4); await digest(19.3); const b = await digest(14.4);
const deterministic = a.length === b.length && a.every((v, i) => v === b[i]);
let finite = true;
for (let t = 0; t <= 22; t += .25) {
const s = T.stateAt(t); bee.pose(s);
bee.root.traverse((o) => {for (const v of [...o.position.toArray(), ...o.quaternion.toArray(), ...o.scale.toArray()]) if (!Number.isFinite(v)) finite = false;});
}
const composition = heroAnchors.every((b) => b.margins);
return {deterministic, finite, composition, heroAnchors, heroBounds, rows};
});
console.log(JSON.stringify({errors, ...results}, null, 2));
await browser.close();
if (errors.length || !results.deterministic || !results.finite || !results.composition) process.exit(1);