@plattar/plattar-ar-adapter 1.122.2 → 1.122.3

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.
@@ -0,0 +1,30 @@
1
+ import { LauncherAR } from "./launcher-ar";
2
+ /**
3
+ * Allows launching AR Experiences provided a single remote 3D Model file
4
+ */
5
+ export declare class RawAR extends LauncherAR {
6
+ private readonly _modelLocation;
7
+ private _ar;
8
+ constructor(modelLocation?: string | undefined | null);
9
+ get modelLocation(): string;
10
+ /**
11
+ * Initialise the RawAR instance. This returns a Promise that resolves
12
+ * successfully if initialisation is successful, otherwise it will fail.
13
+ *
14
+ * filure can occur for a number of reasons but it generally means that AR
15
+ * cannot be performed.
16
+ */
17
+ init(): Promise<LauncherAR>;
18
+ /**
19
+ * Initialise and launch with a single function call. this is mostly for convenience.
20
+ * Use .init() and .start() separately for fine-grained control
21
+ */
22
+ launch(): Promise<void>;
23
+ /**
24
+ * Launches the internal AR instance using an appropriate version of AR Viewers
25
+ */
26
+ start(): void;
27
+ canQuicklook(): boolean;
28
+ canRealityViewer(): boolean;
29
+ canSceneViewer(): boolean;
30
+ }
@@ -0,0 +1,110 @@
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.RawAR = void 0;
7
+ const util_1 = require("../util/util");
8
+ const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
9
+ const reality_viewer_1 = __importDefault(require("../viewers/reality-viewer"));
10
+ const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
11
+ const launcher_ar_1 = require("./launcher-ar");
12
+ /**
13
+ * Allows launching AR Experiences provided a single remote 3D Model file
14
+ */
15
+ class RawAR extends launcher_ar_1.LauncherAR {
16
+ constructor(modelLocation = null) {
17
+ super();
18
+ if (!modelLocation) {
19
+ throw new Error("RawAR.constructor(modelLocation) - modelLocation must be defined");
20
+ }
21
+ const lowerLoc = modelLocation.toLowerCase();
22
+ if (lowerLoc.endsWith("usdz") || lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf") || lowerLoc.endsWith("reality")) {
23
+ this._modelLocation = modelLocation;
24
+ this._ar = null;
25
+ }
26
+ else {
27
+ throw new Error("RawAR.constructor(modelLocation) - modelLocation must be one of gltf, glb, usdz or reality");
28
+ }
29
+ }
30
+ get modelLocation() {
31
+ return this._modelLocation;
32
+ }
33
+ /**
34
+ * Initialise the RawAR instance. This returns a Promise that resolves
35
+ * successfully if initialisation is successful, otherwise it will fail.
36
+ *
37
+ * filure can occur for a number of reasons but it generally means that AR
38
+ * cannot be performed.
39
+ */
40
+ init() {
41
+ return new Promise((accept, reject) => {
42
+ if (!util_1.Util.canAugment()) {
43
+ return reject(new Error("RawAR.init() - cannot proceed as AR not available in context"));
44
+ }
45
+ const modelLocation = this._modelLocation;
46
+ const lowerLoc = modelLocation.toLowerCase();
47
+ // we need to define our AR module here
48
+ // we are in Safari/Quicklook mode here
49
+ if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
50
+ // load the reality experience if dealing with reality file
51
+ if (lowerLoc.endsWith("reality") && util_1.Util.canRealityViewer()) {
52
+ this._ar = new reality_viewer_1.default();
53
+ this._ar.modelUrl = modelLocation;
54
+ return accept(this);
55
+ }
56
+ // load the usdz experience if dealing with usdz file
57
+ if (lowerLoc.endsWith("usdz") && util_1.Util.canQuicklook()) {
58
+ this._ar = new quicklook_viewer_1.default();
59
+ this._ar.modelUrl = modelLocation;
60
+ return accept(this);
61
+ }
62
+ return reject(new Error("RawAR.init() - cannot proceed as model is not a .usdz or .reality file"));
63
+ }
64
+ // check android
65
+ if (util_1.Util.canSceneViewer()) {
66
+ if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
67
+ this._ar = new scene_viewer_1.default();
68
+ this._ar.modelUrl = modelLocation;
69
+ return accept(this);
70
+ }
71
+ return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
72
+ }
73
+ // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
74
+ // earlier in the process
75
+ return reject(new Error("RawAR.init() - could not initialise AR correctly, check values"));
76
+ });
77
+ }
78
+ /**
79
+ * Initialise and launch with a single function call. this is mostly for convenience.
80
+ * Use .init() and .start() separately for fine-grained control
81
+ */
82
+ launch() {
83
+ return new Promise((accept, reject) => {
84
+ this.init().then((value) => {
85
+ value.start();
86
+ return accept();
87
+ }).catch(reject);
88
+ });
89
+ }
90
+ /**
91
+ * Launches the internal AR instance using an appropriate version of AR Viewers
92
+ */
93
+ start() {
94
+ if (!this._ar) {
95
+ throw new Error("RawAR.start() - cannot proceed as AR instance is null");
96
+ }
97
+ // this was initialised via the init() function
98
+ this._ar.start();
99
+ }
100
+ canQuicklook() {
101
+ return this._ar && this._ar.nodeType === "Quick Look" ? true : false;
102
+ }
103
+ canRealityViewer() {
104
+ return this._ar && this._ar.nodeType === "Reality Viewer" ? true : false;
105
+ }
106
+ canSceneViewer() {
107
+ return this._ar && this._ar.nodeType === "Scene Viewer" ? true : false;
108
+ }
109
+ }
110
+ exports.RawAR = RawAR;
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export { ConfiguratorAR } from "./ar/configurator-ar";
5
5
  export { ProductAR } from "./ar/product-ar";
6
6
  export { SceneAR } from "./ar/scene-ar";
7
7
  export { ModelAR } from "./ar/model-ar";
8
+ export { RawAR } from "./ar/raw-ar";
8
9
  export { Util } from "./util/util";
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.Util = exports.ModelAR = exports.SceneAR = exports.ProductAR = exports.ConfiguratorAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
25
+ exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.ProductAR = exports.ConfiguratorAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
26
26
  exports.PlattarWeb = __importStar(require("@plattar/plattar-web"));
27
27
  exports.PlattarQRCode = __importStar(require("@plattar/plattar-qrcode"));
28
28
  exports.version = __importStar(require("./version"));
@@ -34,6 +34,8 @@ var scene_ar_1 = require("./ar/scene-ar");
34
34
  Object.defineProperty(exports, "SceneAR", { enumerable: true, get: function () { return scene_ar_1.SceneAR; } });
35
35
  var model_ar_1 = require("./ar/model-ar");
36
36
  Object.defineProperty(exports, "ModelAR", { enumerable: true, get: function () { return model_ar_1.ModelAR; } });
37
+ var raw_ar_1 = require("./ar/raw-ar");
38
+ Object.defineProperty(exports, "RawAR", { enumerable: true, get: function () { return raw_ar_1.RawAR; } });
37
39
  var util_1 = require("./util/util");
38
40
  Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return util_1.Util; } });
39
41
  const plattar_embed_1 = __importDefault(require("./embed/plattar-embed"));
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.122.2";
1
+ declare const _default: "1.122.3";
2
2
  export default _default;
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = "1.122.2";
3
+ exports.default = "1.122.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.122.2",
3
+ "version": "1.122.3",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",