-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Support EXT_mesh_primitive_restart glTF extension #12792
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
Conversation
Thank you for the pull request, @eringram! Welcome to the Cesium community! In order for us to review your PR, please complete the following steps:
Review Pull Request Guidelines to make sure your PR gets accepted quickly. |
Thanks @eringram! I can confirm we have a CLA on file covering you. |
I read through the code. This looks great; thanks @eringram. |
@eringram Is this PR ready for full or partial review? If so, could you please update the PR description with the current status? Thanks! |
Sorry just updated the description! The code in GltfLoader.js is ready for review and still working on more thorough unit tests. |
I updated the MeshPrimitiveRestart.gltf test data to include primitive groups for all the valid modes for the extension (line loop, line strip, triangle strip, triangle fan). Also added more unit tests to ensure
Nevermind, just noticed the cases are different in the error messages...
|
This is ready for full review. Anyone have an idea why the |
(Quick, while in another call:) Regarding the formatting: Indeed, something is strange here: #12801 (comment) The test that is failing now is related to some error message not matching the expected one, at https://github.com/CesiumGS/cesium/pull/12792/files#diff-8f11fb72d71b01b789e5660c80ad63658fa8768871b77786e95b636aa918c6c4R4277 . A bit more generally, I think that it's a bit dubious to check for the exact error message, even though this is done in many places. I think that this "overspecifies" the test. (I hope there are no plans on internationalization, FWIW...). One could try to "justify" that, but only with the severe lack of differentiation between types of errors: There should be far more than just However, the test here could just be changed to expect a type error, but ... of course, such an error should preferably not be thrown to the user either... |
Ok good to know it wasn't just me, I ended up just reverting the whitespace. Not sure how to fix the discrepancy it but it seems related to the
These considerations make sense, you're right that the lack of error types kind of leads to comparing the error messages like this. I tried to use a generic |
Tbh, after further thinking, the test that is failing is probably not necessary in the first place. Its purpose is to test that an error is thrown when a mesh primitive restart group's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGES.md
Outdated
- Expand the CustomShader Sample to support real-time modification of CustomShader. [#12702](https://github.com/CesiumGS/cesium/pull/12702) | ||
- Add wrapR property to Sampler and Texture3D, to support the newly added third dimension wrap.[#12701](https://github.com/CesiumGS/cesium/pull/12701) | ||
- Added the ability to load a specific changeset for iTwin Mesh Exports using `ITwinData.createTilesetFromIModelId` [#12778](https://github.com/CesiumGS/cesium/issues/12778) | ||
- Added support for the [EXT_mesh_primitive_restart](https://github.com/KhronosGroup/glTF/pull/2478) glTF extension. [#12764](https://github.com/CesiumGS/cesium/issues/12764) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once merged, this change will go into the next release, which will be on Sept 2 (typically it's on the 1st of each month, but Sept 1 is Labor Day in the US).
Please move this item to the H2 section above under a new "additions" subsection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I somehow missed the latest release header
* @returns {object[]} An array of mesh primitives | ||
* @private | ||
*/ | ||
function getMeshPrimitives(mesh) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is already pretty brutal in terms of length and separation of concerns. What do you think of moving this function to it's own file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, moved to a new file.
Co-authored-by: Gabby Getz <[email protected]>
Co-authored-by: Gabby Getz <[email protected]>
Co-authored-by: Gabby Getz <[email protected]>
@pmconne Not required, but checking to see if you intended to review this |
Looks great! Thanks @eringram! |
Description
This PR adds support for the EXT_mesh_primitive_restart glTF extension. It is based on the implementation in iTwin.js-- see
getMeshPrimitives
in GltfReader.ts."Primitive restart" refers to starting a new primitive of the same type as the current primitive when a specific index value is encountered (the maximum value for that index buffer type). It is useful for batching multiple primitives of the same type in a single draw call. See the README in this PR for more detailed explanation and a simple example.
Issue number and link
Addresses #12764
Testing plan
getMeshPrimitives
function reduces the length of the primitives array from 8 to 4 (effectively combining the 4 groups of 2 primitives each).(the 4 groups are two green triangles, two blue triangles, two green line strips, and two blue line loops)
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change