forked from mirror/ObjToSchematic
Fixed progress bars not working, added progress tracking for importing, closes #121
This commit is contained in:
parent
21ea0e7c2c
commit
ba7d7b6d6d
@ -1,3 +1,4 @@
|
|||||||
|
import { ProgressManager } from '../progress';
|
||||||
import { LOC } from '../localiser';
|
import { LOC } from '../localiser';
|
||||||
import { checkNaN } from '../math';
|
import { checkNaN } from '../math';
|
||||||
import { Mesh, Tri } from '../mesh';
|
import { Mesh, Tri } from '../mesh';
|
||||||
@ -183,10 +184,13 @@ export class ObjImporter extends IImporter {
|
|||||||
|
|
||||||
fileSource.replace('\r', ''); // Convert Windows carriage return
|
fileSource.replace('\r', ''); // Convert Windows carriage return
|
||||||
const fileLines = fileSource.split('\n');
|
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);
|
this.parseOBJLine(line);
|
||||||
}
|
ProgressManager.Get.progress(progressHandle, index / numLines);
|
||||||
|
})
|
||||||
|
|
||||||
return new Mesh(this._vertices, this._normals, this._uvs, this._tris, new Map());
|
return new Mesh(this._vertices, this._normals, this._uvs, this._tris, new Map());
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,13 @@ export class UI {
|
|||||||
EventManager.Get.add(EAppEvent.onLanguageChanged, () => {
|
EventManager.Get.add(EAppEvent.onLanguageChanged, () => {
|
||||||
this._handleLanguageChange();
|
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'];
|
public uiOrder = ['settings', 'import', 'materials', 'voxelise', 'assign', 'export'];
|
||||||
|
Loading…
Reference in New Issue
Block a user