|
@@ -320,7 +320,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
|
|
const positions = mesh.getVerticesData(VertexBuffer.PositionKind);
|
|
const positions = mesh.getVerticesData(VertexBuffer.PositionKind);
|
|
const normals = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
const normals = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
const mapVertices: { [key: string]: number[] } = {};
|
|
const mapVertices: { [key: string]: number[] } = {};
|
|
-
|
|
|
|
|
|
+
|
|
if (!positions || !normals) {
|
|
if (!positions || !normals) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -330,7 +330,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
|
|
const y = positions[i * 3 + 1];
|
|
const y = positions[i * 3 + 1];
|
|
const z = positions[i * 3 + 2];
|
|
const z = positions[i * 3 + 2];
|
|
const key = x + "_" + y + "_" + z;
|
|
const key = x + "_" + y + "_" + z;
|
|
-
|
|
|
|
|
|
+
|
|
let lst = mapVertices[key];
|
|
let lst = mapVertices[key];
|
|
if (!lst) {
|
|
if (!lst) {
|
|
lst = [];
|
|
lst = [];
|
|
@@ -338,7 +338,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
|
|
}
|
|
}
|
|
lst.push(i);
|
|
lst.push(i);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
const normal = new Vector3();
|
|
const normal = new Vector3();
|
|
for (const key in mapVertices) {
|
|
for (const key in mapVertices) {
|
|
const lst = mapVertices[key];
|
|
const lst = mapVertices[key];
|
|
@@ -364,10 +364,9 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
|
|
normals[vIdx * 3 + 2] = normal.z;
|
|
normals[vIdx * 3 + 2] = normal.z;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
mesh.setVerticesData(VertexBuffer.NormalKind, normals);
|
|
mesh.setVerticesData(VertexBuffer.NormalKind, normals);
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Read the OBJ file and create an Array of meshes.
|
|
* Read the OBJ file and create an Array of meshes.
|
|
* Each mesh contains all information given by the OBJ and the MTL file.
|
|
* Each mesh contains all information given by the OBJ and the MTL file.
|