@plattar/plattar-ar-adapter 1.122.2 → 1.123.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.
- package/build/es2015/plattar-ar-adapter.js +8330 -5562
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +1450 -447
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/launcher-ar.d.ts +8 -1
- package/dist/ar/launcher-ar.js +12 -0
- package/dist/ar/model-ar.d.ts +0 -5
- package/dist/ar/model-ar.js +1 -12
- package/dist/ar/product-ar.d.ts +1 -6
- package/dist/ar/product-ar.js +3 -14
- package/dist/ar/raw-ar.d.ts +25 -0
- package/dist/ar/raw-ar.js +98 -0
- package/dist/ar/scene-ar.d.ts +21 -1
- package/dist/ar/scene-ar.js +148 -5
- package/dist/embed/controllers/configurator-controller.d.ts +18 -0
- package/dist/embed/controllers/configurator-controller.js +186 -0
- package/dist/embed/controllers/plattar-controller.d.ts +62 -0
- package/dist/embed/controllers/plattar-controller.js +51 -0
- package/dist/embed/controllers/product-controller.d.ts +18 -0
- package/dist/embed/controllers/product-controller.js +141 -0
- package/dist/embed/controllers/viewer-controller.d.ts +18 -0
- package/dist/embed/controllers/viewer-controller.js +155 -0
- package/dist/embed/plattar-embed.d.ts +2 -10
- package/dist/embed/plattar-embed.js +54 -224
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -5
- package/dist/ar/configurator-ar.d.ts +0 -9
- package/dist/ar/configurator-ar.js +0 -19
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { LauncherAR } from "../../ar/launcher-ar";
|
|
2
|
+
export declare enum ControllerState {
|
|
3
|
+
None = 0,
|
|
4
|
+
Renderer = 1,
|
|
5
|
+
QRCode = 2
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* All Plattar Controllers are derived from the same interface
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class PlattarController {
|
|
11
|
+
/**
|
|
12
|
+
* Default QR Code rendering options
|
|
13
|
+
*/
|
|
14
|
+
static get DEFAULT_QR_OPTIONS(): any;
|
|
15
|
+
private readonly _parent;
|
|
16
|
+
constructor(parent: HTMLElement);
|
|
17
|
+
/**
|
|
18
|
+
* Called by the parent when a HTML Attribute has changed and the controller
|
|
19
|
+
* requires an update
|
|
20
|
+
*/
|
|
21
|
+
abstract onAttributesUpdated(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Start Rendering a QR Code with the provided options
|
|
24
|
+
* @param options (optional) - The QR Code Options
|
|
25
|
+
*/
|
|
26
|
+
abstract startQRCode(options: any | undefined | null): Promise<HTMLElement>;
|
|
27
|
+
/**
|
|
28
|
+
* Start the underlying Plattar Renderer for this Controller
|
|
29
|
+
*/
|
|
30
|
+
abstract startRenderer(): Promise<HTMLElement>;
|
|
31
|
+
/**
|
|
32
|
+
* Initialise and start AR mode if available
|
|
33
|
+
*/
|
|
34
|
+
abstract startAR(): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Initialise and return a launcher that can be used to start AR
|
|
37
|
+
*/
|
|
38
|
+
abstract initAR(): Promise<LauncherAR>;
|
|
39
|
+
/**
|
|
40
|
+
* Removes the currently active renderer view from the DOM
|
|
41
|
+
*/
|
|
42
|
+
abstract removeRenderer(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Get the underlying renderer component (if any)
|
|
45
|
+
*/
|
|
46
|
+
abstract get element(): HTMLElement | null;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the Parent Instance
|
|
49
|
+
*/
|
|
50
|
+
get parent(): HTMLElement;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the specified attribute from the parent
|
|
53
|
+
* @param attribute - The name of thhe attribute
|
|
54
|
+
* @returns - The attribute value or null
|
|
55
|
+
*/
|
|
56
|
+
getAttribute(attribute: string): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Appends the provided element into the shadow-root of the parent element
|
|
59
|
+
* @param element - The element to append
|
|
60
|
+
*/
|
|
61
|
+
append(element: HTMLElement): void;
|
|
62
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlattarController = exports.ControllerState = void 0;
|
|
4
|
+
var ControllerState;
|
|
5
|
+
(function (ControllerState) {
|
|
6
|
+
ControllerState[ControllerState["None"] = 0] = "None";
|
|
7
|
+
ControllerState[ControllerState["Renderer"] = 1] = "Renderer";
|
|
8
|
+
ControllerState[ControllerState["QRCode"] = 2] = "QRCode";
|
|
9
|
+
})(ControllerState = exports.ControllerState || (exports.ControllerState = {}));
|
|
10
|
+
/**
|
|
11
|
+
* All Plattar Controllers are derived from the same interface
|
|
12
|
+
*/
|
|
13
|
+
class PlattarController {
|
|
14
|
+
constructor(parent) {
|
|
15
|
+
this._parent = parent;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Default QR Code rendering options
|
|
19
|
+
*/
|
|
20
|
+
static get DEFAULT_QR_OPTIONS() {
|
|
21
|
+
return {
|
|
22
|
+
color: "#101721",
|
|
23
|
+
qrType: "default",
|
|
24
|
+
margin: 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the Parent Instance
|
|
30
|
+
*/
|
|
31
|
+
get parent() {
|
|
32
|
+
return this._parent;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the specified attribute from the parent
|
|
36
|
+
* @param attribute - The name of thhe attribute
|
|
37
|
+
* @returns - The attribute value or null
|
|
38
|
+
*/
|
|
39
|
+
getAttribute(attribute) {
|
|
40
|
+
return this.parent ? (this.parent.hasAttribute(attribute) ? this.parent.getAttribute(attribute) : null) : null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Appends the provided element into the shadow-root of the parent element
|
|
44
|
+
* @param element - The element to append
|
|
45
|
+
*/
|
|
46
|
+
append(element) {
|
|
47
|
+
const shadow = this.parent.shadowRoot || this.parent.attachShadow({ mode: 'open' });
|
|
48
|
+
shadow.append(element);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.PlattarController = PlattarController;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LauncherAR } from "../../ar/launcher-ar";
|
|
2
|
+
import { PlattarController } from "./plattar-controller";
|
|
3
|
+
/**
|
|
4
|
+
* Manages an instance of the <plattar-product> HTML Element
|
|
5
|
+
*/
|
|
6
|
+
export declare class ProductController extends PlattarController {
|
|
7
|
+
private _state;
|
|
8
|
+
private _element;
|
|
9
|
+
private _prevQROpt;
|
|
10
|
+
constructor(parent: HTMLElement);
|
|
11
|
+
onAttributesUpdated(): void;
|
|
12
|
+
startQRCode(options: any): Promise<HTMLElement>;
|
|
13
|
+
startRenderer(): Promise<HTMLElement>;
|
|
14
|
+
startAR(): Promise<void>;
|
|
15
|
+
initAR(): Promise<LauncherAR>;
|
|
16
|
+
removeRenderer(): boolean;
|
|
17
|
+
get element(): HTMLElement | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductController = void 0;
|
|
4
|
+
const plattar_api_1 = require("@plattar/plattar-api");
|
|
5
|
+
const product_ar_1 = require("../../ar/product-ar");
|
|
6
|
+
const util_1 = require("../../util/util");
|
|
7
|
+
const plattar_controller_1 = require("./plattar-controller");
|
|
8
|
+
/**
|
|
9
|
+
* Manages an instance of the <plattar-product> HTML Element
|
|
10
|
+
*/
|
|
11
|
+
class ProductController extends plattar_controller_1.PlattarController {
|
|
12
|
+
constructor(parent) {
|
|
13
|
+
super(parent);
|
|
14
|
+
this._state = plattar_controller_1.ControllerState.None;
|
|
15
|
+
this._element = null;
|
|
16
|
+
this._prevQROpt = null;
|
|
17
|
+
}
|
|
18
|
+
onAttributesUpdated() {
|
|
19
|
+
const state = this._state;
|
|
20
|
+
// re-render the QR Code when attributes have changed
|
|
21
|
+
if (state === plattar_controller_1.ControllerState.QRCode) {
|
|
22
|
+
this.startQRCode(this._prevQROpt);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// use the messenger function to change variation when attributes have changed
|
|
26
|
+
if (state === plattar_controller_1.ControllerState.Renderer) {
|
|
27
|
+
const viewer = this._element;
|
|
28
|
+
if (viewer) {
|
|
29
|
+
const variationID = this.getAttribute("variation-id");
|
|
30
|
+
viewer.messenger.selectVariation(variationID);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
startQRCode(options) {
|
|
36
|
+
return new Promise((accept, reject) => {
|
|
37
|
+
// remove the old renderer instance if any
|
|
38
|
+
this.removeRenderer();
|
|
39
|
+
const productID = this.getAttribute("product-id");
|
|
40
|
+
if (productID) {
|
|
41
|
+
const opt = options || plattar_controller_1.PlattarController.DEFAULT_QR_OPTIONS;
|
|
42
|
+
const viewer = document.createElement("plattar-qrcode");
|
|
43
|
+
// required attributes with defaults for plattar-viewer node
|
|
44
|
+
const width = this.getAttribute("width") || "500px";
|
|
45
|
+
const height = this.getAttribute("height") || "500px";
|
|
46
|
+
viewer.setAttribute("width", width);
|
|
47
|
+
viewer.setAttribute("height", height);
|
|
48
|
+
if (opt.color) {
|
|
49
|
+
viewer.setAttribute("color", opt.color);
|
|
50
|
+
}
|
|
51
|
+
if (opt.margin) {
|
|
52
|
+
viewer.setAttribute("margin", "" + opt.margin);
|
|
53
|
+
}
|
|
54
|
+
if (opt.qrType) {
|
|
55
|
+
viewer.setAttribute("qr-type", opt.qrType);
|
|
56
|
+
}
|
|
57
|
+
// optional attributes
|
|
58
|
+
const variationID = this.getAttribute("variation-id");
|
|
59
|
+
let dst = plattar_api_1.Server.location().base + "renderer/product.html?product_id=" + productID;
|
|
60
|
+
if (variationID) {
|
|
61
|
+
dst += "&variation_id=" + variationID;
|
|
62
|
+
}
|
|
63
|
+
viewer.setAttribute("url", opt.url || dst);
|
|
64
|
+
viewer.onload = () => {
|
|
65
|
+
return accept(viewer);
|
|
66
|
+
};
|
|
67
|
+
this.append(viewer);
|
|
68
|
+
this._element = viewer;
|
|
69
|
+
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
70
|
+
this._prevQROpt = opt;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return reject(new Error("ProductController.startQRCode() - minimum required attributes not set, use product-id as a minimum"));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
startRenderer() {
|
|
77
|
+
return new Promise((accept, reject) => {
|
|
78
|
+
// remove the old renderer instance if any
|
|
79
|
+
this.removeRenderer();
|
|
80
|
+
const productID = this.getAttribute("product-id");
|
|
81
|
+
if (productID) {
|
|
82
|
+
// required attributes with defaults for plattar-product node
|
|
83
|
+
const width = this.getAttribute("width") || "500px";
|
|
84
|
+
const height = this.getAttribute("height") || "500px";
|
|
85
|
+
const server = this.getAttribute("server") || "production";
|
|
86
|
+
const viewer = document.createElement("plattar-product");
|
|
87
|
+
viewer.setAttribute("width", width);
|
|
88
|
+
viewer.setAttribute("height", height);
|
|
89
|
+
viewer.setAttribute("server", server);
|
|
90
|
+
viewer.setAttribute("product-id", productID);
|
|
91
|
+
// optional attributes
|
|
92
|
+
const variationID = this.getAttribute("variation-id");
|
|
93
|
+
if (variationID) {
|
|
94
|
+
viewer.setAttribute("variation-id", variationID);
|
|
95
|
+
}
|
|
96
|
+
viewer.onload = () => {
|
|
97
|
+
return accept(viewer);
|
|
98
|
+
};
|
|
99
|
+
this.append(viewer);
|
|
100
|
+
this._element = viewer;
|
|
101
|
+
this._state = plattar_controller_1.ControllerState.Renderer;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
return reject(new Error("ProductController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
startAR() {
|
|
108
|
+
return new Promise((accept, reject) => {
|
|
109
|
+
this.initAR().then((launcher) => {
|
|
110
|
+
launcher.start();
|
|
111
|
+
accept();
|
|
112
|
+
}).catch(reject);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
initAR() {
|
|
116
|
+
return new Promise((accept, reject) => {
|
|
117
|
+
if (!util_1.Util.canAugment()) {
|
|
118
|
+
return reject(new Error("ProductController.initAR() - cannot proceed as AR not available in context"));
|
|
119
|
+
}
|
|
120
|
+
const productID = this.getAttribute("product-id");
|
|
121
|
+
if (productID) {
|
|
122
|
+
const variationID = this.getAttribute("variation-id");
|
|
123
|
+
const product = new product_ar_1.ProductAR(productID, variationID);
|
|
124
|
+
return product.init().then(accept).catch(reject);
|
|
125
|
+
}
|
|
126
|
+
return reject(new Error("ProductController.initAR() - minimum required attributes not set, use product-id as a minimum"));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
removeRenderer() {
|
|
130
|
+
if (this._element) {
|
|
131
|
+
this._element.remove();
|
|
132
|
+
this._element = null;
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
get element() {
|
|
138
|
+
return this._element;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.ProductController = ProductController;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LauncherAR } from "../../ar/launcher-ar";
|
|
2
|
+
import { PlattarController } from "./plattar-controller";
|
|
3
|
+
/**
|
|
4
|
+
* Manages an instance of the <plattar-viewer> HTML Element
|
|
5
|
+
*/
|
|
6
|
+
export declare class ViewerController extends PlattarController {
|
|
7
|
+
private _state;
|
|
8
|
+
private _element;
|
|
9
|
+
private _prevQROpt;
|
|
10
|
+
constructor(parent: HTMLElement);
|
|
11
|
+
onAttributesUpdated(): void;
|
|
12
|
+
startQRCode(options: any): Promise<HTMLElement>;
|
|
13
|
+
startRenderer(): Promise<HTMLElement>;
|
|
14
|
+
startAR(): Promise<void>;
|
|
15
|
+
initAR(): Promise<LauncherAR>;
|
|
16
|
+
removeRenderer(): boolean;
|
|
17
|
+
get element(): HTMLElement | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ViewerController = void 0;
|
|
4
|
+
const plattar_api_1 = require("@plattar/plattar-api");
|
|
5
|
+
const product_ar_1 = require("../../ar/product-ar");
|
|
6
|
+
const util_1 = require("../../util/util");
|
|
7
|
+
const plattar_controller_1 = require("./plattar-controller");
|
|
8
|
+
/**
|
|
9
|
+
* Manages an instance of the <plattar-viewer> HTML Element
|
|
10
|
+
*/
|
|
11
|
+
class ViewerController extends plattar_controller_1.PlattarController {
|
|
12
|
+
constructor(parent) {
|
|
13
|
+
super(parent);
|
|
14
|
+
this._state = plattar_controller_1.ControllerState.None;
|
|
15
|
+
this._element = null;
|
|
16
|
+
this._prevQROpt = null;
|
|
17
|
+
}
|
|
18
|
+
onAttributesUpdated() {
|
|
19
|
+
const state = this._state;
|
|
20
|
+
// re-render the QR Code when attributes have changed
|
|
21
|
+
if (state === plattar_controller_1.ControllerState.QRCode) {
|
|
22
|
+
this.startQRCode(this._prevQROpt);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// use the messenger function to change variation when attributes have changed
|
|
26
|
+
if (state === plattar_controller_1.ControllerState.Renderer) {
|
|
27
|
+
const viewer = this._element;
|
|
28
|
+
if (viewer) {
|
|
29
|
+
const productID = this.getAttribute("product-id");
|
|
30
|
+
const variationID = this.getAttribute("variation-id");
|
|
31
|
+
viewer.messenger.selectVariation(productID, variationID);
|
|
32
|
+
}
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
startQRCode(options) {
|
|
37
|
+
return new Promise((accept, reject) => {
|
|
38
|
+
// remove the old renderer instance if any
|
|
39
|
+
this.removeRenderer();
|
|
40
|
+
const sceneID = this.getAttribute("scene-id");
|
|
41
|
+
if (sceneID) {
|
|
42
|
+
const opt = options || plattar_controller_1.PlattarController.DEFAULT_QR_OPTIONS;
|
|
43
|
+
const viewer = document.createElement("plattar-qrcode");
|
|
44
|
+
// required attributes with defaults for plattar-viewer node
|
|
45
|
+
const width = this.getAttribute("width") || "500px";
|
|
46
|
+
const height = this.getAttribute("height") || "500px";
|
|
47
|
+
viewer.setAttribute("width", width);
|
|
48
|
+
viewer.setAttribute("height", height);
|
|
49
|
+
if (opt.color) {
|
|
50
|
+
viewer.setAttribute("color", opt.color);
|
|
51
|
+
}
|
|
52
|
+
if (opt.margin) {
|
|
53
|
+
viewer.setAttribute("margin", "" + opt.margin);
|
|
54
|
+
}
|
|
55
|
+
if (opt.qrType) {
|
|
56
|
+
viewer.setAttribute("qr-type", opt.qrType);
|
|
57
|
+
}
|
|
58
|
+
let dst = plattar_api_1.Server.location().base + "renderer/viewer.html?scene_id=" + sceneID;
|
|
59
|
+
// optional attributes
|
|
60
|
+
const productID = this.getAttribute("product-id");
|
|
61
|
+
const variationID = this.getAttribute("variation-id");
|
|
62
|
+
if (productID) {
|
|
63
|
+
dst += "&productId=" + productID;
|
|
64
|
+
}
|
|
65
|
+
if (variationID) {
|
|
66
|
+
dst += "&variationId=" + variationID;
|
|
67
|
+
}
|
|
68
|
+
viewer.setAttribute("url", opt.url || dst);
|
|
69
|
+
viewer.onload = () => {
|
|
70
|
+
return accept(viewer);
|
|
71
|
+
};
|
|
72
|
+
this.append(viewer);
|
|
73
|
+
this._element = viewer;
|
|
74
|
+
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
75
|
+
this._prevQROpt = opt;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return reject(new Error("ViewerController.startQRCode() - minimum required attributes not set, use scene-id as a minimum"));
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
startRenderer() {
|
|
82
|
+
return new Promise((accept, reject) => {
|
|
83
|
+
// remove the old renderer instance if any
|
|
84
|
+
this.removeRenderer();
|
|
85
|
+
const sceneID = this.getAttribute("scene-id");
|
|
86
|
+
if (sceneID) {
|
|
87
|
+
// required attributes with defaults for plattar-viewer node
|
|
88
|
+
const width = this.getAttribute("width") || "500px";
|
|
89
|
+
const height = this.getAttribute("height") || "500px";
|
|
90
|
+
const server = this.getAttribute("server") || "production";
|
|
91
|
+
const viewer = document.createElement("plattar-viewer");
|
|
92
|
+
viewer.setAttribute("width", width);
|
|
93
|
+
viewer.setAttribute("height", height);
|
|
94
|
+
viewer.setAttribute("server", server);
|
|
95
|
+
viewer.setAttribute("scene-id", sceneID);
|
|
96
|
+
// optional attributes
|
|
97
|
+
const productID = this.getAttribute("product-id");
|
|
98
|
+
const variationID = this.getAttribute("variation-id");
|
|
99
|
+
if (productID) {
|
|
100
|
+
viewer.setAttribute("product-id", productID);
|
|
101
|
+
}
|
|
102
|
+
if (variationID) {
|
|
103
|
+
viewer.setAttribute("variation-id", variationID);
|
|
104
|
+
}
|
|
105
|
+
viewer.onload = () => {
|
|
106
|
+
return accept(viewer);
|
|
107
|
+
};
|
|
108
|
+
this.append(viewer);
|
|
109
|
+
this._element = viewer;
|
|
110
|
+
this._state = plattar_controller_1.ControllerState.Renderer;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
return reject(new Error("ViewerController.startRenderer() - minimum required attributes not set, use scene-id as a minimum"));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
startAR() {
|
|
117
|
+
return new Promise((accept, reject) => {
|
|
118
|
+
this.initAR().then((launcher) => {
|
|
119
|
+
launcher.start();
|
|
120
|
+
accept();
|
|
121
|
+
}).catch(reject);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
initAR() {
|
|
125
|
+
return new Promise((accept, reject) => {
|
|
126
|
+
if (!util_1.Util.canAugment()) {
|
|
127
|
+
return reject(new Error("ViewerController.initAR() - cannot proceed as AR not available in context"));
|
|
128
|
+
}
|
|
129
|
+
const productID = this.getAttribute("product-id");
|
|
130
|
+
if (productID) {
|
|
131
|
+
const variationID = this.getAttribute("variation-id");
|
|
132
|
+
const product = new product_ar_1.ProductAR(productID, variationID);
|
|
133
|
+
return product.init().then(accept).catch(reject);
|
|
134
|
+
}
|
|
135
|
+
const sceneID = this.getAttribute("scene-id");
|
|
136
|
+
// otherwise, scene was set so use SceneAR
|
|
137
|
+
if (sceneID) {
|
|
138
|
+
return reject(new Error("ViewerController.initAR() - AR mode for scene-id not yet supported, use product-id"));
|
|
139
|
+
}
|
|
140
|
+
return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id or product-id as a minimum"));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
removeRenderer() {
|
|
144
|
+
if (this._element) {
|
|
145
|
+
this._element.remove();
|
|
146
|
+
this._element = null;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
get element() {
|
|
152
|
+
return this._element;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.ViewerController = ViewerController;
|
|
@@ -4,16 +4,8 @@ import { LauncherAR } from "../ar/launcher-ar";
|
|
|
4
4
|
* of Plattar related content
|
|
5
5
|
*/
|
|
6
6
|
export default class PlattarEmbed extends HTMLElement {
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
private _sceneID;
|
|
10
|
-
private _productID;
|
|
11
|
-
private _variationID;
|
|
12
|
-
private _width;
|
|
13
|
-
private _height;
|
|
14
|
-
private _isReady;
|
|
15
|
-
private _server;
|
|
16
|
-
private _viewer;
|
|
7
|
+
private _currentType;
|
|
8
|
+
private _controller;
|
|
17
9
|
constructor();
|
|
18
10
|
get viewer(): HTMLElement | null;
|
|
19
11
|
connectedCallback(): void;
|