@plattar/plattar-ar-adapter 1.136.1 → 1.139.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
|
@@ -352,6 +352,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
352
352
|
};
|
|
353
353
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
354
354
|
exports.RawAR = void 0;
|
|
355
|
+
const plattar_analytics_1 = require("@plattar/plattar-analytics");
|
|
356
|
+
const plattar_api_1 = require("@plattar/plattar-api");
|
|
355
357
|
const util_1 = require("../util/util");
|
|
356
358
|
const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
|
|
357
359
|
const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
|
|
@@ -361,14 +363,17 @@ const launcher_ar_1 = require("./launcher-ar");
|
|
|
361
363
|
* Allows launching AR Experiences provided a single remote 3D Model file
|
|
362
364
|
*/
|
|
363
365
|
class RawAR extends launcher_ar_1.LauncherAR {
|
|
364
|
-
constructor(modelLocation = null) {
|
|
366
|
+
constructor(modelLocation = null, sceneID = null) {
|
|
365
367
|
super();
|
|
368
|
+
// analytics instance
|
|
369
|
+
this._analytics = null;
|
|
366
370
|
if (!modelLocation) {
|
|
367
371
|
throw new Error("RawAR.constructor(modelLocation) - modelLocation must be defined");
|
|
368
372
|
}
|
|
369
373
|
const lowerLoc = modelLocation.toLowerCase();
|
|
370
374
|
if (lowerLoc.endsWith("usdz") || lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf") || lowerLoc.endsWith("reality")) {
|
|
371
375
|
this._modelLocation = modelLocation;
|
|
376
|
+
this._sceneID = sceneID;
|
|
372
377
|
this._ar = null;
|
|
373
378
|
}
|
|
374
379
|
else {
|
|
@@ -378,6 +383,33 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
378
383
|
get modelLocation() {
|
|
379
384
|
return this._modelLocation;
|
|
380
385
|
}
|
|
386
|
+
_SetupAnalytics() {
|
|
387
|
+
return new Promise((accept, _reject) => {
|
|
388
|
+
const sceneID = this._sceneID;
|
|
389
|
+
if (!sceneID) {
|
|
390
|
+
return accept();
|
|
391
|
+
}
|
|
392
|
+
const scene = new plattar_api_1.Scene(sceneID);
|
|
393
|
+
scene.include(plattar_api_1.Project);
|
|
394
|
+
scene.get().then((scene) => {
|
|
395
|
+
const analytics = new plattar_analytics_1.Analytics(scene.attributes.application_id);
|
|
396
|
+
analytics.origin = plattar_api_1.Server.location().type;
|
|
397
|
+
this._analytics = analytics;
|
|
398
|
+
analytics.data.push("type", "scene-ar");
|
|
399
|
+
analytics.data.push("sceneId", scene.id);
|
|
400
|
+
analytics.data.push("sceneTitle", scene.attributes.title);
|
|
401
|
+
const application = scene.relationships.find(plattar_api_1.Project);
|
|
402
|
+
// setup application stuff (if any)
|
|
403
|
+
if (application) {
|
|
404
|
+
analytics.data.push("applicationId", application.id);
|
|
405
|
+
analytics.data.push("applicationTitle", application.attributes.title);
|
|
406
|
+
}
|
|
407
|
+
accept();
|
|
408
|
+
}).catch((_err) => {
|
|
409
|
+
accept();
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}
|
|
381
413
|
/**
|
|
382
414
|
* Initialise the RawAR instance. This returns a Promise that resolves
|
|
383
415
|
* successfully if initialisation is successful, otherwise it will fail.
|
|
@@ -390,39 +422,42 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
390
422
|
if (!util_1.Util.canAugment()) {
|
|
391
423
|
return reject(new Error("RawAR.init() - cannot proceed as AR not available in context"));
|
|
392
424
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
//
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
425
|
+
// send the analytics (if any)
|
|
426
|
+
this._SetupAnalytics().then(() => {
|
|
427
|
+
const modelLocation = this._modelLocation;
|
|
428
|
+
const lowerLoc = modelLocation.toLowerCase();
|
|
429
|
+
// we need to define our AR module here
|
|
430
|
+
// we are in Safari/Quicklook mode here
|
|
431
|
+
if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
|
|
432
|
+
// load the reality experience if dealing with reality file
|
|
433
|
+
if (lowerLoc.endsWith("reality") && util_1.Util.canRealityViewer()) {
|
|
434
|
+
this._ar = new reality_viewer_1.default();
|
|
435
|
+
this._ar.modelUrl = modelLocation;
|
|
436
|
+
return accept(this);
|
|
437
|
+
}
|
|
438
|
+
// load the usdz experience if dealing with usdz file
|
|
439
|
+
if (lowerLoc.endsWith("usdz") && util_1.Util.canQuicklook()) {
|
|
440
|
+
this._ar = new quicklook_viewer_1.default();
|
|
441
|
+
this._ar.modelUrl = modelLocation;
|
|
442
|
+
return accept(this);
|
|
443
|
+
}
|
|
444
|
+
return reject(new Error("RawAR.init() - cannot proceed as model is not a .usdz or .reality file"));
|
|
409
445
|
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return
|
|
446
|
+
// check android
|
|
447
|
+
if (util_1.Util.canSceneViewer()) {
|
|
448
|
+
if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
|
|
449
|
+
const arviewer = new scene_viewer_1.default();
|
|
450
|
+
arviewer.modelUrl = modelLocation;
|
|
451
|
+
arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
|
|
452
|
+
this._ar = arviewer;
|
|
453
|
+
return accept(this);
|
|
454
|
+
}
|
|
455
|
+
return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
|
|
420
456
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return reject(new Error("RawAR.init() - could not initialise AR correctly, check values"));
|
|
457
|
+
// otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
|
|
458
|
+
// earlier in the process
|
|
459
|
+
return reject(new Error("RawAR.init() - could not initialise AR correctly, check values"));
|
|
460
|
+
});
|
|
426
461
|
});
|
|
427
462
|
}
|
|
428
463
|
/**
|
|
@@ -432,6 +467,14 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
432
467
|
if (!this._ar) {
|
|
433
468
|
throw new Error("RawAR.start() - cannot proceed as AR instance is null");
|
|
434
469
|
}
|
|
470
|
+
const analytics = this._analytics;
|
|
471
|
+
if (analytics) {
|
|
472
|
+
analytics.data.push("device", this._ar.device);
|
|
473
|
+
analytics.data.push("eventCategory", this._ar.nodeType);
|
|
474
|
+
analytics.data.push("eventAction", "Start Scene Augment");
|
|
475
|
+
analytics.write();
|
|
476
|
+
analytics.startRecordEngagement();
|
|
477
|
+
}
|
|
435
478
|
// this was initialised via the init() function
|
|
436
479
|
this._ar.start();
|
|
437
480
|
}
|
|
@@ -447,7 +490,7 @@ class RawAR extends launcher_ar_1.LauncherAR {
|
|
|
447
490
|
}
|
|
448
491
|
exports.RawAR = RawAR;
|
|
449
492
|
|
|
450
|
-
},{"../util/util":15,"../viewers/quicklook-viewer":18,"../viewers/reality-viewer":19,"../viewers/scene-viewer":20,"./launcher-ar":1}],5:[function(require,module,exports){
|
|
493
|
+
},{"../util/util":15,"../viewers/quicklook-viewer":18,"../viewers/reality-viewer":19,"../viewers/scene-viewer":20,"./launcher-ar":1,"@plattar/plattar-analytics":39,"@plattar/plattar-api":43}],5:[function(require,module,exports){
|
|
451
494
|
"use strict";
|
|
452
495
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
453
496
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -858,7 +901,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
858
901
|
output = "usdz";
|
|
859
902
|
}
|
|
860
903
|
viewer.messenger.getARFile(output).then((result) => {
|
|
861
|
-
const rawAR = new raw_ar_1.RawAR(result.filename);
|
|
904
|
+
const rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
|
|
862
905
|
return rawAR.init().then(accept).catch(reject);
|
|
863
906
|
}).catch(reject);
|
|
864
907
|
return;
|
|
@@ -884,7 +927,7 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
|
|
|
884
927
|
}
|
|
885
928
|
});
|
|
886
929
|
configurator.get().then((result) => {
|
|
887
|
-
const rawAR = new raw_ar_1.RawAR(result.filename);
|
|
930
|
+
const rawAR = new raw_ar_1.RawAR(result.filename, sceneID);
|
|
888
931
|
rawAR.init().then(accept).catch(reject);
|
|
889
932
|
}).catch(reject);
|
|
890
933
|
return;
|
|
@@ -2163,7 +2206,7 @@ exports.Util = Util;
|
|
|
2163
2206
|
},{}],16:[function(require,module,exports){
|
|
2164
2207
|
"use strict";
|
|
2165
2208
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2166
|
-
exports.default = "1.
|
|
2209
|
+
exports.default = "1.139.1";
|
|
2167
2210
|
|
|
2168
2211
|
},{}],17:[function(require,module,exports){
|
|
2169
2212
|
"use strict";
|