Skip to content

Commit

Permalink
Fix for incorrect buffer size for index array in model loader (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtorresfabra authored Jun 6, 2023
1 parent fc0cb17 commit 263c20f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 3d-style/source/model_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,10 @@ function convertPrimitive(primitive: Object, gltf: Object, textures: Array<Model
// array here. TODO: There might be no need to copy element by element to mesh.indexArray.
const indexAccessor = (typeof indicesIdx === "object") ? indicesIdx : gltf.json.accessors[indicesIdx];
assert(typeof indicesIdx === "number" || (primitive.extensions && primitive.extensions.hasOwnProperty("KHR_draco_mesh_compression")));
mesh.indexArray.reserve(indexAccessor.count);
const numTriangles = indexAccessor.count / 3;
mesh.indexArray.reserve(numTriangles);
const indexArrayBuffer = getBufferData(gltf, indexAccessor);
for (let i = 0; i < indexAccessor.count; i++) {
for (let i = 0; i < numTriangles; i++) {
mesh.indexArray.emplaceBack(indexArrayBuffer[i * 3], indexArrayBuffer[i * 3 + 1], indexArrayBuffer[i * 3 + 2]);
}

Expand Down

0 comments on commit 263c20f

Please sign in to comment.