@plattar/plattar-ar-adapter 1.129.1 → 1.130.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.
@@ -1,4 +1,8 @@
1
+ export interface LauncherAROptions {
2
+ anchor: "horizontal" | "vertical" | "vto" | "horizontal_vertical";
3
+ }
1
4
  export declare abstract class LauncherAR {
5
+ private readonly _opt;
2
6
  constructor();
3
7
  abstract init(): Promise<LauncherAR>;
4
8
  abstract start(): void;
@@ -10,4 +14,8 @@ export declare abstract class LauncherAR {
10
14
  * Use .init() and .start() separately for fine-grained control
11
15
  */
12
16
  launch(): Promise<void>;
17
+ /**
18
+ * AR Options used for launching AR
19
+ */
20
+ get options(): LauncherAROptions;
13
21
  }
@@ -2,7 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LauncherAR = void 0;
4
4
  class LauncherAR {
5
- constructor() { }
5
+ constructor() {
6
+ this._opt = {
7
+ anchor: "horizontal_vertical"
8
+ };
9
+ }
6
10
  /**
7
11
  * Initialise and launch with a single function call. this is mostly for convenience.
8
12
  * Use .init() and .start() separately for fine-grained control
@@ -15,5 +19,11 @@ class LauncherAR {
15
19
  }).catch(reject);
16
20
  });
17
21
  }
22
+ /**
23
+ * AR Options used for launching AR
24
+ */
25
+ get options() {
26
+ return this._opt;
27
+ }
18
28
  }
19
29
  exports.LauncherAR = LauncherAR;
@@ -80,8 +80,10 @@ class ModelAR extends launcher_ar_1.LauncherAR {
80
80
  }
81
81
  // check android
82
82
  if (util_1.Util.canSceneViewer()) {
83
- this._ar = new scene_viewer_1.default();
84
- this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
83
+ const arviewer = new scene_viewer_1.default();
84
+ arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
85
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
86
+ this._ar = arviewer;
85
87
  return accept(this);
86
88
  }
87
89
  // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
@@ -122,8 +122,17 @@ class ProductAR extends launcher_ar_1.LauncherAR {
122
122
  }
123
123
  // check android
124
124
  if (util_1.Util.canSceneViewer()) {
125
- this._ar = new scene_viewer_1.default();
126
- this._ar.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
125
+ const arviewer = new scene_viewer_1.default();
126
+ arviewer.modelUrl = plattar_api_1.Server.location().cdn + model.attributes.path + model.attributes.original_filename;
127
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
128
+ const scene = product.relationships.find(plattar_api_1.Scene);
129
+ if (scene) {
130
+ const sceneOpt = scene.attributes.custom_json || {};
131
+ if (sceneOpt.anchor === "vertical") {
132
+ arviewer.isVertical = true;
133
+ }
134
+ }
135
+ this._ar = arviewer;
127
136
  return accept(this);
128
137
  }
129
138
  // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
package/dist/ar/raw-ar.js CHANGED
@@ -64,8 +64,10 @@ class RawAR extends launcher_ar_1.LauncherAR {
64
64
  // check android
65
65
  if (util_1.Util.canSceneViewer()) {
66
66
  if (lowerLoc.endsWith("glb") || lowerLoc.endsWith("gltf")) {
67
- this._ar = new scene_viewer_1.default();
68
- this._ar.modelUrl = modelLocation;
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;
69
71
  return accept(this);
70
72
  }
71
73
  return reject(new Error("RawAR.init() - cannot proceed as model is not a .glb or .gltf file"));
@@ -123,8 +123,13 @@ class SceneAR extends launcher_ar_1.LauncherAR {
123
123
  // check android
124
124
  if (util_1.Util.canSceneViewer()) {
125
125
  return this._ComposeScene(scene, "glb").then((modelUrl) => {
126
- this._ar = new scene_viewer_1.default();
127
- this._ar.modelUrl = modelUrl;
126
+ const arviewer = new scene_viewer_1.default();
127
+ arviewer.modelUrl = modelUrl;
128
+ arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
129
+ if (sceneOpt.anchor === "vertical") {
130
+ arviewer.isVertical = true;
131
+ }
132
+ this._ar = arviewer;
128
133
  return accept(this);
129
134
  }).catch(reject);
130
135
  }
@@ -50,6 +50,10 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
50
50
  // optional attributes
51
51
  const configState = this.getAttribute("config-state");
52
52
  const showAR = this.getAttribute("show-ar");
53
+ const showUI = this.getAttribute("show-ui");
54
+ if (showUI && showUI === "true") {
55
+ dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
56
+ }
53
57
  if (configState) {
54
58
  dst += "&config_state=" + configState;
55
59
  }
@@ -87,12 +91,16 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
87
91
  // optional attributes
88
92
  const configState = this.getAttribute("config-state");
89
93
  const showAR = this.getAttribute("show-ar");
94
+ const showUI = this.getAttribute("show-ui");
90
95
  if (configState) {
91
96
  viewer.setAttribute("config-state", configState);
92
97
  }
93
98
  if (showAR) {
94
99
  viewer.setAttribute("show-ar", showAR);
95
100
  }
101
+ if (showUI) {
102
+ viewer.setAttribute("show-ui", showUI);
103
+ }
96
104
  viewer.onload = () => {
97
105
  return accept(viewer);
98
106
  };
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewerController = void 0;
4
4
  const plattar_api_1 = require("@plattar/plattar-api");
5
5
  const product_ar_1 = require("../../ar/product-ar");
6
+ const scene_ar_1 = require("../../ar/scene-ar");
6
7
  const scene_product_ar_1 = require("../../ar/scene-product-ar");
7
- const configurator_state_1 = require("../../util/configurator-state");
8
8
  const util_1 = require("../../util/util");
9
9
  const plattar_controller_1 = require("./plattar-controller");
10
10
  /**
@@ -142,16 +142,11 @@ class ViewerController extends plattar_controller_1.PlattarController {
142
142
  return product.init().then(accept).catch(reject);
143
143
  }
144
144
  const sceneID = this.getAttribute("scene-id");
145
- // use the first default product-variation id if available
145
+ // fallback to using default SceneAR implementation
146
146
  if (sceneID) {
147
- return configurator_state_1.ConfiguratorState.decodeScene(sceneID).then((state) => {
148
- const first = state.first();
149
- if (first) {
150
- const sceneProductAR = new scene_product_ar_1.SceneProductAR(first.scene_product_id, first.product_variation_id);
151
- return sceneProductAR.init().then(accept).catch(reject);
152
- }
153
- return reject(new Error("ViewerController.initAR() - your scene does not contain any valid products"));
154
- }).catch(reject);
147
+ const sceneAR = new scene_ar_1.SceneAR(sceneID);
148
+ sceneAR.init().then(accept).catch(reject);
149
+ return;
155
150
  }
156
151
  return reject(new Error("ViewerController.initAR() - minimum required attributes not set, use scene-id as a minimum"));
157
152
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * as PlattarWeb from "@plattar/plattar-web";
2
2
  export * as PlattarQRCode from "@plattar/plattar-qrcode";
3
3
  export * as version from "./version";
4
+ export { LauncherAR } from "./ar/launcher-ar";
5
+ export { LauncherAROptions } from "./ar/launcher-ar";
4
6
  export { ProductAR } from "./ar/product-ar";
5
7
  export { SceneProductAR } from "./ar/scene-product-ar";
6
8
  export { SceneAR } from "./ar/scene-ar";
package/dist/index.js CHANGED
@@ -26,10 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
29
+ exports.ConfiguratorState = exports.Util = exports.RawAR = exports.ModelAR = exports.SceneAR = exports.SceneProductAR = exports.ProductAR = exports.LauncherAR = exports.version = exports.PlattarQRCode = exports.PlattarWeb = void 0;
30
30
  exports.PlattarWeb = __importStar(require("@plattar/plattar-web"));
31
31
  exports.PlattarQRCode = __importStar(require("@plattar/plattar-qrcode"));
32
32
  exports.version = __importStar(require("./version"));
33
+ var launcher_ar_1 = require("./ar/launcher-ar");
34
+ Object.defineProperty(exports, "LauncherAR", { enumerable: true, get: function () { return launcher_ar_1.LauncherAR; } });
33
35
  var product_ar_1 = require("./ar/product-ar");
34
36
  Object.defineProperty(exports, "ProductAR", { enumerable: true, get: function () { return product_ar_1.ProductAR; } });
35
37
  var scene_product_ar_1 = require("./ar/scene-product-ar");
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.129.1";
1
+ declare const _default: "1.130.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.129.1";
3
+ exports.default = "1.130.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.129.1",
3
+ "version": "1.130.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",
@@ -41,15 +41,15 @@
41
41
  "@plattar/plattar-api": "^1.120.1",
42
42
  "@plattar/plattar-qrcode": "1.122.1",
43
43
  "@plattar/plattar-services": "^1.120.1",
44
- "@plattar/plattar-web": "^1.128.1"
44
+ "@plattar/plattar-web": "^1.130.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@babel/cli": "^7.17.10",
48
- "@babel/core": "^7.17.10",
49
- "@babel/preset-env": "^7.17.10",
48
+ "@babel/core": "^7.17.12",
49
+ "@babel/preset-env": "^7.17.12",
50
50
  "browserify": "^17.0.0",
51
51
  "typescript": "^4.6.4",
52
- "uglify-js": "^3.15.4"
52
+ "uglify-js": "^3.15.5"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"