@plattar/plattar-ar-adapter 1.129.1 → 1.130.3
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 +110 -49
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +87 -57
- package/build/es2019/plattar-ar-adapter.min.js +1 -9
- package/dist/ar/launcher-ar.d.ts +8 -0
- package/dist/ar/launcher-ar.js +11 -1
- package/dist/ar/model-ar.js +4 -2
- package/dist/ar/product-ar.js +11 -2
- package/dist/ar/raw-ar.js +4 -2
- package/dist/ar/scene-ar.js +7 -2
- package/dist/embed/controllers/configurator-controller.js +8 -0
- package/dist/embed/controllers/viewer-controller.js +5 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
271
|
-
|
|
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
|
-
|
|
378
|
-
|
|
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
|
-
|
|
537
|
-
|
|
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
|
}
|
|
@@ -674,6 +702,10 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
674
702
|
// optional attributes
|
|
675
703
|
const configState = this.getAttribute("config-state");
|
|
676
704
|
const showAR = this.getAttribute("show-ar");
|
|
705
|
+
const showUI = this.getAttribute("show-ui");
|
|
706
|
+
if (showUI && showUI === "true") {
|
|
707
|
+
dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
|
|
708
|
+
}
|
|
677
709
|
if (configState) {
|
|
678
710
|
dst += "&config_state=" + configState;
|
|
679
711
|
}
|
|
@@ -711,12 +743,16 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
711
743
|
// optional attributes
|
|
712
744
|
const configState = this.getAttribute("config-state");
|
|
713
745
|
const showAR = this.getAttribute("show-ar");
|
|
746
|
+
const showUI = this.getAttribute("show-ui");
|
|
714
747
|
if (configState) {
|
|
715
748
|
viewer.setAttribute("config-state", configState);
|
|
716
749
|
}
|
|
717
750
|
if (showAR) {
|
|
718
751
|
viewer.setAttribute("show-ar", showAR);
|
|
719
752
|
}
|
|
753
|
+
if (showUI) {
|
|
754
|
+
viewer.setAttribute("show-ui", showUI);
|
|
755
|
+
}
|
|
720
756
|
viewer.onload = () => {
|
|
721
757
|
return accept(viewer);
|
|
722
758
|
};
|
|
@@ -1141,8 +1177,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
1141
1177
|
exports.ViewerController = void 0;
|
|
1142
1178
|
const plattar_api_1 = require("@plattar/plattar-api");
|
|
1143
1179
|
const product_ar_1 = require("../../ar/product-ar");
|
|
1180
|
+
const scene_ar_1 = require("../../ar/scene-ar");
|
|
1144
1181
|
const scene_product_ar_1 = require("../../ar/scene-product-ar");
|
|
1145
|
-
const configurator_state_1 = require("../../util/configurator-state");
|
|
1146
1182
|
const util_1 = require("../../util/util");
|
|
1147
1183
|
const plattar_controller_1 = require("./plattar-controller");
|
|
1148
1184
|
/**
|
|
@@ -1280,16 +1316,11 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1280
1316
|
return product.init().then(accept).catch(reject);
|
|
1281
1317
|
}
|
|
1282
1318
|
const sceneID = this.getAttribute("scene-id");
|
|
1283
|
-
//
|
|
1319
|
+
// fallback to using default SceneAR implementation
|
|
1284
1320
|
if (sceneID) {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
const sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
1289
|
-
return sceneProductAR.init().then(accept).catch(reject);
|
|
1290
|
-
}
|
|
1291
|
-
return reject(new Error("ViewerController.initAR() - your scene does not contain any valid products"));
|
|
1292
|
-
}).catch(reject);
|
|
1321
|
+
const sceneAR = new scene_ar_1.SceneAR(sceneID);
|
|
1322
|
+
sceneAR.init().then(accept).catch(reject);
|
|
1323
|
+
return;
|
|
1293
1324
|
}
|
|
1294
1325
|
return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
|
|
1295
1326
|
});
|
|
@@ -1308,7 +1339,7 @@ class ViewerController extends plattar_controller_1.PlattarController {
|
|
|
1308
1339
|
}
|
|
1309
1340
|
exports.ViewerController = ViewerController;
|
|
1310
1341
|
|
|
1311
|
-
},{"../../ar/product-ar":3,"../../ar/scene-
|
|
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){
|
|
1312
1343
|
"use strict";
|
|
1313
1344
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1314
1345
|
exports.VTOController = void 0;
|
|
@@ -1711,10 +1742,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1711
1742
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1712
1743
|
};
|
|
1713
1744
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1714
|
-
exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
|
|
1745
|
+
exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.LauncherAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
|
|
1715
1746
|
exports.PlattarWeb = __importStar(require("@plattar/plattar-web"));
|
|
1716
1747
|
exports.PlattarQRCode = __importStar(require("@plattar/plattar-qrcode"));
|
|
1717
1748
|
exports.version = __importStar(require("./version"));
|
|
1749
|
+
var launcher_ar_1 = require("./ar/launcher-ar");
|
|
1750
|
+
Object.defineProperty(exports, "LauncherAR", { enumerable: true, get: function () { return launcher_ar_1.LauncherAR; } });
|
|
1718
1751
|
var product_ar_1 = require("./ar/product-ar");
|
|
1719
1752
|
Object.defineProperty(exports, "ProductAR", { enumerable: true, get: function () { return product_ar_1.ProductAR; } });
|
|
1720
1753
|
var scene_product_ar_1 = require("./ar/scene-product-ar");
|
|
@@ -1738,7 +1771,7 @@ if (customElements) {
|
|
|
1738
1771
|
}
|
|
1739
1772
|
console.log("using @plattar/plattar-ar-adapter v" + version_1.default);
|
|
1740
1773
|
|
|
1741
|
-
},{"./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){
|
|
1774
|
+
},{"./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){
|
|
1742
1775
|
"use strict";
|
|
1743
1776
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1744
1777
|
exports.ConfiguratorState = void 0;
|
|
@@ -2053,7 +2086,7 @@ exports.Util = Util;
|
|
|
2053
2086
|
},{}],16:[function(require,module,exports){
|
|
2054
2087
|
"use strict";
|
|
2055
2088
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2056
|
-
exports.default = "1.
|
|
2089
|
+
exports.default = "1.130.3";
|
|
2057
2090
|
|
|
2058
2091
|
},{}],17:[function(require,module,exports){
|
|
2059
2092
|
"use strict";
|
|
@@ -6226,6 +6259,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6226
6259
|
exports.default = "1.120.1";
|
|
6227
6260
|
|
|
6228
6261
|
},{}],115:[function(require,module,exports){
|
|
6262
|
+
const Util = require("../../util/util");
|
|
6229
6263
|
const ElementController = require("../controllers/element-controller");
|
|
6230
6264
|
|
|
6231
6265
|
class BaseElement extends HTMLElement {
|
|
@@ -6255,6 +6289,10 @@ class BaseElement extends HTMLElement {
|
|
|
6255
6289
|
return this._controller ? this._controller.context : undefined;
|
|
6256
6290
|
}
|
|
6257
6291
|
|
|
6292
|
+
get parent() {
|
|
6293
|
+
return this._controller ? this._controller.parent : undefined;
|
|
6294
|
+
}
|
|
6295
|
+
|
|
6258
6296
|
get element() {
|
|
6259
6297
|
return this._controller;
|
|
6260
6298
|
}
|
|
@@ -6359,10 +6397,14 @@ class BaseElement extends HTMLElement {
|
|
|
6359
6397
|
get elementType() {
|
|
6360
6398
|
return "none";
|
|
6361
6399
|
}
|
|
6400
|
+
|
|
6401
|
+
get elementLocation() {
|
|
6402
|
+
return Util.getElementLocation(this.elementType);
|
|
6403
|
+
}
|
|
6362
6404
|
}
|
|
6363
6405
|
|
|
6364
6406
|
module.exports = BaseElement;
|
|
6365
|
-
},{"../controllers/element-controller":117}],116:[function(require,module,exports){
|
|
6407
|
+
},{"../../util/util":128,"../controllers/element-controller":117}],116:[function(require,module,exports){
|
|
6366
6408
|
const BaseElement = require("./base/base-element.js");
|
|
6367
6409
|
|
|
6368
6410
|
class ConfiguratorElement extends BaseElement {
|
|
@@ -6378,6 +6420,16 @@ class ConfiguratorElement extends BaseElement {
|
|
|
6378
6420
|
return "configurator";
|
|
6379
6421
|
}
|
|
6380
6422
|
|
|
6423
|
+
get elementLocation() {
|
|
6424
|
+
if (this.hasAttribute("show-ui")) {
|
|
6425
|
+
const state = this.getAttribute("show-ui");
|
|
6426
|
+
|
|
6427
|
+
return state === "true" ? "configurator/dist/index.html" : super.elementLocation;
|
|
6428
|
+
}
|
|
6429
|
+
|
|
6430
|
+
return super.elementLocation;
|
|
6431
|
+
}
|
|
6432
|
+
|
|
6381
6433
|
get optionalAttributes() {
|
|
6382
6434
|
return [{
|
|
6383
6435
|
key: "config-state",
|
|
@@ -6435,7 +6487,7 @@ class ElementController {
|
|
|
6435
6487
|
throw new Error("ElementController - attribute \"server\" must be one of \"production\", \"staging\" or \"dev\"");
|
|
6436
6488
|
}
|
|
6437
6489
|
|
|
6438
|
-
const embedLocation =
|
|
6490
|
+
const embedLocation = element.elementLocation;
|
|
6439
6491
|
|
|
6440
6492
|
if (embedLocation === undefined) {
|
|
6441
6493
|
throw new Error("ElementController - element named \"" + elementType + "\" is invalid");
|
|
@@ -6477,6 +6529,10 @@ class ElementController {
|
|
|
6477
6529
|
return messenger.self;
|
|
6478
6530
|
}
|
|
6479
6531
|
|
|
6532
|
+
get parent() {
|
|
6533
|
+
return messenger.parent;
|
|
6534
|
+
}
|
|
6535
|
+
|
|
6480
6536
|
get controller() {
|
|
6481
6537
|
return this._controller;
|
|
6482
6538
|
}
|
|
@@ -6521,15 +6577,7 @@ class IFrameController {
|
|
|
6521
6577
|
if (element.hasAttribute("fullscreen")) {
|
|
6522
6578
|
const style = document.createElement('style');
|
|
6523
6579
|
|
|
6524
|
-
style.textContent =
|
|
6525
|
-
._PlattarFullScreen {
|
|
6526
|
-
width: 100%;
|
|
6527
|
-
height: 100%;
|
|
6528
|
-
position: absolute;
|
|
6529
|
-
top: 0;
|
|
6530
|
-
left: 0;
|
|
6531
|
-
}
|
|
6532
|
-
`;
|
|
6580
|
+
style.textContent = `._PlattarFullScreen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; }`;
|
|
6533
6581
|
|
|
6534
6582
|
this._iframe.className = "_PlattarFullScreen";
|
|
6535
6583
|
|
|
@@ -6867,9 +6915,9 @@ module.exports = {
|
|
|
6867
6915
|
class Util {
|
|
6868
6916
|
static getServerLocation(server) {
|
|
6869
6917
|
switch (server) {
|
|
6870
|
-
case "production": return "https://app.plattar.com/
|
|
6871
|
-
case "staging": return "https://staging.plattar.space/
|
|
6872
|
-
case "dev": return "https://localhost/
|
|
6918
|
+
case "production": return "https://app.plattar.com/";
|
|
6919
|
+
case "staging": return "https://staging.plattar.space/";
|
|
6920
|
+
case "dev": return "https://localhost/";
|
|
6873
6921
|
default: return undefined;
|
|
6874
6922
|
}
|
|
6875
6923
|
}
|
|
@@ -6878,25 +6926,7 @@ class Util {
|
|
|
6878
6926
|
const isValid = Util.isValidType(etype);
|
|
6879
6927
|
|
|
6880
6928
|
if (isValid) {
|
|
6881
|
-
return etype + ".html";
|
|
6882
|
-
}
|
|
6883
|
-
|
|
6884
|
-
return undefined;
|
|
6885
|
-
}
|
|
6886
|
-
|
|
6887
|
-
static getElementBundleLocation(etype, server) {
|
|
6888
|
-
const location = Util.getServerLocation(server);
|
|
6889
|
-
|
|
6890
|
-
if (!location) {
|
|
6891
|
-
return undefined;
|
|
6892
|
-
}
|
|
6893
|
-
|
|
6894
|
-
const isValid = Util.isValidType(etype);
|
|
6895
|
-
|
|
6896
|
-
if (isValid) {
|
|
6897
|
-
const isMinified = location === "dev" ? false : true;
|
|
6898
|
-
|
|
6899
|
-
return isMinified ? (etype + "-bundle.min.js") : (etype + "-bundle.js");
|
|
6929
|
+
return "renderer/" + etype + ".html";
|
|
6900
6930
|
}
|
|
6901
6931
|
|
|
6902
6932
|
return undefined;
|
|
@@ -6939,7 +6969,7 @@ class Util {
|
|
|
6939
6969
|
|
|
6940
6970
|
module.exports = Util;
|
|
6941
6971
|
},{}],129:[function(require,module,exports){
|
|
6942
|
-
module.exports = "1.
|
|
6972
|
+
module.exports = "1.130.1";
|
|
6943
6973
|
|
|
6944
6974
|
},{}],130:[function(require,module,exports){
|
|
6945
6975
|
(function (global){(function (){
|