mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-03 20:37:30 +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
600 lines
27 KiB
Plaintext
600 lines
27 KiB
Plaintext
---
|
|
title: "Soft Blob Touch"
|
|
description: "A granular soft blob idles with slow internal drift; a scripted touch dot decel-arrives, the blob deforms toward it with an attraction bulge, then recovers with a velocity-preserving spring. No hard edges anywhere."
|
|
mode: "frame"
|
|
---
|
|
|
|
import { CatalogDetail, CatalogSlot } from "/snippets/catalog-detail.jsx";
|
|
import { InstallCommand } from "/snippets/install-command.jsx";
|
|
|
|
<CatalogDetail
|
|
previewSrc="/public/catalog/components/soft-blob-touch.json"
|
|
compositionId="soft-blob-touch"
|
|
compositionSrc="compositions/components/soft-blob-touch.html"
|
|
title="Soft Blob Touch"
|
|
description="A granular soft blob idles with slow internal drift; a scripted touch dot decel-arrives, the blob deforms toward it with an attraction bulge, then recovers with a velocity-preserving spring. No hard edges anywhere."
|
|
variables={[{"id":"touch_x","type":"number","role":"layout","label":"Touch X","description":"Touch point, percent of host width.","default":66,"min":8,"max":92,"step":1,"unit":"%"},{"id":"touch_y","type":"number","role":"layout","label":"Touch Y","description":"Touch point, percent of host height.","default":38,"min":8,"max":92,"step":1,"unit":"%"},{"id":"touch_at","type":"number","role":"timing","label":"Touch at","description":"Seconds from mount start when the dot makes contact.","default":1.6,"min":0.9,"max":10,"step":0.1,"unit":"s"},{"id":"grain","type":"enum","role":"style","label":"Grain","description":"Speck register for the granular body.","default":"fine","options":[{"value":"fine","label":"Fine"},{"value":"coarse","label":"Coarse"}]},{"id":"accent","type":"enum","role":"style","label":"Accent","description":"Body tint: green rides --brand, blue rides --accent, violet rides --accent-2.","default":"green","options":[{"value":"green","label":"Green"},{"value":"blue","label":"Blue"},{"value":"violet","label":"Violet"}]},{"id":"exit","type":"enum","role":"timing","label":"Exit","description":"Optional departure. Default none: the settled blob holds until the frame cuts.","default":"none","options":[{"value":"none","label":"None"},{"value":"fade","label":"Fade"},{"value":"up","label":"Up"}]}]}
|
|
meta={{"category":"Product Demo","badge":"Stable","codeLines":515}}
|
|
attribution={{"path":"registry/components/soft-blob-touch","tags":["motion-primitive","product-demo","material","blob","touch","grain"]}}
|
|
hasCode
|
|
rawUrl="https://raw.githubusercontent.com/heygen-com/hyperframes/main/registry/components/soft-blob-touch/soft-blob-touch.html"
|
|
>
|
|
|
|
<CatalogSlot slot="code">
|
|
|
|
```html soft-blob-touch.html
|
|
<!doctype html>
|
|
<!--
|
|
soft-blob-touch: HyperFrames video primitive (product demo / material)
|
|
|
|
A granular soft blob idles with slow internal drift; a scripted touch dot
|
|
decel-arrives at a caller-positioned point; the blob deforms toward it
|
|
(an attraction bulge with mass), then recovers with an interruptible
|
|
spring once the dot retreats. The AI-orb material beat. Softness is the
|
|
whole point: the body is layered radial gradients plus a seeded grain
|
|
field, and nothing in the frame has a hard edge.
|
|
|
|
Reference: alexwidua 1702356241186476225 sheet-02 (granular blob leaning
|
|
toward a finger; fuzzy boundary, mass, recovery wobble).
|
|
|
|
Variables (declared in data-composition-variables below):
|
|
- touch_x, touch_y (numbers, percent of host box): where the dot lands.
|
|
- touch_at (seconds): when the dot makes contact. Clamped so the whole
|
|
deform and recover tail stays inside the clip.
|
|
- grain ("fine" | "coarse"): speck count and size for the body.
|
|
- accent ("green" | "blue" | "violet"): green rides --brand, blue rides
|
|
--accent, violet rides --accent-2.
|
|
- exit ("none" | "fade" | "up"): default none, the settled blob holds.
|
|
|
|
Envelope, fixed IN and OUT with elastic HOLD only (never timeScale):
|
|
IN ends when the recovery spring settles (touch_at + 1.57s); HOLD is
|
|
dead still (drift completes integer sine cycles and ends at exactly
|
|
zero by then); OUT = 0.45s only when exit is not none.
|
|
|
|
Deformation model (law L1, interruptible spring):
|
|
Two plain-object params (bulge, lean) feed ONE onUpdate painter. The
|
|
attack tween is the first 75 percent of a power2.out lean-in, cut
|
|
mid-flight when the dot lifts (analytic cut: the junction value AND
|
|
velocity are computed in closed form). The recovery tween's ease is a
|
|
closed-form underdamped spring whose initial velocity equals the cut
|
|
velocity, so the redirect preserves momentum exactly. Both tweens have
|
|
explicit endpoints; any seek order lands identical values.
|
|
|
|
Determinism (canvas 2D law, per particle-image-reveal):
|
|
One grain table is computed exactly once at build from fixed LCG seed
|
|
0x50f7b10b. Every painted frame is a pure function of (table, params,
|
|
timeline time). onUpdate clears and redraws from scratch; no
|
|
Math.random, no wall clock, no incremental state. Eventful seeks
|
|
(suppressEvents false) repaint identically in any order.
|
|
-->
|
|
<html
|
|
lang="en"
|
|
data-composition-id="soft-blob-touch"
|
|
data-composition-duration="4"
|
|
data-composition-variables='[
|
|
{ "id": "touch_x", "type": "number", "role": "layout", "label": "Touch X", "description": "Touch point, percent of host width.", "default": 66, "min": 8, "max": 92, "step": 1, "unit": "%" },
|
|
{ "id": "touch_y", "type": "number", "role": "layout", "label": "Touch Y", "description": "Touch point, percent of host height.", "default": 38, "min": 8, "max": 92, "step": 1, "unit": "%" },
|
|
{ "id": "touch_at", "type": "number", "role": "timing", "label": "Touch at", "description": "Seconds from mount start when the dot makes contact.", "default": 1.6, "min": 0.9, "max": 10, "step": 0.1, "unit": "s" },
|
|
{ "id": "grain", "type": "enum", "role": "style", "label": "Grain", "description": "Speck register for the granular body.", "default": "fine", "options": [{ "value": "fine", "label": "Fine" }, { "value": "coarse", "label": "Coarse" }] },
|
|
{ "id": "accent", "type": "enum", "role": "style", "label": "Accent", "description": "Body tint: green rides --brand, blue rides --accent, violet rides --accent-2.", "default": "green", "options": [{ "value": "green", "label": "Green" }, { "value": "blue", "label": "Blue" }, { "value": "violet", "label": "Violet" }] },
|
|
{ "id": "exit", "type": "enum", "role": "timing", "label": "Exit", "description": "Optional departure. Default none: the settled blob holds until the frame cuts.", "default": "none", "options": [{ "value": "none", "label": "None" }, { "value": "fade", "label": "Fade" }, { "value": "up", "label": "Up" }] }
|
|
]'
|
|
>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Soft Blob Touch</title>
|
|
</head>
|
|
<body>
|
|
<template>
|
|
<div id="root" data-composition-id="soft-blob-touch" data-duration="4" 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, "Inter", system-ui, sans-serif);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.sbt-clip {
|
|
position: absolute;
|
|
inset: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.sbt-stage {
|
|
position: absolute;
|
|
inset: 0;
|
|
will-change: transform, opacity;
|
|
}
|
|
|
|
.sbt-canvas {
|
|
position: absolute;
|
|
inset: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
/* The touch dot: a soft disc with a gradient falloff, no hard rim.
|
|
Motion rides transforms only (px), never left or top. */
|
|
.sbt-touch {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
width: 4.6cqmin;
|
|
height: 4.6cqmin;
|
|
margin-left: -2.3cqmin;
|
|
margin-top: -2.3cqmin;
|
|
border-radius: 50%;
|
|
background: radial-gradient(
|
|
circle at 42% 38%,
|
|
color-mix(in srgb, var(--fg, #f8fafc) 96%, transparent) 0%,
|
|
color-mix(in srgb, var(--fg, #f8fafc) 78%, transparent) 34%,
|
|
color-mix(in srgb, var(--fg, #f8fafc) 26%, transparent) 62%,
|
|
transparent 78%
|
|
);
|
|
will-change: transform, opacity;
|
|
}
|
|
</style>
|
|
|
|
<div
|
|
id="soft-blob-touch-clip"
|
|
class="sbt-clip clip"
|
|
data-start="0"
|
|
data-duration="4"
|
|
data-track-index="0"
|
|
>
|
|
<div class="sbt-stage">
|
|
<canvas class="sbt-canvas" aria-hidden="true"></canvas>
|
|
<div class="sbt-touch" aria-hidden="true"></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(".sbt-stage");
|
|
var canvas = root.querySelector(".sbt-canvas");
|
|
var touchDot = root.querySelector(".sbt-touch");
|
|
var vars =
|
|
window.__hyperframes && window.__hyperframes.getVariables
|
|
? window.__hyperframes.getVariables()
|
|
: {};
|
|
|
|
function num(value, fallback, min, max) {
|
|
var n = Number(value);
|
|
if (!isFinite(n)) n = fallback;
|
|
return Math.max(min, Math.min(max, n));
|
|
}
|
|
|
|
var grain = vars.grain === "coarse" ? "coarse" : "fine";
|
|
var exit = vars.exit === "fade" || vars.exit === "up" ? vars.exit : "none";
|
|
// 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";
|
|
// The bundler mirrors composition variables as scoped CSS custom
|
|
// props, so this unit's own accent variable shadows the contract
|
|
// --accent token inside the subtree ("blue" is a valid CSS color
|
|
// and would render pure blue). When the shadow is present, fall
|
|
// back to the literal contract value instead of var(--accent).
|
|
var computedAccent = getComputedStyle(root).getPropertyValue("--accent").trim();
|
|
if (
|
|
computedAccent === "green" ||
|
|
computedAccent === "blue" ||
|
|
computedAccent === "violet"
|
|
) {
|
|
accentColors.blue = "#61a8ff";
|
|
}
|
|
|
|
// Envelope. The deform tail is ATTACK + RECOVER after contact;
|
|
// clamp touch_at so the spring settles inside the clip.
|
|
var ATTACK_NAT = 0.55; // natural length of the uncut lean-in
|
|
var CUT_FRAC = 0.75; // the dot lifts at 75 percent of it
|
|
var ATTACK = ATTACK_NAT * CUT_FRAC;
|
|
var RECOVER = 1.15;
|
|
var duration = Math.max(0.001, parseFloat(root.dataset.duration || "4"));
|
|
var OUT = exit === "none" ? 0 : 0.45;
|
|
var maxTouch = Math.max(0.9, duration - (ATTACK + RECOVER) - OUT - 0.05);
|
|
var touchAt = num(vars.touch_at, 1.6, 0.9, maxTouch);
|
|
var cutAt = touchAt + ATTACK;
|
|
var IN_END = cutAt + RECOVER;
|
|
var OUT_START = IN_END + Math.max(0, duration - IN_END - OUT);
|
|
|
|
// Canvas raster basis is fixed once at mount (elastic root: the
|
|
// host box decides the resolution; same host, same raster).
|
|
var dpr = Math.min(2, Math.max(1, Number(window.devicePixelRatio) || 1));
|
|
var box = root.getBoundingClientRect();
|
|
var cssW = Math.max(1, Math.round(box.width) || 640);
|
|
var cssH = Math.max(1, Math.round(box.height) || 360);
|
|
canvas.width = Math.round(cssW * dpr);
|
|
canvas.height = Math.round(cssH * dpr);
|
|
var ctx = canvas.getContext("2d");
|
|
var W = canvas.width;
|
|
var H = canvas.height;
|
|
var minDim = Math.min(W, H);
|
|
|
|
var touchX = (num(vars.touch_x, 66, 8, 92) / 100) * W;
|
|
var touchY = (num(vars.touch_y, 38, 8, 92) / 100) * H;
|
|
var centerX = W * 0.5;
|
|
var centerY = H * 0.5;
|
|
var R = minDim * 0.26;
|
|
|
|
// Direction of attraction, guarded for a touch at dead center.
|
|
var dxT = touchX - centerX;
|
|
var dyT = touchY - centerY;
|
|
var distT = Math.hypot(dxT, dyT);
|
|
var dirX = distT > 1 ? dxT / distT : 0.7071;
|
|
var dirY = distT > 1 ? dyT / distT : -0.7071;
|
|
|
|
// Resolve accent and fg to concrete rgb once at mount so canvas
|
|
// fills never depend on style recalc during seeks. Mixing happens
|
|
// numerically here (computed color-mix strings are not parseable
|
|
// across engines).
|
|
function probeColor(cssColor, fallback) {
|
|
var probe = root.ownerDocument.createElement("span");
|
|
probe.style.color = cssColor;
|
|
root.appendChild(probe);
|
|
var out = getComputedStyle(probe).color || fallback;
|
|
probe.remove();
|
|
var m = out.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/);
|
|
if (!m) {
|
|
m = fallback.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/);
|
|
}
|
|
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : [113, 245, 167];
|
|
}
|
|
var accentRgb = probeColor(accentColors[accent], "rgb(113, 245, 167)");
|
|
var fgRgb = probeColor("var(--fg, #f8fafc)", "rgb(248, 250, 252)");
|
|
function mix(a, b, t) {
|
|
return [
|
|
Math.round(a[0] + (b[0] - a[0]) * t),
|
|
Math.round(a[1] + (b[1] - a[1]) * t),
|
|
Math.round(a[2] + (b[2] - a[2]) * t),
|
|
];
|
|
}
|
|
function rgba(c, a) {
|
|
return "rgba(" + c[0] + "," + c[1] + "," + c[2] + "," + a + ")";
|
|
}
|
|
var bodyRgb = mix(accentRgb, fgRgb, 0.18);
|
|
var softRgb = mix(accentRgb, fgRgb, 0.55);
|
|
|
|
// The grain table: computed exactly once, then only read.
|
|
var counts = { fine: 1500, coarse: 760 };
|
|
var sizes = { fine: 0.0055, coarse: 0.0102 };
|
|
var COUNT = counts[grain];
|
|
var SPECK = sizes[grain] * minDim;
|
|
var grains = (function () {
|
|
var state = 0x50f7b10b;
|
|
function next() {
|
|
state = (Math.imul(1664525, state) + 1013904223) >>> 0;
|
|
return state / 4294967296;
|
|
}
|
|
var rows = [];
|
|
for (var i = 0; i < COUNT; i += 1) {
|
|
// Radial distribution with a fuzzy tail past R: density thins
|
|
// toward the boundary and alpha fades it out, so the edge is
|
|
// granular vapor, never a line.
|
|
var rr = Math.pow(next(), 0.55) * R * 1.16;
|
|
var th = next() * Math.PI * 2;
|
|
var edge = Math.max(0, Math.min(1, (1.16 - rr / R) / 0.42));
|
|
rows.push({
|
|
x: Math.cos(th) * rr,
|
|
y: Math.sin(th) * rr * 0.94,
|
|
size: SPECK * (0.5 + 0.9 * next()),
|
|
dim: (0.3 + 0.7 * next()) * edge,
|
|
tone: next(),
|
|
driftAmp: (0.008 + 0.014 * next()) * minDim,
|
|
driftCycles: next() < 0.5 ? 1 : 2,
|
|
phaseX: next() * Math.PI * 2,
|
|
phaseY: next() * Math.PI * 2,
|
|
});
|
|
}
|
|
return rows;
|
|
})();
|
|
|
|
function clamp01(v) {
|
|
return v < 0 ? 0 : v > 1 ? 1 : v;
|
|
}
|
|
|
|
// Deformation params. Attack lifts both toward CUT value; the
|
|
// recovery springs them home. The painter owns all amplitudes.
|
|
var P = { bulge: 0, lean: 0 };
|
|
var bCut = 1 - Math.pow(1 - CUT_FRAC, 2); // power2.out at the cut
|
|
var vCut = (2 * (1 - CUT_FRAC)) / ATTACK_NAT; // slope there, per s
|
|
var attackEase = function (p) {
|
|
return (1 - Math.pow(1 - p * CUT_FRAC, 2)) / bCut;
|
|
};
|
|
// Closed-form underdamped spring x(s), x(0) = 1, x'(0) = vCut/bCut
|
|
// (velocity preserved across the cut), corrected by a linear ramp
|
|
// so x(RECOVER) is exactly zero. Higher frequency for the local
|
|
// bulge, lower for the whole-mass lean: the surface snaps back
|
|
// faster than the body.
|
|
function springEase(lambda, omega) {
|
|
var v0 = vCut / bCut;
|
|
var c2 = (v0 + lambda) / omega;
|
|
function x(s) {
|
|
return Math.exp(-lambda * s) * (Math.cos(omega * s) + c2 * Math.sin(omega * s));
|
|
}
|
|
var xEnd = x(RECOVER);
|
|
return function (p) {
|
|
var s = p * RECOVER;
|
|
return 1 - (x(s) - (s / RECOVER) * xEnd);
|
|
};
|
|
}
|
|
var bulgeSpring = springEase(4.2, Math.PI * 2 * 2.2);
|
|
var leanSpring = springEase(3.6, Math.PI * 2 * 1.5);
|
|
|
|
// Pure repaint: clear, then rebuild the whole frame from
|
|
// (grain table, P, t). Drift phase u completes integer sine
|
|
// cycles over [0, IN_END] and is exactly zero from IN_END on,
|
|
// so the HOLD frame is dead still.
|
|
var sigma = R * 0.85;
|
|
var bulgeAmp = R * 0.62;
|
|
var leanAmp = minDim * 0.045;
|
|
function paint(t) {
|
|
ctx.clearRect(0, 0, W, H);
|
|
var u = clamp01(t / IN_END);
|
|
var lx = leanAmp * P.lean * dirX;
|
|
var ly = leanAmp * P.lean * dirY;
|
|
var cx = centerX + lx;
|
|
var cy = centerY + ly;
|
|
|
|
// Layered radial gradients: wide aura, mid glow, dense core,
|
|
// and a bulge lobe that swells toward the touch point.
|
|
var aura = ctx.createRadialGradient(cx, cy, 0, cx, cy, R * 1.9);
|
|
aura.addColorStop(0, rgba(accentRgb, 0.16));
|
|
aura.addColorStop(0.55, rgba(accentRgb, 0.06));
|
|
aura.addColorStop(1, rgba(accentRgb, 0));
|
|
ctx.fillStyle = aura;
|
|
ctx.fillRect(0, 0, W, H);
|
|
|
|
var mid = ctx.createRadialGradient(cx, cy, 0, cx, cy, R * 1.12);
|
|
mid.addColorStop(0, rgba(bodyRgb, 0.34));
|
|
mid.addColorStop(0.62, rgba(bodyRgb, 0.16));
|
|
mid.addColorStop(1, rgba(bodyRgb, 0));
|
|
ctx.fillStyle = mid;
|
|
ctx.fillRect(0, 0, W, H);
|
|
|
|
var core = ctx.createRadialGradient(
|
|
cx - R * 0.12,
|
|
cy - R * 0.14,
|
|
0,
|
|
cx,
|
|
cy,
|
|
R * 0.62,
|
|
);
|
|
core.addColorStop(0, rgba(softRgb, 0.4));
|
|
core.addColorStop(1, rgba(softRgb, 0));
|
|
ctx.fillStyle = core;
|
|
ctx.fillRect(0, 0, W, H);
|
|
|
|
if (P.bulge > 0.001) {
|
|
var lobeX = cx + dirX * R * 0.72;
|
|
var lobeY = cy + dirY * R * 0.72;
|
|
var lobeR = R * (0.22 + 0.5 * P.bulge);
|
|
var lobe = ctx.createRadialGradient(lobeX, lobeY, 0, lobeX, lobeY, lobeR);
|
|
lobe.addColorStop(0, rgba(softRgb, 0.34 * P.bulge));
|
|
lobe.addColorStop(1, rgba(softRgb, 0));
|
|
ctx.fillStyle = lobe;
|
|
ctx.fillRect(0, 0, W, H);
|
|
}
|
|
|
|
// Grain field. Each speck drifts on its own integer-cycle sine
|
|
// (zero at u = 0 and u = 1) and is attracted toward the touch
|
|
// point with an exponential falloff: the material near the dot
|
|
// reaches for it, the far side barely stirs.
|
|
var TAU = Math.PI * 2;
|
|
for (var i = 0; i < grains.length; i += 1) {
|
|
var g = grains[i];
|
|
var driftX =
|
|
g.driftAmp * (Math.sin(TAU * g.driftCycles * u + g.phaseX) - Math.sin(g.phaseX));
|
|
var driftY =
|
|
g.driftAmp * (Math.sin(TAU * g.driftCycles * u + g.phaseY) - Math.sin(g.phaseY));
|
|
var gx = cx + g.x + driftX;
|
|
var gy = cy + g.y + driftY;
|
|
if (P.bulge > 0.001) {
|
|
var tx = touchX - gx;
|
|
var ty = touchY - gy;
|
|
var td = Math.hypot(tx, ty);
|
|
if (td > 0.5) {
|
|
var w = Math.exp(-td / sigma);
|
|
var pull = (bulgeAmp * P.bulge * w) / td;
|
|
gx += tx * pull;
|
|
gy += ty * pull;
|
|
}
|
|
}
|
|
var c = g.tone < 0.62 ? softRgb : fgRgb;
|
|
ctx.globalAlpha = g.dim * 0.85;
|
|
ctx.fillStyle = rgba(c, 1);
|
|
ctx.beginPath();
|
|
ctx.arc(gx, gy, g.size, 0, TAU);
|
|
ctx.fill();
|
|
}
|
|
ctx.globalAlpha = 1;
|
|
}
|
|
|
|
// Touch dot choreography, transforms only, px space of the host
|
|
// box (canvas coordinates divided by dpr).
|
|
var stageW = cssW;
|
|
var stageH = cssH;
|
|
var dotX = touchX / dpr;
|
|
var dotY = touchY / dpr;
|
|
// Enter and leave along the attraction axis, from off stage.
|
|
var away = Math.hypot(stageW, stageH) * 0.7;
|
|
var offX = dotX + dirX * away;
|
|
var offY = dotY + dirY * away;
|
|
|
|
gsap.set(stage, { opacity: 1, y: "0cqh" });
|
|
gsap.set(touchDot, { x: offX, y: offY, opacity: 0 });
|
|
|
|
var tl = gsap.timeline({
|
|
paused: true,
|
|
onUpdate: function () {
|
|
paint(tl.time());
|
|
},
|
|
});
|
|
|
|
// Anchor tween: spans the full authored duration so seeks into
|
|
// the hold keep tl.time() honest and onUpdate (the canvas
|
|
// repaint) fires for every eventful seek anywhere in [0, D].
|
|
tl.to({ p: 0 }, { p: 1, duration: duration, ease: "none" }, 0);
|
|
|
|
// The dot decel-arrives (power3.out: it arrives, it never
|
|
// passes through), dwells for the press, then accelerates away.
|
|
var arriveStart = Math.max(0, touchAt - 0.85);
|
|
tl.fromTo(
|
|
touchDot,
|
|
{ x: offX, y: offY, opacity: 0 },
|
|
{
|
|
x: dotX,
|
|
y: dotY,
|
|
opacity: 1,
|
|
duration: touchAt - arriveStart,
|
|
ease: "power3.out",
|
|
},
|
|
arriveStart,
|
|
);
|
|
tl.fromTo(
|
|
touchDot,
|
|
{ x: dotX, y: dotY, opacity: 1 },
|
|
{
|
|
x: offX,
|
|
y: offY,
|
|
opacity: 0,
|
|
duration: 0.55,
|
|
ease: "power2.in",
|
|
immediateRender: false,
|
|
},
|
|
cutAt,
|
|
);
|
|
|
|
// Attack: the truncated lean-in, cut mid-flight at the dot lift.
|
|
tl.fromTo(
|
|
P,
|
|
{ bulge: 0, lean: 0 },
|
|
{ bulge: bCut, lean: bCut, duration: ATTACK, ease: attackEase },
|
|
touchAt,
|
|
);
|
|
// Recovery: velocity-matched closed-form springs back to rest.
|
|
tl.fromTo(
|
|
P,
|
|
{ bulge: bCut },
|
|
{
|
|
bulge: 0,
|
|
duration: RECOVER,
|
|
ease: bulgeSpring,
|
|
immediateRender: false,
|
|
},
|
|
cutAt,
|
|
);
|
|
tl.fromTo(
|
|
P,
|
|
{ lean: bCut },
|
|
{
|
|
lean: 0,
|
|
duration: RECOVER,
|
|
ease: leanSpring,
|
|
immediateRender: false,
|
|
},
|
|
cutAt,
|
|
);
|
|
|
|
// HOLD: truly still. Drift is zero past IN_END by construction
|
|
// and both params are home, so every hold frame is identical.
|
|
|
|
// OUT: optional departure; exit none holds until the frame cuts.
|
|
if (exit === "up") {
|
|
tl.to(stage, { y: "-4cqh", duration: OUT, ease: "power2.in" }, OUT_START);
|
|
tl.to(stage, { opacity: 0, duration: OUT, ease: "power2.in" }, OUT_START);
|
|
} else if (exit === "fade") {
|
|
tl.to(stage, { opacity: 0, duration: OUT, ease: "power2.in" }, OUT_START);
|
|
}
|
|
|
|
tl.seek(0);
|
|
paint(0);
|
|
window.__timelines = window.__timelines || {};
|
|
window.__timelines["soft-blob-touch"] = tl;
|
|
})();
|
|
</script>
|
|
</div>
|
|
</template>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="install">
|
|
|
|
<InstallCommand command="npx hyperframes add soft-blob-touch" item="soft-blob-touch" />
|
|
|
|
That writes one file: `compositions/components/soft-blob-touch.html`.
|
|
|
|
</CatalogSlot>
|
|
|
|
<CatalogSlot slot="docs">
|
|
|
|
## Paste it into your composition
|
|
|
|
Open `compositions/components/soft-blob-touch.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 |
|
|
| --- | --- | --- | --- |
|
|
| `touch_x` | `66` | 8% to 92%, step 1% | Touch point, percent of host width. |
|
|
| `touch_y` | `38` | 8% to 92%, step 1% | Touch point, percent of host height. |
|
|
| `touch_at` | `1.6` | 0.9s to 10s, step 0.1s | Seconds from mount start when the dot makes contact. |
|
|
| `grain` | `fine` | `fine`, `coarse` | Speck register for the granular body. |
|
|
| `accent` | `green` | `green`, `blue`, `violet` | Body tint: green rides --brand, blue rides --accent, violet rides --accent-2. |
|
|
| `exit` | `none` | `none`, `fade`, `up` | Optional departure. Default none: the settled blob holds until the frame cuts. |
|
|
|
|
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="soft-blob-touch"
|
|
data-composition-src="compositions/components/soft-blob-touch.html"
|
|
data-variable-values='{"touch_x":66,"touch_y":38,"touch_at":1.6,"grain":"fine","accent":"green","exit":"none"}'
|
|
></div>
|
|
```
|
|
|
|
{/* hf:generated-footer */}
|
|
|
|
Tagged `motion-primitive` `product-demo` `material` `blob` `touch` `grain`.
|
|
|
|
## 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>
|