mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 11:59:26 -05:00
ushort の index を uint に変換する
This commit is contained in:
@@ -76,7 +76,31 @@ namespace UniVRM10
|
||||
// update Mesh
|
||||
foreach (var (gltfMesh, mesh) in Enumerable.Zip(gltf.meshes, model.MeshGroups, (l, r) => (l, r.Meshes[0])))
|
||||
{
|
||||
var indices = mesh.IndexBuffer.GetSpan<uint>();
|
||||
SpanLike<uint> indices;
|
||||
switch (mesh.IndexBuffer.Stride)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
// ushort
|
||||
var ushort_indices = mesh.IndexBuffer.GetSpan<ushort>();
|
||||
indices = SpanLike.Create<uint>(ushort_indices.Length);
|
||||
for (int i = 0; i < ushort_indices.Length; ++i)
|
||||
{
|
||||
indices[i] = ushort_indices[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 4:
|
||||
{
|
||||
// uint
|
||||
indices = mesh.IndexBuffer.GetSpan<uint>();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
var position = AddAccessor<Vector3>(mesh.VertexBuffer.Positions);
|
||||
var normal = AddAccessor<Vector3>(mesh.VertexBuffer.Normals);
|
||||
var uv = AddAccessor<Vector2>(mesh.VertexBuffer.TexCoords);
|
||||
|
||||
Reference in New Issue
Block a user