Fix error message handling in case of multiple loads.
This commit is contained in:
parent
a70fdad067
commit
49e6b06280
@ -31,6 +31,7 @@ export class EmbeddedViewer
|
|||||||
* @param {EnvironmentSettings} [parameters.environmentSettings] Environment settings.
|
* @param {EnvironmentSettings} [parameters.environmentSettings] Environment settings.
|
||||||
* @param {function} [parameters.onModelLoaded] Callback that is called when the model with all
|
* @param {function} [parameters.onModelLoaded] Callback that is called when the model with all
|
||||||
* of the textures is fully loaded.
|
* of the textures is fully loaded.
|
||||||
|
* @param {function} [parameters.onModelLoadFailed] Callback that is called when the model load failed.
|
||||||
*/
|
*/
|
||||||
constructor (parentElement, parameters)
|
constructor (parentElement, parameters)
|
||||||
{
|
{
|
||||||
@ -69,6 +70,7 @@ export class EmbeddedViewer
|
|||||||
this.model = null;
|
this.model = null;
|
||||||
this.modelLoader = new ThreeModelLoader ();
|
this.modelLoader = new ThreeModelLoader ();
|
||||||
|
|
||||||
|
this.progressDiv = null;
|
||||||
window.addEventListener ('resize', () => {
|
window.addEventListener ('resize', () => {
|
||||||
this.Resize ();
|
this.Resize ();
|
||||||
});
|
});
|
||||||
@ -120,26 +122,30 @@ export class EmbeddedViewer
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.model = null;
|
this.model = null;
|
||||||
let progressDiv = null;
|
if (this.progressDiv !== null) {
|
||||||
|
this.parentElement.removeChild (this.progressDiv);
|
||||||
|
this.progressDiv = null;
|
||||||
|
}
|
||||||
this.modelLoader.LoadModel (inputFiles, settings, {
|
this.modelLoader.LoadModel (inputFiles, settings, {
|
||||||
onLoadStart : () => {
|
onLoadStart : () => {
|
||||||
this.canvas.style.display = 'none';
|
this.canvas.style.display = 'none';
|
||||||
progressDiv = document.createElement ('div');
|
this.progressDiv = document.createElement ('div');
|
||||||
progressDiv.innerHTML = Loc ('Loading model...');
|
this.progressDiv.innerHTML = Loc ('Loading model...');
|
||||||
this.parentElement.appendChild (progressDiv);
|
this.parentElement.appendChild (this.progressDiv);
|
||||||
},
|
},
|
||||||
onFileListProgress : (current, total) => {
|
onFileListProgress : (current, total) => {
|
||||||
},
|
},
|
||||||
onFileLoadProgress : (current, total) => {
|
onFileLoadProgress : (current, total) => {
|
||||||
},
|
},
|
||||||
onImportStart : () => {
|
onImportStart : () => {
|
||||||
progressDiv.innerHTML = Loc ('Importing model...');
|
this.progressDiv.innerHTML = Loc ('Importing model...');
|
||||||
},
|
},
|
||||||
onVisualizationStart : () => {
|
onVisualizationStart : () => {
|
||||||
progressDiv.innerHTML = Loc ('Visualizing model...');
|
this.progressDiv.innerHTML = Loc ('Visualizing model...');
|
||||||
},
|
},
|
||||||
onModelFinished : (importResult, threeObject) => {
|
onModelFinished : (importResult, threeObject) => {
|
||||||
this.parentElement.removeChild (progressDiv);
|
this.parentElement.removeChild (this.progressDiv);
|
||||||
|
this.progressDiv = null;
|
||||||
this.canvas.style.display = 'inherit';
|
this.canvas.style.display = 'inherit';
|
||||||
this.viewer.SetMainObject (threeObject);
|
this.viewer.SetMainObject (threeObject);
|
||||||
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
|
let boundingSphere = this.viewer.GetBoundingSphere ((meshUserData) => {
|
||||||
@ -173,7 +179,10 @@ export class EmbeddedViewer
|
|||||||
if (importError.message !== null) {
|
if (importError.message !== null) {
|
||||||
message += ' (' + importError.message + ')';
|
message += ' (' + importError.message + ')';
|
||||||
}
|
}
|
||||||
progressDiv.innerHTML = message;
|
this.progressDiv.innerHTML = message;
|
||||||
|
if (this.parameters.onModelLoadFailed) {
|
||||||
|
this.parameters.onModelLoadFailed ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user