fire-paper-loader
它能做什么
这个技能指导 AI 智能体制作一个加载屏幕,屏幕上是一圈燃烧的纸张,并由后台工作线程绘制。适合需要加载大型页面、又希望加载器持续运动的网站。
适用场景
- ✓当页面加载较慢,而加载器需要持续运动时。
- ✓当你想要一个戏剧化的燃烧纸张开场,并能淡入页面时。
- ✓当主页面繁忙时,加载器可能会卡住,需要保持运动时。
技能链接
https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/fire-paper-loader/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我为网站做一个燃烧纸张的加载器,即使页面忙于加载,它也能持续动画。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会从页面头部启动一个后台工作线程,在它自己的画布上绘制火焰,因此即使主页面忙碌,火焰也能持续运行。加载进度计数和平滑的淡出会引导进入页面。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Fire-Paper Loader
A ring of burning paper opens on black while the page builds. The mechanism: the fire is drawn by a Worker on an OffscreenCanvas that is started from <head>, so the ring keeps burning while the main thread is blocked for hundreds of milliseconds. The flame look is staging; a loader that stops dead for 450 ms reads as a hang whatever it looks like.
Nearest skills: web-design-performance covers general page speed; this one is specifically a loader that survives a blocked thread. For the burning-paper look on scroll transitions (not a loader), the flame GLSL is the same kbFlame but the page draws it. For a spinner or AI-status orb, use thinking-orbs.
Stack, verified in the source: Vanilla JavaScript, raw WebGL 1 (GLSL ES 1.00, no Three.js in the loader), Worker plus OffscreenCanvas, CSS for the label and fade.
Start from the head, not from the body
Symptom: the loader appears 1-2 s late, or the worker never gets a GL context, or the fire stands still while three.js downloads. A worker can start and create its WebGL context only while the main thread is free, which is during stylesheet loading in <head> and not again until the page is parsed.
- In a
<script>in<head>: create a canvas,transferControlToOffscreen(), start a Worker from a Blob URL of a tiny boot script, post{kbPre, canvas}and callgetContext('webgl', {antialias:false, alpha:false, depth:false, stencil:false})in the worker there and then. Keep the canvas and worker onwindow.__kbPre. - The boot script is only a shell. The loader's own
<script>(later in the body) sends its owntextContentto the worker with{kbInit, src, canvas:null, t0, origin: performance.timeOrigin, reduced, view, target}, and the workerevals it. One source text runs on both threads:const IN_W = typeof document === 'undefined'. Two copies drift apart. - Guard every step: no
Worker, noOffscreenCanvas, notransferControlToOffscreen, workeronerror, or afailmessage means draw on the main thread with the same code after the same warm-up. - Convert clocks. The worker's
performance.now()differs from the page's: sendperformance.timeOrigin, and addperformance.timeOrigin - originin the worker so every timestamp the page reads is its own.
Compile in parallel, warm the pipeline, then show
Symptom: the first visible frames are the slowest of the load (30-130 ms, once 408 ms on Metal).
- Create both programs (ring, cinders), attach shaders,
linkProgramboth, and only then ask for status. WithKHR_parallel_shader_compilethe driver compiles on its own threads; readingCOMPILE_STATUSper shader defeats it. Skip the per-shader check when the extension exists. warmUp(): run a real frame's draws of both programs into a 1x1 viewport, thenreadPixels1 pixel, waited. A first draw builds the GPU pipeline; make that happen before anything is seen.- Only then start
requestAnimationFrame. The page'sLOAD.ready()resolves when the worker draws (typically 0.15-0.3 s, timed out at 1.2 s); the build awaits it so it does not hold the thread off for a second while the fire stands still. - Show one canvas, not two. Drawing the fire on both threads first cost compile time in the first visible frames.
The ring's pace is planned in what is seen
Symptom: the coal sits at one size for a second, then leaps 2.5x; or a ring that stalls is overtaken by a faster one and reads as two fires.
- Plan the growth in
S = gain + ln(radius / first radius), not in the raw progressu. Equal steps in S look like equal growth at every size. The fade-in weighs 0.3 in S (at 1 it held the size back for 0.9 s). - Follow
Swith a critically damped spring (omega 5/s, speed clamped to 1.6/s, integrated in 1/120 s sub-steps) toward a goal that is the real progress but never behind a creep:creep = 0.38*(1 - exp(-t/800 ms)), and the goal cannot passWAIT0.290 while waiting, easing towardCEIL0.335 with a 2.5 s time constant. A hard hold and progress arriving in lumps read as a ring parked, then shoved. - Never still: minimum
VMIN0.016/s (about 5 px a frame at 8 fps), maximumVMAX0.05/s. The seen radius: a 4 px fleck at progress 0, 5.8 px by 0.15, then the burn's own radius. - Before the page has said anything, progress creeps on its own clock, so the ring lives while three.js is still on the wire.
Hand off without a stall
Symptom: the ring lurches into the page's intro, or the page stutters for 55-240
常见问题
为什么使用工作线程?
工作线程与主页面分开运行,因此即使页面被占用,火焰仍然可以持续运动。
它涵盖一般的页面速度吗?
不涵盖。该技能指出,一般的速度优化由另一个技能负责,本技能只针对加载器。
使用什么代码?
使用原生 JavaScript 和 WebGL,不需要大型三维库。
详情
作者的原始描述
Build a burning-paper ring loader whose GLSL flame is drawn by a Worker on an OffscreenCanvas started from the head, so a main thread blocked by the page build cannot freeze it, with a progress count, an even-paced run into the hand-off, and a clean fade to the page. Covers the ember thread and ember gradient, porous char, worker start-up, parallel shader compile with a waited 1-px warm-up draw, hand-off without a stall, reduced motion and hidden-tab behaviour. Use for a loading screen, preloader, page loader, splash, "kindling", burn loader, ember ring, burning paper hole, fire loader, or a l
repo: MengTo/Skills
热度
- GitHub 星标
- 7.2k
- 排名
- #13429
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
3d-cloth-material
7.2k帮你的智能体在 Three.js 中制作逼真的编织织物,包括纱线编织纹理、柔和光泽、自然褶皱、下摆和缝线。
3d-falling-leaves
7.2k帮你的智能体在 3D 场景中添加逼真的飘落树叶,树叶会翻滚、随风飘动,并在镜头移动时循环利用。
3d-four-seasons
7.2k帮你的智能体为 3D 场景添加春夏秋冬四季效果,无需重建场景即可改变植被、光线、天空和积雪。
3d-high-poly-models
7.2k帮你的智能体构建形状平滑、边缘可信的精细 3D 模型,然后制作在网页上运行流畅的轻量版本。