3D Tilt View DOM layer inspector
I wanted to see if HTML-in-canvas could rebuild Mozilla's old Firefox 3D Tilt View (Victor Porof, Firefox 11 to 46) and Microsoft Edge's 3D View panel, with one extra twist: every tilted plane stays interactive.
This experiment builds on /structure-depth/ and /layout-debug/ by lifting five drawable layers of a live mini app into an exploded WebGL 2 stack.
Drag the dark background to orbit, slide layer spacing from 0 px to 90 px, and click buttons, edit the title, toggle filters or drag across the article paragraphs right inside the tilted stack.
Drag background to orbit · tap any tilted control
Show the code 5 drawable layers, 3D projection, extruded slabs, hit geometry and 2D fallback
- The five layers inside one canvas. Each depth level is its own
drawableelement aligned to one app footprint. - One 3D matrix per layer. The same
DOMMatrixdrives WebGL clip space, the inspector's quad bounds andupdateElementGeometry(). - Coloured side slabs, wireframes and depth connectors. A small colour shader runs on
stage.glfromElementGLwith no second WebGL context. - The
painthandler. Uploads changed layers withstage.upload(), draws back to front, updates hit boxes and bumpsdataset.hitTick. - The 2D isometric fallback. When WebGL 2 isn't available, the same five layers draw with five-argument
drawElementImage().
How it works
Firefox's classic 3D Tilt View (written by Victor Porof for Firefox 11 to 46) and Edge's 3D View panel both lift DOM depth into WebGL meshes, though those tools draw snapshots that you inspect rather than use.
Here I put five separate drawable elements inside one <canvas content="drawable" layoutsubtree> and align their local coordinates to one shared app footprint.
At 0 px spacing and 0° tilt they sit flush as a single interface; as spacing grows they separate along Z.
One ElementGL instance owns the page's single WebGL 2 context.
Its built-in textured-quad shader draws each layer from texElementSubImage2D(), and a small companion colour shader on the same stage.gl draws the extruded side-thickness slabs, wireframe outlines and vertical corner connectors from each layer down to z = 0.
Because all five planes are parallel in local space, drawing from layer 0 up to layer 4 gives exact painter's order with no depth-buffer fighting.
Every visible layer receives its exact 3D DOMMatrix via canvas.updateElementGeometry(el, { canvasTransform }), followed by updating el.dataset.hitTick whenever the transform changes so Chromium clears its hit-test cache.
When you turn on Solo selected layer, the other four layers are marked inert and parked off-stage at a scale of 0.001 so clicks and text selection pass straight through to the soloed plane.
If WebGL 2 isn't available, the page falls back to a 2D isometric stack using five-argument drawElementImage(), and if HTML-in-canvas isn't available at all it moves the five elements into a plain HTML stack.
Live checks
These checks wait for a tap so the demo starts with one GPU context. Each check builds its own small fixture on the test stage and retires its canvas when finished.
Findings
Not verified in a live browser yet. Run the live checks above in Chromium with #canvas-draw-element enabled to record results for your device.
- Inspirations and credits: Mozilla's Firefox 3D Tilt View (Victor Porof, Firefox 11 to 46), Microsoft Edge's 3D View DevTools panel, and the depth and layout experiments at /structure-depth/ and /layout-debug/ on this site.
- One WebGL context for both DOM textures and 3D overlays: sharing
stage.glfromElementGLlets the colour-slab program and the element-quad program draw into the same framebuffer without creating a second WebGL context. RestoringElementGL's program and VAO after each slab draw keepsstage.quad()intact. - Clip-space Z zeroing:
DOMMatrixkeeps Z in CSS pixels while WebGL clips outside[-w, w]. Zeroing row 3 (m13,m23,m33,m43) of the clip matrix after multiplying in perspective keeps exactx/wandy/wprojection with no near/far clipping. - Solo layer hit routing: parking hidden layers with
updateElementGeometry()atscale(0.001)and settinginert = truekeeps upper layers from intercepting taps aimed at Layer 0 or Layer 1. - Not verified: live WebGL rendering, native
<select>popup placement on a tilted plane, text selection drag handles inside a perspective-transformed layer, and real Android touch orbiting at 412 px and DPR 2.625.