@plattar/plattar-ar-adapter 1.183.1 → 1.183.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,7 +6,6 @@ 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");
10
9
  const util_1 = require("../util/util");
11
10
  const quicklook_viewer_1 = __importDefault(require("../viewers/quicklook-viewer"));
12
11
  const scene_viewer_1 = __importDefault(require("../viewers/scene-viewer"));
@@ -58,31 +57,30 @@ class ConfiguratorAR extends launcher_ar_1.LauncherAR {
58
57
  * an AR File
59
58
  */
60
59
  async _Compose(output) {
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");
64
- }
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++;
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}`);
79
77
  }
80
- });
81
- if (totalARObjectCount <= 0) {
82
- throw new Error("ConfiguratorAR.Compose() - cannot proceed as scene does not contain any enabled AR components");
78
+ const data = await response.json();
79
+ return data.data.attributes.url;
80
+ }
81
+ catch (error) {
82
+ throw new Error(`ConfiguratorAR - Fetching Existing Graph Error - there was a request error to ${url}, error was ${error.message}`);
83
83
  }
84
- const results = await configurator.get();
85
- return results.filename;
86
84
  }
87
85
  /**
88
86
  * Initialise the SceneAR instance. This returns a Promise that resolves
@@ -118,4 +118,9 @@ export declare class ConfiguratorState {
118
118
  * @returns - Base64 String
119
119
  */
120
120
  encode(): string;
121
+ /**
122
+ * Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
123
+ * NOTE: Eventually this structure should replace ConfiguratorState
124
+ */
125
+ get sceneGraph(): any;
121
126
  }
@@ -414,5 +414,38 @@ class ConfiguratorState {
414
414
  encode() {
415
415
  return btoa(JSON.stringify(this._state));
416
416
  }
417
+ /**
418
+ * Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
419
+ * NOTE: Eventually this structure should replace ConfiguratorState
420
+ */
421
+ get sceneGraph() {
422
+ const objects = this.array();
423
+ // in here we need to generate the schema input to be sent to the backend service
424
+ const schema = {
425
+ // ensure to only generate AR using files we pass into the backend
426
+ strict: false,
427
+ inputs: []
428
+ };
429
+ objects.forEach((object) => {
430
+ if (object.meta_data.type === "scenemodel") {
431
+ const data = {
432
+ id: object.scene_product_id,
433
+ type: 'scenemodel',
434
+ visibility: object.meta_data.augment
435
+ };
436
+ schema.inputs.push(data);
437
+ }
438
+ else {
439
+ const data = {
440
+ id: object.scene_product_id,
441
+ type: 'sceneproduct',
442
+ variation_id: object.product_variation_id,
443
+ visibility: object.meta_data.augment
444
+ };
445
+ schema.inputs.push(data);
446
+ }
447
+ });
448
+ return schema;
449
+ }
417
450
  }
418
451
  exports.ConfiguratorState = ConfiguratorState;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "1.183.1";
1
+ declare const _default: "1.183.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.183.1";
3
+ exports.default = "1.183.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plattar/plattar-ar-adapter",
3
- "version": "1.183.1",
3
+ "version": "1.183.2",
4
4
  "description": "Plattar AR Adapter for interfacing with Google & Apple WebAR",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -48,7 +48,7 @@
48
48
  "@babel/core": "^7.26.9",
49
49
  "@babel/preset-env": "^7.26.9",
50
50
  "browserify": "^17.0.1",
51
- "typescript": "^5.7.3",
51
+ "typescript": "^5.8.2",
52
52
  "uglify-js": "^3.19.3"
53
53
  },
54
54
  "publishConfig": {