@plattar/plattar-ar-adapter 1.130.3 → 1.131.1
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.
- package/build/es2015/plattar-ar-adapter.js +113 -20
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +84 -19
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/product-ar.d.ts +4 -2
- package/dist/ar/product-ar.js +24 -7
- package/dist/ar/scene-product-ar.d.ts +1 -1
- package/dist/ar/scene-product-ar.js +2 -2
- package/dist/embed/controllers/plattar-controller.js +4 -0
- package/dist/embed/controllers/product-controller.js +11 -2
- package/dist/embed/controllers/viewer-controller.js +31 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -172,7 +172,7 @@ const launcher_ar_1 = require("./launcher-ar");
|
|
|
172
172
|
* Performs AR functionality related to Plattar Products and Variation types
|
|
173
173
|
*/
|
|
174
174
|
class ProductAR extends launcher_ar_1.LauncherAR {
|
|
175
|
-
constructor(productID = null, variationID = null) {
|
|
175
|
+
constructor(productID = null, variationID = null, variationSKU = null) {
|
|
176
176
|
super();
|
|
177
177
|
// analytics instance
|
|
178
178
|
this._analytics = null;
|
|
@@ -180,7 +180,8 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
180
180
|
throw new Error("ProductAR.constructor(productID, variationID) - productID must be defined");
|
|
181
181
|
}
|
|
182
182
|
this._productID = productID;
|
|
183
|
-
this.
|
|
183
|
+
this._variationSKU = variationSKU;
|
|
184
|
+
this._variationID = variationID ? variationID : (variationSKU ? null : "default");
|
|
184
185
|
this._ar = null;
|
|
185
186
|
}
|
|
186
187
|
get productID() {
|
|
@@ -189,6 +190,9 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
189
190
|
get variationID() {
|
|
190
191
|
return this._variationID;
|
|
191
192
|
}
|
|
193
|
+
get variationSKU() {
|
|
194
|
+
return this._variationSKU;
|
|
195
|
+
}
|
|
192
196
|
_SetupAnalytics(product, variation) {
|
|
193
197
|
let analytics = null;
|
|
194
198
|
const scene = product.relationships.find(plattar_api_1.Scene);
|
|
@@ -237,14 +241,27 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
237
241
|
product.include(plattar_api_1.Scene.include(plattar_api_1.Project));
|
|
238
242
|
product.get().then((product) => {
|
|
239
243
|
// find the required variation from our product
|
|
240
|
-
const variationID = this.variationID ? (this.variationID === "default" ? product.attributes.product_variation_id : this.variationID) :
|
|
241
|
-
|
|
242
|
-
|
|
244
|
+
const variationID = this.variationID ? (this.variationID === "default" ? product.attributes.product_variation_id : this.variationID) : null;
|
|
245
|
+
const variationSKU = this.variationSKU;
|
|
246
|
+
if (!variationID && !variationSKU) {
|
|
247
|
+
return reject(new Error("ProductAR.init() - cannot proceed as variation-id or variation-sku was not set correctly"));
|
|
248
|
+
}
|
|
249
|
+
let variation = undefined;
|
|
250
|
+
if (variationID) {
|
|
251
|
+
variation = product.relationships.find(plattar_api_1.ProductVariation, variationID);
|
|
252
|
+
}
|
|
253
|
+
// if no variation was found with variationID - try searching variation sku
|
|
254
|
+
if (!variation && variationSKU) {
|
|
255
|
+
const variations = product.relationships.filter(plattar_api_1.ProductVariation);
|
|
256
|
+
if (variations) {
|
|
257
|
+
variation = variations.find((element) => {
|
|
258
|
+
return element.attributes.sku === variationSKU;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
243
261
|
}
|
|
244
|
-
const variation = product.relationships.find(plattar_api_1.ProductVariation, variationID);
|
|
245
262
|
// make sure our variation is actually available before moving forward
|
|
246
263
|
if (!variation) {
|
|
247
|
-
return reject(new Error("ProductAR.init() - cannot proceed as variation with id " + variationID + " cannot be found"));
|
|
264
|
+
return reject(new Error("ProductAR.init() - cannot proceed as variation with id " + variationID + " or sku " + variationSKU + " cannot be found"));
|
|
248
265
|
}
|
|
249
266
|
// otherwise both the product and variation are available
|
|
250
267
|
// we need to figure out if we can actually do AR though
|
|
@@ -611,8 +628,8 @@ const util_1 = require("../util/util");
|
|
|
611
628
|
* SceneProducts are much more convenient to grab from the Plattar CMS
|
|
612
629
|
*/
|
|
613
630
|
class SceneProductAR extends product_ar_1.ProductAR {
|
|
614
|
-
constructor(sceneProductID = null, variationID = null) {
|
|
615
|
-
super(sceneProductID, variationID);
|
|
631
|
+
constructor(sceneProductID = null, variationID = null, variationSKU = null) {
|
|
632
|
+
super(sceneProductID, variationID, variationSKU);
|
|
616
633
|
// this is evaluated in the init() function
|
|
617
634
|
this._attachedProductID = null;
|
|
618
635
|
if (!sceneProductID) {
|
|
@@ -972,6 +989,7 @@ class PlattarController {
|
|
|
972
989
|
const productID = this.getAttribute("product-id");
|
|
973
990
|
const sceneProductID = this.getAttribute("scene-product-id");
|
|
974
991
|
const variationID = this.getAttribute("variation-id");
|
|
992
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
975
993
|
const arMode = this.getAttribute("ar-mode");
|
|
976
994
|
if (configState) {
|
|
977
995
|
dst += "&config_state=" + configState;
|
|
@@ -988,6 +1006,9 @@ class PlattarController {
|
|
|
988
1006
|
if (variationID) {
|
|
989
1007
|
dst += "&variation_id=" + variationID;
|
|
990
1008
|
}
|
|
1009
|
+
if (variationSKU) {
|
|
1010
|
+
dst += "&variation_sku=" + variationSKU;
|
|
1011
|
+
}
|
|
991
1012
|
if (arMode) {
|
|
992
1013
|
dst += "&ar_mode=" + arMode;
|
|
993
1014
|
}
|
|
@@ -1087,10 +1108,14 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
1087
1108
|
}
|
|
1088
1109
|
// optional attributes
|
|
1089
1110
|
const variationID = this.getAttribute("variation-id");
|
|
1111
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1090
1112
|
const showAR = this.getAttribute("show-ar");
|
|
1091
1113
|
let dst = plattar_api_1.Server.location().base + "renderer/product.html?product_id=" + productID;
|
|
1092
1114
|
if (variationID) {
|
|
1093
|
-
dst += "&
|
|
1115
|
+
dst += "&variationId=" + variationID;
|
|
1116
|
+
}
|
|
1117
|
+
if (variationSKU) {
|
|
1118
|
+
dst += "&variationSku=" + variationSKU;
|
|
1094
1119
|
}
|
|
1095
1120
|
if (showAR) {
|
|
1096
1121
|
dst += "&show_ar=" + showAR;
|
|
@@ -1125,10 +1150,14 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
1125
1150
|
viewer.setAttribute("product-id", productID);
|
|
1126
1151
|
// optional attributes
|
|
1127
1152
|
const variationID = this.getAttribute("variation-id");
|
|
1153
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1128
1154
|
const showAR = this.getAttribute("show-ar");
|
|
1129
1155
|
if (variationID) {
|
|
1130
1156
|
viewer.setAttribute("variation-id", variationID);
|
|
1131
1157
|
}
|
|
1158
|
+
if (variationSKU) {
|
|
1159
|
+
viewer.setAttribute("variation-sku", variationSKU);
|
|
1160
|
+
}
|
|
1132
1161
|
if (showAR) {
|
|
1133
1162
|
viewer.setAttribute("show-ar", showAR);
|
|
1134
1163
|
}
|
|
@@ -1151,7 +1180,8 @@ class ProductController extends plattar_controller_1.PlattarController {
|
|
|
1151
1180
|
const productID = this.getAttribute("product-id");
|
|
1152
1181
|
if (productID) {
|
|
1153
1182
|
const variationID = this.getAttribute("variation-id");
|
|
1154
|
-
const
|
|
1183
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1184
|
+
const product = new product_ar_1.ProductAR(productID, variationID, variationSKU);
|
|
1155
1185
|
return product.init().then(accept).catch(reject);
|
|
1156
1186
|
}
|
|
1157
1187
|
return reject(new Error("ProductController.initAR() - minimum required attributes not set, use product-id as a minimum"));
|
|
@@ -1179,6 +1209,7 @@ const plattar_api_1 = require("@plattar/plattar-api");
|
|
|
1179
1209
|
const product_ar_1 = require("../../ar/product-ar");
|
|
1180
1210
|
const scene_ar_1 = require("../../ar/scene-ar");
|
|
1181
1211
|
const scene_product_ar_1 = require("../../ar/scene-product-ar");
|
|
1212
|
+
const configurator_state_1 = require("../../util/configurator-state");
|
|
1182
1213
|
const util_1 = require("../../util/util");
|
|
1183
1214
|
const plattar_controller_1 = require("./plattar-controller");
|
|
1184
1215
|
/**
|
|
@@ -1234,6 +1265,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1234
1265
|
// optional attributes
|
|
1235
1266
|
const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
|
|
1236
1267
|
const variationID = this.getAttribute("variation-id");
|
|
1268
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1237
1269
|
const showAR = this.getAttribute("show-ar");
|
|
1238
1270
|
if (productID) {
|
|
1239
1271
|
dst += "&productId=" + productID;
|
|
@@ -1241,6 +1273,9 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1241
1273
|
if (variationID) {
|
|
1242
1274
|
dst += "&variationId=" + variationID;
|
|
1243
1275
|
}
|
|
1276
|
+
if (variationSKU) {
|
|
1277
|
+
dst += "&variationSku=" + variationSKU;
|
|
1278
|
+
}
|
|
1244
1279
|
if (showAR) {
|
|
1245
1280
|
dst += "&show_ar=" + showAR;
|
|
1246
1281
|
}
|
|
@@ -1275,6 +1310,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1275
1310
|
// optional attributes
|
|
1276
1311
|
const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
|
|
1277
1312
|
const variationID = this.getAttribute("variation-id");
|
|
1313
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1278
1314
|
const showAR = this.getAttribute("show-ar");
|
|
1279
1315
|
if (productID) {
|
|
1280
1316
|
viewer.setAttribute("product-id", productID);
|
|
@@ -1282,6 +1318,9 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1282
1318
|
if (variationID) {
|
|
1283
1319
|
viewer.setAttribute("variation-id", variationID);
|
|
1284
1320
|
}
|
|
1321
|
+
if (variationSKU) {
|
|
1322
|
+
viewer.setAttribute("variation-sku", variationSKU);
|
|
1323
|
+
}
|
|
1285
1324
|
if (showAR) {
|
|
1286
1325
|
viewer.setAttribute("show-ar", showAR);
|
|
1287
1326
|
}
|
|
@@ -1305,22 +1344,39 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1305
1344
|
// use product-id if available
|
|
1306
1345
|
if (productID) {
|
|
1307
1346
|
const variationID = this.getAttribute("variation-id");
|
|
1308
|
-
const
|
|
1347
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1348
|
+
const product = new product_ar_1.ProductAR(productID, variationID, variationSKU);
|
|
1309
1349
|
return product.init().then(accept).catch(reject);
|
|
1310
1350
|
}
|
|
1311
1351
|
const sceneProductID = this.getAttribute("scene-product-id");
|
|
1312
1352
|
// use scene-product-id if available
|
|
1313
1353
|
if (sceneProductID) {
|
|
1314
1354
|
const variationID = this.getAttribute("variation-id");
|
|
1315
|
-
const
|
|
1355
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1356
|
+
const product = new scene_product_ar_1.SceneProductAR(sceneProductID, variationID, variationSKU);
|
|
1316
1357
|
return product.init().then(accept).catch(reject);
|
|
1317
1358
|
}
|
|
1318
1359
|
const sceneID = this.getAttribute("scene-id");
|
|
1319
1360
|
// fallback to using default SceneAR implementation
|
|
1320
1361
|
if (sceneID) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1362
|
+
// special case - check if scene only has a single product, if so
|
|
1363
|
+
// we need to use provided variation-id or variation-sku to override
|
|
1364
|
+
const variationID = this.getAttribute("variation-id");
|
|
1365
|
+
const variationSKU = this.getAttribute("variation-sku");
|
|
1366
|
+
// just do scene-ar if variation ID and variation SKU is not set
|
|
1367
|
+
if (!variationID && !variationSKU) {
|
|
1368
|
+
const sceneAR = new scene_ar_1.SceneAR(sceneID);
|
|
1369
|
+
return sceneAR.init().then(accept).catch(reject);
|
|
1370
|
+
}
|
|
1371
|
+
// otherwise decode scene
|
|
1372
|
+
return configurator_state_1.ConfiguratorState.decodeScene(sceneID).then((state) => {
|
|
1373
|
+
const firstProduct = state.first();
|
|
1374
|
+
if (state.length > 1 || !firstProduct) {
|
|
1375
|
+
return reject(new Error("ViewerController.initAR() - single product required to override variation-id or variation-sku"));
|
|
1376
|
+
}
|
|
1377
|
+
const product = new scene_product_ar_1.SceneProductAR(firstProduct.scene_product_id, variationID, variationSKU);
|
|
1378
|
+
return product.init().then(accept).catch(reject);
|
|
1379
|
+
}).catch(reject);
|
|
1324
1380
|
}
|
|
1325
1381
|
return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
1326
1382
|
});
|
|
@@ -1339,7 +1395,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1339
1395
|
}
|
|
1340
1396
|
exports.ViewerController = ViewerController;
|
|
1341
1397
|
|
|
1342
|
-
},{"../../ar/product-ar":3,"../../ar/scene-ar":5,"../../ar/scene-product-ar":6,"../../util/util":15,"./plattar-controller":8,"@plattar/plattar-api":42}],11:[function(require,module,exports){
|
|
1398
|
+
},{"../../ar/product-ar":3,"../../ar/scene-ar":5,"../../ar/scene-product-ar":6,"../../util/configurator-state":14,"../../util/util":15,"./plattar-controller":8,"@plattar/plattar-api":42}],11:[function(require,module,exports){
|
|
1343
1399
|
"use strict";
|
|
1344
1400
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1345
1401
|
exports.VTOController = void 0;
|
|
@@ -2086,7 +2142,7 @@ exports.Util = Util;
|
|
|
2086
2142
|
},{}],16:[function(require,module,exports){
|
|
2087
2143
|
"use strict";
|
|
2088
2144
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2089
|
-
exports.default = "1.
|
|
2145
|
+
exports.default = "1.131.1";
|
|
2090
2146
|
|
|
2091
2147
|
},{}],17:[function(require,module,exports){
|
|
2092
2148
|
"use strict";
|
|
@@ -6716,6 +6772,9 @@ class FaceARElement extends BaseElement {
|
|
|
6716
6772
|
return [{
|
|
6717
6773
|
key: "variation-id",
|
|
6718
6774
|
map: "variationId"
|
|
6775
|
+
}, {
|
|
6776
|
+
key: "variation-sku",
|
|
6777
|
+
map: "variationSku"
|
|
6719
6778
|
}, {
|
|
6720
6779
|
key: "product-id",
|
|
6721
6780
|
map: "productId"
|
|
@@ -6782,6 +6841,9 @@ class ProductElement extends BaseElement {
|
|
|
6782
6841
|
return [{
|
|
6783
6842
|
key: "variation-id",
|
|
6784
6843
|
map: "variation_id"
|
|
6844
|
+
}, {
|
|
6845
|
+
key: "variation-sku",
|
|
6846
|
+
map: "variationSku"
|
|
6785
6847
|
}, {
|
|
6786
6848
|
key: "show-ar",
|
|
6787
6849
|
map: "show_ar"
|
|
@@ -6828,6 +6890,9 @@ class ViewerElement extends BaseElement {
|
|
|
6828
6890
|
return [{
|
|
6829
6891
|
key: "variation-id",
|
|
6830
6892
|
map: "variationId"
|
|
6893
|
+
}, {
|
|
6894
|
+
key: "variation-sku",
|
|
6895
|
+
map: "variationSku"
|
|
6831
6896
|
}, {
|
|
6832
6897
|
key: "product-id",
|
|
6833
6898
|
map: "productId"
|
|
@@ -6969,7 +7034,7 @@ class Util {
|
|
|
6969
7034
|
|
|
6970
7035
|
module.exports = Util;
|
|
6971
7036
|
},{}],129:[function(require,module,exports){
|
|
6972
|
-
module.exports = "1.
|
|
7037
|
+
module.exports = "1.131.1";
|
|
6973
7038
|
|
|
6974
7039
|
},{}],130:[function(require,module,exports){
|
|
6975
7040
|
(function (global){(function (){
|