@plattar/plattar-ar-adapter 1.136.1 → 1.138.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/README.md +2 -35
- package/build/es2015/plattar-ar-adapter.js +3090 -5432
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +79 -36
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/raw-ar.d.ts +4 -1
- package/dist/ar/raw-ar.js +75 -32
- package/dist/embed/controllers/configurator-controller.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
package/dist/ar/raw-ar.d.ts
CHANGED
|
@@ -4,9 +4,12 @@ import { LauncherAR } from "./launcher-ar";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class RawAR extends LauncherAR {
|
|
6
6
|
private readonly _modelLocation;
|
|
7
|
+
private readonly _sceneID;
|
|
7
8
|
private _ar;
|
|
8
|
-
|
|
9
|
+
private _analytics;
|
|
10
|
+
constructor(modelLocation?: string | undefined | null, sceneID?: string | undefined | null);
|
|
9
11
|
get modelLocation(): string;
|
|
12
|
+
private _SetupAnalytics;
|
|
10
13
|
/**
|
|
11
14
|
* Initialise the RawAR instance. This returns a Promise that resolves
|
|
12
15
|
* successfully if initialisation is successful, otherwise it will fail.
|
package/dist/ar/raw-ar.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RawAR = void 0;
|
|
7
|
+
const plattar_analytics_1 = require("@plattar/plattar-analytics");
|
|
8
|
+
const plattar_api_1 = require("@plattar/plattar-api");
|
|
7
9
|
const util_1 = require("../util/util");
|
|
8
10
|
const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
|
|
9
11
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
@@ -13,14 +15,17 @@ const launcher_ar_1 = require("./launcher-ar");
|
|
|
13
15
|
* Allows launching AR Experiences provided a single remote 3D Model file
|
|
14
16
|
*/
|
|
15
17
|
class RawAR extends launcher_ar_1.LauncherAR {
|
|
16
|
-
constructor(modelLocation = null) {
|
|
18
|
+
constructor(modelLocation = null, sceneID = null) {
|
|
17
19
|
super();
|
|
20
|
+
// analytics instance
|
|
21
|
+
this._analytics = null;
|
|
18
22
|
if (!modelLocation) {
|
|
19
23
|
throw new Error("RawAR.constructor(modelLocation) - modelLocation must be defined");
|
|
20
24
|
}
|
|
21
25
|
const lowerLoc = modelLocation.toLowerCase();
|
|
22
26
|
if (lowerLoc.endsWith("usdz") || lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf") || lowerLoc.endsWith("reality")) {
|
|
23
27
|
this._modelLocation = modelLocation;
|
|
28
|
+
this._sceneID = sceneID;
|
|
24
29
|
this._ar = null;
|
|
25
30
|
}
|
|
26
31
|
else {
|
|
@@ -30,6 +35,33 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
30
35
|
get modelLocation() {
|
|
31
36
|
return this._modelLocation;
|
|
32
37
|
}
|
|
38
|
+
_SetupAnalytics() {
|
|
39
|
+
return new Promise((accept, _reject) => {
|
|
40
|
+
const sceneID = this._sceneID;
|
|
41
|
+
if (!sceneID) {
|
|
42
|
+
return accept();
|
|
43
|
+
}
|
|
44
|
+
const scene = new plattar_api_1.Scene(sceneID);
|
|
45
|
+
scene.include(plattar_api_1.Project);
|
|
46
|
+
scene.get().then((scene) => {
|
|
47
|
+
const analytics = new plattar_analytics_1.Analytics(scene.attributes.application_id);
|
|
48
|
+
analytics.origin = plattar_api_1.Server.location().type;
|
|
49
|
+
this._analytics = analytics;
|
|
50
|
+
analytics.data.push("type", "scene-ar");
|
|
51
|
+
analytics.data.push("sceneId", scene.id);
|
|
52
|
+
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
53
|
+
const application = scene.relationships.find(plattar_api_1.Project);
|
|
54
|
+
// setup application stuff (if any)
|
|
55
|
+
if (application) {
|
|
56
|
+
analytics.data.push("applicationId", application.id);
|
|
57
|
+
analytics.data.push("applicationTitle", application.attributes.title);
|
|
58
|
+
}
|
|
59
|
+
accept();
|
|
60
|
+
}).catch((_err) => {
|
|
61
|
+
accept();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
33
65
|
/**
|
|
34
66
|
* Initialise the RawAR instance. This returns a Promise that resolves
|
|
35
67
|
* successfully if initialisation is successful, otherwise it will fail.
|
|
@@ -42,39 +74,42 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
42
74
|
if (!util_1.Util.canAugment()) {
|
|
43
75
|
return reject(new Error("RawAR.init() - cannot proceed as AR not available in context"));
|
|
44
76
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
// send the analytics (if any)
|
|
78
|
+
this._SetupAnalytics().then(() => {
|
|
79
|
+
const modelLocation = this._modelLocation;
|
|
80
|
+
const lowerLoc = modelLocation.toLowerCase();
|
|
81
|
+
// we need to define our AR module here
|
|
82
|
+
// we are in Safari/Quicklook mode here
|
|
83
|
+
if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
|
|
84
|
+
// load the reality experience if dealing with reality file
|
|
85
|
+
if (lowerLoc.endsWith("reality") && util_1.Util.canRealityViewer()) {
|
|
86
|
+
this._ar = new reality_viewer_1.default();
|
|
87
|
+
this._ar.modelUrl = modelLocation;
|
|
88
|
+
return accept(this);
|
|
89
|
+
}
|
|
90
|
+
// load the usdz experience if dealing with usdz file
|
|
91
|
+
if (lowerLoc.endsWith("usdz") && util_1.Util.canQuicklook()) {
|
|
92
|
+
this._ar = new quicklook_viewer_1.default();
|
|
93
|
+
this._ar.modelUrl = modelLocation;
|
|
94
|
+
return accept(this);
|
|
95
|
+
}
|
|
96
|
+
return reject(new Error("RawAR.init() - cannot proceed as model is not a .usdz or .reality file"));
|
|
55
97
|
}
|
|
56
|
-
//
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
// check android
|
|
99
|
+
if (util_1.Util.canSceneViewer()) {
|
|
100
|
+
if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
|
|
101
|
+
const arviewer = new scene_viewer_1.default();
|
|
102
|
+
arviewer.modelUrl = modelLocation;
|
|
103
|
+
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
104
|
+
this._ar = arviewer;
|
|
105
|
+
return accept(this);
|
|
106
|
+
}
|
|
107
|
+
return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
|
|
61
108
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
|
|
67
|
-
const arviewer = new scene_viewer_1.default();
|
|
68
|
-
arviewer.modelUrl = modelLocation;
|
|
69
|
-
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
70
|
-
this._ar = arviewer;
|
|
71
|
-
return accept(this);
|
|
72
|
-
}
|
|
73
|
-
return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
|
|
74
|
-
}
|
|
75
|
-
// otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
|
|
76
|
-
// earlier in the process
|
|
77
|
-
return reject(new Error("RawAR.init() - could not initialise AR correctly, check values"));
|
|
109
|
+
// otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
|
|
110
|
+
// earlier in the process
|
|
111
|
+
return reject(new Error("RawAR.init() - could not initialise AR correctly, check values"));
|
|
112
|
+
});
|
|
78
113
|
});
|
|
79
114
|
}
|
|
80
115
|
/**
|
|
@@ -84,6 +119,14 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
84
119
|
if (!this._ar) {
|
|
85
120
|
throw new Error("RawAR.start() - cannot proceed as AR instance is null");
|
|
86
121
|
}
|
|
122
|
+
const analytics = this._analytics;
|
|
123
|
+
if (analytics) {
|
|
124
|
+
analytics.data.push("device", this._ar.device);
|
|
125
|
+
analytics.data.push("eventCategory", this._ar.nodeType);
|
|
126
|
+
analytics.data.push("eventAction", "Start Scene Augment");
|
|
127
|
+
analytics.write();
|
|
128
|
+
analytics.startRecordEngagement();
|
|
129
|
+
}
|
|
87
130
|
// this was initialised via the init() function
|
|
88
131
|
this._ar.start();
|
|
89
132
|
}
|
|
@@ -174,7 +174,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
174
174
|
output = "usdz";
|
|
175
175
|
}
|
|
176
176
|
viewer.messenger.getARFile(output).then((result) => {
|
|
177
|
-
const rawAR = new raw_ar_1.RawAR(result.filename);
|
|
177
|
+
const rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
|
|
178
178
|
return rawAR.init().then(accept).catch(reject);
|
|
179
179
|
}).catch(reject);
|
|
180
180
|
return;
|
|
@@ -200,7 +200,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
202
|
configurator.get().then((result) => {
|
|
203
|
-
const rawAR = new raw_ar_1.RawAR(result.filename);
|
|
203
|
+
const rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
|
|
204
204
|
rawAR.init().then(accept).catch(reject);
|
|
205
205
|
}).catch(reject);
|
|
206
206
|
return;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.
|
|
1
|
+
declare const _default: "1.138.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.138.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",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"@plattar/plattar-web": "^1.135.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/cli": "^7.
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/preset-env": "^7.
|
|
47
|
+
"@babel/cli": "^7.19.3",
|
|
48
|
+
"@babel/core": "^7.19.6",
|
|
49
|
+
"@babel/preset-env": "^7.19.4",
|
|
50
50
|
"browserify": "^17.0.0",
|
|
51
|
-
"typescript": "^4.8.
|
|
52
|
-
"uglify-js": "^3.17.
|
|
51
|
+
"typescript": "^4.8.4",
|
|
52
|
+
"uglify-js": "^3.17.3"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|