Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(site): Little Red Riding Hood restaged, first cut of v2

yzr46172e745d5c
diff --git a/site/little-red-riding-hood/ch01/index.html b/site/little-red-riding-hood/ch01/index.html
index 3223f33..f047c53 100644
--- a/site/little-red-riding-hood/ch01/index.html
+++ b/site/little-red-riding-hood/ch01/index.html
@@ -64,6 +64,8 @@ const BEATS = [
[['m1-home', ['scene1', 'scene2']], ['m2-wolf', ['scene3', 'scene4', 'scene4w', 'scene5']],
['m3-chimney', ['scene6', 'scene7', 'scene8', 'scene9']], ['m4-ending', ['scene10', 'scene11']]]
.forEach(([n, beats]) => music(`audio/bgm/${n}.mp3`, beats, +(new URLSearchParams(location.search).get('bgm') || .6)));
+// The hush before "EAT you with!": the music fades out just before it and comes back with the rescue (scene 9).
+window.MUSIC_OFF = { scene8: t => t >= PRE8 + TIMINGS.scene8.parts.hush8 - .3 };
paperWarm(g => { redPuppet(g); motherPuppet(g); wolfPuppet(g); grandmaPuppet(g); woodcutterPuppet(g); door(g); smoke(g, 0, 0);
birdProp(g); butterflyProp(g); FLOWER_COLS.forEach(c => flowerProp(g, c)); cloudProp(g); sunProp(g); granCapProp(g); basketProp(g); });
boot();
diff --git a/site/little-red-riding-hood/ch01/scene1.js b/site/little-red-riding-hood/ch01/scene1.js
index 9c8bb3c..44fc06f 100644
--- a/site/little-red-riding-hood/ch01/scene1.js
+++ b/site/little-red-riding-hood/ch01/scene1.js
@@ -1,91 +1,188 @@
-/* scene1.js — home. */
+/* scene1.js — home. Down from the treetops to the cottage; on "a little girl who loved her red hooded cape" the door
+ opens and Red twirls out, cape flying, and ends facing us for her name. Mother comes to the door: "Take this…", an
+ insert of the basket (Red's hand lifts the cloth on "cake": cake and juice; she takes the handle on "to Grandma");
+ Mother close, Red's hood blurred in front of her; the path itself on "Stay on the path"; Mother's finger on "don't
+ talk to strangers!"; Red close (Mother's blurred head in front), "I promise!"; the wide, she skips off down the path
+ into the woods, Mother waving; a trunk wipes to scene 2. Beat clock = PRE1 + the scene-clip word times. */
'use strict';
-// The ground at the cottage door is y 790; puppets here are at scale .6 (Red about 245 px tall).
-const PRE1 = 1.5, DOOR = 6.75, OUT = 7.05, LAND = 8.25;
-const SC1 = t => PRE1 + TIMINGS.scene1.parts.s01b + t; // a moment in Mother's line
-const T13 = 8.9, GIVE = 9.15, REACH = 9.85, TAKE = 10.35;
-const T14 = SC1(5.25), T15 = PRE1 + TIMINGS.scene1.parts.s01c - .15, SC1c = t => PRE1 + TIMINGS.scene1.parts.s01c + t;
-// 1.6: Red turns round and walks off along the garden path toward the woods; the path climbs and narrows into the
-// distance, so she grows smaller as she goes. Mother waves from the door. A near tree trunk wipes to scene 2.
-const T16 = T15 + 1.5, TURN = T16 + .25, WALK = TURN + .4, WIPE = 23.55;
-const pathY = x => 806 - .05 * (x - 560), depth = x => .62 * (1 - .32 * Math.min(1, Math.max(0, (x - 830) / 970)));
+const PRE1 = 2.4;
+// The ground at the cottage door is y 790; puppets here are at scale .6 (Red about 245 px tall). Past the gate the path
+// climbs and narrows into the distance, so she grows smaller as she goes.
+const s1_pathY = x => 806 - .05 * (x - 560), s1_depth = x => .62 * (1 - .32 * Math.min(1, Math.max(0, (x - 830) / 970)));
// A raised finger that wags on twos while she says the words between a and b.
-const wag = (q, a, b) => q > a && q < b ? 9 * (Math.floor(q * FPS / 2) % 2 ? 1 : -1) : 0;
-const footY = (gy, s) => gy - 170 * s; // hip height for feet on the ground line gy
-function door(parent) {
+const s1_wag = (q, a, b) => q > a && q < b ? 9 * onTwos(q) : 0;
+const s1_footY = (gy, s) => gy - 170 * s; // hip height for feet on the ground line gy
+// A whole-body turn from a to b over four frames, through a thin squash (never quite 0).
+const s1_turn = (q, t0, a, b) => { const v = tween(q, t0, 4 / FPS, a, b); return Math.abs(v) < .12 ? .12 * Math.sign(b) : v; };
+// For the basket insert: an arm that reaches in from off frame. The hand is at the origin and the arm runs back along
+// -x; place(hx, hy, sx, sy, k) puts the hand at (hx, hy) with the arm pointing back to the shoulder (sx, sy) off frame, k its size.
+function s1_arm(parent, sleeve, skin, cape = '') {
+ const g = mk('g', {}, parent);
+ prop(g, `<g filter="url(#paper)"><rect x="-1400" y="-40" width="1010" height="80" rx="34" fill="${sleeve}"/>${cape ? `<path d="M-1400,-60 L-720,-60 Q-650,0 -720,60 L-1400,60 Z" fill="${cape}"/>` : ''}</g>
+ <g filter="url(#paper)"><rect x="-430" y="-31" width="430" height="62" rx="28" fill="${skin}"/><circle r="46" fill="${skin}"/>
+ <ellipse cx="-6" cy="-42" rx="17" ry="26" transform="rotate(-28,-6,-42)" fill="${skin}"/></g>`);
+ return (hx, hy, sx, sy, k = 1) => tf(g, `translate(${hx.toFixed(1)},${hy.toFixed(1)}) rotate(${(Math.atan2(hy - sy, hx - sx) * 180 / Math.PI).toFixed(1)}) scale(${k})`);
+}
+// A point (x, y) turned by deg (clockwise on screen) about (cx, cy).
+const s1_rot = (x, y, cx, cy, deg) => { const a = deg * Math.PI / 180, c = Math.cos(a), s = Math.sin(a); return [cx + (x - cx) * c - (y - cy) * s, cy + (x - cx) * s + (y - cy) * c]; };
+// The cottage door, swinging open on its hinge at t0. (index.html's paperWarm builds one to bake it: keep the name.)
+function door(parent, t0 = 0) {
const g = mk('g', {}, parent);
g.innerHTML = `<g filter="url(#paper)"><path d="M606,790 L606,476 Q675,424 744,476 L744,790 Z" fill="#8a5a32"/>
<path d="M640,450 V790 M675,436 V790 M710,450 V790" stroke="#6e4426" stroke-width="3"/>
<path d="M606,530 h70 M606,720 h70" stroke="#3b2a1e" stroke-width="9"/><circle cx="726" cy="630" r="7" fill="#caa24c"/></g>`;
bakeAll(g);
const open = [1, .7, .3, -.1, -.4, -.55];
- return q => { const k = Math.floor((q - DOOR) * FPS); tf(g, `translate(606,0) scale(${k < 0 ? 1 : open[Math.min(k, open.length - 1)]},1) translate(-606,0)`); };
+ return q => { const k = Math.floor((q - t0) * FPS); tf(g, `translate(606,0) scale(${k < 0 ? 1 : open[Math.min(k, open.length - 1)]},1) translate(-606,0)`); };
}
+
function scene1(p, D) {
- // 1.1 from the treetops down to the cottage, then a slow push toward the door
+ const P = PRE1, T = (c, t = 0) => clipAt('scene1', P, c, t);
+ // Times on the beat clock. s01 starts the scene clip, so its word times are used as they are; s01b's are written
+ // (word time − 8.83) and s01c's (word time − 16.3), the clips' starts in narration.en.words.txt.
+ const DOOR = T('s01', 1.7), OUT = T('s01', 2.3), LAND = T('s01', 3.95); // "a little girl who loved her red hooded cape": she twirls out
+ const MED = T('s01', 5.4), NAME = T('s01', 6.56), HOOD = T('s01', 7.72); // "everyone called her Little Red Riding Hood": Red to us
+ const MOM = T('s01', 7.2); // Mother comes to the door behind her
+ const TWO = T('s01', 8.4), GIVE = T('s01b'); // "Take this": the basket held out
+ const INS = T('s01b', 9.1 - 8.83), CAKE = T('s01b', 9.21 - 8.83), TOGRAN = T('s01b', 10.27 - 8.83); // insert: the basket
+ const CU = T('s01b', 11.2 - 8.83), WELL = T('s01b', 11.49 - 8.83), FINGER = T('s01b', 12.45 - 8.83); // Mother close
+ const PATH = T('s01b', 13.02 - 8.83); // "Stay on the path": the path
+ const DONT = T('s01b', 14.0 - 8.83), TALK = T('s01b', 14.13 - 8.83), STR = T('s01b', 15.03 - 8.83); // "don't talk to strangers!"
+ const RED = T('s01c', -.12), PROM = T('s01c', 16.46 - 16.3); // "I promise!"
+ const WIDE = T('s01c', 17.62 - 16.3), TURN = WIDE + .3, WALK = TURN + .45; // she skips off (the walk1 hole)
+ const WIPE = D - .85, WP = .78, WA = 28; // her skip: period and stride
+
+ // ---- cameras ----
const cam = paperCam(p, 'home', { x: 800, y: -260, z: 1 });
- cam.to({ y: 450 }, .4, 3.2).to({ x: 690, y: 560, z: 1.45 }, 3.8, 2.8);
- // 1.2 medium on the door: it swings open and Red spins out into the garden, ending turned back toward the house
- cam.cut({ x: 745, y: 640, z: 2 }, 6.6);
- // 1.3 two-shot: Mother steps into the doorway and hands Red the basket
- cam.cut({ x: 760, y: 600, z: 1.7 }, T13);
- // 1.4 Mother close, facing us, finger raised; 1.5 Red close, nodding hard. Each is alone in her close-up.
- cam.cut({ x: 708, y: 552, z: 4.4 }, T14).soft(T14, true);
- // The reverse angle for Red's close-up: from the doorway out over the garden, so a second camera on its own set,
- // with Red drawn large in it instead of zooming.
+ cam.to({ y: 450 }, .2, 2.3).to({ x: 700, y: 585, z: 1.45 }, 2.5, DOOR + .2 - 2.5) // down from the treetops, in toward the door
+ .to({ x: 735, y: 595, z: 1.6 }, DOOR + .2, MED - DOOR - .2) // a slow drift in as she twirls
+ .cut({ x: 815, y: 612, z: 2.6 }, MED).to({ x: 812, y: 608, z: 2.75 }, MED, TWO - MED) // Red, medium, to us
+ .cut({ x: 760, y: 610, z: 1.9 }, TWO) // the two of them at the door
+ .cut({ x: 1120, y: 600, z: 3 }, INS) // the insert's blurred wall
+ .cut({ x: 745, y: 566, z: 3.4 }, CU).to({ x: 742, y: 562, z: 3.5 }, CU, PATH - CU) // Mother close
+ .cut({ x: 742, y: 562, z: 3.5 }, DONT) // Mother's finger
+ .cut({ x: 1000, y: 470, z: 1 }, WIDE).to({ x: 1200 }, WALK + .3, 3); // the wide: off she goes
+ cam.soft(MED, true).soft(TWO, false).soft(INS, 'all').soft(CU, true).soft(WIDE, false);
+ // "Stay on the path": the path itself, where it bends into the trees by the meadow (the very place she will leave it
+ // in scene 4; the home set's path is too thin to read). A camera of its own on the meadow set.
+ const path = paperCam(p, 'meadow', { x: 1020, y: 650, z: 1.5 }).to({ x: 1120, y: 630, z: 1.7 }, PATH, DONT - PATH);
+ // The reverse for Red's close-up: from the doorway out over the garden, Red drawn large on a camera of its own.
const out = paperCam(p, 'homeOut').soft(0, 'all'), redOut = redPuppet(out.stage);
- cam.cut({ x: 1000, y: 470, z: 1 }, T16).soft(T16, false).to({ x: 1140 }, WALK + .3, 3);
+ // Listeners in front of the close-ups, out of focus: Mother's head in Red's, Red's hood in Mother's.
+ mk('defs', {}, p).innerHTML = '<filter id="s1_blur" x="-20%" y="-20%" width="140%" height="140%"><feGaussianBlur stdDeviation="9"/></filter>';
+ const momFgG = mk('g', { filter: 'url(#s1_blur)' }, out.stage), momFg = motherPuppet(momFgG);
+ const fg = mk('g', { filter: 'url(#s1_blur)' }, p), redFg = redPuppet(fg);
+ // The insert: the basket between Mother's hand (left) and Red's (right), in frame coordinates over the blurred wall.
+ const ins = mk('g', {}, p), bw = mk('g', {}, ins), bk = basketProp(bw), cloth = bk.g.firstChild;
+ bk.g.appendChild(cloth); // the prop draws its cloth behind the cake and bottle; here it lies over them until lifted
+ const momHand = s1_arm(ins, '#f4efe2', '#f2c9a6'), redHand = s1_arm(ins, '#f4efe2', '#f6d2b5', '#c8322f');
const wipe = trunkWipe(p, WIPE, D - WIPE - .05);
- const puffs = smoke(cam.stage, 932, 84), theDoor = door(cam.stage), mom = motherPuppet(cam.stage), red = redPuppet(cam.stage);
+ const puffs = smoke(cam.stage, 932, 84), theDoor = door(cam.stage, DOOR), mom = motherPuppet(cam.stage), red = redPuppet(cam.stage);
+
+ // ---- sound ----
+ sfx('scene1', 0, 'forest', .4); // the garden's birds and leaves (shared.js lays it again every 9.5 s)
+ sfx('scene1', DOOR, 'creak', 1.1); sfx('scene1', OUT + .25, 'whoosh', .5); sfx('scene1', LAND, 'step2', .7);
+ sfx('scene1', CAKE + .2, 'whoosh', .3);
+ for (let k = 0, t; (t = WALK + WP * (.25 + .5 * k)) < WIPE + .2; k++) sfx('scene1', +t.toFixed(2), 'step' + (1 + k % 3), .7 - .05 * k);
+
stopClock(D, (q, f) => {
- const reverse = q >= T15 && q < T15 + 1.5;
- vis(cam.root, !reverse); vis(out.root, reverse);
- if (reverse) {
+ const redCU = between(q, RED, WIDE), momCU = between(q, CU, PATH) || between(q, DONT, RED), insert = between(q, INS, CU);
+ const pathShot = between(q, PATH, DONT);
+ vis(cam.root, !redCU && !pathShot); vis(out.root, redCU); vis(path.root, pathShot);
+ vis(fg, momCU); vis(ins, insert);
+ if (pathShot) { path.apply(q, f); return; }
+ const breath = k => Math.sin((q + k) * 2 * Math.PI / 3);
+
+ // ---- Red's close-up: "I promise!", two nods; Mother's blurred head at the left ----
+ if (redCU) {
out.apply(q, f);
- redOut.pose({ x: 800, y: 430 + 194 * 2.88, s: 2.88, head: 'F', mouth: mouthAt('s01c', q - SC1c(0)), shut: blinking(q, [19.4]),
- nod: [.1, .45].some(t => q >= SC1c(t) && q < SC1c(t) + 2 / FPS) ? 22 : 0, rua: 4, rfa: -2 }, f);
+ const nod = [0, PROM - RED - .12 + .2].reduce((n, t) => n + 20 * Math.sin(Math.PI * Math.min(1, Math.max(0, (q - RED - .12 - t) / .3))), 0);
+ redOut.pose({ x: 930, y: 1000 + 3 * breath(0), s: 2.88, head: 'F', nod, headR: -3 + 2 * breath(.5), mouth: lips(q, 'scene1', P, 's01c'),
+ shut: blinking(q, [RED + .9]), rua: 4, rfa: -2, lua: -4, lfa: 2 }, f);
+ momFg.pose({ x: 120, y: 1290 + 4 * breath(1), s: 3.6, turn: 1, headR: 4, shut: false }, f);
return;
}
cam.apply(q, f); puffs(q); theDoor(q); wipe(q);
- vis(mom.g, q >= T13);
- const held = q < TAKE, sm = .6;
- mom.pose({
- x: 690, y: 790 - 212 * sm, s: sm,
- ua: q < TAKE ? tween(q, GIVE, .45, 6, -45) : tween(q, TAKE + .15, .5, -45, 6),
- fa: q < TAKE ? tween(q, GIVE, .45, -6, -15) : tween(q, TAKE + .15, .5, -15, -6),
- finger: q >= T14 && q < T15, head: q >= T14 && q < T15 ? 'F' : 'P',
- rua: -28, rfa: -146 + wag(q, SC1(5.4), SC1(6.1)) + wag(q, SC1(6.7), SC1(7.9)), lua: 40, lfa: -58,
- basket: held, swing: held ? 6 * Math.exp(-(q - GIVE) * 2.5) * Math.sin((q - GIVE) * 9) * (q > GIVE) : 0,
- brow: q < T14 ? span(q, SC1(3.0), SC1(3.3)) : -.7 * span(q, SC1(6.6), SC1(6.8)), headR: q < T14 ? 4 * span(q, SC1(3.0), SC1(3.3)) : -3 * span(q, SC1(6.6), SC1(6.8)),
- mouth: mouthAt('s01b', q - SC1(0)), shut: blinking(q, [11.4, 15.6, 22.4]),
- ...(q >= TURN + .2 ? { ua: -118, fa: -30 + (Math.floor(q * FPS / 2) % 2 ? 22 : -22) } : {}), // waving on twos
- }, f);
+ // ---- the insert: Red's hand lifts the cloth on "cake", takes the handle on "to Grandma", Mother lets go ----
+ if (insert) {
+ const BX = 800, BY = 885, S = 2.1, K = S / 1.5, at = (x, y) => [BX + x * S, BY + y * S];
+ tf(ins, `translate(800,450) scale(${(1 + .07 * span(q, INS, CU)).toFixed(4)}) translate(-800,-450)`); // a slow push in
+ const lift = span(q, CAKE + .12, CAKE + .55), theta = 40 * lift, CX = 150 * lift, CY = 70 * lift; // the cloth slides off over the right rim
+ bk.pose(BX, BY, S, 0);
+ tf(cloth, `translate(${CX.toFixed(1)},${CY.toFixed(1)}) rotate(${theta.toFixed(1)},138,-150)`);
+ const [mx, my] = at(-26, -236), [gx, gy] = at(35, -235); // on the handle's top, where it shows over the cake
+ const pinch = s1_rot(0, -262, 138, -150, theta), [cx, cy] = at(pinch[0] + CX, pinch[1] + CY);
+ // Red's hand: in to the cloth, lifts it, then across to the handle
+ const RS = [1900, -150];
+ let rx, ry;
+ if (q < CAKE + .12) { const u = span(q, INS - .05, CAKE + .12); rx = RS[0] + (cx - RS[0]) * u; ry = RS[1] + (cy - RS[1]) * u; }
+ else if (q < CAKE + .75) { rx = cx; ry = cy; }
+ else { const u = span(q, CAKE + .75, TOGRAN + .05); rx = cx + (gx - cx) * u; ry = cy + (gy - cy) * u; }
+ // once she has it, she lifts it a little and it swings from her hand
+ const up = span(q, TOGRAN + .35, TOGRAN + .75), sw = 6 * Math.exp(-Math.max(0, q - TOGRAN - .5) * 2.5) * Math.sin(Math.max(0, q - TOGRAN - .5) * 9) * (q > TOGRAN + .5);
+ const lx = 30 * up, ly = -45 * up;
+ tf(bw, `translate(${lx.toFixed(1)},${ly.toFixed(1)}) rotate(${sw.toFixed(2)},${gx.toFixed(1)},${gy.toFixed(1)})`);
+ redHand(rx + (q > TOGRAN ? lx : 0) + jit(f, 41), ry + (q > TOGRAN ? ly : 0) + jit(f, 42), 1750, -400, K);
+ // Mother's hand holds the handle until Red has it, then slides away up and out
+ const away = span(q, TOGRAN + .25, TOGRAN + .65), MS = [-250, -350];
+ const bob = 5 * Math.sin((q - INS) * 3) * (1 - away);
+ momHand(mx + (MS[0] + 200 - mx) * away + jit(f, 43), my + bob + (MS[1] + 100 - my) * away + jit(f, 44), MS[0], MS[1], K);
+ if (q < TOGRAN + .35) tf(bw, `translate(0,${bob.toFixed(1)})`);
+ }
- vis(red.g, q >= DOOR + .25 && !(q >= T14 && q < T15));
- const u = Math.min(1, Math.max(0, (q - OUT) / (LAND - OUT))), after = Math.max(0, q - LAND), s = .6 + .02 * u;
- const settle = Math.exp(-after * 3) * Math.sin(after * 10), spinning = u > 0 && u < 1;
- const sinceTake = Math.max(0, q - TAKE), sway = 7 * Math.exp(-sinceTake * 2.2) * Math.sin(sinceTake * 8);
- if (q >= T16) { // 1.6
- const w = walk(q - WALK, { period: .85, A: 26 }), xs = 830 + w.d * .5, sr = depth(xs), x = 830 + w.d * sr;
- const tw = Math.min(1, Math.max(0, (q - TURN) / .35)), walking = q > WALK;
- red.pose({ x, y: pathY(x) - (170 - w.drop) * sr, s: sr, turn: -Math.cos(Math.PI * tw),
- near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: walking ? 3 + 3 * Math.sin(2 * w.ph + .6) : 3,
- ua: walking ? -8 + 6 * Math.sin(w.ph) : -8, fa: -78, swing: walking ? 9 * Math.sin(w.ph - 1) : 0,
- headR: walking ? 2 * Math.sin(2 * w.ph) : 0, shut: blinking(q, [21.6]) }, f);
+ // ---- Red's hood, blurred, in front of Mother's close-up ----
+ if (momCU) redFg.pose({ x: 1565, y: 1500 + 5 * breath(.3), s: 4.5, turn: -1, basket: true, headR: q < DONT ? 5 * span(q, WELL, WELL + .4) : 2, cape: 3, shut: false }, f);
+
+ // ---- Mother ----
+ vis(mom.g, q >= MOM && !insert);
+ const sm = .6, front = momCU;
+ let ua = 6, fa = -6, basket = q < INS;
+ if (q >= GIVE && q < INS + .1) ua = tween(q, GIVE, .4, 6, -45), fa = tween(q, GIVE, .4, -6, -15); // the basket held out
+ let rua = 6, rfa = -4, brow = 0, headR = 0, finger = false;
+ if (front) {
+ brow = q < FINGER ? .7 * span(q, WELL, WELL + .3) : -.7; // sad for Grandma, then firm
+ headR = q < FINGER ? 5 * span(q, WELL, WELL + .3) : -2 * span(q, FINGER, FINGER + .3);
+ const up = span(q, FINGER, FINGER + .3);
+ rua = 6 - 34 * up; rfa = -4 - 142 * up + s1_wag(q, TALK, TALK + .7) + s1_wag(q, STR, STR + .8); finger = up > .5;
+ }
+ let wave = {};
+ if (q >= TURN + .2) wave = { ua: -118, fa: -30 + 22 * onTwos(q) }; // waving her off, on twos
+ mom.pose({ x: q < MOM + .4 ? tween(q, MOM, .4, 650, 690) : 690, y: 790 - 212 * sm + (front ? .8 * breath(.2) : 0), s: sm, head: front ? 'F' : 'P',
+ ua, fa, basket, swing: basket ? 6 * Math.exp(-Math.max(0, q - GIVE) * 2.5) * Math.sin((q - GIVE) * 9) * (q > GIVE) : 0,
+ rua, rfa, lua: -6, lfa: 4, finger, brow, headR,
+ mouth: lips(q, 'scene1', P, 's01b'), shut: blinking(q, [MOM + .9, TWO + .4, CU + .2, DONT + 1.0, WIDE + .6, WIDE + 2.4]), ...wave }, f);
+
+ // ---- Red ----
+ vis(red.g, q >= DOOR + .2 && !insert && !momCU && !between(q, PATH, DONT));
+ if (q >= WIDE) { // she turns to the path and skips off along it
+ const w = walk(q - WALK, { period: WP, A: WA }), xs = 830 + w.d * .5, sr = s1_depth(xs), x = 830 + w.d * sr, walking = q > WALK;
+ red.pose({ x, y: s1_pathY(x) - (170 - w.drop) * sr - (walking ? 10 * sr * Math.abs(Math.cos(w.ph)) : 0), s: sr,
+ turn: s1_turn(q, TURN, -1, 1), near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
+ cape: walking ? 4 + 5 * Math.sin(2 * w.ph + .6) : 3, ua: walking ? -8 + 8 * Math.sin(w.ph) : -8, fa: -78, swing: walking ? 10 * Math.sin(w.ph - 1) : 0,
+ headR: walking ? 2 * Math.sin(2 * w.ph) : 0, shut: blinking(q, [WIDE + 1.6]) }, f);
return;
}
+ if (q >= TWO) { // turned to Mother (on the cut): looks at the basket, reaches for it
+ const reach = span(q, GIVE + .1, GIVE + .45);
+ red.pose({ x: 830, y: s1_footY(800, .62) + breath(0), s: .62, turn: -1, basket: false, headR: 4 * span(q, GIVE, GIVE + .2),
+ ua: -8 - 60 * reach, fa: -78 + 58 * reach, shut: blinking(q, [TWO + .25]) }, f);
+ return;
+ }
+ // out of the door in a twirl (one and a quarter turns), landing to face us
+ const u = Math.min(1, Math.max(0, (q - OUT) / (LAND - OUT))), after = Math.max(0, q - LAND), s = .6 + .02 * u;
+ const settle = Math.exp(-after * 3) * Math.sin(after * 10), spinning = u > 0 && u < 1, landed = u >= 1;
+ const arms = landed ? span(q, NAME, NAME + .3) * (1 - span(q, HOOD + .5, HOOD + .8)) : 0; // arms out for her name
+ const dip = 10 * Math.sin(Math.PI * span(q, HOOD, HOOD + .45)); // a little curtsy on "Hood"
red.pose({
- x: 675 + 155 * ease(u), y: footY(790 + 10 * u, s) - 16 * Math.abs(Math.sin(Math.PI * 3 * u)), s,
- turn: Math.cos(Math.PI * 3 * ease(u)), // one and a half turns: she ends facing the door
- near: 12 * Math.sin(6 * Math.PI * u), far: -12 * Math.sin(6 * Math.PI * u),
- kNear: 22 * Math.abs(Math.sin(3 * Math.PI * u)), kFar: 14 * Math.abs(Math.sin(3 * Math.PI * u + 1)),
- cape: 3 + 30 * Math.sin(Math.PI * u) + 6 * settle,
- ua: spinning ? -8 - 62 * Math.sin(Math.PI * u) : q < TAKE ? tween(q, REACH, .4, 4 + 4 * settle, -70) : tween(q, TAKE + .05, .5, -70, -8),
- fa: spinning ? -24 : q < TAKE ? tween(q, REACH, .4, -10, -20) : tween(q, TAKE + .05, .5, -20, -78),
- basket: !held, swing: sway,
- headR: spinning ? 0 : -2 * settle - 3 * span(q, SC1(3.2), SC1(3.5)) + 3 * span(q, T15, T15 + .2), shut: blinking(q, [9.6, 13.9, 19.4]),
-
+ x: 675 + 155 * ease(u), y: s1_footY(790 + 10 * u, s) - 16 * Math.abs(Math.sin(Math.PI * 2.5 * u)) + dip + (landed ? breath(0) : 0), s,
+ turn: Math.cos(Math.PI * 2.5 * ease(u)), head: landed ? 'F' : 'P', basket: false,
+ near: 12 * Math.sin(5 * Math.PI * u), far: -12 * Math.sin(5 * Math.PI * u),
+ kNear: 22 * Math.abs(Math.sin(2.5 * Math.PI * u)), kFar: 14 * Math.abs(Math.sin(2.5 * Math.PI * u + 1)),
+ cape: 3 + 34 * Math.sin(Math.PI * u) + 6 * settle,
+ ua: spinning ? -8 - 62 * Math.sin(Math.PI * u) : -8, fa: spinning ? -24 : -78,
+ rua: 6 - 44 * arms + 3 * settle, rfa: -4 - 20 * arms, lua: -6 + 44 * arms - 3 * settle, lfa: 4 + 20 * arms,
+ headR: landed ? 4 * Math.sin((q - LAND) * 2.2) - 2 * settle : 0, shut: blinking(q, [LAND + .7, MED + 1.3, HOOD + 1.0]),
}, f);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene10.js b/site/little-red-riding-hood/ch01/scene10.js
index 224b567..34977e5 100644
--- a/site/little-red-riding-hood/ch01/scene10.js
+++ b/site/little-red-riding-hood/ch01/scene10.js
@@ -1,28 +1,82 @@
-/* scene10.js — away into the woods. */
+/* scene10.js — away into the woods, still in the nightcap. */
'use strict';
-const PRE10 = .3;
+const PRE10 = 1.0; // the wolf lands under the broken window and is off before the woodcutter shouts
function scene10(p, D) {
- const C = (c, t) => clipAt('scene10', PRE10, c, t);
- const cam = paperCam(p, 'grandmaOut', { x: 1750, y: 470, z: 1 }, { after: 'house', stages: ['inside'] });
- // the window he went through: the room redrawn over the set's cross bars, the woodcutter seen only through the hole,
- // jagged glass left in the frame and a few shards on the grass below
- mk('rect', { x: 1300, y: 520, width: 160, height: 120 }, mk('clipPath', { id: 'pane10' }, cam.stage));
- const pane = mk('g', { 'clip-path': 'url(#pane10)' }, cam.stage);
+ const C = (c, t) => clipAt('scene10', PRE10, c, t), LAND = .32, FOLLOW = C('s10b', -.05), FAR = C('run10', -.12);
+ // 10.1 outside: glass still falling, the wolf drops onto the grass and bolts right; 10.2 close on the woodcutter in
+ // the broken window, fist shaking ("And don't come back…"); 10.3 a close running follow in the woods, pushing in on
+ // the nightcap on "never even took off the nightcap"; 10.4 the wolf tiny on the far path, the cap tail still flapping.
+ const out = paperCam(p, 'grandmaOut', { x: 1460, y: 640, z: 1.9 }, { after: 'house', stages: ['inside'] });
+ out.cut({ x: 1386, y: 590, z: 3.0 }, C('s10', -.12)).to({ x: 1392, y: 586, z: 3.4 }, C('s10', .3), 2.1).cut({ x: 2650, y: 640, z: 2.4 }, FAR);
+ // the window he went through: the room redrawn over the set's cross bars, the woodcutter seen only through the hole
+ mk('rect', { x: 1300, y: 520, width: 160, height: 120 }, mk('clipPath', { id: 's10_pane' }, out.stage));
+ const pane = mk('g', { 'clip-path': 'url(#s10_pane)' }, out.stage);
prop(pane, '<g filter="url(#paper)"><rect x="1296" y="516" width="168" height="44" fill="#6e4a30"/><rect x="1296" y="560" width="168" height="84" fill="#5a3a24"/></g>');
const wood = woodcutterPuppet(pane);
- prop(cam.stage, `<path d="M1300,520 L1346,520 L1312,556 L1300,546 Z M1460,520 L1412,520 L1442,538 L1460,572 Z M1300,640 L1300,598 L1318,620 L1338,640 Z M1460,640 L1420,640 L1440,620 L1460,600 Z"
+ prop(out.stage, `<path d="M1300,520 L1346,520 L1312,556 L1300,546 Z M1460,520 L1412,520 L1442,538 L1460,572 Z M1300,640 L1300,598 L1318,620 L1338,640 Z M1460,640 L1420,640 L1440,620 L1460,600 Z"
fill="#e8f4f6" stroke="#ffffff" stroke-width="2" opacity=".85"/>
- <g filter="url(#paper)" fill="#6e4a30"><path d="M1376,520 h8 v22 l-5,7 l-3,-6 Z M1376,640 h8 v-24 l-4,-7 l-4,9 Z M1300,577 v7 h20 l6,-3 l-8,-4 Z M1460,577 v7 h-18 l-5,-4 l6,-3 Z"/></g>
- ${[[1312, 812, 30], [1340, 820, -20], [1371, 808, 60], [1398, 818, 10], [1430, 811, -45], [1452, 822, 80]].map(([x, y, r]) =>
- `<path d="M0,-8 L6,6 L-6,4 Z" fill="#e8f4f6" stroke="#ffffff" stroke-width="1.5" transform="translate(${x},${y}) rotate(${r}) scale(1.4)"/>`).join('')}`);
- const wolf = wolfPuppet(cam.stage), wipe = trunkWipe(p, D - .7, .65); // time passes: to the table
- cam.to({ x: 2560, y: 640, z: 2.4 }, C('s10b', 0), 3.4);
+ <g filter="url(#paper)" fill="#6e4a30"><path d="M1376,520 h8 v22 l-5,7 l-3,-6 Z M1376,640 h8 v-24 l-4,-7 l-4,9 Z M1300,577 v7 h20 l6,-3 l-8,-4 Z M1460,577 v7 h-18 l-5,-4 l6,-3 Z"/></g>`);
+ // shards: the last of the glass falling from the sill onto the grass (they land and lie there)
+ const shards = [[1312, 30, .00], [1340, -20, .06], [1371, 60, .02], [1398, 10, .1], [1430, -45, .04], [1452, 80, .12], [1388, 120, .16]].map(([x, r, d], i) => ({
+ x, r, d, gy: 806 + (i * 7) % 18, el: prop(out.stage, '<path d="M0,-8 L6,6 L-6,4 Z" fill="#e8f4f6" stroke="#ffffff" stroke-width="1.5"/>') }));
+ const wolfOut = wolfPuppet(out.stage);
+ // the woods: one long camera that rides with him
+ const woods = paperCam(p, 'forest', { x: 900, y: 600, z: 2.1 });
+ // speed lines behind him (paper strips, built first so they pass behind him), on twos
+ const lines = prop(woods.stage, [0, 1, 2, 3].map(i => `<rect x="${-170 - i * 34}" y="${-100 + i * 40}" width="${150 - i * 18}" height="7" rx="3.5" fill="#f6efe0" opacity=".75"/>`).join(''));
+ const wolf = wolfPuppet(woods.stage), WS = .8, WX0 = 700, SPEED = 470;
+ const wx = q => WX0 + SPEED * Math.max(0, q - FOLLOW + .3);
+ woods.to({ x: q => wx(q) + 150, y: 600, z: 2.1 }, FOLLOW, .001)
+ .to({ x: q => wx(q) + 85, y: hipOn(WOODS, WS, 200) - 50, z: 3.3 }, C('s10b', 1.75), 1.3); // into his head for "nightcap"
+ const wipe = trunkWipe(p, D - .4, .5); // time passes: to the table
const backPath = x => 808 - (x - 1380) * 116 / 1620, far = x => .6 * (1 - .78 * Math.min(1, (x - 1380) / 1620));
+
+ sfx('scene10', 0, 'forest', .5, 10);
+ sfx('scene10', .05, 'tinkle', 1.4); sfx('scene10', LAND, 'thud', 1.2); sfx('scene10', LAND + .02, 'tinkle', .7);
+ for (let t = LAND + .3; t < C('s10', .8); t += .44) sfx('scene10', +t.toFixed(2), 'run', 1.1 - .25 * (t - LAND));
+ sfx('scene10', FOLLOW, 'whoosh', 1.4);
+ for (let t = FOLLOW; t < FAR - .1; t += .44) sfx('scene10', +t.toFixed(2), 'run', 1.4);
+ for (let t = FAR; t < D; t += .44) sfx('scene10', +t.toFixed(2), 'run', .35);
+
stopClock(D, (q, f) => {
- cam.apply(q, f); wipe(q);
- const w = walk(Math.max(0, q - .25), { L: 196, A: 28, period: .48, knee: 60 }), xs = 1420 + w.d * .3, s = far(xs), x = 1420 + w.d * s;
- wolf.pose({ x, y: backPath(x) - (200 - w.drop) * s - (q < .25 ? 20 * (1 - q / .25) : 0), s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
- lean: 26, ua: -30 + 45 * Math.sin(w.ph), fa: -40, tail: -25 + 6 * Math.sin(2 * w.ph), cap: 'off', night: true, jaw: .4 }, f);
- wood.pose({ x: 1372, y: 560 + 224 * .62, s: .62, axe: false, ua: -150, fa: -20 + 14 * onTwos(q), brow: -1, mouth: lips(q, 'scene10', PRE10, 's10'), shut: blinking(q, [C('s10b', .8)]) }, f);
+ const inWoods = q >= FOLLOW && q < FAR;
+ vis(out.root, !inWoods); vis(woods.root, inWoods);
+ if (inWoods) woods.apply(q, f); else out.apply(q, f);
+ wipe(q);
+ const flap = 38 * onTwos(q);
+ // shards fall from the sill (y 640) with gravity, then lie still
+ for (const s of shards) {
+ const u = Math.max(0, q - s.d), y = Math.min(s.gy, 640 + 40 * u + .5 * 2200 * u * u);
+ tf(s.el, `translate(${s.x + 30 * Math.min(u, .4)},${y.toFixed(1)}) rotate(${s.r + (y < s.gy ? 500 * u : 0)}) scale(1.4)`);
+ }
+ if (!inWoods) {
+ if (q < FAR) {
+ // the wolf out of the window: falling, a crouch on landing, then a gallop out of frame right
+ const s = .62, gy = hipOn(812, s, 200);
+ if (q < LAND) {
+ const u = q / LAND;
+ wolfOut.pose({ x: 1430 + 90 * u, y: gy - 120 * (1 - u * u), s, run: 0, stretch: 1 - u, cap: 'off', night: true, flap, headR: 10 - 20 * u, brow: 1, mouth: 'D' }, f);
+ } else {
+ const t = q - LAND - .25, x = 1520 + (t > 0 ? 260 * t + 300 * t * t : 0);
+ wolfOut.pose({ x, y: gy, s, run: (x - 1520) / s, crouch: t < 0 ? 1 - (q - LAND) / .25 * .6 : 0, cap: 'off', night: true, flap, tail: -20, brow: 1, mouth: 'D', look: -1 }, f);
+ }
+ } else {
+ // far down the back path, receding: tiny, the cap tail flapping
+ const x = 2600 + 150 * (q - FAR), s = far(x);
+ wolfOut.pose({ x, y: backPath(x) - 200 * s, s, run: (x - 2000) / s, cap: 'off', night: true, flap: 1.4 * flap, tail: -20, mouth: 'D' }, f);
+ }
+ // the woodcutter rises into the window, then shakes his fist after the wolf
+ const up = span(q, .45, .8), shout = between(q, C('s10', 0), C('s10', 2.5));
+ wood.pose({ x: 1372, y: 712 + 130 * (1 - up), s: .62, axe: false, ua: -132 + 6 * (shout ? onTwos(q) : 0), fa: shout ? -30 + 22 * onTwos(q) : -40,
+ brow: -1, headR: shout ? -4 : 0, mouth: lips(q, 'scene10', PRE10, 's10'), shut: blinking(q, [.95, C('s10', 1.9)]) }, f);
+ } else {
+ const x = wx(q), u = Math.max(0, q - FOLLOW + .3);
+ wolf.pose({ x, y: hipOn(WOODS, WS, 200), s: WS, run: (x - WX0) / WS, lean: 0, cap: 'off', night: true, flap,
+ tail: -14 + 8 * onTwos(q), ear: -1, brow: 1, mouth: 'D', jaw: .55 + .15 * onTwos(q),
+ look: between(q, C('s10b', 2.2), C('s10b', 2.9)) ? -1 : 1, headR: between(q, C('s10b', 2.2), C('s10b', 2.9)) ? -8 : 0,
+ shut: blinking(q, [C('s10b', .9), C('s10b', 3.6)]) }, f);
+ tf(lines, `translate(${(x + (onTwos(q) > 0 ? 0 : -30)).toFixed(1)},${(hipOn(WOODS, WS, 200) + 10).toFixed(1)})`);
+ vis(lines, u > .2);
+ }
});
}
diff --git a/site/little-red-riding-hood/ch01/scene11.js b/site/little-red-riding-hood/ch01/scene11.js
index d34e89a..072b359 100644
--- a/site/little-red-riding-hood/ch01/scene11.js
+++ b/site/little-red-riding-hood/ch01/scene11.js
@@ -1,24 +1,91 @@
-/* scene11.js — cake. */
+/* scene11.js — cake, juice, the moral and a wink. */
'use strict';
-const PRE11 = .8;
+const PRE11 = 1.4; // the trunk wipe uncovers the warm table, and the wide holds a moment
+// Grandma's near (profile) hand in the world, from her pose: the arm hangs from (16, -134), 50 to the elbow, 54 to the hand.
+function s11_hand(o) {
+ const r = Math.PI / 180, a = o.ua * r, b = (o.ua + o.fa) * r, L = (o.lean || 0) * r;
+ const hx = 16 - 50 * Math.sin(a) - 54 * Math.sin(b), hy = -134 + 50 * Math.cos(a) + 54 * Math.cos(b);
+ return [o.x + o.s * (hx * Math.cos(L) - hy * Math.sin(L)), o.y + (o.hop || 0) + o.s * (hx * Math.sin(L) + hy * Math.cos(L))];
+}
+// Eased keys [[t, {k: v}], …]: each key holds until the next one, which it eases into over `over` s.
+function s11_keys(q, keys, over = .25) {
+ let o = { ...keys[0][1] };
+ for (let i = 1; i < keys.length; i++) {
+ const [t, v] = keys[i]; if (q < t - over) break;
+ const u = span(q, t - over, t); for (const k in v) o[k] = (o[k] ?? 0) + (v[k] - (o[k] ?? 0)) * u;
+ }
+ return o;
+}
function scene11(p, D) {
const C = (c, t) => clipAt('scene11', PRE11, c, t);
const cam = paperCam(p, 'room', { x: 2475, y: 590, z: 1.75 }), st = cam.stage;
const gran = grandmaPuppet(st), red = redPuppet(st), wood = woodcutterPuppet(st);
+ // the table: cloth, the cake with a slice gone, Grandma's plate and glass, the juice bottle, the bouquet in a jug, cups
prop(st, `<g filter="url(#paper)"><path d="M2262,636 L2698,636 L2712,800 L2248,800 Z" fill="#f6efe0"/><path d="M2256,700 L2704,700" stroke="#c8322f" stroke-width="10" stroke-dasharray="14 10"/></g>
- <g filter="url(#paper)"><ellipse cx="2405" cy="630" rx="42" ry="11" fill="#b5853c"/><rect x="2363" y="610" width="84" height="20" fill="#d9a85a"/><ellipse cx="2405" cy="610" rx="42" ry="11" fill="#f6efe0"/>
- <path d="M2405,610 L2447,610 L2442,620 Z" fill="#c8322f"/></g>
- <g filter="url(#paper)"><path d="M2556,632 L2560,580 Q2576,566 2592,580 L2596,632 Z" fill="#3f5f8a"/><path d="M2594,590 q16,4 6,24" stroke="#3f5f8a" stroke-width="6" fill="none"/></g>
- <g filter="url(#paper)"><rect x="2348" y="616" width="18" height="20" fill="#f6e7b8"/><rect x="2606" y="616" width="18" height="20" fill="#f6e7b8"/><rect x="2516" y="616" width="16" height="20" fill="#f6e7b8"/></g>`);
+ <g filter="url(#paper)"><ellipse cx="2452" cy="632" rx="40" ry="10" fill="#b5853c"/><rect x="2412" y="612" width="80" height="20" fill="#d9a85a"/><ellipse cx="2452" cy="612" rx="40" ry="10" fill="#f6efe0"/>
+ <path d="M2452,612 L2492,612 L2487,622 Z" fill="#c8322f"/></g>
+ <g filter="url(#paper)"><ellipse cx="2388" cy="634" rx="22" ry="5" fill="#e8dcc6"/></g>
+ <g filter="url(#paper)"><rect x="2560" y="578" width="30" height="56" rx="7" fill="#e9a43a"/><rect x="2567" y="560" width="16" height="22" rx="4" fill="#e9a43a"/>
+ <rect x="2565" y="552" width="20" height="10" rx="3" fill="#c8322f"/><rect x="2563" y="596" width="24" height="18" fill="#f6efe0"/><circle cx="2575" cy="605" r="6" fill="#d6493f"/></g>
+ <g filter="url(#paper)"><path d="M2606,634 L2610,604 L2636,604 L2640,634 Z" fill="#3f5f8a"/>
+ <path d="M2623,604 l-10,-34 M2623,604 l0,-40 M2623,604 l10,-34" stroke="#4f7a34" stroke-width="3"/>
+ <circle cx="2613" cy="568" r="8" fill="#d6493f"/><circle cx="2623" cy="561" r="8" fill="#f6efe0"/><circle cx="2633" cy="568" r="8" fill="#e88ab0"/>
+ <circle cx="2613" cy="568" r="2.6" fill="#efae48"/><circle cx="2623" cy="561" r="2.6" fill="#efae48"/><circle cx="2633" cy="568" r="2.6" fill="#efae48"/></g>
+ <g filter="url(#paper)"><rect x="2516" y="616" width="16" height="20" fill="#f6e7b8"/><rect x="2668" y="616" width="18" height="20" fill="#f6e7b8"/></g>`);
+ // what Grandma lifts: the slice of cake and her glass of apple juice (drawn round the hand that holds them)
+ const slice = prop(st, '<g filter="url(#paper)"><path d="M-16,8 L16,8 L16,-4 L-16,-10 Z" fill="#d9a85a"/><path d="M-16,-10 L16,-4 L16,-8 L-16,-15 Z" fill="#f6efe0"/><path d="M14,-8 l4,4 l-6,1 Z" fill="#c8322f"/></g>');
+ const glass = mk('g', {}, st), juice = mk('rect', { x: -8, y: -12, width: 16, height: 22, fill: '#e9a43a' }, glass);
+ prop(glass, '<path d="M-10,-24 L10,-24 L8,12 L-8,12 Z" fill="#ffffff" fill-opacity=".35" stroke="#ffffff" stroke-width="2.5"/>');
const warm = mk('rect', { width: 1600, height: 900, fill: '#ffb050', opacity: .1 }, p), wipe = trunkWipe(p, 0, .8, 'out');
- const shut = iris(p, C('s11c', 1.0), 1.2, 805, 445), card = endCard(p, C('s11c', 2.3));
- // 11.1 the three at the table; 11.2 Red close, to us; 11.3 back out, and the iris closes on her
- cam.cut({ x: 2480, y: 535, z: 3.4 }, C('s11b', -.05)).soft(C('s11b', -.05), true).cut({ x: 2475, y: 560, z: 1.5 }, C('s11c', -.05)).soft(C('s11c', -.05), false).to({ x: 2480, y: 520, z: 1.9 }, C('s11c', .1), 2.4);
+ // 11.1 the three at the table; 11.2 medium on Grandma: cake, juice, and she comes back to life (push in on "better");
+ // 11.3 Red close, to us, the moral, and the wink; 11.4 back out to the table, the iris closes on Red, The End
+ cam.cut({ x: 2372, y: 585, z: 3.1 }, C('s11', .3)).to({ x: 2370, y: 568, z: 3.4 }, C('s11', 2.9), 2.2)
+ .cut({ x: 2482, y: 556, z: 3.0 }, C('s11b', -.08)).soft(C('s11b', -.08), true).to({ x: 2482, y: 548, z: 3.5 }, C('s11b', 2.4), 2.6)
+ .cut({ x: 2475, y: 568, z: 2.0 }, C('s11c', -.08)).soft(C('s11c', -.08), false).to({ x: 2480, y: 560, z: 1.55 }, C('s11c', .05), 2.4);
+ const IRIS = C('s11c', 2.0), v = cam.at(IRIS);
+ const shut = iris(p, C('s11c', .8), 1.2, 800 + (2482 - v.x) * v.z, 450 + (548 - v.y) * v.z), card = endCard(p, C('s11c', 2.3));
+ // Grandma's arm, step by step (clip s11): reach the slice, bite, put it down; reach the glass, drink, put it down
+ const DOWN = { ua: 6, fa: -6 }, REACH = { ua: -40, fa: -25 }, MOUTH = { ua: -60, fa: -110 }, DRINK = { ua: -50, fa: -100 }, REACH2 = { ua: -28, fa: -38 };
+ const ARM = [[0, DOWN], [C('s11', .55), REACH], [C('s11', .85), MOUTH], [C('s11', 1.45), MOUTH], [C('s11', 1.65), REACH], [C('s11', 1.8), DOWN],
+ [C('s11', 1.95), REACH2], [C('s11', 2.2), DRINK], [C('s11', 2.75), DRINK], [C('s11', 2.95), REACH2], [C('s11', 3.1), DOWN],
+ [C('better11', .2), { ua: -90, fa: -60 }], [C('better11', .5), { ua: -92, fa: -25 }], [C('better11', .8), { ua: -90, fa: -65 }], [C('better11', 1.1), { ua: -92, fa: -25 }], [C('better11', 1.4), { ua: -90, fa: -60 }], [C('s11b', .1), DOWN]];
+ const reach1 = s11_hand({ x: 2330, y: 655, s: .55, ...REACH, lean: 10 }), reach2 = s11_hand({ x: 2330, y: 655, s: .55, ...REACH2, lean: 10 });
+
+ sfx('scene11', 0, 'room', .4, 10); // relaid every 9.5 s by shared.js (BED_STEP)
+ sfx('scene11', C('better11', .2), 'pop', 1.2); sfx('scene11', C('better11', .2), 'hop', 1.4); sfx('scene11', C('wink11', .25), 'chime', .8);
+
stopClock(D, (q, f) => {
cam.apply(q, f); wipe(q); shut(q); card(q);
- const eat = between(q, C('s11', .5), C('s11', 1.2)) || between(q, C('s11', 1.6), C('s11', 2.4));
- gran.pose({ x: 2330, y: 655, s: .55, cap: true, glasses: true, ua: eat ? -60 : 6, fa: eat ? -110 : -6, blush: span(q, C('s11', 3), C('s11', 4.2)), shut: blinking(q, [C('s11', 1.0), C('s11b', 3)]) }, f);
- red.pose({ x: 2482, y: 660, s: .6, head: 'F', basket: false, mouth: lips(q, 'scene11', PRE11, 's11b'), shut: blinking(q, [C('s11', 2.6), C('s11b', 5.6)]) || between(q, C('s11b', 5.0), C('s11b', 5.0) + 3 / FPS) }, f);
- wood.pose({ x: 2640, y: 668, s: .62, turn: -1, axe: false, mouth: between(q, C('s11', 3.0), C('s11', 4.6)) ? (onTwos(q) > 0 ? 'D' : 'C') : 'X', shut: blinking(q, [C('s11', 1.8), C('s11b', 4)]) }, f);
+ const close = between(q, C('s11b', -.08), C('s11c', -.08)), front = q >= C('s11b', -.08), better = span(q, C('s11', 3.0), C('s11', 4.6));
+ const lift = between(q, C('better11', 0), C('better11', 1.5)), bounce = lift ? -18 * Math.abs(Math.sin(Math.PI * (q - C('better11', 0)) / .5)) : 0;
+ // Grandma: poorly at first (bent, head low), then the cake and juice, then pink cheeks, upright, a hop and a cheer
+ const arm = s11_keys(q, ARM, .22);
+ const g = { x: 2330, y: 655, s: .55, ...arm, lean: 4 + 6 * (1 - better), hop: bounce, headR: 7 - 12 * better + (lift ? -6 : 0), nod: 4 * (1 - better) };
+ const chewing = between(q, C('s11', .9), C('s11', 1.5)), drinking = between(q, C('s11', 2.2), C('s11', 2.75));
+ gran.pose({ ...g, cap: true, glasses: true, blush: better, head: front ? 'F' : 'P', turn: 1,
+ mouth: chewing ? (onTwos(q) > 0 ? 'B' : 'X') : drinking ? 'F' : lift ? 'D' : 'X',
+ shut: blinking(q, [C('s11', 1.9), C('s11', 4.0), C('s11b', 1.2), C('s11b', 3.8)]) || (q < C('s11', .3) && onTwos(q) > 0 && q > .9) || chewing && q < C('s11', 1.2) }, f);
+ const hand = s11_hand(g);
+ // the slice: on the plate, then in her hand from the reach to the put-down; a bite out of it after the first chew
+ const holdS = between(q, C('s11', .55), C('s11', 1.65)), bitten = q > C('s11', 1.05);
+ const [sx, sy] = holdS ? hand : [reach1[0], 628];
+ tf(slice, `translate(${sx.toFixed(1)},${(sy - (holdS ? 6 : 0)).toFixed(1)}) scale(${bitten ? .7 : 1},1)`);
+ // the glass: on the table, in her hand, tipped to her mouth while she drinks; the juice goes down
+ const holdG = between(q, C('s11', 1.95), C('s11', 2.95)), tip = drinking ? -40 * span(q, C('s11', 2.2), C('s11', 2.35)) : 0;
+ const [gx, gy] = holdG ? hand : [reach2[0], 622];
+ tf(glass, `translate(${gx.toFixed(1)},${(gy - (holdG ? 8 : 0)).toFixed(1)}) rotate(${tip.toFixed(1)})`);
+ const level = 1 - .7 * span(q, C('s11', 2.3), C('s11', 2.7));
+ juice.setAttribute('y', (10 - 22 * level).toFixed(1)); juice.setAttribute('height', (22 * level).toFixed(1));
+ // Red: watching Grandma (profile, facing her), glad on "better"; on the cut, the moral to us and the wink
+ const rWink = between(q, C('wink11', .25), C('wink11', .85));
+ red.pose({ x: 2482, y: 660, s: .6, turn: front ? 1 : -1, head: front ? 'F' : 'P', basket: false, hop: lift ? .7 * bounce : 0,
+ headR: front ? (rWink ? 7 : 2 * Math.sin(q * 1.3)) : -4 + 4 * better, nod: close && between(q, C('s11b', 1.6), C('s11b', 2.1)) ? 4 : 0,
+ wink: rWink,
+ mouth: lips(q, 'scene11', PRE11, 's11b') !== 'X' ? lips(q, 'scene11', PRE11, 's11b') : lift ? 'D' : 'X',
+ shut: !rWink && (blinking(q, [C('s11', 2.6), C('s11b', 2.3), C('s11c', .6)]) || between(q, C('better11', .1), C('better11', .5))) }, f);
+ // the woodcutter: listens to Grandma, laughs and cheers with her, nods along with Red's promise
+ wood.pose({ x: 2670, y: 668, s: .62, turn: -1, axe: false, ua: lift ? -150 : 6, fa: lift ? -40 : -6, headR: lift ? -10 : 0,
+ nod: close && between(q, C('s11b', 3.0), C('s11b', 3.5)) ? 5 : 0,
+ mouth: lift ? (onTwos(q) > 0 ? 'D' : 'C') : 'X', shut: blinking(q, [C('s11', 1.8), C('s11b', .6), C('s11b', 4)]) }, f);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene2.js b/site/little-red-riding-hood/ch01/scene2.js
index 5867ab1..97d4802 100644
--- a/site/little-red-riding-hood/ch01/scene2.js
+++ b/site/little-red-riding-hood/ch01/scene2.js
@@ -1,21 +1,57 @@
-/* scene2.js — the woods. */
+/* scene2.js — the woods. A side-on follow of Red along the path, the layers sliding past; on "three big oak trees" she
+ looks up at three far crowns over the treetops. She passes a bush; on "But someone was watching" the camera stops
+ and pushes in on it as she walks out of frame; on "watching" two eyes open in its dark and follow her; the close-up
+ holds on them through the silence (eyes2). Scene 3's wolf comes out of this same bush (BX, BY): keep it here.
+ Beat clock = PRE2 + the scene-clip word times. */
'use strict';
const PRE2 = .9;
+const s2_BX = 1180, s2_BY = 742; // the bush
+// Three far oaks on a rise over the forest's back trees, drawn in the far layer (k .35) so they slide slowly.
+const s2_OAKS = `<g filter="url(#paper)"><path d="M1060,470 Q1230,330 1400,470 Z" fill="#9db69a"/></g>
+ <g filter="url(#paper)">${[[1146, 350, 38], [1222, 326, 45], [1300, 348, 37]].map(([x, y, r]) => `<rect x="${x - 4}" y="${y + r - 8}" width="8" height="${70 - r}" fill="#8b7a62"/>
+ <circle cx="${x}" cy="${y}" r="${r}" fill="#64936b"/><circle cx="${x - r * .45}" cy="${y + r * .3}" r="${r * .62}" fill="#64936b"/><circle cx="${x + r * .45}" cy="${y + r * .3}" r="${r * .62}" fill="#64936b"/>`).join('')}</g>`;
+
function scene2(p, D) {
- const EYES = PRE2 + TIMINGS.scene2.marks['s02.eyes'], BX = 1180, BY = 742;
- const cam = paperCam(p, 'forest', { x: 460, y: 470, z: 1 });
- prop(cam.stage, bushBackSVG(BX, BY)); const eyes = bushEyes(cam.stage, BX, BY - 50); prop(cam.stage, bushFrontSVG(BX, BY));
+ const P = PRE2, T = (c, t = 0) => clipAt('scene2', P, c, t);
+ const OAKS = T('s02', 2.78), BUT = T('s02', 5.12), WATCH = T('s02', 6.14); // "three big oak trees", "But someone was watching."
+ const PASS = T('s02', 4.9); // Red level with the bush, just before "But"
+ const CLOSE = T('eyes2', .2); // the eyes, close, in the silence
+ const OPEN = WATCH - .15, NARROW = CLOSE + 1.0, BLINK = CLOSE + 1.9;
+ // Her walk, timed so that she is at the bush at PASS (speed: one step of 2·L·sin A every half period, at scale .6).
+ const S = .6, PER = .95, A = 24, V = 2 * 166 * Math.sin(A * Math.PI / 180) / (PER / 2) * S;
+ const go = walker(s2_BX + 30 - V * PASS, S, { period: PER, A });
+
+ const cam = paperCam(p, 'forest', { x: go(0).x + 160, y: 470, z: 1 }, { stages: ['far'] });
+ prop(cam.stageAt.far, s2_OAKS);
+ prop(cam.stage, bushBackSVG(s2_BX, s2_BY)); const eyes = bushEyes(cam.stage, s2_BX, s2_BY - 50);
+ const front = prop(cam.stage, bushFrontSVG(s2_BX, s2_BY));
const red = redPuppet(cam.stage), wipe = trunkWipe(p, 0, .8, 'out');
- const go = walker(300, .6, { period: .95, A: 24 });
- // 2.1 follow her along the path; 2.2 at "But someone was watching" the camera stops and pushes in on the bush
- // she has just passed; 2.3 the eyes, close, watching her go.
- cam.to({ x: t => go(t).x + 160 }, 0, .01).to({ x: BX, y: 650, z: 2.3 }, EYES, 1.3).cut({ x: BX, y: BY - 50, z: 5.5 }, EYES + 2.1);
+ // 2.1 follow her along the path; 2.2 at "But" the camera stops and pushes in on the bush she has just passed while
+ // she walks on out of frame; 2.3 the eyes, close, still watching where she went.
+ cam.to({ x: t => go(t).x + 160 }, 0, .01)
+ .to({ x: s2_BX + 90, y: 640, z: 2.0 }, BUT, 1.5)
+ .cut({ x: s2_BX + 10, y: s2_BY - 62, z: 3.5 }, CLOSE).to({ x: s2_BX + 4, y: s2_BY - 56 }, CLOSE, D + .6 - CLOSE); // z 3.5 is the layered sets' limit
+ cam.soft(CLOSE, true);
+
+ sfx('scene2', 0, 'forest', .52); // shared.js lays it again every 9.5 s
+ for (let k = 0, t; (t = PER * (.25 + .5 * k)) < BUT + 2.4; k++) sfx('scene2', +t.toFixed(2), 'step' + (1 + k % 3), t < BUT ? .6 : .6 - .3 * Math.min(1, (t - BUT) / 2));
+ sfx('scene2', OPEN - .1, 'rustle', 1.1);
+
stopClock(D, (q, f) => {
cam.apply(q, f); wipe(q);
- const w = go(q), s = .6;
- red.pose({ x: w.x, y: hipOn(WOODS, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
- cape: 3 + 3 * Math.sin(2 * w.ph + .6), ua: -8 + 6 * Math.sin(w.ph), fa: -78, swing: 9 * Math.sin(w.ph - 1), headR: 2 * Math.sin(2 * w.ph), shut: blinking(q, [2.6]) }, f);
- const o = q < EYES + .8 ? 0 : q < EYES + .9 ? .3 : between(q, EYES + 3.4, EYES + 3.57) ? .1 : 1;
- eyes(o, q < EYES + 2.3 ? .4 : Math.min(1, .4 + (q - EYES - 2.3) * .5));
+ const w = go(q), look = OAKS - .1 < q && q < OAKS + 1.5; // she looks up at the oaks and points
+ const point = span(q, OAKS, OAKS + .3) * (1 - span(q, OAKS + 1.2, OAKS + 1.5));
+ red.pose({ x: w.x, y: hipOn(WOODS, S) + w.drop * S, s: S, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
+ cape: 3 + 3 * Math.sin(2 * w.ph + .6), ua: -8 + 6 * Math.sin(w.ph), fa: -78, swing: 9 * Math.sin(w.ph - 1),
+ headR: look ? -9 * span(q, OAKS - .1, OAKS + .2) * (1 - span(q, OAKS + 1.2, OAKS + 1.5)) : 2 * Math.sin(2 * w.ph),
+ fua: point > .05 ? -20 - 85 * point : null, ffa: -10 + 5 * point, shut: blinking(q, [1.9, OAKS + 1.9, BUT + .4]) }, f);
+ // The bush shivers as the eyes open.
+ const shiver = between(q, OPEN - .1, OPEN + .5) ? 2.2 * onTwos(q) : 0;
+ tf(front, `rotate(${shiver},${s2_BX},${s2_BY})`);
+ // The eyes: shut until "watching", open in three frames, follow her out of frame; in the close-up they keep looking
+ // where she went, narrow (sly), and blink once.
+ const o = q < OPEN ? 0 : q < OPEN + 1 / FPS ? .25 : q < OPEN + 2 / FPS ? .7 : q < NARROW ? 1
+ : between(q, BLINK, BLINK + 2 / FPS) ? .08 : 1 - .45 * span(q, NARROW, NARROW + .25);
+ eyes(o, Math.max(-.2, Math.min(1, (w.x - s2_BX) / 320)));
});
}
diff --git a/site/little-red-riding-hood/ch01/scene3.js b/site/little-red-riding-hood/ch01/scene3.js
index 0f4efcf..dbf0e1b 100644
--- a/site/little-red-riding-hood/ch01/scene3.js
+++ b/site/little-red-riding-hood/ch01/scene3.js
@@ -1,39 +1,124 @@
-/* scene3.js — the wolf. */
+/* scene3.js — the wolf meets Red on the path (storyboard v2, scene 3).
+ Shots (beat clock): 1 two-shot, the wolf pops out of scene 2's bush, Red startles and turns (0 – s03 -.05);
+ 2 the wolf's close-up bow, cap off ("Good morning, Little Red Riding Hood!"); 3 two-shot, "Where are you off to?",
+ Red listening; 4 Red's medium close-up over the wolf's blurred head and ear, she points ahead (s03b);
+ 5 insert: his paw lifts the cloth off her basket, the cake ("Cake…"); 6 the wolf front, rubbing paws, Red blurred
+ behind and unaware, a slow push in and the hold on the rub (to the end). */
'use strict';
const PRE3 = 2.2;
+const s3_C = (c, t = 0) => clipAt('scene3', PRE3, c, t);
+const s3_BX = 1180, s3_BY = 742, s3_POP = .35, s3_HOP = .8, s3_LAND = 1.2;
+sfx('scene3', 0, 'forest', .5, 10); // the bed: shared.js lays it again every 9.5 s; 10 s long, so a seek joins it part-way
+sfx('scene3', .3, 'rustle', 1.6);
+sfx('scene3', s3_HOP, 'whoosh', .8); sfx('scene3', s3_LAND, 'pad', 1.6);
+[[.24, 'step1'], [.71, 'step2'], [1.42, 'step3'], [2.05, 'step1']].forEach(([t, n]) => sfx('scene3', t, n, 1.2));
+sfx('scene3', s3_C('s03', .12), 'whoosh', .5); // the cap swept off
+
function scene3(p, D) {
- const C = (c, t) => clipAt('scene3', PRE3, c, t), TX = 2250, POP = 1.5, STOP = 1.425;
- const cam = paperCam(p, 'forest', { x: 2060, y: 560, z: 1.45 });
- const wolf = wolfPuppet(cam.stage), red = redPuppet(cam.stage);
- prop(cam.stage, `<g filter="url(#paper)"><path d="M${TX - 64},800 C${TX - 50},500 ${TX - 56},200 ${TX - 40},-200 L${TX + 44},-200 C${TX + 56},200 ${TX + 50},500 ${TX + 66},800 Z" fill="#6e4a30"/>
- <path d="M${TX - 20},700 C${TX - 10},500 ${TX - 24},300 ${TX - 12},0 M${TX + 22},760 C${TX + 30},520 ${TX + 18},300 ${TX + 26},40" stroke="#5a3b24" stroke-width="6" fill="none"/></g>`);
- // 3.2 the wolf's view of her: the woods behind her, his ear and shoulder dark and close at the edge
- const rev = paperCam(p, 'forestRev').soft(0, 'all'), redRev = redPuppet(rev.stage);
- prop(rev.root, `<g filter="url(#paper)"><path d="M1290,900 C1300,700 1380,560 1480,520 L1520,380 L1560,500 C1620,520 1660,560 1680,600 L1680,900 Z" fill="#3e3a36"/></g>`);
- const go = walker(1640, .6, { period: .95, A: 24 }, 1, 3);
- cam.cut({ x: 2120, y: 520, z: 2.6 }, C('s03c', -.05)).soft(C('s03c', -.05), true);
+ const C = s3_C, k01 = (q, a, d) => Math.min(1, Math.max(0, (q - a) / d)), arc = (q, a, d) => Math.sin(Math.PI * k01(q, a, d));
+ const defs = mk('defs', {}, p);
+ defs.innerHTML = `<filter id="s3_blurR" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="6"/></filter>
+ <filter id="s3_blurC" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="2.4"/></filter>
+ <clipPath id="s3_hide" clipPathUnits="userSpaceOnUse"><path d="M-5000,-5000 H1325 V758 H-5000 Z M1325,-5000 H9000 V9000 H1325 Z"/></clipPath>`;
+ const S1 = C('s03', -.05), S2 = C('s03', 2.55), S3 = C('s03b', -.15), S4 = C('s03c', -.1), S5 = C('s03c', 1.15);
+
+ // A: the path by the bush (shots 1–3). The wolf hides behind the bush (clipped below its foot until he is out).
+ const A = paperCam(p, 'forest', { x: 1430, y: 600, z: 1.9 });
+ const wolfWrap = mk('g', { 'clip-path': 'url(#s3_hide)' }, A.stage), wolf = wolfPuppet(wolfWrap);
+ const bushB = prop(A.stage, bushBackSVG(s3_BX, s3_BY)), eyes = bushEyes(A.stage, s3_BX, s3_BY - 50), bushF = prop(A.stage, bushFrontSVG(s3_BX, s3_BY));
+ const red = redPuppet(A.stage), go = walker(1560, .6, { period: .95, A: 24 }, 1, 2);
+ A.to({ x: 1490, z: 2 }, s3_HOP, 1.2).cut({ x: 1470, y: 565, z: 3.4 }, S1).cut({ x: 1570, y: 610, z: 2.15 }, S2);
+
+ // R: the wolf's view of her (forestRev), his head and ear big and soft at the left.
+ const R = paperCam(p, 'forestRev', { x: 820, y: 450, z: 1 }).soft(0, 'all'), redR = redPuppet(R.stage);
+ const wolfR = wolfPuppet(mk('g', { filter: 'url(#s3_blurR)' }, R.stage));
+ R.to({ x: 870, y: 430, z: 1.12 }, S3 + .2, 3.2);
+
+ // I: insert of her basket, his paw lifting the cloth (the soft woods behind).
+ const I = paperCam(p, 'forest', { x: 1700, y: 600, z: 2.2 }).soft(0, 'all'), bWrap = mk('g', {}, I.stage), basket = basketProp(bWrap);
+ const BXI = 1700, BYI = 720, BS = .8, HY = BYI - 240 * BS;
+ prop(bWrap, `<g filter="url(#paper)"><rect x="${BXI - 11}" y="${HY - 300}" width="22" height="300" rx="9" fill="#f4efe2"/><circle cx="${BXI}" cy="${HY}" r="15" fill="#f6d2b5"/></g>`);
+ const paw = prop(I.stage, `<g filter="url(#paper)"><rect x="-420" y="-13" width="420" height="26" rx="12" fill="${ARM}"/><circle cx="0" cy="0" r="19" fill="${FUR2}"/>
+ <path d="M14,-12 l12,-4 M16,0 l13,0 M14,12 l12,4" stroke="#f6efe0" stroke-width="3.5" stroke-linecap="round"/></g>`);
+ I.to({ z: 2.4, y: 610 }, S4, 1.1);
+
+ // C: the wolf to us, close; Red small and soft behind him on the path, the bush soft at the left.
+ const Cm = paperCam(p, 'forest', { x: 1500, y: 600, z: 2.4 }).soft(0, 'all'), back = mk('g', { filter: 'url(#s3_blurC)' }, Cm.stage);
+ prop(back, bushBackSVG(s3_BX, s3_BY)); prop(back, bushFrontSVG(s3_BX, s3_BY));
+ const redC = redPuppet(back), wolfC = wolfPuppet(Cm.stage);
+ Cm.to({ x: 1460, y: 578, z: 2.85 }, S5 + .1, 4.4);
+
stopClock(D, (q, f) => {
- const reverse = between(q, C('s03b', -.05), C('s03c', -.05));
- vis(cam.root, !reverse); vis(rev.root, reverse);
- if (reverse) {
- rev.apply(q, f);
- redRev.pose({ x: 760, y: 430 + 194 * 2, s: 2, head: 'F', mouth: mouthAt('s03b', q - C('s03b')), shut: blinking(q, [C('s03b', 1.6)]),
- rua: q > C('s03b', 2.2) ? -96 : 6, rfa: q > C('s03b', 2.2) ? -10 : -4 }, f);
+ const shot = q < S3 ? 'A' : q < S4 ? 'R' : q < S5 ? 'I' : 'C';
+ vis(A.root, shot === 'A'); vis(R.root, shot === 'R'); vis(I.root, shot === 'I'); vis(Cm.root, shot === 'C');
+ const wag = 8 * Math.sin(q * 5);
+
+ if (shot === 'A') {
+ A.apply(q, f);
+ // the bush shakes, the eyes go, he rises behind it, peeks, hops out onto the path
+ const shake = between(q, .3, .78) ? 3 * jit(f, 41) : 0;
+ tf(bushB, `rotate(${shake.toFixed(2)},${s3_BX},${s3_BY})`); tf(bushF, `rotate(${(-shake * .7).toFixed(2)},${s3_BX},${s3_BY})`);
+ eyes(q < s3_POP ? 1 : 0, 1);
+ const rise = 220 - 180 * span(q, s3_POP, s3_POP + .15), u = k01(q, s3_HOP, s3_LAND - s3_HOP), air = arc(q, s3_HOP, s3_LAND - s3_HOP);
+ const land = between(q, s3_LAND, s3_LAND + 2 / FPS) ? 8 : 0, s = .6;
+ const bow = span(q, C('s03', .05), C('s03', .45)) * (1 - span(q, C('s03', 1.95), C('s03', 2.3)));
+ const capOff = between(q, C('s03', .1), C('s03', 2.3)), capOn = between(q, C('s03', 2.3), C('s03', 2.5));
+ const preen = between(q, 1.5, 1.95), ask = between(q, C('s03', 2.6), C('s03', 4.1));
+ wolf.pose({ x: s3_BX + (1400 - s3_BX) * ease(u), y: hipOn(WOODS, s, 200) + rise * (1 - ease(u)) - 80 * air + land, s, turn: 1,
+ near: -25 * air, far: 25 * air, kNear: 55 * air, kFar: 55 * air,
+ lean: 28 * bow + (ask ? 8 : 0), cap: capOff ? 'hand' : 'on',
+ ua: capOff ? 5 : capOn ? -150 : preen ? -20 : ask ? -46 : 6, fa: capOff ? -85 * bow : capOn ? -30 : preen ? -100 : ask ? -20 : -6,
+ headR: -10 * bow + (ask ? -4 : 0), tail: q < s3_LAND ? 30 * air : wag, look: 1, ear: between(q, .55, .7) ? 1 : 0,
+ brow: between(q, .5, s3_HOP) ? -1 : 0, mouth: lips(q, 'scene3', PRE3, 's03'),
+ shut: blinking(q, [.65, C('s03', 1.2), C('s03', 3.5)]) }, f);
+ // Red: two steps on, the hop of fright, the whole-body turn to him, a hop back; then she listens
+ const w = go(q), turn = 1 - 2 * span(q, 1.45, 1.78);
+ const jump = 16 * arc(q, 1.25, .17) + 10 * arc(q, 1.85, .2), fright = between(q, 1.25, 1.6);
+ red.pose({ x: w.x + 26 * span(q, 1.85, 2.05), y: hipOn(WOODS, s) + w.drop * s - jump, s, turn,
+ near: w.near, far: w.far, kNear: w.kNear * (1 - span(q, .95, 1.12)) + 30 * arc(q, 1.85, .2), kFar: w.kFar + 30 * arc(q, 1.85, .2),
+ cape: 3 + 3 * Math.sin(2 * w.ph + .6) + 9 * (jump > 1), ua: fright ? -30 : -8 + 6 * Math.sin(w.ph), fa: fright ? -100 : -78,
+ swing: q < .95 ? 9 * Math.sin(w.ph - 1) : 4 * Math.sin(q * 2.2), headR: q > C('s03', 3) && q < S3 ? 5 : 2 * Math.sin(2 * w.ph),
+ mouth: fright ? 'E' : 'X', brow: between(q, 1.25, 2.4) ? 1 : 0,
+ shut: blinking(q, [C('s03', .9), C('s03', 3.2)]) }, f);
return;
}
- cam.apply(q, f);
- const w = go(q), s = .6, startle = between(q, POP + .1, POP + .1 + 2 / FPS);
- red.pose({ x: w.x - (q > POP + .1 ? 12 : 0), y: hipOn(WOODS, s) + w.drop * s - (startle ? 12 : 0), s,
- near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3, ua: -8, fa: -78,
- headR: q > POP + .1 ? -4 : 0, shut: blinking(q, [6.2, 12.0]), mouth: 'X' }, f);
- // the wolf hops out from behind the trunk, bows with his cap in his paw, then asks
- const hop = Math.min(1, Math.max(0, (q - POP) / .4)), land = between(q, POP + .4, POP + .4 + 2 / FPS);
- const bow = q < C('s03', 3) ? span(q, C('s03', .2), C('s03', .6)) : 1 - span(q, C('s03', 3), C('s03', 3.4));
- const aside = q >= C('s03c', -.05);
- wolf.pose({ x: TX + 10 - 150 * hop, y: hipOn(WOODS, s, 200) - 50 * Math.sin(Math.PI * hop) + (land ? 6 : 0), s, turn: -1,
- lean: 26 * bow, cap: bow > .05 ? 'hand' : 'on', ua: bow > .05 ? -20 * bow : q > C('s03', 3.4) && q < C('s03b') ? -46 : 6, fa: bow > .05 ? -125 * bow : -20,
- tail: 8 * Math.sin(q * 5), head: aside ? 'F' : 'P', mouth: lips(q, 'scene3', PRE3, 's03', 's03c'),
- rua: 40, rfa: -104 + 8 * onTwos(q), lua: -40, lfa: 104 - 8 * onTwos(q),
- brow: aside && q > C('s03c', 2.5) ? onTwos(q) : 0, look: aside && q < C('s03c', 2.3) ? -1 : 0, shut: blinking(q, [4.0, 14.8]) }, f);
+
+ if (shot === 'R') {
+ R.apply(q, f);
+ const lift = span(q, C('s03b', 0), C('s03b', .3)) * (1 - span(q, C('s03b', 1.0), C('s03b', 1.3)));
+ const pt = span(q, C('s03b', 1.15), C('s03b', 1.45)) * (1 - span(q, C('s03b', 2.9), C('s03b', 3.25)));
+ redR.pose({ x: 880, y: 430 + 194 * 2, s: 2, head: 'F', mouth: lips(q, 'scene3', PRE3, 's03b'),
+ nod: 6 * arc(q, C('s03b', .45), .3), headR: 3 * Math.sin(q * 1.7) - 6 * pt,
+ rua: 6 - 34 * lift, rfa: -4 - 30 * lift, lua: -6 + 146 * pt, lfa: 4 + 16 * pt, swing: 3 * Math.sin(q * 2),
+ shut: blinking(q, [C('s03b', 1.6), C('s03b', 3.3)]) }, f);
+ // his ear jumps at "Grandma's" and at "three big oaks"; his jaw drops a little at "house"
+ wolfR.pose({ x: 210, y: 1150 + 4 * Math.sin(q * 3), s: 2.6, turn: 1, cap: 'on', look: 1,
+ ear: between(q, C('s03b', .1), C('s03b', .45)) || between(q, C('s03b', 1.85), C('s03b', 2.2)) ? 1 : 0,
+ jaw: .25 * arc(q, C('s03b', .55), .8), headR: -3 + 2 * Math.sin(q * 1.3), tail: wag,
+ shut: blinking(q, [C('s03b', 2.6)]) }, f);
+ return;
+ }
+
+ if (shot === 'I') {
+ I.apply(q, f);
+ const k = q - S4, open = .55 * span(k, .25, .55), sw = 2.5 * Math.sin(q * 2.2);
+ tf(bWrap, `rotate(${sw.toFixed(2)},${BXI},${HY})`);
+ basket.pose(BXI, BYI, BS, open);
+ // his paw follows the cloth's left corner, then slips away
+ const cx = BXI + (-138 - 190 * open) * BS - 6, cy = BYI + (-150 + 120 * open) * BS + 6 - 30;
+ const inn = span(k, 0, .25), out = span(k, .75, .95);
+ tf(paw, `translate(${(cx - 300 * (1 - inn) - 420 * out).toFixed(1)},${cy.toFixed(1)}) rotate(${(-12 + 4 * jit(f, 43)).toFixed(1)})`);
+ return;
+ }
+
+ Cm.apply(q, f);
+ const k = q - C('s03c'), slow = Math.floor(q * FPS / 4) % 2 ? 1 : -1, rub = k > 2.8 ? onTwos(q) : k > 1.35 ? slow : 0;
+ const look = k < 1.2 ? 1 : between(k, 2.6, 2.85) ? 1 : 0;
+ const brow = k < 1.2 ? 1 : k < 2.8 ? -.8 : k < 4.7 ? 1 : (Math.floor(q * FPS / 3) % 2 ? 1 : .3);
+ wolfC.pose({ x: 1400, y: 745, s: 1.05, turn: 0, head: 'F', cap: 'on', look, brow, mouth: lips(q, 'scene3', PRE3, 's03c'),
+ rua: -25, rfa: 130 + 10 * rub, lua: 25, lfa: -130 + 10 * rub, headR: 3 * Math.sin(q * 1.6), nod: 3 * Math.sin(q * 3.1),
+ shut: blinking(q, [C('s03c', 2.3), C('s03c', 5.0)]) }, f);
+ redC.pose({ x: 1700, y: hipOn(765, .42), s: .42, turn: 1, swing: 6 * Math.sin(q * 2.2), headR: k > 3.1 && k < 4.3 ? 8 : 2 * Math.sin(q * 1.1),
+ cape: 3 + 2 * Math.sin(q * 1.4), shut: blinking(q, [C('s03c', 1.6), C('s03c', 4.8)]) }, f);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene4.js b/site/little-red-riding-hood/ch01/scene4.js
index 62913a6..cd0edda 100644
--- a/site/little-red-riding-hood/ch01/scene4.js
+++ b/site/little-red-riding-hood/ch01/scene4.js
@@ -1,38 +1,173 @@
-/* scene4.js — flowers. */
+/* scene4.js — the meadow: the turning point. Red leaves the path; the wolf runs ahead.
+ Shots (beat clock = PRE4 + clip times of the joined scene4: s04 0, think4 4.43, s04b 6.98, hole 11.38–13.58, run4 16.97):
+ A 0 → s04+0.05 the path's edge, two-shot as scene 3 left them: the wolf (860, facing right) and Red (1060,
+ facing him), the meadow opening behind her; he leans in, oily
+ B → s04+1.45 close two-shot: "Why hurry?", paw out, Red readable at the right
+ C → s04+4.40 medium wide: on "Look" he sweeps his arm up past her; she turns to the meadow (in the wide) and
+ the camera pans with the arm onto it (flowers, butterflies, the bird, the sun) for "lovely flowers!"
+ D1 → s04+5.15 Red's medium close-up, profile: she looks at the flowers and smiles, leans to go; the wolf behind
+ D2 → s04+6.45 cut to her front close-up between the grinning wolf (left) and a torn-paper thought picture of
+ Mother's raised finger (right) that flickers in and fades; worried, she bites her lip
+ D3 → s04b+1.27 profile again: she looks at the flowers, nods — decided — and steps to the path's edge
+ E → s04b+2.47 insert low on her feet: one big step over the pebble edge onto the grass on "left the path"
+ F → s04b+6.72 medium: she skips into the meadow and picks on twos, three flowers, the bunch growing
+ G → run4+0.53 low fast follow of the wolf on all fours, grass and big flowers whipping past; he leaves the frame
+ H → end (+hold) wide: Red small and alone, still picking, the wolf gone */
'use strict';
-const PRE4 = .3;
+const PRE4 = 1.0;
+// Red picks a flower in u 0 … 1 (about a second): bend to it, snap, show it, put it in the bunch.
+function s4_pick(u, col) {
+ if (u < .3) { const e = ease(u / .3); return { lean: 62 * e, crouch: .7 * e, fua: -20 - 30 * e, ffa: 10 * e, held: null, put: false }; }
+ if (u < .45) return { lean: 62, crouch: .7, fua: -50, ffa: 10, held: u >= .38 ? col : null, put: false };
+ if (u < .75) { const e = ease((u - .45) / .3); return { lean: 62 - 47 * e, crouch: .7 * (1 - e), fua: -50 - 50 * e, ffa: 10 - 60 * e, held: col, put: false }; }
+ const e = ease((u - .75) / .25);
+ return { lean: 15 * (1 - e), crouch: 0, fua: -100 + 80 * e, ffa: -50 - 20 * e, held: u < .88 ? col : null, put: u >= .88 };
+}
+// A torn sheet w × h around (0, 0) (Little Horse's thought picture), the same every time.
+function s4_torn(w, h, seed) {
+ const pts = [], n = 9;
+ const side = (x0, y0, x1, y1, k) => { for (let i = 0; i < n; i++) { const u = i / n; pts.push([x0 + (x1 - x0) * u + 4 * jit(seed, k + i), y0 + (y1 - y0) * u + 4 * jit(seed, k + 40 + i)]); } };
+ side(-w / 2, -h / 2, w / 2, -h / 2, 0); side(w / 2, -h / 2, w / 2, h / 2, 100); side(w / 2, h / 2, -w / 2, h / 2, 200); side(-w / 2, h / 2, -w / 2, -h / 2, 300);
+ return 'M' + pts.map(p => p.map(v => v.toFixed(1)).join(',')).join(' L') + ' Z';
+}
+// The thought picture popping in on twos (a flicker), then fading out in steps.
+const s4_think = (q, t0, t1) => q < t0 || q >= t1 + .5 ? 0 : q >= t1 ? [.7, .45, .2, .08, 0, 0][Math.floor((q - t1) * FPS)] : [.5, .15, .8, .4, 1][Math.min(4, Math.floor((q - t0) * FPS))];
+
function scene4(p, D) {
- const C = (c, t) => clipAt('scene4', PRE4, c, t), PICK = PRE4 + TIMINGS.scene4.marks['s04b.pick'], RUN = PRE4 + TIMINGS.scene4.marks['s04b.run'];
- const cam = paperCam(p, 'forest', { x: 2000, y: 560, z: 1.5 });
+ const C = (c, t) => clipAt('scene4', PRE4, c, t), s = .6;
+ const T = {
+ B: C('s04', .05), C: C('s04', 1.45), sweep: C('s04', 1.6), pan: C('s04', 2.15), D1: C('s04', 4.4), D2: C('s04', 5.15),
+ cloud: C('s04', 5.35), cloudOff: C('s04', 6.15), D3: C('s04', 6.45), walk: C('s04b', .45), E: C('s04b', 1.27),
+ step: C('s04b', 1.42), F: C('s04b', 2.47), G: C('s04b', 6.72), H: C('run4', .53),
+ };
+ const PICKS = [C('s04b', 3.6), C('s04b', 4.65), C('s04b', 5.7), C('run4', .8)], PICK = 1.05;
+ // ---- sound: the meadow bed (shared.js's BED_STEP lays it again every 9.5 s), feet where they are seen
+ sfx('scene4', 0, 'meadow', .6);
+ sfx('scene4', T.step + .5, 'step1', 1.6);
+ [.35, .7, 1.05].forEach((t, i) => sfx('scene4', T.F + t, 'step' + (2 + i % 2), 1.1));
+ PICKS.forEach(t => sfx('scene4', t + .4, 'pop', .45));
+ sfx('scene4', T.G + .25, 'whoosh', 1.2);
+ for (let t = T.G + .3; t < T.H - .1; t += .44) sfx('scene4', +t.toFixed(2), 'run', 1.3);
+
+ // ---- the set, its live things (sun and clouds in the sky layer), the cast
+ const cam = paperCam(p, 'meadow', { x: 1020, y: 560, z: 1.45 }, { stages: ['sky'] });
+ const sun = sunProp(cam.stageAt.sky), clouds = [cloudProp(cam.stageAt.sky), cloudProp(cam.stageAt.sky)];
+ const bird = birdProp(cam.stage), flies = [butterflyProp(cam.stage), butterflyProp(cam.stage)];
const red = redPuppet(cam.stage), wolf = wolfPuppet(cam.stage);
- // 4.1 he sweeps a paw at the meadow and the camera follows it; 4.2 she skips into the flowers and picks;
- // 4.3 low, running with him along the path (she is a blur behind, still picking)
- cam.to({ x: 3250, y: 500, z: 1.05 }, C('s04', 2.1), 2.6);
- const RX = 2950, runner = walker(2600, .6, { L: 196, A: 26, period: .5, knee: 60 });
- cam.cut({ x: 2700, y: 620, z: 1.7 }, RUN).to({ x: t => Math.min(3600, runner(t - RUN).x + 100) }, RUN, .01);
+ // the flowers she picks: one a step ahead of each pick (picks 0–2 in F, 3–4 in H)
+ const STEP = 2 * 166 * Math.sin(18 * Math.PI / 180) * s, RX = PICKS.map((t, i) => 1467 + STEP * i), REACH = 64;
+ const flowers = PICKS.map((t, i) => flowerProp(cam.stage, FLOWER_COLS[i]));
+ const edge = [[1150, 935, 1.3, 4], [1262, 950, 1.5, 1]].map(([x, y, k, c]) => [flowerProp(cam.stage, FLOWER_COLS[c]), x, y, k]); // the insert's foreground
+ const near = [1530, 1610, 1700, 1790].map((x, i) => [flowerProp(cam.stage, FLOWER_COLS[(i + 2) % 7]), x]); // not picked
+
+ // flowerProp draws its stem over its head (seen at insert size): put each head back on top
+ for (const fl of [...flowers, ...edge.map(e => e[0]), ...near.map(e => e[0])]) fl.g.appendChild(fl.g.firstChild);
+
+ // ---- the thought picture (screen space, over everything): Mother, finger raised
+ const th = mk('g', {}, p), thIn = mk('g', {}, th);
+ prop(th, `<g filter="url(#paper)">${[[948, 404, 10], [985, 372, 16]].map(([x, y, r]) => `<circle cx="${x}" cy="${y}" r="${r}" fill="#f6efe0"/>`).join('')}</g>`);
+ prop(thIn, `<g filter="url(#paper)"><path d="${s4_torn(400, 320, 404)}" fill="#f6efe0"/><path d="${s4_torn(370, 292, 405)}" fill="#e3edd2"/></g>`);
+ const clip = mk('clipPath', { id: 's4_clip' }, thIn); mk('path', { d: s4_torn(366, 288, 405) }, clip);
+ const momG = mk('g', { 'clip-path': 'url(#s4_clip)' }, thIn), mom = motherPuppet(momG);
+
+ // ---- cameras
+ cam.cut({ x: 965, y: 580, z: 2.6 }, T.B) // B: the wolf asks, Red at the right
+ .cut({ x: 1020, y: 540, z: 1.4 }, T.C).to({ x: 2300, y: 500, z: 1.1 }, T.pan, 1.75) // C: sweep and pan
+ .cut({ x: 1000, y: 565, z: 2.6 }, T.D1) // D1: Red, profile, the wolf behind her
+ .cut({ x: 1010, y: 548, z: 3.2 }, T.D2) // D2: Red front between the wolf and Mother
+ .cut({ x: 1000, y: 565, z: 2.6 }, T.D3).to({ x: 1060 }, T.walk, .8) // D3: decided, she steps
+ .cut({ x: 1170, y: 792, z: 3 }, T.E) // E: feet off the path
+ .cut({ x: 1530, y: 630, z: 1.9 }, T.F).to({ x: 1600 }, PICKS[1], 2) // F: picking
+ .cut({ x: s4_wolfX(T.G, T.G) + 30, y: 700, z: 1.8 }, T.G) // G: low follow, then he runs out
+ .to({ x: t => s4_wolfX(Math.min(t, T.G + 2.3), T.G) + 30 }, T.G, .001)
+ .cut({ x: 1760, y: 500, z: 1 }, T.H); // H: alone
+
stopClock(D, (q, f) => {
cam.apply(q, f);
- const s = .6, run = q >= RUN;
- if (!run) {
- const sweep = span(q, C('s04', 1.7), C('s04', 2.1));
- wolf.pose({ x: 2120, y: hipOn(WOODS, s, 200), s, turn: q < C('s04', 1.6) ? -1 : q < C('s04', 1.9) ? .2 : 1,
- lean: q < C('s04', 1.5) ? 8 * span(q, C('s04', 0), C('s04', .3)) : 0, ua: q < C('s04', 1.5) ? -50 : -60 - 50 * sweep, fa: -20,
- mouth: lips(q, 'scene4', PRE4, 's04'), tail: 8 * Math.sin(q * 5), shut: blinking(q, [1.1]) }, f);
+ cam.show('fore', !between(q, T.E, T.F)); // the insert: the big fore flowers would hide her feet
+ // sky and meadow life
+ sun.pose(1300, 170, .8, q * 6);
+ clouds[0].pose(640 + 6 * q, 120, 1); clouds[1].pose(1500 + 6 * q, 70, .8);
+ const flee = q >= T.G ? Math.max(0, q - (T.G + .25 + (2250 - 2100 - 140) / 330)) : 0; // up and away as the wolf comes by
+ bird.pose(2250 + 260 * flee, 788 - 420 * flee - 30 * Math.sin(Math.min(1, flee * 3) * Math.PI / 2), .7,
+ flee > 0 ? { flap: onTwos(q) } : { peck: Math.floor(q * FPS / 3) % 4 === 0 ? 1 : 0, look: Math.sin(q * 1.3) });
+ vis(bird.g, flee < 1.5);
+ const wings = [1, .7, .35, .7][Math.floor(q * FPS / 2) % 4];
+ flies[0].pose(1640 + 110 * Math.sin(q * .9), 620 + 40 * Math.sin(q * 2.3), .5, wings);
+ flies[1].pose(2150 + 160 * Math.sin(q * .6 + 1), 580 + 50 * Math.sin(q * 1.9), .45, [.7, .35, .7, 1][Math.floor(q * FPS / 2) % 4]);
+ edge.forEach(([fl, x, y, k], i) => fl.pose(x, y, k, { sway: 3 * Math.sin(q * 1.4 + i), on: between(q, T.E, T.F) }));
+ near.forEach(([fl, x], i) => fl.pose(x, 812 + 6 * (i % 2), .75, { sway: 4 * Math.sin(q * 1.7 + i) }));
+
+ // ---- Red
+ const done = PICKS.filter(t => q >= t + PICK * .88).length;
+ PICKS.forEach((t, i) => flowers[i].pose(RX[i] + REACH, 806, 1.2, { sway: 3 * Math.sin(q * 1.5 + i), on: q < t + PICK * .38 }));
+ const breathe = 1.2 * Math.sin(q * 2.2);
+ if (q < T.walk) {
+ const front = between(q, T.D2, T.D3);
+ const turn = q < T.D1 ? -1 + 2 * span(q, T.sweep + .35, T.sweep + .65) : 1; // to the meadow, in the wide
+ red.pose({ x: 1060, y: hipOn(795, s) + breathe * .3, s, head: front ? 'F' : 'P', turn,
+ headR: front ? 0 : q < T.D1 ? (q > T.sweep + .2 ? -5 : 2) : 7 * span(q, T.D1 + .1, T.D1 + .4) - 6 * span(q, T.D3 + .05, T.D3 + .2),
+ lean: q >= T.D1 && q < T.D2 ? 7 * span(q, T.D1 + .35, T.D2 - .1) : 0,
+ nod: front ? 5 * span(q, T.D2 + .05, T.D2 + .3) : q >= T.D3 + .2 && q < T.D3 + .45 ? 4 : 0,
+ brow: front ? 1 + span(q, T.cloud + .2, T.cloud + .5) : 0,
+ mouth: front && q >= T.cloud + .45 ? (q < T.D3 - .25 ? 'G' : 'A') : 'X',
+ shut: blinking(q, [.6, T.C + .9, T.D1 + .6, T.D2 + 1.05, T.D3 + .1]) }, f);
+ } else if (q < T.step) {
+ const w = walk(Math.min(q - T.walk, .5), { period: 1, A: 18 }); // one step to the edge
+ red.pose({ x: 1060 + w.d * s, y: hipOn(795, s) + w.drop * s, s, near: w.near, far: w.far,
+ kNear: w.kNear, kFar: w.kFar, headR: q > T.E ? 6 : 1, shut: blinking(q, [T.walk + .9]) }, f);
+ } else if (q < T.F) {
+ const u = Math.min(1, (q - T.step) / .6), b = bigStep(u), x0 = 1060 + STEP;
+ // the kit's step keeps the hip up: drop it so the reaching foot lands, and bend the back knee to keep that foot down
+ const drop = 166 * (1 - Math.cos(b.near * Math.PI / 180)), k = 30 * ease(u);
+ red.pose({ x: x0 + b.d * s, y: hipOn(795 + 5 * ease(u), s) + drop * s, s, near: b.near, far: b.far, kNear: b.kNear, kFar: b.kFar + k, headR: 6 }, f);
} else {
- const w = runner(q - RUN);
- wolf.pose({ x: w.x, y: hipOn(WOODS, s, 200) + w.drop * s - 6, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar,
- lean: 28, ua: -30 + 45 * Math.sin(w.ph), fa: -40, tail: -25 + 6 * Math.sin(2 * w.ph), mouth: 'D', jaw: .5 }, f);
+ // skip in (three steps), then a pick at each PICKS time, with one step forward before each one after the first
+ const skip = walk(Math.min(q - T.F, 1.05), { period: .7, A: 26, knee: 50 }), inSkip = q - T.F < 1.05;
+ let x = inSkip ? 1205 + skip.d * s : RX[0], pose = {}, legs = inSkip ? skip : null;
+ PICKS.forEach((t, i) => {
+ if (i && q >= t - .3) { const st = walk(Math.min(q - (t - .3), .25), { period: .5, A: 18 }); x = RX[i - 1] + st.d * s; if (q < t - .05) legs = st; }
+ if (between(q, t, t + PICK)) pose = s4_pick((q - t) / PICK, FLOWER_COLS[i]);
+ });
+ const hop = inSkip ? -10 * Math.abs(Math.sin(skip.ph)) : 0;
+ red.pose({ x, y: hipOn(800, s) + (legs ? legs.drop * s : 0) + hop, s,
+ near: legs ? legs.near : 0, far: legs ? legs.far : 0, kNear: legs ? legs.kNear : 0, kFar: legs ? legs.kFar : 0,
+ lean: pose.lean || 0, crouch: pose.crouch || 0, fua: pose.fua ?? null, ffa: pose.ffa ?? -10, held: pose.held || null,
+ ua: -8 - .6 * (pose.lean || 0), swing: -(pose.lean || 0), bouquet: done,
+ headR: pose.lean ? 0 : inSkip ? -3 : 2, mouth: 'X', shut: blinking(q, [T.F + 1.6, PICKS[2] + 1.1, T.H + .4]) }, f);
}
- // Red: before the pan she stands at the bend; off-screen she runs on; in the meadow she skips in and picks
- if (q < PICK) {
- red.pose({ x: 1883, y: hipOn(WOODS, s), s, ua: -8, fa: -78, headR: -3, shut: blinking(q, [2.4]) }, f);
+
+ // ---- the wolf
+ vis(wolf.g, q < T.E || between(q, T.G, T.H));
+ if (q < T.G) {
+ // he leans in to ask, then sweeps his arm up past her to the meadow and stays, watching her go
+ const sweep = span(q, T.sweep + .1, T.sweep + .55), watch = q >= T.D1;
+ wolf.pose({ x: 860, y: hipOn(790, s, 200) + breathe * .4, s, turn: 1,
+ lean: q < T.C ? 6 + 8 * span(q, T.B, T.B + .4) : watch ? 10 : 6,
+ ua: q < T.C ? (q >= T.B + .1 ? -42 : 4) : watch ? -30 + 8 * onTwos(q) * (q > T.D3) : -10 - 110 * sweep + 10 * span(q, T.sweep + 1.6, T.sweep + 2.2),
+ fa: q < T.C ? (q >= T.B + .1 ? -62 : -70) : watch ? -90 : -10 * sweep,
+ mouth: lips(q, 'scene4', PRE4, 's04'), tail: 10 * Math.sin(q * 4), brow: q < T.C || watch ? .8 : 0,
+ headR: watch ? -4 : 0, look: 1, shut: blinking(q, [.35, T.B + 1.0, T.D1 + 1.2, T.D3 + .6]) }, f);
} else {
- const sm = .44, gy = 722, w = walk(Math.min(q - PICK, 1.9), { period: .7, A: 24 }), x = 2440 + w.d * sm; // out in the meadow, beyond the path
- const picks = [7.3, 8.0, 8.7, 9.4, 10.6, 11.4, 12.2].map(t => t + PRE4), done = picks.filter(t => q >= t + .35).length;
- const bend = picks.some(t => between(q, t, t + .35));
- red.pose({ x: x + 40 * done, y: hipOn(gy, sm) + w.drop * sm - (q - PICK < 1.9 ? 8 * Math.abs(Math.sin(w.ph)) : 0) + (bend ? 10 : 0), s: sm,
- near: w.near, far: w.far, kNear: bend ? 30 : w.kNear, kFar: bend ? 20 : w.kFar, ua: bend ? 40 : -8, fa: bend ? 30 : -78,
- headR: bend ? 14 : -2, bouquet: done, shut: blinking(q, [9.0]) }, f);
+ const x = s4_wolfX(q, T.G), d = (x - s4_wolfX(T.G, T.G)) / s, off = q - T.G;
+ wolf.pose({ x, y: hipOn(800, s, 200), s, run: d, crouch: off < .25 ? .6 * (1 - off / .25) : 0,
+ jaw: .45, ear: -1, brow: 1, tail: -14 + 6 * onTwos(q), look: 1, shut: false }, f);
+ }
+
+ // ---- the thought picture
+ const k = s4_think(q, T.cloud, T.cloudOff);
+ vis(th, k > 0);
+ if (k > 0) {
+ th.setAttribute('opacity', Math.min(1, k * 1.4).toFixed(2));
+ tf(thIn, `translate(1190,230) scale(${(.85 + .15 * Math.min(1, k)).toFixed(3)})`);
+ mom.pose({ x: 0, y: 190, s: 1.05, head: 'F', finger: true, rua: -28, rfa: -146 + (q > T.cloud + .35 ? 9 * onTwos(q) : 0), lua: 6, lfa: -4,
+ brow: -.7, mouth: 'A', shut: false }, f);
}
});
}
+// The wolf's x on the run, from a crouch at t0 at x 2100: 330 a second (2.5 strides), faster once the camera lets him go.
+function s4_wolfX(q, t0) {
+ const t = Math.max(0, q - t0 - .25), a = .35, v = 330;
+ const x = 2100 + (t < a ? v * t * t / (2 * a) : v * (t - a / 2));
+ return x + Math.max(0, t - 2.05) ** 2 * 140;
+}
diff --git a/site/little-red-riding-hood/ch01/scene4w.js b/site/little-red-riding-hood/ch01/scene4w.js
index 816812c..992f182 100644
--- a/site/little-red-riding-hood/ch01/scene4w.js
+++ b/site/little-red-riding-hood/ch01/scene4w.js
@@ -1,49 +1,130 @@
-/* scene4w.js — in the meadow (point and read).
- Meanwhile, back in the meadow: Red stands up from her picking and turns to us, and the page waits while the reader
- taps the things in the picture to hear their names. The camera holds still, so the hit shapes for the things baked
- into the set (tree, sun, cloud, flowers) are placed by where they show on screen at this view. */
+/* scene4w.js — in the meadow: listen and find (lib/find.js, as Little Horse's scenes 3 and 8).
+ s04w "Little Red Riding Hood wanted flowers for Grandma. Help her look! Listen, and touch what she asks for."
+ Shot 1 (0 – "Help"): medium close, Red bent over one flower, picks it on "flowers", holds it up, and it goes into
+ her bouquet on "Grandma". Shot 2 (cut on "Help", a little wide): she looks about the meadow in profile, turns round
+ to us on "Listen", her eyes on the butterfly, while the camera eases in to the game's frame (still from D on). The game: she asks for a flower, the butterfly, the bird
+ (find.js speaks; her mouth follows findMouth(), her eyes go to FIND.target while she waits, to us while she asks).
+ The flower the child touches flies into her bouquet. The bird pecks and hops along the tree top, the butterfly
+ loops over the grass, the sun's rays turn, the cloud drifts. Every visible thing answers a tap with its name. */
'use strict';
-const PRE4W = 1.2, CAM4W = { x: 3250, y: 480, z: 1.2 };
-let MEADOW_THINGS = [];
-// A screen point of the fixed view, in the world of its k = 1 plane (where hit shapes and puppets go).
-const meadowAt = (sx, sy) => [CAM4W.x + (sx - 800) / CAM4W.z, CAM4W.y + (sy - 450) / CAM4W.z];
-// birdProp and butterflyProp live in lib/shared.js (the meadow props).
+const PRE4W = 1.0;
+let MEADOW_THINGS = []; // filled by scene4w each time it builds; findWords (lib/find.js) reads it
+sfx('scene4w', 0, 'meadow', .6);
+sfx('scene4w', PRE4W + 1.55, 'rustle', .5); // the stem snaps
+
+const s4w_RX = 2300, s4w_GY = 795, s4w_S = .6, s4w_B0 = 5; // Red on the grass; flowers in her bunch from scene 4 (5; 7 by scene 7)
+const s4w_GAME = { x: 2430, y: 590, z: 1.65 }; // the tapping frame: cloud and flowers to tree and bird
+const s4w_CLUMP = [[2105, '#d6493f', .95, 0], [2160, '#efae48', 1.05, 1.7], [2212, '#e88ab0', .9, 3.1]]; // x, colour, s, phase
+const s4w_PICK = { x: s4w_RX + 30, col: '#f6efe0' }; // the one she picks in shot 1
+const s4w_bump = (q, t0, d) => q < t0 || q > t0 + d ? 0 : Math.sin(Math.PI * (q - t0) / d);
+// the screen-left (bouquet) hand of the front figure, in puppet units from the hip (armsF in cast.js)
+const s4w_hand = (lua, lfa) => { const r = Math.PI / 180, a = lua * r, b = (lua + lfa) * r;
+ return [-30 - 52 * Math.sin(a) - 48 * Math.sin(b), -126 + 52 * Math.cos(a) + 48 * Math.cos(b)]; };
+// the butterfly's loop over the grass between Red and the tree; the bird's place on the tree top
+const s4w_flyAt = q => ({ x: 2490 + 60 * Math.sin(.7 * q) + 12 * Math.sin(2.1 * q + 1), y: 650 + 22 * Math.sin(1.3 * q) + 6 * Math.sin(3.1 * q) });
+function s4w_birdAt(q) { // every 3.1 s a hop to a new place along the crown, then a peck or a look about
+ const T = 3.1, k = Math.floor(q / T), u = q - k * T, X = i => 2715 + 70 * (.5 + .5 * jit(i, 47));
+ const a = X(k - 1), b = X(k), dir = b > a ? 1 : -1;
+ if (u < .35) { const w = u / .35; return { x: a + (b - a) * ease(w), hop: 18 * Math.sin(Math.PI * w), dir, flap: k % 3 === 0 ? onTwos(q) : 0 }; }
+ return { x: b, hop: 0, dir: k % 2 ? dir : -dir, peck: u > 1.2 && u < 1.5 ? 1 : 0, look: u > 2 && u < 2.6 ? 1 : 0 };
+}
+
function scene4w(p, D) {
- const cam = paperCam(p, 'forest', CAM4W), st = cam.stage;
- // the set's own clouds sit at the very top of this view: one more, lower and drifting, is the one to tap
- const sky = mk('g', {}, st);
- prop(sky, `<g filter="url(#paper)"><circle cx="-40" cy="10" r="30" fill="#fbf4e2"/><circle cx="0" cy="-8" r="40" fill="#fbf4e2"/>
- <circle cx="45" cy="8" r="32" fill="#fbf4e2"/><rect x="-70" y="10" width="148" height="30" rx="15" fill="#fbf4e2"/></g>`);
- mk('rect', { x: -80, y: -56, width: 170, height: 106, rx: 40, fill: 'transparent' }, sky);
- const hits = mk('g', {}, st); // invisible hit shapes over the set's own things, under the puppets
- const spot = (word, d) => { const g = mk('g', {}, hits); mk('path', { d, fill: 'transparent' }, g); return { g, word }; };
- const at = (sx, sy) => meadowAt(sx, sy).map(v => v.toFixed(0)).join(',');
- const circle = (sx, sy, r) => { const [x, y] = meadowAt(sx, sy), R = r / CAM4W.z; return `M${x - R},${y} a${R},${R} 0 1 0 ${2 * R},0 a${R},${R} 0 1 0 ${-2 * R},0 Z`; };
- const box = (x0, y0, x1, y1) => `M${at(x0, y0)} L${at(x1, y0)} L${at(x1, y1)} L${at(x0, y1)} Z`;
- const sun = spot('sun', circle(1200, 85, 88)), tree = spot('tree', box(905, 425, 1112, 690)), flower = spot('flower', box(885, 700, 1040, 795));
- const red = redPuppet(st), bird = birdProp(st), fly = butterflyProp(st);
- MEADOW_THINGS = [sun, { g: sky, word: 'cloud' }, tree, flower, { g: red.g.querySelector('[data-p="basketF"]'), word: 'basket', side: 'right' }, // the basket in her hand; above it is her face
- { g: bird.g, word: 'bird' }, { g: fly.g, word: 'butterfly' }];
- const [RX] = meadowAt(640, 0), GY = 738, s = .6;
- const [BX, BY] = meadowAt(1478, 362); // the bird on the crown of the round tree at the right
- // Red: bent over a flower, then up and round to face us (1.0–1.6); after that she breathes and looks about,
- // for as long as the page waits (draw runs on past D).
- const draw = (q, f) => {
- cam.apply(q, f);
- const up = span(q, .9, 1.3), turn = q < 1.1 ? 1 : 1 - Math.min(1, (q - 1.1) / .5), front = q >= 1.6;
- const look = front ? Math.sin(q * .9) : 0, breathe = Math.sin(q * 2.4);
- red.pose({ x: RX, y: hipOn(GY, s) + 10 * (1 - up) - (front ? 1.5 * breathe : 0), s, turn, head: front ? 'F' : 'P',
- kNear: 30 * (1 - up), kFar: 20 * (1 - up), ua: front ? -8 : 40 * (1 - up) - 8 * up, fa: front ? -78 : 30 * (1 - up) - 78 * up,
- rua: 8 + 2 * breathe, rfa: -6, lua: -14, lfa: 40, headR: front ? 6 * look : 14 * (1 - up), cape: 3 + 2 * breathe,
- bouquet: 7, shut: blinking(q, [2.6, 6.4]) || (q > D && (q % 4.3) < 2 / FPS) }, f);
- const peck = Math.floor(q * 1.3) % 3 === 0 && (q * 1.3) % 1 < .25 ? 1 : 0;
- bird.pose(BX, BY, .8, { peck, look: peck ? 0 : Math.sign(Math.sin(q * .7)) });
- // the butterfly loops slowly over the flowers at the right, wings on twos
- const [FX, FY] = meadowAt(1275 + 50 * Math.sin(q * .8), 640 + 22 * Math.sin(q * 1.6));
- const [CX, CY] = meadowAt(560 + 40 * Math.sin(q / 6), 205);
- tf(sky, `translate(${CX.toFixed(1)},${CY.toFixed(1)}) scale(1.2)`);
- fly.pose(FX, FY, 1.3, [1, .7, .35, .7][Math.floor(q * FPS / 2) % 4]);
+ const C = t => clipAt('scene4w', PRE4W, 's04w', t), HELP = C(3.4), LISTEN = C(4.55);
+ const cam = paperCam(p, 'meadow', { x: s4w_RX - 10, y: 668, z: 2.5 });
+ cam.to({ x: s4w_RX + 10, y: 660, z: 2.75 }, 0, HELP); // a slow push while she picks
+ cam.cut({ x: 2420, y: 575, z: 1.45 }, HELP).to(s4w_GAME, LISTEN, D - LISTEN); // in on her as she turns to us; still from D (the taps)
+ const st = cam.stage;
+ const sun = sunProp(st), cloud = cloudProp(st);
+ const tree = mk('rect', { x: 2610, y: 450, width: 270, height: 290, fill: 'transparent' }, st); // painted into the set
+ const bird = birdProp(st), fly = butterflyProp(st);
+ const red = redPuppet(st);
+ const pick = flowerProp(st, s4w_PICK.col);
+ const clumpG = mk('g', {}, st), clump = s4w_CLUMP.map(([, col]) => flowerProp(clumpG, col));
+ const headF = red.g.querySelector('[data-p="headF"]'), eyes = [...headF.querySelectorAll('.eyeO, .eyeC')];
+ const basket = red.g.querySelector('[data-p="basketF"]');
+ // where each thing is in the world (for her eyes)
+ let B = s4w_birdAt(0), F = s4w_flyAt(0);
+ const where = new Map([[sun.g, () => [2600, 395]], [cloud.g, () => [2060, 420]], [tree, () => [2745, 560]], [bird.g, () => [B.x, 440]],
+ [fly.g, () => [F.x, F.y]], [clumpG, () => flying || [2160, 770]], [basket, () => [s4w_RX + 30, 690]]]);
+ MEADOW_THINGS = [{ g: clumpG, word: 'flower' }, { g: fly.g, word: 'butterfly' }, { g: bird.g, word: 'bird' },
+ { g: tree, word: 'tree' }, { g: sun.g, word: 'sun' }, { g: cloud.g, word: 'cloud' }, { g: basket, word: 'basket', side: 'right' },
+ { g: red.g, word: 'Red Riding Hood', clip: 'q-me', talk: true, side: 'above' }];
+
+ // the flower the child touched is the one that flies: the last pointer down on the page, nearest flower head
+ let flying = null, tap = null, gotQ = null, gotI = 1, birdQ = -1e9, flyQ = -1e9, sawG = null;
+ const onTap = e => { tap = [e.clientX, e.clientY]; };
+ document.addEventListener('pointerdown', onTap, true);
+ P.cleanup.push(() => document.removeEventListener('pointerdown', onTap, true));
+ const nearest = () => {
+ if (!tap) return 1;
+ let best = 1, bd = Infinity;
+ clump.forEach((c, i) => { const r = c.g.getBoundingClientRect(), d = Math.hypot(r.left + r.width / 2 - tap[0], r.top + r.height * .3 - tap[1]); if (d < bd) { bd = d; best = i; } });
+ return best;
};
- // on twos like stopClock, but a tail run: while the page waits, tapWords runs it on past D on wall time
- clockRun(t => { const f = Math.floor(t * FPS + 1e-6); draw(f / FPS, f); }, D, { tail: true });
+
+ stopClock(D, (q, f) => {
+ cam.apply(q, f);
+ const wait = q > D, saying = wait && FIND.saying, breathe = Math.sin(q * 2.3);
+ // what find.js has just done: the flower found (it flies), the bird or the butterfly found (they show off)
+ if (FIND.found === clumpG && gotQ === null) { gotQ = q; gotI = nearest(); }
+ const saw = findSaw();
+ if (saw !== sawG) { sawG = saw; if (saw === bird.g) birdQ = q; if (saw === fly.g) flyQ = q; }
+ const fly01 = gotQ === null ? 0 : Math.min(1, (q - gotQ) / 1.0), landed = fly01 >= 1, glad = landed ? s4w_bump(q - gotQ - 1, 0, .4) : 0;
+
+ // ---- Red ----
+ const front = q >= LISTEN + 3 / FPS, praise = saying === 'q-done';
+ const LUA = praise ? 150 : -12 + 1.5 * breathe, LFA = praise ? 10 : -10; // the bunch in front of her apron; up high for the praise
+ let o;
+ if (q < HELP) { // shot 1: bent to the flower, picks it on "flowers", shows it, into the bunch on "Grandma"
+ const PK = C(1.55), up = span(q, PK + .1, PK + .6), into = span(q, C(2.5), C(2.9));
+ const tug = q < PK ? 3 * s4w_bump(q % .9, .5, .3) : 0;
+ o = { turn: 1, ua: -35 * (1 - up) - 8 * up, fa: -78 * up, lean: 62 * (1 - up) + 12 * up * (1 - into), crouch: .7 * (1 - up), fua: q < C(2.9) ? -50 * (1 - up) - 95 * up + 40 * into : null,
+ ffa: 10 * (1 - up) - 50 * up + tug, held: q >= PK && q < C(2.8) ? s4w_PICK.col : null, bouquet: s4w_B0 + (q >= C(2.8) ? 1 : 0),
+ headR: 16 * (1 - up) - 6 * up * (1 - into) + 4 * into, shut: blinking(q, [.6, C(2.2)]) };
+ } else if (!front) { // shot 2: looks over the meadow (up to the tree top, down at the flowers), then turns round to us
+ const k = Math.floor((q - LISTEN) * FPS / 2);
+ o = { turn: q < LISTEN ? 1 : [1, .6, .25][Math.min(2, k)], headR: q < C(3.95) ? -12 : 10, bouquet: s4w_B0 + 1, shut: blinking(q, [C(4.2)]) };
+ } else { // facing us: breathing, a small weight shift, the bunch in her screen-left hand, the basket in the right
+ const hop = praise ? -14 * Math.abs(Math.sin((q - D) * 7)) : -10 * glad - 8 * s4w_bump(q, C(4.95), .35); // hops: as the flower lands; on "and"
+ const pre = !wait; // before the game: her head follows the butterfly's loop, nods on "touch" and "asks for"
+ const headR = pre ? 3 + 6 * Math.sin(.7 * q) : 2.5 * Math.sin(q * .6) + (saying ? 3 * Math.sin(q * 4) : 0);
+ o = { turn: 0, head: 'F', y: hop, rua: 8 + 2 * breathe, rfa: -6, lua: LUA, lfa: LFA,
+ bouquet: s4w_B0 + 1 + (landed ? 1 : 0), cape: 3 + 2 * breathe, headR, nod: pre ? 7 * s4w_bump(q, C(5.4), .5) + 7 * s4w_bump(q, C(6.3), .5) : 0,
+ mouth: wait ? findMouth() : 'X', shut: !saying && (blinking(q, [C(5.8)]) || (wait && (q % 3.7) < 2 / FPS)) };
+ }
+ red.pose({ x: s4w_RX + (front ? 1.5 * Math.sin(q * .45) : 0), s: s4w_S, ...o, y: hipOn(s4w_GY, s4w_S) - (front ? 1.2 * breathe : 0) + (o.y || 0) }, f);
+ // her eyes: to us while she speaks, else to the thing asked for (or the one just found), else wandering
+ let dx = 0, dy = 0;
+ const look = !wait ? where.get(fly.g) : saw && where.get(saw) || (!saying && FIND.target && where.get(FIND.target));
+ if (front && look) { const [tx, ty] = look(), hx = s4w_RX, hy = s4w_GY - 330 * s4w_S; dx = 3.5 * Math.max(-1, Math.min(1, (tx - hx) / 160)); dy = 2.5 * Math.max(-1, Math.min(1, (ty - hy) / 160)); }
+ else if (front && !saying) dx = 2.5 * Math.sin(q * .8);
+ eyes.forEach(e => tf(e, `translate(${dx.toFixed(1)},${dy.toFixed(1)})`));
+
+ // ---- the flower she picks in shot 1 ----
+ pick.pose(s4w_PICK.x, s4w_GY + 2, .95, { sway: 4 * Math.sin(q * 1.6) + (q < C(1.55) ? 6 * s4w_bump(q % .9, .5, .3) : 0), on: q < C(1.55) });
+ // ---- the clump to find; the found one flies up in an arc into her bunch, turning ----
+ flying = null;
+ s4w_CLUMP.forEach(([x, , s, ph], i) => {
+ if (i === gotI && gotQ !== null && !landed) { // (landed: hidden back home, so the clump's hit box shrinks again)
+ const [hx, hy] = s4w_hand(LUA, LFA), tx = s4w_RX + hx * s4w_S, ty = hipOn(s4w_GY, s4w_S) + (hy - 46) * s4w_S;
+ const u = ease(fly01), sz = s * (1 - .45 * u + .45 * Math.sin(Math.PI * fly01)), y0 = s4w_GY + 40; // foot placed so the head lands on the bunch
+ const fx = x + (tx - x) * u, fy = y0 + (ty + 70 * sz - y0) * u - 170 * Math.sin(Math.PI * fly01);
+ flying = [fx, fy - 70 * sz];
+ clump[i].pose(fx, fy, sz, { sway: 360 * fly01 });
+ } else clump[i].pose(x, s4w_GY + 40, s, { sway: 5 * Math.sin(q * 1.3 + ph), on: !(i === gotI && landed) });
+ });
+ // ---- the sky ----
+ sun.pose(2600, 395, .7, q * 4);
+ cloud.pose(2060 + 25 * Math.sin(q / 5), 420 + 3 * Math.sin(q / 2), 1);
+ // ---- the bird on the tree top: hops, pecks, looks; found, it flaps for a moment ----
+ B = s4w_birdAt(q);
+ const shows = q - birdQ < 1;
+ const by = 440 - B.hop - (shows ? 16 * s4w_bump(q - birdQ, 0, 1) : 0);
+ bird.pose(B.x, by, .8, { peck: shows ? 0 : B.peck || 0, flap: shows ? onTwos(q) : B.flap || 0, look: B.look || 0 });
+ if (B.dir < 0) tf(bird.g, `translate(${B.x.toFixed(1)},${by.toFixed(1)}) scale(-.8,.8)`); // birdProp only faces right
+ // ---- the butterfly: loops over the grass, wings on twos; found, a quick climb and back ----
+ F = s4w_flyAt(q);
+ fly.pose(F.x, F.y - 40 * s4w_bump(q - flyQ, 0, 1.2), 1, [1, .7, .35, .7][Math.floor(q * FPS / (q - flyQ < 1.2 ? 1 : 2)) % 4]);
+ });
}
diff --git a/site/little-red-riding-hood/ch01/scene5.js b/site/little-red-riding-hood/ch01/scene5.js
index 9a25404..f91d191 100644
--- a/site/little-red-riding-hood/ch01/scene5.js
+++ b/site/little-red-riding-hood/ch01/scene5.js
@@ -1,37 +1,98 @@
-/* scene5.js — Grandma's door. */
+/* scene5.js — Grandma's door (storyboard v2 §5, director finding #5).
+ Shots (beat clock; PRE5 is the arrival):
+ A 0 – 4.4 the wide under the three oaks (the woodcutter's block, his axe left in it); the wolf gallops in on all
+ fours from the left, skids, crouches and looks both ways, rises and tiptoes to the door; slow push in
+ B 4.4 – s05 2.3 door close-up: three knocks, a paw at his throat, the squeaky "Grandma! It's me, Little Red…",
+ fluttering his lashes on "It's me"
+ C s05 2.3 – s05b 2.15 inside, Grandma in bed (the listener): she perks up at the name, sniffs, "Just lift the latch,
+ dear," pointing to the door
+ D s05b 2.15 – door5 back outside, the wolf's sly grin on "and come in", rubbing his paws
+ E door5 (2 s) from inside: the latch lifts (latch), the door creaks open on the wolf's dark shape against the daylight
+ Last frame: the room's door open, the wolf's silhouette (scene 6 opens on him in the doorway). */
'use strict';
-const PRE5 = 4.0;
-[3.45, 3.62, 3.79].forEach(t => sfx('scene5', t, 'knock', 2)); // the engine plays at half the vol: 2 is full
+const PRE5 = 5.6;
+const s5_C = (c, t = 0) => clipAt('scene5', PRE5, c, t);
+const s5_IN = s5_C('s05', 2.3), s5_OUT = s5_C('s05b', 2.15), s5_DOOR = s5_C('door5');
+const s5_KNOCK = [55, 57, 59].map(k => k / FPS), s5_TIP = 3.0, s5_TIPP = .9; // the knocks; the tiptoe starts at s5_TIP, a step every s5_TIPP / 2
+// the woodcutter's place by the oaks (scene 7 has him chopping here): a block, a log on it and split logs; axe: his axe
+// stuck in the block (he is not here yet)
+const s5_WX = 400, s5_WY = 772, s5_CHIMNEY = [1483, 258]; // Grandma's fire is lit: smoke from the chimney in 5 and 7
+function s5_woodPile(parent, axe) {
+ const X = s5_WX, Y = s5_WY;
+ return prop(parent, `<g filter="url(#paper)"><path d="M${X + 56},${Y} L${X + 60},${Y - 78} L${X + 116},${Y - 78} L${X + 120},${Y} Z" fill="#7a5034"/><ellipse cx="${X + 88}" cy="${Y - 78}" rx="28" ry="7" fill="#c9a074"/>
+ <rect x="${X + 74}" y="${Y - 118}" width="28" height="40" fill="#a37a52"/><ellipse cx="${X + 88}" cy="${Y - 118}" rx="14" ry="4.5" fill="#d8b88a"/>
+ <path d="M${X - 120},${Y} l60,0 l-6,-22 l-56,4 Z M${X - 110},${Y - 20} l56,-4 l-4,-20 l-54,6 Z" fill="#a37a52"/></g>
+ ${axe ? `<g filter="url(#paper)" transform="rotate(-24,${X + 92},${Y - 80})"><rect x="${X + 89}" y="${Y - 166}" width="7" height="88" rx="3" fill="#8a5a32"/>
+ <path d="M${X + 80},${Y - 90} L${X + 108},${Y - 92} L${X + 110},${Y - 74} L${X + 78},${Y - 74} Z" fill="#9aa0a6"/></g>` : ''}`);
+}
+// the shape in the doorway seen from inside: daylight behind, so a dark figure (scenes 5 and 7 share the look)
+document.body.insertAdjacentHTML('beforeend', `<svg width="0" height="0" style="position:absolute" aria-hidden="true"><defs>
+ ${[30, 55, 80].map(k => `<filter id="s5_dark${k}" color-interpolation-filters="sRGB"><feComponentTransfer><feFuncR type="linear" slope="${k / 100}"/><feFuncG type="linear" slope="${k / 100}"/><feFuncB type="linear" slope="${(k + 6) / 100}"/></feComponentTransfer></filter>`).join('')}
+</defs></svg>`);
+
+sfx('scene5', 0, 'forest', .5);
+sfx('scene5', s5_IN, 'room', .4);
+[1.0, 1.44].forEach(t => sfx('scene5', t, 'run', 1.3));
+sfx('scene5', 1.9, 'skid', 1.3);
+[0, 1, 2].forEach(k => sfx('scene5', +(s5_TIP + s5_TIPP * (.25 + k / 2)).toFixed(2), 'pad', 1));
+s5_KNOCK.forEach(t => sfx('scene5', t, 'knock', 2)); // the engine plays at half the vol: 2 is full
+sfx('scene5', s5_DOOR + .05, 'latch', 1.6);
+sfx('scene5', s5_DOOR + .6, 'creak', 1.4);
+
function scene5(p, D) {
- const C = (c, t) => clipAt('scene5', PRE5, c, t);
- const cam = paperCam(p, 'grandmaOut', { x: 900, y: 470, z: 1 }, { after: 'house', stages: ['inside'] });
+ const C = s5_C, s = .6;
+ // outside: the three oaks, the house, the woodcutter's block
+ const cam = paperCam(p, 'grandmaOut', { x: 960, y: 420, z: .85 }, { after: 'house', stages: ['inside'] });
const door = doorLeaf(cam.stage, 'M1010,800 L1010,560 Q1070,510 1130,560 L1130,800 Z', '#3f5f8a', 1010, '<path d="M1040,530 V800 M1070,520 V800 M1100,530 V800" stroke="#2f4a6e" stroke-width="3"/><circle cx="1116" cy="680" r="6" fill="#caa24c"/>');
+ s5_woodPile(cam.stage, true);
+ const puff = smoke(cam.stage, ...s5_CHIMNEY);
const wolf = wolfPuppet(cam.stage);
- // inside: 5.3 Grandma in bed answers; 5.4 from inside, the latch lifts and the door opens on the wolf
- const inn = paperCam(p, 'room', { x: 1200, y: 560, z: 2.3 }), R = roomProps(inn, []), gran = grandmaPuppet(R.inBed), wolfIn = wolfPuppet(R.atDoor);
- inn.cut({ x: 330, y: 600, z: 1.8 }, C('s05b', 3.75));
- const RUN = 1.8, SKID = 2.1, TIP = 2.2, KNOCK = 3.45, INSIDE = C('s05b', -.05);
- const runner = walker(-150, .6, { L: 196, A: 26, period: .5, knee: 60 }), tip = walker(650, .6, { period: 1.2, A: 28, knee: 50 });
- cam.cut({ x: 1010, y: 610, z: 2.4 }, 3.3);
+ cam.to({ x: 950, y: 432, z: .9 }, 0, 3.2).to({ x: 930, y: 500, z: 1.15 }, 3.2, 1.2); // A: in with him as he creeps up
+ cam.cut({ x: 975, y: 590, z: 2.6 }, 4.4); // B: the door
+ // inside: Grandma in bed; then the door from inside
+ const inn = paperCam(p, 'room', { x: 1252, y: 536, z: 3 }), R = roomProps(inn, []), gran = grandmaPuppet(R.inBed), wolfIn = wolfPuppet(R.atDoor);
+ R.atDoor.setAttribute('filter', 'url(#s5_dark30)');
+ const latch = prop(inn.stage, `<g filter="url(#paper)"><rect x="318" y="596" width="36" height="9" rx="3" fill="#3b2a1e"/></g>`);
+ inn.to({ x: 1248, y: 524, z: 3.5 }, s5_IN + .3, s5_OUT - s5_IN - .3); // slowly in on her while she listens and answers
+ inn.cut({ x: 330, y: 600, z: 1.8 }, s5_DOOR).to({ x: 300, y: 610, z: 2.1 }, s5_DOOR + .9, 1.6);
+ const gallop = [[.8, -320], [2.45, 800]], tip = walker(800, s, { L: 196, A: 11, period: s5_TIPP, knee: 64 }, 1, 3);
stopClock(D, (q, f) => {
- const inside = q >= INSIDE;
+ const inside = q >= s5_IN && (q < s5_OUT || q >= s5_DOOR);
vis(cam.root, !inside); vis(inn.root, inside);
- const s = .6;
if (inside) {
- inn.apply(q, f); R.door(opening(q, C('s05b', 4.3)));
- gran.pose({ x: 1250, y: 630, s: .55, turn: -1, mouth: lips(q, 'scene5', PRE5, 's05b'), nod: between(q, C('s05b', .05), C('s05b', .05) + 2 / FPS) ? 4 : 0, shut: blinking(q, [C('s05b', 2.2)]) }, f);
- vis(wolfIn.g, q >= C('s05b', 4.3));
- wolfIn.pose({ x: 262, y: hipOn(800, s, 200), s, lean: 6, ua: -20, fa: -30, brow: 1 }, f);
+ inn.apply(q, f);
+ const opened = s5_DOOR + .6;
+ R.door(opening(q, opened));
+ tf(latch, q >= s5_DOOR + .25 ? 'rotate(-32,320,600)' : ''); vis(latch, q < opened);
+ // Grandma: hears the name, lifts her head and smiles; a sniff; then her line, a hand toward the door on "latch"
+ const up = span(q, s5_IN + .1, s5_IN + .5), sniff = between(q, C('s05b', -.5), C('s05b', -.5) + 2 / FPS);
+ const point = span(q, C('s05b', .35), C('s05b', .7)) - span(q, C('s05b', 1.9), C('s05b', 2.2));
+ gran.pose({ x: 1250, y: 630, s: .55, turn: -1, headR: -6 * (1 - up) + (sniff ? 5 : 0), nod: sniff ? 3 : 0,
+ mouth: lips(q, 'scene5', PRE5, 's05b'), ua: -50 * point, fa: -40 * point,
+ shut: sniff || blinking(q, [s5_IN + .9, C('s05b', 2.5)]), brow: -.4 * up }, f);
+ // the wolf in the doorway, dark against the day
+ vis(wolfIn.g, q >= opened);
+ wolfIn.pose({ x: 262, y: hipOn(800, s, 200), s, lean: 8, ua: -30, fa: -60 + 6 * onTwos(q), brow: -1, tail: 10 + 8 * onTwos(q),
+ shut: blinking(q, [s5_DOOR + 1.6]) }, f);
return;
}
- cam.apply(q, f); door(1);
+ cam.apply(q, f); door(1); puff(q);
let o;
- if (q < SKID) { const w = runner(Math.min(q, RUN)); o = { x: Math.min(w.x, 600) + (q > RUN ? 50 * span(q, RUN, SKID) : 0), y: hipOn(800, s, 200) + w.drop * s, near: q > RUN ? 28 : w.near, far: q > RUN ? -20 : w.far, kNear: q > RUN ? 0 : w.kNear, kFar: q > RUN ? 0 : w.kFar, lean: q > RUN ? -14 : 28, ua: -30 + 40 * Math.sin(w.ph), fa: -40, tail: -20 }; }
- else { const w = tip(Math.min(q - TIP, 2.4)), x = Math.min(935, w.x); o = { x, y: hipOn(800, s, 200) + w.drop * s - 10, near: x < 935 ? w.near : 0, far: x < 935 ? w.far : 0, kNear: x < 935 ? w.kNear : 0, kFar: x < 935 ? w.kFar : 0, lean: 10, ua: -100, fa: -60, tail: 10 }; }
- if (q >= 3.3) { // 5.2 at the door: three knocks, then a paw at his throat for the high voice
- const knock = [KNOCK, KNOCK + .17, KNOCK + .34].some(t => between(q, t, t + 1 / FPS));
- o = { ...o, x: 935, near: 0, far: 0, kNear: 0, kFar: 0, lean: 6, ua: q < C('s05', 1.5) ? -75 : -10, fa: q < C('s05', 1.5) ? -35 + (knock ? 25 : 0) : -155,
- brow: q > C('s05', 1.5) ? 1 : 0, shut: q > C('s05', 2) && q < C('s05', 2.6) && onTwos(q) > 0, mouth: lips(q, 'scene5', PRE5, 's05') };
+ if (q < s5_TIP) { // the gallop (paws planted by the distance run), braking into a skid, then crouched, looking both ways
+ const r = route(q, gallop, s), low = span(q, 2.4, 2.55);
+ o = { x: r.x, y: hipOn(800, s, 200), run: r.d, skid: span(q, 1.95, 2.15) * (1 - low), crouch: low, tail: -10 + 6 * onTwos(q),
+ ear: q < 2.5 ? -1 : onTwos(q) * .5, look: q < 2.6 ? 1 : q < 2.8 ? -1 : 1, headR: q < 2.6 ? 0 : q < 2.8 ? -8 : 4 };
+ } else if (q < 4.4) { // up on his hind legs, tiptoeing: paws up, knees high
+ const w = tip(q - s5_TIP), done = q - s5_TIP >= 1.5 * s5_TIPP; // walker ends mid-stance: stand straight once done
+ o = { x: w.x, y: hipOn(800, s, 200) + (done ? 0 : w.drop * s), near: done ? 0 : w.near, far: done ? 0 : w.far, kNear: done ? 0 : w.kNear, kFar: done ? 0 : w.kFar, lean: 12,
+ ua: -95, fa: -65, tail: 12, look: 1, brow: -1 };
+ } else { // B and D: at the door
+ const knock = s5_KNOCK.some(t => between(q, t, t + 1 / FPS)), throat = q >= 5.05 && q < C('s05', 2.4);
+ o = { x: tip(9).x, y: hipOn(800, s, 200), lean: 6, ua: throat ? -10 : -75, fa: throat ? -155 : -35 + (knock ? 25 : 0),
+ nod: between(q, 5.2, 5.2 + 2 / FPS) ? 4 : 0, brow: q > 5.05 ? 1 : 0, mouth: lips(q, 'scene5', PRE5, 's05'),
+ shut: (between(q, C('s05', 1.0), C('s05', 1.9)) && onTwos(q) > 0) || blinking(q, [4.45]), tail: 6 * onTwos(q) };
+ if (q >= s5_OUT) o = { ...o, ua: -40, fa: -95 + 12 * onTwos(q), brow: -1, mouth: 'X', tail: 14 + 10 * onTwos(q), look: 1,
+ ear: between(q, s5_OUT + .8, s5_OUT + 1) ? 1 : 0, shut: blinking(q, [s5_OUT + .5]) };
}
wolf.pose({ s, ...o }, f);
});
diff --git a/site/little-red-riding-hood/ch01/scene6.js b/site/little-red-riding-hood/ch01/scene6.js
index 6d62274..18fa60d 100644
--- a/site/little-red-riding-hood/ch01/scene6.js
+++ b/site/little-red-riding-hood/ch01/scene6.js
@@ -1,43 +1,132 @@
-/* scene6.js — the wardrobe. */
+/* scene6.js — the wardrobe. Times are on the beat clock; C(t) is t s into the narrator's s06.
+ A 0 – C 0 wide: the wolf leaning in at the open door, Grandma in bed sees him (scene 5's last frame)
+ B C 0 – C 3.45 medium, Grandma to us: a start, eyes wide behind her glasses; then a set jaw ("quick!")
+ C C 3.45 – C 4.5 bed to wardrobe: she hops out of bed in an arc, flings the wardrobe open, lands inside;
+ her nightcap and glasses fly off onto the pillow
+ I C 4.5 – C 5.2 insert: the pillow, the cap lying there, the glasses landing and rocking
+ D C 5.2 – C 10.25 the wardrobe: she pulls it shut (slam, shake, wobble); in the silence the camera pans left
+ with the wolf creeping in to the head of the bed, his back to the wardrobe; he finds the
+ cap and glasses and puts them on ("The wolf put on her nightcap and glasses")
+ G C 10.25 – C 12.6 the bed: he climbs in, pulls the quilt to his chin and waits (push in)
+ H C 12.6 – end close: the wardrobe door opens a crack, Grandma's eye looks out (eye6) */
'use strict';
-const PRE6 = .6;
-sfx('scene6', PRE6 + TIMINGS.scene6.marks['s06.hide'] + .8, 'bang', 1.6); // the wardrobe slammed shut
+const PRE6 = 1.2;
+const s6_C = t => clipAt('scene6', PRE6, 's06', t);
+const s6_WALK = { t0: s6_C(2.2), period: .88, steps: 11, x0: 262 }; // the wolf's creep from the door to the bed's head
+const s6_SHUT0 = Math.round(s6_C(5.25) * FPS) / FPS, s6_SLAM = s6_SHUT0 + 5 / FPS; // the wardrobe door pulled to, on a frame
+sfx('scene6', 0, 'room', .4, 10); // the room bed (shared.js relays it every 9.5 s)
+sfx('scene6', s6_C(3.56), 'hop', 1.4); sfx('scene6', s6_C(3.68), 'whoosh', 1); sfx('scene6', s6_C(3.95), 'creak', .8);
+sfx('scene6', s6_C(4.62), 'pad', .9); // the glasses land on the pillow (in the insert)
+sfx('scene6', s6_SLAM, 'slam', 2); sfx('scene6', s6_SLAM, 'bang', .9);
+for (let j = 1; j <= s6_WALK.steps; j++) { // his paws, once he is in the picture
+ const t = s6_WALK.t0 + (j - .5) * s6_WALK.period / 2;
+ if (t > s6_C(5.95)) sfx('scene6', +t.toFixed(3), 'pad', 1);
+}
+sfx('scene6', s6_C(10.8), 'creak', .5); // the bed takes his weight
+sfx('scene6', s6_C(12.85), 'creak', .7); // the wardrobe door, just a crack
function scene6(p, D) {
- const HIDE = PRE6 + TIMINGS.scene6.marks['s06.hide'], CAP = PRE6 + TIMINGS.scene6.marks['s06.cap'], W = t => PRE6 + t;
- const cam = paperCam(p, 'room', { x: 1120, y: 480, z: .9 }), R = roomProps(cam, []);
- const granIn = grandmaPuppet(R.inWardrobe), gran = grandmaPuppet(R.inBed), wolfBed = wolfPuppet(R.inBed), wolf = wolfPuppet(R.front);
- const things = prop(R.front, `<g filter="url(#paper)"><path d="M-40,8 C-40,-30 46,-34 54,6 Q8,-10 -40,8 Z" fill="#f6efe0"/></g>`), specs = mk('g', {}, R.front);
- specs.innerHTML = '<circle cx="-12" r="10" fill="none" stroke="#7a5a2a" stroke-width="2.6"/><circle cx="12" r="10" fill="none" stroke="#7a5a2a" stroke-width="2.6"/>';
- const wipe = trunkWipe(p, D - .7, .65);
- // 6.1 the wolf leans in; her eyes go wide; 6.2 she hops into the wardrobe and slams it; 6.3 close on the bed:
- // nightcap, glasses, into bed; then wide again — a crack in the wardrobe door, one eye.
- cam.shake(HIDE + .8, 2 / FPS, 8).cut({ x: 1120, y: 620, z: 1.9 }, CAP).to({ z: 2.15 }, CAP + .1, 4).cut({ x: 1120, y: 480, z: .9 }, W(11));
- const sneak = walker(262, .6, { period: 1.1, A: 26, knee: 50 }, 1, 8);
+ const C = s6_C, SLAM = s6_SLAM, HOP0 = C(3.56), HOP1 = C(4.2), OPEN = C(3.95), SHUT0 = s6_SHUT0;
+ const cam = paperCam(p, 'room', { x: 800, y: 560, z: 1.15 }), R = roomProps(cam, []);
+ // inside the wardrobe: dark; Grandma; and, for the last shot, her face close behind the crack (clipped to the door)
+ mk('rect', { x: 1792, y: 412, width: 140, height: 378, fill: '#2a1a10' }, R.inWardrobe);
+ const granIn = grandmaPuppet(R.inWardrobe);
+ mk('rect', { x: 1792, y: 412, width: 140, height: 378 }, mk('clipPath', { id: 'crack6' }, R.inWardrobe));
+ const eyeG = mk('g', { 'clip-path': 'url(#crack6)' }, R.inWardrobe), granEye = grandmaPuppet(eyeG);
+ // Grandma without her cap, to us: the puppet's front head has only a fringe, so her grey hair is a prop here
+ const HAIR = `<g filter="url(#paper)"><path d="M-44,-194 C-50,-254 50,-254 44,-194 Q24,-226 0,-220 Q-24,-226 -44,-194 Z" fill="#cfc8be"/><circle cy="-252" r="15" fill="#cfc8be"/></g>`;
+ const hairIn = prop(R.inWardrobe, HAIR), hairEye = prop(eyeG, HAIR);
+ // in bed the quilt hides her lower half: clipped at the quilt's lower edge (off once she hops)
+ mk('rect', { x: -500, y: -500, width: 4000, height: 1264 }, mk('clipPath', { id: 'bed6' }, R.inBed));
+ const bedClip = mk('g', { 'clip-path': 'url(#bed6)' }, R.inBed);
+ const gran = grandmaPuppet(bedClip), wolfBed = wolfPuppet(R.inBed);
+ const cap = granCapProp(R.front), specs = granGlassesProp(R.front), wolf = wolfPuppet(R.front);
+ // the quilt's edge he pulls up to his chin, his paws on it
+ const flap = mk('g', {}, R.front);
+ const cloth = prop(flap, `<g filter="url(#paper)"><path d="M-190,8 C-130,6 -110,-60 -64,-66 Q0,-74 64,-66 C86,-60 92,-14 100,8 Z" fill="#b5523b"/><path d="M-112,-40 C-96,-58 -84,-64 -64,-66 Q0,-74 64,-66 C76,-64 84,-56 88,-44" stroke="#c8704a" stroke-width="8" fill="none"/></g>`);
+ const paws = prop(flap, `<g filter="url(#paper)"><circle cx="-30" cy="0" r="12" fill="${FUR2}"/><circle cx="30" cy="0" r="12" fill="${FUR2}"/></g>`);
+ cam.cut({ x: 1200, y: 585, z: 2.9 }, C(0)).to({ x: 1235, y: 585, z: 3.4 }, C(1.84), 1.2).cut({ x: 1580, y: 600, z: 1.7 }, C(3.45)).cut({ x: 1300, y: 625, z: 3.3 }, C(4.5))
+ .cut({ x: 1800, y: 590, z: 1.9 }, C(5.2)).to({ x: 1500, y: 590, z: 1.85 }, C(6.0), 1.0).to({ x: 1470, y: 585, z: 2.0 }, C(7.8), 1.6)
+ .cut({ x: 1290, y: 580, z: 2.0 }, C(10.25)).to({ x: 1250, y: 545, z: 2.6 }, C(11.0), 1.6)
+ .cut({ x: 1916, y: 580, z: 3.4 }, C(12.6)).shake(SLAM, 2 / FPS, 8);
+ const wipe = trunkWipe(p, D - .1, .6); // scene 7 opens on the trunk
+ const lin = (q, a, b) => Math.min(1, Math.max(0, (q - a) / (b - a))), lerp = (a, b, u) => a + (b - a) * u;
+ const GY = 680; // Grandma sitting up in bed, the quilt to her chest (clipped at its lower edge)
+ const breath = q => 1.5 * Math.sin(q * 2.6);
+ const hop = q => { const u = lin(q, HOP0, HOP1); return { u, x: 1250 + 608 * u, y: GY + (684 - GY) * u - 170 * Math.sin(Math.PI * u) }; };
+ const creep = walker(s6_WALK.x0, .6, { period: s6_WALK.period, A: 30, knee: 50 }, 1, s6_WALK.steps), WX = creep(1e9).x;
+ const STOP = s6_WALK.t0 + s6_WALK.steps * s6_WALK.period / 2, WY = hipOn(800, .6, 200);
+ // the cap and glasses: off her head as she leaves the bed, onto the pillow; then up to the wolf's head
+ const CAPOFF = C(3.6), CAPREST = C(4.1), SPOFF = C(3.64), SPREST = C(4.62);
+ const GRAB = C(8.45), CAPON = C(8.85), GRAB2 = C(9.05), SPON = C(9.45), CLIMB0 = C(10.35), CLIMB1 = C(10.85);
+ const c0 = hop(CAPOFF), s0 = hop(SPOFF), capFrom = [c0.x + 5, c0.y - 132], spFrom = [s0.x + 18, s0.y - 113];
+ const capRest = [1282, 628], spRest = [1306, 645], capTo = [WX - 3, WY - 150], spTo = [WX - 26, WY - 130];
stopClock(D, (q, f) => {
cam.apply(q, f); wipe(q); R.door(-.35);
- const hop = Math.min(1, Math.max(0, (q - HIDE) / .7)), inWard = q >= HIDE + .8;
- R.wardrobe(q < HIDE + .45 ? 1 : q < HIDE + .8 ? -.3 : q < W(11.2) ? 1 + (q < HIDE + 1.2 ? .03 * onTwos(q) : 0) : .82);
- vis(gran.g, !inWard);
- const sg = .55, startled = q >= W(1.0);
- gran.pose({ x: 1250 + 605 * ease(hop), y: 630 + (692 - 630) * hop - 130 * Math.sin(Math.PI * hop), s: sg, turn: hop > 0 ? 1 : -1,
- head: startled && hop === 0 ? 'F' : 'P', brow: startled ? 1 : 0, hop: between(q, W(1.0), W(1.0) + 2 / FPS) ? -8 : 0,
- ua: between(q, W(.4), W(1.0)) ? -150 : 6, fa: between(q, W(.4), W(1.0)) ? -30 : -6, rua: -30, rfa: -10, lua: 30, lfa: 10,
- cap: q < HIDE + .1, glasses: q < HIDE + .1 }, f);
- vis(granIn.g, q >= W(11.2));
- granIn.pose({ x: 1830, y: 692, s: sg, head: 'F', cap: false, glasses: false, shut: blinking(q, [W(11.9)]) }, f);
- // her nightcap and glasses fly onto the bed, and wait there for the wolf
- const fly = Math.min(1, Math.max(0, (q - HIDE - .1) / .4)), worn = q >= W(7.4), specsOn = q >= W(8.2);
- vis(things, q >= HIDE + .1 && !worn); tf(things, `translate(${1300 - 120 * fly},${560 + 80 * fly - 90 * Math.sin(Math.PI * fly)}) scale(.55)`);
- vis(specs, q >= HIDE + .1 && !specsOn); tf(specs, `translate(${1280 - 70 * fly},${560 + 84 * fly - 60 * Math.sin(Math.PI * fly)}) scale(.55)`);
- const s = .6, w = sneak(Math.max(0, q - HIDE - 1.2)), bed = Math.min(1, Math.max(0, (q - W(9.0)) / .4));
- const x = q < W(9.0) ? Math.min(1000, w.x) : 1000 + 250 * ease(bed);
- // over the quilt while he climbs, under it once he is in: two of him, one on each side of the quilt
- const tucked = bed >= 1; vis(wolf.g, !tucked); vis(wolfBed.g, tucked);
- (tucked ? wolfBed : wolf).pose({ x, y: q < W(9.0) ? hipOn(800, s, 200) + w.drop * s : hipOn(800, s, 200) + (630 - hipOn(800, s, 200)) * bed - 80 * Math.sin(Math.PI * bed), s,
- turn: q < W(9.0) ? 1 : bed < .5 ? 1 - 2 * bed * 2 : -1, near: q < W(9.0) && x < 1000 ? w.near : 0, far: q < W(9.0) && x < 1000 ? w.far : 0,
- kNear: x < 1000 ? w.kNear : 0, kFar: x < 1000 ? w.kFar : 0, lean: q < W(1.2) ? 22 * span(q, W(.1), W(.5)) : q < HIDE + 1.2 ? 22 : 8,
- ua: between(q, W(7.0), W(7.4)) ? -60 : between(q, W(7.4), W(8.6)) ? -150 : 6, fa: between(q, W(7.0), W(7.4)) ? -30 : between(q, W(7.4), W(8.6)) ? -30 : -6,
- cap: worn ? 'off' : 'on', night: worn, glasses: specsOn, head: q >= W(10.2) ? 'F' : 'P', brow: q >= W(10.2) ? onTwos(q) * .6 : 0,
- tail: 6 * Math.sin(q * 4), shut: blinking(q, [W(2.6), W(9.4)]) }, f);
+ R.wardrobe(q < OPEN ? 1 : q < SHUT0 ? opening(q, OPEN) : q < SLAM ? opening(q, SHUT0, [-.35, -.15, .15, .45, .75, 1])
+ : q < SLAM + .45 ? 1 + .03 * onTwos(q) : 1 - .22 * span(q, C(12.85), C(13.35)));
+ // Grandma in bed, then in the air
+ const h = hop(q), jolt = C(.25), set = C(1.84);
+ vis(gran.g, q < HOP1); if (q >= HOP0) bedClip.removeAttribute('clip-path'); else bedClip.setAttribute('clip-path', 'url(#bed6)');
+ if (q < C(0)) gran.pose({ x: 1250, y: GY, s: .55, turn: -1, hop: between(q, .6, .6 + 2 / FPS) ? -8 : 0, nod: breath(q),
+ ua: q > .6 ? -60 : 6, fa: q > .6 ? -50 : -6, shut: blinking(q, [.3]) }, f);
+ else if (q < C(3.45)) gran.pose({ x: 1250, y: GY, s: .55, head: 'F', turn: -1, hop: between(q, jolt, jolt + 2 / FPS) ? -10 : 0,
+ brow: q < jolt ? .4 : q < set ? 1.4 : -1, mouth: between(q, jolt, C(1.4)) ? 'D' : 'X', crouch: .5 * span(q, C(2.75), C(3.2)),
+ nod: breath(q) + (between(q, C(2.36), C(2.36) + 2 / FPS) ? 6 : 0),
+ rua: between(q, jolt, set) ? -150 : 6, rfa: between(q, jolt, set) ? -110 : -4, lua: between(q, jolt, set) ? 150 : -6, lfa: between(q, jolt, set) ? 110 : 4,
+ shut: blinking(q, [C(1.6), C(3.0)]) }, f);
+ else gran.pose({ x: h.x, y: h.y, s: .55, turn: 1, crouch: q < HOP0 ? .6 : 0, lean: h.u > 0 ? 25 : 0, ua: h.u > 0 ? -100 : -20, fa: -20,
+ cap: q < CAPOFF, glasses: q < SPOFF }, f);
+ // in the wardrobe: lands, then (front, after the cut) pulls the door to
+ vis(granIn.g, q >= HOP1 && q < C(12.6));
+ if (q < C(5.2)) granIn.pose({ x: 1858, y: 680, s: .55, turn: 1, crouch: .6 * (1 - span(q, HOP1, HOP1 + .25)), cap: false, glasses: false, ua: -40, fa: -20 }, f);
+ else granIn.pose({ x: 1858, y: 680, s: .55, head: 'F', cap: false, glasses: false, brow: -1, lua: q < SHUT0 + 2 / FPS ? 80 : 30, lfa: q < SHUT0 + 2 / FPS ? 20 : 10, shut: blinking(q, [SLAM + .1]) }, f);
+ // her eye at the crack: the face slides in from behind the right-hand door
+ vis(hairIn, q >= C(5.2) && q < C(12.6)); tf(hairIn, 'translate(1858,680) scale(.55)');
+ vis(eyeG, q >= C(12.6)); const ex = 1938 + 40 * (1 - span(q, C(13.3), C(13.65)));
+ tf(hairEye, `translate(${ex.toFixed(1)},911) scale(1.6)`);
+ granEye.pose({ x: ex, y: 911, s: 1.6, head: 'F', cap: false, glasses: false,
+ brow: q > C(13.95) ? .8 : 0, shut: blinking(q, [C(13.75), C(14.35)]) }, f);
+ // the cap: off, onto the pillow, then up onto the wolf
+ vis(cap.g, q >= CAPOFF && q < CAPON);
+ if (q < GRAB) { const u = lin(q, CAPOFF, CAPREST); cap.pose(lerp(capFrom[0], capRest[0], u), lerp(capFrom[1], capRest[1], u) - 70 * Math.sin(Math.PI * u), .55, -12 * u); }
+ else { const u = span(q, GRAB, CAPON); cap.pose(lerp(capRest[0], capTo[0], u), lerp(capRest[1], capTo[1], u) - 30 * Math.sin(Math.PI * u), .55 + .07 * u, -12 * (1 - u)); }
+ // the glasses: higher, spinning, they land in the insert and rock still
+ vis(specs.g, q >= SPOFF && q < SPON);
+ if (q < SPREST) { const u = lin(q, SPOFF, SPREST); specs.pose(lerp(spFrom[0], spRest[0], u), lerp(spFrom[1], spRest[1], u) - 4 * 150 * u * (1 - u), .55, 360 * u); }
+ else if (q < GRAB2) { const t = q - SPREST; specs.pose(spRest[0], spRest[1] - (t < .17 ? 12 * Math.sin(Math.PI * t / .17) : 0), .55, 8 + (t < .6 ? 10 * Math.cos(t * 18) * (1 - t / .6) : 0)); }
+ else { const u = span(q, GRAB2, SPON); specs.pose(lerp(spRest[0], spTo[0], u), lerp(spRest[1], spTo[1], u) - 20 * Math.sin(Math.PI * u), .55 + .05 * u, 8 * (1 - u)); }
+ // the wolf
+ const tucked = q >= CLIMB1, capOn = q >= CAPON, spOn = q >= SPON;
+ vis(wolf.g, !tucked); vis(wolfBed.g, tucked);
+ if (tucked) {
+ const waiting = between(q, C(11.5), C(12.4));
+ wolfBed.pose({ x: 1250, y: 630, s: .6, turn: -1, head: 'F', cap: 'off', night: true, glasses: true, nod: breath(q),
+ look: q > C(11.06) && q < C(12.2) ? -1 : 0, brow: waiting ? (onTwos(q) > 0 ? 1 : .3) : .5, shut: blinking(q, [C(12.3)]) }, f);
+ } else if (q >= C(10.25)) { // G: to us, climbing in over the quilt
+ const u = lin(q, CLIMB0, CLIMB1);
+ wolf.pose({ x: lerp(WX, 1250, u), y: lerp(WY, 630, u) - 80 * Math.sin(Math.PI * u), s: .6, turn: -1, head: 'F', cap: 'off', night: true, glasses: true,
+ rua: -20 * Math.sin(Math.PI * u), lua: 20 * Math.sin(Math.PI * u), nod: breath(q) }, f);
+ } else if (q < s6_WALK.t0) { // in the doorway, leaning in, sly
+ wolf.pose({ x: s6_WALK.x0, y: WY, s: .6, lean: 12, brow: .6, look: 1, ua: -20, fa: -40, tail: 8 * Math.sin(q * 3), nod: breath(q), shut: blinking(q, [.9]) }, f);
+ } else if (q < STOP) { // creeping in on tiptoe
+ const w = creep(q - s6_WALK.t0);
+ wolf.pose({ x: w.x, y: WY + w.drop * .6, s: .6, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, lean: 14, ua: -100, fa: -60,
+ brow: .6, tail: 10 * Math.sin(q * 4) }, f);
+ } else { // at the head of the bed: turns his back to the wardrobe, finds them, puts them on
+ const turn = 1 - 2 * lin(q, C(7.1), C(7.1) + 3 / FPS);
+ const scratch = between(q, C(7.4), C(7.8)), reach = lin(q, C(8.1), C(8.35)) * (1 - lin(q, GRAB, CAPON)), reach2 = lin(q, C(8.9), GRAB2) * (1 - lin(q, GRAB2, SPON));
+ const lift = between(q, GRAB, CAPON + .1) ? lin(q, GRAB, CAPON) : 0, lift2 = between(q, GRAB2, SPON + .1) ? lin(q, GRAB2, SPON) : 0;
+ const preen = q >= SPON + .1;
+ let ua = 6, fa = -6;
+ if (scratch) ua = -165, fa = -60 + 20 * onTwos(q);
+ else if (lift) ua = lerp(-40, -170, lift), fa = lerp(-20, -40, lift);
+ else if (lift2) ua = lerp(-40, -120, lift2), fa = lerp(-20, -80, lift2);
+ else if (reach || reach2) ua = -40, fa = -20;
+ wolf.pose({ x: WX, y: WY, s: .6, turn, lean: 30 * Math.max(reach, reach2), cap: capOn ? 'off' : 'on', night: capOn, glasses: spOn, ua, fa,
+ headR: between(q, C(7.8), C(8.1)) ? 14 : preen ? -8 : 0, brow: scratch || between(q, C(7.8), C(8.45)) ? 1.2 : preen ? (onTwos(q) > 0 ? .9 : .3) : .4,
+ ear: between(q, C(7.8), C(8.1)) ? onTwos(q) : 0, tail: 8 * Math.sin(q * 3), nod: breath(q), shut: blinking(q, [C(7.5), C(9.9)]) }, f);
+ }
+ vis(flap, tucked); const fh = span(q, C(10.9), C(11.25));
+ tf(cloth, `translate(1250,646) scale(1,${Math.max(.05, fh).toFixed(3)})`); tf(paws, `translate(1250,${(646 - 66 * fh).toFixed(1)})`);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene7.js b/site/little-red-riding-hood/ch01/scene7.js
index 7f8fca7..ae4f08e 100644
--- a/site/little-red-riding-hood/ch01/scene7.js
+++ b/site/little-red-riding-hood/ch01/scene7.js
@@ -1,46 +1,94 @@
-/* scene7.js — Red at the door. */
+/* scene7.js — Red arrives (storyboard v2 §7, director finding #10).
+ Shots (beat clock; PRE7 is her walk in):
+ A 0 – 3.1 trunk wipe out; the wide under the oaks: the woodcutter chopping by his block (a chop on each fall of
+ the axe), Red walks in from the left with basket and bouquet and stops behind him
+ B 3.1 – s07w 1.95 close on Red, waving up at him: "Good morning, Mr. Woodcutter!"; he finishes his swing and stops
+ C – s07x 1.35 his close-up, turned to us (the turn is on the cut), waving: "Morning, Little Red!"
+ D – wave7 the two of them: "Say hello to your grandma for me!"; Red nods
+ E wave7 – s07 3.1 the wide: he turns back to his block and chops, she skips on to the cottage (the camera goes
+ with her); she stops short of the open door
+ F – s07 4.35 Red's close-up, to us, worried: "How strange."
+ G – s07b insert: the door wide open, swinging a little on its hinge, dark inside
+ H s07b – end from inside (scene 5's view of the doorway): Red in the doorway against the daylight, "Grandma?"; on
+ door7 she steps in and out of the shadow; the chops go on outside, muffled
+ Uses scene5.js's s5_woodPile and its s5_dark* filters, so the block and the doorway look the same in both scenes.
+ Last frame: Red stepping in through the door (scene 8 opens on her by the bed). */
'use strict';
-const PRE7 = 1.6;
-const C7 = (c, t) => clipAt('scene7', PRE7, c, t);
-// The woodcutter chops by the oak while nobody talks to him: a swing every CHOP s, the blade landing at .85 of it.
-const CHOP = .9, CHOPPING = [[0, C7('s07w', .1)], [C7('s07', .9), 99]];
-const chopAt = q => { for (const [a, b] of CHOPPING) if (q >= a && q < b) return ((q - a) / CHOP) % 1; return -1; };
-for (const [a, b] of CHOPPING) for (let t = a + .85 * CHOP; t < Math.min(b, PRE7 + TIMINGS.scene7.dur); t += CHOP) sfx('scene7', t, 'chop', a ? .9 : 1.6);
+const PRE7 = 3.2;
+const s7_C = (c, t = 0) => clipAt('scene7', PRE7, c, t);
+const s7_END = PRE7 + TIMINGS.scene7.dur + .6;
+const s7_CUT = { B: 3.1, C: s7_C('s07w', 1.95), D: s7_C('s07x', 1.35), E: s7_C('wave7'), F: s7_C('s07', 3.1), G: s7_C('s07', 4.35), H: s7_C('s07b', -.1) };
+// the woodcutter chops while nobody talks to him: a swing every s7_CHOP s, the blade landing at .85 of it; a swing in
+// hand is finished before he stops
+const s7_CHOP = .9, s7_CHOPPING = [[0, s7_C('s07w', 1.0)], [s7_C('wave7', .5), 99]];
+const s7_chopAt = q => { for (const [a, b] of s7_CHOPPING) if (q >= a && q < a + Math.ceil((b - a) / s7_CHOP) * s7_CHOP) return ((q - a) / s7_CHOP) % 1; return -1; };
+// Red's walks: [start, from x, period, stride angle, steps]
+const s7_WALK_IN = [.7, -80, .95, 24, 4], s7_WALK_ON = [s7_CUT.E + .12, 244, .8, 24.4, 7], s7_STEP_IN = [s7_C('door7', .1), 262, .95, 20, 2];
+const s7_falls = ([t0, , period, , steps]) => Array.from({ length: steps }, (_, k) => +(t0 + period * (.25 + k / 2)).toFixed(2));
+
+sfx('scene7', 0, 'forest', .5);
+sfx('scene7', s7_CUT.H, 'room', .4);
+for (const [a, b] of s7_CHOPPING) for (let k = 0; a + (k + .85) * s7_CHOP < Math.min(a + Math.ceil((b - a) / s7_CHOP) * s7_CHOP, s7_END); k++) {
+ const t = +(Math.ceil((a + (k + .85) * s7_CHOP) * FPS - 1e-6) / FPS).toFixed(3); // on the frame the blade lands
+ sfx('scene7', t, t >= s7_CUT.H ? 'chopin' : 'chop', t >= s7_CUT.H ? 1 : t >= s7_CUT.F ? .9 : 1.4);
+}
+[...s7_falls(s7_WALK_IN), ...s7_falls(s7_WALK_ON), ...s7_falls(s7_STEP_IN)].forEach((t, i) => sfx('scene7', t, 'step' + (1 + i % 3), 1.4));
+sfx('scene7', s7_CUT.G + .2, 'creak', .9);
+
function scene7(p, D) {
- const C = C7;
- const cam = paperCam(p, 'grandmaOut', { x: 820, y: 470, z: 1 }, { after: 'house', stages: ['inside'] });
+ const C = s7_C, K = s7_CUT, s = .6, WX = s5_WX, WY = s5_WY;
+ const cam = paperCam(p, 'grandmaOut', { x: 760, y: 470, z: 1 }, { after: 'house', stages: ['inside'] });
const door = doorLeaf(cam.stage, 'M1010,800 L1010,560 Q1070,510 1130,560 L1130,800 Z', '#3f5f8a', 1010, '<path d="M1040,530 V800 M1070,520 V800 M1100,530 V800" stroke="#2f4a6e" stroke-width="3"/><circle cx="1116" cy="680" r="6" fill="#caa24c"/>');
- // the woodcutter by the oak, a chopping block in front of him and a few split logs
- const WX = 400, WY = 772;
- const wood = woodcutterPuppet(cam.stage);
- prop(cam.stage, `<g filter="url(#paper)"><path d="M${WX + 56},${WY} L${WX + 60},${WY - 78} L${WX + 116},${WY - 78} L${WX + 120},${WY} Z" fill="#7a5034"/><ellipse cx="${WX + 88}" cy="${WY - 78}" rx="28" ry="7" fill="#c9a074"/>
- <rect x="${WX + 74}" y="${WY - 118}" width="28" height="40" fill="#a37a52"/><ellipse cx="${WX + 88}" cy="${WY - 118}" rx="14" ry="4.5" fill="#d8b88a"/>
- <path d="M${WX - 120},${WY} l60,0 l-6,-22 l-56,4 Z M${WX - 110},${WY - 20} l56,-4 l-4,-20 l-54,6 Z" fill="#a37a52"/></g>`);
- const red = redPuppet(cam.stage), wipe = trunkWipe(p, 0, .8, 'out');
- const inn = paperCam(p, 'room', { x: 330, y: 600, z: 1.8 }), R = roomProps(inn, []), redIn = redPuppet(R.atDoor);
- // 7.1 she comes along the path, stops to greet him, then on to the open door
- const opts = { period: .95, A: 24 }, go1 = walker(-60, .6, opts, 1, 3), STOP = go1(99).x, go2 = walker(STOP, .6, opts, 1, 6), ON = C('s07', .2);
- cam.cut({ x: WX - 20, y: 600, z: 2.1 }, C('s07w', -.05)).cut({ x: 820, y: 470, z: 1 }, ON); // the greeting, close
+ s5_woodPile(cam.stage, false);
+ const puff = smoke(cam.stage, ...s5_CHIMNEY);
+ const wood = woodcutterPuppet(cam.stage), red = redPuppet(cam.stage), wipe = trunkWipe(p, 0, .8, 'out');
+ cam.cut({ x: 300, y: 590, z: 2.6 }, K.B).cut({ x: 405, y: 548, z: 2.6 }, K.C).cut({ x: 330, y: 585, z: 1.9 }, K.D)
+ .cut({ x: 640, y: 470, z: 1 }, K.E).to({ x: 760, y: 470, z: 1 }, K.E + .6, 2.6).to({ x: 850, y: 540, z: 1.45 }, C('s07', 1.6), 1.6)
+ .cut({ x: 818, y: 588, z: 3.2 }, K.F).cut({ x: 1138, y: 655, z: 3.1 }, K.G).to({ x: 1122, y: 650, z: 3.4 }, K.G + .3, 1.6);
+ const inn = paperCam(p, 'room', { x: 310, y: 622, z: 2 }), R = roomProps(inn, []), redIn = redPuppet(R.atDoor);
+ inn.to({ x: 350, y: 632, z: 2.2 }, K.H + .6, 2.4);
+ // a walk that ends standing: walker stops mid-stance with the swing knee bent, so the legs are set straight once it is done
+ const walkOf = ([t0, x0, period, A, steps]) => { const w = walker(x0, s, { period, A }, 1, steps); return q => q - t0 < steps * period / 2 ? w(q - t0) : { ...w(q - t0), near: 0, far: 0, kNear: 0, kFar: 0, drop: 0 }; };
+ const walkIn = walkOf(s7_WALK_IN), walkOn = walkOf(s7_WALK_ON), stepIn = walkOf(s7_STEP_IN);
stopClock(D, (q, f) => {
- const inside = q >= C('s07b', -.05);
+ const inside = q >= K.H;
vis(cam.root, !inside); vis(inn.root, inside);
- const s = .6;
+ const blink = (...t) => blinking(q, t);
if (inside) {
inn.apply(q, f); R.door(-.35);
- const w = walk(Math.max(0, Math.min(q - C('s07b', 1.1), .95)), { period: .95, A: 24 });
- redIn.pose({ x: 270 + w.d * s, y: hipOn(800, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, bouquet: 7,
- mouth: lips(q, 'scene7', PRE7, 's07b'), headR: 3 }, f);
+ const w = stepIn(q);
+ R.atDoor.setAttribute('filter', w.x < 330 ? 'url(#s5_dark55)' : w.x < 372 ? 'url(#s5_dark80)' : ''); // out of the light into the room
+ redIn.pose({ x: w.x, y: hipOn(800, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, bouquet: 7,
+ cape: 3 + 3 * Math.sin(2 * w.ph), mouth: lips(q, 'scene7', PRE7, 's07b') === 'X' ? 'A' : lips(q, 'scene7', PRE7, 's07b'),
+ brow: 1, headR: q < C('s07b', .7) ? -4 : 2, shut: blink(C('s07b', 1.1)) }, f);
return;
}
- cam.apply(q, f); wipe(q); door(.45 + .06 * Math.sin(q * 2.2));
- // the axe: raised over his head, a pause, down onto the log
- const u = chopAt(q), ua = u < 0 ? 6 : u < .6 ? -42 - 133 * ease(u / .6) : u < .75 ? -175 : u < .85 ? -175 + 133 * (u - .75) / .1 : -42;
- const talk = between(q, C('s07w', .1), ON + .3), turnBack = span(q, C('s07w', .1), C('s07w', .4)) - span(q, ON, ON + .3);
- wood.pose({ x: WX, y: WY - 200 * .62, s: .62, turn: 1 - 2 * turnBack, ua, fa: u < 0 ? -6 : 0, hop: u >= .85 && u < .9 ? 2 : 0,
- mouth: lips(q, 'scene7', PRE7, 's07x'), brow: talk ? .6 : 0, shut: blinking(q, [C('s07x', 1.6), C('s07', 3.0)]) }, f);
- const w = q < ON ? go1(q) : go2(q - ON);
- red.pose({ x: w.x, y: hipOn(800, s) + w.drop * s, s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3 + 3 * Math.sin(2 * w.ph + .6),
- ua: -8 + 4 * Math.sin(w.ph), fa: -78, swing: 6 * Math.sin(w.ph - 1), bouquet: 7, mouth: lips(q, 'scene7', PRE7, 's07w'),
- headR: q > C('s07', 3.2) ? -6 : 0, shut: blinking(q, [C('s07w', 2.2), C('s07', 2.4)]) }, f);
+ cam.apply(q, f); wipe(q); puff(q);
+ door(q >= K.G ? .2 + .08 * Math.sin((q - K.G) * 2.6) : .22 + .04 * Math.sin(q * 2.2)); // wide open (the wolf left it so), stirring
+ // the woodcutter: chopping in profile; turned to us on the cut to his close-up; back round in the wide
+ const u = s7_chopAt(q), ua = u < 0 ? 6 : u < .6 ? -42 - 133 * ease(u / .6) : u < .75 ? -175 : u < .85 ? -175 + 133 * (u - .75) / .1 : -42;
+ const front = q >= K.C && q < K.E + .12, back = Math.min(1, Math.max(0, Math.floor((q - K.E - .12) * FPS) + 1) / 4);
+ const waving = between(q, C('s07x', -.15), C('s07x', 1.35));
+ wood.pose({ x: WX, y: WY - 200 * .62, s: .62, turn: front ? 0 : q < K.C ? 1 : back, ua, fa: u < 0 ? -6 : 0, hop: u >= .85 && u < .9 ? 2 : 0,
+ lua: waving ? 150 : -6, lfa: waving ? 20 * onTwos(q) : 4, mouth: lips(q, 'scene7', PRE7, 's07x'),
+ headR: q >= C('s07w', 1.2) && q < K.C ? -6 : 0, shut: blink(3.6, C('s07x', 1.6), C('s07x', 3.4), 12.6) }, f);
+ // Red
+ let o;
+ if (q < K.E + .12) {
+ const w = walkIn(q), hi = between(q, C('s07w', -.1), C('s07w', 1.5));
+ o = { x: w.x, y: hipOn(800, s) + w.drop * s, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3 + 3 * Math.sin(2 * w.ph + .6),
+ swing: 6 * Math.sin(w.ph - 1), headR: q >= K.B ? -7 : 0, fua: hi ? -112 + 14 * onTwos(q) : null, ffa: hi ? -35 : -10,
+ nod: [C('s07x', 3.2), C('s07x', 3.45)].some(t => between(q, t, t + 2 / FPS)) ? 4 : 0, mouth: lips(q, 'scene7', PRE7, 's07w'),
+ shut: blink(2.9, C('s07x', .6), C('s07x', 2.6)) };
+ } else {
+ const w = walkOn(q), skip = q < K.E + 1.3 ? 16 * Math.abs(Math.sin(w.ph)) : 0, look = q >= C('s07', 2.6);
+ o = { x: w.x, y: hipOn(800, s) + w.drop * s - skip, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, cape: 3 + 3 * Math.sin(2 * w.ph + .6) + skip * .4,
+ swing: 6 * Math.sin(w.ph - 1), headR: look ? -4 : 0, brow: look ? 1 : 0, shut: blink(C('s07', 1.4)) };
+ if (q >= K.F) { // F: to us, worried, more so on "strange"
+ o = { ...o, head: 'F', brow: 1 + span(q, C('s07', 3.3), C('s07', 3.8)), headR: 4 + 4 * span(q, C('s07', 3.3), C('s07', 3.8)), mouth: 'A',
+ lua: -20, lfa: -40, shut: blink(C('s07', 3.95)) };
+ }
+ }
+ red.pose({ s, bouquet: 7, ...o }, f);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene8.js b/site/little-red-riding-hood/ch01/scene8.js
index c015c8f..e5e1102 100644
--- a/site/little-red-riding-hood/ch01/scene8.js
+++ b/site/little-red-riding-hood/ch01/scene8.js
@@ -1,50 +1,99 @@
-/* scene8.js — what big ears. */
+/* scene8.js — the three questions. Red and the wolf alternate in close-ups that come closer each time (his with the
+ wall and window behind him, hers with the open door), an insert on every feature she names, the wardrobe crack with
+ Grandma's umbrella rising, a hush, "EAT", and the lunge — which scene 9 picks up mid-air (s8_flight, s8_redDuck). */
'use strict';
-const PRE8 = .4;
+const PRE8 = .8;
+// The lunge, shared with scene 9: ft seconds after the wolf leaves the bed (side two-shot in the room set). Up off the
+// quilt fast, then a cartoon hang near the top (scene 8 ends somewhere in it), then (scene 9) the dive at the bouquet.
+const s8_LUNGE_VIEW = { x: 1100, y: 580, z: 1.9 };
+function s8_flight(ft) {
+ const up = Math.min(1, ft / .3), hang = span(ft, .3, 1.05), dive = Math.max(0, Math.min(1, (ft - 1.05) / .3));
+ const x = 1250 - 35 * (1 - (1 - up) ** 2) - 15 * hang - 25 * dive, y = 640 - 170 * (1 - (1 - up) ** 2) - 8 * hang + 140 * dive * dive;
+ return { x, y, s: .6, turn: -1, run: 0, stretch: 1, crouch: 0, night: true, cap: 'off', glasses: false, jaw: .9, mouth: 'D', brow: 1.5, tail: 30, ear: 0 };
+}
+// Red under him: the bouquet goes up over her head and she starts to duck (ft from the same lunge clock).
+function s8_redDuck(ft) {
+ const u = span(ft, .05, .5);
+ return { x: 1030, y: hipOn(800, .6), s: .6, turn: 1, crouch: .55 * u + .45 * span(ft, 1.0, 1.3), ua: -8 - 100 * u, fa: -78 + 50 * u, bouquet: 7, brow: 2, mouth: u > .3 ? 'E' : 'A', shut: ft > 1.1 };
+}
+{ const C = (c, t = 0) => clipAt('scene8', PRE8, c, t);
+ sfx('scene8', 0, 'room', .4, 10); // BED_STEP (shared.js) lays it again every 9.5 s
+ // the woodcutter still chopping outside, through the wall, in the gaps; quiet from the umbrella on
+ [.35, C('s08', 2.75), C('s08c', -.6), C('s08d', -.55), C('umbrella8', .2), C('umbrella8', 1.05)].forEach(t => sfx('scene8', +t.toFixed(2), 'chopin', .9));
+ sfx('scene8', +(C('s08f', 1.8) - .34).toFixed(2), 'sting', 2); // its chord lands on "EAT"
+ sfx('scene8', +C('lunge8', -.05).toFixed(2), 'whoosh', 1.6);
+}
function scene8(p, D) {
- const C = (c, t) => clipAt('scene8', PRE8, c, t), mid = c => C(c, -.05);
- const cam = paperCam(p, 'room', { x: 1140, y: 560, z: 1.9 }), R = roomProps(cam, []);
- const wolf = wolfPuppet(R.inBed), red = redPuppet(R.front);
- // Grandma inside the wardrobe, seen only through the crack of its door (open to .6: 1875–1932)
- mk('rect', { x: 1875, y: 424, width: 57, height: 366 }, mk('clipPath', { id: 'crack8' }, R.inWardrobe));
- const crack = mk('g', { 'clip-path': 'url(#crack8)' }, R.inWardrobe);
+ const C = (c, t = 0) => clipAt('scene8', PRE8, c, t), breathe = (q, k = 0) => 2 * Math.sin(q * 2.2 + k);
+ // the room: the two-shot, the wardrobe crack, the lunge
+ const cam = paperCam(p, 'room', { x: 1120, y: 570, z: 2.0 }), R = roomProps(cam, []);
+ const wolf = wolfPuppet(R.inBed), red = redPuppet(R.front), wolfL = wolfPuppet(R.front);
+ mk('rect', { x: 1875, y: 424, width: 57, height: 366 }, mk('clipPath', { id: 's8_crack' }, R.inWardrobe));
+ const crack = mk('g', { 'clip-path': 'url(#s8_crack)' }, R.inWardrobe);
mk('rect', { x: 1868, y: 410, width: 72, height: 390, fill: '#2a1a10' }, crack);
const granIn = grandmaPuppet(crack);
- // the close-ups face each other across the bed: his, with the wall and window behind him (her view); hers, with
- // the open door behind her (his view). Each line comes closer than the one before.
- const A = paperCam(p, 'roomA').soft(0, 'all'), wolfA = wolfPuppet(A.stage);
+ // the close-ups: his (her view: wall and window behind him), hers (his view: the open door behind her)
+ const A = paperCam(p, 'roomA', { x: 800, y: 405, z: 1.25 }).soft(0, 'all'), wolfA = wolfPuppet(A.stage), specs = granGlassesProp(A.stage);
const B = paperCam(p, 'roomB').soft(0, 'all'), redB = redPuppet(B.stage);
- const shots = [['s08', 'two'], ['s08b', 'A', 1.9], ['s08c', 'B', 2], ['s08d', 'A', 2.7], ['s08e', 'B', 2.8], ['s08f', 'A', 3.4]];
- const EAT = C('s08f', .88);
- // while he says "see you with", a look at the wardrobe: through the crack, Grandma's eye narrows and the umbrella comes up
- const WARD = [C('s08d', 1.0), mid('s08e')];
- cam.cut({ x: 1870, y: 560, z: 2.6 }, WARD[0]);
+ const EAT = C('s08f', 1.8), HUSH = C('hush8', -.3), LUNGE = C('lunge8', -.05);
+ // [start, camera, the close-up's size]; inserts are the A camera closing on his face at size 1.9
+ const SH = [[0, 'two'], [C('s08', 1.25), 'ears', 1.9], [C('s08b', -.08), 'A', 2.5], [C('s08c', -.1), 'B', 2.6], [C('s08c', 1.5), 'eyes', 1.9],
+ [C('s08d', -.08), 'A', 2.8], [C('umbrella8', -.5), 'ward'], [C('s08e', -.06), 'B', 3.1], [C('s08e', 2.15), 'mouth', 1.9], [HUSH, 'A', 3.0], [LUNGE, 'two']];
+ const hip = big => 430 + 212 * big;
+ const AV = { x: 800, y: 405, z: 1.25 };
+ A.cut({ x: 800, y: 345, z: 2.4 }, SH[1][0]).cut(AV, SH[2][0]).cut({ x: 800, y: 418, z: 2.5 }, SH[4][0])
+ .cut(AV, SH[5][0]).cut({ x: 800, y: 492, z: 2.5 }, SH[8][0]).cut(AV, SH[9][0]).shake(EAT, .35, 14);
+ const WARD = SH[6][0];
+ cam.cut({ x: 1898, y: 572, z: 3.0 }, WARD).cut(s8_LUNGE_VIEW, LUNGE);
stopClock(D, (q, f) => {
- let k = 0; for (let i = 0; i < shots.length; i++) if (q >= mid(shots[i][0])) k = i;
- const ward = between(q, ...WARD), [, which, big] = ward ? [, 'two'] : shots[k], s = .6;
- vis(cam.root, which === 'two'); vis(A.root, which === 'A'); vis(B.root, which === 'B');
- const wolfMouth = lips(q, 'scene8', PRE8, 's08b', 's08d', 's08f');
- // s08e has half a second of silence after "And Grandma…": its cues (shots.js) already hold her mouth shut through it
- const tE = q - C('s08e'), redMouth = lips(q, 'scene8', PRE8, 's08', 's08c') !== 'X' ? lips(q, 'scene8', PRE8, 's08', 's08c') : mouthAt('s08e', tE);
- if (ward) {
+ let k = 0; for (let i = 0; i < SH.length; i++) if (q >= SH[i][0]) k = i;
+ const [, which, big] = SH[k], two = which === 'two' || which === 'ward', onA = ['A', 'ears', 'eyes', 'mouth'].includes(which);
+ vis(cam.root, two); vis(A.root, onA); vis(B.root, which === 'B');
+ const wolfMouth = lips(q, 'scene8', PRE8, 's08b', 's08d', 's08f'), said = lips(q, 'scene8', PRE8, 's08', 's08c', 's08e');
+ // worried, more with each question; a small "o" of fear once she has asked about the mouth
+ const worry = q < C('s08c', -.5) ? 1 : q < C('s08e', -.5) ? 1.4 : 2, redMouth = said !== 'X' ? said : q > C('s08e', 1) ? 'F' : 'A';
+ if (two) {
cam.apply(q, f); R.wardrobe(.6);
- const up = span(q, WARD[0] + .4, WARD[0] + 1.1);
- granIn.pose({ x: 1906, y: 692, s: .55, head: 'F', cap: false, glasses: false, umbrella: true, brow: -1.8 * span(q, WARD[0] + .1, WARD[0] + .3), mouth: 'A',
- rua: 30 - 150 * up, rfa: -10 - 70 * up, shut: blinking(q, [WARD[0] + .7]) }, f);
- } else if (which === 'two') {
- cam.apply(q, f); R.wardrobe(.6);
- wolf.pose({ x: 1250, y: 630, s, turn: -1, cap: 'off', night: true, glasses: true, ear: between(q, C('s08', 1.3), C('s08', 2.6)) ? onTwos(q) : 0 }, f);
- red.pose({ x: 1030, y: hipOn(800, s), s, bouquet: 7, mouth: redMouth, ua: -8, fa: -78, shut: blinking(q, [C('s08', 2.8)]) }, f);
- } else if (which === 'A') {
+ if (which === 'ward') { // through the crack: her eye narrows, then the umbrella comes up, slowly
+ const up = span(q, WARD + .35, WARD + 1.75);
+ granIn.pose({ x: 1906, y: 692 + breathe(q), s: .55, head: 'F', cap: false, glasses: false, umbrella: true, brow: -1.8 * span(q, WARD + .1, WARD + .35), mouth: 'A',
+ rua: 30 - 150 * up, rfa: -10 - 70 * up, nod: 3 * span(q, WARD + 1.8, WARD + 2.0), shut: blinking(q, [WARD + 1.95]) }, f);
+ return;
+ }
+ const lunge = q >= LUNGE, ft = q - LUNGE;
+ vis(wolf.g, !lunge); vis(wolfL.g, lunge);
+ if (lunge) wolfL.pose(s8_flight(ft), f);
+ else wolf.pose({ x: 1250, y: 630 + breathe(q), s: .6, turn: -1, cap: 'off', night: true, glasses: true, look: 1, mouth: 'X', shut: blinking(q, [C('s08', .6)]) }, f);
+ red.pose(lunge ? s8_redDuck(ft) : { x: 1030, y: hipOn(800, .6) + breathe(q, 1) * .5, s: .6, bouquet: 7, mouth: redMouth, brow: worry, ua: -8, fa: -78, headR: -4 * span(q, 0, .5),
+ shut: blinking(q, [.3, C('s08', 2.6)]) }, f);
+ return;
+ }
+ if (onA) {
A.apply(q, f);
- const eat = q >= EAT, lunge = span(q, EAT + .6, D);
- if (k === 5) A.shake(EAT, .3, 12);
- wolfA.pose({ x: 800, y: 430 + 212 * big * (1 + .3 * lunge) - 300 * lunge, s: big * (1 + .3 * lunge), head: 'F', cap: 'off', night: true, glasses: !eat,
- mouth: wolfMouth, jaw: eat && q < EAT + .9 ? 1 : null, brow: eat ? -1 : .6, rua: 30, rfa: -60, lua: -30, lfa: 60, shut: blinking(q, [C('s08b', 1.3), C('s08d', 1.5)]) }, f);
- } else {
- B.apply(q, f);
- redB.pose({ x: 800, y: 430 + 194 * big, s: big, head: 'F', mouth: redMouth, headR: k === 2 ? -6 : 0, bouquet: 0, basket: false,
- nod: k === 4 && between(tE, 1.0, 1.5) ? 3 : 0, shut: blinking(q, [C('s08c', 2.6), C('s08e', 1.1)]) }, f);
+ const hush = which === 'A' && k === 9, eat = q >= EAT;
+ // in the hush he comes closer (a push-in); at EAT he rears up and grows over us
+ const push = hush ? .35 * span(q, HUSH, EAT - .05) + .2 * span(q, EAT, EAT + .25) + .1 * span(q, C('s08f', 2.55), LUNGE) : 0;
+ const see = k === 5 ? .12 * span(q, C('s08d', .95), C('s08d', 1.3)) : 0, s = big + push + see, rise = hush ? 70 * span(q, C('s08f', 2.55), LUNGE) : 0;
+ const hear = k === 2 ? span(q, C('s08b', .85), C('s08b', 1.15)) * (1 - span(q, C('s08b', 2.1), C('s08b', 2.4))) : 0;
+ const claws = eat ? span(q, EAT, EAT + .2) : 0;
+ const look = which === 'eyes' ? [0, -1.2, 1.2, 0][Math.min(3, Math.floor((q - SH[4][0]) / .45))] : 0;
+ // an old lady's wobble on his lines; in the hush, still, eyes narrowing
+ wolfA.pose({ x: 800, y: hip(s) - rise + breathe(q) * (hush ? .3 : 1), s, head: 'F', cap: 'off', night: true, glasses: !eat, look,
+ mouth: wolfMouth, jaw: eat && q < EAT + .7 ? 1 : which === 'mouth' ? .45 * span(q, SH[8][0] + .3, SH[8][0] + 1) : null,
+ headR: which === 'A' && !hush && wolfMouth !== 'X' ? 3 * Math.sin(q * 9) : 0,
+ brow: eat ? 1.6 : hush ? 1.1 * span(q, HUSH + .4, EAT - .3) : 0,
+ ear: which === 'ears' && (between(q, C('s08', 1.36), C('s08', 1.9)) || between(q, C('s08', 2.3), C('s08', 2.7))) ? onTwos(q) : eat && q < EAT + .4 ? onTwos(q) : 0,
+ rua: 30 - 200 * hear - 150 * claws, rfa: -60 + 50 * hear + 20 * claws, lua: -30 + 150 * claws, lfa: 60 - 20 * claws,
+ shut: blinking(q, [C('s08b', 2.5), C('s08c', 2.4), C('s08d', 1.9)]) }, f);
+ // her glasses fly off his nose at EAT
+ const g = (q - EAT) / .7; vis(specs.g, eat && g < 1);
+ if (eat && g < 1) specs.pose(800 + 520 * g, hip(s) - rise - 222 * s - 380 * g + 420 * g * g, .62 * s, 260 * g);
+ return;
}
+ B.apply(q, f);
+ const shrink = k === 7 ? span(q, C('s08e', .1), C('s08e', .5)) : 0; // "And…": she pulls back
+ redB.pose({ x: 800, y: 430 + 194 * big + breathe(q, 1) + 10 * shrink, s: big, head: 'F', mouth: redMouth, brow: worry, headR: k === 3 ? -5 : -3 * shrink,
+ bouquet: 7, basket: true, lua: 15, lfa: -110, rua: 4, rfa: -4, nod: k === 7 && between(q, C('s08e', .25), C('s08e', .45)) ? 3 : 0,
+ shut: blinking(q, [C('s08c', .85), C('s08e', .3)]) }, f);
});
}
diff --git a/site/little-red-riding-hood/ch01/scene9.js b/site/little-red-riding-hood/ch01/scene9.js
index 4d54ac0..3806530 100644
--- a/site/little-red-riding-hood/ch01/scene9.js
+++ b/site/little-red-riding-hood/ch01/scene9.js
@@ -1,14 +1,31 @@
-/* scene9.js — out!. */
+/* scene9.js — out! It starts mid-lunge on scene 8's last frame (s8_flight, s8_redDuck): the wolf's face goes into
+ the bouquet; the wardrobe bursts open; Grandma's close-up, her run and the umbrella on his head; he gallops for the
+ door and skids before the woodcutter; a cut on each mark of "Grandma … the woodcutter … one way out", his eyes go
+ to the window; the leap, followed, through the glass. */
'use strict';
-const PRE9 = 1.0;
-const C9 = (c, t) => clipAt('scene9', PRE9, c, t), M9 = k => PRE9 + TIMINGS.scene9.marks['s09c.' + k];
-// BANG: the wardrobe bursts open; WHACK: the umbrella comes down on his head; RUN: he bolts for the front door;
-// LEAP: the only way left, over everyone; CRASH: through the window.
-const LAND9 = 1.2, BANG = C9('s09', 0), WHACK = C9('s09', 2.04), RUN = C9('s09b', -.85), LEAP = C9('s09c', 5.3), CRASH = LEAP + .9;
-sfx('scene9', LAND9, 'thud', 2); sfx('scene9', BANG, 'bang', 2); sfx('scene9', WHACK + .12, 'bonk', 2); sfx('scene9', CRASH, 'crash', 2);
+const PRE9 = .2;
+const s9_C = (c, t = 0) => clipAt('scene9', PRE9, c, t), s9_M = k => PRE9 + TIMINGS.scene9.marks['s09c.' + k];
+// the lunge clock where scene 8 left it (its beat end, hold included)
+const s9_F0 = PRE8 + TIMINGS.scene8.dur + HOLD - clipAt('scene8', PRE8, 'lunge8', -.05);
+const s9_T = (() => {
+ const C = s9_C, BANG = C('burst9', .4), WHACK = C('bonk9', .35), LEAP = C('leap9', .25);
+ return { HIT: .3, LAND: .8, BANG, LANDG: BANG + .5, RUNG: C('s09', 1.15), ATG: C('s09', 2.45), WHACK, TURN: WHACK + .45, GO: WHACK + .7, AT_DOOR: WHACK + 1.35,
+ WOOD: C('bonk9', .6), SHOO: C('s09b', 1.0), LEAP, CRASH: LEAP + .8 };
+})();
+{ const C = s9_C, T = s9_T;
+ sfx('scene9', 0, 'room', .4, 10); // BED_STEP (shared.js) lays it again every 9.5 s
+ const fx = (t, n, v) => sfx('scene9', +t.toFixed(2), n, v);
+ fx(T.HIT, 'thud', 2); fx(T.LAND, 'thud', 1.2);
+ fx(T.BANG - .38, 'knock', .8); fx(T.BANG - .2, 'knock', .9); fx(T.BANG, 'bang', 2); fx(T.LANDG, 'hop', 1.4);
+ for (let t = T.RUNG + .1, i = 0; t < T.ATG; t += .22, i++) fx(t, 'step' + (1 + i % 3), .9);
+ fx(T.WHACK + .1, 'bonk', 2);
+ fx(T.GO + .05, 'run', 1.3);
+ fx(T.AT_DOOR - .2, 'skid', 1.6); fx(T.SHOO, 'thud', 1);
+ fx(T.LEAP, 'whoosh', 1.6); fx(T.CRASH, 'crash', 2); fx(T.CRASH + .2, 'tinkle', 1.4);
+}
// The bedroom window (in the room set, 1420–1660 × 300–530): glass until `at`; then broken — the woods redrawn over
// the set's cross bars, jagged glass left in the frame — and shards that burst out and fall to the floor.
-function brokenWindow(back, front, at) {
+function s9_brokenWindow(back, front, at) {
const glass = prop(back, `<g><rect x="1420" y="300" width="240" height="230" fill="#e8f4f6" opacity=".25"/>
<path d="M1440,340 l40,-26 M1450,362 l64,-42 M1562,340 l40,-26 M1572,470 l52,-34" stroke="#ffffff" stroke-width="6" stroke-linecap="round" opacity=".6"/></g>`);
const broken = prop(back, `<g filter="url(#paper)"><rect x="1418" y="298" width="244" height="234" fill="#cfe0d0"/><path d="M1418,430 C1480,400 1560,420 1662,396 L1662,532 L1418,532 Z" fill="#7fa54f"/>
@@ -31,63 +48,91 @@ function brokenWindow(back, front, at) {
};
}
function scene9(p, D) {
- const C = C9;
- const cam = paperCam(p, 'room', { x: 1050, y: 500, z: 1.1 }), R = roomProps(cam, []);
- const win = brokenWindow(R.atDoor, R.front, CRASH);
- const wood = woodcutterPuppet(R.atDoor), gran = grandmaPuppet(R.front), red = redPuppet(R.front), wolf = wolfPuppet(R.front);
+ const C = s9_C, T = s9_T, breathe = (q, k = 0) => 2 * Math.sin(q * 2.2 + k);
+ const cam = paperCam(p, 'room', s8_LUNGE_VIEW), R = roomProps(cam, []);
+ const win = s9_brokenWindow(R.atDoor, R.front, T.CRASH);
+ const wood = woodcutterPuppet(R.atDoor);
const spill = prop(R.front, `<g filter="url(#paper)">${[[-60, 4, '#d6493f'], [-30, -6, '#f6efe0'], [0, 6, '#efae48'], [30, -4, '#e88ab0'], [60, 6, '#d6493f'], [-90, 8, '#f6efe0']].map(([x, y, c]) =>
- `<rect x="${x - 14}" y="${y - 2}" width="28" height="3" fill="#4f7a34"/><circle cx="${x + 14}" cy="${y}" r="9" fill="${c}"/>`).join('')}</g>`, { transform: 'translate(720,796) scale(.7)' });
- // 9.1 he crouches on the bed and leaps; she ducks and cries for help; he sails over her, snaps the bouquet out of her
- // hands and lands face first in it; 9.2 the wardrobe rattles and
- // bursts open: Grandma and her umbrella; 9.3 wide: she runs at him and brings it down on his head; he bolts for the
- // door — 9.4 where the woodcutter steps in; 9.5 wide: Grandma one side, the woodcutter the other, the window; the leap.
- const DOOR = C('s09b', -.05), WIDE = C('s09c', -.05);
- cam.cut({ x: 1800, y: 560, z: 1.8 }, C('s09', -.7)).cut({ x: 1150, y: 500, z: 1.1 }, C('s09', .9))
- .cut({ x: 290, y: 560, z: 1.8 }, DOOR).cut({ x: 1000, y: 470, z: .95 }, WIDE).shake(CRASH, 3 / FPS, 10);
- const runner = walker(780, .6, { L: 196, A: 26, period: .5, knee: 60 }, -1, 3);
+ `<rect x="${x - 14}" y="${y - 2}" width="28" height="3" fill="#4f7a34"/><circle cx="${x + 14}" cy="${y}" r="9" fill="${c}"/>`).join('')}</g>`, { transform: 'translate(735,796) scale(.7)' });
+ const red = redPuppet(R.front), wolf = wolfPuppet(R.front), gran = grandmaPuppet(R.front);
+ // his close-up when his eyes find the window: the room behind him, out of focus
+ const W = paperCam(p, 'room', { x: 820, y: 450, z: 1.4 }).soft(0, 'all'), wolfW = wolfPuppet(W.stage);
+ // shots: A the lunge (two-shot), B the wardrobe, C Grandma's close-up, D wide (her run, the bonk), E the door,
+ // F [gran], G [wood], H his eyes to the window (W), I the window, J the leap
+ const SH = [[0, 'A'], [C('burst9', -.05), 'B'], [C('s09', -.15), 'C'], [C('s09', 1.1), 'D'], [C('s09', 2.6), 'D2'], [C('bonk9', 1.4), 'E'],
+ [s9_M('gran') - .05, 'F'], [s9_M('wood') - .05, 'G'], [s9_M('way') - .05, 'H'], [C('s09c', 5.35), 'I'], [C('leap9', .05), 'J']];
+ const at = n => SH.find(s => s[1] === n)[0];
+ const wolfX = q => q < T.LEAP ? 530 : 530 + 1010 * Math.min(1, (q - T.LEAP) / .8);
+ cam.to({ x: 1030 }, T.HIT, .6).cut({ x: 1820, y: 590, z: 2.1 }, at('B')).cut({ x: 1700, y: 580, z: 3.5 }, at('C')).cut({ x: 1250, y: 520, z: 1.15 }, at('D')).cut({ x: 850, y: 580, z: 2.0 }, at('D2'))
+ .cut({ x: 380, y: 590, z: 2.0 }, at('E')).to({ x: 330, y: 545, z: 2.3 }, T.SHOO - .2, .6)
+ .cut({ x: 925, y: 560, z: 2.6 }, at('F')).cut({ x: 290, y: 595, z: 2.3 }, at('G'))
+ .cut({ x: 1540, y: 430, z: 1.7 }, at('I')).to({ z: 2.4 }, at('I') + .05, .85)
+ .cut({ x: 680, y: 540, z: 1.5 }, at('J')).to({ x: t => Math.max(680, Math.min(1420, wolfX(t) + 60)), y: 500 }, T.LEAP, .35)
+ .to({ x: 1260, y: 500, z: 1.45 }, T.CRASH + .25, 1.0).shake(T.CRASH, 3 / FPS, 10);
+ const gallop = q => route(q, [[T.GO, 800], [T.AT_DOOR, 470]], .6);
stopClock(D, (q, f) => {
- cam.apply(q, f); R.door(-.35); win(q);
- R.wardrobe(q < C('s09', -.7) ? 1 : q < BANG ? 1 + .04 * onTwos(q) : opening(q, BANG, [1, .4, -.2, -.45, -.4]));
- const s = .6, sw = q >= WIDE;
- vis(spill, q >= LAND9);
+ let k = 0; for (let i = 0; i < SH.length; i++) if (q >= SH[i][0]) k = i;
+ const shot = SH[k][1];
+ vis(cam.root, shot !== 'H'); vis(W.root, shot === 'H');
+ if (shot === 'H') { // eyes right, then the whole head after them: the window
+ W.apply(q, f);
+ const t0 = at('H'), tt = span(q, t0 + .5, t0 + .75);
+ wolfW.pose({ x: 820, y: 450 + 215 * 2.6 + breathe(q), s: 2.6, head: tt > .5 ? 'P' : 'F', turn: tt > .5 ? tt : 1, cap: 'off', night: true, glasses: false, brow: -1,
+ look: 2 * span(q, t0 + .1, t0 + .25), ear: between(q, t0 + .3, t0 + .5) ? onTwos(q) : 0, rua: 20, rfa: -70, lua: -20, lfa: 70, shut: blinking(q, [t0 + .02]) }, f);
+ return;
+ }
+ cam.apply(q, f); win(q); R.door(-.35);
+ R.wardrobe(q < T.BANG - .4 ? 1 : q < T.BANG ? 1 + .05 * onTwos(q) : opening(q, T.BANG, [1, .3, -.3, -.5, -.45]));
+ vis(spill, q >= T.LAND);
+ const s = .6, floor4 = hipOn(800, s, 200);
// the wolf
let o;
- const leap = Math.min(1, Math.max(0, (q - .3) / .9)), crouch = span(q, 0, .25) * (1 - leap), UP = C('s09', 1.2);
- if (q < LAND9) o = { x: 1250 - 470 * ease(leap), y: 630 + 12 * crouch + 122 * leap - 80 * Math.sin(Math.PI * leap), turn: -1, lean: 20 * crouch + 40 * leap, ua: -120, fa: -30, near: -40 * Math.sin(Math.PI * leap), far: 40 * Math.sin(Math.PI * leap), tail: -30 * leap,
- mouth: leap > .3 && leap < .7 ? 'D' : 'X', jaw: leap > .3 && leap < .55 ? 1 : null };
- else if (q < UP) o = { x: 780, y: 752, turn: -1, lean: 78, shut: true, ua: -120, fa: -30 };
- else if (q < RUN) {
- const r = span(q, UP, UP + .5), hit = between(q, WHACK + .1, WHACK + .45);
- o = { x: 780, y: 752 - 72 * r - (hit ? 40 * Math.sin(Math.PI * (q - WHACK - .1) / .35) : 0), turn: -1, lean: 78 * (1 - r),
- ua: q > WHACK + .1 ? -160 : -20, fa: q > WHACK + .1 ? -30 : -10, brow: q > WHACK + .1 ? 1 : 0, ear: hit ? onTwos(q) : 0,
- shut: between(q, WHACK + .1, WHACK + .9), mouth: hit ? 'D' : 'X' };
- } else if (q < DOOR) { const w = runner(q - RUN); o = { x: w.x, y: 680 + w.drop * s, turn: -1, near: w.near, far: w.far, kNear: w.kNear, kFar: w.kFar, lean: 28, ua: -30 + 40 * Math.sin(w.ph), fa: -40, brow: 1, tail: -20 }; }
- else if (q < WIDE) { // skids to a stop in front of the woodcutter
- const k = span(q, DOOR, DOOR + .3);
- o = { x: 470 - 40 * k + (q > DOOR + .5 ? 1.5 * onTwos(q) : 0), y: 680, turn: -1, lean: -14, near: 28 * (1 - k), far: -20 * (1 - k), ua: -100, fa: -60, brow: 1, tail: 10 };
- } else if (q < LEAP) { // looks at Grandma, at the woodcutter, at the window; crouches
- const look = q < M9('gran') ? -1 : q < M9('wood') ? 1 - 2 * span(q, M9('wood'), M9('wood') + .12) : -1 + 2 * span(q, M9('way'), M9('way') + .12);
- const cr = span(q, LEAP - .35, LEAP - .05);
- o = { x: 430, y: 680 + 14 * cr, turn: q < M9('wood') ? -1 + 2 * span(q, M9('gran'), M9('gran') + .12) : look, lean: 22 * cr, headR: q > M9('way') + .2 ? -12 * (1 - cr) : 0,
- ua: -100 + 60 * cr, fa: -60, brow: 1, near: 20 * cr, far: 20 * cr, kNear: 40 * cr, kFar: 40 * cr, tail: 10 };
- } else { const u = Math.min(1, (q - LEAP) / .9); o = { x: 430 + 1110 * u, y: 694 - 224 * u - 300 * Math.sin(Math.PI * u), s: s * (1 - .3 * u * u), turn: 1, lean: 30, near: -30, far: 30, ua: -150, fa: -20, tail: -30, brow: 1 }; }
- vis(wolf.g, q < CRASH);
- wolf.pose({ s, cap: 'off', night: true, glasses: false, ...o }, f);
- // Red: ducks, then watches the wolf; at the crash, the window
- const duck = between(q, .45, 1.9);
- red.pose({ x: 1030, y: hipOn(800, s) + (duck ? 62 * s : 0), s, turn: q < 1.9 || q > CRASH - .3 ? 1 : -1, near: duck ? -62 : 0, far: duck ? -50 : 0, kNear: duck ? 104 : 0, kFar: duck ? 100 : 0, // a squat
- ua: duck ? -150 : -8, fa: duck ? -40 : -78, headR: duck ? 10 : sw && q > LEAP ? -8 : 0, bouquet: q < .75 ? 7 : 0, shut: duck,
- mouth: lips(q, 'scene9', PRE9, 's09a') }, f);
- // Grandma: out of the wardrobe in a hop, across the room, the umbrella down on his head; then she shakes it at him
- vis(gran.g, q >= BANG + 1 / FPS);
- const hop = span(q, BANG, BANG + .5), run = span(q, C('s09', .9), C('s09', 1.9)), whack = span(q, WHACK, WHACK + .16);
- gran.pose({ x: 1860 - 160 * hop - 810 * run, y: 692 - 110 * Math.sin(Math.PI * hop) - (run > 0 && run < 1 ? 8 * Math.abs(Math.sin(q * 14)) : 0), s: .55,
- turn: q > CRASH - .4 ? 1 : -1, cap: false, glasses: false, umbrella: true, mouth: lips(q, 'scene9', PRE9, 's09'),
- ua: q < WHACK ? -175 : -175 + 47 * whack + (between(q, WHACK + .5, RUN) || between(q, WIDE, LEAP) ? 30 * onTwos(q) : 0), fa: -10, brow: -1 }, f);
- // the woodcutter steps into the doorway
- vis(wood.g, q >= DOOR);
- const stamp = between(q, C('s09b', 1.7), C('s09b', 1.7) + 2 / FPS);
- wood.pose({ x: 200 + 68 * span(q, DOOR, DOOR + .35), y: hipOn(800, .62, 200), s: .62, ua: -20, fa: -150, lean: q > C('s09b', 1.6) ? 8 : 0, hop: stamp ? -10 : 0, brow: -1,
- mouth: lips(q, 'scene9', PRE9, 's09b'), shut: blinking(q, [C('s09b', 2.4)]) }, f);
+ if (q < T.HIT) o = s8_flight(s9_F0 + q);
+ else if (q < T.LAND) { const u = (q - T.HIT) / (T.LAND - T.HIT), a = s8_flight(s9_F0 + T.HIT);
+ o = { ...a, x: a.x + (800 - a.x) * ease(u), y: a.y + (floor4 + 30 - a.y) * u * u - 150 * Math.sin(Math.PI * u), stretch: 1 - u, crouch: u, headR: 30 * u, jaw: 0, mouth: 'X', shut: true, tail: 30 - 50 * u }; }
+ else if (q < C('s09', 1.55)) o = { x: 800, y: floor4 + 34, s, turn: -1, run: 0, crouch: 1, headR: 42, shut: true, tail: -20 + 6 * onTwos(q) * (q > 1.2 && q < 1.5 ? 1 : 0), night: true, cap: 'off' };
+ else if (q < T.GO) { // up, dazed; turns to her "rascal!"; the bonk; clutches his head; turns for the door
+ const up = span(q, C('s09', 1.55), C('s09', 1.9)), tr = q < T.TURN ? 1 - 2 * (1 - span(q, C('s09', 2.0), C('s09', 2.3))) : 1 - 2 * span(q, T.TURN, T.TURN + .3);
+ const hit = q >= T.WHACK + .1, bump = between(q, T.WHACK + .1, T.WHACK + .4) ? 30 * Math.sin(Math.PI * (q - T.WHACK - .1) / .3) : 0;
+ o = { x: 800, y: floor4 - bump, s, turn: tr, lean: 40 * (1 - up), headR: q < C('s09', 2.0) ? 8 * Math.sin(q * 6) : 0, ua: hit ? -165 : -20, fa: hit ? -30 : -40,
+ brow: -1, ear: hit && q < T.WHACK + .6 ? onTwos(q) : 0, shut: hit && q < T.WHACK + .7, mouth: hit && q < T.WHACK + .5 ? 'D' : 'X', tail: -10 };
+ } else if (q < T.SHOO) { // gallop to the door, skid before the woodcutter
+ const g = gallop(q), sk = span(q, T.AT_DOOR - .25, T.AT_DOOR);
+ o = { x: g.x, y: floor4, s, turn: -1, run: g.d, skid: sk * (1 - span(q, T.AT_DOOR + .3, T.AT_DOOR + .6)), crouch: .4 * span(q, T.AT_DOOR + .3, T.AT_DOOR + .6), brow: -1, ear: sk > 0 && q < T.AT_DOOR + .3 ? onTwos(q) : 0, tail: 20 * (1 - sk) };
+ } else if (q < at('J')) { // "Shoo!": he rears up and backs off a step, trembling
+ const back = span(q, T.SHOO, T.SHOO + .35);
+ o = { x: 470 + 60 * back + (q > T.SHOO + .4 ? 1.5 * onTwos(q) : 0), y: floor4, s, turn: -1, lean: -10 * back, ua: -150, fa: -50, brow: -1.2, near: 10 * back, far: -10 * back, tail: -30,
+ look: q > s9_M('way') ? -1 : 0, shut: blinking(q, [s9_M('wood') + .8]) };
+ } else if (q < T.LEAP) o = { x: 530, y: floor4, s, turn: 1, run: 0, crouch: span(q, at('J'), T.LEAP - .05), tail: 20 * onTwos(q), brow: -1 };
+ else { const u = Math.min(1, (q - T.LEAP) / .8);
+ o = { x: wolfX(q), y: floor4 + (430 - floor4) * u - 260 * Math.sin(Math.PI * u), s, turn: 1, run: 0, stretch: 1, crouch: 0, brow: -1, jaw: .4, tail: -30 }; }
+ vis(wolf.g, q < T.CRASH);
+ wolf.pose({ s, cap: 'off', night: true, glasses: false, flap: o.run !== undefined && o.run !== null ? 20 * onTwos(q) : 0, ...o }, f);
+ // Red: ducked under the bouquet, "Help!"; up again, watching (turned to him); ducks as he flies over, turns after him
+ const said = lips(q, 'scene9', PRE9, 's09a');
+ if (q < 2.6) { const r = s8_redDuck(s9_F0 + q); red.pose({ ...r, bouquet: q < T.HIT ? 7 : 2, mouth: said !== 'X' ? said : r.mouth, shut: q > T.HIT && q < 1.4 }, f); }
+ else {
+ const duck = span(q, T.LEAP + .15, T.LEAP + .35) * (1 - span(q, T.LEAP + .6, T.LEAP + .9)), tr = -1 + 2 * span(q, T.LEAP + .45, T.LEAP + .7);
+ red.pose({ x: 1030, y: hipOn(800, s) + breathe(q, 1) * .5, s, turn: tr, crouch: .6 * duck, ua: -8 - 140 * duck, fa: -78 + 40 * duck, bouquet: 2, brow: 1.5, mouth: 'F',
+ shut: blinking(q, [4.6, 8.3, 12.2]) || duck > .5 }, f);
+ }
+ // Grandma: out of the wardrobe in a hop, her close-up, across the room, the umbrella down on his head; then she stands
+ // her ground, umbrella up; ducks as he flies over, turns after him
+ vis(gran.g, q >= T.BANG + 1 / FPS);
+ const gm = lips(q, 'scene9', PRE9, 's09'), hop = span(q, T.BANG, T.LANDG), run = span(q, T.RUNG, T.ATG), sq = q < T.LANDG ? .8 * span(q, T.BANG, T.BANG + .1) * (1 - span(q, T.BANG + .1, T.BANG + .2)) : 1 - span(q, T.LANDG, T.LANDG + .25);
+ const shake = 14 * onTwos(q), gx = 1880 - 180 * hop - 795 * run, gd = span(q, T.LEAP + .1, T.LEAP + .3) * (1 - span(q, T.LEAP + .55, T.LEAP + .8));
+ if (shot === 'C') gran.pose({ x: gx, y: 692 + breathe(q), s: .55, head: 'F', cap: false, glasses: false, umbrella: true, mouth: gm, brow: -1.5,
+ rua: -150 + shake, rfa: -30, lua: -20, lfa: -40, shut: blinking(q, [C('s09', .2)]) }, f);
+ else {
+ const wind = q < T.WHACK ? 0 : span(q, T.WHACK, T.WHACK + .16), after = q > T.WHACK + .5;
+ gran.pose({ x: gx, y: 692 - 110 * Math.sin(Math.PI * hop) - (run > 0 && run < 1 ? 8 * Math.abs(Math.sin(q * 14)) : 0), s: .55, crouch: Math.max(sq, .6 * gd),
+ turn: q > T.CRASH - .15 ? 1 : -1, cap: false, glasses: false, umbrella: true, mouth: gm, brow: -1.5,
+ ua: after ? -160 + .7 * shake : -175 + 40 * wind, fa: after ? -20 : -10, shut: blinking(q, [10.6, 13.0]) }, f);
+ }
+ // the woodcutter steps into the doorway, axe up: "Go on! Shoo!"
+ vis(wood.g, q >= T.WOOD);
+ const stamp = between(q, T.SHOO, T.SHOO + 2 / FPS);
+ wood.pose({ x: 200 + 68 * span(q, T.WOOD, T.WOOD + .35), y: hipOn(800, .62, 200) + breathe(q, 2), s: .62, head: 'F', rua: -60 - 100 * span(q, T.AT_DOOR - .45, T.AT_DOOR - .1) + (q > T.SHOO ? 8 * onTwos(q) : 0), rfa: -20, lua: -10, lfa: 20,
+ hop: stamp ? -10 : 0, brow: -1, mouth: lips(q, 'scene9', PRE9, 's09b'), shut: blinking(q, [C('s09b', 1.6), s9_M('wood') + 1.2]) }, f);
});
}
diff --git a/site/little-red-riding-hood/lib/shared.js b/site/little-red-riding-hood/lib/shared.js
index d014da8..19e5e18 100644
--- a/site/little-red-riding-hood/lib/shared.js
+++ b/site/little-red-riding-hood/lib/shared.js
@@ -161,3 +161,9 @@ function bigStep(u, L = 166, reach = 30) {
const near = -reach * Math.sin(Math.PI * e / 2) - 40 * lift * (1 - e), far = reach * e * .7;
return { near, far, kNear: 75 * lift, kFar: 0, d: 2 * L * Math.sin(reach * Math.PI / 360) * e * 1.6, drop: 0 };
}
+
+// Beds (forest, meadow, room) are 10 s files with soft ends that tile every 9.5 s (SOUND.md): a scene calls sfx() for
+// one once, at its start, and it is laid again every BED_STEP s so it runs to the scene's end (effects past a beat's
+// end never play, and export.py leaves them out too). The page waiting at the meadow stop plays no effects.
+const BED_STEP = { forest: 9.5, meadow: 9.5, room: 9.5 };
+{ const once = window.sfx; window.sfx = (beat, t, name, vol, ...more) => { once(beat, t, name, vol, ...more); if (BED_STEP[name]) for (let k = 1; k * BED_STEP[name] < 60; k++) once(beat, +(t + k * BED_STEP[name]).toFixed(2), name, vol, ...more); }; }