Lenticular and scanimation
I wanted to know if one WebGL 2 canvas could interlace three live HTML cards behind simulated cylindrical lenticules or a sliding Scanimation barrier grid, flip cleanly between them as you tilt or drag, and switch updateElementGeometry() plus inert so only the visible layer takes clicks, typing and Tab focus.
Drag left or right across the sheet to tilt the lenticules or slide the Scanimation acetate, or tap the angle presets above. Controls inside whichever card faces you remain clickable and typeable. Turn on Magnify loupe and drag the circular ring to inspect the interlaced strips up close.
Show the code Three drawable cards, ElementGL multi-texture upload, lenticular and Scanimation shader, authority handoff and phone tilt
- Three live
drawablecards inside one canvas. Layers A, B and C sit inside one<canvas content="drawable" layoutsubtree>; hidden layers carryinertso Tab focus skips them. - One WebGL 2 context through
ElementGL. On eachpaintevent, the changed cards upload viastage.upload()(gl.texElementSubImage2D()) into three textures, then one quad pass binds all three texture units. - Lenticular micro-prism and Scanimation barrier-grid fragment shader. Lenticular mode refracts through vertical cylindrical ridges with Fresnel highlights, cross-talk ghosting and slight RGB dispersion. Scanimation mode interlaces vertical strips of A, B and C beneath a sliding 1/3-slit black acetate sheet, and both modes share the 4.5x magnify loupe.
- Hit-test and focus handoff via
updateElementGeometry()andinert. Whichever card exceeds 50% optical weight getsinert = falseand aDOMMatrixscaled bygeometryUnit(); hidden layers move off-canvas and turninert = true. - Opt-in phone tilt through
DeviceOrientationEvent. Nothing prompts on load. Pressing Use phone tilt requests permission only where iOS requires it, zeroes on your firstgammaangle, and falls back with a note if no orientation events arrive.
How it works
A physical lenticular print laminates an array of vertical cylindrical lenses over an interlaced image so your left-to-right viewing angle selects a different strip behind each rib. A Scanimation sheet produces the same flip without refraction: it prints vertical strips of three frames side by side and slides a black striped acetate grid (1/3 clear slits, 2/3 opaque bars) across them by a couple of pixels.
Here all three interactive HTML cards live as drawable children inside one <canvas content="drawable" layoutsubtree> backed by one ElementGL WebGL 2 context (/lib/element-gl.js). Whenever you type in Layer A's note field, drag Layer B's exposure slider or flip Layer C into Japanese, Chromium fires a paint event and I re-upload the changed card with gl.texElementSubImage2D(). Tilting or sliding doesn't mutate the DOM, so dragging runs purely in the fragment shader with zero texture re-uploads.
Three stacked drawable elements would fight over pointer events and keyboard Tab stops if all three stayed active at once. After every angle or acetate change, I calculate the optical weights for A, B and C. If one layer crosses 50%, that card gets inert = false and its exact card transform (scaled by geometryUnit() from /lib/surface.js) passed to canvas.updateElementGeometry(), followed by toggling dataset.hitTick to clear Chromium's hit-test cache. The other two layers get inert = true and move to (-100000, -100000) so clicks, focus and text selection always stay on the facing interface. Right on a 50/50 transition seam, all three layers turn inert until one wins.
Live checks
These checks build isolated fixtures on testStage() and never touch the visible sheet or request sensor permissions.
Findings
- Not verified yet in a live Chromium 157 or Android Chrome 159 run: syntax, graphics rules and writing rules pass locally; run the tap-gated checks above to measure live results on your browser.
- Uploading three distinct
drawablechildren through oneElementGLcontext works by callingstage.upload()for each card (resettingTEXTURE0first so extra texture units don't collide) and binding Layers B and C toTEXTURE1andTEXTURE2insidestage.quad()'s uniform callback. - Setting
inert = trueand pushing hidden layers off-canvas withupdateElementGeometry()keeps Tab focus andelementsFromPoint()locked onto the visible layer without usingdisplay: none, so off-angle layers still paint and stay warm as textures for smooth cross-talk transitions. - In Scanimation mode, sliding the 1/3-slit acetate grid by one third of the pitch period (3 CSS px at a 9 px pitch) swaps 100% of the visible slit area from Layer A to Layer B to Layer C while sharing the same 50% authority threshold.