Langsung ke konten
Skillpedia
Agen101k Β· #976

worker-visualizer

Fungsinya

Membuat animasi visual yang berjalan lancar (60 frame per detik) di browser Anda. Perhitungan berat dilakukan di latar belakang tanpa membuat halaman utama macet, lalu hasilnya ditampilkan di canvas.

Kapan dipakai

  • βœ“Ketika Anda ingin melihat simulasi partikel atau fisika secara real-time.
  • βœ“Untuk membuat efek visual kompleks seperti fraktal yang bergerak.
  • βœ“Ketika mengembangkan sesuatu yang membutuhkan perhitungan berat tanpa memperlambat antarmuka.

Link skill

https://github.com/nexu-io/open-design/blob/main/design-templates/worker-visualizer/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/nexu-io/open-design/blob/main/design-templates/worker-visualizer/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuatkan simulasi 1000 partikel yang saling tarik-menarik dan tampilkan di canvas.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Kode membagi pekerjaan: satu bagian menangani perhitungan berat di area terpisah (Web Worker), dan bagian lain hanya menggambar hasilnya di layar. Ini memastikan halaman tetap responsif.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

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 ImageData buffer.
  • 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 a data: URL.
  • Prefer SharedArrayBuffer for large per-frame state: allocate on the main thread, pass the SharedArrayBuffer to the worker, and read the same Float32Array/Uint8ClampedArray view while drawing. Guard on typeof SharedArrayBuffer !== 'undefined' && crossOriginIsolated.
  • Fallback path: if not isolated, postMessage a transferable ArrayBuffer each 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.
  • SharedArrayBuffer path engages when crossOriginIsolated is true; postMessage fallback 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.
Pertanyaan umum

Apa itu 'Web Worker'?

Ini seperti asisten rahasia di browser yang mengerjakan tugas berat tanpa mengganggu apa yang Anda lihat di layar utama.

Apa itu 'SharedArrayBuffer'?

Ini adalah cara canggih untuk berbagi data berukuran besar antara bagian utama dan asisten (Web Worker) tanpa perlu menyalin semuanya, sehingga prosesnya lebih cepat.

Mengapa animasinya berjalan di 60fps?

Alat ini dirancang untuk mengoptimalkan perhitungan dan penggambaran, sehingga animasinya halus dan nyaman dilihat, seperti di dalam game.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
101k
Peringkat
#976
Lisensi
Apache-2.0
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa