worker-visualizer
Skill này làm gì
Tạo một hoạt ảnh trực quan chạy mượt (60 khung hình mỗi giây) trong trình duyệt của bạn. Nó thực hiện các phép tính nặng ở chế độ nền mà không làm đơ trang chính và hiển thị kết quả trên canvas.
Khi nào nên dùng
- ✓Khi bạn muốn xem mô phỏng hạt hoặc vật lý theo thời gian thực.
- ✓Khi bạn muốn tạo hiệu ứng hình ảnh phức tạp, như các fractal chuyển động.
- ✓Khi bạn phát triển thứ cần tính toán nặng mà không làm chậm giao diện.
Liên kết skill
https://github.com/nexu-io/open-design/blob/main/design-templates/worker-visualizer/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tạo mô phỏng 1000 hạt hút lẫn nhau và hiển thị trên canvas.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Mã nguồn chia công việc: một phần xử lý các phép tính nặng ở một khu vực riêng (Web Worker), phần còn lại chỉ vẽ kết quả lên màn hình. Cách này giúp trang luôn phản hồi nhanh.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Worker Visualizer Skill
Produce a single self-contained index.html that moves heavy per-frame compute into a Web Worker and renders the result to a canvas, keeping the main thread at a smooth 60fps.
Why this is a powered artifact
OpenDesign detects new Worker( / SharedArrayBuffer / OffscreenCanvas and renders this file in powered preview — a cross-origin-isolated iframe with allow-same-origin. That means external and blob Web Workers construct successfully, SharedArrayBuffer is defined (crossOriginIsolated === true), and importScripts works. In the old opaque sandbox all three failed; here they just work.
Resource map
worker-visualizer/
├── SKILL.md ← you're reading this
└── example.html ← a working 12k-particle SharedArrayBuffer sim (READ FIRST)
Workflow
Step 0 — Read the reference
Read example.html. Note the split: the worker integrates positions each tick; the main thread only reads + draws. It feature-detects crossOriginIsolated and uses a SharedArrayBuffer for zero-copy when available, falling back to a transferable postMessage copy otherwise. Always ship that fallback so the artifact still animates if isolation is off.
Step 1 — Choose the workload
Pick ONE compute-bound job worth offloading:
- Particle / N-body field (default): thousands of bodies with a cheap force law.
- Fractal: Mandelbrot/Julia escape-time into an
ImageDatabuffer. - Cellular automata / reaction-diffusion: grid updated in the worker.
- Data/audio visualizer: transform a stream into bars/rings each frame.
Step 2 — Build index.html
- One file, zero external requests. Build the worker from a
Blob+URL.createObjectURL(inline its source), or embed it as adata:URL. - Prefer SharedArrayBuffer for large per-frame state: allocate on the main thread, pass the
SharedArrayBufferto the worker, and read the sameFloat32Array/Uint8ClampedArrayview while drawing. Guard ontypeof SharedArrayBuffer !== 'undefined' && crossOriginIsolated. - Fallback path: if not isolated,
postMessagea transferableArrayBuffereach frame. - Consider
OffscreenCanvas+canvas.transferControlToOffscreen()to render inside the worker for the heaviest scenes.
Step 3 — Overlay + brand
- HUD with the title and 2–3 live stat tiles (particle count, transport mode, fps). Map accent color to the active DESIGN.md when present; otherwise a dark ground with one vivid accent.
Step 4 — Self-review (P0)
- Worker constructs with no SecurityError; sim runs.
- Main-thread render holds ~60fps under the full workload.
-
SharedArrayBufferpath engages whencrossOriginIsolatedis true;postMessagefallback engages otherwise — verify BOTH branches degrade cleanly. - No unbounded growth: velocities/positions stay stable over minutes.
- The "Transport" stat truthfully reports which path is live.
Câu hỏi thường gặp
“Web Worker” là gì?
Đó giống như một trợ lý ẩn trong trình duyệt, thực hiện các tác vụ nặng mà không làm ảnh hưởng đến những gì bạn thấy trên màn hình chính.
“SharedArrayBuffer” là gì?
Đó là một cách nâng cao để chia sẻ dữ liệu rất lớn giữa phần chính và Web Worker mà không cần sao chép toàn bộ, nhờ đó nhanh hơn.
Tại sao hoạt ảnh chạy ở 60fps?
Công cụ được thiết kế để tối ưu tính toán và vẽ hình, giúp hoạt ảnh mượt và dễ xem, giống như trong trò chơi.
Chi tiết
Mô tả gốc của tác giả
A real-time data/particle/simulation visualizer whose heavy compute runs in a Web Worker (off the main thread), optionally sharing memory with the UI via SharedArrayBuffer, and renders to a canvas at 60fps. Produced as a single self-contained `index.html`. Use when the brief asks for a "web worker", "simulation", "particle system", "physics", "off-main-thread", "fractal", "real-time compute", or "
repo: nexu-io/open-design
Độ phổ biến
- Sao GitHub
- 101k
- Vị trí xếp hạng
- #976
- Giấy phép
- Apache-2.0
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
sample-plugin
101kGiúp agent của bạn tạo một tệp metadata cho các bài kiểm thử. Nó giúp đảm bảo mã nguồn chạy đúng trong nhiều tình huống khác nhau.
aster-atelier
101kGiúp agent của bạn tạo một website nghệ thuật theo phong cách cổ điển. Nó dùng hình ảnh tinh tế, bầu trời xanh và phông chữ serif để tạo cảm giác điện ảnh.
audio-jingle
101kGiúp agent của bạn tạo âm thanh như nhạc hiệu và hiệu ứng âm thanh. Nó có thể tạo nhạc và giọng nói, rồi lưu kết quả thành tệp âm thanh.
blog-post
101kGiúp agent của bạn viết bài báo dài hoặc bài blog. Có chỗ dành cho hình ảnh, trích dẫn và thông tin tác giả.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.