@plattar/plattar-ar-adapter 1.123.6 → 1.123.7
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 +393 -93
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +319 -93
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/embed/controllers/configurator-controller.d.ts +8 -0
- package/dist/embed/controllers/configurator-controller.js +95 -48
- package/dist/embed/controllers/vto-controller.d.ts +8 -0
- package/dist/embed/controllers/vto-controller.js +85 -37
- package/dist/util/configurator-state.d.ts +41 -0
- package/dist/util/configurator-state.js +136 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1086,6 +1086,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
1086
1086
|
|
|
1087
1087
|
var raw_ar_1 = require("../../ar/raw-ar");
|
|
1088
1088
|
|
|
1089
|
+
var scene_ar_1 = require("../../ar/scene-ar");
|
|
1090
|
+
|
|
1091
|
+
var scene_product_ar_1 = require("../../ar/scene-product-ar");
|
|
1092
|
+
|
|
1093
|
+
var configurator_state_1 = require("../../util/configurator-state");
|
|
1094
|
+
|
|
1089
1095
|
var util_1 = require("../../util/util");
|
|
1090
1096
|
|
|
1091
1097
|
var plattar_controller_1 = require("./plattar-controller");
|
|
@@ -1240,74 +1246,133 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
1240
1246
|
return new Promise(function (accept, reject) {
|
|
1241
1247
|
if (!util_1.Util.canAugment()) {
|
|
1242
1248
|
return reject(new Error("ConfiguratorController.initAR() - cannot proceed as AR not available in context"));
|
|
1243
|
-
}
|
|
1244
|
-
// we can use the real-time configurator state to launch the AR view
|
|
1249
|
+
}
|
|
1245
1250
|
|
|
1251
|
+
var arMode = _this15.getAttribute("ar-mode") || "generated";
|
|
1246
1252
|
|
|
1247
|
-
|
|
1253
|
+
switch (arMode.toLowerCase()) {
|
|
1254
|
+
case "inherited":
|
|
1255
|
+
_this15._InitARInherited(accept, reject);
|
|
1248
1256
|
|
|
1249
|
-
|
|
1257
|
+
return;
|
|
1250
1258
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1259
|
+
case "generated":
|
|
1260
|
+
default:
|
|
1261
|
+
_this15._InitARGenerated(accept, reject);
|
|
1253
1262
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Private Function - This launches the Static/Inherited AR Mode
|
|
1268
|
+
*/
|
|
1257
1269
|
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1270
|
+
}, {
|
|
1271
|
+
key: "_InitARInherited",
|
|
1272
|
+
value: function _InitARInherited(accept, reject) {
|
|
1273
|
+
var sceneID = this.getAttribute("scene-id");
|
|
1274
|
+
var configState = this.getAttribute("config-state"); // use config-state if its available
|
|
1275
|
+
|
|
1276
|
+
if (sceneID && configState) {
|
|
1277
|
+
var state = configurator_state_1.ConfiguratorState.decode(configState);
|
|
1278
|
+
var first = state.first();
|
|
1279
|
+
|
|
1280
|
+
if (first) {
|
|
1281
|
+
var sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
1282
|
+
sceneProductAR.init().then(accept)["catch"](reject);
|
|
1283
|
+
return;
|
|
1262
1284
|
}
|
|
1263
1285
|
|
|
1264
|
-
|
|
1265
|
-
|
|
1286
|
+
return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
|
|
1287
|
+
} // otherwise fallback to using scene
|
|
1266
1288
|
|
|
1267
1289
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
var state = JSON.parse(decodedb64State);
|
|
1272
|
-
|
|
1273
|
-
if (state.meta) {
|
|
1274
|
-
var sceneProductIndex = state.meta.scene_product_index || 0;
|
|
1275
|
-
var variationIndex = state.meta.product_variation_index || 1;
|
|
1276
|
-
var states = state.states || [];
|
|
1277
|
-
|
|
1278
|
-
if (states.length > 0) {
|
|
1279
|
-
var configurator = new plattar_services_1.Configurator();
|
|
1280
|
-
states.forEach(function (productState) {
|
|
1281
|
-
configurator.addSceneProduct(productState[sceneProductIndex], productState[variationIndex]);
|
|
1282
|
-
});
|
|
1290
|
+
if (sceneID) {
|
|
1291
|
+
configurator_state_1.ConfiguratorState.decodeScene(sceneID).then(function (state) {
|
|
1292
|
+
var first = state.first();
|
|
1283
1293
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1294
|
+
if (first) {
|
|
1295
|
+
var _sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
1287
1296
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
}
|
|
1297
|
+
return _sceneProductAR.init().then(accept)["catch"](reject);
|
|
1298
|
+
}
|
|
1291
1299
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
rawAR.init().then(accept)["catch"](reject);
|
|
1297
|
-
})["catch"](reject);
|
|
1298
|
-
}
|
|
1300
|
+
return reject(new Error("ConfiguratorController.initAR() - invalid Scene does not have any product states"));
|
|
1301
|
+
})["catch"](reject);
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1299
1304
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1305
|
+
return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Private Function - This launches the Dynamic/Generated AR Mode
|
|
1309
|
+
*/
|
|
1302
1310
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1311
|
+
}, {
|
|
1312
|
+
key: "_InitARGenerated",
|
|
1313
|
+
value: function _InitARGenerated(accept, reject) {
|
|
1314
|
+
// if scene ID is available and the state is a configurator viewer
|
|
1315
|
+
// we can use the real-time configurator state to launch the AR view
|
|
1316
|
+
var viewer = this.element;
|
|
1317
|
+
var sceneID = this.getAttribute("scene-id");
|
|
1318
|
+
|
|
1319
|
+
if (viewer && sceneID && viewer.messenger) {
|
|
1320
|
+
var output = "glb";
|
|
1321
|
+
|
|
1322
|
+
if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
|
|
1323
|
+
output = "usdz";
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
viewer.messenger.getARFile(output).then(function (result) {
|
|
1327
|
+
var rawAR = new raw_ar_1.RawAR(result.filename);
|
|
1328
|
+
return rawAR.init().then(accept)["catch"](reject);
|
|
1329
|
+
})["catch"](reject);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
var configState = this.getAttribute("config-state"); // otherwise scene ID is available to the viewer is not launched
|
|
1334
|
+
// we can use the static configuration state to launch the AR view
|
|
1335
|
+
|
|
1336
|
+
if (sceneID && configState) {
|
|
1337
|
+
var state = configurator_state_1.ConfiguratorState.decode(configState);
|
|
1338
|
+
|
|
1339
|
+
if (state.length > 0) {
|
|
1340
|
+
var server = this.getAttribute("server") || "production";
|
|
1341
|
+
var configurator = new plattar_services_1.Configurator();
|
|
1342
|
+
configurator.server = server;
|
|
1343
|
+
|
|
1344
|
+
if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
|
|
1345
|
+
configurator.output = "usdz";
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
if (util_1.Util.canSceneViewer()) {
|
|
1349
|
+
configurator.output = "glb";
|
|
1306
1350
|
}
|
|
1351
|
+
|
|
1352
|
+
state.forEach(function (productState) {
|
|
1353
|
+
if (productState.meta_data.augment === true) {
|
|
1354
|
+
configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
configurator.get().then(function (result) {
|
|
1358
|
+
var rawAR = new raw_ar_1.RawAR(result.filename);
|
|
1359
|
+
rawAR.init().then(accept)["catch"](reject);
|
|
1360
|
+
})["catch"](reject);
|
|
1361
|
+
return;
|
|
1307
1362
|
}
|
|
1308
1363
|
|
|
1309
|
-
return reject(new Error("ConfiguratorController.initAR() -
|
|
1310
|
-
}
|
|
1364
|
+
return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
|
|
1365
|
+
} // otherwise no config-state or viewer is active
|
|
1366
|
+
// fallback to using default SceneAR implementation
|
|
1367
|
+
|
|
1368
|
+
|
|
1369
|
+
if (sceneID) {
|
|
1370
|
+
var sceneAR = new scene_ar_1.SceneAR(sceneID);
|
|
1371
|
+
sceneAR.init().then(accept)["catch"](reject);
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
1311
1376
|
}
|
|
1312
1377
|
}, {
|
|
1313
1378
|
key: "removeRenderer",
|
|
@@ -1334,6 +1399,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
1334
1399
|
exports.ConfiguratorController = ConfiguratorController;
|
|
1335
1400
|
}, {
|
|
1336
1401
|
"../../ar/raw-ar": 4,
|
|
1402
|
+
"../../ar/scene-ar": 5,
|
|
1403
|
+
"../../ar/scene-product-ar": 6,
|
|
1404
|
+
"../../util/configurator-state": 14,
|
|
1337
1405
|
"../../util/util": 15,
|
|
1338
1406
|
"./plattar-controller": 8,
|
|
1339
1407
|
"@plattar/plattar-api": 42,
|
|
@@ -2068,56 +2136,121 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2068
2136
|
|
|
2069
2137
|
if (!(util_1.Util.isSafari() || util_1.Util.isChromeOnIOS())) {
|
|
2070
2138
|
return reject(new Error("VTOController.initAR() - cannot proceed as VTO AR only available on IOS Mobile devices"));
|
|
2071
|
-
}
|
|
2072
|
-
// we can use the real-time configurator state to launch the AR view
|
|
2139
|
+
}
|
|
2073
2140
|
|
|
2141
|
+
var arMode = _this28.getAttribute("ar-mode") || "generated";
|
|
2074
2142
|
|
|
2075
|
-
|
|
2143
|
+
switch (arMode.toLowerCase()) {
|
|
2144
|
+
case "inherited":
|
|
2145
|
+
_this28._InitARInherited(accept, reject);
|
|
2076
2146
|
|
|
2077
|
-
|
|
2147
|
+
return;
|
|
2148
|
+
|
|
2149
|
+
case "generated":
|
|
2150
|
+
default:
|
|
2151
|
+
_this28._InitARGenerated(accept, reject);
|
|
2078
2152
|
|
|
2079
|
-
if (viewer && sceneID) {
|
|
2080
|
-
return viewer.messenger.getARFile("vto").then(function (result) {
|
|
2081
|
-
var rawAR = new raw_ar_1.RawAR(result.filename);
|
|
2082
|
-
return rawAR.init().then(accept)["catch"](reject);
|
|
2083
|
-
})["catch"](reject);
|
|
2084
2153
|
}
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
/**
|
|
2157
|
+
* Private Function - This launches the Static/Inherited AR Mode
|
|
2158
|
+
*/
|
|
2085
2159
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2160
|
+
}, {
|
|
2161
|
+
key: "_InitARInherited",
|
|
2162
|
+
value: function _InitARInherited(accept, reject) {
|
|
2163
|
+
var sceneID = this.getAttribute("scene-id");
|
|
2164
|
+
var configState = this.getAttribute("config-state"); // use config-state if its available
|
|
2088
2165
|
|
|
2166
|
+
if (sceneID && configState) {
|
|
2167
|
+
var state = __1.ConfiguratorState.decode(configState);
|
|
2089
2168
|
|
|
2090
|
-
|
|
2091
|
-
var state = __1.ConfiguratorState.decode(configState);
|
|
2169
|
+
var first = state.first();
|
|
2092
2170
|
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2171
|
+
if (first) {
|
|
2172
|
+
var sceneProductAR = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
2173
|
+
sceneProductAR.init().then(accept)["catch"](reject);
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
|
|
2178
|
+
} // otherwise fallback to using scene
|
|
2179
|
+
|
|
2180
|
+
|
|
2181
|
+
if (sceneID) {
|
|
2182
|
+
__1.ConfiguratorState.decodeScene(sceneID).then(function (state) {
|
|
2183
|
+
var first = state.first();
|
|
2184
|
+
|
|
2185
|
+
if (first) {
|
|
2186
|
+
var _sceneProductAR2 = new __1.SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
2187
|
+
|
|
2188
|
+
return _sceneProductAR2.init().then(accept)["catch"](reject);
|
|
2107
2189
|
}
|
|
2108
2190
|
|
|
2109
|
-
return reject(new Error("VTOController.initAR() - invalid
|
|
2110
|
-
}
|
|
2111
|
-
// fallback to using default SceneAR implementation
|
|
2191
|
+
return reject(new Error("VTOController.initAR() - invalid Scene does not have any product states"));
|
|
2192
|
+
})["catch"](reject);
|
|
2112
2193
|
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2113
2196
|
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2197
|
+
return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Private Function - This launches the Dynamic/Generated AR Mode
|
|
2201
|
+
*/
|
|
2202
|
+
|
|
2203
|
+
}, {
|
|
2204
|
+
key: "_InitARGenerated",
|
|
2205
|
+
value: function _InitARGenerated(accept, reject) {
|
|
2206
|
+
// if scene ID is available and the state is a configurator viewer
|
|
2207
|
+
// we can use the real-time configurator state to launch the AR view
|
|
2208
|
+
var viewer = this.element;
|
|
2209
|
+
var sceneID = this.getAttribute("scene-id");
|
|
2210
|
+
|
|
2211
|
+
if (viewer && sceneID && viewer.messenger) {
|
|
2212
|
+
viewer.messenger.getARFile("vto").then(function (result) {
|
|
2213
|
+
var rawAR = new raw_ar_1.RawAR(result.filename);
|
|
2214
|
+
return rawAR.init().then(accept)["catch"](reject);
|
|
2215
|
+
})["catch"](reject);
|
|
2216
|
+
return;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
var configState = this.getAttribute("config-state"); // otherwise scene ID is available to the viewer is not launched
|
|
2220
|
+
// we can use the static configuration state to launch the AR view
|
|
2221
|
+
|
|
2222
|
+
if (sceneID && configState) {
|
|
2223
|
+
var state = __1.ConfiguratorState.decode(configState);
|
|
2224
|
+
|
|
2225
|
+
if (state.length > 0) {
|
|
2226
|
+
var server = this.getAttribute("server") || "production";
|
|
2227
|
+
var configurator = new plattar_services_1.Configurator();
|
|
2228
|
+
configurator.server = server;
|
|
2229
|
+
configurator.output = "vto";
|
|
2230
|
+
state.forEach(function (productState) {
|
|
2231
|
+
if (productState.meta_data.augment === true) {
|
|
2232
|
+
configurator.addSceneProduct(productState.scene_product_id, productState.product_variation_id);
|
|
2233
|
+
}
|
|
2234
|
+
});
|
|
2235
|
+
configurator.get().then(function (result) {
|
|
2236
|
+
var rawAR = new raw_ar_1.RawAR(result.filename);
|
|
2237
|
+
rawAR.init().then(accept)["catch"](reject);
|
|
2238
|
+
})["catch"](reject);
|
|
2239
|
+
return;
|
|
2117
2240
|
}
|
|
2118
2241
|
|
|
2119
|
-
return reject(new Error("VTOController.initAR() -
|
|
2120
|
-
}
|
|
2242
|
+
return reject(new Error("VTOController.initAR() - invalid config-state does not have any product states"));
|
|
2243
|
+
} // otherwise no config-state or viewer is active
|
|
2244
|
+
// fallback to using default SceneAR implementation
|
|
2245
|
+
|
|
2246
|
+
|
|
2247
|
+
if (sceneID) {
|
|
2248
|
+
var sceneAR = new __1.SceneAR(sceneID);
|
|
2249
|
+
sceneAR.init().then(accept)["catch"](reject);
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
return reject(new Error("VTOController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
2121
2254
|
}
|
|
2122
2255
|
}, {
|
|
2123
2256
|
key: "removeRenderer",
|
|
@@ -2519,6 +2652,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2519
2652
|
});
|
|
2520
2653
|
exports.ConfiguratorState = void 0;
|
|
2521
2654
|
|
|
2655
|
+
var plattar_api_1 = require("@plattar/plattar-api");
|
|
2656
|
+
|
|
2522
2657
|
var ConfiguratorState = /*#__PURE__*/function () {
|
|
2523
2658
|
function ConfiguratorState() {
|
|
2524
2659
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
@@ -2564,6 +2699,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2564
2699
|
|
|
2565
2700
|
|
|
2566
2701
|
_createClass(ConfiguratorState, [{
|
|
2702
|
+
key: "setSceneProduct",
|
|
2703
|
+
value: function setSceneProduct(sceneProductID, productVariationID) {
|
|
2704
|
+
var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
2705
|
+
this.addSceneProduct(sceneProductID, productVariationID, metaData);
|
|
2706
|
+
}
|
|
2707
|
+
/**
|
|
2708
|
+
* Adds a new Scene Product/Variation combo with meta-data into the Configurator State
|
|
2709
|
+
*
|
|
2710
|
+
* @param sceneProductID - The Scene Product ID to be used (as defined in Plattar CMS)
|
|
2711
|
+
* @param productVariationID - The Product Variation ID to be used (as defined in Plattar CMS)
|
|
2712
|
+
* @param metaData - Arbitrary meta-data that can be used against certain operaions
|
|
2713
|
+
*/
|
|
2714
|
+
|
|
2715
|
+
}, {
|
|
2567
2716
|
key: "addSceneProduct",
|
|
2568
2717
|
value: function addSceneProduct(sceneProductID, productVariationID) {
|
|
2569
2718
|
var metaData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
@@ -2571,16 +2720,75 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2571
2720
|
if (sceneProductID && productVariationID) {
|
|
2572
2721
|
var states = this._state.states;
|
|
2573
2722
|
var meta = this._state.meta;
|
|
2574
|
-
var newData =
|
|
2575
|
-
|
|
2576
|
-
|
|
2723
|
+
var newData = null;
|
|
2724
|
+
var existingData = this.findSceneProductIndex(sceneProductID);
|
|
2725
|
+
|
|
2726
|
+
if (existingData) {
|
|
2727
|
+
newData = existingData;
|
|
2728
|
+
} else {
|
|
2729
|
+
newData = []; // push the new data into the stack
|
|
2730
|
+
|
|
2731
|
+
states.push(newData);
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
newData[meta.scene_product_index] = sceneProductID;
|
|
2735
|
+
newData[meta.product_variation_index] = productVariationID;
|
|
2577
2736
|
|
|
2578
2737
|
if (metaData) {
|
|
2579
|
-
newData
|
|
2738
|
+
newData[meta.meta_index] = metaData;
|
|
2580
2739
|
}
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
/**
|
|
2743
|
+
* Search and return the data index reference for the provided Scene Product ID
|
|
2744
|
+
* if not found, will return null
|
|
2745
|
+
* @param sceneProductID
|
|
2746
|
+
*/
|
|
2581
2747
|
|
|
2582
|
-
|
|
2748
|
+
}, {
|
|
2749
|
+
key: "findSceneProductIndex",
|
|
2750
|
+
value: function findSceneProductIndex(sceneProductID) {
|
|
2751
|
+
var states = this._state.states;
|
|
2752
|
+
|
|
2753
|
+
if (states.length > 0) {
|
|
2754
|
+
var meta = this._state.meta;
|
|
2755
|
+
var found = states.find(function (productState) {
|
|
2756
|
+
return productState[meta.scene_product_index] === sceneProductID;
|
|
2757
|
+
});
|
|
2758
|
+
return found ? found : null;
|
|
2583
2759
|
}
|
|
2760
|
+
|
|
2761
|
+
return null;
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Search and return the data for the provided Scene Product ID
|
|
2765
|
+
* if not found, will return null
|
|
2766
|
+
* @param sceneProductID
|
|
2767
|
+
*/
|
|
2768
|
+
|
|
2769
|
+
}, {
|
|
2770
|
+
key: "findSceneProduct",
|
|
2771
|
+
value: function findSceneProduct(sceneProductID) {
|
|
2772
|
+
var found = this.findSceneProductIndex(sceneProductID);
|
|
2773
|
+
|
|
2774
|
+
if (found) {
|
|
2775
|
+
var meta = this._state.meta;
|
|
2776
|
+
var data = {
|
|
2777
|
+
scene_product_id: found[meta.scene_product_index],
|
|
2778
|
+
product_variation_id: found[meta.product_variation_index],
|
|
2779
|
+
meta_data: {
|
|
2780
|
+
augment: true
|
|
2781
|
+
}
|
|
2782
|
+
}; // include the meta-data
|
|
2783
|
+
|
|
2784
|
+
if (found.length === 3) {
|
|
2785
|
+
data.meta_data.augment = found[meta.meta_index].augment || true;
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
return data;
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
return null;
|
|
2584
2792
|
}
|
|
2585
2793
|
/**
|
|
2586
2794
|
* Iterate over the internal state data
|
|
@@ -2614,14 +2822,64 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2614
2822
|
});
|
|
2615
2823
|
}
|
|
2616
2824
|
}
|
|
2825
|
+
/**
|
|
2826
|
+
* @returns Returns the first reference of data in the stack, otherwise returns null
|
|
2827
|
+
*/
|
|
2828
|
+
|
|
2829
|
+
}, {
|
|
2830
|
+
key: "first",
|
|
2831
|
+
value: function first() {
|
|
2832
|
+
var states = this._state.states;
|
|
2833
|
+
|
|
2834
|
+
if (states.length > 0) {
|
|
2835
|
+
var meta = this._state.meta;
|
|
2836
|
+
var found = states.find(function (productState) {
|
|
2837
|
+
var check = productState[meta.scene_product_index]; // ensure the data contains valid elements
|
|
2838
|
+
|
|
2839
|
+
return check !== null && check !== undefined;
|
|
2840
|
+
});
|
|
2841
|
+
|
|
2842
|
+
if (!found) {
|
|
2843
|
+
return null;
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
var data = {
|
|
2847
|
+
scene_product_id: found[meta.scene_product_index],
|
|
2848
|
+
product_variation_id: found[meta.product_variation_index],
|
|
2849
|
+
meta_data: {
|
|
2850
|
+
augment: true
|
|
2851
|
+
}
|
|
2852
|
+
}; // include the meta-data
|
|
2853
|
+
|
|
2854
|
+
if (found.length === 3) {
|
|
2855
|
+
data.meta_data.augment = found[meta.meta_index].augment || true;
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
return data;
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
return null;
|
|
2862
|
+
}
|
|
2617
2863
|
}, {
|
|
2618
2864
|
key: "length",
|
|
2619
2865
|
get: function get() {
|
|
2620
2866
|
return this._state.states.length;
|
|
2621
2867
|
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Decodes and returns an instance of ConfiguratorState from a previously
|
|
2870
|
+
* encoded state
|
|
2871
|
+
* @param state - The previously encoded state as a Base64 String
|
|
2872
|
+
* @returns - ConfiguratorState instance
|
|
2873
|
+
*/
|
|
2874
|
+
|
|
2622
2875
|
}, {
|
|
2623
2876
|
key: "encode",
|
|
2624
|
-
value:
|
|
2877
|
+
value:
|
|
2878
|
+
/**
|
|
2879
|
+
* Encode and return the internal ConfiguratorState as a Base64 String
|
|
2880
|
+
* @returns - Base64 String
|
|
2881
|
+
*/
|
|
2882
|
+
function encode() {
|
|
2625
2883
|
return btoa(JSON.stringify(this._state));
|
|
2626
2884
|
}
|
|
2627
2885
|
}], [{
|
|
@@ -2629,13 +2887,55 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2629
2887
|
value: function decode(state) {
|
|
2630
2888
|
return new ConfiguratorState(state);
|
|
2631
2889
|
}
|
|
2890
|
+
/**
|
|
2891
|
+
* Generates a new ConfiguratorState instance from all SceneProducts and default
|
|
2892
|
+
* variations from the provided Scene ID
|
|
2893
|
+
* @param sceneID - the Scene ID to generate
|
|
2894
|
+
* @returns - Promise that resolves into a ConfiguratorState instance
|
|
2895
|
+
*/
|
|
2896
|
+
|
|
2897
|
+
}, {
|
|
2898
|
+
key: "decodeScene",
|
|
2899
|
+
value: function decodeScene() {
|
|
2900
|
+
var sceneID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
2901
|
+
return new Promise(function (accept, reject) {
|
|
2902
|
+
var configState = new ConfiguratorState();
|
|
2903
|
+
|
|
2904
|
+
if (!sceneID) {
|
|
2905
|
+
return reject(new Error("ConfiguratorState.decodeScene(sceneID) - sceneID must be defined"));
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
var scene = new plattar_api_1.Scene(sceneID);
|
|
2909
|
+
scene.include(plattar_api_1.SceneProduct);
|
|
2910
|
+
scene.include(plattar_api_1.SceneProduct.include(plattar_api_1.Product));
|
|
2911
|
+
scene.get().then(function (scene) {
|
|
2912
|
+
var sceneProducts = scene.relationships.filter(plattar_api_1.SceneProduct); // nothing to do if no AR components can be found
|
|
2913
|
+
|
|
2914
|
+
if (sceneProducts.length <= 0) {
|
|
2915
|
+
return accept(configState);
|
|
2916
|
+
} // add out scene models
|
|
2917
|
+
|
|
2918
|
+
|
|
2919
|
+
sceneProducts.forEach(function (sceneProduct) {
|
|
2920
|
+
var product = sceneProduct.relationships.find(plattar_api_1.Product);
|
|
2921
|
+
|
|
2922
|
+
if (product && product.attributes.product_variation_id) {
|
|
2923
|
+
configState.setSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
accept(configState);
|
|
2927
|
+
})["catch"](reject);
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2632
2930
|
}]);
|
|
2633
2931
|
|
|
2634
2932
|
return ConfiguratorState;
|
|
2635
2933
|
}();
|
|
2636
2934
|
|
|
2637
2935
|
exports.ConfiguratorState = ConfiguratorState;
|
|
2638
|
-
}, {
|
|
2936
|
+
}, {
|
|
2937
|
+
"@plattar/plattar-api": 42
|
|
2938
|
+
}],
|
|
2639
2939
|
15: [function (require, module, exports) {
|
|
2640
2940
|
"use strict";
|
|
2641
2941
|
|
|
@@ -2766,7 +3066,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
2766
3066
|
Object.defineProperty(exports, "__esModule", {
|
|
2767
3067
|
value: true
|
|
2768
3068
|
});
|
|
2769
|
-
exports["default"] = "1.123.
|
|
3069
|
+
exports["default"] = "1.123.7";
|
|
2770
3070
|
}, {}],
|
|
2771
3071
|
17: [function (require, module, exports) {
|
|
2772
3072
|
"use strict";
|