@plattar/plattar-ar-adapter 1.154.1 → 1.155.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.
- package/build/es2015/plattar-ar-adapter.js +2064 -1158
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +978 -783
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/configurator-ar.d.ts +29 -0
- package/dist/ar/configurator-ar.js +161 -0
- package/dist/ar/launcher-ar.js +3 -7
- package/dist/ar/model-ar.js +2 -0
- package/dist/ar/product-ar.js +2 -0
- package/dist/ar/raw-ar.js +2 -0
- package/dist/ar/scene-ar.js +2 -0
- package/dist/embed/controllers/configurator-controller.d.ts +4 -2
- package/dist/embed/controllers/configurator-controller.js +171 -179
- package/dist/embed/controllers/plattar-controller.d.ts +21 -1
- package/dist/embed/controllers/plattar-controller.js +138 -67
- package/dist/embed/controllers/product-controller.d.ts +6 -1
- package/dist/embed/controllers/product-controller.js +9 -2
- package/dist/embed/controllers/vto-controller.d.ts +4 -2
- package/dist/embed/controllers/vto-controller.js +190 -194
- package/dist/embed/plattar-embed.d.ts +23 -0
- package/dist/embed/plattar-embed.js +130 -91
- package/dist/util/configurator-state.d.ts +48 -6
- package/dist/util/configurator-state.js +145 -28
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/embed/controllers/viewer-controller.d.ts +0 -14
- package/dist/embed/controllers/viewer-controller.js +0 -193
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LauncherAR } from "./launcher-ar";
|
|
2
|
+
import { DecodedConfiguratorState } from "../util/configurator-state";
|
|
3
|
+
/**
|
|
4
|
+
* Performs AR functionality related to Plattar Scenes
|
|
5
|
+
*/
|
|
6
|
+
export declare class ConfiguratorAR extends LauncherAR {
|
|
7
|
+
private _analytics;
|
|
8
|
+
private _state;
|
|
9
|
+
private _ar;
|
|
10
|
+
constructor(state: DecodedConfiguratorState);
|
|
11
|
+
private _SetupAnalytics;
|
|
12
|
+
/**
|
|
13
|
+
* Composes a Scene into an AR Model (remote operation) that can be used to launch
|
|
14
|
+
* an AR File
|
|
15
|
+
*/
|
|
16
|
+
private _Compose;
|
|
17
|
+
/**
|
|
18
|
+
* Initialise the SceneAR instance. This returns a Promise that resolves
|
|
19
|
+
* successfully if initialisation is successful, otherwise it will fail.
|
|
20
|
+
*
|
|
21
|
+
* filure can occur for a number of reasons but it generally means that AR
|
|
22
|
+
* cannot be performed.
|
|
23
|
+
*/
|
|
24
|
+
init(): Promise<LauncherAR>;
|
|
25
|
+
start(): void;
|
|
26
|
+
canQuicklook(): boolean;
|
|
27
|
+
canRealityViewer(): boolean;
|
|
28
|
+
canSceneViewer(): boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConfiguratorAR = void 0;
|
|
7
|
+
const plattar_analytics_1 = require("@plattar/plattar-analytics");
|
|
8
|
+
const plattar_api_1 = require("@plattar/plattar-api");
|
|
9
|
+
const plattar_services_1 = require("@plattar/plattar-services");
|
|
10
|
+
const util_1 = require("../util/util");
|
|
11
|
+
const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
|
|
12
|
+
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
13
|
+
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
14
|
+
const launcher_ar_1 = require("./launcher-ar");
|
|
15
|
+
const version_1 = __importDefault(require("../version"));
|
|
16
|
+
/**
|
|
17
|
+
* Performs AR functionality related to Plattar Scenes
|
|
18
|
+
*/
|
|
19
|
+
class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
20
|
+
constructor(state) {
|
|
21
|
+
super();
|
|
22
|
+
// analytics instance
|
|
23
|
+
this._analytics = null;
|
|
24
|
+
if (!state) {
|
|
25
|
+
throw new Error("ConfiguratorAR.constructor(state) - state must be defined");
|
|
26
|
+
}
|
|
27
|
+
this._state = state;
|
|
28
|
+
this._ar = null;
|
|
29
|
+
}
|
|
30
|
+
_SetupAnalytics() {
|
|
31
|
+
const scene = this._state.scene;
|
|
32
|
+
let analytics = null;
|
|
33
|
+
// setup scene stuff (if any)
|
|
34
|
+
if (scene) {
|
|
35
|
+
analytics = new plattar_analytics_1.Analytics(scene.attributes.application_id);
|
|
36
|
+
analytics.origin = plattar_api_1.Server.location().type;
|
|
37
|
+
this._analytics = analytics;
|
|
38
|
+
analytics.data.push("type", "scene-ar");
|
|
39
|
+
analytics.data.push("sdkVersion", version_1.default);
|
|
40
|
+
analytics.data.push("sceneId", scene.id);
|
|
41
|
+
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
42
|
+
const application = scene.relationships.find(plattar_api_1.Project);
|
|
43
|
+
// setup application stuff (if any)
|
|
44
|
+
if (application) {
|
|
45
|
+
analytics.data.push("applicationId", application.id);
|
|
46
|
+
analytics.data.push("applicationTitle", application.attributes.title);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Composes a Scene into an AR Model (remote operation) that can be used to launch
|
|
52
|
+
* an AR File
|
|
53
|
+
*/
|
|
54
|
+
async _Compose(output) {
|
|
55
|
+
const objects = this._state.state.array();
|
|
56
|
+
if (objects.length <= 0) {
|
|
57
|
+
throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain AR components");
|
|
58
|
+
}
|
|
59
|
+
// define our configurator
|
|
60
|
+
const configurator = new plattar_services_1.Configurator();
|
|
61
|
+
configurator.server = plattar_api_1.Server.location().type;
|
|
62
|
+
configurator.output = output;
|
|
63
|
+
let totalARObjectCount = 0;
|
|
64
|
+
objects.forEach((object) => {
|
|
65
|
+
if (object.meta_data.augment) {
|
|
66
|
+
if (object.meta_data.type === "scenemodel") {
|
|
67
|
+
configurator.addModel(object.scene_product_id);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
configurator.addSceneProduct(object.scene_product_id, object.product_variation_id);
|
|
71
|
+
}
|
|
72
|
+
totalARObjectCount++;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (totalARObjectCount <= 0) {
|
|
76
|
+
throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain any enabled AR components");
|
|
77
|
+
}
|
|
78
|
+
const results = await configurator.get();
|
|
79
|
+
return results.filename;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Initialise the SceneAR instance. This returns a Promise that resolves
|
|
83
|
+
* successfully if initialisation is successful, otherwise it will fail.
|
|
84
|
+
*
|
|
85
|
+
* filure can occur for a number of reasons but it generally means that AR
|
|
86
|
+
* cannot be performed.
|
|
87
|
+
*/
|
|
88
|
+
async init() {
|
|
89
|
+
if (!util_1.Util.canAugment()) {
|
|
90
|
+
throw new Error("ConfiguratorAR.init() - cannot proceed as AR not available in context");
|
|
91
|
+
}
|
|
92
|
+
const scene = this._state.scene;
|
|
93
|
+
this._SetupAnalytics();
|
|
94
|
+
const sceneOpt = scene.attributes.custom_json || {};
|
|
95
|
+
// we need to define our AR module here
|
|
96
|
+
// we are in Safari/Quicklook mode here
|
|
97
|
+
if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
|
|
98
|
+
// we need to launch a VTO experience here
|
|
99
|
+
// VTO requires Reality Support
|
|
100
|
+
if (sceneOpt.anchor === "face") {
|
|
101
|
+
if (util_1.Util.canRealityViewer()) {
|
|
102
|
+
const modelUrl = await this._Compose("vto");
|
|
103
|
+
this._ar = new reality_viewer_1.default();
|
|
104
|
+
this._ar.modelUrl = modelUrl;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
throw new Error("ConfiguratorAR.init() - cannot proceed as VTO AR requires Reality Viewer support");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// otherwise, load the USDZ stuff second if available
|
|
112
|
+
if (util_1.Util.canQuicklook()) {
|
|
113
|
+
const modelUrl = await this._Compose("usdz");
|
|
114
|
+
this._ar = new quicklook_viewer_1.default();
|
|
115
|
+
this._ar.modelUrl = modelUrl;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
throw new Error("ConfiguratorAR.init() - cannot proceed as IOS device does not support AR Mode");
|
|
119
|
+
}
|
|
120
|
+
// check android
|
|
121
|
+
if (util_1.Util.canSceneViewer()) {
|
|
122
|
+
const modelUrl = await this._Compose("glb");
|
|
123
|
+
const arviewer = new scene_viewer_1.default();
|
|
124
|
+
arviewer.modelUrl = modelUrl;
|
|
125
|
+
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
126
|
+
if (sceneOpt.anchor === "vertical") {
|
|
127
|
+
arviewer.isVertical = true;
|
|
128
|
+
}
|
|
129
|
+
this._ar = arviewer;
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
// otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
|
|
133
|
+
// earlier in the process
|
|
134
|
+
throw new Error("ConfiguratorAR.init() - could not initialise AR correctly, check values");
|
|
135
|
+
}
|
|
136
|
+
start() {
|
|
137
|
+
if (!this._ar) {
|
|
138
|
+
throw new Error("SceneAR.start() - cannot proceed as AR instance is null");
|
|
139
|
+
}
|
|
140
|
+
const analytics = this._analytics;
|
|
141
|
+
if (analytics) {
|
|
142
|
+
analytics.data.push("device", this._ar.device);
|
|
143
|
+
analytics.data.push("eventCategory", this._ar.nodeType);
|
|
144
|
+
analytics.data.push("eventAction", "Start Scene Augment");
|
|
145
|
+
analytics.write();
|
|
146
|
+
analytics.startRecordEngagement();
|
|
147
|
+
}
|
|
148
|
+
// this was initialised via the init() function
|
|
149
|
+
this._ar.start();
|
|
150
|
+
}
|
|
151
|
+
canQuicklook() {
|
|
152
|
+
return this._ar && this._ar.nodeType === "Quick Look" ? true : false;
|
|
153
|
+
}
|
|
154
|
+
canRealityViewer() {
|
|
155
|
+
return this._ar && this._ar.nodeType === "Reality Viewer" ? true : false;
|
|
156
|
+
}
|
|
157
|
+
canSceneViewer() {
|
|
158
|
+
return this._ar && this._ar.nodeType === "Scene Viewer" ? true : false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.ConfiguratorAR = ConfiguratorAR;
|
package/dist/ar/launcher-ar.js
CHANGED
|
@@ -11,13 +11,9 @@ class LauncherAR {
|
|
|
11
11
|
* Initialise and launch with a single function call. this is mostly for convenience.
|
|
12
12
|
* Use .init() and .start() separately for fine-grained control
|
|
13
13
|
*/
|
|
14
|
-
launch() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value.start();
|
|
18
|
-
return accept();
|
|
19
|
-
}).catch(reject);
|
|
20
|
-
});
|
|
14
|
+
async launch() {
|
|
15
|
+
const value = await this.init();
|
|
16
|
+
return value.start();
|
|
21
17
|
}
|
|
22
18
|
/**
|
|
23
19
|
* AR Options used for launching AR
|
package/dist/ar/model-ar.js
CHANGED
|
@@ -11,6 +11,7 @@ const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"
|
|
|
11
11
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
12
12
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
13
13
|
const launcher_ar_1 = require("./launcher-ar");
|
|
14
|
+
const version_1 = __importDefault(require("../version"));
|
|
14
15
|
/**
|
|
15
16
|
* Performs AT Functionality using Plattar FileModel types
|
|
16
17
|
*/
|
|
@@ -36,6 +37,7 @@ class ModelAR extends launcher_ar_1.LauncherAR {
|
|
|
36
37
|
analytics = new plattar_analytics_1.Analytics(project.id);
|
|
37
38
|
analytics.origin = plattar_api_1.Server.location().type;
|
|
38
39
|
analytics.data.push("type", "model-ar");
|
|
40
|
+
analytics.data.push("sdkVersion", version_1.default);
|
|
39
41
|
analytics.data.push("applicationId", project.id);
|
|
40
42
|
analytics.data.push("applicationTitle", project.attributes.title);
|
|
41
43
|
analytics.data.push("modelId", model.id);
|
package/dist/ar/product-ar.js
CHANGED
|
@@ -11,6 +11,7 @@ const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"
|
|
|
11
11
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
12
12
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
13
13
|
const launcher_ar_1 = require("./launcher-ar");
|
|
14
|
+
const version_1 = __importDefault(require("../version"));
|
|
14
15
|
/**
|
|
15
16
|
* Performs AR functionality related to Plattar Products and Variation types
|
|
16
17
|
*/
|
|
@@ -45,6 +46,7 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
45
46
|
analytics.origin = plattar_api_1.Server.location().type;
|
|
46
47
|
this._analytics = analytics;
|
|
47
48
|
analytics.data.push("type", "product-ar");
|
|
49
|
+
analytics.data.push("sdkVersion", version_1.default);
|
|
48
50
|
analytics.data.push("sceneId", scene.id);
|
|
49
51
|
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
50
52
|
const application = scene.relationships.find(plattar_api_1.Project);
|
package/dist/ar/raw-ar.js
CHANGED
|
@@ -11,6 +11,7 @@ const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"
|
|
|
11
11
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
12
12
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
13
13
|
const launcher_ar_1 = require("./launcher-ar");
|
|
14
|
+
const version_1 = __importDefault(require("../version"));
|
|
14
15
|
/**
|
|
15
16
|
* Allows launching AR Experiences provided a single remote 3D Model file
|
|
16
17
|
*/
|
|
@@ -48,6 +49,7 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
48
49
|
analytics.origin = plattar_api_1.Server.location().type;
|
|
49
50
|
this._analytics = analytics;
|
|
50
51
|
analytics.data.push("type", "scene-ar");
|
|
52
|
+
analytics.data.push("sdkVersion", version_1.default);
|
|
51
53
|
analytics.data.push("sceneId", scene.id);
|
|
52
54
|
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
53
55
|
const application = scene.relationships.find(plattar_api_1.Project);
|
package/dist/ar/scene-ar.js
CHANGED
|
@@ -12,6 +12,7 @@ const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"
|
|
|
12
12
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
13
13
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
14
14
|
const launcher_ar_1 = require("./launcher-ar");
|
|
15
|
+
const version_1 = __importDefault(require("../version"));
|
|
15
16
|
/**
|
|
16
17
|
* Performs AR functionality related to Plattar Scenes
|
|
17
18
|
*/
|
|
@@ -38,6 +39,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
38
39
|
analytics.origin = plattar_api_1.Server.location().type;
|
|
39
40
|
this._analytics = analytics;
|
|
40
41
|
analytics.data.push("type", "scene-ar");
|
|
42
|
+
analytics.data.push("sdkVersion", version_1.default);
|
|
41
43
|
analytics.data.push("sceneId", scene.id);
|
|
42
44
|
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
43
45
|
const application = scene.relationships.find(plattar_api_1.Project);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { LauncherAR } from "../../ar/launcher-ar";
|
|
2
|
+
import { DecodedConfiguratorState } from "../../util/configurator-state";
|
|
2
3
|
import { PlattarController } from "./plattar-controller";
|
|
3
4
|
/**
|
|
4
5
|
* Manages an instance of the <plattar-configurator> HTML Element
|
|
5
6
|
*/
|
|
6
7
|
export declare class ConfiguratorController extends PlattarController {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
private _cachedConfigState;
|
|
9
|
+
getConfiguratorState(): Promise<DecodedConfiguratorState>;
|
|
10
|
+
onAttributesUpdated(attributeName: string): Promise<void>;
|
|
9
11
|
startViewerQRCode(options: any): Promise<HTMLElement>;
|
|
10
12
|
startRenderer(): Promise<HTMLElement>;
|
|
11
13
|
initAR(): Promise<LauncherAR>;
|