/qadri-3d:webgl-componentsfrom qadri-3d
Build small, always-on WebGL visuals (identity avatars, ambient orbs, glass and iridescent surfaces, animated textures) that ship inside a normal web app UI without wrecking performance, accessibility, SSR, or layout. Use whenever a shader-, GLSL-, or canvas-driven decorative element is added to a product UI, especially one rendered many times per page or per list; when reviewing or optimizing one; or when debugging one that renders blurry, aliased, all-black, or paints over the surrounding UI on machines without hardware acceleration.
Ships in qadri-3d. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Lessons for embedding shader-driven visuals (identity avatars, ambient orbs, animated textures) into product UI. The failure modes are predictable, and nearly all of them come from treating the widget like a demo instead of like a component that renders fifty times in a list.
Never create one WebGL context per component instance. Browsers cap a document at roughly 8 to 16 live contexts, then silently evict the oldest. A list of avatars hits that cap immediately.
drawImage.canvas.height - size, not from 0.requestAnimationFrame loop for all instances, owned at module level. No per-instance loops.IntersectionObserver so offscreen instances never draw.document.visibilityState !== "visible", and stop scheduling once nothing visible remains.texture2D(..., bias) to pull the detail back. This presents as "why is it suddenly blurry and washed out" and is easy to misdiagnose as a texture problem.generateMipmap, so keep generated sources power-of-two and resample arbitrary images onto a power-of-two canvas before upload.Glass, chrome, iridescence and caustics are the usual reasons these widgets exist, and the instinct is to paint them: a gaussian for the highlight, a hand-authored violet-to-red ramp for the rainbow, a smoothstep ring for the edge. Painted optics need a new hand-tuned term for every angle and every background, and they stop being convincing the moment anything moves. Deriving them costs about the same per pixel and holds up on its own.
N = normalize(vec3(p, sqrt(1 - r*r))). From it, Fresnel 0.04 + 0.96 * pow(1 - dot(N, V), 5.0) and a reflection vector are two more lines, and a Fresnel-weighted env(reflect(-V, N)) already is the specular edge — grazing angles drive the weight to 1 and the rim shows nothing but environment. A separate rim term added on top of this is a sign the reflection is not doing its job.pows, needs no texture upload or GPU memory, and gives correct-looking reflections everywhere the widget curves.refract and a few exps — the whole loop is comparable to a 13-tap blur, and unlike the blur it scales with nothing but area. If it still needs trimming, drop taps before dropping resolution, but re-check for striping each time.vec4(emitted, coverage) — rather than a finished opaque image. The clear middle then lets the page through while only the reflective rim goes properly opaque.prefers-color-scheme and pass it as a uniform.backdrop-filter (blur() is universally supported; an SVG feDisplacementMap bends it properly but is not portable), or drawing the backdrop into the scene yourself. Say which one you did — a widget described as refracting the page when it is only reflecting a procedural environment will be found out the moment it moves over something patterned.Do not copy a device-pixel-ratio cap from another project. The right cap is a function of how expensive your fragment shader is.
Optimizing the shader first is what earns the sharper rendering. Decide the cap after the shader is final, not before.
gl.deleteTexture until back under the cap. Evicting a texture that is on screen just forces an immediate regeneration.createImageBitmap, falling back to Image, and close() the bitmap in a finally so early-return paths cannot leak decoded pixel memory.webglcontextlost, call preventDefault(), tear down the loop, and flip every mounted instance to its DOM fallback. Context loss is routine under GPU resets and tab pressure, not exotic.failIfMajorPerformanceCaveat: true. Where the GPU is blocklisted, a heavy source pass takes seconds and freezes the tab, and the flat fallback is strictly the better widget there.failIfMajorPerformanceCaveat: true is the right call, but accept what it implies: the widget refuses to render on every machine with hardware acceleration switched off — a plain Chrome settings toggle, not an exotic state — plus blocklisted GPUs, remote-desktop sessions, and lost contexts. Those users see only the fallback, and none of them are the machine you develop on, which is precisely how a broken fallback ships: nobody who could fix it ever renders it.
fallback part of the minimum API shape. Take it as a prop next to source, and include it in every documented example — above all the first copy-paste snippet, because that is the one humans and agents lift. An example gallery where only a dedicated "fallback demo" passes one teaches everyone else to omit it.object-cover, which matches the shader's cover-fit crop. A window onto a larger image → position it absolutely against the frame and let the clip do the cropping.overflow: hidden only clips an absolutely positioned descendant when the clipping element is itself positioned. A fallback that positions an oversized image against a static wrapper ignores the clip entirely and paints across the surrounding UI at full size. Put position: relative on the overflow-hidden frame, and treat its absence as a review blocker — this exact bug ships invisibly because the branch never renders on a dev machine.forceFallback prop and use it in the design-system or docs page with the hardest fallback shape supported (an image an order of magnitude larger than the widget, positioned off-center). A clipping regression then splatters a photo across the docs page where anyone sees it, instead of waiting for a customer report. If flipping to the fallback unmounts the canvas, the registration effect must depend on that flag so the stale instance is released, not leaked.img override, for instance) can silently strip the className or style a fallback depends on, leaving a demo that renders plausibly while testing nothing."use client". This is an RSC boundary marker rather than a React-wide requirement, so check which world you are in: it applies in the Next.js App Router and the other RSC setups (React Router's RSC mode, Waku, the Parcel and Vite RSC plugins), and is an inert directive in a plain SPA, the Next Pages Router, or Astro and Remix islands, where the only effect is a bundler warning about module-level directives. Where it does apply, omitting it often works in dev while the production server render fails with an opaque digest error, because dev and prod RSC behavior differ. Verify with a real production build, not the dev server.window, document, matchMedia) at module scope, only inside functions called after mount. This one bites in Astro, Remix, Gatsby and a Vite SSR build just as hard as in Next.source={{...}} object re-registers the instance on every render when the effect depends on object identity.prefers-reduced-motion renders one still frame and never starts the loop. Keep full visual fidelity, since reduced motion is not reduced appearance. Listen for the media-query change and repaint live.aria-hidden, meaningful ones get role="img" with a label. Make it a prop that defaults to hidden.isolation: isolate if it layers internally with z-index. Otherwise its internal stacking leaks into the page and the widget floats above sticky headers and navigation.Math.random() in the render path. Determinism is what makes the widget an identity mark rather than a screensaver.scripts/gpu-probe.html answers it directly: the strict-context result, whether WebGL exists at all, the live context cap, and the blit orientation. Edit CONTEXT_OPTIONS at the top of the file to match your component's real options first, because the answer only transfers if the options match. Serve it and read the JSON:python3 -m http.server 8000 --directory scripts
--user-data-dir keeps it out of the normal profile:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --disable-gpu --user-data-dir=/tmp/nogpu-profile http://localhost:8000/gpu-probe.html
Expect the probe to report FALLBACK, then confirm every widget in your app shows its fallback, correctly clipped and painting nothing outside its frame. Note the two no-GPU states differ: --disable-gpu removes WebGL entirely, while the GUI toggle (Settings → System → "Use graphics acceleration when available", off, then restart) usually leaves a software rasterizer that the strict context refuses anyway. Both land on the fallback branch, and the GUI toggle is the exact state the affected users are in.
--disable-gpu shows only fallbacks with nothing painting outside its frame, and a production build serves the page.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub qadri-uk/claude-skills --plugin qadri-3d71 skills in this plugin
/360-product-spinAdd a 360° product spin (a draggable image sequence) to a product page, and produce the frames by photographing the product on a turntable or rendering a 3D model with three.js. Use when the user wants a 360 view, a spin or rotating product photos, "turn the product around", a 360 product viewer, sprite sheets for product rotation, or has product photos but no 3D model. Uses the zero-dependency Spin360 web component./3d-3d-cloth-materialBuild convincing woven cloth in Three.js, with a thread-level weave normal map, sheen and anisotropic highlights, folds that never stretch the texture, hems with thickness, stitches, seams, frayed edges, fold occlusion, dye and wear variation, and light passing through thin fabric. Use for linen, silk, wool, canvas, curtains, banners, cloaks, tablecloths, tapestries or any 3D drape that currently looks like a plastic sheet, a stretched texture, or a flat coloured plane./3d-3d-falling-leavesBuild recognizable falling leaves in world space using instanced geometry, independent tumble, coupled sideways drift, shared wind, scene occlusion, and camera-aware recycling. Use for 3D autumn leaves or drifting foliage in Three.js and similar scenes; use falling-leaves for a 2D canvas overlay.