diff --git a/source/engine/core/taskrunner.js b/source/engine/core/taskrunner.js index 6e1cb8c..4294cf6 100644 --- a/source/engine/core/taskrunner.js +++ b/source/engine/core/taskrunner.js @@ -59,7 +59,7 @@ export function RunTaskAsync (task) { setTimeout (() => { task (); - }, 0); + }, 10); } export function RunTasks (count, callbacks) @@ -81,7 +81,7 @@ export function WaitWhile (expression) if (expression ()) { setTimeout (() => { Waiter (expression); - }, 1); + }, 10); } } Waiter (expression); diff --git a/source/engine/import/importer.js b/source/engine/import/importer.js index 65da4fa..5e8396d 100644 --- a/source/engine/import/importer.js +++ b/source/engine/import/importer.js @@ -114,7 +114,9 @@ export class Importer onReady : () => { callbacks.onImportStart (); RunTaskAsync (() => { - this.ImportLoadedFiles (settings, callbacks); + this.DecompressArchives (this.fileList, () => { + this.ImportLoadedFiles (settings, callbacks); + }); }); }, onFileProgress : callbacks.onFileProgress, @@ -149,11 +151,7 @@ export class Importer this.fileList = newFileList; } this.fileList.GetContent ({ - onReady : () => { - this.DecompressArchives (this.fileList, () => { - callbacks.onReady (); - }); - }, + onReady : callbacks.onReady, onFileProgress : callbacks.onFileProgress, onFileLoadProgress : callbacks.onFileLoadProgress }); diff --git a/source/website/dialog.js b/source/website/dialog.js index 64e411d..c511dd1 100644 --- a/source/website/dialog.js +++ b/source/website/dialog.js @@ -135,22 +135,42 @@ export class ProgressDialog extends Dialog super (); this.SetCloseable (false); this.textDiv = null; + this.progressDiv = null; } Init (text) { let contentDiv = this.GetContentDiv (); contentDiv.classList.add ('ov_progress'); + let innerContentDiv = AddDiv (contentDiv, 'ov_progress_inner'); - AddDiv (contentDiv, 'ov_progress_img', ''); - this.textDiv = AddDiv (contentDiv, 'ov_progress_text'); + AddDiv (innerContentDiv, 'ov_progress_img', ''); + this.textDiv = AddDiv (innerContentDiv, 'ov_progress_text'); this.SetText (text); + + this.progressDiv = AddDiv (contentDiv, 'ov_progress_bar'); } SetText (text) { this.textDiv.innerHTML = text; } + + ResetProgress () + { + this.progressDiv.style.width = '0px'; + } + + SetProgress (ratio) + { + let progressWidth = 0; + if (ratio !== null) { + let contentDiv = this.GetContentDiv (); + let fullWidth = contentDiv.offsetWidth; + progressWidth = ratio * fullWidth; + } + this.progressDiv.style.width = progressWidth.toString () + 'px'; + } } export class ButtonDialog extends Dialog diff --git a/source/website/threemodelloaderui.js b/source/website/threemodelloaderui.js index 42fb46f..2b5679f 100644 --- a/source/website/threemodelloaderui.js +++ b/source/website/threemodelloaderui.js @@ -29,11 +29,18 @@ export class ThreeModelLoaderUI progressDialog.Open (); }, onFileProgress : (current, total) => { + progressDialog.SetProgress (null); progressDialog.SetText ('Loading File ' + (current + 1).toString () + '/' + total.toString ()); }, onFileLoadProgress : (current, total) => { + if (total > 0) { + progressDialog.SetProgress (current / total); + } else { + progressDialog.SetProgress (null); + } }, onSelectMainFile : (fileNames, selectFile) => { + progressDialog.SetProgress (null); progressDialog.Close (); this.modalDialog = this.ShowFileSelectorDialog (fileNames, (index) => { progressDialog.Open (); @@ -41,9 +48,11 @@ export class ThreeModelLoaderUI }); }, onImportStart : () => { + progressDialog.SetProgress (null); progressDialog.SetText ('Importing Model'); }, onVisualizationStart : () => { + progressDialog.SetProgress (null); progressDialog.SetText ('Visualizing Model'); }, onModelFinished : (importResult, threeObject) => { diff --git a/website/css/dialogs.css b/website/css/dialogs.css index cae122c..cbc5df5 100644 --- a/website/css/dialogs.css +++ b/website/css/dialogs.css @@ -221,11 +221,15 @@ div.ov_progress background: var(--ov_dialog_background_color); text-align: center; width: 400px; - padding: 20px; box-shadow: var(--ov_shadow); border-radius: 5px; } +div.ov_progress_inner +{ + padding: 20px; +} + div.ov_progress div.ov_progress_img svg { width: 80px; @@ -251,6 +255,13 @@ div.ov_progress div.ov_progress_text text-align: center; } +div.ov_progress div.ov_progress_bar +{ + background: var(--ov_button_color); + width: 0px; + height: 3px; +} + div.ov_snapshot_dialog_left { width: 190px;