1.2.7 • Published 13 hours ago

artlabs-experience v1.2.7

Weekly downloads
-
License
MIT
Repository
-
Last release
13 hours ago

artlabs Experience SDK

artlabs Experience is the SDK for artlabs platform to enhance web applications with Augmented Reality (AR) and Virtual Try-On (VTO) capabilities. This library integrates various modules to provide a seamless experience in product visualization and interaction.

Installation

Via NPM

Install the ES module using npm:

npm install artlabs-experience

Via Script Tag

You can directly UMD build to your HTML page:

<script src="https://unpkg.com/artlabs-experience/dist/artlabs-experience.umd.js"></script>

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

Usage

To start using the library, you must import the ArtlabsExperience module in your JavaScript file:

import ArtlabsExperience from 'artlabs-experience';

Or, if you're using named exports:

import { init, startAR } from 'artlabs-experience';

If you're using the UMD build, you can access the library via the global ArtlabsExperience object:

Then initialize the library with your token. It's a zero-config by default, but you can pass your configuration options as well. You can join the platform and get your API key at artlabs.ai.

ArtlabsExperience.init({
  token: 'YOUR_TOKEN_HERE',
});

Config

To initialize the ArtlabsExperience library with custom settings for the Augmented Reality (AR) and Virtual Try-On (VTO) experiences, pass the configuration options as shown in the example below. Modify the options to suit your application's requirements:

Common Config

OptionDefault ValueDescription
localeenSets SDK language. Accepts ISO language codes. Available locales are; en, de, fr, es, it, nl, no

AR Configuration Options

OptionDefault ValueDescription
debugModefalseEnables additional logging for debugging purposes.
showBannerfalseControls the visibility of a banner in the AR experience.
bannerType'default'The type of banner displayed in the AR experience.
bannerButtonText'Add to Cart'The type of banner displayed in the AR experience.

VTO Configuration Options

OptionDefault ValueDescription
debugModefalseEnables additional logging for debugging purposes.
fontFamily'inherit'The font family used in the VTO experience interface.
disableUIfalseIf true, the default user interface for VTO will be disabled.
showActionfalseControls the visibility of action buttons in the VTO experience.
logoUrlfalseURL of the logo to be displayed in the VTO experience.
useWatermarkfalseDetermines whether a watermark is displayed in the VTO screenshot.

Example Config

ArtlabsExperience.init({
  token: 'YOUR_TOKEN_HERE',
  config: {
    locale: 'en',
    vto: {
      debugMode: false, // Set to true to enable debugging
      fontFamily: 'inherit', // Customize the font for the UI
      disableUI: false, // Set to true to disable the default UI
      showBanner: true, // Set to true to display a banner in VTO
      bannerButtonText: 'Add to Cart', // Customize the text for the banner button
      logoUrl: 'https://example.com/path/to/logo.png', // Provide a URL for your custom logo
      useWatermark: true, // Set to true to include a watermark in screenshots
    },
    ar: {
      debugMode: false, // Set to true to enable debugging
      showBanner: true, // Set to true to display a banner in the AR experience
      bannerType: 'default', // Specify a custom banner type
      bannerButtonText: 'Buy Now',
    },
  },
});

Starting AR and VTO Experiences

Invoke AR or VTO experiences with product SKUs and configuration:

// Start AR Experience
await ArtlabsExperience.startAR('PRODUCT_SKU', {
  // Optional product metadata to show in AR banner
  product: {
    title: 'Product Title',
    subtitle: 'Product Subtitle',
    price: '100$',
  },
});

// Start VTO Experience.
// You can pass multiple SKUs as comma separated string or a single SKU
await ArtlabsExperience.startVTO('PRODUCT_SKU1,PRODUCT_SKU2,PRODUCT_SKU3');

// Stop VTO Experience
await ArtlabsExperience.stopVTO();

// Change product in experience
await ArtlabsExperience.changeProduct('PRODUCT_SKU4');

Events

There are multiple events that can be listened to. You can register an event listener via invoking the addEventListener method.

ArtlabsExperience.addEventListener('event-name', callbackFunction);
ArtlabsExperience.removeEventListener('event-name', callbackFunction);

AR Events

  • ar-banner-click Triggered when a user clicks on the AR banner. This event is dispatched with an object containing the sku of the product and the productConfig.

VTO Events

  • vto-banner-click Triggered when a user clicks on the VTO banner. This event is dispatched with an object containing the sku of the product and the productConfig.
  • vto-load Emitted when the VTO experience begins loading. It signifies that the resources and assets for the VTO are being fetched and initialized.
  • vto-change-product Dispatched when there is a change in the product displayed during the VTO experience, allowing for dynamic updating of the product being tried on.
  • vto-error Fired when an error occurs within the VTO experience. It sends a message detailing the error, which can be used for debugging or user feedback.
  • stop-vto Sent out when the VTO experience is terminated, either by user action or programmatically.

Checking for AR and VTO Availability

Sometimes you may want to check if the current product has enabled AR or VTO experiences so you can show/hide relevant buttons. You can do that by invoking the checkAvailability method.

const availabilityResult = await ArtlabsExperience.checkAvailability('SKU1,SKU2,SKU3');

// availabilityResult will be an object with the following properties:
// {
//   SKU1: {
//     ar: true,
//     vto: true,
//   },
//   SKU2: {
//     ar: false,
//     vto: false,
//   },
//   SKU3: {
//     ar: true,
//     vto: false,
//   },
// }
1.2.7

13 hours ago

1.2.6

9 days ago

1.2.5

13 days ago

1.2.4

15 days ago

1.2.3

17 days ago

1.2.2

1 month ago

1.2.1

1 month ago

1.2.0

1 month ago

1.1.20

1 month ago

1.1.19

1 month ago

1.1.14

2 months ago

1.1.18

2 months ago

1.1.17

2 months ago

1.1.12

2 months ago

1.1.13

2 months ago

1.1.11

2 months ago

1.1.10

2 months ago

1.1.9

2 months ago

1.1.8

2 months ago

1.1.6

3 months ago

1.1.4

3 months ago

1.1.3

3 months ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.18

3 months ago

1.0.17

3 months ago

1.0.15

3 months ago

1.0.14

3 months ago

1.0.13

3 months ago

1.0.12

3 months ago

1.1.1-CES

4 months ago

1.1.0-CES

4 months ago

1.0.11

4 months ago

1.1.0-beta.1

5 months ago

1.0.10

5 months ago

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago