3D Product Showcase
Interactive 3D .glb on your product page: 360° drag-to-rotate, AR on mobile, deferred loading and integrated CTA.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. 3D has 50 effects, including 8 free. Explore the category →
3 usage examples



How it works
The core component is a <model-viewer> tag (Custom Element registered by model-viewer.min.js) inside .p3d-scene. The camera-controls attribute enables drag-to-rotate (mouse or touch); auto-rotate starts automatic spin on load, with rotation-per-second="22deg"; auto-rotate-delay="0" removes the initial delay. disable-zoom blocks pinch gestures to avoid interfering with the page's vertical scroll; touch-action="pan-y" keeps native scrolling active on mobile.
model-viewer.min.js is an ES module (~530 KB) loaded on demand: an IntersectionObserver with rootMargin="200px" watches each [data-p3d] and injects the <script type="module"> tag as the scene approaches the viewport — then disconnects. A boolean flag loaded prevents double loading when multiple scenes coexist on the same page. On browsers without IntersectionObserver, the script is injected immediately on page load.
The ar attribute on <model-viewer>, combined with ar-modes="webxr scene-viewer quick-look", enables the AR button. On click, the script calls mv.activateAR(): WebXR first (Android Chrome 79+), then Scene Viewer (Android with Google Play Services), then Quick Look (iOS Safari 12+). The AR button (.p3d-ar) is a plain <button> positioned absolutely; it can be hidden if mv.canActivateAR is false.
The poster slot contains the loading state shown while the .glb is downloaded and parsed. --poster-color: transparent removes the slot's default white background. The attributes exposure="1.05", shadow-intensity="1" and camera-orbit="25deg 78deg 105%" set global lighting, contact shadow and initial camera position; field-of-view="30deg" reduces perspective distortion for a near-telephoto look.
Accessibility
- Keyboard navigation: model-viewer's
camera-controlsexposes a visible focus ring and accepts arrow keys (left/right: yaw rotation, up/down: elevation) to rotate the model — no extra ARIA needed. - Reduced motion: under
prefers-reduced-motion: reduce, the script removes theauto-rotateattribute before the first render — the 3D piece remains interactive and rotatable by drag, but automatic rotation is disabled. - Model description: the
altattribute on<model-viewer>is announced by screen readers in place of the visual render. The text should describe the product concisely (e.g. "Brushed-steel chronograph watch, 3D 360° view"). - AR button: the
.p3d-arbutton is a native<button type="button">; on browsers without AR (mv.activateARabsent), clicking has no visible effect. To hide it cleanly, listen to model-viewer'sar-statusevent or checkmv.canActivateARafter load. - No-WebGL fallback: the
posterslot guarantees a readable message when 3D rendering is unavailable (old browser, no GPU, permission denied). The.p3d-ctabutton remains accessible at all times as it lives outside the model-viewer component.
Browser compatibility
model-viewer uses WebGL (and WebGL 2.0 for some lighting effects) for rendering. The component is available as a Custom Element in all modern Chromium-based browsers. AR: WebXR (Chrome Android 79+), Scene Viewer (Android with Google Play Services), Quick Look (Safari iOS 12+). IntersectionObserver since Chrome 51, Firefox 55, Safari 12.1.
Without WebGL or network access, model-viewer stays on the poster slot screen — the loading message and CTA button remain visible. Without IntersectionObserver, the model-viewer script is loaded immediately instead of being deferred.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0809-root">
<div class="p3d-scene" data-p3d="">
<span class="p3d-badge">…</span>
<button type="button" class="p3d-ar" data-p3d-ar="">…</button>
<model-viewer class="p3d-mv" data-p3d-mv=""
src="/assets/models/watch.glb"
alt="…"
camera-controls="" auto-rotate="" auto-rotate-delay="0" rotation-per-second="22deg"
interaction-prompt="none" disable-zoom="" touch-action="pan-y"
shadow-intensity="1" exposure="1.05" camera-orbit="25deg 78deg 105%" field-of-view="30deg"
ar="" ar-modes="webxr scene-viewer quick-look">
<div class="p3d-poster" slot="poster" aria-hidden="true">
<span class="p3d-emoji">…</span>
<span>…</span>
</div>
</model-viewer>
<div class="p3d-overlay">
<div class="p3d-name">…</div>
<div class="p3d-price"><s>…</s>…</div>
<button type="button" class="p3d-cta">…</button>
</div>
<div class="p3d-hint" aria-hidden="true">…</div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
3D file — src attribute on <model-viewer> |
/assets/models/watch.glb | Replace with any .glb or .gltf file hosted on the same domain (or with CORS enabled). .usdz files are supported for iOS Quick Look via the ios-src attribute. Common 3D tools (Blender, Cinema 4D, Sketchfab) export to .glb. |
Promo badge — content of .p3d-badge |
−40% | Free text: discount rate, "New", "Exclusive"… Leave empty or remove the element to hide the badge. |
Rotation speed — rotation-per-second attribute |
22deg | Reduce to 8deg for a barely perceptible spin on an editorial page; increase to 40deg for a dynamic demo effect. |
Camera position — camera-orbit attribute |
25deg 78deg 105% | Three values: azimuth (rotation around vertical axis), elevation, distance. "0deg 90deg 100%" gives a neutral front view; "45deg 60deg 90%" a high diagonal perspective. |
Lighting — exposure and shadow-intensity attributes |
1.05 / 1 | exposure from 0.8 to 1.2 adjusts overall brightness. shadow-intensity from 0 to 2 controls the contact shadow on the floor (0 = no shadow). |
AR activation — ar attribute on <model-viewer> |
present | Remove the ar attribute to disable AR entirely and hide the .p3d-ar button. AR requires HTTPS; on HTTP the browser blocks it regardless of this attribute. |
Loading poster — poster slot |
⌚ emoji + "Loading 3D product…" | Replace with a high-resolution PNG or JPG of the product for immediate visual feedback before the .glb is ready. Prefer an image at the same aspect ratio as the model-viewer viewport. |
FAQ
src attribute on <model-viewer> accepts any .glb or .gltf file hosted on the same domain (or with CORS enabled). For AR on iOS, add a .usdz file via the ios-src attribute. Common 3D tools (Blender, Cinema 4D, Sketchfab) export to .glb.load event exposes mv.canActivateAR (boolean). Listen to that event and show or hide the button accordingly: mv.addEventListener('load', () => { arBtn.hidden = !mv.canActivateAR; }). AR also requires HTTPS, so the button can be hidden server-side based on the protocol.IntersectionObserver with rootMargin="200px" only triggers the model-viewer load when the scene approaches the visible viewport. If the visitor leaves the page without ever reaching the section, neither model-viewer.min.js (~530 KB) nor the .glb file is downloaded.