Skip to Content

Embed the viewer

Show the 3D viewer and AR on your product page with one script and one tag, keyed on the same article number you send us.

Product page
<script src="https://js.charpstar.net/V2/charpstAR-Base.js" data-client="YourCompany" defer></script>
<charpstar-viewer data-articleid="CH-1001"></charpstar-viewer>
Resultlive from our Demo companyOpen
The viewer the snippet puts on your page, shown here through its hosted link. Drag to turn the model.
  • data-client is your company's delivery name. It is in every delivered asset as embed.dataClient, and it is the same on every page of your shop.
  • data-articleid is the article number, exactly as you sent it in articleId.
  • Until a product is delivered, the tag shows nothing: no empty box, no error. Once it is delivered, the viewer shows up by itself, with a button to see it in AR.
  • On a phone, AR opens in the phone's own AR view. On a computer, visitors get a QR code to open it on their phone.
  • When a visitor picks another variant, change data-articleid and the viewer switches without reloading the page.

Prefer buttons on top of your existing product image? Use the AR and 3D buttons instead of the inline viewer. The full guide follows.

The script

Add the CharpstAR script anywhere in your product page. We recommend placing it just before the closing </body> tag. The same script powers both options below.

<script src="https://js.charpstar.net/V2/charpstAR-Base.js" data-client="YourCompany" data-language="en-gb" defer></script>

Safe to add to every page. If a product is not available in 3D yet, the viewer or buttons hide themselves, so there is no broken UI on products that are not ready.

Configuration

The script tag takes two attributes that apply to the whole site. Set them once on the script tag.

AttributeRequiredDescription
data-clientRequiredIdentifies your company. Your value is in every delivered asset as embed.dataClient.
data-languageOptionalLanguage of the QR code popup that desktop visitors see when they open AR. Defaults to en-gb. Supported values: en, en-gb, en-us, sv-se, sv, no, no-no, nb-no, da-dk, de-at, de-de, fi-fi, es, it-it.

Two ways to show it

Both options work with the single script tag above. Pick whichever fits your product page.

Option 1: AR and 3D buttons

The simplest way. Two compact buttons sit on top of your existing product image. View in AR opens AR straight away. View in 3D opens the viewer in a popup with Dark Mode and Dimensions controls.

Place the snippet inside the wrapper that holds your product image. Give the wrapper position: relative so the buttons can sit in one of its corners.

<charpstar-container data-articleid="YOUR_ARTICLE_ID" data-position="top-right" style="display: none">
  <button data-tech="charpstar-ar">View in AR</button>
  <button data-tech="charpstar-3d">View in 3D</button>
</charpstar-container>

Keep style="display: none" on the container. Our script shows it only once it knows the product is available, so the buttons never flash on first paint.

You can keep just one of the two buttons. For example, leave out the 3D button to offer AR only.

AttributeRequiredDescription
data-articleidRequiredThe product's article number. The container hides itself if there is no 3D model for it.
data-positionOptionalWhere the buttons sit on the product image. Defaults to top-right. Accepted values: top-left, top-right, bottom-left, bottom-right.
data-tech="charpstar-ar"On AR buttonMarks the child <button> as the AR button.
data-tech="charpstar-3d"On 3D buttonMarks the child <button> as the 3D button.

Option 2: Inline 3D viewer

An interactive 3D viewer right on the product page, with Dark Mode, Dimensions and View in AR built in. Best when 3D is the main product visual.

The viewer fills its parent's width and height, so wrap it in a block sized like your product image.

<charpstar-viewer data-articleid="YOUR_ARTICLE_ID"></charpstar-viewer>
AttributeRequiredDescription
data-articleidRequiredThe product's article number. The viewer hides itself if there is no 3D model for it.

JavaScript API

To show your own UI only for products that have 3D (a "View in 3D" badge elsewhere on the page, a different gallery layout, or your own fallback), check first:

charpstAR.checkIfExists(articleId)

Returns a promise that resolves to true if there is a 3D model for the article, and false otherwise.

const has3D = await window.charpstAR.checkIfExists("YOUR_ARTICLE_ID");

if (has3D) {
  // Show your "View in 3D" badge, swap your gallery layout, etc.
}
ParameterTypeDescription
articleIdstringThe article number you want to check.

Returns: Promise<boolean>

Wait for the script to load before you call it. With defer, that is any time after DOMContentLoaded. The function never throws: network errors resolve to false.

Behaviour

Hides itself when a product has no 3D

Both <charpstar-viewer> and <charpstar-container> check whether the article has a 3D model before they show anything. If it does not, the element stays hidden: no error message, no broken UI. So it is safe to put the snippet in every product page template.

Several on one page

You can place several viewers, several button containers, or a mix on the same page. Each one works on its own: opening the 3D popup on one card does not affect any other card.

Live article updates

Both elements follow changes to data-articleid. When a visitor picks another variant in your page, change the attribute and the viewer or buttons switch to the new article without reloading the page.

// Switch to a different product variant
document.querySelector("charpstar-viewer")
  .setAttribute("data-articleid", "NEW_ID");

Device support

"View in AR" picks the right experience for each device:

DeviceAR experience
iPhone and iPadAR Quick Look (built in on iOS 12 and later)
Android phone or tabletScene Viewer (Android 8.0 and later, with ARCore 1.9 or later)
ComputerA QR code popup: the visitor scans it to continue on a phone

The 3D viewer (inline or in the popup) works in all current browsers on computers and phones: Chrome, Safari, Firefox and Edge.

Shopify

In your theme editor, add a Custom Liquid block to the product template:

{%- assign cs_article = product.selected_or_first_available_variant.sku -%}
{%- if cs_article != blank -%}
<script src="https://js.charpstar.net/V2/charpstAR-Base.js" data-client="YourCompany" defer></script>
<charpstar-viewer data-articleid="{{ cs_article | escape }}" style="display:block;width:100%;height:480px"></charpstar-viewer>
{%- endif -%}

This works when your SKU is the same article number you send us.

On this page