mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-11 19:09:20 +00:00
* feat(catalog): add the seven 3D-motion pieces as installable registry blocks Each piece ships as a registry block with a CDN poster and preview, a live catalog detail page and its source. Scripts travel inside the catalog payload (shared vendor libraries fetched once, item scripts inline, the one HDR as a data URI) because the docs host only serves fonts, images and JSON. NO_ESSAY_COMMENTS_OK: the long comment blocks are in vendored libraries and the ported frost source under registry/blocks, not hand-written here. HF_MAX_NONLFS_KB=6000: four hosted texture PNGs under docs/public/catalog/items are runtime assets the docs host must serve as files. fallow skipped locally: it audits against origin/main and this branch is stacked on an older main. * chore(catalog): regenerate gallery data and nav after rebasing onto main * fix(catalog): read the install manifest through the bounded project reader * fix(catalog): a script the inliner missed fails the payload instead of shipping a dead URL * refactor(catalog): the leftover-script check reuses the reference finder * fix(catalog): frost and glass textures load from the CDN and the iteration presets are gone * chore(catalog): regenerate the frost and glass payloads and nav * fix(catalog): frost and glass textures are hosted through the registry url field, not hardcoded * chore(catalog): regenerate the frost and glass payloads against the hosted texture URLs * fix(catalog): the hosted-reference rewrite refuses a bare name it cannot safely replace * ci(catalog): verify changed catalog payloads in headless Chrome and check the docs catalog * feat(catalog): every item page follows the shared layout with a Tune panel and tabs * fix(catalog): let the texture-mask item host its masks so its tile plays live * chore(catalog): regenerate item pages, gallery data and the texture-mask payload * chore(catalog): regenerate item pages after merging main * fix(catalog): declared-only variables get the Tune panel, Code and Docs tabs capped * feat(catalog): give the blend-difference caption a demo scene so its tile plays live * chore(catalog): live payload for the blend-difference caption * perf(catalog): heavy 3d pieces compile and draw before ready, not on the first visible frame * feat(catalog): the avatar promo card hosts its videos, audio and fonts on the CDN * feat(catalog): the avatar promo card tile plays live from its CDN-hosted media * chore(catalog): the avatar promo card plays live, no allowlist left * chore(catalog): shorten two comment blocks * chore(catalog): trim first-party comment blocks to the comment-check limits * chore(catalog): shorten two frost source comments * fix(catalog): the Docs tab renders as prose again, and the detail page honours reduced motion Frame-mode pages carry no prose wrapper, and the detail component sat inside not-prose, so the Docs slot's headings, paragraphs, links and lists had no styling at all. The slots now carry their own prose classes and the chrome around them keeps not-prose. The recorded clip also gets the reduced-motion guard the docs-snippet check requires, and the generator reads stability from the source metadata type so the scripts typecheck passes. * fix(catalog): docs-tab paragraphs render as blocks Mintlify emits paragraphs as inline spans, so two paragraphs in the Docs slot ran together. * fix(ci): drop the duplicate docs_catalog job output git's line-based auto-merge silently duplicated the outputs key when main and this branch each added it on non-adjacent lines during the rebase; oxfmt's yaml parser rejects the repeated map key. * fix(catalog): close four CodeQL alerts in the frost source * chore(catalog): allowlist the avatar-promo-card CDN asset deletions, format sync-docs-catalog check-no-main-deletions.mjs was rejecting 11 local mp4/font files this branch already deleted in favor of CDN hosting; scripts/sync-docs-catalog.mjs had one line over the 100-col print width from an earlier edit in this branch. * fix(catalog): detail tabs use docs prose spacing, Install first; previews skip no-WebGPU runners * fix(catalog): the docs tab scrolls with the page instead of a capped inner box * refactor(catalog): split the payload asset and verify scripts into single-purpose helpers * refactor(catalog): split the preview generator into single-purpose helpers * ci(catalog): fail when the committed catalog differs from generator output The docs host serves the committed catalog and nothing regenerates it, so a stale copy shipped silently. The catalog payloads job now generates into a temp dir and compares it with the committed tree. * chore(catalog): regenerate docs/public/catalog with the refactored scripts One full regeneration from an empty output tree with the current scripts. The tree grows from 58.4 MB to 65.1 MB. Two hosted assets are about 2 MB each (an avatar png and a wav); the same bytes are already committed under assets/, so HF_MAX_NONLFS_KB is raised for this commit only. * fix(catalog): run the catalog script tests under the runner they are written for The rebase put three node:test files in the vitest half of test:scripts, where they report "No test suite found". They now sit in the node --test list. * fix(catalog): a WebGPU item without an adapter shows its recorded clip and says why * ci(catalog): the drift check runs from a committed fetch mirror with no network Generation now serves every font and CDN script fetch from scripts/catalog-fetch-mirror and fails when a fetch is not in it, even if the caller swallowed the error. CATALOG_FETCH_MIRROR=record refreshes the mirror from the live network. The docs_catalog filter also watches packages/core, packages/producer and the mirror, and the 13 re-hashed font files are listed in ALLOWED_DELETIONS. * chore(catalog): clean up the temp font cache and sort the mirror index without a locale * fix(catalog): hide Tune when the clip stands in, time out the adapter request, share one check * fix(catalog): the adapter probe survives a sync throw and a hang; test the clip guard * fix(catalog): keep the adapter probe inside the component, Mintlify evaluates only exports * fix(catalog): run the detail and page generator tests in CI; no Tune flash while probing WebGPU * docs(catalog): credit vendored libraries and make each SKILL.md list what the block installs CREDITS.md names every vendored dependency with its upstream and licence, and flags the two leaf textures whose origin is still to be confirmed. Each SKILL.md Files table now comes from the block manifest and its install and render paths point at compositions/<name>/. A test checks that every path a SKILL.md names is a manifest file that exists. * fix(catalog): a declared WebGPU item passes verify by its manifest tag, not by console wording verify-catalog-payloads forgave a missing adapter only by matching the markup and the message, which library-reported errors and widgets never satisfy. The webgpu tag in the item manifest is now the owner: a tagged item ignores its page and console errors, an untagged one gets no forgiveness, and a marker payload with no html is listed instead of crashing the run. * docs(catalog): correct the credits per block and guard the mount and render paths CREDITS.md states the three.js version and vendored-or-CDN status per block, adds d3-delaunay, Clipper on the CDN and the Google Fonts loads, and lists every texture with no known origin. The SKILL.md test now also checks the mount and render paths against the manifest composition. * test(catalog): read each block manifest once in the SKILL.md file test The two checks shared a copied manifest read, which fallow flagged as a clone with a high score. * fix(catalog): commit the hosted item files a gitignore rule kept out, and check git not the disk The compositions/ and *-ad/ ignore rules matched folder names under docs/public/catalog/items, so 33 hosted fonts, textures and marks were generated but never committed and would 404 on the docs host. The rules now have a negation for that tree and the files are added. The drift check read the checkout, where git-ignored files still exist, so it passed locally and failed only in CI. It now unpacks HEAD with git archive and compares that. * fix(catalog): a tile keeps its poster until the composition has painted * fix(catalog): a tagged WebGPU item forgives only the adapter-absent error, and test the wiring The manifest webgpu tag now decides whether an item may lack an adapter, and the error wording decides which lines are that absence. Any other page or console error on the item, and every failed request, still fails. The per-item decision is one exported function the tests drive, marker payloads are parsed by a tested helper, and the SKILL.md variable counts are checked against their tables (cuboid-carousel said forty-nine for forty). * fix(catalog): the pinned group's posters load eagerly at high priority * fix(catalog): type the tile reveal test so the scripts typecheck passes * fix(catalog): stop the adapter signature matching an unrelated failed adapter request failed to request .*adapter also matched errors about other adapters. It now matches only a request for the WebGPU adapter, so a tagged item cannot hide an unrelated failure behind it. * test(catalog): a tagged item still fails on an error about some other adapter * feat(catalog): the install command sits above the preview, as on the live catalog * fix(catalog): find the install slot through Mintlify's child wrapper * fix(docs): catalog copy buttons keep their size when the label swaps to Copied * refactor(docs): name the shown copy label once in the catalog copy button * fix(docs): primary catalog button keeps a readable label on hover and after copy * fix(docs): inset the catalog tab strip and tab content to match the boxed panels
889 lines
35 KiB
Plaintext
889 lines
35 KiB
Plaintext
---
|
|
title: "Scroll Camera Story"
|
|
description: "A compressed forced-scroll cinematic pass: a tall scene of slotted sections travels past the camera top to bottom, depth layers parallax at different rates, each section rises as the camera reaches it, and the pass decelerates into a held final section."
|
|
mode: "frame"
|
|
---
|
|
|
|
import { CatalogDetail, CatalogSlot } from "/snippets/catalog-detail.jsx";
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
|
|
<CatalogDetail
|
|
previewSrc="/public/catalog/components/scroll-camera-story.json"
|
|
compositionId="scroll-camera-story"
|
|
compositionSrc="compositions/components/scroll-camera-story.html"
|
|
title="Scroll Camera Story"
|
|
description="A compressed forced-scroll cinematic pass: a tall scene of slotted sections travels past the camera top to bottom, depth layers parallax at different rates, each section rises as the camera reaches it, and the pass decelerates into a held final section."
|
|
variables={[{"id":"sections","type":"number","role":"content","label":"Sections","description":"How many skeleton sections ride the pass. A sections slot overrides this with its own child count.","default":3,"min":2,"max":4,"step":1},{"id":"travel","type":"number","role":"content","label":"Travel","description":"Total camera travel in cqh. The world is 100 + travel cqh tall.","default":220,"min":100,"max":400,"step":10,"unit":"cqh"},{"id":"cues","type":"string","role":"timing","label":"Cues","description":"Comma-separated seconds: arrival times for the sections after the first. Empty keeps the authored default rhythm.","default":""},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Token the skeleton accents and foreground motes ride.","default":"green","options":[{"value":"green","label":"Green"},{"value":"blue","label":"Blue"},{"value":"violet","label":"Violet"}]},{"id":"exit","type":"enum","role":"style","label":"Exit","description":"Optional departure. None holds the final section.","default":"none","options":[{"value":"none","label":"None"},{"value":"fade","label":"Fade"},{"value":"up","label":"Up"}]}]}
|
|
meta={{"category":"Camera & 3D","badge":"Stable","codeLines":805}}
|
|
attribution={{"path":"registry/components/scroll-camera-story","tags":["camera","scroll","parallax","story","sections","slot","servo"]}}
|
|
hasCode
|
|
rawUrl="https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry/components/scroll-camera-story/scroll-camera-story.html"
|
|
>
|
|
|
|
<CatalogSlot slot="code">
|
|
|
|
```html scroll-camera-story.html
|
|
<!doctype html>
|
|
<!--
|
|
scroll-camera-story -- HyperFrames video primitive (camera)
|
|
|
|
A compressed forced-scroll cinematic pass: a tall authored scene travels
|
|
past the camera top to bottom. Four depth layers move at different rates
|
|
(far slowest, foreground fastest), sections enter with a soft rise as the
|
|
camera reaches them, and the pass decelerates into a held final section.
|
|
|
|
Camera-servo law: all camera state lives in ONE plain object (cam.t, the
|
|
pass progress 0 to 1) plus a drift object, and every layer transform is a
|
|
pure function of that state written by one applyCamera() writer. The world
|
|
wrapper carries the camera translate; depth layers carry derived parallax
|
|
offsets computed in the same writer, so any seek in any order reproduces
|
|
the exact frame. Micro-drift runs INTEGER sine cycles (2 on x-phase, 3 on
|
|
y-phase) that end at exactly zero when the final section lands, so the
|
|
held final section is byte-still.
|
|
|
|
Seek-safety trap (banked): cq-unit transform tweens blow up under seeks.
|
|
Nothing here tweens a cq unit. The world height is set ONCE at mount in
|
|
cqh; every tweened transform is percent-based (translate percent of the
|
|
element's own box, gsap yPercent on section cards) derived from plain
|
|
numbers, so no container-query re-resolution ever happens inside a tween.
|
|
|
|
Sections are SLOTS. Callers supply content by placing an inert template
|
|
at HOST DOCUMENT level (templates never render, and the runtime wipes the
|
|
host clip's own children on mount):
|
|
|
|
<template data-slot="scroll-camera-story-sections">
|
|
<div>first section content</div>
|
|
<div>second section content</div>
|
|
</template>
|
|
|
|
Each direct child of the template becomes one section's card content, in
|
|
order (clamped to 2-4 sections). Sections without a slot child keep their
|
|
token skeleton default. Without a slot, the `sections` variable picks how
|
|
many skeleton sections ride the pass.
|
|
|
|
Variables (declared in data-composition-variables below):
|
|
- sections (number 2-4, default 3): skeleton section count; a sections
|
|
slot overrides it with its own child count.
|
|
- travel (number cqh, default 220): total camera travel. The world is
|
|
(100 + travel) cqh tall; sections spread evenly along the travel.
|
|
- cues (string, default ""): comma-separated seconds, arrival times for
|
|
the sections AFTER the first (the first section is on screen at
|
|
mount). Empty keeps the authored default rhythm. If one extra value
|
|
is supplied, the first is treated as the mount section's and dropped.
|
|
- accent ("green" | "blue" | "violet", default "green"): green rides
|
|
--brand, blue rides --accent, violet rides --accent-2.
|
|
- exit ("none" | "fade" | "up", default "none"): frame roots own
|
|
transitions; the default holds the final section to the last pixel.
|
|
|
|
Envelope, fixed IN and OUT with elastic HOLD only (never timeScale):
|
|
IN_BASE = 0.85s stage fade + first section rise
|
|
PASS = camera moves ending on each arrival cue, quiet register
|
|
(power2.inOut, longer final move: the pass decelerates)
|
|
HOLD = elastic; drift ends at zero on the last arrival, then the
|
|
held final section is dead still
|
|
OUT_BASE = 0.50s only when exit != none
|
|
If D is too short the fixed phases compress together.
|
|
|
|
Wave K laws: L1, camera segments never overlap (each move starts after
|
|
the previous ends, so no mid-motion redirect exists to snap velocity);
|
|
L2, the quiet register is the only register here, no percussive variant.
|
|
|
|
Mount contract: the runtime clones only this template. #root fills the
|
|
host box (no data-width/data-height, container-type: size, cq units in
|
|
static styles only), is styled via #root only, and registers one paused
|
|
timeline under the LITERAL "scroll-camera-story" key.
|
|
-->
|
|
<html
|
|
lang="en"
|
|
data-composition-id="scroll-camera-story"
|
|
data-composition-duration="5.5"
|
|
data-composition-variables='[
|
|
{ "id": "sections", "type": "number", "role": "content", "label": "Sections", "description": "How many skeleton sections ride the pass. A sections slot overrides this with its own child count.", "default": 3, "min": 2, "max": 4, "step": 1 },
|
|
{ "id": "travel", "type": "number", "role": "content", "label": "Travel", "description": "Total camera travel in cqh. The world is 100 + travel cqh tall.", "default": 220, "min": 100, "max": 400, "step": 10, "unit": "cqh" },
|
|
{ "id": "cues", "type": "string", "role": "timing", "label": "Cues", "description": "Comma-separated seconds: arrival times for the sections after the first. Empty keeps the authored default rhythm.", "default": "" },
|
|
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Token the skeleton accents and foreground motes ride.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
|
|
{ "id": "exit", "type": "enum", "role": "style", "label": "Exit", "description": "Optional departure. None holds the final section.", "default": "none", "options": [{ "value": "none", "label": "None" }, { "value": "fade", "label": "Fade" }, { "value": "up", "label": "Up" }] }
|
|
]'
|
|
>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Scroll Camera Story</title>
|
|
</head>
|
|
<body>
|
|
<template>
|
|
<div id="root" data-composition-id="scroll-camera-story" data-duration="5.5" data-fps="30">
|
|
<style>
|
|
*,
|
|
*::before,
|
|
*::after {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
#root {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
container-type: size;
|
|
isolation: isolate;
|
|
color: var(--fg, #f8fafc);
|
|
font-family: var(--font-body, ui-sans-serif, system-ui, sans-serif);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.scs-clip {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
background: var(--bg, transparent);
|
|
}
|
|
|
|
.scs-stage {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
background:
|
|
radial-gradient(
|
|
ellipse 120% 70% at 50% 0%,
|
|
color-mix(in srgb, var(--scs-accent) 6%, transparent) 0%,
|
|
transparent 60%
|
|
),
|
|
var(--bg, #0b0c0e);
|
|
will-change: transform, opacity;
|
|
}
|
|
|
|
/* ONE world wrapper: the camera translate lives here; depth layers
|
|
below carry derived parallax offsets from the same writer. */
|
|
.scs-world {
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
left: 0;
|
|
will-change: transform;
|
|
}
|
|
|
|
.scs-layer {
|
|
position: absolute;
|
|
inset: 0;
|
|
will-change: transform;
|
|
}
|
|
|
|
/* far layer: large soft washes, slowest */
|
|
.scs-blob {
|
|
position: absolute;
|
|
width: 64cqmin;
|
|
height: 64cqmin;
|
|
border-radius: 50%;
|
|
background: radial-gradient(
|
|
circle,
|
|
color-mix(in srgb, var(--scs-accent) 11%, transparent) 0%,
|
|
color-mix(in srgb, var(--scs-accent) 5%, transparent) 45%,
|
|
transparent 70%
|
|
);
|
|
}
|
|
|
|
.scs-blob:nth-child(1) {
|
|
top: 2%;
|
|
left: -14cqmin;
|
|
}
|
|
|
|
.scs-blob:nth-child(2) {
|
|
top: 17%;
|
|
right: -18cqmin;
|
|
width: 78cqmin;
|
|
height: 78cqmin;
|
|
background: radial-gradient(
|
|
circle,
|
|
color-mix(in srgb, var(--fg, #f8fafc) 6%, transparent) 0%,
|
|
color-mix(in srgb, var(--fg, #f8fafc) 3%, transparent) 45%,
|
|
transparent 70%
|
|
);
|
|
}
|
|
|
|
.scs-blob:nth-child(3) {
|
|
top: 34%;
|
|
left: 6cqw;
|
|
}
|
|
|
|
.scs-blob:nth-child(4) {
|
|
top: 48%;
|
|
right: 2cqw;
|
|
width: 56cqmin;
|
|
height: 56cqmin;
|
|
}
|
|
|
|
/* mid layer: hairline geometry */
|
|
.scs-ring {
|
|
position: absolute;
|
|
width: 16cqmin;
|
|
height: 16cqmin;
|
|
border: 0.16cqmin solid color-mix(in srgb, var(--fg, #f8fafc) 12%, transparent);
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.scs-rule {
|
|
position: absolute;
|
|
width: 12cqmin;
|
|
height: 0.16cqmin;
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 14%, transparent);
|
|
}
|
|
|
|
.scs-plus {
|
|
position: absolute;
|
|
width: 3.4cqmin;
|
|
height: 3.4cqmin;
|
|
}
|
|
|
|
.scs-plus::before,
|
|
.scs-plus::after {
|
|
position: absolute;
|
|
content: "";
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 18%, transparent);
|
|
}
|
|
|
|
.scs-plus::before {
|
|
top: 0;
|
|
bottom: 0;
|
|
left: calc(50% - 0.08cqmin);
|
|
width: 0.16cqmin;
|
|
}
|
|
|
|
.scs-plus::after {
|
|
top: calc(50% - 0.08cqmin);
|
|
right: 0;
|
|
left: 0;
|
|
height: 0.16cqmin;
|
|
}
|
|
|
|
.scs-ring:nth-of-type(1) {
|
|
top: 6%;
|
|
right: 12cqw;
|
|
}
|
|
|
|
.scs-ring:nth-of-type(2) {
|
|
top: 30%;
|
|
left: 9cqw;
|
|
width: 10cqmin;
|
|
height: 10cqmin;
|
|
}
|
|
|
|
.scs-ring:nth-of-type(3) {
|
|
top: 52%;
|
|
right: 8cqw;
|
|
width: 22cqmin;
|
|
height: 22cqmin;
|
|
border-color: color-mix(in srgb, var(--fg, #f8fafc) 8%, transparent);
|
|
}
|
|
|
|
.scs-rule:nth-of-type(1) {
|
|
top: 14%;
|
|
left: 12cqw;
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.scs-rule:nth-of-type(2) {
|
|
top: 40%;
|
|
right: 16cqw;
|
|
}
|
|
|
|
.scs-plus:nth-of-type(1) {
|
|
top: 22%;
|
|
right: 22cqw;
|
|
}
|
|
|
|
.scs-plus:nth-of-type(2) {
|
|
top: 47%;
|
|
left: 18cqw;
|
|
}
|
|
|
|
.scs-plus:nth-of-type(3) {
|
|
top: 9%;
|
|
left: 30cqw;
|
|
}
|
|
|
|
/* foreground layer: small accent motes, fastest */
|
|
.scs-mote {
|
|
position: absolute;
|
|
width: 1cqmin;
|
|
height: 1cqmin;
|
|
border-radius: 50%;
|
|
background: color-mix(in srgb, var(--scs-accent) 55%, transparent);
|
|
}
|
|
|
|
.scs-mote:nth-child(1) {
|
|
top: 7%;
|
|
left: 8cqw;
|
|
}
|
|
|
|
.scs-mote:nth-child(2) {
|
|
top: 21%;
|
|
right: 10cqw;
|
|
width: 0.7cqmin;
|
|
height: 0.7cqmin;
|
|
}
|
|
|
|
.scs-mote:nth-child(3) {
|
|
top: 43%;
|
|
left: 6cqw;
|
|
width: 1.3cqmin;
|
|
height: 1.3cqmin;
|
|
background: color-mix(in srgb, var(--scs-accent) 40%, transparent);
|
|
}
|
|
|
|
.scs-mote:nth-child(4) {
|
|
top: 66%;
|
|
right: 7cqw;
|
|
}
|
|
|
|
.scs-mote:nth-child(5) {
|
|
top: 88%;
|
|
left: 4cqw;
|
|
width: 0.8cqmin;
|
|
height: 0.8cqmin;
|
|
}
|
|
|
|
/* sections: a static positioner zone per section, a rising card in it */
|
|
.scs-section {
|
|
position: absolute;
|
|
right: 10cqw;
|
|
left: 10cqw;
|
|
display: grid;
|
|
place-items: center;
|
|
height: 84cqh;
|
|
}
|
|
|
|
.scs-card {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: var(--space-2, 2.2cqmin);
|
|
width: min(64cqw, 150cqh);
|
|
max-height: 76cqh;
|
|
padding: var(--space-3, 3.4cqmin);
|
|
overflow: hidden;
|
|
border: 0.16cqmin solid color-mix(in srgb, var(--border, #475569) 70%, transparent);
|
|
border-radius: var(--radius, 2cqmin);
|
|
background: color-mix(in srgb, var(--surface, #0b1016) 88%, var(--bg, #05070c));
|
|
box-shadow: 0 2.4cqh 7cqh color-mix(in srgb, var(--bg, #000000) 34%, transparent);
|
|
will-change: transform, opacity;
|
|
}
|
|
|
|
.scs-chiprow {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--space-1, 1.6cqmin);
|
|
}
|
|
|
|
.scs-chip {
|
|
padding: 0.7cqmin 1.5cqmin;
|
|
border: 0.14cqmin solid color-mix(in srgb, var(--scs-accent) 45%, transparent);
|
|
border-radius: 999px;
|
|
color: color-mix(in srgb, var(--scs-accent) 80%, var(--fg, #f8fafc));
|
|
font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
|
|
font-size: 2cqmin;
|
|
font-weight: 600;
|
|
letter-spacing: 0.14em;
|
|
line-height: 1;
|
|
}
|
|
|
|
.scs-chiprule {
|
|
flex: 1;
|
|
height: 0.14cqmin;
|
|
background: color-mix(in srgb, var(--border, #475569) 60%, transparent);
|
|
}
|
|
|
|
.scs-bar {
|
|
height: 1.4cqmin;
|
|
border-radius: 999px;
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 12%, transparent);
|
|
}
|
|
|
|
.scs-bar.scs-heading {
|
|
width: 62%;
|
|
height: 3.4cqmin;
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 24%, transparent);
|
|
}
|
|
|
|
.scs-bar.scs-sub {
|
|
width: 44%;
|
|
}
|
|
|
|
.scs-minis {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
gap: 2cqmin;
|
|
margin-top: 0.6cqmin;
|
|
}
|
|
|
|
.scs-mini {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1.4cqmin;
|
|
padding: 2cqmin;
|
|
border: 0.14cqmin solid color-mix(in srgb, var(--border, #475569) 55%, transparent);
|
|
border-radius: calc(var(--radius, 2cqmin) * 0.7);
|
|
background: color-mix(in srgb, var(--bg, #05070c) 32%, transparent);
|
|
}
|
|
|
|
.scs-mini .scs-bar {
|
|
width: 62%;
|
|
}
|
|
|
|
.scs-mini-block {
|
|
height: 7cqmin;
|
|
border-radius: calc(var(--radius, 2cqmin) * 0.5);
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 7%, transparent);
|
|
}
|
|
|
|
.scs-mini:nth-child(2) .scs-mini-block {
|
|
background: color-mix(in srgb, var(--scs-accent) 18%, transparent);
|
|
}
|
|
|
|
.scs-rowline {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--space-1, 1.6cqmin);
|
|
}
|
|
|
|
.scs-dot {
|
|
flex: 0 0 auto;
|
|
width: 1.5cqmin;
|
|
height: 1.5cqmin;
|
|
border-radius: 50%;
|
|
background: color-mix(in srgb, var(--fg, #f8fafc) 22%, transparent);
|
|
}
|
|
|
|
.scs-rowline:nth-of-type(2) .scs-dot {
|
|
background: color-mix(in srgb, var(--scs-accent) 70%, transparent);
|
|
}
|
|
|
|
.scs-rowline .scs-bar {
|
|
flex: 1;
|
|
max-width: 72%;
|
|
}
|
|
|
|
.scs-section[data-close] .scs-card {
|
|
align-items: center;
|
|
text-align: center;
|
|
}
|
|
|
|
.scs-section[data-close] .scs-bar.scs-heading {
|
|
width: 52%;
|
|
}
|
|
|
|
.scs-section[data-close] .scs-bar.scs-sub {
|
|
width: 34%;
|
|
}
|
|
|
|
.scs-pill {
|
|
margin-top: 1.2cqmin;
|
|
padding: 1.4cqmin 3.4cqmin;
|
|
border-radius: 999px;
|
|
background: color-mix(in srgb, var(--scs-accent) 82%, var(--surface, #0b1016));
|
|
color: var(--bg, #0b0c0e);
|
|
font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
|
|
font-size: 2.1cqmin;
|
|
font-weight: 600;
|
|
letter-spacing: 0.12em;
|
|
line-height: 1;
|
|
}
|
|
</style>
|
|
|
|
<div
|
|
id="scroll-camera-story-clip"
|
|
class="scs-clip clip"
|
|
data-start="0"
|
|
data-duration="5.5"
|
|
data-track-index="0"
|
|
>
|
|
<div class="scs-stage" role="img" aria-label="Cinematic scroll pass over a tall scene">
|
|
<div class="scs-world">
|
|
<div class="scs-layer scs-far" aria-hidden="true">
|
|
<span class="scs-blob"></span>
|
|
<span class="scs-blob"></span>
|
|
<span class="scs-blob"></span>
|
|
<span class="scs-blob"></span>
|
|
</div>
|
|
<div class="scs-layer scs-mid" aria-hidden="true">
|
|
<span class="scs-ring"></span>
|
|
<span class="scs-ring"></span>
|
|
<span class="scs-ring"></span>
|
|
<span class="scs-rule"></span>
|
|
<span class="scs-rule"></span>
|
|
<span class="scs-plus"></span>
|
|
<span class="scs-plus"></span>
|
|
<span class="scs-plus"></span>
|
|
</div>
|
|
<div class="scs-layer scs-content">
|
|
<div class="scs-section" aria-hidden="true">
|
|
<div class="scs-card">
|
|
<div class="scs-chiprow">
|
|
<span class="scs-chip">01</span>
|
|
<span class="scs-chiprule"></span>
|
|
</div>
|
|
<span class="scs-bar scs-heading"></span>
|
|
<span class="scs-bar" style="width: 74%"></span>
|
|
<span class="scs-bar scs-sub"></span>
|
|
</div>
|
|
</div>
|
|
<div class="scs-section" aria-hidden="true">
|
|
<div class="scs-card">
|
|
<div class="scs-chiprow">
|
|
<span class="scs-chip">02</span>
|
|
<span class="scs-chiprule"></span>
|
|
</div>
|
|
<span class="scs-bar scs-heading" style="width: 46%"></span>
|
|
<div class="scs-minis">
|
|
<div class="scs-mini">
|
|
<span class="scs-bar"></span>
|
|
<span class="scs-mini-block"></span>
|
|
</div>
|
|
<div class="scs-mini">
|
|
<span class="scs-bar"></span>
|
|
<span class="scs-mini-block"></span>
|
|
</div>
|
|
<div class="scs-mini">
|
|
<span class="scs-bar"></span>
|
|
<span class="scs-mini-block"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="scs-section" aria-hidden="true">
|
|
<div class="scs-card">
|
|
<div class="scs-chiprow">
|
|
<span class="scs-chip">03</span>
|
|
<span class="scs-chiprule"></span>
|
|
</div>
|
|
<span class="scs-bar scs-heading" style="width: 40%"></span>
|
|
<div class="scs-rowline">
|
|
<span class="scs-dot"></span>
|
|
<span class="scs-bar"></span>
|
|
</div>
|
|
<div class="scs-rowline">
|
|
<span class="scs-dot"></span>
|
|
<span class="scs-bar" style="max-width: 58%"></span>
|
|
</div>
|
|
<div class="scs-rowline">
|
|
<span class="scs-dot"></span>
|
|
<span class="scs-bar" style="max-width: 66%"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="scs-section" data-close aria-hidden="true">
|
|
<div class="scs-card">
|
|
<div class="scs-chiprow" style="align-self: stretch">
|
|
<span class="scs-chip">04</span>
|
|
<span class="scs-chiprule"></span>
|
|
</div>
|
|
<span class="scs-bar scs-heading"></span>
|
|
<span class="scs-bar scs-sub"></span>
|
|
<span class="scs-pill">>_</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="scs-layer scs-fore" aria-hidden="true">
|
|
<span class="scs-mote"></span>
|
|
<span class="scs-mote"></span>
|
|
<span class="scs-mote"></span>
|
|
<span class="scs-mote"></span>
|
|
<span class="scs-mote"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
var root = document.getElementById("root");
|
|
var stage = root.querySelector(".scs-stage");
|
|
var world = root.querySelector(".scs-world");
|
|
var layerFar = root.querySelector(".scs-far");
|
|
var layerMid = root.querySelector(".scs-mid");
|
|
var layerFore = root.querySelector(".scs-fore");
|
|
var sectionElements = Array.prototype.slice.call(root.querySelectorAll(".scs-section"));
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
function num(value, fallback, min, max) {
|
|
var parsed = parseFloat(value);
|
|
if (!isFinite(parsed)) parsed = fallback;
|
|
return Math.min(max, Math.max(min, parsed));
|
|
}
|
|
|
|
var travel = num(vars.travel, 220, 100, 400);
|
|
var sectionsVar = Math.round(num(vars.sections, 3, 2, 4));
|
|
// Each enum choice routes to a DIFFERENT contract token so the
|
|
// variable stays meaningful under a theme.
|
|
var accentColors = {
|
|
green: "var(--brand, #71f5a7)",
|
|
blue: "var(--accent, #61a8ff)",
|
|
violet: "var(--accent-2, #c5a3ff)",
|
|
};
|
|
var accent = Object.prototype.hasOwnProperty.call(accentColors, vars.accent)
|
|
? vars.accent
|
|
: "green";
|
|
var exitMode = vars.exit === "fade" || vars.exit === "up" ? vars.exit : "none";
|
|
|
|
root.style.setProperty("--scs-accent", accentColors[accent]);
|
|
|
|
// SLOT. Caller templates live at HOST DOCUMENT level (the mount
|
|
// wipes host-clip children, and templates never render). Each
|
|
// direct child of the slot template becomes one section's card
|
|
// content, in order.
|
|
var hostDoc = root.ownerDocument;
|
|
var slotChildren = [];
|
|
try {
|
|
var slotTemplate = hostDoc.querySelector(
|
|
'template[data-slot="scroll-camera-story-sections"]',
|
|
);
|
|
if (slotTemplate)
|
|
slotChildren = Array.prototype.slice.call(slotTemplate.content.children);
|
|
} catch (error) {
|
|
slotChildren = [];
|
|
}
|
|
|
|
var count = Math.min(4, Math.max(2, slotChildren.length || sectionsVar));
|
|
sectionElements.forEach(function (section, index) {
|
|
if (index >= count) {
|
|
section.remove();
|
|
return;
|
|
}
|
|
if (slotChildren[index]) {
|
|
var card = section.querySelector(".scs-card");
|
|
while (card.firstChild) card.removeChild(card.firstChild);
|
|
card.appendChild(hostDoc.importNode(slotChildren[index], true));
|
|
}
|
|
});
|
|
var sections = sectionElements.slice(0, count);
|
|
var cards = sections.map(function (section) {
|
|
return section.querySelector(".scs-card");
|
|
});
|
|
|
|
// World geometry, set ONCE at mount in cqh (static style, never
|
|
// tweened; the seek trap is cq units INSIDE tweens). Section i
|
|
// centers at camera progress i / (count - 1) along the travel.
|
|
world.style.height = (100 + travel).toFixed(2) + "cqh";
|
|
sections.forEach(function (section, index) {
|
|
var progress = index / (count - 1);
|
|
section.style.top = (50 + progress * travel - 42).toFixed(2) + "cqh";
|
|
});
|
|
|
|
/* ===== Camera (camera-servo law): one plain state object, one
|
|
writer. cam.t is the pass progress 0..1. The world translates
|
|
by percent of its OWN height (a pure number: travel out of
|
|
100 + travel), and each depth layer gets a derived parallax
|
|
offset so its net rate is RATE x the camera rate. No cq units
|
|
are ever tweened. ===== */
|
|
var F = (100 * travel) / (100 + travel); // percent of world height per full pass
|
|
var RATE_FAR = 0.35;
|
|
var RATE_MID = 0.65;
|
|
var RATE_FORE = 1.12;
|
|
var cam = { t: 0 };
|
|
var drift = { p: 0, dx: 0, dy: 0 };
|
|
function applyCamera() {
|
|
var y = -cam.t * F;
|
|
world.style.transform = "translate(" + drift.dx + "%, " + (y + drift.dy) + "%)";
|
|
layerFar.style.transform = "translateY(" + cam.t * F * (1 - RATE_FAR) + "%)";
|
|
layerMid.style.transform = "translateY(" + cam.t * F * (1 - RATE_MID) + "%)";
|
|
layerFore.style.transform = "translateY(" + cam.t * F * (1 - RATE_FORE) + "%)";
|
|
}
|
|
applyCamera();
|
|
|
|
// Envelope: fixed IN/OUT, elastic HOLD, never time-scaled.
|
|
var IN_BASE = 0.85;
|
|
var OUT_BASE = exitMode === "none" ? 0 : 0.5;
|
|
var PASS_MIN = 1.2;
|
|
var duration = Math.max(0.001, parseFloat(root.dataset.duration || "5.5"));
|
|
var totalBase = IN_BASE + PASS_MIN + OUT_BASE;
|
|
var scale = duration < totalBase ? duration / totalBase : 1;
|
|
var IN = IN_BASE * scale;
|
|
var OUT = OUT_BASE * scale;
|
|
var usable = duration - OUT;
|
|
|
|
// Arrival schedule: defaults decelerate into a held final
|
|
// section; the cues variable overrides arrivals for sections
|
|
// after the first.
|
|
var HOLD_MIN = Math.min(1.3, Math.max(0.45, usable * 0.24));
|
|
var lastDefault = Math.max(IN + 0.9 * scale, usable - HOLD_MIN);
|
|
var firstDefault = Math.min(lastDefault, IN + 1.15 * scale);
|
|
var arrivals = [];
|
|
var index;
|
|
for (index = 1; index < count; index += 1) {
|
|
arrivals.push(
|
|
count === 2
|
|
? lastDefault
|
|
: firstDefault + ((index - 1) / (count - 2)) * (lastDefault - firstDefault),
|
|
);
|
|
}
|
|
var cueValues = String(vars.cues == null ? "" : vars.cues)
|
|
.split(",")
|
|
.map(function (part) {
|
|
return parseFloat(part);
|
|
})
|
|
.filter(function (value) {
|
|
return isFinite(value);
|
|
});
|
|
// Lenient by one: a list with an extra leading value is treated
|
|
// as including the mount section's arrival.
|
|
if (cueValues.length === count) cueValues = cueValues.slice(1);
|
|
if (cueValues.length >= count - 1) {
|
|
arrivals = cueValues.slice(0, count - 1);
|
|
}
|
|
var floor = IN + 0.35 * scale;
|
|
for (index = 0; index < arrivals.length; index += 1) {
|
|
var clamped = Math.min(usable - 0.3 * scale, Math.max(floor, arrivals[index]));
|
|
arrivals[index] = clamped;
|
|
floor = clamped + 0.4 * scale;
|
|
}
|
|
var lastArrival = arrivals.length > 0 ? arrivals[arrivals.length - 1] : IN;
|
|
|
|
var tl = gsap.timeline({ paused: true });
|
|
|
|
// IN: the stage fades up while the first section rises.
|
|
tl.fromTo(
|
|
stage,
|
|
{ opacity: 0 },
|
|
{ opacity: 1, duration: Math.min(0.6 * scale, IN), ease: "power2.out" },
|
|
0,
|
|
);
|
|
|
|
// Section rises: each card lands exactly on its arrival cue.
|
|
// yPercent only (percent of the card's own box), never cq units.
|
|
cards.forEach(function (card, cardIndex) {
|
|
var arrive = cardIndex === 0 ? IN : arrivals[cardIndex - 1];
|
|
var rise = Math.min(
|
|
0.75 * scale,
|
|
Math.max(0.25, arrive - (cardIndex === 0 ? 0.1 : 0)),
|
|
);
|
|
tl.fromTo(
|
|
card,
|
|
{ opacity: 0, yPercent: 10 },
|
|
{ opacity: 1, yPercent: 0, duration: rise, ease: "power3.out" },
|
|
arrive - rise,
|
|
);
|
|
});
|
|
|
|
// Camera pass: one non-overlapping segment per arrival, quiet
|
|
// register (L2). Each move ends exactly on its cue; the final
|
|
// move runs longer, so the pass decelerates into the hold. No
|
|
// segment starts before the previous ends (L1: no mid-motion
|
|
// redirect exists to snap velocity).
|
|
var previousEnd = IN * 0.7;
|
|
arrivals.forEach(function (arrive, arriveIndex) {
|
|
var isLast = arriveIndex === arrivals.length - 1;
|
|
var gap = arrive - previousEnd - 0.1 * scale;
|
|
var move = Math.max(0.3, Math.min(isLast ? 1.7 : 1.25, gap));
|
|
tl.to(
|
|
cam,
|
|
{
|
|
t: (arriveIndex + 1) / (count - 1),
|
|
duration: move,
|
|
ease: "power2.inOut",
|
|
onUpdate: applyCamera,
|
|
},
|
|
arrive - move,
|
|
);
|
|
previousEnd = arrive;
|
|
});
|
|
|
|
// Micro-drift: 2 and 3 INTEGER sine cycles ending at exactly
|
|
// zero when the final section lands, so the held final section
|
|
// is byte-still and every seek reproduces the same frame.
|
|
if (lastArrival >= 1.2) {
|
|
tl.to(
|
|
drift,
|
|
{
|
|
p: Math.PI * 2 * 2,
|
|
duration: lastArrival,
|
|
ease: "none",
|
|
onUpdate: function () {
|
|
drift.dx = Math.sin(drift.p) * 0.06;
|
|
drift.dy = Math.sin(drift.p * 1.5) * 0.08;
|
|
applyCamera();
|
|
},
|
|
},
|
|
0,
|
|
);
|
|
}
|
|
|
|
// OUT: only when exit != none; the default holds the last frame.
|
|
if (exitMode !== "none") {
|
|
var outStart = duration - OUT;
|
|
tl.to(stage, { opacity: 0, duration: OUT, ease: "power2.in" }, outStart);
|
|
if (exitMode === "up") {
|
|
tl.to(stage, { yPercent: -4, duration: OUT, ease: "power2.in" }, outStart);
|
|
}
|
|
}
|
|
|
|
tl.seek(0);
|
|
window.__timelines = window.__timelines || {};
|
|
window.__timelines["scroll-camera-story"] = tl;
|
|
})();
|
|
</script>
|
|
</div>
|
|
</template>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="install">
|
|
|
|
<InstallCommand command="npx hyperframes add scroll-camera-story" item="scroll-camera-story" />
|
|
|
|
That writes one file: `compositions/components/scroll-camera-story.html`.
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="docs">
|
|
|
|
## Paste it into your composition
|
|
|
|
Open `compositions/components/scroll-camera-story.html` and copy what is inside into your own composition.
|
|
|
|
A component has no size or duration of its own. It takes both from the composition
|
|
you paste it into.
|
|
|
|
## Variables
|
|
|
|
Every one of these has a default, so the piece works untouched. Set the ones you
|
|
want to change on the element:
|
|
|
|
| Variable | Default | Accepts | What it does |
|
|
| --- | --- | --- | --- |
|
|
| `sections` | `3` | 2 to 4, step 1 | How many skeleton sections ride the pass. A sections slot overrides this with its own child count. |
|
|
| `travel` | `220` | 100cqh to 400cqh, step 10cqh | Total camera travel in cqh. The world is 100 + travel cqh tall. |
|
|
| `cues` | `` | string | Comma-separated seconds: arrival times for the sections after the first. Empty keeps the authored default rhythm. |
|
|
| `accent` | `green` | `green`, `blue`, `violet` | Token the skeleton accents and foreground motes ride. |
|
|
| `exit` | `none` | `none`, `fade`, `up` | Optional departure. None holds the final section. |
|
|
|
|
Set them with `data-variable-values` on the element that mounts it. These are the
|
|
defaults, so this behaves exactly like the preview above until you change one:
|
|
|
|
```html wrap
|
|
<div
|
|
data-composition-id="scroll-camera-story"
|
|
data-composition-src="compositions/components/scroll-camera-story.html"
|
|
data-variable-values='{"sections":3,"travel":220,"cues":"","accent":"green","exit":"none"}'
|
|
></div>
|
|
```
|
|
|
|
{/* hf:generated-footer */}
|
|
|
|
Tagged `camera` `scroll` `parallax` `story` `sections` `slot` `servo`.
|
|
|
|
## Related topics
|
|
|
|
- [Browse the complete Catalog](/catalog)
|
|
- [Add assets and Catalog items in Studio](/studio/assets-and-blocks)
|
|
- [Build a richer composition](/go-further)
|
|
|
|
</CatalogSlot>
|
|
|
|
</CatalogDetail>
|