forked from mirror/ObjToSchematic
Fixed warnings
This commit is contained in:
parent
d5ccda9fa9
commit
cee9871bfa
@ -151,6 +151,8 @@ export class AppContext {
|
||||
this._loadedMesh = importer.toMesh();
|
||||
this._loadedMesh.processMesh();
|
||||
Renderer.Get.useMesh(this._loadedMesh);
|
||||
|
||||
this._warnings = this._loadedMesh.getWarnings();
|
||||
}
|
||||
|
||||
private _simplify() {
|
||||
@ -201,6 +203,8 @@ export class AppContext {
|
||||
if (filePath) {
|
||||
exporter.export(this._loadedBlockMesh, filePath);
|
||||
}
|
||||
|
||||
this._warnings = exporter.getWarnings();
|
||||
}
|
||||
|
||||
public draw() {
|
||||
|
24
src/mesh.ts
24
src/mesh.ts
@ -85,12 +85,34 @@ export class Mesh extends Warnable {
|
||||
// TODO: Check indices exist
|
||||
|
||||
if (this._vertices.length === 0) {
|
||||
throw new CustomError('No verticies were loaded');
|
||||
throw new CustomError('No vertices were loaded');
|
||||
}
|
||||
|
||||
if (this._tris.length === 0) {
|
||||
throw new CustomError('No triangles were loaded');
|
||||
}
|
||||
|
||||
// Give warning if normals are not defined
|
||||
let giveNormalsWarning = false;
|
||||
for (let triIndex = 0; triIndex < this.getTriangleCount(); ++triIndex) {
|
||||
const tri = this._tris[triIndex];
|
||||
if (tri.normalIndices) {
|
||||
const xWellDefined = tri.normalIndices.x < this._normals.length;
|
||||
const yWellDefined = tri.normalIndices.y < this._normals.length;
|
||||
const zWellDefined = tri.normalIndices.z < this._normals.length;
|
||||
if (!xWellDefined || !yWellDefined || !zWellDefined) {
|
||||
giveNormalsWarning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!tri.normalIndices) {
|
||||
giveNormalsWarning = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (giveNormalsWarning) {
|
||||
this.addWarning('Some vertices do not have their normals defined, this may cause voxels to be aligned incorrectly');
|
||||
}
|
||||
}
|
||||
|
||||
private _checkMaterials() {
|
||||
|
Loading…
Reference in New Issue
Block a user