Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont optimize without indices #155

Merged
merged 4 commits into from
Aug 10, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/cacheOptimization.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ function cacheOptimization(gltf, cacheSize) {
var primitivesLength = primitives.length;
for (var i = 0; i < primitivesLength; i++) {
primitive = primitives[i];
geometry = gltfPrimitiveToCesiumGeometry(gltf, primitive);
GeometryPipeline.reorderForPostVertexCache(geometry, cacheSize);

cesiumGeometryToGltfPrimitive(gltf, primitive, geometry);
if (defined(primitive.indices)) {
geometry = gltfPrimitiveToCesiumGeometry(gltf, primitive);
GeometryPipeline.reorderForPostVertexCache(geometry, cacheSize);
cesiumGeometryToGltfPrimitive(gltf, primitive, geometry);
}
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions specs/lib/cacheOptimizationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,24 @@ describe('cacheOptimization', function() {
expect(positions).toEqual(unpackedOptimizedVertices);
}), done).toResolve();
});

it('doesn\'t run if a primitive has no indices', function() {
var gltf = {
meshes : {
mesh : {
primitives : [
{
attributes : {
POSITION : 'notImportant',
NORMAL : 'notImportantEither'
}
}
]
}
}
};
expect(function() {
cacheOptimization(gltf);
}).not.toThrowRuntimeError();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to test this, since we don't actually throw RuntimeErrors in gltf-pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and this doesn't fail without the changes, so you're right, we need a better test here.

});
});