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 3 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
18 changes: 18 additions & 0 deletions specs/lib/cacheOptimizationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ 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'
}
}
]
}
}
};
cacheOptimization(gltf);
Copy link
Contributor

@lilleyse lilleyse Aug 10, 2016

Choose a reason for hiding this comment

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

You should have at least one expect in here. Maybe just create a spy for GeometryPipeline.reorderForPostVertexCache and check that it's not called.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh well I guess that would pass for both...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that should work. gltfPrimitiveToCesiumGeometry would work too.

});
});