-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
WriteBinary doesn't keep the order of textures #842
Comments
Hi @gz65555 — this is by design. glTF Transform combines the glTF concepts of "images" and "textures" with its internal representation to make editing simpler, and therefore only the order of images, not textures can be preserved. I'd recommend using something other than indices (names, extras, or URI?) to identify textures if you can. If you're building custom extensions, you will need to register those extensions in glTF Transform to preserve references to textures. I think the specific use case you're mentioning here — converting from glTF to GLB — could also be solved by packing the data without going through the internal glTF Transform representation. Support for that is discussed in #746. |
Thank you for your answer, the material I created myself needs to reference the texture in glTF. In the texture information, name/extras are not reliable, and the material of glTF itself also uses indices as identity. Also, glTF is designed to separate images and textures. I think this is a design issue, can I submit a pull request to fix it? |
Sorry, but I don't know of any solution preserving texture indices that I could accept as a PR. glTF Transform needs to know about references to objects like textures. It converts indices to references when loading, so it can track them. Without knowing where a texture is used, for example, it can't determine the right compression settings when using the KTX2 compression. I understand you're only trying to pack a glTF file into a GLB file here, which is much simpler than the broader goals of this library, but I think the changes you describe are going to create larger problems for the project. For full use of the glTF Transform library it is necessary to provide an implementation if your custom material extension, as shown here: https://gltf-transform.donmccurdy.com/extensions.html#custom-extensions. I would be open to creating a glTF-Transform/packages/core/src/io/platform-io.ts Lines 153 to 171 in a09aa71
|
Yes, adding an I use gltf-transform not only to convert glTF to glb, I also use quantize, mesh-opt and other functions. glTF-transform is a very nice tool for dealing with glTF. I have used a custom extension to customize the material replacement, but it didn't solve the problem. Let me figure out how to get around this problem. Thanks anyway. |
A custom extension will keep the material attached to the correct textures, even when the texture indices change. The material will be updated at export with the correct texture index. If you want to check the draft implementation of KHR_materials_anisotropy you can see how that generally works, and how to add your own extension. |
Merging into #746. |
Describe the bug
I use glTF-Transform to transform a glTF file to glb format, but the order of the textures of glb is not consistent with the original glTF.
To Reproduce
This is an original glTF
helmet.gltf.zip
The field of
textures
is:The code of transform is:
The result I parsed is:
![image](https://user-images.githubusercontent.com/6926263/223161144-4debc85b-fa7f-4b6b-80ab-429798671318.png)
And the result file is:
helmet.glb.zip
Expected behavior
The order of the glb texture field should be the same as the source glTF.
Versions:
The text was updated successfully, but these errors were encountered: