Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloth_30_45_l.obj is missing in the repo #2

Open
vorg opened this issue Jul 14, 2023 · 2 comments
Open

cloth_30_45_l.obj is missing in the repo #2

vorg opened this issue Jul 14, 2023 · 2 comments

Comments

@vorg
Copy link

vorg commented Jul 14, 2023

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.

Screenshot 2023-07-14 at 13 27 37

@shinjeongmin
Copy link

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.

@shinjeongmin
Copy link

shinjeongmin commented Apr 25, 2024

image

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants