webgpu_cloth_simulator icon indicating copy to clipboard operation
webgpu_cloth_simulator copied to clipboard

cloth_30_45_l.obj is missing in the repo

Open vorg opened this issue 2 years ago • 2 comments

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

vorg avatar Jul 14 '23 12:07 vorg

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 avatar Apr 09 '24 10:04 shinjeongmin

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.

shinjeongmin avatar Apr 25 '24 17:04 shinjeongmin