@plattar/plattar-ar-adapter 1.122.4 → 1.123.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.
@@ -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-configurator> HTML Element
5
+ */
6
+ export declare class ConfiguratorController 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,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfiguratorController = void 0;
4
+ const plattar_api_1 = require("@plattar/plattar-api");
5
+ const plattar_services_1 = require("@plattar/plattar-services");
6
+ const raw_ar_1 = require("../../ar/raw-ar");
7
+ const util_1 = require("../../util/util");
8
+ const plattar_controller_1 = require("./plattar-controller");
9
+ /**
10
+ * Manages an instance of the <plattar-configurator> HTML Element
11
+ */
12
+ class ConfiguratorController extends plattar_controller_1.PlattarController {
13
+ constructor(parent) {
14
+ super(parent);
15
+ this._state = plattar_controller_1.ControllerState.None;
16
+ this._element = null;
17
+ this._prevQROpt = null;
18
+ }
19
+ onAttributesUpdated() {
20
+ const state = this._state;
21
+ // re-render the QR Code when attributes have changed
22
+ if (state === plattar_controller_1.ControllerState.QRCode) {
23
+ this.startQRCode(this._prevQROpt);
24
+ return;
25
+ }
26
+ }
27
+ startQRCode(options) {
28
+ return new Promise((accept, reject) => {
29
+ // remove the old renderer instance if any
30
+ this.removeRenderer();
31
+ const sceneID = this.getAttribute("scene-id");
32
+ if (sceneID) {
33
+ const opt = options || plattar_controller_1.PlattarController.DEFAULT_QR_OPTIONS;
34
+ const viewer = document.createElement("plattar-qrcode");
35
+ // required attributes with defaults for plattar-viewer node
36
+ const width = this.getAttribute("width") || "500px";
37
+ const height = this.getAttribute("height") || "500px";
38
+ viewer.setAttribute("width", width);
39
+ viewer.setAttribute("height", height);
40
+ if (opt.color) {
41
+ viewer.setAttribute("color", opt.color);
42
+ }
43
+ if (opt.margin) {
44
+ viewer.setAttribute("margin", "" + opt.margin);
45
+ }
46
+ if (opt.qrType) {
47
+ viewer.setAttribute("qr-type", opt.qrType);
48
+ }
49
+ let dst = plattar_api_1.Server.location().base + "renderer/configurator.html?scene_id=" + sceneID;
50
+ // optional attributes
51
+ const configState = this.getAttribute("config-state");
52
+ const showAR = this.getAttribute("show-ar");
53
+ if (configState) {
54
+ dst += "&config_state=" + configState;
55
+ }
56
+ if (showAR) {
57
+ dst += "&show_ar=" + showAR;
58
+ }
59
+ viewer.setAttribute("url", opt.url || dst);
60
+ viewer.onload = () => {
61
+ return accept(viewer);
62
+ };
63
+ this.append(viewer);
64
+ this._element = viewer;
65
+ this._state = plattar_controller_1.ControllerState.QRCode;
66
+ this._prevQROpt = opt;
67
+ return;
68
+ }
69
+ return reject(new Error("ConfiguratorController.startQRCode() - minimum required attributes not set, use scene-id as a minimum"));
70
+ });
71
+ }
72
+ startRenderer() {
73
+ return new Promise((accept, reject) => {
74
+ // remove the old renderer instance if any
75
+ this.removeRenderer();
76
+ const sceneID = this.getAttribute("scene-id");
77
+ if (sceneID) {
78
+ // required attributes with defaults for plattar-configurator node
79
+ const width = this.getAttribute("width") || "500px";
80
+ const height = this.getAttribute("height") || "500px";
81
+ const server = this.getAttribute("server") || "production";
82
+ const viewer = document.createElement("plattar-configurator");
83
+ viewer.setAttribute("width", width);
84
+ viewer.setAttribute("height", height);
85
+ viewer.setAttribute("server", server);
86
+ viewer.setAttribute("scene-id", sceneID);
87
+ // optional attributes
88
+ const configState = this.getAttribute("config-state");
89
+ const showAR = this.getAttribute("show-ar");
90
+ if (configState) {
91
+ viewer.setAttribute("config-state", configState);
92
+ }
93
+ if (showAR) {
94
+ viewer.setAttribute("show-ar", showAR);
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("ConfiguratorController.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("ConfiguratorController.initAR() - cannot proceed as AR not available in context"));
119
+ }
120
+ // if scene ID is available and the state is a configurator viewer
121
+ // we can use the real-time configurator state to launch the AR view
122
+ const viewer = this.element;
123
+ const sceneID = this.getAttribute("scene-id");
124
+ if (viewer && sceneID) {
125
+ let output = "glb";
126
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
127
+ output = "usdz";
128
+ }
129
+ return viewer.messenger.getARFile(output).then((result) => {
130
+ const rawAR = new raw_ar_1.RawAR(result.filename);
131
+ return rawAR.init().then(accept).catch(reject);
132
+ }).catch(reject);
133
+ }
134
+ const configState = this.getAttribute("config-state");
135
+ // otherwise scene ID is available to the viewer is not launched
136
+ // we can use the static configuration state to launch the AR view
137
+ if (sceneID && configState) {
138
+ try {
139
+ const decodedb64State = atob(configState);
140
+ const state = JSON.parse(decodedb64State);
141
+ if (state.meta) {
142
+ const sceneProductIndex = state.meta.scene_product_index || 0;
143
+ const variationIndex = state.meta.product_variation_index || 1;
144
+ const states = state.states || [];
145
+ if (states.length > 0) {
146
+ const configurator = new plattar_services_1.Configurator();
147
+ states.forEach((productState) => {
148
+ configurator.addSceneProduct(productState[sceneProductIndex], productState[variationIndex]);
149
+ });
150
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
151
+ configurator.output = "usdz";
152
+ }
153
+ if (util_1.Util.canSceneViewer()) {
154
+ configurator.output = "glb";
155
+ }
156
+ const server = this.getAttribute("server") || "production";
157
+ configurator.server = server;
158
+ return configurator.get().then((result) => {
159
+ const rawAR = new raw_ar_1.RawAR(result.filename);
160
+ rawAR.init().then(accept).catch(reject);
161
+ }).catch(reject);
162
+ }
163
+ return reject(new Error("ConfiguratorController.initAR() - invalid config-state does not have any product states"));
164
+ }
165
+ return reject(new Error("ConfiguratorController.initAR() - invalid config-state for configurator"));
166
+ }
167
+ catch (err) {
168
+ return reject(err);
169
+ }
170
+ }
171
+ return reject(new Error("ConfiguratorController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
172
+ });
173
+ }
174
+ removeRenderer() {
175
+ if (this._element) {
176
+ this._element.remove();
177
+ this._element = null;
178
+ return true;
179
+ }
180
+ return false;
181
+ }
182
+ get element() {
183
+ return this._element;
184
+ }
185
+ }
186
+ exports.ConfiguratorController = ConfiguratorController;
@@ -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,17 +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 _currentState;
8
7
  private _currentType;
9
- private _qrCodeOptions;
10
- private _sceneID;
11
- private _productID;
12
- private _variationID;
13
- private _width;
14
- private _height;
15
- private _isReady;
16
- private _server;
17
- private _viewer;
8
+ private _controller;
18
9
  constructor();
19
10
  get viewer(): HTMLElement | null;
20
11
  connectedCallback(): void;