@plattar/plattar-ar-adapter 1.139.1 → 1.140.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 +455 -405
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +83 -48
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/scene-ar.d.ts +7 -1
- package/dist/ar/scene-ar.js +21 -4
- package/dist/embed/controllers/vto-controller.js +32 -1
- package/dist/util/util.d.ts +6 -1
- package/dist/util/util.js +29 -42
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/ar/scene-ar.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { LauncherAR } from "./launcher-ar";
|
|
2
|
+
export interface SceneVariationSelection {
|
|
3
|
+
readonly sceneProductID?: string;
|
|
4
|
+
readonly productID?: string;
|
|
5
|
+
readonly variationID?: string;
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* Performs AR functionality related to Plattar Scenes
|
|
4
9
|
*/
|
|
5
10
|
export declare class SceneAR extends LauncherAR {
|
|
6
11
|
private _analytics;
|
|
7
12
|
private readonly _sceneID;
|
|
13
|
+
private readonly _variationSelection;
|
|
8
14
|
private _ar;
|
|
9
|
-
constructor(sceneID?: string | undefined | null);
|
|
15
|
+
constructor(sceneID?: string | undefined | null, variationSelection?: SceneVariationSelection | undefined | null);
|
|
10
16
|
get sceneID(): string;
|
|
11
17
|
private _SetupAnalytics;
|
|
12
18
|
/**
|
package/dist/ar/scene-ar.js
CHANGED
|
@@ -16,7 +16,7 @@ const launcher_ar_1 = require("./launcher-ar");
|
|
|
16
16
|
* Performs AR functionality related to Plattar Scenes
|
|
17
17
|
*/
|
|
18
18
|
class SceneAR extends launcher_ar_1.LauncherAR {
|
|
19
|
-
constructor(sceneID = null) {
|
|
19
|
+
constructor(sceneID = null, variationSelection = null) {
|
|
20
20
|
super();
|
|
21
21
|
// analytics instance
|
|
22
22
|
this._analytics = null;
|
|
@@ -24,6 +24,7 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
24
24
|
throw new Error("SceneAR.constructor(sceneID) - sceneID must be defined");
|
|
25
25
|
}
|
|
26
26
|
this._sceneID = sceneID;
|
|
27
|
+
this._variationSelection = variationSelection || {};
|
|
27
28
|
this._ar = null;
|
|
28
29
|
}
|
|
29
30
|
get sceneID() {
|
|
@@ -67,9 +68,25 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
67
68
|
// add our scene products
|
|
68
69
|
sceneProducts.forEach((sceneProduct) => {
|
|
69
70
|
const product = sceneProduct.relationships.find(plattar_api_1.Product);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const selection = this._variationSelection;
|
|
72
|
+
// we have a specific product selection
|
|
73
|
+
if (sceneProduct.attributes.include_in_augment) {
|
|
74
|
+
// check if this product is the one we want (from selection optionally)
|
|
75
|
+
if (product && (product.id === selection.productID) && selection.variationID) {
|
|
76
|
+
configurator.addSceneProduct(sceneProduct.id, selection.variationID);
|
|
77
|
+
totalARObjectCount++;
|
|
78
|
+
}
|
|
79
|
+
else if (product) {
|
|
80
|
+
// check if this scene-product is the one we want (from selection)
|
|
81
|
+
if ((sceneProduct.id === selection.sceneProductID) && selection.variationID) {
|
|
82
|
+
configurator.addSceneProduct(sceneProduct.id, selection.variationID);
|
|
83
|
+
totalARObjectCount++;
|
|
84
|
+
}
|
|
85
|
+
else if (product.attributes.product_variation_id) {
|
|
86
|
+
configurator.addSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
|
|
87
|
+
totalARObjectCount++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
73
90
|
}
|
|
74
91
|
});
|
|
75
92
|
// add our scene models
|
|
@@ -49,12 +49,24 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
49
49
|
// optional attributes
|
|
50
50
|
const configState = this.getAttribute("config-state");
|
|
51
51
|
const showAR = this.getAttribute("show-ar");
|
|
52
|
+
const productID = this.getAttribute("product-id");
|
|
53
|
+
const sceneProductID = this.getAttribute("scene-product-id");
|
|
54
|
+
const variationID = this.getAttribute("variation-id");
|
|
52
55
|
if (configState) {
|
|
53
56
|
dst += "&config_state=" + configState;
|
|
54
57
|
}
|
|
55
58
|
if (showAR) {
|
|
56
59
|
dst += "&show_ar=" + showAR;
|
|
57
60
|
}
|
|
61
|
+
if (productID) {
|
|
62
|
+
dst += "&product_id=" + productID;
|
|
63
|
+
}
|
|
64
|
+
if (sceneProductID) {
|
|
65
|
+
dst += "&scene_product_id=" + sceneProductID;
|
|
66
|
+
}
|
|
67
|
+
if (variationID) {
|
|
68
|
+
dst += "&variation_id=" + variationID;
|
|
69
|
+
}
|
|
58
70
|
viewer.setAttribute("url", opt.url || dst);
|
|
59
71
|
viewer.onload = () => {
|
|
60
72
|
return accept(viewer);
|
|
@@ -86,12 +98,24 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
86
98
|
// optional attributes
|
|
87
99
|
const configState = this.getAttribute("config-state");
|
|
88
100
|
const showAR = this.getAttribute("show-ar");
|
|
101
|
+
const productID = this.getAttribute("product-id");
|
|
102
|
+
const sceneProductID = this.getAttribute("scene-product-id");
|
|
103
|
+
const variationID = this.getAttribute("variation-id");
|
|
89
104
|
if (configState) {
|
|
90
105
|
viewer.setAttribute("config-state", configState);
|
|
91
106
|
}
|
|
92
107
|
if (showAR) {
|
|
93
108
|
viewer.setAttribute("show-ar", showAR);
|
|
94
109
|
}
|
|
110
|
+
if (productID) {
|
|
111
|
+
viewer.setAttribute("product-id", productID);
|
|
112
|
+
}
|
|
113
|
+
if (sceneProductID) {
|
|
114
|
+
viewer.setAttribute("scene-product-id", sceneProductID);
|
|
115
|
+
}
|
|
116
|
+
if (variationID) {
|
|
117
|
+
viewer.setAttribute("variation-id", variationID);
|
|
118
|
+
}
|
|
95
119
|
viewer.onload = () => {
|
|
96
120
|
return accept(viewer);
|
|
97
121
|
};
|
|
@@ -194,7 +218,14 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
194
218
|
// otherwise no config-state or viewer is active
|
|
195
219
|
// fallback to using default SceneAR implementation
|
|
196
220
|
if (sceneID) {
|
|
197
|
-
const
|
|
221
|
+
const productID = this.getAttribute("product-id");
|
|
222
|
+
const sceneProductID = this.getAttribute("scene-product-id");
|
|
223
|
+
const variationID = this.getAttribute("variation-id");
|
|
224
|
+
const sceneAR = new __1.SceneAR(sceneID, {
|
|
225
|
+
productID: productID ? productID : undefined,
|
|
226
|
+
sceneProductID: sceneProductID ? sceneProductID : undefined,
|
|
227
|
+
variationID: variationID ? variationID : undefined
|
|
228
|
+
});
|
|
198
229
|
sceneAR.init().then(accept).catch(reject);
|
|
199
230
|
return;
|
|
200
231
|
}
|
package/dist/util/util.d.ts
CHANGED
|
@@ -6,8 +6,13 @@ export declare class Util {
|
|
|
6
6
|
static canQuicklook(): boolean;
|
|
7
7
|
static canSceneViewer(): boolean;
|
|
8
8
|
static canRealityViewer(): boolean;
|
|
9
|
-
static
|
|
9
|
+
static isSafariOnIOS(): boolean;
|
|
10
10
|
static isChromeOnIOS(): boolean;
|
|
11
|
+
static isIOS(): boolean;
|
|
12
|
+
static isAndroid(): boolean;
|
|
13
|
+
static isFirefox(): boolean;
|
|
14
|
+
static isOculus(): boolean;
|
|
15
|
+
static isSafari(): boolean;
|
|
11
16
|
static getIOSVersion(): number[];
|
|
12
17
|
static getChromeVersion(): number;
|
|
13
18
|
}
|
package/dist/util/util.js
CHANGED
|
@@ -6,58 +6,45 @@ exports.Util = void 0;
|
|
|
6
6
|
*/
|
|
7
7
|
class Util {
|
|
8
8
|
static canAugment() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// inside instagram browser
|
|
17
|
-
if (/\bInstagram/i.test(userAgent)) {
|
|
18
|
-
return false;
|
|
9
|
+
return Util.canQuicklook() || Util.canSceneViewer();
|
|
10
|
+
}
|
|
11
|
+
static canQuicklook() {
|
|
12
|
+
if (Util.isIOS()) {
|
|
13
|
+
const isWKWebView = Boolean((window && window).webkit && window.webkit.messageHandlers);
|
|
14
|
+
if (isWKWebView) {
|
|
15
|
+
return Boolean(/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent));
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
else if (/android/i.test(userAgent)) {
|
|
23
|
-
return true;
|
|
17
|
+
const tempAnchor = document.createElement("a");
|
|
18
|
+
return tempAnchor.relList && tempAnchor.relList.supports && tempAnchor.relList.supports("ar");
|
|
24
19
|
}
|
|
25
20
|
return false;
|
|
26
21
|
}
|
|
27
|
-
static canQuicklook() {
|
|
28
|
-
const tempAnchor = document.createElement("a");
|
|
29
|
-
return tempAnchor.relList &&
|
|
30
|
-
tempAnchor.relList.supports &&
|
|
31
|
-
tempAnchor.relList.supports("ar");
|
|
32
|
-
}
|
|
33
22
|
static canSceneViewer() {
|
|
34
|
-
return Util.
|
|
23
|
+
return Util.isAndroid() && !Util.isFirefox() && !Util.isOculus();
|
|
35
24
|
}
|
|
36
25
|
static canRealityViewer() {
|
|
37
|
-
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (/Macintosh|iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
|
41
|
-
if (Util.isSafari() && Util.getIOSVersion()[0] >= 13) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
26
|
+
return Util.isIOS() && Util.getIOSVersion()[0] >= 13;
|
|
46
27
|
}
|
|
47
|
-
static
|
|
48
|
-
|
|
49
|
-
return navigator.vendor.indexOf("Apple") > -1 &&
|
|
50
|
-
navigator.userAgent.indexOf("CriOS") === -1 &&
|
|
51
|
-
navigator.userAgent.indexOf("FxiOS") === -1;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
28
|
+
static isSafariOnIOS() {
|
|
29
|
+
return Util.isIOS() && Util.isSafari();
|
|
54
30
|
}
|
|
55
31
|
static isChromeOnIOS() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
32
|
+
return Util.isIOS() && /CriOS\//.test(navigator.userAgent);
|
|
33
|
+
}
|
|
34
|
+
static isIOS() {
|
|
35
|
+
return (/iPad|iPhone|iPod/.test(navigator.userAgent) && !self.MSStream) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
|
36
|
+
}
|
|
37
|
+
static isAndroid() {
|
|
38
|
+
return /android/i.test(navigator.userAgent);
|
|
39
|
+
}
|
|
40
|
+
static isFirefox() {
|
|
41
|
+
return /firefox/i.test(navigator.userAgent);
|
|
42
|
+
}
|
|
43
|
+
static isOculus() {
|
|
44
|
+
return /OculusBrowser/.test(navigator.userAgent);
|
|
45
|
+
}
|
|
46
|
+
static isSafari() {
|
|
47
|
+
return /Safari\//.test(navigator.userAgent);
|
|
61
48
|
}
|
|
62
49
|
static getIOSVersion() {
|
|
63
50
|
if (/iP(hone|od|ad)/.test(navigator.platform)) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.140.1";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plattar/plattar-ar-adapter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.140.1",
|
|
4
4
|
"description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@babel/cli": "^7.19.3",
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
48
|
+
"@babel/core": "^7.20.2",
|
|
49
|
+
"@babel/preset-env": "^7.20.2",
|
|
50
50
|
"browserify": "^17.0.0",
|
|
51
51
|
"typescript": "^4.8.4",
|
|
52
|
-
"uglify-js": "^3.17.
|
|
52
|
+
"uglify-js": "^3.17.4"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|