@plattar/plattar-ar-adapter 1.123.8 → 1.130.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.
@@ -3,7 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.LauncherAR = void 0;
5
5
  class LauncherAR {
6
- constructor() { }
6
+ constructor() {
7
+ this._opt = {
8
+ anchor: "horizontal_vertical"
9
+ };
10
+ }
7
11
  /**
8
12
  * Initialise and launch with a single function call. this is mostly for convenience.
9
13
  * Use .init() and .start() separately for fine-grained control
@@ -16,6 +20,12 @@ class LauncherAR {
16
20
  }).catch(reject);
17
21
  });
18
22
  }
23
+ /**
24
+ * AR Options used for launching AR
25
+ */
26
+ get options() {
27
+ return this._opt;
28
+ }
19
29
  }
20
30
  exports.LauncherAR = LauncherAR;
21
31
 
@@ -102,8 +112,10 @@ class ModelAR extends launcher_ar_1.LauncherAR {
102
112
  }
103
113
  // check android
104
114
  if (util_1.Util.canSceneViewer()) {
105
- this._ar = new scene_viewer_1.default();
106
- this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
115
+ const arviewer = new scene_viewer_1.default();
116
+ arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
117
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
118
+ this._ar = arviewer;
107
119
  return accept(this);
108
120
  }
109
121
  // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
@@ -267,8 +279,17 @@ class ProductAR extends launcher_ar_1.LauncherAR {
267
279
  }
268
280
  // check android
269
281
  if (util_1.Util.canSceneViewer()) {
270
- this._ar = new scene_viewer_1.default();
271
- this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
282
+ const arviewer = new scene_viewer_1.default();
283
+ arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
284
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
285
+ const scene = product.relationships.find(plattar_api_1.Scene);
286
+ if (scene) {
287
+ const sceneOpt = scene.attributes.custom_json || {};
288
+ if (sceneOpt.anchor === "vertical") {
289
+ arviewer.isVertical = true;
290
+ }
291
+ }
292
+ this._ar = arviewer;
272
293
  return accept(this);
273
294
  }
274
295
  // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
@@ -374,8 +395,10 @@ class RawAR extends launcher_ar_1.LauncherAR {
374
395
  // check android
375
396
  if (util_1.Util.canSceneViewer()) {
376
397
  if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
377
- this._ar = new scene_viewer_1.default();
378
- this._ar.modelUrl = modelLocation;
398
+ const arviewer = new scene_viewer_1.default();
399
+ arviewer.modelUrl = modelLocation;
400
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
401
+ this._ar = arviewer;
379
402
  return accept(this);
380
403
  }
381
404
  return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
@@ -533,8 +556,13 @@ class SceneAR extends launcher_ar_1.LauncherAR {
533
556
  // check android
534
557
  if (util_1.Util.canSceneViewer()) {
535
558
  return this._ComposeScene(scene, "glb").then((modelUrl) => {
536
- this._ar = new scene_viewer_1.default();
537
- this._ar.modelUrl = modelUrl;
559
+ const arviewer = new scene_viewer_1.default();
560
+ arviewer.modelUrl = modelUrl;
561
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
562
+ if (sceneOpt.anchor === "vertical") {
563
+ arviewer.isVertical = true;
564
+ }
565
+ this._ar = arviewer;
538
566
  return accept(this);
539
567
  }).catch(reject);
540
568
  }
@@ -639,9 +667,6 @@ const plattar_controller_1 = require("./plattar-controller");
639
667
  class ConfiguratorController extends plattar_controller_1.PlattarController {
640
668
  constructor(parent) {
641
669
  super(parent);
642
- this._state = plattar_controller_1.ControllerState.None;
643
- this._element = null;
644
- this._prevQROpt = null;
645
670
  }
646
671
  onAttributesUpdated() {
647
672
  const state = this._state;
@@ -651,7 +676,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
651
676
  return;
652
677
  }
653
678
  }
654
- startQRCode(options) {
679
+ startViewerQRCode(options) {
655
680
  return new Promise((accept, reject) => {
656
681
  // remove the old renderer instance if any
657
682
  this.removeRenderer();
@@ -852,6 +877,7 @@ exports.ConfiguratorController = ConfiguratorController;
852
877
  "use strict";
853
878
  Object.defineProperty(exports, "__esModule", { value: true });
854
879
  exports.PlattarController = exports.ControllerState = void 0;
880
+ const plattar_api_1 = require("@plattar/plattar-api");
855
881
  var ControllerState;
856
882
  (function (ControllerState) {
857
883
  ControllerState[ControllerState["None"] = 0] = "None";
@@ -863,6 +889,9 @@ var ControllerState;
863
889
  */
864
890
  class PlattarController {
865
891
  constructor(parent) {
892
+ this._state = ControllerState.None;
893
+ this._element = null;
894
+ this._prevQROpt = null;
866
895
  this._parent = parent;
867
896
  }
868
897
  /**
@@ -887,6 +916,86 @@ class PlattarController {
887
916
  }).catch(reject);
888
917
  });
889
918
  }
919
+ /**
920
+ * Decide which QR Code to render according to the qr-type attribute
921
+ * @param options
922
+ * @returns
923
+ */
924
+ startQRCode(options) {
925
+ const qrType = this.getAttribute("qr-type") || "viewer";
926
+ switch (qrType.toLowerCase()) {
927
+ case "ar":
928
+ return this.startARQRCode(options);
929
+ case "viewer":
930
+ default:
931
+ return this.startViewerQRCode(options);
932
+ }
933
+ }
934
+ /**
935
+ * Displays a QR Code that sends the user direct to AR
936
+ * @param options
937
+ * @returns
938
+ */
939
+ startARQRCode(options) {
940
+ return new Promise((accept, reject) => {
941
+ // remove the old renderer instance if any
942
+ this.removeRenderer();
943
+ const opt = options || PlattarController.DEFAULT_QR_OPTIONS;
944
+ const viewer = document.createElement("plattar-qrcode");
945
+ // required attributes with defaults for plattar-viewer node
946
+ const width = this.getAttribute("width") || "500px";
947
+ const height = this.getAttribute("height") || "500px";
948
+ viewer.setAttribute("width", width);
949
+ viewer.setAttribute("height", height);
950
+ if (opt.color) {
951
+ viewer.setAttribute("color", opt.color);
952
+ }
953
+ if (opt.margin) {
954
+ viewer.setAttribute("margin", "" + opt.margin);
955
+ }
956
+ if (opt.qrType) {
957
+ viewer.setAttribute("qr-type", opt.qrType);
958
+ }
959
+ const qrOptions = btoa(JSON.stringify(opt));
960
+ let dst = plattar_api_1.Server.location().base + "renderer/launcher.html?qr_options=" + qrOptions;
961
+ const sceneID = this.getAttribute("scene-id");
962
+ const configState = this.getAttribute("config-state");
963
+ const embedType = this.getAttribute("embed-type");
964
+ const productID = this.getAttribute("product-id");
965
+ const sceneProductID = this.getAttribute("scene-product-id");
966
+ const variationID = this.getAttribute("variation-id");
967
+ const arMode = this.getAttribute("ar-mode");
968
+ if (configState) {
969
+ dst += "&config_state=" + configState;
970
+ }
971
+ if (embedType) {
972
+ dst += "&embed_type=" + embedType;
973
+ }
974
+ if (productID) {
975
+ dst += "&product_id=" + productID;
976
+ }
977
+ if (sceneProductID) {
978
+ dst += "&scene_product_id=" + sceneProductID;
979
+ }
980
+ if (variationID) {
981
+ dst += "&variation_id=" + variationID;
982
+ }
983
+ if (arMode) {
984
+ dst += "&ar_mode=" + arMode;
985
+ }
986
+ if (sceneID) {
987
+ dst += "&scene_id=" + sceneID;
988
+ }
989
+ viewer.setAttribute("url", opt.url || dst);
990
+ viewer.onload = () => {
991
+ return accept(viewer);
992
+ };
993
+ this._element = viewer;
994
+ this._state = ControllerState.QRCode;
995
+ this._prevQROpt = opt;
996
+ this.append(viewer);
997
+ });
998
+ }
890
999
  /**
891
1000
  * Returns the Parent Instance
892
1001
  */
@@ -912,7 +1021,7 @@ class PlattarController {
912
1021
  }
913
1022
  exports.PlattarController = PlattarController;
914
1023
 
915
- },{}],9:[function(require,module,exports){
1024
+ },{"@plattar/plattar-api":42}],9:[function(require,module,exports){
916
1025
  "use strict";
917
1026
  Object.defineProperty(exports, "__esModule", { value: true });
918
1027
  exports.ProductController = void 0;
@@ -926,9 +1035,6 @@ const plattar_controller_1 = require("./plattar-controller");
926
1035
  class ProductController extends plattar_controller_1.PlattarController {
927
1036
  constructor(parent) {
928
1037
  super(parent);
929
- this._state = plattar_controller_1.ControllerState.None;
930
- this._element = null;
931
- this._prevQROpt = null;
932
1038
  }
933
1039
  onAttributesUpdated() {
934
1040
  const state = this._state;
@@ -949,7 +1055,7 @@ class ProductController extends plattar_controller_1.PlattarController {
949
1055
  return;
950
1056
  }
951
1057
  }
952
- startQRCode(options) {
1058
+ startViewerQRCode(options) {
953
1059
  return new Promise((accept, reject) => {
954
1060
  // remove the old renderer instance if any
955
1061
  this.removeRenderer();
@@ -973,10 +1079,14 @@ class ProductController extends plattar_controller_1.PlattarController {
973
1079
  }
974
1080
  // optional attributes
975
1081
  const variationID = this.getAttribute("variation-id");
1082
+ const showAR = this.getAttribute("show-ar");
976
1083
  let dst = plattar_api_1.Server.location().base + "renderer/product.html?product_id=" + productID;
977
1084
  if (variationID) {
978
1085
  dst += "&variation_id=" + variationID;
979
1086
  }
1087
+ if (showAR) {
1088
+ dst += "&show_ar=" + showAR;
1089
+ }
980
1090
  viewer.setAttribute("url", opt.url || dst);
981
1091
  viewer.onload = () => {
982
1092
  return accept(viewer);
@@ -1007,9 +1117,13 @@ class ProductController extends plattar_controller_1.PlattarController {
1007
1117
  viewer.setAttribute("product-id", productID);
1008
1118
  // optional attributes
1009
1119
  const variationID = this.getAttribute("variation-id");
1120
+ const showAR = this.getAttribute("show-ar");
1010
1121
  if (variationID) {
1011
1122
  viewer.setAttribute("variation-id", variationID);
1012
1123
  }
1124
+ if (showAR) {
1125
+ viewer.setAttribute("show-ar", showAR);
1126
+ }
1013
1127
  viewer.onload = () => {
1014
1128
  return accept(viewer);
1015
1129
  };
@@ -1065,9 +1179,6 @@ const plattar_controller_1 = require("./plattar-controller");
1065
1179
  class ViewerController extends plattar_controller_1.PlattarController {
1066
1180
  constructor(parent) {
1067
1181
  super(parent);
1068
- this._state = plattar_controller_1.ControllerState.None;
1069
- this._element = null;
1070
- this._prevQROpt = null;
1071
1182
  }
1072
1183
  onAttributesUpdated() {
1073
1184
  const state = this._state;
@@ -1089,7 +1200,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
1089
1200
  return;
1090
1201
  }
1091
1202
  }
1092
- startQRCode(options) {
1203
+ startViewerQRCode(options) {
1093
1204
  return new Promise((accept, reject) => {
1094
1205
  // remove the old renderer instance if any
1095
1206
  this.removeRenderer();
@@ -1115,12 +1226,16 @@ class ViewerController extends plattar_controller_1.PlattarController {
1115
1226
  // optional attributes
1116
1227
  const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
1117
1228
  const variationID = this.getAttribute("variation-id");
1229
+ const showAR = this.getAttribute("show-ar");
1118
1230
  if (productID) {
1119
1231
  dst += "&productId=" + productID;
1120
1232
  }
1121
1233
  if (variationID) {
1122
1234
  dst += "&variationId=" + variationID;
1123
1235
  }
1236
+ if (showAR) {
1237
+ dst += "&show_ar=" + showAR;
1238
+ }
1124
1239
  viewer.setAttribute("url", opt.url || dst);
1125
1240
  viewer.onload = () => {
1126
1241
  return accept(viewer);
@@ -1152,12 +1267,16 @@ class ViewerController extends plattar_controller_1.PlattarController {
1152
1267
  // optional attributes
1153
1268
  const productID = (this.getAttribute("product-id") || this.getAttribute("scene-product-id"));
1154
1269
  const variationID = this.getAttribute("variation-id");
1270
+ const showAR = this.getAttribute("show-ar");
1155
1271
  if (productID) {
1156
1272
  viewer.setAttribute("product-id", productID);
1157
1273
  }
1158
1274
  if (variationID) {
1159
1275
  viewer.setAttribute("variation-id", variationID);
1160
1276
  }
1277
+ if (showAR) {
1278
+ viewer.setAttribute("show-ar", showAR);
1279
+ }
1161
1280
  viewer.onload = () => {
1162
1281
  return accept(viewer);
1163
1282
  };
@@ -1233,9 +1352,6 @@ const plattar_controller_1 = require("./plattar-controller");
1233
1352
  class VTOController extends plattar_controller_1.PlattarController {
1234
1353
  constructor(parent) {
1235
1354
  super(parent);
1236
- this._state = plattar_controller_1.ControllerState.None;
1237
- this._element = null;
1238
- this._prevQROpt = null;
1239
1355
  }
1240
1356
  onAttributesUpdated() {
1241
1357
  const state = this._state;
@@ -1245,7 +1361,7 @@ class VTOController extends plattar_controller_1.PlattarController {
1245
1361
  return;
1246
1362
  }
1247
1363
  }
1248
- startQRCode(options) {
1364
+ startViewerQRCode(options) {
1249
1365
  return new Promise((accept, reject) => {
1250
1366
  // remove the old renderer instance if any
1251
1367
  this.removeRenderer();
@@ -1598,7 +1714,11 @@ exports.default = PlattarEmbed;
1598
1714
  "use strict";
1599
1715
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1600
1716
  if (k2 === undefined) k2 = k;
1601
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
1717
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1718
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1719
+ desc = { enumerable: true, get: function() { return m[k]; } };
1720
+ }
1721
+ Object.defineProperty(o, k2, desc);
1602
1722
  }) : (function(o, m, k, k2) {
1603
1723
  if (k2 === undefined) k2 = k;
1604
1724
  o[k2] = m[k];
@@ -1619,10 +1739,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1619
1739
  return (mod && mod.__esModule) ? mod : { "default": mod };
1620
1740
  };
1621
1741
  Object.defineProperty(exports, "__esModule", { value: true });
1622
- exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
1742
+ exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.LauncherAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
1623
1743
  exports.PlattarWeb = __importStar(require("@plattar/plattar-web"));
1624
1744
  exports.PlattarQRCode = __importStar(require("@plattar/plattar-qrcode"));
1625
1745
  exports.version = __importStar(require("./version"));
1746
+ var launcher_ar_1 = require("./ar/launcher-ar");
1747
+ Object.defineProperty(exports, "LauncherAR", { enumerable: true, get: function () { return launcher_ar_1.LauncherAR; } });
1626
1748
  var product_ar_1 = require("./ar/product-ar");
1627
1749
  Object.defineProperty(exports, "ProductAR", { enumerable: true, get: function () { return product_ar_1.ProductAR; } });
1628
1750
  var scene_product_ar_1 = require("./ar/scene-product-ar");
@@ -1646,7 +1768,7 @@ if (customElements) {
1646
1768
  }
1647
1769
  console.log("using @plattar/plattar-ar-adapter v" + version_1.default);
1648
1770
 
1649
- },{"./ar/model-ar":2,"./ar/product-ar":3,"./ar/raw-ar":4,"./ar/scene-ar":5,"./ar/scene-product-ar":6,"./embed/plattar-embed":12,"./util/configurator-state":14,"./util/util":15,"./version":16,"@plattar/plattar-qrcode":108,"@plattar/plattar-web":127}],14:[function(require,module,exports){
1771
+ },{"./ar/launcher-ar":1,"./ar/model-ar":2,"./ar/product-ar":3,"./ar/raw-ar":4,"./ar/scene-ar":5,"./ar/scene-product-ar":6,"./embed/plattar-embed":12,"./util/configurator-state":14,"./util/util":15,"./version":16,"@plattar/plattar-qrcode":108,"@plattar/plattar-web":127}],14:[function(require,module,exports){
1650
1772
  "use strict";
1651
1773
  Object.defineProperty(exports, "__esModule", { value: true });
1652
1774
  exports.ConfiguratorState = void 0;
@@ -1961,7 +2083,7 @@ exports.Util = Util;
1961
2083
  },{}],16:[function(require,module,exports){
1962
2084
  "use strict";
1963
2085
  Object.defineProperty(exports, "__esModule", { value: true });
1964
- exports.default = "1.123.8";
2086
+ exports.default = "1.130.1";
1965
2087
 
1966
2088
  },{}],17:[function(require,module,exports){
1967
2089
  "use strict";
@@ -3374,7 +3496,11 @@ exports.Analytics = Analytics;
3374
3496
  "use strict";
3375
3497
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3376
3498
  if (k2 === undefined) k2 = k;
3377
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
3499
+ var desc = Object.getOwnPropertyDescriptor(m, k);
3500
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
3501
+ desc = { enumerable: true, get: function() { return m[k]; } };
3502
+ }
3503
+ Object.defineProperty(o, k2, desc);
3378
3504
  }) : (function(o, m, k, k2) {
3379
3505
  if (k2 === undefined) k2 = k;
3380
3506
  o[k2] = m[k];
@@ -3497,7 +3623,7 @@ exports.Util = Util;
3497
3623
  },{}],41:[function(require,module,exports){
3498
3624
  "use strict";
3499
3625
  Object.defineProperty(exports, "__esModule", { value: true });
3500
- exports.default = "1.117.2";
3626
+ exports.default = "1.124.1";
3501
3627
 
3502
3628
  },{}],42:[function(require,module,exports){
3503
3629
  "use strict";
@@ -6159,6 +6285,10 @@ class BaseElement extends HTMLElement {
6159
6285
  return this._controller ? this._controller.context : undefined;
6160
6286
  }
6161
6287
 
6288
+ get parent() {
6289
+ return this._controller ? this._controller.parent : undefined;
6290
+ }
6291
+
6162
6292
  get element() {
6163
6293
  return this._controller;
6164
6294
  }
@@ -6381,6 +6511,10 @@ class ElementController {
6381
6511
  return messenger.self;
6382
6512
  }
6383
6513
 
6514
+ get parent() {
6515
+ return messenger.parent;
6516
+ }
6517
+
6384
6518
  get controller() {
6385
6519
  return this._controller;
6386
6520
  }
@@ -6539,7 +6673,7 @@ class EWallElement extends BaseElement {
6539
6673
  }
6540
6674
  }
6541
6675
 
6542
- window.addEventListener('load', onLoad, false)
6676
+ window.addEventListener("load", onLoad, false)
6543
6677
  }
6544
6678
 
6545
6679
  get permissions() {
@@ -6638,6 +6772,9 @@ class ProductElement extends BaseElement {
6638
6772
  return [{
6639
6773
  key: "variation-id",
6640
6774
  map: "variation_id"
6775
+ }, {
6776
+ key: "show-ar",
6777
+ map: "show_ar"
6641
6778
  }];
6642
6779
  }
6643
6780
  }
@@ -6684,6 +6821,9 @@ class ViewerElement extends BaseElement {
6684
6821
  }, {
6685
6822
  key: "product-id",
6686
6823
  map: "productId"
6824
+ }, {
6825
+ key: "show-ar",
6826
+ map: "show_ar"
6687
6827
  }];
6688
6828
  }
6689
6829
  }
@@ -6837,7 +6977,7 @@ class Util {
6837
6977
 
6838
6978
  module.exports = Util;
6839
6979
  },{}],129:[function(require,module,exports){
6840
- module.exports = "1.123.1";
6980
+ module.exports = "1.129.1";
6841
6981
 
6842
6982
  },{}],130:[function(require,module,exports){
6843
6983
  (function (global){(function (){