@plattar/plattar-ar-adapter 2.7.1 → 2.7.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.
- package/build/es2015/plattar-ar-adapter.js +1072 -1442
- package/build/es2015/plattar-ar-adapter.min.js +1 -1
- package/build/es2019/plattar-ar-adapter.js +111 -421
- package/build/es2019/plattar-ar-adapter.min.js +1 -1
- package/dist/ar/scene-ar.js +74 -46
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -2
package/dist/ar/scene-ar.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SceneAR = 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"));
|
|
@@ -64,58 +63,87 @@ class SceneAR extends launcher_ar_1.LauncherAR {
|
|
|
64
63
|
* Composes a Scene into an AR Model (remote operation) that can be used to launch
|
|
65
64
|
* an AR File
|
|
66
65
|
*/
|
|
67
|
-
_ComposeScene(scene, output) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
async _ComposeScene(scene, output) {
|
|
67
|
+
const sceneProducts = scene.relationships.filter(plattar_api_1.SceneProduct);
|
|
68
|
+
const sceneModels = scene.relationships.filter(plattar_api_1.SceneModel);
|
|
69
|
+
// nothing to do if no AR components can be found
|
|
70
|
+
if ((sceneProducts.length + sceneModels.length) <= 0) {
|
|
71
|
+
throw new Error("SceneAR.ComposeScene() - cannot proceed as scene does not contain AR components");
|
|
72
|
+
}
|
|
73
|
+
const url = `${plattar_api_1.Server.location().type === 'staging' ? 'https://converter.plattar.space' : 'https://converter.plattar.com'}/v3/converter/config-to-model`;
|
|
74
|
+
const payload = {
|
|
75
|
+
data: {
|
|
76
|
+
attributes: {
|
|
77
|
+
quality: 100,
|
|
78
|
+
output: output,
|
|
79
|
+
maps: new Array()
|
|
80
|
+
}
|
|
74
81
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
};
|
|
83
|
+
let totalARObjectCount = 0;
|
|
84
|
+
// add our scene products
|
|
85
|
+
sceneProducts.forEach((sceneProduct) => {
|
|
86
|
+
const product = sceneProduct.relationships.find(plattar_api_1.Product);
|
|
87
|
+
const selection = this._options.variationSelection;
|
|
88
|
+
// we have a specific product selection
|
|
89
|
+
if (sceneProduct.attributes.include_in_augment) {
|
|
90
|
+
// check if this product is the one we want (from selection optionally)
|
|
91
|
+
if (product && (product.id === selection.productID) && selection.variationID) {
|
|
92
|
+
payload.data.attributes.maps.push({
|
|
93
|
+
sceneproduct: sceneProduct.id,
|
|
94
|
+
productvariation: selection.variationID
|
|
95
|
+
});
|
|
96
|
+
totalARObjectCount++;
|
|
97
|
+
}
|
|
98
|
+
else if (product) {
|
|
99
|
+
// check if this scene-product is the one we want (from selection)
|
|
100
|
+
if ((sceneProduct.id === selection.sceneProductID) && selection.variationID) {
|
|
101
|
+
payload.data.attributes.maps.push({
|
|
102
|
+
sceneproduct: sceneProduct.id,
|
|
103
|
+
productvariation: selection.variationID
|
|
104
|
+
});
|
|
89
105
|
totalARObjectCount++;
|
|
90
106
|
}
|
|
91
|
-
else if (product) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
else if (product.attributes.product_variation_id) {
|
|
98
|
-
configurator.addSceneProduct(sceneProduct.id, product.attributes.product_variation_id);
|
|
99
|
-
totalARObjectCount++;
|
|
100
|
-
}
|
|
107
|
+
else if (product.attributes.product_variation_id) {
|
|
108
|
+
payload.data.attributes.maps.push({
|
|
109
|
+
sceneproduct: sceneProduct.id,
|
|
110
|
+
productvariation: product.attributes.product_variation_id
|
|
111
|
+
});
|
|
112
|
+
totalARObjectCount++;
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
|
-
});
|
|
104
|
-
// add our scene models
|
|
105
|
-
sceneModels.forEach((sceneModel) => {
|
|
106
|
-
if (sceneModel.attributes.include_in_augment) {
|
|
107
|
-
configurator.addModel(sceneModel.id);
|
|
108
|
-
totalARObjectCount++;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
// ensure we have actually added AR objects
|
|
112
|
-
if (totalARObjectCount <= 0) {
|
|
113
|
-
return reject(new Error("SceneAR.ComposeScene() - cannot proceed as scene does not contain any enabled AR components"));
|
|
114
115
|
}
|
|
115
|
-
return configurator.get().then((result) => {
|
|
116
|
-
accept(result.filename);
|
|
117
|
-
}).catch(reject);
|
|
118
116
|
});
|
|
117
|
+
// add our scene models
|
|
118
|
+
sceneModels.forEach((sceneModel) => {
|
|
119
|
+
if (sceneModel.attributes.include_in_augment) {
|
|
120
|
+
payload.data.attributes.maps.push({
|
|
121
|
+
scenemodel: sceneModel.id
|
|
122
|
+
});
|
|
123
|
+
totalARObjectCount++;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
// ensure we have actually added AR objects
|
|
127
|
+
if (totalARObjectCount <= 0) {
|
|
128
|
+
throw new Error("SceneAR.ComposeScene() - cannot proceed as scene does not contain any enabled AR components");
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const response = await fetch(url, {
|
|
132
|
+
method: "POST",
|
|
133
|
+
headers: {
|
|
134
|
+
"Content-Type": "application/json"
|
|
135
|
+
},
|
|
136
|
+
body: JSON.stringify(payload)
|
|
137
|
+
});
|
|
138
|
+
if (!response.ok) {
|
|
139
|
+
throw new Error(`SceneAR.ComposeScene() - network response was not ok ${response.status}`);
|
|
140
|
+
}
|
|
141
|
+
const data = await response.json();
|
|
142
|
+
return data.data.attributes.filename;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
throw new Error(`SceneAR.ComposeScene() - there was a request error to ${url}, error was ${error.message}`);
|
|
146
|
+
}
|
|
119
147
|
}
|
|
120
148
|
/**
|
|
121
149
|
* Initialise the SceneAR instance. This returns a Promise that resolves
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.7.
|
|
1
|
+
declare const _default: "2.7.2";
|
|
2
2
|
export default _default;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plattar/plattar-ar-adapter",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.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",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"@plattar/plattar-analytics": "^2.7.1",
|
|
41
41
|
"@plattar/plattar-api": "^2.7.1",
|
|
42
42
|
"@plattar/plattar-qrcode": "2.7.1",
|
|
43
|
-
"@plattar/plattar-services": "^2.7.2",
|
|
44
43
|
"@plattar/plattar-web": "^2.7.2"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|