Ana içeriğe geç

3D Viewer

npm version

You have two options for web integrations. The first option provides both a 3D view and an AR button, while the second option goes directly into AR inside the phone camera.

For the time being, AR is only available on mobile devices because it requires a back camera to operate. In both options; when users try to open AR on the desktop, a popup window guides the user to their phone with a QR code.

1: Viewer & AR SDK

bundle size

Install

The <artlabs-viewer> web component can be used directly from either unpkg.com, npm or artlabs cdn

You'll need to paste script code before closing </body> tag of your web page

<script
type="module"
src="https://unpkg.com/artlabs-viewer/dist/artlabs-viewer.min.js"
data-artlabs-key="YOUR_API_KEY"
></script>
uyarı

Make sure to replace YOUR_API_KEY with your API key.

Usage

After initialized, on a specific product page, call SDK with product identifier. (SKU)

<artlabs-viewer sku="YOUR_SKU" />

SDK will do the rest.

Options

NameDefaultDescription
skurequiredSKU of your product. Identifier for 3D assets.
width100%CSS width of parent component. Accepts px, em, rem, vw.
height300pxCSS height of parent component. Accepts px, vh, vw.
auto-rotatefalseShould model rotate automatically.
disable-interaction-promptfalseDisables the interaction prompt that appears when the model is loaded.
show-zoom-buttonsfalseShows zoom controls.
revealautoDetermines when to load and reveal 3D model. Values;
auto As soon as model loaded.
interaction Reveals model after first user interaction
manual the model will remain hidden until dismissPoster() is called.
confignullConfiguration object for additional settings.
extranullExtra product information such as price, description to be displayed in AR banner. Required if show-banner enabled.
show-bannerfalseShould show a banner with Add to Cart button in iOS AR.
banner-typedefaultType of iOS AR banner. Possible values are default, custom and apple-pay. Apple Pay includes a checkout with Apple Pay button.
show-dimensionsfalseShould show the dimensions of model in centimeters.
custom-dimensionsnullCustom dimensions for the model, if different from default.
show-wireframefalseDisplays the model in wireframe mode.
viewer-stylenullObject to customize the viewer's style.
disable-arfalseDisables AR mode, hides View in AR button.
disable-posterfalseDisables the poster image that appears before the model is loaded.
disable-zoomfalseDisables zoom functionality.
show-annotationsfalseEnable model annotations.

Methods

NameDescription
dismissPosterMeant to use with reveal='manual'. Dismisses the poster image and loads 3D model

Example;

const artlabsViewer = document.getElementById('artlabs-viewer');
artlabsViewer.dismissPoster();

Events

Some events can be listened to. You can register an event listener using addEventListener method.

Added to Cart

When user clicks the Add to Cart button in AR banner, this event will be fired with SKU.

const artlabsViewer = document.querySelector('artlabs-viewer');
artlabsViewer.addEventListener('add-to-cart', (e) => {
// Add product to cart
console.log(e.detail.sku);
});

Full Example

<head>
<script
type="module"
src="https://unpkg.com/artlabs-viewer/dist/artlabs-viewer.min.js"
data-artlabs-key="YOUR_API_KEY"
></script>
</head>

<body>
<artlabs-viewer
sku="Nike-Air-Max-90"
height="500px"
show-banner
banner-type="default"
extra='{"price": "$500", "description":"White, Essential"}'
></artlabs-viewer>
</body>

<script>
const artlabsElement = document.querySelector('artlabs-viewer');
artlabsElement.addEventListener('add-to-cart', (e) => {
console.log('Product added to cart :: ', e.detail.sku);
});
</script>

Bundle Size

bundle size

artlabs-viewer loads progressively. Initial load is very small, around 20kb. As the browser requires, it will load additional assets.