|
@@ -5789,8 +5789,25 @@ var BABYLON;
|
|
|
|
|
|
//# sourceMappingURL=babylon.smartArray.js.map
|
|
|
|
|
|
+
|
|
|
var BABYLON;
|
|
|
(function (BABYLON) {
|
|
|
+ // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
|
|
|
+ // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
|
|
+ var LoadFileError = /** @class */ (function (_super) {
|
|
|
+ __extends(LoadFileError, _super);
|
|
|
+ function LoadFileError(message, request) {
|
|
|
+ var _this = _super.call(this, message) || this;
|
|
|
+ _this.request = request;
|
|
|
+ _this.name = "LoadFileError";
|
|
|
+ LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
|
|
|
+ return _this;
|
|
|
+ }
|
|
|
+ // Polyfill for Object.setPrototypeOf if necessary.
|
|
|
+ LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
|
|
|
+ return LoadFileError;
|
|
|
+ }(Error));
|
|
|
+ BABYLON.LoadFileError = LoadFileError;
|
|
|
// Screenshots
|
|
|
var screenshotCanvas;
|
|
|
var cloneValue = function (source, destinationObject) {
|
|
@@ -6204,7 +6221,7 @@ var BABYLON;
|
|
|
callback(!useArrayBuffer ? req.responseText : req.response, req.responseURL);
|
|
|
}
|
|
|
else {
|
|
|
- var e = new Error("Error status: " + req.status + " - Unable to load " + loadUrl);
|
|
|
+ var e = new LoadFileError("Error status: " + req.status + " - Unable to load " + loadUrl, req);
|
|
|
if (onError) {
|
|
|
onError(req, e);
|
|
|
}
|
|
@@ -53355,17 +53372,12 @@ var BABYLON;
|
|
|
return;
|
|
|
}
|
|
|
scene.database = database;
|
|
|
- try {
|
|
|
- onSuccess(plugin, data, responseURL);
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- onError(null, e);
|
|
|
- }
|
|
|
+ onSuccess(plugin, data, responseURL);
|
|
|
};
|
|
|
var manifestChecked = function (success) {
|
|
|
- BABYLON.Tools.LoadFile(rootUrl + sceneFilename, dataCallback, onProgress, database, useArrayBuffer, function (request) {
|
|
|
+ BABYLON.Tools.LoadFile(rootUrl + sceneFilename, dataCallback, onProgress, database, useArrayBuffer, function (request, exception) {
|
|
|
if (request) {
|
|
|
- onError(request.status + " " + request.statusText);
|
|
|
+ onError(request.status + " " + request.statusText, exception);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -53432,6 +53444,7 @@ var BABYLON;
|
|
|
if (onSuccess === void 0) { onSuccess = null; }
|
|
|
if (onProgress === void 0) { onProgress = null; }
|
|
|
if (onError === void 0) { onError = null; }
|
|
|
+ if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
return null;
|
|
@@ -53439,7 +53452,7 @@ var BABYLON;
|
|
|
var loadingToken = {};
|
|
|
scene._addPendingData(loadingToken);
|
|
|
var errorHandler = function (message, exception) {
|
|
|
- var errorMessage = "Unable to import meshes from " + rootUrl + sceneFilename + (message ? ": " + message : "");
|
|
|
+ var errorMessage = "Unable to import meshes from " + rootUrl + sceneFilename + ": " + message;
|
|
|
if (onError) {
|
|
|
onError(scene, errorMessage, exception);
|
|
|
}
|
|
@@ -53449,10 +53462,25 @@ var BABYLON;
|
|
|
}
|
|
|
scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
- var progressHandler = function (event) {
|
|
|
- if (onProgress) {
|
|
|
+ var progressHandler = onProgress ? function (event) {
|
|
|
+ try {
|
|
|
onProgress(event);
|
|
|
}
|
|
|
+ catch (e) {
|
|
|
+ errorHandler("Error in onProgress callback", e);
|
|
|
+ }
|
|
|
+ } : undefined;
|
|
|
+ var successHandler = function (meshes, particleSystems, skeletons) {
|
|
|
+ scene.importedMeshesFiles.push(rootUrl + sceneFilename);
|
|
|
+ if (onSuccess) {
|
|
|
+ try {
|
|
|
+ onSuccess(meshes, particleSystems, skeletons);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ errorHandler("Error in onSuccess callback", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.rewriteRootURL) {
|
|
@@ -53466,33 +53494,14 @@ var BABYLON;
|
|
|
if (!syncedPlugin.importMesh(meshNames, scene, data, rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
|
|
|
return;
|
|
|
}
|
|
|
- if (onSuccess) {
|
|
|
- // wrap onSuccess with try-catch to know if something went wrong.
|
|
|
- try {
|
|
|
- scene.importedMeshesFiles.push(rootUrl + sceneFilename);
|
|
|
- onSuccess(meshes, particleSystems, skeletons);
|
|
|
- scene._removePendingData(loadingToken);
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- var message = 'Error in onSuccess callback.';
|
|
|
- errorHandler(message, e);
|
|
|
- }
|
|
|
- }
|
|
|
+ scene.loadingPluginName = plugin.name;
|
|
|
+ successHandler(meshes, particleSystems, skeletons);
|
|
|
}
|
|
|
else {
|
|
|
var asyncedPlugin = plugin;
|
|
|
asyncedPlugin.importMeshAsync(meshNames, scene, data, rootUrl, function (meshes, particleSystems, skeletons) {
|
|
|
- if (onSuccess) {
|
|
|
- try {
|
|
|
- scene.importedMeshesFiles.push(rootUrl + sceneFilename);
|
|
|
- onSuccess(meshes, particleSystems, skeletons);
|
|
|
- scene._removePendingData(loadingToken);
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- var message = 'Error in onSuccess callback.';
|
|
|
- errorHandler(message, e);
|
|
|
- }
|
|
|
- }
|
|
|
+ scene.loadingPluginName = plugin.name;
|
|
|
+ successHandler(meshes, particleSystems, skeletons);
|
|
|
}, progressHandler, errorHandler);
|
|
|
}
|
|
|
}, progressHandler, errorHandler, pluginExtension);
|
|
@@ -53507,6 +53516,10 @@ var BABYLON;
|
|
|
* @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
*/
|
|
|
SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
+ if (onSuccess === void 0) { onSuccess = null; }
|
|
|
+ if (onProgress === void 0) { onProgress = null; }
|
|
|
+ if (onError === void 0) { onError = null; }
|
|
|
+ if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
return SceneLoader.Append(rootUrl, sceneFilename, new BABYLON.Scene(engine), onSuccess, onProgress, onError, pluginExtension);
|
|
|
};
|
|
|
/**
|
|
@@ -53519,6 +53532,10 @@ var BABYLON;
|
|
|
* @param onError a callback with the scene, a message, and possibly an exception when import fails
|
|
|
*/
|
|
|
SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
|
|
|
+ if (onSuccess === void 0) { onSuccess = null; }
|
|
|
+ if (onProgress === void 0) { onProgress = null; }
|
|
|
+ if (onError === void 0) { onError = null; }
|
|
|
+ if (pluginExtension === void 0) { pluginExtension = null; }
|
|
|
if (sceneFilename.substr && sceneFilename.substr(0, 1) === "/") {
|
|
|
BABYLON.Tools.Error("Wrong sceneFilename parameter");
|
|
|
return null;
|
|
@@ -53540,10 +53557,24 @@ var BABYLON;
|
|
|
scene._removePendingData(loadingToken);
|
|
|
scene.getEngine().hideLoadingUI();
|
|
|
};
|
|
|
- var progressHandler = function (event) {
|
|
|
- if (onProgress) {
|
|
|
+ var progressHandler = onProgress ? function (event) {
|
|
|
+ try {
|
|
|
onProgress(event);
|
|
|
}
|
|
|
+ catch (e) {
|
|
|
+ errorHandler("Error in onProgress callback", e);
|
|
|
+ }
|
|
|
+ } : undefined;
|
|
|
+ var successHandler = function () {
|
|
|
+ if (onSuccess) {
|
|
|
+ try {
|
|
|
+ onSuccess(scene);
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ errorHandler("Error in onSuccess callback", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scene._removePendingData(loadingToken);
|
|
|
};
|
|
|
return SceneLoader._loadData(rootUrl, sceneFilename, scene, function (plugin, data, responseURL) {
|
|
|
if (plugin.load) {
|
|
@@ -53551,25 +53582,14 @@ var BABYLON;
|
|
|
if (!syncedPlugin.load(scene, data, rootUrl, errorHandler)) {
|
|
|
return;
|
|
|
}
|
|
|
- if (onSuccess) {
|
|
|
- try {
|
|
|
- onSuccess(scene);
|
|
|
- }
|
|
|
- catch (e) {
|
|
|
- errorHandler("Error in onSuccess callback", e);
|
|
|
- }
|
|
|
- }
|
|
|
scene.loadingPluginName = plugin.name;
|
|
|
- scene._removePendingData(loadingToken);
|
|
|
+ successHandler();
|
|
|
}
|
|
|
else {
|
|
|
var asyncedPlugin = plugin;
|
|
|
asyncedPlugin.loadAsync(scene, data, rootUrl, function () {
|
|
|
- if (onSuccess) {
|
|
|
- onSuccess(scene);
|
|
|
- }
|
|
|
scene.loadingPluginName = plugin.name;
|
|
|
- scene._removePendingData(loadingToken);
|
|
|
+ successHandler();
|
|
|
}, progressHandler, errorHandler);
|
|
|
}
|
|
|
if (SceneLoader.ShowLoadingScreen) {
|
|
@@ -75751,8 +75771,8 @@ var BABYLON;
|
|
|
if (meshHighlight.observerDefault) {
|
|
|
mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
|
|
|
}
|
|
|
+ delete this._meshes[mesh.uniqueId];
|
|
|
}
|
|
|
- this._meshes[mesh.uniqueId] = null;
|
|
|
this._shouldRender = false;
|
|
|
for (var meshHighlightToCheck in this._meshes) {
|
|
|
if (this._meshes[meshHighlightToCheck]) {
|
|
@@ -80063,7 +80083,12 @@ var BABYLON;
|
|
|
this._loader.importMeshAsync(meshesNames, scene, loaderData, rootUrl, onSuccess, onProgress, onError);
|
|
|
}
|
|
|
catch (e) {
|
|
|
- onError(e.message);
|
|
|
+ if (onError) {
|
|
|
+ onError(e.message, e);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BABYLON.Tools.Error(e.message);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) {
|
|
@@ -80076,7 +80101,12 @@ var BABYLON;
|
|
|
this._loader.loadAsync(scene, loaderData, rootUrl, onSuccess, onProgress, onError);
|
|
|
}
|
|
|
catch (e) {
|
|
|
- onError(e.message);
|
|
|
+ if (onError) {
|
|
|
+ onError(e.message, e);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ BABYLON.Tools.Error(e.message);
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
GLTFFileLoader.prototype.canDirectLoad = function (data) {
|
|
@@ -82554,7 +82584,9 @@ var BABYLON;
|
|
|
GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onSuccess, onProgress, onError) {
|
|
|
var _this = this;
|
|
|
this._loadAsync(meshesNames, scene, data, rootUrl, function () {
|
|
|
- onSuccess(_this._getMeshes(), [], _this._getSkeletons());
|
|
|
+ if (onSuccess) {
|
|
|
+ onSuccess(_this._getMeshes(), [], _this._getSkeletons());
|
|
|
+ }
|
|
|
}, onProgress, onError);
|
|
|
};
|
|
|
GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) {
|
|
@@ -82562,13 +82594,13 @@ var BABYLON;
|
|
|
};
|
|
|
GLTFLoader.prototype._loadAsync = function (nodeNames, scene, data, rootUrl, onSuccess, onProgress, onError) {
|
|
|
var _this = this;
|
|
|
+ this._babylonScene = scene;
|
|
|
+ this._rootUrl = rootUrl;
|
|
|
+ this._successCallback = onSuccess;
|
|
|
+ this._progressCallback = onProgress;
|
|
|
+ this._errorCallback = onError;
|
|
|
this._tryCatchOnError(function () {
|
|
|
_this._loadData(data);
|
|
|
- _this._babylonScene = scene;
|
|
|
- _this._rootUrl = rootUrl;
|
|
|
- _this._successCallback = onSuccess;
|
|
|
- _this._progressCallback = onProgress;
|
|
|
- _this._errorCallback = onError;
|
|
|
_this._addPendingData(_this);
|
|
|
_this._loadDefaultScene(nodeNames);
|
|
|
_this._loadAnimations();
|
|
@@ -82606,7 +82638,9 @@ var BABYLON;
|
|
|
GLTFLoader.prototype._onRenderReady = function () {
|
|
|
this._rootNode.babylonMesh.setEnabled(true);
|
|
|
this._startAnimations();
|
|
|
- this._successCallback();
|
|
|
+ if (this._successCallback) {
|
|
|
+ this._successCallback();
|
|
|
+ }
|
|
|
this._renderReadyObservable.notifyObservers(this);
|
|
|
};
|
|
|
GLTFLoader.prototype._onComplete = function () {
|
|
@@ -83884,9 +83918,9 @@ var BABYLON;
|
|
|
_this._onProgress();
|
|
|
}
|
|
|
});
|
|
|
- }, this._babylonScene.database, true, function (request) {
|
|
|
+ }, this._babylonScene.database, true, function (request, exception) {
|
|
|
_this._tryCatchOnError(function () {
|
|
|
- throw new Error(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""));
|
|
|
+ throw new BABYLON.LoadFileError(context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request);
|
|
|
});
|
|
|
});
|
|
|
if (request) {
|
|
@@ -83905,7 +83939,7 @@ var BABYLON;
|
|
|
catch (e) {
|
|
|
BABYLON.Tools.Error("glTF Loader: " + e.message);
|
|
|
if (this._errorCallback) {
|
|
|
- this._errorCallback(e.message);
|
|
|
+ this._errorCallback(e.message, e);
|
|
|
}
|
|
|
this.dispose();
|
|
|
}
|