-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
GLTFExporter: Missing required padding on integer vertex attributes #27064
Conversation
@donmccurdy Is this required? |
I agree that something like this is probably needed. However, I'm not sure if the padding should be limited to cases where Right now I don't have time to investigate or test this, but if someone else can, please do! This is a case where I do wish we still had unit tests covering GLTFExporter, it would save a lot of time manually checking edge cases. |
Hi, thanks for making a PR! I don't think I have looked into the issue and the change in deep yet but let me share my some impressions for now.
It's a bit weird to me that Exporter has a side effect to Three.js objects. Ideally no side effect in Three.js objects, but adjusting the byte offset and stride only in exported glTF would be better. Also, wondering whether it's a good place to insert the code. The code is inserted at almost the end of As @donmccurdy 's comment,
I agree with it.
I feel the same. glTF loader and exporter are under addons but because of the standard 3D format they are ones of the most popular modules in Three.js and I have been wanting automatic/unit tests for them. If lack of resources for maintaining the tests for glTF stuffs in the official Three.js repo, I've been thinking of that we volunteers make an external Three.js glTF stuffs test repository, that has glTF loader/exporter unit/e2e tests, imports Three.js glTF loader/exporter, and run the tests. |
If I understand the issue correctly, glTF loader already attempts to keep byte offset on four-byte boundary but doesn't take care of byte stride (as described in #25309). Perhaps the lines we need to edit are here. I think we need to
|
@grzesiekmq Let me know if you are too busy now. I can take over because this issue really needs to be fixed. Even if I do I ask @Mugen87 to add your name to the release log because I want to respect your original work. |
@takahirox Feel free to take over and update this PR! 👍 |
OK. I would like to wait for @grzesiekmq 's response for a few days for now because I really don't want to steal or interrupt the contribution. And then I would try to update this PR if no response. |
Yes, please take it over, I don't have idea how to continue this |
OK, I will take it over. I'm working on the issue... |
I think this padding should be limited to cases where https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#buffers-and-buffer-views-overview
and https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#accessors-overview
|
@takahirox ah you're right, thank you! |
I have reflected this idea to this PR, and confirmed that the error is disappeared in this example. I didn't test many enough yet, but if you folks start to review, it's very helpful to me. |
I think ready for review @donmccurdy @Mugen87 Actually, I exported scene1 from https://threejs.org/examples/#misc_exporter_gltf and loaded in https://gltf-viewer.donmccurdy.com/ . These validation errors are disappeared with the change. |
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.
Thank you!
Fixed #25309
Description
Problem was with missing padding on integer vertex attributes.
Problem solved by padding with additional two 0's to 6 bytes filled
Uint8Array
, to make it 8 bytes, soresult is
Uint8Array([0, 0, 1, 0, 0, 1, 0, 0])
like on screenshot below:
But note issue with required stride is not still solved