소스 검색

Fix gltf data alignement (byteOffset multiple of 4) for indices

noalak 8 년 전
부모
커밋
67a19f5780
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      Exporters/3ds Max/Max2Babylon/2017/Exporter/BabylonExporter.GLTFExporter.Mesh.cs

+ 9 - 0
Exporters/3ds Max/Max2Babylon/2017/Exporter/BabylonExporter.GLTFExporter.Mesh.cs

@@ -346,6 +346,15 @@ namespace Max2Babylon
                 // Update byte length and count of accessors, bufferViews and buffers
                 // Scalar
                 AddElementsToAccessor(accessorIndices, _indices.Count);
+                // Ensure the byteoffset is a multiple of 4
+                // Indices accessor element size if 2
+                // So the count needs to be even
+                if (gltfIndices.Count % 2 != 0)
+                {
+                    gltfIndices.Add(0);
+                    bufferViewScalar.byteLength += 2;
+                    buffer.byteLength += 2;
+                }
                 // Vector3
                 AddElementsToAccessor(accessorPositions, globalVerticesSubMesh.Count);
                 AddElementsToAccessor(accessorNormals, globalVerticesSubMesh.Count);