Skip to content

Commit

Permalink
feat: allow importing non-standard VEC3 and VEC4 TEXCOORD_n data and …
Browse files Browse the repository at this point in the history
…convert it to VEC2
  • Loading branch information
hybridherbst committed Jul 23, 2024
1 parent af78321 commit 731ddd1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Runtime/Plugins/GLTFSerialization/Schema/Accessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public unsafe float2[] AsTexcoordArray(ref NumericArray contents, NativeArray<by
return contents.AsFloat2s;
}

if (Type != GLTFAccessorAttributeType.VEC2)
if (Type != GLTFAccessorAttributeType.VEC2 && Type != GLTFAccessorAttributeType.VEC3 && Type != GLTFAccessorAttributeType.VEC4)
{
return null;
}
Expand All @@ -754,7 +754,8 @@ public unsafe float2[] AsTexcoordArray(ref NumericArray contents, NativeArray<by
GetTypeDetails(ComponentType, out uint componentSize, out float maxValue);
var bufferPointer = NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr<byte>(bufferViewData);

uint stride = BufferView.Value.ByteStride > 0 ? BufferView.Value.ByteStride : componentSize * 2;
uint typeBasedStride = Type == GLTFAccessorAttributeType.VEC2 ? (uint) 2 : Type == GLTFAccessorAttributeType.VEC3 ? (uint) 3 : (uint) 4;
uint stride = BufferView.Value.ByteStride > 0 ? BufferView.Value.ByteStride : componentSize * typeBasedStride;
if (!normalizeIntValues) maxValue = 1;

if (ComponentType == GLTFComponentType.Float)
Expand Down

0 comments on commit 731ddd1

Please sign in to comment.