mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2024-12-27 03:18:59 +08:00
Fixed #37, added triangle count warning
This commit is contained in:
parent
acde66085f
commit
8e04c1eb00
@ -92,6 +92,10 @@ export class Mesh extends Warnable {
|
||||
throw new CustomError('No triangles were loaded');
|
||||
}
|
||||
|
||||
if (this._tris.length >= 100_000) {
|
||||
this.addWarning(`The imported mesh has ${this._tris.length} triangles, consider simplifying it in a DDC such as Blender`);
|
||||
}
|
||||
|
||||
// Give warning if normals are not defined
|
||||
let giveNormalsWarning = false;
|
||||
for (let triIndex = 0; triIndex < this.getTriangleCount(); ++triIndex) {
|
||||
|
@ -186,7 +186,7 @@ export const LOG_ERROR = console.error;
|
||||
export const REGEX_NZ_WS = /[ \t]+/;
|
||||
|
||||
/** Regex for number */
|
||||
export const REGEX_NUMBER = /[0-9\.\-]+/;
|
||||
export const REGEX_NUMBER = /[0-9e+\.\-]+/;
|
||||
|
||||
export const REGEX_NZ_ANY = /.+/;
|
||||
|
||||
@ -280,7 +280,7 @@ export class Warnable {
|
||||
}
|
||||
|
||||
public addWarning(warning: string) {
|
||||
this._warnings.push(warning);
|
||||
this._warnings.push('- ' + warning);
|
||||
}
|
||||
|
||||
public getWarnings() {
|
||||
|
@ -10,6 +10,14 @@ test('Parse vertex #1', () => {
|
||||
expect(mesh._vertices[0].equals(new Vector3(1, -2, 3))).toBe(true);
|
||||
});
|
||||
|
||||
test('Parse vertex #2', () => {
|
||||
const importer = new ObjImporter();
|
||||
importer.parseOBJLine('v 4.467e+000 9.243e+000 9.869e+000');
|
||||
const mesh = importer.toMesh();
|
||||
expect(mesh._vertices.length).toEqual(1);
|
||||
expect(mesh._vertices[0].equals(new Vector3(4.467e+000, 9.243e+000, 9.869e+000))).toBe(true);
|
||||
});
|
||||
|
||||
test('Parse normal #1', () => {
|
||||
const importer = new ObjImporter();
|
||||
importer.parseOBJLine('vn -1.0 -0.5 0.0');
|
||||
|
Loading…
Reference in New Issue
Block a user