- Docs
- Build with the SDK
The overlay: the interface above the camera
The camera always fills the screen. Above it is plain HTML that you can change, extend or replace. It adapts to phones, tablets and laptops, in portrait and landscape.
The built-in overlay has a capsule of seven icon buttons on the right (info, reload, share, resize, reposition, rotate, quit), a "point the camera at the image" prompt, a message line, and an info panel. Labels: when the page loads, every button shows its text so people learn what it does (about five seconds, or until the first tap); a tap then shows the text of that button for a moment, and with a mouse a label shows on hover. Choose with buttonLabels: 'intro' | 'always' | 'never' (introMs, tapLabelMs set the times). Resize cycles the content 1x, 1.5x, 2x, 0.5x. Rotate turns it a quarter turn in the plane of the image. Reposition puts both back.
Bring your own. Write a block of HTML with the class tx-overlay. Its direct children go in slots. Attributes do the work:
<div id="my-ui" class="tx-overlay">
<div data-tx-slot="top-left">Score <b data-tx-bind="score">0</b></div>
<div data-tx-slot="center" data-tx-show="scanning">Find the poster</div>
<div data-tx-slot="bottom">
<button class="tx-cta" data-tx-show="found" data-tx-action="play">Play</button>
</div>
</div>
| Attribute | Meaning |
|---|---|
data-tx-slot="top-left, top-right, center, bottom" | Where a block goes. |
data-tx-action="info, close, share, reload, exit, fullscreen, scale, rotate, reposition" | A built-in button. Any other name is yours: the click is reported. |
data-tx-show="loading scanning found lost error" | The element is visible only in those states. |
data-tx-bind="name" | Text filled by overlay.set('name', value). message shows loading and error texts. |
data-tx-modal="info" | A panel opened by data-tx-action="info" or overlay.open('info'). |
Use it: A-Frame tempusxr="overlay: #my-ui", Three.js create({ overlay: document.getElementById('my-ui') }). From code: overlay.toast('+50') (a floating text), overlay.set('score', 12), overlay.open('info'), overlay.on('action', handler).
Theme with CSS variables on the overlay: --tx-accent, --tx-bg, --tx-rail-bg, --tx-danger, --tx-border, --tx-radius, --tx-font, --tx-text. The A-Frame example has a ready custom overlay: open it with ?ui=custom.