Polar clock-wipe and bow-tie sweep
I wanted to know if one ElementGL WebGL 2 canvas could sweep radially between two live HTML scenes behind a refracting glass leading arm, while keeping buttons and text inputs in both cards interactive. Drag around the centre dial to scrub from 0° to 360°, pick a blade pattern, or press Sweep.
Starting...
Show the code two drawable scenes, polar wipe shader, explicit tMs timing, sector hit sync and 2D wedge clip
- Two full-stage
drawablescenes inside one canvas.#cw-scene-aand#cw-scene-bplace buttons and editable<input>fields in the four radial quadrants around the stage centre. - Deterministic
tMssweep controller and polar membership. Drives single-hand, bow-tie and quad-iris angles using explicit timestamps so checks can verify midpoint timing and reduced-motion snaps. - Polar
atan()split and prism glass arm shader. Computes signed angular pixel distance across 1, 2 or 4 blades, bends UVs along a cylindrical bevel with RGB dispersion, and adds a bright leading-edge spine. - Sector-aware
updateElementGeometry()hit sync. CalibratesgeometryUnit(), togglesdataset.hitTick, and enablespointer-eventsonly on controls sitting inside the visible polar sectors. - Five-argument
drawElementImage()2D wedge clip fallback. Clips Scene B to 1, 2 or 4 polar wedges over Scene A and draws matching glass leading rays without WebGL 2.
How it works
Both cards (#cw-scene-a and #cw-scene-b) sit inside one <canvas content="drawable" layoutsubtree> driven by a single ElementGL WebGL 2 context from /lib/element-gl.js. I set gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true) when creating the context and again inside onRestored, wait for the first paint event before uploading either card, and always call stage.begin() ahead of stage.upload().
Inside CLOCK_FRAG, each fragment computes its clockwise angle from 12 o'clock with atan(d.x, -d.y) and wraps it into one period (360° for single hand, 180° for bow-tie dual blades, 90° for quad iris). The signed arc distance in pixels gives an anti-aliased boundary between the two textures, while pixels near the moving leading ray shift along the blade normal by a bevel slope and chromatic offset scaled by uRefract.
Because both cards cover the whole stage, I set pointer-events: none on the card containers and let syncGeometry() toggle inert and pointer-events per control based on whether its radial quadrant belongs to Scene A or Scene B at the current sweep angle. At 0° and 360°, the hidden card moves offstage via updateElementGeometry() and dataset.hitTick clears Chromium's hit-test cache. The animation loop pauses whenever IntersectionObserver or document.hidden marks the stage hidden. Without WebGL 2, draw2DFallback() clips Scene B into polar arcs over Scene A using 5-argument drawElementImage() calls, and on webglcontextlost both cards move into #plain-host side by side.
Live checks
Each check builds an isolated fixture on testStage() without touching the demo above. Press Run to test this browser.
Findings
- Measured in headless Chrome 160.0.8188.0 canary (2026-11-27, 412×915 viewport at 2.625 DPR, SwiftShader WebGL, plus 1024×900 at 1 DPR): all 6 live checks pass, the backing store stays at
994×987(0.98 MP,7.8 MBinitial,8.1 MBpeak during checks),scrollWidth === innerWidth === 412,0errors,0lost contexts,0open snapshots and0wrong-argumentdrawElementImage()calls. - Pixel readbacks in
readPixels()confirm exact polar sector cuts at90°(NE Midnight Express luminance20, NW Daylight Metro223, East glass arm peak255) and270°(SW20, NW223, West glass arm peak255), plus180°rotational symmetry in Bow-tie dual blades (NE20and SW20vs SE223) and45°quadrant splits in Quad Iris (20°=20vs70°=223). - With
pointer-events: noneon the full-stage scene containers and sector-awarepointer-eventsplusinerttoggled per control insidesyncGeometry(),elementsFromPoint()and pointer clicks at135°mid-sweep hit Scene B in NE (#b-btn-ne) and Scene A in NW and SW (#a-btn-nw,#a-input-sw), while0°and360°isolate each card completely. - Emulating
prefers-reduced-motion: reducemounts.motion-warn, checks#ctl-reducedand snapsSweepstraight to the target angle; restoring normal motion removes the notice cleanly. Both?route=2d(5-argumentdrawElementImage()wedge clip) and plain HTML (--disable-blink-features=CanvasDrawElement) pass with zero horizontal overflow. - Chrome 159 on Android (touch dial drag feel, GPU shader frame rates and on-screen keyboard focus in
#a-input-swand#b-input-se) andnpm run check:jank -- /clock-wipe/(Playwright isn't installed here) stay not verified.