Skip to content

Commit 077dd13

Browse files
authored
USDComposer: Fix uv data for multi-material meshes. (#33297)
1 parent f3fd569 commit 077dd13

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

examples/jsm/loaders/usd/USDComposer.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,10 +1998,17 @@ class USDComposer {
19981998

19991999
// Triangulate original data using consistent pattern
20002000
const { indices: origIndices, pattern: triPattern } = this._triangulateIndicesWithPattern( faceVertexIndices, faceVertexCounts, points, holeMap );
2001-
const origUvIndices = uvIndices ? this._applyTriangulationPattern( uvIndices, triPattern ) : null;
2002-
const origUv2Indices = uv2Indices ? this._applyTriangulationPattern( uv2Indices, triPattern ) : null;
2003-
20042001
const numFaceVertices = faceVertexCounts.reduce( ( a, b ) => a + b, 0 );
2002+
const faceVaryingIdentity = ( uvs && ! uvIndices && uvs.length / 2 === numFaceVertices ) ||
2003+
( uvs2 && ! uv2Indices && uvs2.length / 2 === numFaceVertices )
2004+
? this._applyTriangulationPattern( Array.from( { length: numFaceVertices }, ( _, i ) => i ), triPattern )
2005+
: null;
2006+
const origUvIndices = uvIndices
2007+
? this._applyTriangulationPattern( uvIndices, triPattern )
2008+
: ( uvs && uvs.length / 2 === numFaceVertices ? faceVaryingIdentity : null );
2009+
const origUv2Indices = uv2Indices
2010+
? this._applyTriangulationPattern( uv2Indices, triPattern )
2011+
: ( uvs2 && uvs2.length / 2 === numFaceVertices ? faceVaryingIdentity : null );
20052012
const hasIndexedNormals = normals && normalIndicesRaw && normalIndicesRaw.length > 0;
20062013
const hasFaceVaryingNormals = normals && normals.length / 3 === numFaceVertices;
20072014
const origNormalIndices = hasIndexedNormals

0 commit comments

Comments
 (0)