@plattar/plattar-ar-adapter 1.188.1 → 1.188.2

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfiguratorAR = void 0;
7
7
  const plattar_analytics_1 = require("@plattar/plattar-analytics");
8
8
  const plattar_api_1 = require("@plattar/plattar-api");
9
+ const plattar_services_1 = require("@plattar/plattar-services");
9
10
  const util_1 = require("../util/util");
10
11
  const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
11
12
  const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
@@ -57,30 +58,31 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
57
58
  * an AR File
58
59
  */
59
60
  async _Compose(output) {
60
- const type = output === 'glb' ? "viewer" : "reality";
61
- const url = `https://xrutils.plattar.com/v3/scene/${this._options.state.scene.id}/${type}`;
62
- // grab our existing scene-graph from the saved API
63
- try {
64
- const response = await fetch(url, {
65
- method: "POST",
66
- headers: {
67
- "Content-Type": "application/json"
68
- },
69
- body: JSON.stringify({
70
- data: {
71
- attributes: this._options.state.state.sceneGraph
72
- }
73
- })
74
- });
75
- if (!response.ok) {
76
- throw new Error(`ConfiguratorAR - Fetching Existing Graph Error - network response was not ok ${response.status}`);
77
- }
78
- const data = await response.json();
79
- return data.data.attributes.url;
61
+ const objects = this._options.state.state.array();
62
+ if (objects.length <= 0) {
63
+ throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain AR components");
80
64
  }
81
- catch (error) {
82
- throw new Error(`ConfiguratorAR - Fetching Existing Graph Error - there was a request error to ${url}, error was ${error.message}`);
65
+ // define our configurator
66
+ const configurator = new plattar_services_1.Configurator();
67
+ configurator.server = plattar_api_1.Server.location().type;
68
+ configurator.output = output;
69
+ let totalARObjectCount = 0;
70
+ objects.forEach((object) => {
71
+ if (object.meta_data.augment) {
72
+ if (object.meta_data.type === "scenemodel") {
73
+ configurator.addModel(object.scene_product_id);
74
+ }
75
+ else {
76
+ configurator.addSceneProduct(object.scene_product_id, object.product_variation_id);
77
+ }
78
+ totalARObjectCount++;
79
+ }
80
+ });
81
+ if (totalARObjectCount <= 0) {
82
+ throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain any enabled AR components");
83
83
  }
84
+ const results = await configurator.get();
85
+ return results.filename;
84
86
  }
85
87
  /**
86
88
  * Initialise the SceneAR instance. This returns a Promise that resolves
@@ -6,7 +6,6 @@ const scene_product_ar_1 = require("../../ar/scene-product-ar");
6
6
  const util_1 = require("../../util/util");
7
7
  const plattar_controller_1 = require("./plattar-controller");
8
8
  const configurator_ar_1 = require("../../ar/configurator-ar");
9
- const scene_graph_ar_1 = require("../../ar/scene-graph-ar");
10
9
  /**
11
10
  * Manages an instance of the <plattar-configurator> HTML Element
12
11
  */
@@ -143,7 +142,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
143
142
  const showAR = this.getAttribute("show-ar");
144
143
  const showUI = this.getAttribute("show-ui");
145
144
  const showBanner = this.getAttribute("show-ar-banner");
146
- const sceneGraphID = this.getAttribute("scene-graph-id");
147
145
  if (showUI && showUI === "true") {
148
146
  dst = plattar_api_1.Server.location().base + "configurator/dist/index.html?scene_id=" + sceneID;
149
147
  }
@@ -156,9 +154,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
156
154
  if (showBanner) {
157
155
  dst += "&show_ar_banner=" + showBanner;
158
156
  }
159
- if (sceneGraphID) {
160
- dst += "&scene_graph_id=" + sceneGraphID;
161
- }
162
157
  viewer.setAttribute("url", opt.url || dst);
163
158
  this._state = plattar_controller_1.ControllerState.QRCode;
164
159
  this._prevQROpt = opt;
@@ -298,16 +293,6 @@ class ConfiguratorController extends plattar_controller_1.PlattarController {
298
293
  if (!sceneID) {
299
294
  throw new Error("VTOController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
300
295
  }
301
- const graphID = this.getAttribute("scene-graph-id");
302
- // use the scene-graph route if available
303
- if (graphID) {
304
- const configAR = new scene_graph_ar_1.SceneGraphAR({
305
- useARBanner: this.getBooleanAttribute("show-ar-banner"),
306
- id: graphID,
307
- sceneID: sceneID
308
- });
309
- return configAR.init();
310
- }
311
296
  const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
312
297
  return configAR.init();
313
298
  }
@@ -5,7 +5,6 @@ const scene_product_ar_1 = require("../../ar/scene-product-ar");
5
5
  const util_1 = require("../../util/util");
6
6
  const plattar_controller_1 = require("./plattar-controller");
7
7
  const configurator_ar_1 = require("../../ar/configurator-ar");
8
- const scene_graph_ar_1 = require("../../ar/scene-graph-ar");
9
8
  /**
10
9
  * Manages an instance of the <plattar-configurator> HTML Element
11
10
  */
@@ -89,7 +88,6 @@ class LauncherController extends plattar_controller_1.PlattarController {
89
88
  const variationSKU = this.getAttribute("variation-sku");
90
89
  const arMode = this.getAttribute("ar-mode");
91
90
  const showBanner = this.getAttribute("show-ar-banner");
92
- const sceneGraphID = this.getAttribute("scene-graph-id");
93
91
  // required attributes with defaults for plattar-launcher node
94
92
  const width = this.getAttribute("width") || "500px";
95
93
  const height = this.getAttribute("height") || "500px";
@@ -128,9 +126,6 @@ class LauncherController extends plattar_controller_1.PlattarController {
128
126
  viewer.setAttribute("config-state", encodedState);
129
127
  }
130
128
  }
131
- if (sceneGraphID) {
132
- viewer.setAttribute("scene-graph-id", sceneGraphID);
133
- }
134
129
  return new Promise((accept, reject) => {
135
130
  this.append(viewer);
136
131
  if (configState) {
@@ -203,16 +198,6 @@ class LauncherController extends plattar_controller_1.PlattarController {
203
198
  if (!sceneID) {
204
199
  throw new Error("LauncherController.initAR() - generated AR minimum required attributes not set, use scene-id as a minimum");
205
200
  }
206
- const graphID = this.getAttribute("scene-graph-id");
207
- // use the scene-graph route if available
208
- if (graphID) {
209
- const configAR = new scene_graph_ar_1.SceneGraphAR({
210
- useARBanner: this.getBooleanAttribute("show-ar-banner"),
211
- id: graphID,
212
- sceneID: sceneID
213
- });
214
- return configAR.init();
215
- }
216
201
  const configAR = new configurator_ar_1.ConfiguratorAR({ state: await this.getConfiguratorState(), useARBanner: this.getBooleanAttribute("show-ar-banner") });
217
202
  return configAR.init();
218
203
  }
@@ -171,7 +171,6 @@ class PlattarController {
171
171
  const variationSKU = this.getAttribute("variation-sku");
172
172
  const arMode = this.getAttribute("ar-mode");
173
173
  const showBanner = this.getAttribute("show-ar-banner");
174
- const sceneGraphID = this.getAttribute("scene-graph-id");
175
174
  try {
176
175
  configState = (await this.getConfiguratorState()).state.encode();
177
176
  }
@@ -206,9 +205,6 @@ class PlattarController {
206
205
  if (showBanner) {
207
206
  dst += "&show_ar_banner=" + showBanner;
208
207
  }
209
- if (sceneGraphID) {
210
- dst += "&scene_graph_id" + sceneGraphID;
211
- }
212
208
  viewer.setAttribute("url", opt.url || dst);
213
209
  this._state = ControllerState.QRCode;
214
210
  this._prevQROpt = opt;
@@ -119,9 +119,4 @@ export declare class ConfiguratorState {
119
119
  * @returns - Base64 String
120
120
  */
121
121
  encode(): string;
122
- /**
123
- * Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
124
- * NOTE: Eventually this structure should replace ConfiguratorState
125
- */
126
- get sceneGraph(): any;
127
122
  }
@@ -440,38 +440,5 @@ class ConfiguratorState {
440
440
  encode() {
441
441
  return btoa(JSON.stringify(this._state));
442
442
  }
443
- /**
444
- * Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
445
- * NOTE: Eventually this structure should replace ConfiguratorState
446
- */
447
- get sceneGraph() {
448
- const objects = this.array();
449
- // in here we need to generate the schema input to be sent to the backend service
450
- const schema = {
451
- // ensure to only generate AR using files we pass into the backend
452
- strict: false,
453
- inputs: []
454
- };
455
- objects.forEach((object) => {
456
- if (object.meta_data.type === "scenemodel") {
457
- const data = {
458
- id: object.scene_product_id,
459
- type: 'scenemodel',
460
- visibility: object.meta_data.augment
461
- };
462
- schema.inputs.push(data);
463
- }
464
- else {
465
- const data = {
466
- id: object.scene_product_id,
467
- type: 'sceneproduct',
468
- variation_id: object.product_variation_id,
469
- visibility: object.meta_data.augment
470
- };
471
- schema.inputs.push(data);
472
- }
473
- });
474
- return schema;
475
- }
476
443
  }
477
444
  exports.ConfiguratorState = ConfiguratorState;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.188.1";
1
+ declare const _default: "1.188.2";
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.188.1";
3
+ exports.default = "1.188.2";
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
1
  {
2
- "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.188.1",
4
- "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "clean": "rm -rf build dist node_modules",
10
- "build": "npm run clean && npm install && npm run build-ts && npm run build-es2019 && npm run build-es2015",
11
- "build-ts": "tsc --noEmitOnError",
12
- "build-es2019": "rm -rf build/es2019 && mkdir -p build/es2019 && browserify --standalone PlattarARAdapter dist/index.js -o build/es2019/plattar-ar-adapter.js && uglifyjs build/es2019/plattar-ar-adapter.js --output build/es2019/plattar-ar-adapter.min.js",
13
- "build-es2015": "rm -rf build/es2015 && mkdir -p build/es2015 && babel build/es2019/plattar-ar-adapter.js --presets=@babel/env > build/es2015/plattar-ar-adapter.js && uglifyjs build/es2015/plattar-ar-adapter.js --output build/es2015/plattar-ar-adapter.min.js",
14
- "clean:build": "npm run clean && npm run build"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/Plattar/plattar-ar-adapter.git"
19
- },
20
- "engines": {
21
- "node": "^10.17 || >=12.3"
22
- },
23
- "keywords": [
24
- "plattar",
25
- "npm",
26
- "ar",
27
- "augmented",
28
- "reality",
29
- "augmentedreality",
30
- "augmented-reality",
31
- "web"
32
- ],
33
- "author": "plattar",
34
- "license": "Apache-2.0",
35
- "bugs": {
36
- "url": "https://github.com/Plattar/plattar-ar-adapter/issues"
37
- },
38
- "homepage": "https://www.plattar.com",
39
- "dependencies": {
40
- "@plattar/plattar-analytics": "^1.152.2",
41
- "@plattar/plattar-api": "^1.186.3",
42
- "@plattar/plattar-qrcode": "1.178.1",
43
- "@plattar/plattar-services": "^1.186.1",
44
- "@plattar/plattar-web": "^1.182.2"
45
- },
46
- "devDependencies": {
47
- "@babel/cli": "^7.27.0",
48
- "@babel/core": "^7.26.10",
49
- "@babel/preset-env": "^7.26.9",
50
- "browserify": "^17.0.1",
51
- "typescript": "^5.8.3",
52
- "uglify-js": "^3.19.3"
53
- },
54
- "publishConfig": {
55
- "access": "public"
56
- }
2
+ "name": "@plattar/plattar-ar-adapter",
3
+ "version": "1.188.2",
4
+ "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "clean": "rm -rf build dist node_modules",
10
+ "build": "npm run clean && npm install && npm run build-ts && npm run build-es2019 && npm run build-es2015",
11
+ "build-ts": "tsc --noEmitOnError",
12
+ "build-es2019": "rm -rf build/es2019 && mkdir -p build/es2019 && browserify --standalone PlattarARAdapter dist/index.js -o build/es2019/plattar-ar-adapter.js && uglifyjs build/es2019/plattar-ar-adapter.js --output build/es2019/plattar-ar-adapter.min.js",
13
+ "build-es2015": "rm -rf build/es2015 && mkdir -p build/es2015 && babel build/es2019/plattar-ar-adapter.js --presets=@babel/env > build/es2015/plattar-ar-adapter.js && uglifyjs build/es2015/plattar-ar-adapter.js --output build/es2015/plattar-ar-adapter.min.js",
14
+ "clean:build": "npm run clean && npm run build"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/Plattar/plattar-ar-adapter.git"
19
+ },
20
+ "engines": {
21
+ "node": "^10.17 || >=12.3"
22
+ },
23
+ "keywords": [
24
+ "plattar",
25
+ "npm",
26
+ "ar",
27
+ "augmented",
28
+ "reality",
29
+ "augmentedreality",
30
+ "augmented-reality",
31
+ "web"
32
+ ],
33
+ "author": "plattar",
34
+ "license": "Apache-2.0",
35
+ "bugs": {
36
+ "url": "https://github.com/Plattar/plattar-ar-adapter/issues"
37
+ },
38
+ "homepage": "https://www.plattar.com",
39
+ "dependencies": {
40
+ "@plattar/plattar-analytics": "^1.152.2",
41
+ "@plattar/plattar-api": "^1.186.3",
42
+ "@plattar/plattar-qrcode": "1.178.1",
43
+ "@plattar/plattar-services": "^1.157.1",
44
+ "@plattar/plattar-web": "^1.182.2"
45
+ },
46
+ "devDependencies": {
47
+ "@babel/cli": "^7.26.4",
48
+ "@babel/core": "^7.26.10",
49
+ "@babel/preset-env": "^7.26.9",
50
+ "browserify": "^17.0.1",
51
+ "typescript": "^5.8.2",
52
+ "uglify-js": "^3.19.3"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
57
  }
@@ -1,33 +0,0 @@
1
- import { LauncherAR } from "./launcher-ar";
2
- export interface SceneGraphAROptions {
3
- readonly id: string;
4
- readonly sceneID: string;
5
- readonly useARBanner: boolean;
6
- }
7
- /**
8
- * Performs AR functionality related to Plattar Scenes
9
- */
10
- export declare class SceneGraphAR extends LauncherAR {
11
- private _analytics;
12
- private _options;
13
- private _ar;
14
- constructor(options: SceneGraphAROptions);
15
- private _SetupAnalytics;
16
- /**
17
- * Composes a Scene into an AR Model (remote operation) that can be used to launch
18
- * an AR File
19
- */
20
- private _Compose;
21
- /**
22
- * Initialise the SceneAR instance. This returns a Promise that resolves
23
- * successfully if initialisation is successful, otherwise it will fail.
24
- *
25
- * filure can occur for a number of reasons but it generally means that AR
26
- * cannot be performed.
27
- */
28
- init(): Promise<LauncherAR>;
29
- start(): void;
30
- canQuicklook(): boolean;
31
- canRealityViewer(): boolean;
32
- canSceneViewer(): boolean;
33
- }
@@ -1,159 +0,0 @@
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.SceneGraphAR = void 0;
7
- const plattar_analytics_1 = require("@plattar/plattar-analytics");
8
- const plattar_api_1 = require("@plattar/plattar-api");
9
- const util_1 = require("../util/util");
10
- const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
11
- const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
12
- const launcher_ar_1 = require("./launcher-ar");
13
- const version_1 = __importDefault(require("../version"));
14
- /**
15
- * Performs AR functionality related to Plattar Scenes
16
- */
17
- class SceneGraphAR extends launcher_ar_1.LauncherAR {
18
- constructor(options) {
19
- super();
20
- // analytics instance
21
- this._analytics = null;
22
- this._options = options;
23
- this._ar = null;
24
- }
25
- async _SetupAnalytics() {
26
- const scene = new plattar_api_1.Scene(this._options.sceneID);
27
- scene.include(plattar_api_1.Project);
28
- const fetchedScene = await scene.get();
29
- let analytics = null;
30
- analytics = new plattar_analytics_1.Analytics(fetchedScene.attributes.application_id);
31
- analytics.origin = plattar_api_1.Server.location().type;
32
- this._analytics = analytics;
33
- analytics.data.push("type", "scene-graph-ar");
34
- analytics.data.push("sdkVersion", version_1.default);
35
- analytics.data.push("sceneId", fetchedScene.id);
36
- analytics.data.push("sceneTitle", fetchedScene.attributes.title);
37
- const application = fetchedScene.relationships.find(plattar_api_1.Project);
38
- // setup application stuff (if any)
39
- if (application) {
40
- analytics.data.push("applicationId", application.id);
41
- analytics.data.push("applicationTitle", application.attributes.title);
42
- if (this._options.useARBanner) {
43
- this.options.banner = {
44
- title: application.attributes.title,
45
- subtitle: fetchedScene.attributes.title,
46
- button: 'Visit'
47
- };
48
- }
49
- }
50
- return fetchedScene;
51
- }
52
- /**
53
- * Composes a Scene into an AR Model (remote operation) that can be used to launch
54
- * an AR File
55
- */
56
- async _Compose(output) {
57
- const type = output === 'glb' ? "viewer" : "reality";
58
- const url = `https://xrutils.plattar.com/v3/scene/${this._options.sceneID}/${type}/${this._options.id}`;
59
- // grab our existing scene-graph from the saved API
60
- try {
61
- const response = await fetch(url, {
62
- method: "GET",
63
- headers: {
64
- "Content-Type": "application/json"
65
- }
66
- });
67
- if (!response.ok) {
68
- throw new Error(`ARAdapter - Fetching Existing Graph Error - network response was not ok ${response.status}`);
69
- }
70
- const data = await response.json();
71
- return data.data.attributes.url;
72
- }
73
- catch (error) {
74
- throw new Error(`ARAdapter - Fetching Existing Graph Error - there was a request error to ${url}, error was ${error.message}`);
75
- }
76
- }
77
- /**
78
- * Initialise the SceneAR instance. This returns a Promise that resolves
79
- * successfully if initialisation is successful, otherwise it will fail.
80
- *
81
- * filure can occur for a number of reasons but it generally means that AR
82
- * cannot be performed.
83
- */
84
- async init() {
85
- if (!util_1.Util.canAugment()) {
86
- throw new Error("SceneGraphAR.init() - cannot proceed as AR not available in context");
87
- }
88
- const scene = await this._SetupAnalytics();
89
- const sceneOpt = scene.attributes.custom_json || {};
90
- // we need to define our AR module here
91
- // we are in Safari/Quicklook mode here
92
- if (util_1.Util.isSafari() || util_1.Util.isChromeOnIOS()) {
93
- // we need to launch a VTO experience here
94
- // VTO requires Reality Support
95
- if (sceneOpt.anchor === "face") {
96
- if (util_1.Util.canRealityViewer()) {
97
- const modelUrl = await this._Compose("vto");
98
- this._ar = new quicklook_viewer_1.default();
99
- this._ar.modelUrl = modelUrl;
100
- this._ar.banner = this.options.banner;
101
- return this;
102
- }
103
- else {
104
- throw new Error("SceneGraphAR.init() - cannot proceed as VTO AR requires Reality Viewer support");
105
- }
106
- }
107
- // otherwise, load the USDZ stuff second if available
108
- if (util_1.Util.canQuicklook()) {
109
- const modelUrl = await this._Compose("usdz");
110
- this._ar = new quicklook_viewer_1.default();
111
- this._ar.modelUrl = modelUrl;
112
- this._ar.banner = this.options.banner;
113
- return this;
114
- }
115
- throw new Error("SceneGraphAR.init() - cannot proceed as IOS device does not support AR Mode");
116
- }
117
- // check android
118
- if (util_1.Util.canSceneViewer()) {
119
- const modelUrl = await this._Compose("glb");
120
- const arviewer = new scene_viewer_1.default();
121
- arviewer.modelUrl = modelUrl;
122
- arviewer.isVertical = this.options.anchor === "vertical" ? true : false;
123
- arviewer.banner = this.options.banner;
124
- if (sceneOpt.anchor === "vertical") {
125
- arviewer.isVertical = true;
126
- }
127
- this._ar = arviewer;
128
- return this;
129
- }
130
- // otherwise, we didn't have AR available - it should never really reach this stage as this should be caught
131
- // earlier in the process
132
- throw new Error("SceneGraphAR.init() - could not initialise AR correctly, check values");
133
- }
134
- start() {
135
- if (!this._ar) {
136
- throw new Error("SceneGraphAR.start() - cannot proceed as AR instance is null");
137
- }
138
- const analytics = this._analytics;
139
- if (analytics) {
140
- analytics.data.push("device", this._ar.device);
141
- analytics.data.push("eventCategory", this._ar.nodeType);
142
- analytics.data.push("eventAction", "Start Scene Augment");
143
- analytics.write();
144
- analytics.startRecordEngagement();
145
- }
146
- // this was initialised via the init() function
147
- this._ar.start();
148
- }
149
- canQuicklook() {
150
- return this._ar && this._ar.nodeType === "Quick Look" ? true : false;
151
- }
152
- canRealityViewer() {
153
- return this._ar && this._ar.nodeType === "Reality Viewer" ? true : false;
154
- }
155
- canSceneViewer() {
156
- return this._ar && this._ar.nodeType === "Scene Viewer" ? true : false;
157
- }
158
- }
159
- exports.SceneGraphAR = SceneGraphAR;