code-slice-hero
A tiled headline surface flips cell by cell under a sweeping depth field to reveal the rear headline. HyperFrames block, 1920×1080, 8s, 18 variables.
1How It Works & Mechanism
Output shot: A full surface of square tiles hosts a seamless front headline; an imaginary cursor sweeps across the surface, causing nearby tiles to elevate and tilt according to a Gaussian depth field, while only cells that intersect with the contours of both headlines flip over to reveal the rear headline.
A full square-tile surface carries one seamless headline. An imaginary cursor crosses the surface; nearby tiles respond to its Gaussian depth field with lift and tilt, and only the cells intersecting either headline silhouette turn over to reveal the rear headline.
The rendering implementation consists of a 'single instanced WebGL 2 draw' + front/rear headline shared atlas + a batch-projected shadow pass; this is the opposite of a 'per-tile element' approach and is why the block can run stably at 30 fps.
The whole grid is one instanced WebGL 2 draw with a shared front/rear texture pair, plus a batched projected-shadow pass.
Copy, font size, and tile side length are independent: tiles crop the atlas per cell, so larger text will never stretch the squares into rectangles.
Copy, text size and square cell size are independent, so tiles never stretch.
All 18 variables are read with clamp: the schema is parsed first to obtain default values, then overridden with getVariables(), with numerical values clamped one by one to their declared ranges, falling back to defaults on invalid values.
const values = { ...defaults, ...(window.__hyperframes?.getVariables?.() || {}) }; … const clamp = (v, a = 0, b = 1) => Math.max(a, Math.min(b, v));
Headline atlases are drawn on-the-fly at runtime using Canvas 2D (willReadFrequently context), with the front and rear headlines sharing a pair of atlases.
function textSurface(text) { … const canvas = document.createElement("canvas"); … const ctx = canvas.getContext("2d", { willReadFrequently: true });
WebGL2 is a strict requirement: an error is thrown directly if a webgl2 context cannot be acquired, rather than silently degrading.
if (!gl) throw new Error("Code Slice Hero requires WebGL 2 for its full tile surface.");
Follows the deterministic contract family: a paused timeline is registered to window.__timelines["code-slice-hero"], resynchronized via hf-seek, where each frame is a closed-form function of t.
One paused GSAP timeline registered as `window.__timelines["code-slice-hero"]`. … Re-syncs on the `hf-seek` CustomEvent; every frame is a closed-form function of time (seeded PRNG only, no rAF loops, no Date.now).
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | HyperFrames 官方 CLI(add / render) |
| package | GSAP 3.14.2(随块本地副本,非 CDN) |
| package | Geist-Bold.ttf(OFL)与 GSAP-NOTICE.txt 随块分发;本目录无任何网络依赖 |
4Recommended Governance & Evidence
- scripts/: Execute local script or command: code-slice-hero.html (Browser/renderer execution: parse variables → generate front/rear text atlases → register paused GSAP timeline → listen to h
5Second-Pass Verification
- [ok] 变量数与声明一致性(frontmatter 自称 18 variables) — 脚本实测:SKILL.md 变量表 18 行、html data-composition-variables 解析出 18 项、frontmatter 写 18 —— 一致。
- [ok] 「External runtime dependencies: none (served locally)」声称 — 对 html/shadows.js/surface.js 做 http(s):// 全文 grep:零命中;脚本标签只引用 assets/gsap-3.14.2.min.js 与同目录两个模块,字体为本地 Geist-Bold.ttf。
- [ok] WebGL2 硬门槛 — surface.js 中 `if (!gl) throw new Error("Code Slice Hero requires WebGL 2 for its full tile surface.");` 逐字命中,确为显式失败而非静默降级。
- [ok] registry-item 文件清单 vs 盘上文件 — 声明 8 个文件(含 shadows.js / surface.js / 字体 / 两份许可文本)全部存在于盘上,无远端 url 兜底。
- [ok] 无随机/时钟依赖 — 本目录 grep Math.random、Date.now、performance.now、requestAnimationFrame:零命中(确定性由 SKILL.md 的 Runtime contract 声明)。
- [ok] 阴影 pass 的自述与代码相符 — shadows.js 首行注释与实现一致:固定 light 向量、按 bucketSize 空间分桶、单次额外 GPU draw;非 three 阴影系统。
6Verdict & Scenarios
f4df15e71090b458…