Setting the file. One moment. Engine · Embedded Captions · heygen-com/hyperframes · Skills Docs14.43
Hershey Script Med
(opens in a new tab)
modes/cinematic/engine.html
HTML·355 lines·17 KB
14
15 New in the engine:
16 - MOTION grammar from the DNA: soft / present / impact tones (+ "burn" reveal)
17 - HERO three-act orchestration:
18 act 1 SETUP — co-visible groups dim 0.35s before the hero lands
19 act 2 IMPACT — entrance (emergence | settle | slam | rise) with per-letter
20 stagger; amplitude coupled to the spoken word's RMS loudness
21 act 3 AFTERGLOW — slow breathe scale + glow layer (DNA-gated) until exit
22 - depth-match blur on embed (bg) captions only; fg stays sharp
23 - scene-sampled --accent custom property available to per-group CSS
24-->
25<html lang="en">
26 <head>
27 <meta charset="UTF-8" />
28 <meta name="viewport" content="width={{WIDTH}}, height={{HEIGHT}}" />
29 <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
30 <style>
31 :root {
32 --font-scale: {{FONT_SCALE}};
33 --h: {{HEIGHT}}px; --w: {{WIDTH}}px;
34 --accent: {{ACCENT}};
35 }
36
37 * { margin: 0; padding: 0; box-sizing: border-box; }
38 html, body {
39 margin: 0;
40 width: {{WIDTH}}px; height: {{HEIGHT}}px;
41 overflow: hidden;
42 background: #000;
43 font-family: '{{FONT_FAMILY}}', "Helvetica Neue", system-ui, sans-serif;
44 }
45 #a-roll { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
46 #stage {
47 position: absolute;
48 top: 0; left: 0;
49 width: {{WIDTH}}px; height: {{HEIGHT}}px;
50 pointer-events: none;
51 z-index: 2;
52 }
53
54 /* BASE — DNA tokens. bg (embed) captions get the depth-match filter; fg stays sharp. */
55 .cap {
56 display: block;
57 position: absolute;
58 opacity: 0;
59 mix-blend-mode: {{BLEND_MODE}};
60 color: {{CAP_COLOR}};
61 text-shadow: {{TEXT_SHADOW}};
62 filter: {{TEXT_FILTER_BG}};
63 line-height: 1.12; /* contains ink + internal leading — wrapped rows breathe (was 1.0: rows touched) */
64 will-change: transform, opacity;
65 top: 50%; left: 0; right: 0; text-align: center;
66 }
67 .cap[data-layer="fg"] { filter: {{TEXT_FILTER_FG}}; }
68 .cap .w { display: inline-block; opacity: 0; will-change: opacity, transform; }
69 .cap .w .l { display: inline-block; will-change: opacity, transform; }
70
71 /* hero glow — same glyphs duplicated UNDER the hero, blurred; opacity driven by GSAP.
72 em-based blur scales with the hero's font size. Not part of plan.groups → gates skip it.
73 MUST be out of flow (absolute) — as a flow sibling inside a plane it displaces the hero. */
74 .hero-glow, .plane > .cap.hero-glow { position: absolute; left: 0; right: 0; top: 0; filter: blur(0.06em); }
75 /* hero echoes — colored duplicates (RGB fringe / speed trails); position mirrors the
76 hero via its #id rule, color comes from each echo's own rule */
77 .hero-echo, .plane > .cap.hero-echo { position: absolute; left: 0; right: 0; top: 0; }
78
79 .plane { position: absolute; pointer-events: none; }
80 .plane > .cap {
81 position: relative;
82 top: auto; left: auto; right: auto; bottom: auto;
83 }
84
85 {{DNA_CSS}}
86
87 {{PLANES_CSS}}
88
89 /* Per-group typography (agent-authored). */
90 {{CUSTOM_CSS}}
91 </style>
92 </head>
93 <body>
94 <div
95 id="root"
96 data-composition-id="main"
97 data-start="0"
98 data-duration="{{DURATION}}"
99 data-width="{{WIDTH}}"
100 data-height="{{HEIGHT}}"
101 >
102 <video
103 id="a-roll"
104 src="source.mp4"
105 muted
106 playsinline
107 data-duration="{{DURATION}}"
108 data-track-index="0"
109 style="z-index: 1"
110 ></video>
111
112 <div id="stage">{{GROUPS_HTML}}</div>
113
114 <audio
115 id="a-roll-audio"
116 src="source.mp4"
117 data-start="0"
118 data-duration="{{DURATION}}"
119 data-track-index="3"
120 data-volume="1"
121 ></audio>
122 </div>
123
124 <script>
125 window.__timelines = window.__timelines || {};
126 const tl = gsap.timeline({ paused: true });
127 const DUR = {{DURATION}};
128 const GROUPS = {{GROUPS_JSON}};
129 const MOTION = {{MOTION_JSON}};
130 const HEROES = {{HEROES_JSON}};
131 const HERO_IDS = {};
132 HEROES.forEach(function (h) { HERO_IDS[h.id] = true; });
133
134 /* ── word entrance: the DNA's motion grammar ─────────────────────────
135 Each tone = {y, x, blur, scale, rot, dur, ease} or {reveal:"burn"}.
136 rot alternates sign by word index (deterministic percussion); blur is a
137 filter tween on the word span only (the container's depth-match filter
138 is a separate element — no conflict, no reflow). */
139 function wordReveal(wsel, m, at, idx) {
140 if (m.reveal === "burn") { tl.set(wsel, { opacity: 1 }, at); return; }
141 if (m.reveal === "flicker") {
142 /* neon tube igniting — deterministic on/off pattern, phase-shifted by word
143 index so a line of words doesn't strobe in unison */
144 var o = (idx % 3) * 0.018;
145 tl.set(wsel, { opacity: 1 }, at);
146 tl.set(wsel, { opacity: 0.25 }, at + 0.042 + o);
147 tl.set(wsel, { opacity: 1 }, at + 0.078 + o);
148 tl.set(wsel, { opacity: 0.5 }, at + 0.112 + o);
149 tl.set(wsel, { opacity: 1 }, at + 0.152 + o);
150 return;
151 }
152 var from = { opacity: 0 }, to = { opacity: 1, duration: m.dur || 0.4,
153 ease: m.ease || "power2.out", overwrite: "auto", transformOrigin: "50% 70%" };
154 if (m.y) { from.y = m.y; to.y = 0; }
155 if (m.x) { from.x = m.x; to.x = 0; }
156 if (m.scale && m.scale !== 1) { from.scale = m.scale; to.scale = 1; }
157 if (m.stretchX && m.stretchX !== 1) { from.scaleX = m.stretchX; to.scaleX = 1; }
158 if (m.skewX) { from.skewX = m.skewX; to.skewX = 0; }
159 if (m.rot) { from.rotation = ((idx % 2) ? 1 : -1) * m.rot; to.rotation = 0; }
160 if (m.blur) { from.filter = "blur(" + m.blur + "px)"; to.filter = "blur(0px)"; }
161 tl.fromTo(wsel, from, to, at);
162 }
163
164 var EXIT = MOTION.exit || { dur: 0.5, ease: "power2.in", stagger: 0 };
165 var LINE_REVEAL = MOTION.lineReveal || null;
166
167 /* exit cascade: lines of the same plane sharing one page-flip `out` can leave
168 top-to-bottom (editorial). Slot layout = absolute positions, so staggered
169 exits cause no reflow. Every exit still hard-kills at g.out. */
170 var pageMates = {};
171 GROUPS.forEach(function (g) {
172 if (HERO_IDS[g.id]) return;
173 var key = (g.plane || "free") + "@" + g.out;
174 (pageMates[key] = pageMates[key] || []).push(g.id);
175 });
176
177 GROUPS.forEach(function (g) {
178 if (HERO_IDS[g.id]) return; // heroes are orchestrated below
179 var sel = "#" + g.id;
180 var m = MOTION[g.tone] || MOTION.soft || {};
181
182 tl.set(sel, { opacity: 1 }, Math.max(0, g.in - 0.01));
183
184 /* line container reveal (keynote's surgical wipe) — clip-path, not transform.
185 PHRASE mode: the whole line is set visible up front and the WIPE is the
186 reveal (slide-title idiom) — wiping an empty container reads as nothing. */
187 if (LINE_REVEAL && LINE_REVEAL.type === "wipe-x") {
188 tl.set(sel + " .w", { opacity: 1 }, Math.max(0, g.in - 0.01));
189 tl.fromTo(sel, { clipPath: "inset(0% 100% 0% 0%)" },
190 { clipPath: "inset(0% 0% 0% 0%)", duration: LINE_REVEAL.dur || 0.4,
191 ease: LINE_REVEAL.ease || "expo.out", overwrite: "auto" },
192 Math.max(0, g.in - 0.01));
193 } else {
194 g.words.forEach(function (w, i) {
195 wordReveal(sel + " .w[data-i='" + i + "']", m, w.start, i);
196 });
197 }
198
199 /* exit: DNA grammar — direction + speed + optional per-line cascade */
200 var mates = pageMates[(g.plane || "free") + "@" + g.out];
201 var rank = mates.indexOf(g.id);
202 var lead = (EXIT.stagger || 0) * (mates.length - 1 - rank);
203 var exitAt = Math.max(g.in + 0.1, g.out - (EXIT.dur || 0.5) - lead);
204 var to = { opacity: 0, duration: EXIT.dur || 0.5, ease: EXIT.ease || "power2.in", overwrite: "auto" };
205 if (EXIT.y) to.y = EXIT.y;
206 if (EXIT.x) to.x = EXIT.x;
207 if (EXIT.scale && EXIT.scale !== 1) to.scale = EXIT.scale;
208 if (g.out < DUR) tl.to(sel, to, exitAt);
209 tl.set(sel, { opacity: 0, display: "none" }, g.out);
210 });
211
212 /* ── HEROES: three-act orchestration, one per promoted beat ──────────── */
213 HEROES.forEach(function (HERO) {
214 var hsel = "#" + HERO.id;
215 var gsel = "#" + HERO.id + "-glow";
216 var hg = GROUPS.filter(function (g) { return g.id === HERO.id; })[0];
217 var amp = HERO.amp || 1;
218
219 /* act 1 — SETUP: co-visible groups yield (dim) just before the hero lands.
220 Minor heroes are emphasis-plus: no dim, no ripple, no breathe — the apex
221 keeps those privileges (that's what makes it the apex). */
222 if (!HERO.minor && HERO.dimOthers < 1) {
223 GROUPS.forEach(function (g) {
224 if (g.id === HERO.id) return;
225 if (g.in < HERO.in && g.out > HERO.in) {
226 tl.to("#" + g.id, { opacity: HERO.dimOthers, duration: 0.3, ease: "power2.out", overwrite: "auto" },
227 Math.max(0, HERO.in - 0.35));
228 }
229 });
230 }
231
232 tl.set(hsel, { opacity: 1 }, Math.max(0, HERO.in - 0.01));
233
234 /* act 2 — IMPACT: container entrance (amplitude ∝ spoken loudness) */
235 if (HERO.entrance === "settle") {
236 tl.fromTo(hsel, { scale: 1 + 0.10 * amp },
237 { scale: 1, duration: 0.50, ease: "expo.out", transformOrigin: "50% 60%", overwrite: "auto" }, HERO.in);
238 } else if (HERO.entrance === "slam") {
239 /* percussion: ONE unit, violent snap — geometry locks in 0.16s; heat comes after */
240 tl.fromTo(hsel, { scale: 1 + 0.22 * amp },
241 { scale: 1, duration: 0.16, ease: "back.out(2.2)", transformOrigin: "50% 55%", overwrite: "auto" }, HERO.in);
242 } else if (HERO.entrance === "rise") {
243 tl.fromTo(hsel, { y: 22 * amp },
244 { y: 0, duration: 0.60, ease: "power2.out", overwrite: "auto" }, HERO.in);
245 } else if (HERO.entrance === "wipe-up") {
246 /* surgical slide-title reveal — clip-path only (not a transform: can't
247 collide with the afterglow scale channel), bottom-up behind the subject */
248 tl.fromTo(hsel, { clipPath: "inset(100% 0% 0% 0%)" },
249 { clipPath: "inset(0% 0% 0% 0%)", duration: 0.45, ease: "expo.out", overwrite: "auto" }, HERO.in);
250 } else if (HERO.entrance === "flicker-on") {
251 /* neon sign powering up — deterministic strobe, then steady */
252 tl.set(hsel, { opacity: 1 }, HERO.in);
253 tl.set(hsel, { opacity: 0.15 }, HERO.in + 0.05);
254 tl.set(hsel, { opacity: 1 }, HERO.in + 0.095);
255 tl.set(hsel, { opacity: 0.4 }, HERO.in + 0.14);
256 tl.set(hsel, { opacity: 1 }, HERO.in + 0.19);
257 tl.fromTo(hsel, { scale: 1.03 }, { scale: 1, duration: 0.4, ease: "power2.out", overwrite: "auto", transformOrigin: "50% 55%" }, HERO.in + 0.19);
258 } else if (HERO.entrance === "streak") {
259 /* speed pass — slides in along its own motion blur (skew rides the velocity) */
260 tl.fromTo(hsel, { x: -90 * amp, skewX: -12, opacity: 0 },
261 { x: 0, skewX: 0, opacity: 1, duration: 0.28, ease: "expo.out", overwrite: "auto", transformOrigin: "50% 80%" }, HERO.in);
262 } else { /* emergence — grows out from behind the subject */
263 tl.fromTo(hsel, { scale: Math.max(0.74, 1 - 0.18 * amp) },
264 { scale: 1, duration: 0.55, ease: "expo.out", transformOrigin: "50% 62%", overwrite: "auto" }, HERO.in);
265 }
266
267 /* impact ripple (loud): the hero's landing bumps every co-visible caption —
268 captions only, the footage itself NEVER moves */
269 if (!HERO.minor && HERO.ripple > 0) {
270 GROUPS.forEach(function (g) {
271 if (g.id === HERO.id) return;
272 if (g.in < HERO.in && g.out > HERO.in + 0.3) {
273 tl.to("#" + g.id, { y: HERO.ripple, duration: 0.07, ease: "power2.out", overwrite: "auto" }, HERO.in + 0.04);
274 tl.to("#" + g.id, { y: 0, duration: 0.20, ease: "power2.out", overwrite: "auto" }, HERO.in + 0.11);
275 }
276 });
277 }
278
279 /* words / letters */
280 (hg ? hg.words : []).forEach(function (w, i) {
281 var wsel = hsel + " .w[data-i='" + i + "']";
282 if (HERO.perLetter) {
283 tl.set(wsel, { opacity: 1 }, w.start);
284 var letters = document.querySelectorAll(wsel + " .l");
285 for (var li = 0; li < letters.length; li++) {
286 var lf = { opacity: 0, y: "0.16em", scale: 1.05 };
287 var lt = { opacity: 1, y: 0, scale: 1, duration: 0.30, ease: "power4.out", overwrite: "auto" };
288 if (HERO.letterBlur) { lf.filter = "blur(" + HERO.letterBlur + "px)"; lt.filter = "blur(0px)"; }
289 tl.fromTo(letters[li], lf, lt, w.start + li * (HERO.letterStagger || 0.014));
290 }
291 } else {
292 var m = MOTION.impact || MOTION.present || {};
293 wordReveal(wsel, m, w.start, i);
294 }
295 });
296
297 /* glow layer (DNA-gated). Slam = impact THEN heat: glow waits for geometry lock. */
298 if (HERO.glow > 0) {
299 var glowAt = HERO.in + (HERO.entrance === "slam" ? 0.17 : 0.08);
300 var glowPeak = Math.min(0.5, HERO.glow * amp) * (HERO.minor ? 0.5 : 1);
301 tl.set(gsel + " .w", { opacity: 1 }, Math.max(0, HERO.in - 0.01));
302 tl.fromTo(gsel, { opacity: 0 },
303 { opacity: glowPeak, duration: HERO.entrance === "slam" ? 0.3 : 0.5, ease: "power2.out", overwrite: "auto" },
304 glowAt);
305 tl.to(gsel, { opacity: 0, duration: 0.5, ease: "power2.in", overwrite: "auto" }, HERO.out - 0.5);
306 tl.set(gsel, { opacity: 0, display: "none" }, HERO.out);
307 }
308
309 /* fx: ECHO layers (RGB-split fringe / speed trails) — colored duplicates that
310 CONVERGE as the word lands, then rest at a small offset until exit */
311 if (HERO.echoes && HERO.echoes.length) {
312 HERO.echoes.forEach(function (ec, k) {
313 var esel = "#" + HERO.id + "-echo-" + k;
314 tl.set(esel + " .w", { opacity: 1 }, Math.max(0, HERO.in - 0.01));
315 tl.fromTo(esel,
316 { x: (ec.dx || 0) * 4, y: (ec.dy || 0) * 4, opacity: 0 },
317 { x: ec.dx || 0, y: ec.dy || 0, opacity: ec.opacity != null ? ec.opacity : 0.5,
318 duration: 0.22, ease: "power4.out", overwrite: "auto" }, HERO.in);
319 tl.to(esel, { opacity: 0, duration: 0.4, ease: "power2.in", overwrite: "auto" }, HERO.out - 0.45);
320 tl.set(esel, { opacity: 0, display: "none" }, HERO.out);
321 });
322 }
323
324 /* fx: SHEEN — one gradient sweep across the hero during the hold (chrome).
325 Targets the .w spans (the gradient lives there — see wordCss). Starts as the
326 entrance settles so the specular hit is visible early in the hold. */
327 if (HERO.sheen && HERO.out - HERO.in > 0.9) {
328 tl.fromTo(hsel + " .w", { backgroundPosition: "0% 50%" },
329 { backgroundPosition: "200% 50%", duration: Math.min(1.2, HERO.out - HERO.in - 0.5),
330 ease: "power1.inOut", overwrite: "auto" }, HERO.in + 0.22);
331 }
332
333 /* act 3 — AFTERGLOW: ONE slow scale tween (no loops — deterministic).
334 loom (slow growth, loud) subsumes breathe — never two transform tweens
335 on the same element in the same window. wipe-up entrances are clip-path,
336 so the afterglow scale channel is always free by now. */
337 var after = HERO.loom > 0 ? HERO.loom : HERO.breathe;
338 if (!HERO.minor && after > 0 && HERO.out - HERO.in > 1.4) {
339 tl.fromTo(hsel, { scale: 1 },
340 { scale: 1 + after, duration: HERO.out - HERO.in - 1.2, ease: HERO.loom > 0 ? "power1.inOut" : "sine.inOut", overwrite: "auto" },
341 HERO.in + 0.7);
342 }
343
344 /* exit */
345 if (HERO.out < DUR) {
346 tl.to(hsel, { opacity: 0, duration: 0.5, ease: "power2.in", overwrite: "auto" }, HERO.out - 0.5);
347 }
348 tl.set(hsel, { opacity: 0, display: "none" }, HERO.out);
349 });
350
351 tl.seek(0);
352 window.__timelines["main"] = tl;
353 </script>
354 </body>
355</html>