Open vorg opened 1 year ago
Thanks. I couldn't render it, so I looked at it, and the obj path was wrong! I will also explore the issue of cloth_20_30_l.obj breaking.
I solved it! The problem is that ObjLoader can't correct parse quad indices. So, i fix ObjLoader and cloth is perfectly render without broken.
// Loop through faces, and return the buffers that will be sent to GPU for rendering
{
const cache: Record<string, number> = {};
let i = 0;
for (const faces of cachedFaces) {
// calculate triangle count in faces
const triangleCount = faces.length - 2;
for(var j = 0; j < triangleCount; j++) {
const triangleFace : string[] = [faces[0]];
triangleFace.push(faces[1 + j]);
triangleFace.push(faces[2 + j]);
for (const faceString of triangleFace) {
// If we already saw this, add to indices list.
if (cache[faceString] !== undefined) {
finalIndices.push(cache[faceString]);
continue;
}
cache[faceString] = i;
finalIndices.push(i);
// Need to convert strings to integers, and subtract by 1 to get to zero index.
const [vI, uvI, nI] = faceString
.split("/")
.map((s: string) => Number(s) - 1);
vI > -1 && finalPosition.push(...cachedVertices[vI]);
uvI > -1 && finalUvs.push(...cachedUvs[uvI]);
nI > -1 && finalNormals.push(...cachedNormals[nI]);
i += 1;
}
}
}
}
below is fixed code in ObjLoader.ts
But now i have some issue related with uv texture.
The app tries to load cloth_30_45_l.obj which is not in the repo.
I've tried using cloth_20_30_l.obj provided but it appears broken.