zakeke-configurator-react 0.0.50 → 0.0.51
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.
|
@@ -125,6 +125,7 @@ export declare class ZakekeEnvironment {
|
|
|
125
125
|
setItemColor: (guid: string, color: string) => void;
|
|
126
126
|
setItemFontFamily: (guid: string, fontFamily: string) => Promise<void>;
|
|
127
127
|
createImage: (file: File, progress?: ((percentage: number) => void) | undefined) => Promise<Image>;
|
|
128
|
+
createImageFromUrl: (url: string) => Promise<Image>;
|
|
128
129
|
addItemImage: (id: number, areaId: number) => Promise<void>;
|
|
129
130
|
setItemImageFromFile: (guid: string, file: File, progress?: ((percentage: number) => void) | undefined) => Promise<void>;
|
|
130
131
|
setItemImageFromBase64: (guid: string, base64: any) => Promise<void>;
|
|
@@ -41,6 +41,7 @@ export interface ProviderValue {
|
|
|
41
41
|
setItemImageFromFile: (guid: string, file: File) => Promise<void>;
|
|
42
42
|
addItemImage: (id: number, areaId: number) => Promise<void>;
|
|
43
43
|
createImage: (file: File, progress?: (percentage: number) => void) => Promise<Image>;
|
|
44
|
+
createImageFromUrl: (url: string) => Promise<Image>;
|
|
44
45
|
setItemImage: (guid: string, imageId: number) => Promise<void>;
|
|
45
46
|
setItemFontFamily: (guid: string, fontFamily: string) => void;
|
|
46
47
|
setItemColor: (guid: string, color: string) => void;
|
package/dist/index.js
CHANGED
|
@@ -6526,6 +6526,7 @@ var EnvironmentManager = /** @class */ (function () {
|
|
|
6526
6526
|
};
|
|
6527
6527
|
EnvironmentManager.prototype.update = function () {
|
|
6528
6528
|
this.configureScene();
|
|
6529
|
+
this.configureCamera();
|
|
6529
6530
|
this.configureSkybox();
|
|
6530
6531
|
};
|
|
6531
6532
|
EnvironmentManager.prototype.configureSkybox = function () {
|
|
@@ -7556,6 +7557,11 @@ var MakeIncremental = /** @class */ (function () {
|
|
|
7556
7557
|
meshOrGeometry.hasColors = true;
|
|
7557
7558
|
meshOrGeometry.colors = null;
|
|
7558
7559
|
}
|
|
7560
|
+
// Added tangents
|
|
7561
|
+
if (meshOrGeometry.tangents) {
|
|
7562
|
+
meshOrGeometry.hasTangents = true;
|
|
7563
|
+
meshOrGeometry.tangents = null;
|
|
7564
|
+
}
|
|
7559
7565
|
if (meshOrGeometry.matricesIndices) {
|
|
7560
7566
|
meshOrGeometry.hasMatricesIndices = true;
|
|
7561
7567
|
meshOrGeometry.matricesIndices = null;
|
|
@@ -7581,7 +7587,7 @@ var MakeIncremental = /** @class */ (function () {
|
|
|
7581
7587
|
// e se la geometria ha un solo canale per le texture
|
|
7582
7588
|
//var dracoEncode = dracoOptions.useDraco && !isMesh && !meshOrGeometry.uv2s && !(meshOrGeometry.matricesIndices || meshOrGeometry.matricesWeights);
|
|
7583
7589
|
var dracoEncode = dracoOptions.useDraco && !isMesh &&
|
|
7584
|
-
!(meshOrGeometry.matricesIndices || meshOrGeometry.matricesWeights) &&
|
|
7590
|
+
!(meshOrGeometry.matricesIndices || meshOrGeometry.matricesWeights || meshOrGeometry.tangents) &&
|
|
7585
7591
|
meshOrGeometry.indices.length > 0 &&
|
|
7586
7592
|
meshOrGeometry.positions.length > 0 &&
|
|
7587
7593
|
meshOrGeometry.normals.length > 0;
|
|
@@ -7610,6 +7616,9 @@ var MakeIncremental = /** @class */ (function () {
|
|
|
7610
7616
|
if (meshOrGeometry.colors) {
|
|
7611
7617
|
result.colors = meshOrGeometry.colors;
|
|
7612
7618
|
}
|
|
7619
|
+
if (meshOrGeometry.tangents) {
|
|
7620
|
+
result.tangents = meshOrGeometry.tangents;
|
|
7621
|
+
}
|
|
7613
7622
|
if (meshOrGeometry.matricesIndices) {
|
|
7614
7623
|
result.matricesIndices = meshOrGeometry.matricesIndices;
|
|
7615
7624
|
}
|
|
@@ -12164,7 +12173,7 @@ var SceneHelper = /** @class */ (function () {
|
|
|
12164
12173
|
};
|
|
12165
12174
|
SceneHelper.prototype.takeContentScreenshotAsync = function (width, height) {
|
|
12166
12175
|
return __awaiter(this, void 0, void 0, function () {
|
|
12167
|
-
var oldClearColor, size, data;
|
|
12176
|
+
var oldClearColor, size, promise, data;
|
|
12168
12177
|
return __generator(this, function (_a) {
|
|
12169
12178
|
switch (_a.label) {
|
|
12170
12179
|
case 0:
|
|
@@ -12174,7 +12183,10 @@ var SceneHelper = /** @class */ (function () {
|
|
|
12174
12183
|
this._scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
|
|
12175
12184
|
this._scene.render(); // Forzo il ridisegno
|
|
12176
12185
|
size = { width: width, height: height };
|
|
12177
|
-
|
|
12186
|
+
promise = BABYLON.Tools.CreateScreenshotAsync(this._engine, this._camera, size, "image/png");
|
|
12187
|
+
this._scene.render(); // Forzo il ridisegno
|
|
12188
|
+
this._scene.getEngine().endFrame();
|
|
12189
|
+
return [4 /*yield*/, promise];
|
|
12178
12190
|
case 1:
|
|
12179
12191
|
data = _a.sent();
|
|
12180
12192
|
this._scene.clearColor = oldClearColor;
|
|
@@ -14385,6 +14397,84 @@ var SceneHelper = /** @class */ (function () {
|
|
|
14385
14397
|
});
|
|
14386
14398
|
});
|
|
14387
14399
|
};
|
|
14400
|
+
SceneHelper.prototype.reloadAllLoadingErrorTexturesAsync = function (rootUrl) {
|
|
14401
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14402
|
+
var _i, _a, texture;
|
|
14403
|
+
return __generator(this, function (_b) {
|
|
14404
|
+
switch (_b.label) {
|
|
14405
|
+
case 0:
|
|
14406
|
+
_i = 0, _a = this._scene.textures;
|
|
14407
|
+
_b.label = 1;
|
|
14408
|
+
case 1:
|
|
14409
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
14410
|
+
texture = _a[_i];
|
|
14411
|
+
return [4 /*yield*/, this.reloadLoadingErrorTextureAsync(rootUrl, texture)];
|
|
14412
|
+
case 2:
|
|
14413
|
+
_b.sent();
|
|
14414
|
+
_b.label = 3;
|
|
14415
|
+
case 3:
|
|
14416
|
+
_i++;
|
|
14417
|
+
return [3 /*break*/, 1];
|
|
14418
|
+
case 4: return [2 /*return*/];
|
|
14419
|
+
}
|
|
14420
|
+
});
|
|
14421
|
+
});
|
|
14422
|
+
};
|
|
14423
|
+
SceneHelper.prototype.reloadMaterialLoadingErrorTexturesAsync = function (rootUrl, material) {
|
|
14424
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
14425
|
+
var _i, _a, texture;
|
|
14426
|
+
return __generator(this, function (_b) {
|
|
14427
|
+
switch (_b.label) {
|
|
14428
|
+
case 0:
|
|
14429
|
+
_i = 0, _a = material.getActiveTextures();
|
|
14430
|
+
_b.label = 1;
|
|
14431
|
+
case 1:
|
|
14432
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
14433
|
+
texture = _a[_i];
|
|
14434
|
+
return [4 /*yield*/, this.reloadLoadingErrorTextureAsync(rootUrl, texture)];
|
|
14435
|
+
case 2:
|
|
14436
|
+
_b.sent();
|
|
14437
|
+
_b.label = 3;
|
|
14438
|
+
case 3:
|
|
14439
|
+
_i++;
|
|
14440
|
+
return [3 /*break*/, 1];
|
|
14441
|
+
case 4: return [2 /*return*/];
|
|
14442
|
+
}
|
|
14443
|
+
});
|
|
14444
|
+
});
|
|
14445
|
+
};
|
|
14446
|
+
SceneHelper.prototype.reloadLoadingErrorTextureAsync = function (rootUrl, texture) {
|
|
14447
|
+
if (texture instanceof BABYLON.Texture && texture.url) {
|
|
14448
|
+
var internalTexture = texture.getInternalTexture();
|
|
14449
|
+
if (texture.loadingError || (internalTexture && internalTexture.loadingError)) {
|
|
14450
|
+
var originalUrl_1 = texture.url;
|
|
14451
|
+
var isAbsolute = /^(?:\/|[a-z]+:\/\/)/.test(texture.url);
|
|
14452
|
+
var absoluteUrl = texture.url;
|
|
14453
|
+
if (!isAbsolute)
|
|
14454
|
+
absoluteUrl = rootUrl + texture.url;
|
|
14455
|
+
return new Promise(function (resolve, reject) {
|
|
14456
|
+
texture.updateURL(absoluteUrl, null, function () {
|
|
14457
|
+
texture.url = originalUrl_1;
|
|
14458
|
+
resolve();
|
|
14459
|
+
}, function () {
|
|
14460
|
+
texture.url = originalUrl_1;
|
|
14461
|
+
reject();
|
|
14462
|
+
});
|
|
14463
|
+
});
|
|
14464
|
+
}
|
|
14465
|
+
}
|
|
14466
|
+
return Promise.resolve();
|
|
14467
|
+
};
|
|
14468
|
+
SceneHelper.prototype.isTextureLoadingError = function (texture) {
|
|
14469
|
+
if (texture.loadingError)
|
|
14470
|
+
return true;
|
|
14471
|
+
var internalTexture = texture.getInternalTexture();
|
|
14472
|
+
return internalTexture !== null && internalTexture.loadingError;
|
|
14473
|
+
};
|
|
14474
|
+
SceneHelper.prototype.materialHasLoadingErrorTextues = function (material) {
|
|
14475
|
+
var _this = this;
|
|
14476
|
+
return material.getActiveTextures().some(function (t) { return _this.isTextureLoadingError(t); });
|
|
14477
|
+
};
|
|
14388
14478
|
return SceneHelper;
|
|
14389
14479
|
}());
|
|
14390
14480
|
|
|
@@ -24999,7 +25089,7 @@ var SceneViewer = /** @class */ (function () {
|
|
|
24999
25089
|
// textureUrl = rootUrl + texture.name
|
|
25000
25090
|
SceneViewer.prototype.loadSceneFromRemoteFilesAsync = function (rootUrl, sceneFileName, onProgress) {
|
|
25001
25091
|
return __awaiter(this, void 0, void 0, function () {
|
|
25002
|
-
var newScene_1, requireDelayLoading, i, texture, skyboxTexture;
|
|
25092
|
+
var newScene_1, requireDelayLoading, i, texture, e_1, skyboxTexture;
|
|
25003
25093
|
var _this_1 = this;
|
|
25004
25094
|
return __generator(this, function (_a) {
|
|
25005
25095
|
switch (_a.label) {
|
|
@@ -25008,7 +25098,7 @@ var SceneViewer = /** @class */ (function () {
|
|
|
25008
25098
|
throw new Error("Unable to load scene when the 3D engine is null");
|
|
25009
25099
|
_a.label = 1;
|
|
25010
25100
|
case 1:
|
|
25011
|
-
_a.trys.push([1, ,
|
|
25101
|
+
_a.trys.push([1, , 14, 15]);
|
|
25012
25102
|
this.preSceneFileLoading();
|
|
25013
25103
|
this.pauseRendering();
|
|
25014
25104
|
// Per problema useDelayedTextureLoading
|
|
@@ -25053,7 +25143,7 @@ var SceneViewer = /** @class */ (function () {
|
|
|
25053
25143
|
return [4 /*yield*/, this.setupSceneAsync()];
|
|
25054
25144
|
case 5:
|
|
25055
25145
|
_a.sent();
|
|
25056
|
-
if (!this._sceneHelper) return [3 /*break*/,
|
|
25146
|
+
if (!this._sceneHelper) return [3 /*break*/, 11];
|
|
25057
25147
|
if (!(this._configPreview && this._scene.metadata && this._scene.metadata.delayedMaterials)) return [3 /*break*/, 7];
|
|
25058
25148
|
return [4 /*yield*/, this._sceneHelper.loadAllDelayedMaterialsAsync(rootUrl)];
|
|
25059
25149
|
case 6:
|
|
@@ -25071,19 +25161,29 @@ var SceneViewer = /** @class */ (function () {
|
|
|
25071
25161
|
this._sceneHelper.setupShaderMaterialsCameraPosition();
|
|
25072
25162
|
_a.label = 8;
|
|
25073
25163
|
case 8:
|
|
25074
|
-
|
|
25075
|
-
|
|
25076
|
-
if (!skyboxTexture) return [3 /*break*/, 10];
|
|
25077
|
-
return [4 /*yield*/, _Components_SceneHelper__WEBPACK_IMPORTED_MODULE_1__["SceneHelper"].whenTextureIsReadyAsync(skyboxTexture)];
|
|
25164
|
+
_a.trys.push([8, 10, , 11]);
|
|
25165
|
+
return [4 /*yield*/, this.reloadAllLoadingErrorTexturesAsync()];
|
|
25078
25166
|
case 9:
|
|
25079
25167
|
_a.sent();
|
|
25080
|
-
|
|
25081
|
-
case 10:
|
|
25168
|
+
return [3 /*break*/, 11];
|
|
25169
|
+
case 10:
|
|
25170
|
+
e_1 = _a.sent();
|
|
25171
|
+
console.error(e_1);
|
|
25172
|
+
return [3 /*break*/, 11];
|
|
25082
25173
|
case 11:
|
|
25174
|
+
if (!this._environmentManager) return [3 /*break*/, 13];
|
|
25175
|
+
skyboxTexture = this._environmentManager.getSkyboxTexture();
|
|
25176
|
+
if (!skyboxTexture) return [3 /*break*/, 13];
|
|
25177
|
+
return [4 /*yield*/, _Components_SceneHelper__WEBPACK_IMPORTED_MODULE_1__["SceneHelper"].whenTextureIsReadyAsync(skyboxTexture)];
|
|
25178
|
+
case 12:
|
|
25179
|
+
_a.sent();
|
|
25180
|
+
_a.label = 13;
|
|
25181
|
+
case 13: return [3 /*break*/, 15];
|
|
25182
|
+
case 14:
|
|
25083
25183
|
this.resumeRendering();
|
|
25084
25184
|
this.postSceneFileLoading();
|
|
25085
25185
|
return [7 /*endfinally*/];
|
|
25086
|
-
case
|
|
25186
|
+
case 15: return [2 /*return*/];
|
|
25087
25187
|
}
|
|
25088
25188
|
});
|
|
25089
25189
|
});
|
|
@@ -26548,6 +26648,71 @@ var SceneViewer = /** @class */ (function () {
|
|
|
26548
26648
|
this.setRenderingNeeded();
|
|
26549
26649
|
}
|
|
26550
26650
|
};
|
|
26651
|
+
// try to reload all textures with loading errors
|
|
26652
|
+
SceneViewer.prototype.reloadAllLoadingErrorTexturesAsync = function () {
|
|
26653
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26654
|
+
var rootUrl;
|
|
26655
|
+
return __generator(this, function (_a) {
|
|
26656
|
+
switch (_a.label) {
|
|
26657
|
+
case 0:
|
|
26658
|
+
if (!(this._zkScene && this._sceneHelper)) return [3 /*break*/, 2];
|
|
26659
|
+
rootUrl = this._zkScene.get("rootUrl");
|
|
26660
|
+
if (!rootUrl) return [3 /*break*/, 2];
|
|
26661
|
+
return [4 /*yield*/, this._sceneHelper.reloadAllLoadingErrorTexturesAsync(rootUrl)];
|
|
26662
|
+
case 1:
|
|
26663
|
+
_a.sent();
|
|
26664
|
+
_a.label = 2;
|
|
26665
|
+
case 2: return [2 /*return*/];
|
|
26666
|
+
}
|
|
26667
|
+
});
|
|
26668
|
+
});
|
|
26669
|
+
};
|
|
26670
|
+
// try to reload the material textures with loading errors
|
|
26671
|
+
SceneViewer.prototype.reloadMaterialLoadingErrorTexturesAsync = function (material) {
|
|
26672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26673
|
+
var rootUrl;
|
|
26674
|
+
return __generator(this, function (_a) {
|
|
26675
|
+
switch (_a.label) {
|
|
26676
|
+
case 0:
|
|
26677
|
+
if (!(this._zkScene && this._sceneHelper)) return [3 /*break*/, 2];
|
|
26678
|
+
rootUrl = this._zkScene.get("rootUrl");
|
|
26679
|
+
if (!rootUrl) return [3 /*break*/, 2];
|
|
26680
|
+
return [4 /*yield*/, this._sceneHelper.reloadMaterialLoadingErrorTexturesAsync(rootUrl, material)];
|
|
26681
|
+
case 1:
|
|
26682
|
+
_a.sent();
|
|
26683
|
+
_a.label = 2;
|
|
26684
|
+
case 2: return [2 /*return*/];
|
|
26685
|
+
}
|
|
26686
|
+
});
|
|
26687
|
+
});
|
|
26688
|
+
};
|
|
26689
|
+
// try to reload the texture having loading errors
|
|
26690
|
+
SceneViewer.prototype.reloadLoadingErrorTextureAsync = function (texture) {
|
|
26691
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
26692
|
+
var rootUrl;
|
|
26693
|
+
return __generator(this, function (_a) {
|
|
26694
|
+
switch (_a.label) {
|
|
26695
|
+
case 0:
|
|
26696
|
+
if (!(this._zkScene && this._sceneHelper)) return [3 /*break*/, 2];
|
|
26697
|
+
rootUrl = this._zkScene.get("rootUrl");
|
|
26698
|
+
if (!rootUrl) return [3 /*break*/, 2];
|
|
26699
|
+
return [4 /*yield*/, this._sceneHelper.reloadLoadingErrorTextureAsync(rootUrl, texture)];
|
|
26700
|
+
case 1:
|
|
26701
|
+
_a.sent();
|
|
26702
|
+
_a.label = 2;
|
|
26703
|
+
case 2: return [2 /*return*/];
|
|
26704
|
+
}
|
|
26705
|
+
});
|
|
26706
|
+
});
|
|
26707
|
+
};
|
|
26708
|
+
// were there any loading errors for the texture?
|
|
26709
|
+
SceneViewer.prototype.isTextureLoadingError = function (texture) {
|
|
26710
|
+
return this._sceneHelper ? this._sceneHelper.isTextureLoadingError(texture) : false;
|
|
26711
|
+
};
|
|
26712
|
+
// the material has some texture with loading errors
|
|
26713
|
+
SceneViewer.prototype.materialHasLoadingErrorTextues = function (material) {
|
|
26714
|
+
return this._sceneHelper ? this._sceneHelper.materialHasLoadingErrorTextues(material) : false;
|
|
26715
|
+
};
|
|
26551
26716
|
return SceneViewer;
|
|
26552
26717
|
}());
|
|
26553
26718
|
|
|
@@ -42051,6 +42216,22 @@ var ZakekeEnvironment = /** @class */ (function () {
|
|
|
42051
42216
|
}
|
|
42052
42217
|
});
|
|
42053
42218
|
}); };
|
|
42219
|
+
this.createImageFromUrl = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
42220
|
+
var result;
|
|
42221
|
+
return __generator(this, function (_a) {
|
|
42222
|
+
switch (_a.label) {
|
|
42223
|
+
case 0:
|
|
42224
|
+
if (!this.viewer) return [3 /*break*/, 2];
|
|
42225
|
+
return [4 /*yield*/, _api__WEBPACK_IMPORTED_MODULE_6__["axiosApi"].post(Zakeke.config.baseApiUrl + "images/import/url", {
|
|
42226
|
+
url: url
|
|
42227
|
+
})];
|
|
42228
|
+
case 1:
|
|
42229
|
+
result = (_a.sent()).data;
|
|
42230
|
+
return [2 /*return*/, result];
|
|
42231
|
+
case 2: throw "Called create image from url but no viewer or viewer not ready";
|
|
42232
|
+
}
|
|
42233
|
+
});
|
|
42234
|
+
}); };
|
|
42054
42235
|
this.addItemImage = function (id, areaId) { return __awaiter(_this, void 0, void 0, function () {
|
|
42055
42236
|
return __generator(this, function (_a) {
|
|
42056
42237
|
switch (_a.label) {
|
|
@@ -44014,6 +44195,7 @@ var createProviderValue = function (state, dispatch) {
|
|
|
44014
44195
|
return [2 /*return*/, dispatch({ type: 'ADD_ITEM_IMAGE', imageId: imageId, areaId: areaId })];
|
|
44015
44196
|
}); }); },
|
|
44016
44197
|
createImage: state.environment.createImage.bind(state.environment),
|
|
44198
|
+
createImageFromUrl: state.environment.createImageFromUrl.bind(state.environment),
|
|
44017
44199
|
setItemImage: function (guid, imageId) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
44018
44200
|
return [2 /*return*/, dispatch({ type: 'SET_ITEM_IMAGE', guid: guid, imageId: imageId })];
|
|
44019
44201
|
}); }); },
|