Web Components

Published Updated
Framework-agnostic custom HTML elements for embedding Aircada 3D configurators with Shadow DOM isolation.

The Aircada Web Component package registers the <air-viewer> custom element for embedding interactive 3D scenes into Shopify, WooCommerce, Magento, and static HTML pages without React or bundler dependencies.

<air-viewer> Web Component & PostMessage Bridge | Aircada Docs#

Embeds Aircada 3D scenes via <air-viewer> using Shadow DOM isolation, GPU hibernation, and postMessage.

Encapsulated Custom Element Architecture

AirViewerElement registers <air-viewer> via customElements.define('air-viewer', AirViewerElement) with Open Shadow DOM encapsulation and native Declarative Shadow DOM (DSD) support. Host storefront stylesheets cannot bleed into 3D overlays, HUD controls, option drawers, or initial loading indicators.

Viewport GPU Hibernation

When lazy or unload-when-hidden is enabled, an IntersectionObserver monitors the host element bounds. Scrolling <air-viewer> out of the viewport suspends active WebGL/WebGPU rendering and releases idle GPU buffers so multi-viewer product pages stay under mobile VRAM ceilings.

Bidirectional PostMessage Bridge

AircadaEmbedder and airStudioBridge exchange typed CommandTypeIn and CommandTypeOut messages between the host page and the viewer runtime. Hosts push option updates or camera commands and listen for onSetupComplete, onReady, onOptionChanged, onPriceChanged, and onSnapshotCaptured, using explicit domain whitelists instead of wildcard targetOrigin values in production.

Runtime Attributes & Events
NameKindPurpose
smart-idAttribute (string)Identifies the published Aircada 3D project to hydrate.
lazyAttribute (boolean)Defers engine initialization until the element enters the viewport.
unload-when-hiddenAttribute (boolean)Disposes GPU resources when the element leaves the viewport.
devPortAttribute (number)Connects to a local CLI dev server port during development.
onOptionChanged / onPriceChangedOutbound EventNotifies the host storefront when selections or prices update.
onSnapshotCapturedOutbound EventDelivers rendered 3D proof image payloads for cart attachment.
embed.html (html)
<air-viewer
  smart-id="your-project-smart-id"
  lazy
  unload-when-hidden
></air-viewer>

<script type="module">
  const viewer = document.querySelector("air-viewer");
  window.addEventListener("message", (event) => {
    if (event.data?.type === "onPriceChanged") {
      console.log("Updated price:", event.data.payload);
    }
  });
</script>
Embed <air-viewer> with lazy viewport hydration and listen for option/price updates.