← Gallery № 75 · webgl

Magnetic Field

Dipole field lines curving between slowly rotating poles with silk-thread glow rendering.

What is Magnetic Field?

Magnetic Field is a free WebGL web effect in the TappyPrism library. Dipole field lines curving between slowly rotating poles with silk-thread glow rendering. It is rendered on the GPU by a fragment shader, so it costs almost nothing on the CPU and works well as a full-screen background. It ships as a single self-contained HTML file (magnetic-field.html) with zero dependencies — no npm package, no framework, no build step. It exposes 2 live parameters — Animation Speed, Field Lines — adjustable in the browser or at runtime.

Parameters

ParameterKeyRangeDefault
Animation SpeedWAVE_SPEED0.2 – 31
Field LinesLINE_COUNT3 – 128

How to add Magnetic Field to your page

  1. Download the standalone file magnetic-field.html and copy its source into your project.
  2. Or embed it as a background iframe:
    <iframe src="https://prism.tappypotato.com/fx/magnetic-field.html" style="position:fixed;inset:0;width:100%;height:100%;border:0;z-index:-1" title="Magnetic Field"></iframe>
  3. Tune it at runtime with postMessage:
    iframe.contentWindow.postMessage({ type: 'param', name: 'WAVE_SPEED', value: 1 }, '*');

Frequently asked questions

What is Magnetic Field?

Magnetic Field is a free WebGL web effect in the TappyPrism library. Dipole field lines curving between slowly rotating poles with silk-thread glow rendering. It is rendered on the GPU by a fragment shader, so it costs almost nothing on the CPU and works well as a full-screen background. It ships as a single self-contained HTML file (magnetic-field.html) with zero dependencies — no npm package, no framework, no build step. It exposes 2 live parameters — Animation Speed, Field Lines — adjustable in the browser or at runtime.

How do I add Magnetic Field to my website?

Download the standalone file at https://prism.tappypotato.com/fx/magnetic-field.html and copy its source into your page, or embed it as a background iframe: <iframe src="https://prism.tappypotato.com/fx/magnetic-field.html" style="position:fixed;inset:0;width:100%;height:100%;border:0;z-index:-1" title="Magnetic Field"></iframe>. Tune it live with postMessage, e.g. iframe.contentWindow.postMessage({ type: 'param', name: 'WAVE_SPEED', value: 1 }, '*').