diff --git a/Runtime/Scripts/SceneImporter/ImporterMeshes.cs b/Runtime/Scripts/SceneImporter/ImporterMeshes.cs index 6f1e02e01..8c195f337 100644 --- a/Runtime/Scripts/SceneImporter/ImporterMeshes.cs +++ b/Runtime/Scripts/SceneImporter/ImporterMeshes.cs @@ -265,8 +265,30 @@ protected virtual DracoDecodeResult ConstructDracoMesh(GLTFMesh mesh, int meshIn decodeSettings |= DecodeSettings.RequireTangents; if (firstPrim != null && firstPrim.Targets != null) decodeSettings |= DecodeSettings.ForceUnityVertexLayout; + + var attrMap = DracoDecoder.CreateAttributeIdMap(weightsAttributeId, jointsAttributeId); + if (attrMap == null) + attrMap = new Dictionary(); + + if (hasTangents) + attrMap.Add( VertexAttribute.Tangent, dracoExtension.attributes[SemanticProperties.TANGENT]); + + if (dracoExtension.attributes.TryGetValue(SemanticProperties.COLOR_0, out var colorAttr)) + attrMap.Add( VertexAttribute.Color, colorAttr); + + if (dracoExtension.attributes.TryGetValue(SemanticProperties.TEXCOORD_0, out var uvAttr)) + attrMap.Add( VertexAttribute.TexCoord0, uvAttr); - decodeResult.decodeResults[i] = DracoDecoder.DecodeMesh( _assetCache.MeshCache[meshIndex].DracoMeshData[i], bufferViewData, decodeSettings, DracoDecoder.CreateAttributeIdMap(weightsAttributeId, jointsAttributeId)); + if (dracoExtension.attributes.TryGetValue(SemanticProperties.TEXCOORD_1, out var uv2Attr)) + attrMap.Add( VertexAttribute.TexCoord1, uv2Attr); + + if (dracoExtension.attributes.TryGetValue(SemanticProperties.NORMAL, out var normalAttr)) + attrMap.Add( VertexAttribute.Normal, normalAttr); + + if (dracoExtension.attributes.TryGetValue(SemanticProperties.POSITION, out var positionAttr)) + attrMap.Add( VertexAttribute.Position, positionAttr); + + decodeResult.decodeResults[i] = DracoDecoder.DecodeMesh( _assetCache.MeshCache[meshIndex].DracoMeshData[i], bufferViewData, decodeSettings, attrMap); #else var draco = new DracoMeshLoader();