@plattar/plattar-ar-adapter 1.188.2 → 1.188.4
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/build/es2015/plattar-ar-adapter.js +2048 -1568
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +524 -224
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/configurator-ar.js +22 -24
- package/dist/ar/scene-graph-ar.d.ts +33 -0
- package/dist/ar/scene-graph-ar.js +159 -0
- package/dist/embed/controllers/configurator-controller.d.ts +2 -2
- package/dist/embed/controllers/configurator-controller.js +32 -8
- package/dist/embed/controllers/gallery-controller.d.ts +2 -2
- package/dist/embed/controllers/gallery-controller.js +17 -8
- package/dist/embed/controllers/launcher-controller.js +24 -4
- package/dist/embed/controllers/plattar-controller.d.ts +12 -4
- package/dist/embed/controllers/plattar-controller.js +41 -26
- package/dist/embed/controllers/vto-controller.d.ts +2 -2
- package/dist/embed/controllers/vto-controller.js +17 -8
- package/dist/util/configurator-state.d.ts +6 -0
- package/dist/util/configurator-state.js +64 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +55 -55
|
@@ -66,15 +66,19 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
async startViewerQRCode(options) {
|
|
69
|
+
const opt = this._GetDefaultQROptions(options);
|
|
69
70
|
// remove the old renderer instance if any
|
|
70
|
-
|
|
71
|
+
if (!opt.detached) {
|
|
72
|
+
this.removeRenderer();
|
|
73
|
+
}
|
|
71
74
|
const sceneID = this.getAttribute("scene-id");
|
|
72
75
|
if (!sceneID) {
|
|
73
76
|
throw new Error("VTOController.startQRCode() - minimum required attributes not set, use scene-id as a minimum");
|
|
74
77
|
}
|
|
75
|
-
const opt = options || this._GetDefaultQROptions();
|
|
76
78
|
const viewer = document.createElement("plattar-qrcode");
|
|
77
|
-
|
|
79
|
+
if (!opt.detached) {
|
|
80
|
+
this._element = viewer;
|
|
81
|
+
}
|
|
78
82
|
// required attributes with defaults for plattar-viewer node
|
|
79
83
|
const width = this.getAttribute("width") || "500px";
|
|
80
84
|
const height = this.getAttribute("height") || "500px";
|
|
@@ -120,13 +124,18 @@ class VTOController extends plattar_controller_1.PlattarController {
|
|
|
120
124
|
dst += "&variation_id=" + variationID;
|
|
121
125
|
}
|
|
122
126
|
viewer.setAttribute("url", opt.url || dst);
|
|
123
|
-
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
124
127
|
this._prevQROpt = opt;
|
|
128
|
+
if (!opt.detached) {
|
|
129
|
+
this._state = plattar_controller_1.ControllerState.QRCode;
|
|
130
|
+
return new Promise((accept, reject) => {
|
|
131
|
+
viewer.onload = () => {
|
|
132
|
+
return accept(viewer);
|
|
133
|
+
};
|
|
134
|
+
this.append(viewer);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
125
137
|
return new Promise((accept, reject) => {
|
|
126
|
-
|
|
127
|
-
return accept(viewer);
|
|
128
|
-
};
|
|
129
|
-
this.append(viewer);
|
|
138
|
+
return accept(viewer);
|
|
130
139
|
});
|
|
131
140
|
}
|
|
132
141
|
async startRenderer() {
|
|
@@ -119,4 +119,10 @@ export declare class ConfiguratorState {
|
|
|
119
119
|
* @returns - Base64 String
|
|
120
120
|
*/
|
|
121
121
|
encode(): string;
|
|
122
|
+
encodeSceneGraphID(): Promise<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
|
|
125
|
+
* NOTE: Eventually this structure should replace ConfiguratorState
|
|
126
|
+
*/
|
|
127
|
+
get sceneGraph(): any;
|
|
122
128
|
}
|
|
@@ -440,5 +440,69 @@ class ConfiguratorState {
|
|
|
440
440
|
encode() {
|
|
441
441
|
return btoa(JSON.stringify(this._state));
|
|
442
442
|
}
|
|
443
|
+
async encodeSceneGraphID() {
|
|
444
|
+
const graph = this.sceneGraph;
|
|
445
|
+
// some scene-graphs are very large in size, we store it remotely
|
|
446
|
+
// this storage will expire in 10 minutes so this is a non-permanent version
|
|
447
|
+
// and is designed for quick ar
|
|
448
|
+
const url = `https://c.plattar.com/v3/redir/store`;
|
|
449
|
+
// finally send our scene-graph to the backend to generate the AR file and return
|
|
450
|
+
try {
|
|
451
|
+
const response = await fetch(url, {
|
|
452
|
+
method: "POST",
|
|
453
|
+
headers: {
|
|
454
|
+
"Content-Type": "application/json"
|
|
455
|
+
},
|
|
456
|
+
body: JSON.stringify({
|
|
457
|
+
data: {
|
|
458
|
+
attributes: {
|
|
459
|
+
data: graph
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
if (!response.ok) {
|
|
465
|
+
throw new Error(`ConfiguratorState.encodeSceneGraphID() - network response was not ok ${response.status}`);
|
|
466
|
+
}
|
|
467
|
+
const data = await response.json();
|
|
468
|
+
return data.data.id;
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
throw new Error(`ConfiguratorState.encodeSceneGraphID() - there was a request error to ${url}, error was ${error.message}`);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Compiles and returns the Dynamic Scene Graph (Updated for 2025 for DynamicAR)
|
|
476
|
+
* NOTE: Eventually this structure should replace ConfiguratorState
|
|
477
|
+
*/
|
|
478
|
+
get sceneGraph() {
|
|
479
|
+
const objects = this.array();
|
|
480
|
+
// in here we need to generate the schema input to be sent to the backend service
|
|
481
|
+
const schema = {
|
|
482
|
+
// ensure to only generate AR using files we pass into the backend
|
|
483
|
+
strict: false,
|
|
484
|
+
inputs: []
|
|
485
|
+
};
|
|
486
|
+
objects.forEach((object) => {
|
|
487
|
+
if (object.meta_data.type === "scenemodel") {
|
|
488
|
+
const data = {
|
|
489
|
+
id: object.scene_product_id,
|
|
490
|
+
type: 'scenemodel',
|
|
491
|
+
visibility: object.meta_data.augment
|
|
492
|
+
};
|
|
493
|
+
schema.inputs.push(data);
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
const data = {
|
|
497
|
+
id: object.scene_product_id,
|
|
498
|
+
type: 'sceneproduct',
|
|
499
|
+
variation_id: object.product_variation_id,
|
|
500
|
+
visibility: object.meta_data.augment
|
|
501
|
+
};
|
|
502
|
+
schema.inputs.push(data);
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
return schema;
|
|
506
|
+
}
|
|
443
507
|
}
|
|
444
508
|
exports.ConfiguratorState = ConfiguratorState;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.188.
|
|
1
|
+
declare const _default: "1.188.4";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
2
|
+
"name": "@plattar/plattar-ar-adapter",
|
|
3
|
+
"version": "1.188.4",
|
|
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.2",
|
|
48
|
+
"@babel/core": "^7.27.4",
|
|
49
|
+
"@babel/preset-env": "^7.27.2",
|
|
50
|
+
"browserify": "^17.0.1",
|
|
51
|
+
"typescript": "^5.8.3",
|
|
52
|
+
"uglify-js": "^3.19.3"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
}
|
|
57
57
|
}
|