hyperframes 0.6.97 → 0.6.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/beat-analyzer.global.js +326 -0
- package/dist/cli.js +2479 -1961
- package/dist/commands/layout-audit.browser.js +86 -0
- package/dist/hyperframe-runtime.js +22 -22
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +22 -22
- package/dist/skills/hyperframes-cli/SKILL.md +67 -103
- package/dist/skills/hyperframes-cli/references/doctor-browser.md +45 -0
- package/dist/skills/hyperframes-cli/references/init-and-scaffold.md +51 -0
- package/dist/skills/hyperframes-cli/references/lambda.md +132 -0
- package/dist/skills/hyperframes-cli/references/lint-validate-inspect.md +93 -0
- package/dist/skills/hyperframes-cli/references/preview-render.md +107 -0
- package/dist/skills/hyperframes-cli/references/upgrade-info-misc.md +75 -0
- package/dist/studio/assets/hyperframes-player-DgsMQSvV.js +418 -0
- package/dist/studio/assets/index-B62bDCQv.css +1 -0
- package/dist/studio/assets/index-Ce3pBm_I.js +252 -0
- package/dist/studio/assets/{index-HveJ0MuV.js → index-D-ET9M0b.js} +1 -1
- package/dist/studio/assets/index-D-bS9Dxx.js +1 -0
- package/dist/studio/index.html +2 -2
- package/dist/templates/_shared/AGENTS.md +46 -21
- package/dist/templates/_shared/CLAUDE.md +16 -14
- package/package.json +3 -2
- package/dist/pngDecodeBlitWorker.js +0 -239
- package/dist/skills/gsap/SKILL.md +0 -240
- package/dist/skills/gsap/references/effects.md +0 -297
- package/dist/skills/gsap/scripts/extract-audio-data.py +0 -188
- package/dist/skills/hyperframes/SKILL.md +0 -491
- package/dist/skills/hyperframes/data-in-motion.md +0 -19
- package/dist/skills/hyperframes/house-style.md +0 -73
- package/dist/skills/hyperframes/palettes/bold-energetic.md +0 -14
- package/dist/skills/hyperframes/palettes/clean-corporate.md +0 -14
- package/dist/skills/hyperframes/palettes/dark-premium.md +0 -14
- package/dist/skills/hyperframes/palettes/jewel-rich.md +0 -14
- package/dist/skills/hyperframes/palettes/monochrome.md +0 -14
- package/dist/skills/hyperframes/palettes/nature-earth.md +0 -14
- package/dist/skills/hyperframes/palettes/neon-electric.md +0 -14
- package/dist/skills/hyperframes/palettes/pastel-soft.md +0 -14
- package/dist/skills/hyperframes/palettes/warm-editorial.md +0 -14
- package/dist/skills/hyperframes/patterns.md +0 -191
- package/dist/skills/hyperframes/references/audio-reactive.md +0 -76
- package/dist/skills/hyperframes/references/beat-direction.md +0 -171
- package/dist/skills/hyperframes/references/captions.md +0 -163
- package/dist/skills/hyperframes/references/css-patterns.md +0 -373
- package/dist/skills/hyperframes/references/design-picker.md +0 -117
- package/dist/skills/hyperframes/references/dynamic-techniques.md +0 -102
- package/dist/skills/hyperframes/references/html-in-canvas-patterns.md +0 -507
- package/dist/skills/hyperframes/references/motion-principles.md +0 -150
- package/dist/skills/hyperframes/references/narration.md +0 -92
- package/dist/skills/hyperframes/references/prompt-expansion.md +0 -68
- package/dist/skills/hyperframes/references/techniques.md +0 -525
- package/dist/skills/hyperframes/references/text-effects.md +0 -64
- package/dist/skills/hyperframes/references/transcript-guide.md +0 -107
- package/dist/skills/hyperframes/references/transitions/catalog.md +0 -117
- package/dist/skills/hyperframes/references/transitions/css-3d.md +0 -12
- package/dist/skills/hyperframes/references/transitions/css-blur.md +0 -51
- package/dist/skills/hyperframes/references/transitions/css-cover.md +0 -43
- package/dist/skills/hyperframes/references/transitions/css-destruction.md +0 -95
- package/dist/skills/hyperframes/references/transitions/css-dissolve.md +0 -66
- package/dist/skills/hyperframes/references/transitions/css-distortion.md +0 -45
- package/dist/skills/hyperframes/references/transitions/css-grid.md +0 -10
- package/dist/skills/hyperframes/references/transitions/css-light.md +0 -49
- package/dist/skills/hyperframes/references/transitions/css-mechanical.md +0 -30
- package/dist/skills/hyperframes/references/transitions/css-other.md +0 -25
- package/dist/skills/hyperframes/references/transitions/css-push.md +0 -41
- package/dist/skills/hyperframes/references/transitions/css-radial.md +0 -37
- package/dist/skills/hyperframes/references/transitions/css-scale.md +0 -24
- package/dist/skills/hyperframes/references/transitions.md +0 -138
- package/dist/skills/hyperframes/references/typography.md +0 -175
- package/dist/skills/hyperframes/references/video-composition.md +0 -62
- package/dist/skills/hyperframes/scripts/animation-map.mjs +0 -601
- package/dist/skills/hyperframes/scripts/contrast-report.mjs +0 -348
- package/dist/skills/hyperframes/scripts/package-loader.mjs +0 -269
- package/dist/skills/hyperframes/templates/design-picker.html +0 -1432
- package/dist/skills/hyperframes/visual-styles.md +0 -443
- package/dist/studio/assets/hyperframes-player-Daj5djxa.js +0 -418
- package/dist/studio/assets/index-B0twsRu0.css +0 -1
- package/dist/studio/assets/index-Cfye9xzo.js +0 -251
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Dynamic Caption Techniques
|
|
2
|
-
|
|
3
|
-
You are here because SKILL.md told you to read this file before writing animation code. Pick your technique combination from the table below based on the energy level you detected from the transcript, then implement using standard GSAP patterns.
|
|
4
|
-
|
|
5
|
-
## Technique Selection by Energy
|
|
6
|
-
|
|
7
|
-
Captions are a constrained surface — the highlight and exit technique is closely tied to how much intensity the spoken content carries. The table below is a calibration reference. If the design spec (`frame.md` or `design.md`) or the storyboard specifies a caption style, that overrides anything here.
|
|
8
|
-
|
|
9
|
-
The core principle: **all energy levels use karaoke highlight as the baseline.** The difference is intensity — not the technique type.
|
|
10
|
-
|
|
11
|
-
**What changes with energy:**
|
|
12
|
-
|
|
13
|
-
- **Highlight intensity:** high energy gets accent color + glow + 15% scale pop on active words. Low energy gets a gentle white shift with 3% scale. The karaoke behavior is the same; the amplitude is different.
|
|
14
|
-
- **Exit style:** high energy exits scatter or drop (the word leaves with motion). Low energy exits collapse (the word simply fades or shrinks). The exit should express the same energy as the content.
|
|
15
|
-
- **Cycle variation:** high energy alternates highlight styles every 2 groups for variety. Low energy uses a single consistent style, varying only the ease. Variation itself creates energy; consistency creates calm.
|
|
16
|
-
|
|
17
|
-
Calibration reference (starting points, not rules):
|
|
18
|
-
|
|
19
|
-
| Energy level | Highlight amplitude | Exit | Cycle variation |
|
|
20
|
-
| ------------ | ----------------------------------- | ------------------- | --------------- |
|
|
21
|
-
| High | Accent color + glow + 15% scale pop | Scatter or drop | Every 2 groups |
|
|
22
|
-
| Medium-high | Color pop, no glow | Scatter or collapse | Every 3 groups |
|
|
23
|
-
| Medium | White shift only | Fade + slide | Every 3 groups |
|
|
24
|
-
| Medium-low | Minimal scale change | Fade | Single style |
|
|
25
|
-
| Low | Warm tones, slow transition | Collapse | Single style |
|
|
26
|
-
|
|
27
|
-
**All energy levels use karaoke highlight as the baseline.** The difference is intensity — high energy gets accent color + glow + 15% scale pop on active words, low energy gets a gentle white shift with 3% scale.
|
|
28
|
-
|
|
29
|
-
**Emphasis words always break the pattern.** When a word is flagged as emphasis (emotional keyword, ALL CAPS, brand name), give it a stronger animation than surrounding words (larger scale, accent color, overshoot ease). This creates contrast.
|
|
30
|
-
|
|
31
|
-
**Marker highlight modes add a visual layer on top of karaoke.** For emphasis words that need more than color/scale, add a marker-style effect — highlight sweep, circle, burst, or scribble — using the `/marker-highlight` skill. Match mode to energy: burst for hype, circle for key terms, highlight for standard, scribble for subtle.
|
|
32
|
-
|
|
33
|
-
## Audio-Reactive Captions (Mandatory for Music)
|
|
34
|
-
|
|
35
|
-
**If the source audio is music (vocals over instrumentation, beats, any musical content), you MUST extract audio data and add audio-reactive animations.** This is not optional — music without audio reactivity looks disconnected. Even low-energy ballads get subtle bass pulse and treble glow.
|
|
36
|
-
|
|
37
|
-
No special wiring is needed. The group loop already iterates over every caption group to build entrance, karaoke, and exit tweens. At that point, read the audio data for each group's time range and use it to modulate the group's animation intensity with regular GSAP tweens.
|
|
38
|
-
|
|
39
|
-
```js
|
|
40
|
-
// Load audio data inline (same pattern as TRANSCRIPT)
|
|
41
|
-
var AUDIO = JSON.parse(audioDataJson); // { fps, totalFrames, frames: [{ bands: [...] }] }
|
|
42
|
-
|
|
43
|
-
GROUPS.forEach(function (group, gi) {
|
|
44
|
-
var groupEl = document.getElementById("cg-" + gi);
|
|
45
|
-
if (!groupEl) return;
|
|
46
|
-
|
|
47
|
-
// Read peak energy for this group's time range
|
|
48
|
-
var startFrame = Math.floor(group.start * AUDIO.fps);
|
|
49
|
-
var endFrame = Math.min(Math.floor(group.end * AUDIO.fps), AUDIO.totalFrames - 1);
|
|
50
|
-
var peakBass = 0;
|
|
51
|
-
var peakTreble = 0;
|
|
52
|
-
for (var f = startFrame; f <= endFrame; f++) {
|
|
53
|
-
var frame = AUDIO.frames[f];
|
|
54
|
-
if (!frame) continue;
|
|
55
|
-
peakBass = Math.max(peakBass, frame.bands[0] || 0, frame.bands[1] || 0);
|
|
56
|
-
peakTreble = Math.max(peakTreble, frame.bands[6] || 0, frame.bands[7] || 0);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Modulate entrance — louder groups enter bigger and glowier
|
|
60
|
-
tl.to(
|
|
61
|
-
groupEl,
|
|
62
|
-
{
|
|
63
|
-
scale: 1 + peakBass * 0.06,
|
|
64
|
-
textShadow:
|
|
65
|
-
"0 0 " + Math.round(peakTreble * 12) + "px rgba(255,255,255," + peakTreble * 0.4 + ")",
|
|
66
|
-
duration: 0.3,
|
|
67
|
-
ease: "power2.out",
|
|
68
|
-
},
|
|
69
|
-
group.start,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
// Reset at exit so audio-driven values don't persist
|
|
73
|
-
tl.set(groupEl, { scale: 1, textShadow: "none" }, group.end - 0.15);
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
This shapes the animation at build time, not playback time — no per-frame callbacks, no `tl.call()` loops, no async fetch timing issues. Loud groups come in with more weight and glow; quiet groups come in soft. The audio data modulates _how much_, the content determines _what_.
|
|
78
|
-
|
|
79
|
-
Keep audio reactivity subtle — 3-6% scale variation and soft glow. Heavy pulsing makes text unreadable.
|
|
80
|
-
|
|
81
|
-
To generate the audio data file:
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
python3 skills/gsap-effects/scripts/extract-audio-data.py audio.mp3 --fps 30 --bands 8 -o audio-data.json
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Combining Techniques
|
|
88
|
-
|
|
89
|
-
Don't use the same highlight animation on every group — cycle through styles using the group index. Don't combine multiple competing animations on the same word at the same timestamp. Vary techniques across groups to match the content's pace changes.
|
|
90
|
-
|
|
91
|
-
**Marker highlight effects** (from the `/marker-highlight` skill) layer well with karaoke — use karaoke for the word-by-word reveal, then add a marker effect on emphasis words only. For example: karaoke highlights each word in white, but brand names get a yellow highlight sweep and stats get a red circle. Cycle marker modes across groups for visual variety (see the mode-to-energy mapping in the marker-highlight skill).
|
|
92
|
-
|
|
93
|
-
## Available Tools
|
|
94
|
-
|
|
95
|
-
These tools are available in the HyperFrames runtime. Use them when they solve a real problem — not every composition needs all of them.
|
|
96
|
-
|
|
97
|
-
| Tool | What it does | Access | When it's useful |
|
|
98
|
-
| ------------------- | ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
99
|
-
| **pretext** | Pure-arithmetic text measurement without DOM reflow. 0.0002ms per call. | `window.__hyperframes.pretext.prepare(text, font)` / `.layout(prepared, maxWidth, lineHeight)` | Per-frame text reflow, shrinkwrap containers, computing layout before render |
|
|
100
|
-
| **fitTextFontSize** | Finds the largest font size that fits text on one line. Built on pretext. | `window.__hyperframes.fitTextFontSize(text, { maxWidth, fontFamily, fontWeight })` | Overflow prevention for long phrases, portrait mode, large base sizes |
|
|
101
|
-
| **audio data** | Pre-extracted per-frame RMS energy and frequency bands. | Extract with `extract-audio-data.py`, load inline or via `fetch("audio-data.json")` | Audio-reactive visuals — modulate intensity based on the music |
|
|
102
|
-
| **GSAP** | Animation timeline with tweens and callbacks. | `gsap.to()`, `gsap.set()`, `tl.to()`, `tl.set()` | All caption animation |
|
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
# HTML-in-Canvas Patterns
|
|
2
|
-
|
|
3
|
-
HyperFrames' most powerful visual capability. Capture ANY live HTML/CSS as a GPU texture, then render it through WebGL shaders, Three.js 3D scenes, or post-processing effects — at 60fps, pixel-perfect, with every CSS feature supported.
|
|
4
|
-
|
|
5
|
-
**Read this file when a beat deserves cinematic treatment beyond flat GSAP animations.** Use for 1-3 hero beats per video, not every beat. The rest can use standard GSAP — the contrast between flat beats and HTML-in-Canvas beats IS part of the visual storytelling.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Core Boilerplate (same in every HTML-in-Canvas composition)
|
|
10
|
-
|
|
11
|
-
Every HTML-in-Canvas effect shares this structure. Learn this once, adapt it for any effect.
|
|
12
|
-
|
|
13
|
-
```html
|
|
14
|
-
<!-- 1. Source HTML — your content goes inside a layoutsubtree canvas -->
|
|
15
|
-
<canvas
|
|
16
|
-
id="hic-source"
|
|
17
|
-
layoutsubtree
|
|
18
|
-
width="1920"
|
|
19
|
-
height="1080"
|
|
20
|
-
style="position:absolute;inset:0;opacity:0;"
|
|
21
|
-
>
|
|
22
|
-
<div id="hic-content" style="width:1920px;height:1080px;">
|
|
23
|
-
<!-- YOUR HTML CONTENT HERE — text, images, cards, dashboards, anything -->
|
|
24
|
-
</div>
|
|
25
|
-
</canvas>
|
|
26
|
-
|
|
27
|
-
<!-- 2. Render target — the visible canvas that shows the effect -->
|
|
28
|
-
<canvas id="hic-output" width="1920" height="1080" style="position:absolute;inset:0;"></canvas>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```js
|
|
32
|
-
// 3. Feature detection — always check, always provide fallback
|
|
33
|
-
function isHiCSupported() {
|
|
34
|
-
var tc = document.createElement("canvas");
|
|
35
|
-
if (!("layoutSubtree" in tc)) return false;
|
|
36
|
-
tc.setAttribute("layoutsubtree", "");
|
|
37
|
-
var ctx = tc.getContext("2d");
|
|
38
|
-
return ctx && typeof ctx.drawElementImage === "function";
|
|
39
|
-
}
|
|
40
|
-
var apiOk = isHiCSupported();
|
|
41
|
-
|
|
42
|
-
// 4. Capture function — call this every frame in onUpdate
|
|
43
|
-
var capCanvas = document.getElementById("hic-source");
|
|
44
|
-
var capCtx = capCanvas.getContext("2d");
|
|
45
|
-
function captureContent() {
|
|
46
|
-
if (apiOk) {
|
|
47
|
-
capCtx.drawElementImage(document.getElementById("hic-content"), 0, 0, 1920, 1080);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 5. Drive from GSAP timeline — capture + render every frame
|
|
52
|
-
tl.to(
|
|
53
|
-
proxy,
|
|
54
|
-
{
|
|
55
|
-
/* your animation properties */
|
|
56
|
-
duration: BEAT_DURATION,
|
|
57
|
-
ease: "sine.inOut",
|
|
58
|
-
onUpdate: function () {
|
|
59
|
-
captureContent();
|
|
60
|
-
// render your effect here (Three.js or WebGL2)
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
0,
|
|
64
|
-
);
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
**Fallback:** When `drawElementImage` is not available (preview without Chrome flag), draw a solid-color placeholder or use Canvas 2D text. The HyperFrames renderer auto-enables the flag — the effect WILL work in the final video. See the liquid-glass block for a complete fallback example.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## Effect Catalog
|
|
72
|
-
|
|
73
|
-
### 1. 3D Rotation with Bloom (Three.js)
|
|
74
|
-
|
|
75
|
-
**What it looks like:** Content floats in 3D space, slowly rotating with cinematic glow around bright edges. Like a product screenshot displayed in a dark theater.
|
|
76
|
-
|
|
77
|
-
**When to use:** Hero product showcase, feature reveal, CTA with premium feel.
|
|
78
|
-
|
|
79
|
-
**Key Three.js components:** `PlaneGeometry` + `CanvasTexture` + `EffectComposer` + `UnrealBloomPass`
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
// After the boilerplate above, add:
|
|
83
|
-
var scene3d = new THREE.Scene();
|
|
84
|
-
var camera = new THREE.PerspectiveCamera(45, 1920 / 1080, 0.1, 100);
|
|
85
|
-
camera.position.set(0, 0, 4);
|
|
86
|
-
|
|
87
|
-
var renderer = new THREE.WebGLRenderer({
|
|
88
|
-
canvas: document.getElementById("hic-output"),
|
|
89
|
-
antialias: true,
|
|
90
|
-
alpha: true,
|
|
91
|
-
});
|
|
92
|
-
renderer.setSize(1920, 1080);
|
|
93
|
-
|
|
94
|
-
var texture = new THREE.CanvasTexture(capCanvas);
|
|
95
|
-
var mesh = new THREE.Mesh(
|
|
96
|
-
new THREE.PlaneGeometry(3.6, 2.2),
|
|
97
|
-
new THREE.MeshBasicMaterial({ map: texture }),
|
|
98
|
-
);
|
|
99
|
-
scene3d.add(mesh);
|
|
100
|
-
|
|
101
|
-
// Post-processing: bloom for cinematic glow.
|
|
102
|
-
// EffectComposer / RenderPass / UnrealBloomPass are ES-module named imports
|
|
103
|
-
// (see the import block below) — they're NOT properties of THREE in modern
|
|
104
|
-
// versions. Three.js r150+ removed the UMD `examples/js/` globals.
|
|
105
|
-
var composer = new EffectComposer(renderer);
|
|
106
|
-
composer.addPass(new RenderPass(scene3d, camera));
|
|
107
|
-
composer.addPass(new UnrealBloomPass(new THREE.Vector2(1920, 1080), 0.3, 0.4, 0.85));
|
|
108
|
-
|
|
109
|
-
var proxy = { rotY: -0.12, zoom: 4.2 };
|
|
110
|
-
tl.to(
|
|
111
|
-
proxy,
|
|
112
|
-
{
|
|
113
|
-
rotY: 0.12,
|
|
114
|
-
zoom: 3.6,
|
|
115
|
-
duration: BEAT_DURATION,
|
|
116
|
-
ease: "sine.inOut",
|
|
117
|
-
onUpdate: function () {
|
|
118
|
-
captureContent();
|
|
119
|
-
texture.needsUpdate = true;
|
|
120
|
-
mesh.rotation.y = proxy.rotY;
|
|
121
|
-
camera.position.z = proxy.zoom;
|
|
122
|
-
composer.render();
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
0,
|
|
126
|
-
);
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**Load Three.js and post-processing via ESM (use a `type="module"` script):**
|
|
130
|
-
|
|
131
|
-
```html
|
|
132
|
-
<script type="module">
|
|
133
|
-
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.181.2/+esm";
|
|
134
|
-
import { EffectComposer } from "https://cdn.jsdelivr.net/npm/three@0.181.2/examples/jsm/postprocessing/EffectComposer.js";
|
|
135
|
-
import { RenderPass } from "https://cdn.jsdelivr.net/npm/three@0.181.2/examples/jsm/postprocessing/RenderPass.js";
|
|
136
|
-
import { ShaderPass } from "https://cdn.jsdelivr.net/npm/three@0.181.2/examples/jsm/postprocessing/ShaderPass.js";
|
|
137
|
-
import { UnrealBloomPass } from "https://cdn.jsdelivr.net/npm/three@0.181.2/examples/jsm/postprocessing/UnrealBloomPass.js";
|
|
138
|
-
// ... rest of composition code using these imports
|
|
139
|
-
</script>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
The `examples/js/` path was removed in Three.js r152. Use `examples/jsm/` (ES modules) with `three@0.181.2` — the version used by the HyperFrames Three.js adapter.
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
### 2. Magnetic Cursor Distortion (Raw WebGL2)
|
|
147
|
-
|
|
148
|
-
**What it looks like:** Content warps and bends toward a moving point, like a magnet pulling on pixels. Chromatic aberration splits RGB channels at the distortion site.
|
|
149
|
-
|
|
150
|
-
**When to use:** Interactive feel, product demo with cursor, "look at THIS feature" moment.
|
|
151
|
-
|
|
152
|
-
**Key technique:** Custom fragment shader with Gaussian warp + chromatic split. No Three.js needed — just raw WebGL2.
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
// WebGL2 setup
|
|
156
|
-
var gl = document.getElementById("hic-output").getContext("webgl2", {
|
|
157
|
-
alpha: false,
|
|
158
|
-
preserveDrawingBuffer: true,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Vertex shader — full-screen quad
|
|
162
|
-
var VS = `#version 300 es
|
|
163
|
-
in vec2 a_pos;
|
|
164
|
-
out vec2 v_uv;
|
|
165
|
-
void main() {
|
|
166
|
-
v_uv = a_pos * 0.5 + 0.5;
|
|
167
|
-
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
168
|
-
}`;
|
|
169
|
-
|
|
170
|
-
// Fragment shader — magnetic warp + chromatic aberration
|
|
171
|
-
var FS = `#version 300 es
|
|
172
|
-
precision highp float;
|
|
173
|
-
in vec2 v_uv;
|
|
174
|
-
out vec4 fragColor;
|
|
175
|
-
uniform sampler2D u_tex;
|
|
176
|
-
uniform vec2 u_cursor; // cursor position (0-1)
|
|
177
|
-
uniform float u_strength; // warp strength (0-1)
|
|
178
|
-
|
|
179
|
-
void main() {
|
|
180
|
-
vec2 uv = v_uv;
|
|
181
|
-
vec2 delta = uv - u_cursor;
|
|
182
|
-
float dist = length(delta);
|
|
183
|
-
float warp = u_strength * exp(-dist * dist * 8.0);
|
|
184
|
-
vec2 warped = uv - delta * warp * 0.3;
|
|
185
|
-
|
|
186
|
-
// Chromatic aberration at distortion site
|
|
187
|
-
float aberration = warp * 0.008;
|
|
188
|
-
float r = texture(u_tex, warped + vec2(aberration, 0.0)).r;
|
|
189
|
-
float g = texture(u_tex, warped).g;
|
|
190
|
-
float b = texture(u_tex, warped - vec2(aberration, 0.0)).b;
|
|
191
|
-
fragColor = vec4(r, g, b, 1.0);
|
|
192
|
-
}`;
|
|
193
|
-
|
|
194
|
-
// Compile, link, setup quad geometry, upload texture...
|
|
195
|
-
// (See registry/blocks/vfx-magnetic/vfx-magnetic.html for complete implementation)
|
|
196
|
-
|
|
197
|
-
// Drive cursor position from GSAP
|
|
198
|
-
var proxy = { cx: 0.2, cy: 0.5, strength: 0.0 };
|
|
199
|
-
tl.to(
|
|
200
|
-
proxy,
|
|
201
|
-
{
|
|
202
|
-
cx: 0.8,
|
|
203
|
-
cy: 0.4,
|
|
204
|
-
strength: 1.0,
|
|
205
|
-
duration: BEAT_DURATION,
|
|
206
|
-
ease: "power2.inOut",
|
|
207
|
-
onUpdate: function () {
|
|
208
|
-
captureContent();
|
|
209
|
-
// Upload texture, set uniforms, draw
|
|
210
|
-
gl.uniform2f(cursorLoc, proxy.cx, proxy.cy);
|
|
211
|
-
gl.uniform1f(strengthLoc, proxy.strength);
|
|
212
|
-
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
0,
|
|
216
|
-
);
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
---
|
|
220
|
-
|
|
221
|
-
### 3. Shatter / Fragment Explosion (Three.js)
|
|
222
|
-
|
|
223
|
-
**What it looks like:** Content breaks into geometric fragments that fly apart, revealing what's behind.
|
|
224
|
-
|
|
225
|
-
**When to use:** Dramatic transition, "breaking free" moment, tension release.
|
|
226
|
-
|
|
227
|
-
**Key technique:** Subdivide the source texture into triangle mesh fragments using BufferGeometry, then animate each fragment's position/rotation with GSAP.
|
|
228
|
-
|
|
229
|
-
Study `registry/blocks/vfx-shatter/vfx-shatter.html` for the complete 1156-line implementation. The core idea:
|
|
230
|
-
|
|
231
|
-
```js
|
|
232
|
-
// 1. Capture content to texture (same boilerplate)
|
|
233
|
-
// Seeded PRNG for determinism — Math.random() is banned
|
|
234
|
-
function mulberry32(seed) {
|
|
235
|
-
return function () {
|
|
236
|
-
seed |= 0;
|
|
237
|
-
seed = (seed + 0x6d2b79f5) | 0;
|
|
238
|
-
var t = Math.imul(seed ^ (seed >>> 15), 1 | seed);
|
|
239
|
-
t ^= t + Math.imul(t ^ (t >>> 7), 61 | t);
|
|
240
|
-
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
var rng = mulberry32(42);
|
|
244
|
-
|
|
245
|
-
// 2. Create N triangle fragments from the texture
|
|
246
|
-
var fragments = [];
|
|
247
|
-
for (var i = 0; i < NUM_FRAGMENTS; i++) {
|
|
248
|
-
var geom = new THREE.BufferGeometry();
|
|
249
|
-
var mesh = new THREE.Mesh(geom, new THREE.MeshBasicMaterial({ map: texture }));
|
|
250
|
-
scene3d.add(mesh);
|
|
251
|
-
fragments.push({ mesh: mesh, targetPos: randomExplosionVector(rng), delay: rng() * 0.5 });
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 3. Animate: first hold still, then EXPLODE
|
|
255
|
-
tl.to({}, { duration: holdTime }, 0);
|
|
256
|
-
fragments.forEach(function (frag) {
|
|
257
|
-
tl.to(
|
|
258
|
-
frag.mesh.position,
|
|
259
|
-
{
|
|
260
|
-
x: frag.targetPos.x,
|
|
261
|
-
y: frag.targetPos.y,
|
|
262
|
-
z: frag.targetPos.z,
|
|
263
|
-
duration: 0.8,
|
|
264
|
-
ease: "power3.in",
|
|
265
|
-
},
|
|
266
|
-
holdTime + frag.delay,
|
|
267
|
-
);
|
|
268
|
-
tl.to(
|
|
269
|
-
frag.mesh.rotation,
|
|
270
|
-
{ x: rng() * 4, y: rng() * 4, duration: 0.8, ease: "power2.in" },
|
|
271
|
-
holdTime + frag.delay,
|
|
272
|
-
);
|
|
273
|
-
});
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
### 4. Liquid / Fluid Surface (Three.js)
|
|
279
|
-
|
|
280
|
-
**What it looks like:** Content floats above a rippling liquid surface with real-time wave dynamics. Or content IS the surface, undulating like water.
|
|
281
|
-
|
|
282
|
-
**When to use:** Organic/premium feel, ambient background, "living" product showcase.
|
|
283
|
-
|
|
284
|
-
**Key technique:** Subdivided PlaneGeometry with vertex displacement driven by noise functions in a vertex shader.
|
|
285
|
-
|
|
286
|
-
Study `registry/blocks/vfx-liquid-background/vfx-liquid-background.html` for the 1244-line implementation. Core idea:
|
|
287
|
-
|
|
288
|
-
```js
|
|
289
|
-
// Custom vertex shader with wave displacement
|
|
290
|
-
var vertexShader = `
|
|
291
|
-
varying vec2 vUv;
|
|
292
|
-
uniform float u_time;
|
|
293
|
-
void main() {
|
|
294
|
-
vUv = uv;
|
|
295
|
-
vec3 pos = position;
|
|
296
|
-
// Sine wave displacement
|
|
297
|
-
pos.z += sin(pos.x * 3.0 + u_time * 2.0) * 0.15;
|
|
298
|
-
pos.z += cos(pos.y * 2.5 + u_time * 1.5) * 0.1;
|
|
299
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
300
|
-
}
|
|
301
|
-
`;
|
|
302
|
-
|
|
303
|
-
var mesh = new THREE.Mesh(
|
|
304
|
-
new THREE.PlaneGeometry(4, 3, 64, 64), // heavily subdivided for smooth waves
|
|
305
|
-
new THREE.ShaderMaterial({
|
|
306
|
-
vertexShader: vertexShader,
|
|
307
|
-
fragmentShader: `varying vec2 vUv; uniform sampler2D u_tex;
|
|
308
|
-
void main() { gl_FragColor = texture2D(u_tex, vUv); }`,
|
|
309
|
-
uniforms: {
|
|
310
|
-
u_tex: { value: texture },
|
|
311
|
-
u_time: { value: 0 },
|
|
312
|
-
},
|
|
313
|
-
}),
|
|
314
|
-
);
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
### 5. Portal / Dimensional Reveal (Three.js)
|
|
320
|
-
|
|
321
|
-
**What it looks like:** A glowing circular portal opens and content emerges through it from another dimension.
|
|
322
|
-
|
|
323
|
-
**When to use:** Product reveal, "entering the app" moment, hero feature introduction.
|
|
324
|
-
|
|
325
|
-
Study `registry/blocks/vfx-portal/vfx-portal.html` for the complete 863-line implementation.
|
|
326
|
-
|
|
327
|
-
---
|
|
328
|
-
|
|
329
|
-
## When to Use HTML-in-Canvas vs Standard GSAP
|
|
330
|
-
|
|
331
|
-
| Scenario | Use | Why |
|
|
332
|
-
| -------------------------------- | ------------------------------------ | ------------------------------------ |
|
|
333
|
-
| Hero product screenshot showcase | HTML-in-Canvas (3D rotation + bloom) | Makes flat UI feel cinematic |
|
|
334
|
-
| Feature list / stats | Standard GSAP | Content-focused, doesn't need 3D |
|
|
335
|
-
| CTA / brand reveal | HTML-in-Canvas (portal or magnetic) | Makes the moment memorable |
|
|
336
|
-
| Social proof / logos | Standard GSAP | Orderly cascade, trust is steady |
|
|
337
|
-
| Transition between acts | HTML-in-Canvas (shatter) | Dramatic act break |
|
|
338
|
-
| Background atmosphere | HTML-in-Canvas (liquid surface) | Premium ambient feel |
|
|
339
|
-
| Quick feature cards | Standard GSAP | Speed matters, 3D would slow it down |
|
|
340
|
-
|
|
341
|
-
---
|
|
342
|
-
|
|
343
|
-
## More Effects You Can Build
|
|
344
|
-
|
|
345
|
-
These aren't in the VFX blocks — build them yourself from the core boilerplate + a custom fragment shader. Each effect is a single GLSL function applied to the captured texture.
|
|
346
|
-
|
|
347
|
-
### 6. Noise Dissolve
|
|
348
|
-
|
|
349
|
-
Content dissolves into noise particles, revealing what's behind. Great for transitions.
|
|
350
|
-
|
|
351
|
-
```glsl
|
|
352
|
-
// Fragment shader — noise-based dissolve
|
|
353
|
-
uniform float u_progress; // 0.0 = fully visible, 1.0 = fully dissolved
|
|
354
|
-
uniform sampler2D u_tex;
|
|
355
|
-
|
|
356
|
-
float hash(vec2 p) {
|
|
357
|
-
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
void main() {
|
|
361
|
-
vec2 uv = v_uv;
|
|
362
|
-
float noise = hash(uv * 50.0);
|
|
363
|
-
float threshold = u_progress;
|
|
364
|
-
if (noise < threshold) {
|
|
365
|
-
// Edge glow at the dissolve boundary
|
|
366
|
-
float edge = smoothstep(threshold - 0.05, threshold, noise);
|
|
367
|
-
fragColor = vec4(1.0, 0.6, 0.2, 1.0) * (1.0 - edge); // orange edge glow
|
|
368
|
-
} else {
|
|
369
|
-
fragColor = texture(u_tex, uv);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### 7. Holographic / Iridescent
|
|
375
|
-
|
|
376
|
-
Content gets a rainbow-shifting holographic sheen that moves with time. Premium, futuristic feel.
|
|
377
|
-
|
|
378
|
-
```glsl
|
|
379
|
-
uniform float u_time;
|
|
380
|
-
uniform sampler2D u_tex;
|
|
381
|
-
|
|
382
|
-
void main() {
|
|
383
|
-
vec4 color = texture(u_tex, v_uv);
|
|
384
|
-
// Iridescent color shift based on position + time
|
|
385
|
-
float angle = v_uv.x * 6.28 + v_uv.y * 3.14 + u_time * 0.5;
|
|
386
|
-
vec3 holo = vec3(
|
|
387
|
-
sin(angle) * 0.5 + 0.5,
|
|
388
|
-
sin(angle + 2.094) * 0.5 + 0.5,
|
|
389
|
-
sin(angle + 4.189) * 0.5 + 0.5
|
|
390
|
-
);
|
|
391
|
-
// Blend holographic over content (subtle overlay)
|
|
392
|
-
fragColor = vec4(mix(color.rgb, holo, 0.15 + 0.1 * sin(u_time)), color.a);
|
|
393
|
-
}
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### 8. Scan Lines + CRT
|
|
397
|
-
|
|
398
|
-
Retro CRT monitor look — scan lines, slight curvature, phosphor glow. Great for "code" or "terminal" beats.
|
|
399
|
-
|
|
400
|
-
```glsl
|
|
401
|
-
uniform sampler2D u_tex;
|
|
402
|
-
uniform float u_time;
|
|
403
|
-
|
|
404
|
-
void main() {
|
|
405
|
-
vec2 uv = v_uv;
|
|
406
|
-
// Barrel distortion (CRT curvature)
|
|
407
|
-
vec2 centered = uv - 0.5;
|
|
408
|
-
float dist = dot(centered, centered);
|
|
409
|
-
uv = uv + centered * dist * 0.15;
|
|
410
|
-
|
|
411
|
-
vec4 color = texture(u_tex, uv);
|
|
412
|
-
// Scan lines
|
|
413
|
-
float scanline = sin(uv.y * 800.0) * 0.04;
|
|
414
|
-
color.rgb -= scanline;
|
|
415
|
-
// Slight RGB offset (phosphor)
|
|
416
|
-
color.r = texture(u_tex, uv + vec2(0.001, 0.0)).r;
|
|
417
|
-
color.b = texture(u_tex, uv - vec2(0.001, 0.0)).b;
|
|
418
|
-
// Vignette
|
|
419
|
-
float vignette = 1.0 - dist * 2.0;
|
|
420
|
-
fragColor = vec4(color.rgb * vignette, 1.0);
|
|
421
|
-
}
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### 9. Frosted Glass Blur
|
|
425
|
-
|
|
426
|
-
Content behind frosted glass — visible but softened, with subtle light refraction. Good for "behind the scenes" or "coming soon" moments.
|
|
427
|
-
|
|
428
|
-
```glsl
|
|
429
|
-
uniform sampler2D u_tex;
|
|
430
|
-
uniform float u_blur; // 0.0 = clear, 1.0 = full frost
|
|
431
|
-
|
|
432
|
-
void main() {
|
|
433
|
-
vec2 uv = v_uv;
|
|
434
|
-
vec4 color = vec4(0.0);
|
|
435
|
-
// Box blur with offset
|
|
436
|
-
float radius = u_blur * 0.015;
|
|
437
|
-
for (float x = -2.0; x <= 2.0; x += 1.0) {
|
|
438
|
-
for (float y = -2.0; y <= 2.0; y += 1.0) {
|
|
439
|
-
color += texture(u_tex, uv + vec2(x, y) * radius);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
color /= 25.0;
|
|
443
|
-
// Add frost noise texture
|
|
444
|
-
float frost = fract(sin(dot(uv * 200.0, vec2(12.9898, 78.233))) * 43758.5453);
|
|
445
|
-
color.rgb += frost * 0.03 * u_blur;
|
|
446
|
-
fragColor = color;
|
|
447
|
-
}
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
### 10. Pixel Sort / Glitch Art
|
|
451
|
-
|
|
452
|
-
Pixels rearrange themselves in vertical or horizontal strips — digital art aesthetic. Great for tech/creative brands.
|
|
453
|
-
|
|
454
|
-
```glsl
|
|
455
|
-
uniform sampler2D u_tex;
|
|
456
|
-
uniform float u_intensity; // 0-1
|
|
457
|
-
|
|
458
|
-
void main() {
|
|
459
|
-
vec2 uv = v_uv;
|
|
460
|
-
// Random horizontal displacement per row
|
|
461
|
-
float row = floor(uv.y * 80.0);
|
|
462
|
-
float noise = fract(sin(row * 127.1) * 43758.5);
|
|
463
|
-
float displace = step(0.7, noise) * u_intensity * 0.1;
|
|
464
|
-
// Shift UV with RGB split
|
|
465
|
-
float r = texture(u_tex, uv + vec2(displace, 0.0)).r;
|
|
466
|
-
float g = texture(u_tex, uv).g;
|
|
467
|
-
float b = texture(u_tex, uv - vec2(displace * 0.5, 0.0)).b;
|
|
468
|
-
fragColor = vec4(r, g, b, 1.0);
|
|
469
|
-
}
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
---
|
|
473
|
-
|
|
474
|
-
## Creating ANY Custom Effect
|
|
475
|
-
|
|
476
|
-
The fragment shaders above are templates. The pattern is always:
|
|
477
|
-
|
|
478
|
-
1. **Capture your HTML content** with `drawElementImage` (the boilerplate at the top)
|
|
479
|
-
2. **Upload the captured canvas as a WebGL texture**
|
|
480
|
-
3. **Write a fragment shader** that reads from the texture and outputs modified colors
|
|
481
|
-
4. **Drive shader uniforms from GSAP** via `onUpdate`
|
|
482
|
-
|
|
483
|
-
Any GLSL effect from ShaderToy, The Book of Shaders, CodePen, or anywhere else can be adapted:
|
|
484
|
-
|
|
485
|
-
1. Find an effect you like (search "GLSL [effect name]" or browse shadertoy.com)
|
|
486
|
-
2. Copy the fragment shader
|
|
487
|
-
3. Replace `iResolution` with `vec2(1920.0, 1080.0)`, `iTime` with your `u_time` uniform
|
|
488
|
-
4. Add `uniform sampler2D u_tex;` for the captured content texture
|
|
489
|
-
5. Wire the uniforms to GSAP proxy values
|
|
490
|
-
|
|
491
|
-
**Geometry ideas beyond flat planes:**
|
|
492
|
-
|
|
493
|
-
- `SphereGeometry` — content mapped onto a globe (world map, global reach)
|
|
494
|
-
- `CylinderGeometry` — content on a rotating cylinder (carousel/scroll feel)
|
|
495
|
-
- `TorusGeometry` — content wrapped around a ring (infinity, cycle)
|
|
496
|
-
- `BoxGeometry` — content on a 3D box (product packaging, dice)
|
|
497
|
-
- GLTF models — content mapped as screen texture on phone, laptop, monitor (see `vfx-iphone-device`)
|
|
498
|
-
|
|
499
|
-
**Post-processing stacking** (Three.js EffectComposer):
|
|
500
|
-
|
|
501
|
-
- Bloom + film grain = cinematic
|
|
502
|
-
- Bloom + chromatic aberration = lens effect
|
|
503
|
-
- Depth of field + vignette = focused attention
|
|
504
|
-
- Film grain + scan lines = retro
|
|
505
|
-
- Multiple passes stack — add as many as you want
|
|
506
|
-
|
|
507
|
-
**You are not limited to the effects listed here.** If you can imagine a visual treatment, you can build it. The HTML-in-Canvas API gives you the source material (any HTML rendered as a texture), and WebGL/Three.js gives you unlimited creative control over how that material is presented.
|