Fixed progress bars not working, added progress tracking for importing, closes #121

This commit is contained in:
Lucas Dower 2023-06-01 20:47:59 +01:00
parent 21ea0e7c2c
commit ba7d7b6d6d
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import { ProgressManager } from '../progress';
import { LOC } from '../localiser';
import { checkNaN } from '../math';
import { Mesh, Tri } from '../mesh';
@ -183,10 +184,13 @@ export class ObjImporter extends IImporter {
fileSource.replace('\r', ''); // Convert Windows carriage return
const fileLines = fileSource.split('\n');
const numLines = fileLines.length;
for (const line of fileLines) {
const progressHandle = ProgressManager.Get.start('VoxelMeshBuffer');
fileLines.forEach((line, index) => {
this.parseOBJLine(line);
}
ProgressManager.Get.progress(progressHandle, index / numLines);
})
return new Mesh(this._vertices, this._normals, this._uvs, this._tris, new Map());
});

View File

@ -73,6 +73,13 @@ export class UI {
EventManager.Get.add(EAppEvent.onLanguageChanged, () => {
this._handleLanguageChange();
});
EventManager.Get.add(EAppEvent.onTaskProgress, (e: any) => {
const lastAction = this._appContext?.getLastAction();
if (lastAction !== undefined) {
this.getActionButton(lastAction)?.setProgress(e[1]);
}
});
}
public uiOrder = ['settings', 'import', 'materials', 'voxelise', 'assign', 'export'];