@plattar/plattar-ar-adapter 1.158.2 → 1.163.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 +571 -335
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +206 -100
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/configurator-ar.d.ts +6 -2
- package/dist/ar/configurator-ar.js +17 -8
- package/dist/ar/launcher-ar.d.ts +2 -0
- package/dist/ar/launcher-ar.js +2 -1
- package/dist/ar/model-ar.d.ts +6 -2
- package/dist/ar/model-ar.js +14 -4
- package/dist/ar/product-ar.d.ts +8 -4
- package/dist/ar/product-ar.js +28 -6
- package/dist/ar/raw-ar.d.ts +7 -3
- package/dist/ar/raw-ar.js +16 -8
- package/dist/ar/scene-ar.d.ts +7 -3
- package/dist/ar/scene-ar.js +16 -8
- package/dist/ar/scene-product-ar.d.ts +2 -2
- package/dist/ar/scene-product-ar.js +5 -4
- package/dist/embed/controllers/configurator-controller.js +16 -2
- package/dist/embed/controllers/plattar-controller.d.ts +12 -0
- package/dist/embed/controllers/plattar-controller.js +22 -0
- package/dist/embed/controllers/product-controller.js +11 -1
- package/dist/embed/controllers/vto-controller.js +7 -2
- package/dist/embed/plattar-embed.d.ts +2 -0
- package/dist/embed/plattar-embed.js +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/viewers/ar-viewer.d.ts +8 -1
- package/dist/viewers/ar-viewer.js +8 -2
- package/dist/viewers/quicklook-viewer.d.ts +1 -4
- package/dist/viewers/quicklook-viewer.js +9 -18
- package/dist/viewers/reality-viewer.d.ts +1 -1
- package/dist/viewers/reality-viewer.js +2 -5
- package/dist/viewers/scene-viewer.d.ts +1 -3
- package/dist/viewers/scene-viewer.js +9 -23
- package/package.json +7 -7
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { LauncherAR } from "./launcher-ar";
|
|
2
2
|
import { DecodedConfiguratorState } from "../util/configurator-state";
|
|
3
|
+
export interface ConfiguratorAROptions {
|
|
4
|
+
readonly state: DecodedConfiguratorState;
|
|
5
|
+
readonly useARBanner: boolean;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Performs AR functionality related to Plattar Scenes
|
|
5
9
|
*/
|
|
6
10
|
export declare class ConfiguratorAR extends LauncherAR {
|
|
7
11
|
private _analytics;
|
|
8
|
-
private
|
|
12
|
+
private _options;
|
|
9
13
|
private _ar;
|
|
10
|
-
constructor(
|
|
14
|
+
constructor(options: ConfiguratorAROptions);
|
|
11
15
|
private _SetupAnalytics;
|
|
12
16
|
/**
|
|
13
17
|
* Composes a Scene into an AR Model (remote operation) that can be used to launch
|
|
@@ -9,7 +9,6 @@ const plattar_api_1 = require("@plattar/plattar-api");
|
|
|
9
9
|
const plattar_services_1 = require("@plattar/plattar-services");
|
|
10
10
|
const util_1 = require("../util/util");
|
|
11
11
|
const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
|
|
12
|
-
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
13
12
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
14
13
|
const launcher_ar_1 = require("./launcher-ar");
|
|
15
14
|
const version_1 = __importDefault(require("../version"));
|
|
@@ -17,18 +16,18 @@ const version_1 = __importDefault(require("../version"));
|
|
|
17
16
|
* Performs AR functionality related to Plattar Scenes
|
|
18
17
|
*/
|
|
19
18
|
class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
20
|
-
constructor(
|
|
19
|
+
constructor(options) {
|
|
21
20
|
super();
|
|
22
21
|
// analytics instance
|
|
23
22
|
this._analytics = null;
|
|
24
|
-
if (!state) {
|
|
23
|
+
if (!options.state) {
|
|
25
24
|
throw new Error("ConfiguratorAR.constructor(state) - state must be defined");
|
|
26
25
|
}
|
|
27
|
-
this.
|
|
26
|
+
this._options = options;
|
|
28
27
|
this._ar = null;
|
|
29
28
|
}
|
|
30
29
|
_SetupAnalytics() {
|
|
31
|
-
const scene = this.
|
|
30
|
+
const scene = this._options.state.scene;
|
|
32
31
|
let analytics = null;
|
|
33
32
|
// setup scene stuff (if any)
|
|
34
33
|
if (scene) {
|
|
@@ -44,6 +43,13 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
44
43
|
if (application) {
|
|
45
44
|
analytics.data.push("applicationId", application.id);
|
|
46
45
|
analytics.data.push("applicationTitle", application.attributes.title);
|
|
46
|
+
if (this._options.useARBanner) {
|
|
47
|
+
this.options.banner = {
|
|
48
|
+
title: application.attributes.title,
|
|
49
|
+
subtitle: scene.attributes.title,
|
|
50
|
+
button: 'Visit'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
}
|
|
@@ -52,7 +58,7 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
52
58
|
* an AR File
|
|
53
59
|
*/
|
|
54
60
|
async _Compose(output) {
|
|
55
|
-
const objects = this.
|
|
61
|
+
const objects = this._options.state.state.array();
|
|
56
62
|
if (objects.length <= 0) {
|
|
57
63
|
throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain AR components");
|
|
58
64
|
}
|
|
@@ -89,7 +95,7 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
89
95
|
if (!util_1.Util.canAugment()) {
|
|
90
96
|
throw new Error("ConfiguratorAR.init() - cannot proceed as AR not available in context");
|
|
91
97
|
}
|
|
92
|
-
const scene = this.
|
|
98
|
+
const scene = this._options.state.scene;
|
|
93
99
|
this._SetupAnalytics();
|
|
94
100
|
const sceneOpt = scene.attributes.custom_json || {};
|
|
95
101
|
// we need to define our AR module here
|
|
@@ -100,8 +106,9 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
100
106
|
if (sceneOpt.anchor === "face") {
|
|
101
107
|
if (util_1.Util.canRealityViewer()) {
|
|
102
108
|
const modelUrl = await this._Compose("vto");
|
|
103
|
-
this._ar = new
|
|
109
|
+
this._ar = new quicklook_viewer_1.default();
|
|
104
110
|
this._ar.modelUrl = modelUrl;
|
|
111
|
+
this._ar.banner = this.options.banner;
|
|
105
112
|
return this;
|
|
106
113
|
}
|
|
107
114
|
else {
|
|
@@ -113,6 +120,7 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
113
120
|
const modelUrl = await this._Compose("usdz");
|
|
114
121
|
this._ar = new quicklook_viewer_1.default();
|
|
115
122
|
this._ar.modelUrl = modelUrl;
|
|
123
|
+
this._ar.banner = this.options.banner;
|
|
116
124
|
return this;
|
|
117
125
|
}
|
|
118
126
|
throw new Error("ConfiguratorAR.init() - cannot proceed as IOS device does not support AR Mode");
|
|
@@ -123,6 +131,7 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
|
|
|
123
131
|
const arviewer = new scene_viewer_1.default();
|
|
124
132
|
arviewer.modelUrl = modelUrl;
|
|
125
133
|
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
134
|
+
arviewer.banner = this.options.banner;
|
|
126
135
|
if (sceneOpt.anchor === "vertical") {
|
|
127
136
|
arviewer.isVertical = true;
|
|
128
137
|
}
|
package/dist/ar/launcher-ar.d.ts
CHANGED
package/dist/ar/launcher-ar.js
CHANGED
package/dist/ar/model-ar.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { LauncherAR } from "./launcher-ar";
|
|
2
|
+
export interface ModelAROptions {
|
|
3
|
+
readonly modelID: string;
|
|
4
|
+
readonly useARBanner: boolean;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Performs AT Functionality using Plattar FileModel types
|
|
4
8
|
*/
|
|
5
9
|
export declare class ModelAR extends LauncherAR {
|
|
6
10
|
private _analytics;
|
|
7
|
-
private readonly
|
|
11
|
+
private readonly _options;
|
|
8
12
|
private _ar;
|
|
9
|
-
constructor(
|
|
13
|
+
constructor(options: ModelAROptions);
|
|
10
14
|
get modelID(): string;
|
|
11
15
|
private _SetupAnalytics;
|
|
12
16
|
/**
|
package/dist/ar/model-ar.js
CHANGED
|
@@ -16,18 +16,18 @@ const version_1 = __importDefault(require("../version"));
|
|
|
16
16
|
* Performs AT Functionality using Plattar FileModel types
|
|
17
17
|
*/
|
|
18
18
|
class ModelAR extends launcher_ar_1.LauncherAR {
|
|
19
|
-
constructor(
|
|
19
|
+
constructor(options) {
|
|
20
20
|
super();
|
|
21
21
|
// analytics instance
|
|
22
22
|
this._analytics = null;
|
|
23
|
-
if (!modelID) {
|
|
23
|
+
if (!options.modelID) {
|
|
24
24
|
throw new Error("ModelAR.constructor(modelID) - modelID must be defined");
|
|
25
25
|
}
|
|
26
|
-
this.
|
|
26
|
+
this._options = options;
|
|
27
27
|
this._ar = null;
|
|
28
28
|
}
|
|
29
29
|
get modelID() {
|
|
30
|
-
return this.
|
|
30
|
+
return this._options.modelID;
|
|
31
31
|
}
|
|
32
32
|
_SetupAnalytics(model) {
|
|
33
33
|
let analytics = null;
|
|
@@ -43,6 +43,13 @@ class ModelAR extends launcher_ar_1.LauncherAR {
|
|
|
43
43
|
analytics.data.push("modelId", model.id);
|
|
44
44
|
analytics.data.push("modelTitle", model.attributes.title);
|
|
45
45
|
this._analytics = analytics;
|
|
46
|
+
if (this._options.useARBanner) {
|
|
47
|
+
this.options.banner = {
|
|
48
|
+
title: project.attributes.title,
|
|
49
|
+
subtitle: model.attributes.title,
|
|
50
|
+
button: 'Visit'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
}
|
|
48
55
|
/**
|
|
@@ -70,12 +77,14 @@ class ModelAR extends launcher_ar_1.LauncherAR {
|
|
|
70
77
|
if (model.attributes.reality_filename && util_1.Util.canRealityViewer()) {
|
|
71
78
|
this._ar = new reality_viewer_1.default();
|
|
72
79
|
this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.reality_filename;
|
|
80
|
+
this._ar.banner = this.options.banner;
|
|
73
81
|
return accept(this);
|
|
74
82
|
}
|
|
75
83
|
// otherwise, load the USDZ stuff second if available
|
|
76
84
|
if (model.attributes.usdz_filename && util_1.Util.canQuicklook()) {
|
|
77
85
|
this._ar = new quicklook_viewer_1.default();
|
|
78
86
|
this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.usdz_filename;
|
|
87
|
+
this._ar.banner = this.options.banner;
|
|
79
88
|
return accept(this);
|
|
80
89
|
}
|
|
81
90
|
return reject(new Error("ModelAR.init() - cannot proceed as ModelFile does not have a defined .usdz or .reality file"));
|
|
@@ -85,6 +94,7 @@ class ModelAR extends launcher_ar_1.LauncherAR {
|
|
|
85
94
|
const arviewer = new scene_viewer_1.default();
|
|
86
95
|
arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
|
|
87
96
|
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
97
|
+
arviewer.banner = this.options.banner;
|
|
88
98
|
this._ar = arviewer;
|
|
89
99
|
return accept(this);
|
|
90
100
|
}
|
package/dist/ar/product-ar.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { LauncherAR } from "./launcher-ar";
|
|
2
|
+
export interface ProductAROptions {
|
|
3
|
+
readonly productID: string;
|
|
4
|
+
readonly variationID: string | null;
|
|
5
|
+
readonly variationSKU: string | null;
|
|
6
|
+
readonly useARBanner: boolean;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* Performs AR functionality related to Plattar Products and Variation types
|
|
4
10
|
*/
|
|
5
11
|
export declare class ProductAR extends LauncherAR {
|
|
6
12
|
private _analytics;
|
|
7
|
-
private readonly
|
|
8
|
-
private readonly _variationID;
|
|
9
|
-
private readonly _variationSKU;
|
|
13
|
+
private readonly _options;
|
|
10
14
|
private _ar;
|
|
11
|
-
constructor(
|
|
15
|
+
constructor(options: ProductAROptions);
|
|
12
16
|
get productID(): string;
|
|
13
17
|
get variationID(): string | null;
|
|
14
18
|
get variationSKU(): string | null;
|
package/dist/ar/product-ar.js
CHANGED
|
@@ -16,26 +16,38 @@ const version_1 = __importDefault(require("../version"));
|
|
|
16
16
|
* Performs AR functionality related to Plattar Products and Variation types
|
|
17
17
|
*/
|
|
18
18
|
class ProductAR extends launcher_ar_1.LauncherAR {
|
|
19
|
-
|
|
19
|
+
/*
|
|
20
|
+
constructor(productID: string | undefined | null = null, variationID: string | undefined | null = null, variationSKU: string | undefined | null = null) {
|
|
20
21
|
super();
|
|
21
|
-
|
|
22
|
-
this._analytics = null;
|
|
22
|
+
|
|
23
23
|
if (!productID) {
|
|
24
24
|
throw new Error("ProductAR.constructor(productID, variationID) - productID must be defined");
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
this._productID = productID;
|
|
27
28
|
this._variationSKU = variationSKU;
|
|
28
29
|
this._variationID = variationID ? variationID : (variationSKU ? null : "default");
|
|
29
30
|
this._ar = null;
|
|
30
31
|
}
|
|
32
|
+
*/
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super();
|
|
35
|
+
// analytics instance
|
|
36
|
+
this._analytics = null;
|
|
37
|
+
if (!options.productID) {
|
|
38
|
+
throw new Error("ProductAR.constructor(productID, variationID) - productID must be defined");
|
|
39
|
+
}
|
|
40
|
+
this._options = options;
|
|
41
|
+
this._ar = null;
|
|
42
|
+
}
|
|
31
43
|
get productID() {
|
|
32
|
-
return this.
|
|
44
|
+
return this._options.productID;
|
|
33
45
|
}
|
|
34
46
|
get variationID() {
|
|
35
|
-
return this.
|
|
47
|
+
return this._options.variationID;
|
|
36
48
|
}
|
|
37
49
|
get variationSKU() {
|
|
38
|
-
return this.
|
|
50
|
+
return this._options.variationSKU;
|
|
39
51
|
}
|
|
40
52
|
_SetupAnalytics(product, variation) {
|
|
41
53
|
let analytics = null;
|
|
@@ -54,6 +66,13 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
54
66
|
if (application) {
|
|
55
67
|
analytics.data.push("applicationId", application.id);
|
|
56
68
|
analytics.data.push("applicationTitle", application.attributes.title);
|
|
69
|
+
if (this._options.useARBanner) {
|
|
70
|
+
this.options.banner = {
|
|
71
|
+
title: product.attributes.title,
|
|
72
|
+
subtitle: variation.attributes.title,
|
|
73
|
+
button: 'Visit'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
57
76
|
}
|
|
58
77
|
}
|
|
59
78
|
if (analytics) {
|
|
@@ -129,12 +148,14 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
129
148
|
if (model.attributes.reality_filename && util_1.Util.canRealityViewer()) {
|
|
130
149
|
this._ar = new reality_viewer_1.default();
|
|
131
150
|
this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.reality_filename;
|
|
151
|
+
this._ar.banner = this.options.banner;
|
|
132
152
|
return accept(this);
|
|
133
153
|
}
|
|
134
154
|
// otherwise, load the USDZ stuff second if available
|
|
135
155
|
if (model.attributes.usdz_filename && util_1.Util.canQuicklook()) {
|
|
136
156
|
this._ar = new quicklook_viewer_1.default();
|
|
137
157
|
this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.usdz_filename;
|
|
158
|
+
this._ar.banner = this.options.banner;
|
|
138
159
|
return accept(this);
|
|
139
160
|
}
|
|
140
161
|
return reject(new Error("ProductAR.init() - cannot proceed as ModelFile does not have a defined .usdz or .reality file"));
|
|
@@ -144,6 +165,7 @@ class ProductAR extends launcher_ar_1.LauncherAR {
|
|
|
144
165
|
const arviewer = new scene_viewer_1.default();
|
|
145
166
|
arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
|
|
146
167
|
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
168
|
+
arviewer.banner = this.options.banner;
|
|
147
169
|
const scene = product.relationships.find(plattar_api_1.Scene);
|
|
148
170
|
if (scene) {
|
|
149
171
|
const sceneOpt = scene.attributes.custom_json || {};
|
package/dist/ar/raw-ar.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { LauncherAR } from "./launcher-ar";
|
|
2
|
+
export interface RawAROptions {
|
|
3
|
+
readonly modelLocation: string;
|
|
4
|
+
readonly sceneID: string | null;
|
|
5
|
+
readonly useARBanner: boolean;
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* Allows launching AR Experiences provided a single remote 3D Model file
|
|
4
9
|
*/
|
|
5
10
|
export declare class RawAR extends LauncherAR {
|
|
6
|
-
private readonly
|
|
7
|
-
private readonly _sceneID;
|
|
11
|
+
private readonly _options;
|
|
8
12
|
private _ar;
|
|
9
13
|
private _analytics;
|
|
10
|
-
constructor(
|
|
14
|
+
constructor(options: RawAROptions);
|
|
11
15
|
get modelLocation(): string;
|
|
12
16
|
private _SetupAnalytics;
|
|
13
17
|
/**
|
package/dist/ar/raw-ar.js
CHANGED
|
@@ -16,17 +16,16 @@ const version_1 = __importDefault(require("../version"));
|
|
|
16
16
|
* Allows launching AR Experiences provided a single remote 3D Model file
|
|
17
17
|
*/
|
|
18
18
|
class RawAR extends launcher_ar_1.LauncherAR {
|
|
19
|
-
constructor(
|
|
19
|
+
constructor(options) {
|
|
20
20
|
super();
|
|
21
21
|
// analytics instance
|
|
22
22
|
this._analytics = null;
|
|
23
|
-
if (!modelLocation) {
|
|
23
|
+
if (!options.modelLocation) {
|
|
24
24
|
throw new Error("RawAR.constructor(modelLocation) - modelLocation must be defined");
|
|
25
25
|
}
|
|
26
|
-
const lowerLoc = modelLocation.toLowerCase();
|
|
26
|
+
const lowerLoc = options.modelLocation.toLowerCase();
|
|
27
27
|
if (lowerLoc.endsWith("usdz") || lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf") || lowerLoc.endsWith("reality")) {
|
|
28
|
-
this.
|
|
29
|
-
this._sceneID = sceneID;
|
|
28
|
+
this._options = options;
|
|
30
29
|
this._ar = null;
|
|
31
30
|
}
|
|
32
31
|
else {
|
|
@@ -34,11 +33,11 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
get modelLocation() {
|
|
37
|
-
return this.
|
|
36
|
+
return this._options.modelLocation;
|
|
38
37
|
}
|
|
39
38
|
_SetupAnalytics() {
|
|
40
39
|
return new Promise((accept, _reject) => {
|
|
41
|
-
const sceneID = this.
|
|
40
|
+
const sceneID = this._options.sceneID;
|
|
42
41
|
if (!sceneID) {
|
|
43
42
|
return accept();
|
|
44
43
|
}
|
|
@@ -57,6 +56,13 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
57
56
|
if (application) {
|
|
58
57
|
analytics.data.push("applicationId", application.id);
|
|
59
58
|
analytics.data.push("applicationTitle", application.attributes.title);
|
|
59
|
+
if (this._options.useARBanner) {
|
|
60
|
+
this.options.banner = {
|
|
61
|
+
title: application.attributes.title,
|
|
62
|
+
subtitle: scene.attributes.title,
|
|
63
|
+
button: 'Visit'
|
|
64
|
+
};
|
|
65
|
+
}
|
|
60
66
|
}
|
|
61
67
|
accept();
|
|
62
68
|
}).catch((_err) => {
|
|
@@ -78,7 +84,7 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
78
84
|
}
|
|
79
85
|
// send the analytics (if any)
|
|
80
86
|
this._SetupAnalytics().then(() => {
|
|
81
|
-
const modelLocation = this.
|
|
87
|
+
const modelLocation = this._options.modelLocation;
|
|
82
88
|
const lowerLoc = modelLocation.toLowerCase();
|
|
83
89
|
// we need to define our AR module here
|
|
84
90
|
// we are in Safari/Quicklook mode here
|
|
@@ -87,6 +93,7 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
87
93
|
if (lowerLoc.endsWith("reality") && util_1.Util.canRealityViewer()) {
|
|
88
94
|
this._ar = new reality_viewer_1.default();
|
|
89
95
|
this._ar.modelUrl = modelLocation;
|
|
96
|
+
this._ar.banner = this.options.banner;
|
|
90
97
|
return accept(this);
|
|
91
98
|
}
|
|
92
99
|
// load the usdz experience if dealing with usdz file
|
|
@@ -103,6 +110,7 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
103
110
|
const arviewer = new scene_viewer_1.default();
|
|
104
111
|
arviewer.modelUrl = modelLocation;
|
|
105
112
|
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
113
|
+
arviewer.banner = this.options.banner;
|
|
106
114
|
this._ar = arviewer;
|
|
107
115
|
return accept(this);
|
|
108
116
|
}
|
package/dist/ar/scene-ar.d.ts
CHANGED
|
@@ -4,15 +4,19 @@ export interface SceneVariationSelection {
|
|
|
4
4
|
readonly productID?: string;
|
|
5
5
|
readonly variationID?: string;
|
|
6
6
|
}
|
|
7
|
+
export interface SceneAROptions {
|
|
8
|
+
readonly sceneID: string;
|
|
9
|
+
readonly variationSelection: SceneVariationSelection;
|
|
10
|
+
readonly useARBanner: boolean;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* Performs AR functionality related to Plattar Scenes
|
|
9
14
|
*/
|
|
10
15
|
export declare class SceneAR extends LauncherAR {
|
|
11
16
|
private _analytics;
|
|
12
|
-
private readonly
|
|
13
|
-
private readonly _variationSelection;
|
|
17
|
+
private readonly _options;
|
|
14
18
|
private _ar;
|
|
15
|
-
constructor(
|
|
19
|
+
constructor(options: SceneAROptions);
|
|
16
20
|
get sceneID(): string;
|
|
17
21
|
private _SetupAnalytics;
|
|
18
22
|
/**
|
package/dist/ar/scene-ar.js
CHANGED
|
@@ -9,7 +9,6 @@ const plattar_api_1 = require("@plattar/plattar-api");
|
|
|
9
9
|
const plattar_services_1 = require("@plattar/plattar-services");
|
|
10
10
|
const util_1 = require("../util/util");
|
|
11
11
|
const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
|
|
12
|
-
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
13
12
|
const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
|
|
14
13
|
const launcher_ar_1 = require("./launcher-ar");
|
|
15
14
|
const version_1 = __importDefault(require("../version"));
|
|
@@ -17,19 +16,18 @@ const version_1 = __importDefault(require("../version"));
|
|
|
17
16
|
* Performs AR functionality related to Plattar Scenes
|
|
18
17
|
*/
|
|
19
18
|
class SceneAR extends launcher_ar_1.LauncherAR {
|
|
20
|
-
constructor(
|
|
19
|
+
constructor(options) {
|
|
21
20
|
super();
|
|
22
21
|
// analytics instance
|
|
23
22
|
this._analytics = null;
|
|
24
|
-
if (!sceneID) {
|
|
23
|
+
if (!options.sceneID) {
|
|
25
24
|
throw new Error("SceneAR.constructor(sceneID) - sceneID must be defined");
|
|
26
25
|
}
|
|
27
|
-
this.
|
|
28
|
-
this._variationSelection = variationSelection || {};
|
|
26
|
+
this._options = options;
|
|
29
27
|
this._ar = null;
|
|
30
28
|
}
|
|
31
29
|
get sceneID() {
|
|
32
|
-
return this.
|
|
30
|
+
return this._options.sceneID;
|
|
33
31
|
}
|
|
34
32
|
_SetupAnalytics(scene) {
|
|
35
33
|
let analytics = null;
|
|
@@ -47,6 +45,13 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
47
45
|
if (application) {
|
|
48
46
|
analytics.data.push("applicationId", application.id);
|
|
49
47
|
analytics.data.push("applicationTitle", application.attributes.title);
|
|
48
|
+
if (this._options.useARBanner) {
|
|
49
|
+
this.options.banner = {
|
|
50
|
+
title: application.attributes.title,
|
|
51
|
+
subtitle: scene.attributes.title,
|
|
52
|
+
button: 'Visit'
|
|
53
|
+
};
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
}
|
|
@@ -70,7 +75,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
70
75
|
// add our scene products
|
|
71
76
|
sceneProducts.forEach((sceneProduct) => {
|
|
72
77
|
const product = sceneProduct.relationships.find(plattar_api_1.Product);
|
|
73
|
-
const selection = this.
|
|
78
|
+
const selection = this._options.variationSelection;
|
|
74
79
|
// we have a specific product selection
|
|
75
80
|
if (sceneProduct.attributes.include_in_augment) {
|
|
76
81
|
// check if this product is the one we want (from selection optionally)
|
|
@@ -135,8 +140,9 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
135
140
|
if (sceneOpt.anchor === "face") {
|
|
136
141
|
if (util_1.Util.canRealityViewer()) {
|
|
137
142
|
return this._ComposeScene(scene, "vto").then((modelUrl) => {
|
|
138
|
-
this._ar = new
|
|
143
|
+
this._ar = new quicklook_viewer_1.default();
|
|
139
144
|
this._ar.modelUrl = modelUrl;
|
|
145
|
+
this._ar.banner = this.options.banner;
|
|
140
146
|
return accept(this);
|
|
141
147
|
}).catch(reject);
|
|
142
148
|
}
|
|
@@ -149,6 +155,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
149
155
|
return this._ComposeScene(scene, "usdz").then((modelUrl) => {
|
|
150
156
|
this._ar = new quicklook_viewer_1.default();
|
|
151
157
|
this._ar.modelUrl = modelUrl;
|
|
158
|
+
this._ar.banner = this.options.banner;
|
|
152
159
|
return accept(this);
|
|
153
160
|
}).catch(reject);
|
|
154
161
|
}
|
|
@@ -160,6 +167,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
160
167
|
const arviewer = new scene_viewer_1.default();
|
|
161
168
|
arviewer.modelUrl = modelUrl;
|
|
162
169
|
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
170
|
+
arviewer.banner = this.options.banner;
|
|
163
171
|
if (sceneOpt.anchor === "vertical") {
|
|
164
172
|
arviewer.isVertical = true;
|
|
165
173
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductAR } from "./product-ar";
|
|
1
|
+
import { ProductAR, ProductAROptions } from "./product-ar";
|
|
2
2
|
import { LauncherAR } from "./launcher-ar";
|
|
3
3
|
/**
|
|
4
4
|
* Allows launching Product AR by providing a SceneProduct ID instead.
|
|
@@ -7,7 +7,7 @@ import { LauncherAR } from "./launcher-ar";
|
|
|
7
7
|
export declare class SceneProductAR extends ProductAR {
|
|
8
8
|
private readonly _sceneProductID;
|
|
9
9
|
private _attachedProductID;
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(options: ProductAROptions);
|
|
11
11
|
get sceneProductID(): string;
|
|
12
12
|
get productID(): string;
|
|
13
13
|
init(): Promise<LauncherAR>;
|
|
@@ -9,14 +9,15 @@ const util_1 = require("../util/util");
|
|
|
9
9
|
* SceneProducts are much more convenient to grab from the Plattar CMS
|
|
10
10
|
*/
|
|
11
11
|
class SceneProductAR extends product_ar_1.ProductAR {
|
|
12
|
-
constructor(
|
|
13
|
-
super(sceneProductID, variationID, variationSKU);
|
|
12
|
+
constructor(options) {
|
|
13
|
+
//super(sceneProductID, variationID, variationSKU);
|
|
14
|
+
super(options);
|
|
14
15
|
// this is evaluated in the init() function
|
|
15
16
|
this._attachedProductID = null;
|
|
16
|
-
if (!
|
|
17
|
+
if (!options.productID) {
|
|
17
18
|
throw new Error("SceneProductAR.constructor(sceneProductID, variationID) - sceneProductID must be defined");
|
|
18
19
|
}
|
|
19
|
-
this._sceneProductID =
|
|
20
|
+
this._sceneProductID = options.productID;
|
|
20
21
|
}
|
|
21
22
|
get sceneProductID() {
|
|
22
23
|
return this._sceneProductID;
|
|
@@ -75,6 +75,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
75
75
|
this.parent.lockObserver();
|
|
76
76
|
this.parent.destroy();
|
|
77
77
|
this.setAttribute("product-id", product.scene_product_id);
|
|
78
|
+
this.removeAttribute("scene-id");
|
|
78
79
|
this.parent.unlockObserver();
|
|
79
80
|
const controller = this.parent.create();
|
|
80
81
|
if (controller) {
|
|
@@ -105,6 +106,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
105
106
|
this.parent.lockObserver();
|
|
106
107
|
this.parent.destroy();
|
|
107
108
|
this.setAttribute("product-id", product.scene_product_id);
|
|
109
|
+
this.removeAttribute("scene-id");
|
|
108
110
|
this.parent.unlockObserver();
|
|
109
111
|
const controller = this.parent.create();
|
|
110
112
|
if (controller) {
|
|
@@ -139,6 +141,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
139
141
|
let dst = plattar_api_1.Server.location().base + "renderer/configurator.html?scene_id=" + sceneID;
|
|
140
142
|
const showAR = this.getAttribute("show-ar");
|
|
141
143
|
const showUI = this.getAttribute("show-ui");
|
|
144
|
+
const showBanner = this.getAttribute("show-ar-banner");
|
|
142
145
|
if (showUI && showUI === "true") {
|
|
143
146
|
dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
|
|
144
147
|
}
|
|
@@ -148,6 +151,9 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
148
151
|
if (showAR) {
|
|
149
152
|
dst += "&show_ar=" + showAR;
|
|
150
153
|
}
|
|
154
|
+
if (showBanner) {
|
|
155
|
+
dst += "&show_ar_banner=" + showBanner;
|
|
156
|
+
}
|
|
151
157
|
viewer.setAttribute("url", opt.url || dst);
|
|
152
158
|
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
153
159
|
this._prevQROpt = opt;
|
|
@@ -176,6 +182,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
176
182
|
this.parent.lockObserver();
|
|
177
183
|
this.parent.destroy();
|
|
178
184
|
this.setAttribute("product-id", product.scene_product_id);
|
|
185
|
+
this.removeAttribute("scene-id");
|
|
179
186
|
this.parent.unlockObserver();
|
|
180
187
|
const controller = this.parent.create();
|
|
181
188
|
if (controller) {
|
|
@@ -232,6 +239,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
232
239
|
this.parent.lockObserver();
|
|
233
240
|
this.parent.destroy();
|
|
234
241
|
this.setAttribute("product-id", product.scene_product_id);
|
|
242
|
+
this.removeAttribute("scene-id");
|
|
235
243
|
this.parent.unlockObserver();
|
|
236
244
|
const controller = this.parent.create();
|
|
237
245
|
if (controller) {
|
|
@@ -263,7 +271,13 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
263
271
|
const state = (await this.getConfiguratorState()).state;
|
|
264
272
|
const first = state.first();
|
|
265
273
|
if (first) {
|
|
266
|
-
const sceneProductAR = new
|
|
274
|
+
//const sceneProductAR: SceneProductAR = new SceneProductAR(first.scene_product_id, first.product_variation_id);
|
|
275
|
+
const sceneProductAR = new scene_product_ar_1.SceneProductAR({
|
|
276
|
+
productID: first.scene_product_id,
|
|
277
|
+
variationID: first.product_variation_id,
|
|
278
|
+
variationSKU: null,
|
|
279
|
+
useARBanner: this.getBooleanAttribute("show-ar-banner")
|
|
280
|
+
});
|
|
267
281
|
return sceneProductAR.init();
|
|
268
282
|
}
|
|
269
283
|
throw new Error("ConfiguratorController.initAR() - invalid decoded config-state does not have any product states");
|
|
@@ -276,7 +290,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
276
290
|
if (!sceneID) {
|
|
277
291
|
throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
|
|
278
292
|
}
|
|
279
|
-
const configAR = new configurator_ar_1.ConfiguratorAR(await this.getConfiguratorState());
|
|
293
|
+
const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
|
|
280
294
|
return configAR.init();
|
|
281
295
|
}
|
|
282
296
|
removeRenderer() {
|
|
@@ -90,6 +90,12 @@ export declare abstract class PlattarController {
|
|
|
90
90
|
* @returns - The attribute value or null
|
|
91
91
|
*/
|
|
92
92
|
getAttribute(attribute: string): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the specified attribute from the parent as a boolean
|
|
95
|
+
* @param attribute - The name of the attribute
|
|
96
|
+
* @returns - The attribute value
|
|
97
|
+
*/
|
|
98
|
+
getBooleanAttribute(attribute: string): boolean;
|
|
93
99
|
/**
|
|
94
100
|
* Sets a particular attribute into the HTML DOM
|
|
95
101
|
*
|
|
@@ -97,6 +103,12 @@ export declare abstract class PlattarController {
|
|
|
97
103
|
* @param value - The value of the attribute
|
|
98
104
|
*/
|
|
99
105
|
setAttribute(attribute: string, value: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* Removes a particular attribute from HTML DOM
|
|
108
|
+
*
|
|
109
|
+
* @param attribute - The name of the attribute
|
|
110
|
+
*/
|
|
111
|
+
removeAttribute(attribute: string): void;
|
|
100
112
|
/**
|
|
101
113
|
* Appends the provided element into the shadow-root of the parent element
|
|
102
114
|
* @param element - The element to append
|