From 077dd13c0e869d9f3dbe55875686f920367de457 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Tue, 31 Mar 2026 14:01:55 +0200 Subject: [PATCH] USDComposer: Fix uv data for multi-material meshes. (#33297) --- examples/jsm/loaders/usd/USDComposer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/jsm/loaders/usd/USDComposer.js b/examples/jsm/loaders/usd/USDComposer.js index 0cbdfe6db6baf3..0e3721cf15e329 100644 --- a/examples/jsm/loaders/usd/USDComposer.js +++ b/examples/jsm/loaders/usd/USDComposer.js @@ -1998,10 +1998,17 @@ class USDComposer { // Triangulate original data using consistent pattern const { indices: origIndices, pattern: triPattern } = this._triangulateIndicesWithPattern( faceVertexIndices, faceVertexCounts, points, holeMap ); - const origUvIndices = uvIndices ? this._applyTriangulationPattern( uvIndices, triPattern ) : null; - const origUv2Indices = uv2Indices ? this._applyTriangulationPattern( uv2Indices, triPattern ) : null; - const numFaceVertices = faceVertexCounts.reduce( ( a, b ) => a + b, 0 ); + const faceVaryingIdentity = ( uvs && ! uvIndices && uvs.length / 2 === numFaceVertices ) || + ( uvs2 && ! uv2Indices && uvs2.length / 2 === numFaceVertices ) + ? this._applyTriangulationPattern( Array.from( { length: numFaceVertices }, ( _, i ) => i ), triPattern ) + : null; + const origUvIndices = uvIndices + ? this._applyTriangulationPattern( uvIndices, triPattern ) + : ( uvs && uvs.length / 2 === numFaceVertices ? faceVaryingIdentity : null ); + const origUv2Indices = uv2Indices + ? this._applyTriangulationPattern( uv2Indices, triPattern ) + : ( uvs2 && uvs2.length / 2 === numFaceVertices ? faceVaryingIdentity : null ); const hasIndexedNormals = normals && normalIndicesRaw && normalIndicesRaw.length > 0; const hasFaceVaryingNormals = normals && normals.length / 3 === numFaceVertices; const origNormalIndices = hasIndexedNormals