primitive.indices の型を ushort に対応させる

This commit is contained in:
ousttrue
2021-10-14 18:26:37 +09:00
parent 0953e00dfa
commit 9a950f8fab
2 changed files with 7 additions and 3 deletions

View File

@@ -72,6 +72,10 @@ namespace UniGLTF
{
return cv.ComponentType;
}
else if (typeof(T) == typeof(ushort))
{
return glComponentType.UNSIGNED_SHORT;
}
else if (typeof(T) == typeof(uint))
{
return glComponentType.UNSIGNED_INT;
@@ -119,10 +123,10 @@ namespace UniGLTF
}
}
public static int ExtendBufferAndGetAccessorIndex<T>(this glTF gltf, int bufferIndex, T[] array,
public static int ExtendBufferAndGetAccessorIndex<T>(this glTF gltf, int bufferIndex, IReadOnlyList<T> list,
glBufferTarget target = glBufferTarget.NONE) where T : struct
{
return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment<T>(array), target);
return gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, new ArraySegment<T>(list.ToArray()), target);
}
public static int ExtendBufferAndGetAccessorIndex<T>(this glTF gltf, int bufferIndex,

View File

@@ -127,7 +127,7 @@ namespace UniGLTF
indices.Add((uint)i0);
}
var indicesAccessorIndex = gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, indices.ToArray(), glBufferTarget.ELEMENT_ARRAY_BUFFER);
var indicesAccessorIndex = gltf.ExtendBufferAndGetAccessorIndex(bufferIndex, indices, glBufferTarget.ELEMENT_ARRAY_BUFFER);
if (indicesAccessorIndex < 0)
{
// https://github.com/vrm-c/UniVRM/issues/664