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.

10 cards ยท 0 matches

Starting Three.js WebGL scene...

Show the code HTMLSurfaces cards, CSS.highlights search ranges and live check
  1. One Three.js canvas with drawable cards. HTMLSurfaces moves each card into the canvas as a drawable child and uploads it via texElementSubImage2D().
  2. Custom highlight pseudo-element. ::highlight(graph-match) paints yellow marks over matched Range objects without mutating text nodes.
  3. Range search and texture invalidation. Walks cached Text nodes per card, sets CSS.highlights and calls surfaces.invalidate() so every 3D texture repaints.
  4. 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