Skip to content

Commit 071ce80

Browse files
vanceingallsclaude
andauthored
feat(registry): add filmed-screen component (#5487)
* feat(registry): add filmed-screen component Films a live-DOM scene like a camera pointed at a monitor: a tilted screen plane in perspective, depth of field that follows a named element, chromatic fringing, LED sub-pixels, per-shot palettes and cut tears. The focused element stays sharp. Ported from ff-tracking's lens.sksl, with each colour channel weighted by its own sample in the bokeh average. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(registry): land the filmed-screen catalog poster on the title The catalog poster is captured at min(3 s, 0.6 × duration), which was the demo's first cut, so it showed a tear over a blurred title. The first cut moves to 3.8 s and the first shot racks back to the title before it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(registry): filmed-screen glides between shots and racks focus Shots now glide into each other by default: camera, palette and colour mode ease over `glide` seconds, and `transition: "cut"` keeps the hard cut with its tear. Focus racks instead of snapping: the focus box is a Hann-weighted average of where it was over the last `rack` seconds, so a new target eases in on an S-curve and every seek order still renders the same frame. The demo now films three scenes in the style of other compositions, a code editor, an analytics card and a chat thread, one shot and grade each. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(registry): filmed-screen shares the composite slot and films each instance Review on #5487: - The composite hooks no longer cycle with data-vfx-chain. Both re-arm every seek, and core's resolver reads its prior when called, so a stale wrapper of ours is re-entered through it. Each wrapper now keeps its own prior and returns at once when re-entered, so the chain stays a constant depth. The slot is only claimed once a lens is mounted. - A second instance films its own canvas. mount() takes the snippet's caller-scoped query result and picks the first canvas not already filmed; the library's own document belongs to whichever copy loaded first. - No WebGL2 now steps aside like no HTML-in-Canvas. mount() returns { destroy() }, a lens whose canvas leaves the page is dropped, and a lens whose composition is not on screen skips its capture instead of logging. - Docs: fadeOut and zIndex, the rack comment, and the description and tags now describe glides instead of cuts. filmed-screen.test.mjs runs both arm orders against core's arming pattern, two mounts over two canvases, and that the demo pastes the snippet's library. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(registry): filmed-screen test passes oxlint The vfx stand-in returned `true || prior`, which oxlint rejects as a constant-truthiness expression. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(registry): match script tags case-insensitively in the filmed-screen test CodeQL reads the extraction regexps as HTML filters (js/bad-tag-filter). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(registry): filmed-screen waits for the scene's first paint instead of erroring In Studio's preview the first draw can run before Chrome has painted the layoutsubtree scene once (the paint wait gives up after 250 ms on a busy machine). drawElementImage then throws "No cached paint record", which was logged with console.error and surfaced as a preview console error. That error is now a wait: the lens requests a paint and draws again when it lands. Other capture failures still log. Render output is unchanged: the demo renders byte-identical to before. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 0e535ac commit 071ce80

6 files changed

Lines changed: 1979 additions & 1 deletion

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"player:perf": "bun run --filter @hyperframes/player perf",
5454
"format:check": "oxfmt --check .",
5555
"knip": "knip",
56-
"test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/prune-fallow-audit-caches.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/publish-workflow.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/lint-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/ci/base-file.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts",
56+
"test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/prune-fallow-audit-caches.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/publish-workflow.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/lint-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/ci/base-file.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs registry/components/filmed-screen/filmed-screen.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts",
5757
"typecheck:scripts": "tsc --noEmit -p scripts/tsconfig.json",
5858
"test:skills": "HYPERFRAMES_MEDIA_HOME_REQUIRED=1 node --import ./packages/cli/scripts/test-home.mjs --test 'skills/**/*.test.mjs' 'packages/cli/src/media-use/**/*.test.mjs'",
5959
"generate:previews": "tsx scripts/generate-template-previews.ts",
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# filmed-screen
2+
3+
Your scene, filmed off a screen. The live DOM is captured through HTML-in-Canvas every frame and
4+
shaded by one WebGL pass: a tilted screen plane in perspective, depth of field that follows an
5+
element you name, chromatic fringing, LED sub-pixels, a per-shot colour grade, bloom, vignette and
6+
grain. Shots glide into each other and focus racks smoothly between elements. The element in focus stays sharp: inside its box the pass turns off
7+
blur, LED-cell snapping and fringing, and fades back in over ~160 px around it.
8+
9+
Ported from the virtual-camera pass in [ff-tracking](https://github.com/mrsarac/ff-tracking)
10+
(`lens.sksl`), with one change to its maths: each colour channel is weighted by its own sample in
11+
the bokeh average, where the original weighted all three by the green one and tinted blurred
12+
texture green.
13+
14+
## Mounting
15+
16+
Paste `filmed-screen.html` into the composition that owns the scene and put the scene inside
17+
`.hf-filmed-screen-scene`:
18+
19+
```html
20+
<canvas
21+
class="hf-filmed-screen"
22+
layoutsubtree
23+
width="1920"
24+
height="1080"
25+
style="position:absolute;left:0;top:0;width:1920px;height:1080px"
26+
>
27+
<div
28+
class="hf-filmed-screen-scene"
29+
style="position:absolute;left:0;top:0;width:1920px;height:1080px"
30+
>
31+
...scene...
32+
</div>
33+
</canvas>
34+
```
35+
36+
Then edit the `HFFilmedScreen.mount()` call at the bottom of the snippet. It works at the root and
37+
inside a `data-composition-src` sub-composition; shot times are read from the owning composition's
38+
timeline.
39+
40+
## Shots
41+
42+
```js
43+
HFFilmedScreen.mount({
44+
canvas: document.querySelectorAll(".hf-filmed-screen"),
45+
shots: [
46+
{
47+
until: 3,
48+
palette: ["#08060a", "#2a1405", "#8a4a10", "#ffb340", "#fff1d6"],
49+
tilt: [0.16, -0.22, 0.03],
50+
zoom: [1.0, 1.2],
51+
blur: 1.0,
52+
focus: (t) => document.getElementById(t < 1.4 ? "title" : "sub"),
53+
},
54+
{
55+
until: 6,
56+
palette: null,
57+
focus: (t, local) => document.querySelectorAll(".tile")[Math.min(2, local | 0)],
58+
},
59+
],
60+
});
61+
```
62+
63+
| field | default | notes |
64+
| ---------- | ------------------ | -------------------------------------------------------------------------------------------------- |
65+
| until | — | End of the shot, in seconds of the owning composition; the next shot starts here. |
66+
| palette | null | Five hex colours, dark → light. `null` keeps true colour. |
67+
| invert | false | Flips brightness and keeps hue, so light pages read as dark screens. |
68+
| tilt | [0.1, -0.15, 0.02] | Screen plane rotation `[x, y, roll]` in radians. |
69+
| zoom | [1.1, 1.3] | Eased across the shot. |
70+
| blur | 0.9 | Depth-of-field strength; ~0.6–1.2 reads as a phone camera. |
71+
| center | canvas centre | Where the camera points when nothing is in focus. |
72+
| focus | — | `(t, local) → Element \| {x,y,w,h} \| array`; the last entry is the focus. |
73+
| transition | "glide" | `"glide"` eases camera, grade and colour mode in from the previous shot; `"cut"` cuts with a tear. |
74+
| glide | 1.2 | Seconds a glide takes. |
75+
76+
## Mount options
77+
78+
| option | default | notes |
79+
| ------- | ------- | ----------------------------------------------------------------------- |
80+
| canvas | — | Element, list or selector. The first canvas not already filmed is used. |
81+
| shots | — | The shot list above. |
82+
| rack | 0.7 | Seconds a focus change takes to settle. |
83+
| fadeOut | true | Fades to black over the last 0.4 s of the owning composition. |
84+
| zIndex | 10 | z-index of the lens output canvas. |
85+
86+
Pass `document.querySelectorAll(...)` from your own snippet rather than a selector string. The
87+
library initialises once per page, so its own `document` belongs to whichever copy loaded first;
88+
your query is scoped to your composition, which is what keeps two instances (or the same
89+
sub-composition mounted twice) on their own canvases.
90+
91+
Focus is a weighted average, over the last `rack` seconds, of where each shot's target sits in the
92+
DOM now, so it eases on an S-curve and any seek order renders the same frame.
93+
94+
`mount()` returns `{ destroy() }`, which drops the lens, frees its GL context and removes its output
95+
canvas. A lens whose canvas leaves the page is dropped on the next frame anyway.
96+
97+
The lens shares the engine's composite hooks with other owners such as `data-vfx-chain`: each
98+
wrapper keeps its own prior and a re-entered one returns at once, so the chain stays a constant
99+
depth however both re-arm. `filmed-screen.test.mjs` runs that against core's arming pattern.
100+
101+
A `<canvas>` without `layoutsubtree` (p5, three.js, a 2D canvas) is sampled directly instead; give
102+
`focus` rectangles in its pixel space.
103+
104+
## Requirements and costs
105+
106+
- **HTML-in-Canvas** (`drawElementImage`) and **WebGL2**, which the HyperFrames renderer's Chrome
107+
has. Without either, the snippet moves the scene back into the page and renders it unfilmed, with
108+
one console warning.
109+
- **Keep the `<canvas layoutsubtree>` in the HTML.** The renderer picks screenshot capture for
110+
compositions that declare one. Created from script, it is never seen, the frame handshake is
111+
skipped and frames come out blank.
112+
- **`.hf-filmed-screen-scene` needs a pixel size.** `inset: 0` inside a layoutsubtree canvas
113+
measures 0×0 and captures nothing.
114+
- **Renders use screenshot capture on one worker**, so they are slower than drawElement capture.
115+
- The scene is stamped with `data-layout-allow-occlusion` at mount, because `check` otherwise reports
116+
every filmed line of text as hidden under the output canvas. Elements added after mount are not
117+
stamped.

0 commit comments

Comments
 (0)