Searchable 3D graph of HTML cards
I wanted to know if the CSS Custom Highlight API (CSS.highlights) can paint substring search matches straight into 3D WebGL card textures without rewriting DOM spans, while buttons and checkboxes inside each card stay clickable. Type a query such as geometry, paint or texture, drag to orbit, or switch layout.
Show the code HTMLSurfaces cards, CSS.highlights search ranges and live check
- One Three.js canvas with drawable cards.
HTMLSurfacesmoves each card into the canvas as adrawablechild and uploads it viatexElementSubImage2D(). - Custom highlight pseudo-element.
::highlight(graph-match)paints yellow marks over matchedRangeobjects without mutating text nodes. - Range search and texture invalidation. Walks cached
Textnodes per card, setsCSS.highlightsand callssurfaces.invalidate()so every 3D texture repaints. - 3D force and geometric layouts. Relaxes connected topic cards in 3D space while
surfaces.update()keeps projected hit boxes aligned with front-facing cards.
How it works
This experiment takes inspiration from ianTPE's searchable 3D graph (WICG #192).
Ten ordinary HTML <article> cards live in the page initially so the document works as plain markup if HTML-in-canvas or WebGL is missing.
When the browser supports both, Three.js renders each card onto a double-sided plane via HTMLSurfaces from /lib/html3d.js, connected by 3D lines representing shared concepts.
Typing in the search box walks a cached list of Text nodes collected with TreeWalker, finds every matching substring, builds Range objects and registers a single Highlight named graph-match in CSS.highlights.
Because CSS.highlights draws visual highlights during paint without altering DOM nodes, the cards never lose focus or rebuild their markup.
Calling surfaces.invalidate() flags all cards dirty and triggers canvas.requestPaint(), pushing updated textures with yellow highlights straight into the 3D scene while surfaces.update() syncs updateElementGeometry() so card buttons and checkboxes stay clickable.
Live checks
These checks wait for a tap so the page keeps one WebGL context until requested. Each check runs inside its own isolated fixture on the test stage and retires its canvas afterwards.
Findings
- Measured in Chrome Canary
161.0.8200.0on 2026-12-04 at412x915(DPR2.625, SwiftShader WebGL): all 6 live checks passed with zero JS errors, zero lost contexts, zero open snapshots and zero horizontal overflow on a756x900canvas (10.4 MB). - Searching via
CSS.highlights.set()changed yellow::highlight(graph-match)texture pixels from0(maxY=0) to1589(maxY=153) without inserting DOM spans, then dropped back to0after deleting the highlight entry. - Interactive buttons inside tilted 3D cards received pointer clicks cleanly (
elementsFromPoint(168, 677)hit the button and fired its handler), while toggling focus kept ring coordinates at0drift and toggling reduced motion paused and resumed cleanly.