@plattar/plattar-ar-adapter 1.138.1 → 1.139.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,18 @@
1
1
  import { LauncherAR } from "./launcher-ar";
2
+ export interface SceneVariationSelection {
3
+ readonly sceneProductID?: string;
4
+ readonly productID?: string;
5
+ readonly variationID?: string;
6
+ }
2
7
  /**
3
8
  * Performs AR functionality related to Plattar Scenes
4
9
  */
5
10
  export declare class SceneAR extends LauncherAR {
6
11
  private _analytics;
7
12
  private readonly _sceneID;
13
+ private readonly _variationSelection;
8
14
  private _ar;
9
- constructor(sceneID?: string | undefined | null);
15
+ constructor(sceneID?: string | undefined | null, variationSelection?: SceneVariationSelection | undefined | null);
10
16
  get sceneID(): string;
11
17
  private _SetupAnalytics;
12
18
  /**
@@ -16,7 +16,7 @@ const launcher_ar_1 = require("./launcher-ar");
16
16
  * Performs AR functionality related to Plattar Scenes
17
17
  */
18
18
  class SceneAR extends launcher_ar_1.LauncherAR {
19
- constructor(sceneID = null) {
19
+ constructor(sceneID = null, variationSelection = null) {
20
20
  super();
21
21
  // analytics instance
22
22
  this._analytics = null;
@@ -24,6 +24,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
24
24
  throw new Error("SceneAR.constructor(sceneID) - sceneID must be defined");
25
25
  }
26
26
  this._sceneID = sceneID;
27
+ this._variationSelection = variationSelection || {};
27
28
  this._ar = null;
28
29
  }
29
30
  get sceneID() {
@@ -67,9 +68,25 @@ class SceneAR extends launcher_ar_1.LauncherAR {
67
68
  // add our scene products
68
69
  sceneProducts.forEach((sceneProduct) => {
69
70
  const product = sceneProduct.relationships.find(plattar_api_1.Product);
70
- if (sceneProduct.attributes.include_in_augment && product && product.attributes.product_variation_id) {
71
- configurator.addSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
72
- totalARObjectCount++;
71
+ const selection = this._variationSelection;
72
+ // we have a specific product selection
73
+ if (sceneProduct.attributes.include_in_augment) {
74
+ // check if this product is the one we want (from selection optionally)
75
+ if (product && (product.id === selection.productID) && selection.variationID) {
76
+ configurator.addSceneProduct(sceneProduct.id, selection.variationID);
77
+ totalARObjectCount++;
78
+ }
79
+ else if (product) {
80
+ // check if this scene-product is the one we want (from selection)
81
+ if ((sceneProduct.id === selection.sceneProductID) && selection.variationID) {
82
+ configurator.addSceneProduct(sceneProduct.id, selection.variationID);
83
+ totalARObjectCount++;
84
+ }
85
+ else if (product.attributes.product_variation_id) {
86
+ configurator.addSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
87
+ totalARObjectCount++;
88
+ }
89
+ }
73
90
  }
74
91
  });
75
92
  // add our scene models
@@ -49,12 +49,24 @@ class VTOController extends plattar_controller_1.PlattarController {
49
49
  // optional attributes
50
50
  const configState = this.getAttribute("config-state");
51
51
  const showAR = this.getAttribute("show-ar");
52
+ const productID = this.getAttribute("product-id");
53
+ const sceneProductID = this.getAttribute("scene-product-id");
54
+ const variationID = this.getAttribute("variation-id");
52
55
  if (configState) {
53
56
  dst += "&config_state=" + configState;
54
57
  }
55
58
  if (showAR) {
56
59
  dst += "&show_ar=" + showAR;
57
60
  }
61
+ if (productID) {
62
+ dst += "&product_id=" + productID;
63
+ }
64
+ if (sceneProductID) {
65
+ dst += "&scene_product_id=" + sceneProductID;
66
+ }
67
+ if (variationID) {
68
+ dst += "&variation_id=" + variationID;
69
+ }
58
70
  viewer.setAttribute("url", opt.url || dst);
59
71
  viewer.onload = () => {
60
72
  return accept(viewer);
@@ -86,12 +98,24 @@ class VTOController extends plattar_controller_1.PlattarController {
86
98
  // optional attributes
87
99
  const configState = this.getAttribute("config-state");
88
100
  const showAR = this.getAttribute("show-ar");
101
+ const productID = this.getAttribute("product-id");
102
+ const sceneProductID = this.getAttribute("scene-product-id");
103
+ const variationID = this.getAttribute("variation-id");
89
104
  if (configState) {
90
105
  viewer.setAttribute("config-state", configState);
91
106
  }
92
107
  if (showAR) {
93
108
  viewer.setAttribute("show-ar", showAR);
94
109
  }
110
+ if (productID) {
111
+ viewer.setAttribute("product-id", productID);
112
+ }
113
+ if (sceneProductID) {
114
+ viewer.setAttribute("scene-product-id", sceneProductID);
115
+ }
116
+ if (variationID) {
117
+ viewer.setAttribute("variation-id", variationID);
118
+ }
95
119
  viewer.onload = () => {
96
120
  return accept(viewer);
97
121
  };
@@ -194,7 +218,14 @@ class VTOController extends plattar_controller_1.PlattarController {
194
218
  // otherwise no config-state or viewer is active
195
219
  // fallback to using default SceneAR implementation
196
220
  if (sceneID) {
197
- const sceneAR = new __1.SceneAR(sceneID);
221
+ const productID = this.getAttribute("product-id");
222
+ const sceneProductID = this.getAttribute("scene-product-id");
223
+ const variationID = this.getAttribute("variation-id");
224
+ const sceneAR = new __1.SceneAR(sceneID, {
225
+ productID: productID ? productID : undefined,
226
+ sceneProductID: sceneProductID ? sceneProductID : undefined,
227
+ variationID: variationID ? variationID : undefined
228
+ });
198
229
  sceneAR.init().then(accept).catch(reject);
199
230
  return;
200
231
  }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.138.1";
1
+ declare const _default: "1.139.2";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = "1.138.1";
3
+ exports.default = "1.139.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.138.1",
3
+ "version": "1.139.2",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "@babel/preset-env": "^7.19.4",
50
50
  "browserify": "^17.0.0",
51
51
  "typescript": "^4.8.4",
52
- "uglify-js": "^3.17.3"
52
+ "uglify-js": "^3.17.4"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"