-
Notifications
You must be signed in to change notification settings - Fork 35
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
GLTF Loader #732
GLTF Loader #732
Conversation
Super valuable contribution, thanks! We now support gltf via trimesh. I presume you usef gltflib because the gltf support in trimesh is limited? Does this code-path support more of gltf or are there also things that trimesh supports, which are not yet in this code here? API-wise, I'm not a big fan of the capitalized
edit: that refactoring is perhaps a bit more than you originally planned, but we can add |
Yes, the trimesh library has very limited support for GLTF. The GLTF specification is essentially defined using JSON to describe the scene content, along with embedded or external resource files. GLB, on the other hand, is a format that packages the JSON definition and various resource files into a single file with a specific structure. The gltflib library is a basic reading and writing library for GLTF/GLB files, and it does not involve any detailed parsing. Through the gltflib library, we can conveniently and quickly access any content we want from the GLTF/GLB files.
Therefore, whether this code-path supports more GLTF features completely depends on how much we have implemented. |
I have designed the GLTF loader as a class rather than a function here because there are many intermediate states that need to be maintained during the loading and conversion process, and using a class can make it simpler and more clear. Perhaps I could make it an internal class object and then provide a unified function interface? |
Yes, I think the user-facing API is easier if its just a function (or two). Thanks! |
I believe that the current PR already covers all the functionality that using trimesh to load GLTF (with a bit more, such as the second set of texture coordinates). I will continue to expand its support for other aspects of GLTF (synchronizing with the capabilities of pygfx). However, it is only effective for the GLTF/GLB format, as trimesh also supports some other model file formats. Nevertheless, the GLTF format is relatively universal, and there are many third-party libraries and tools that support converting various model types to the GLTF format. By supporting GLTF well, we can effectively support the vast majority of model file formats. |
I have refactored the code. I think that the name What do you think? @almarklein |
Additionally, the behavior of To add a bit more context, when users use the Although we can convert the local matrix to the world matrix by reconstructing the node graph, and assigning this calculated world matrix to the local matrix of the Mesh (which is likely what the current trimesh implementation does). It can also lead to potential problems when the user tries to compose these separately loaded Meshes into a node graph (through operations like |
I specifically want to load |
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.
So IIUC the difference of load_mesh_gltf()
compared to load_mesh()
is that it also loads the transform?
The docs build is failing, but I don't think its related to this pr: WARNING: cannot cache unpickable configuration value: 'sphinx_gallery_conf'
The new |
Are there any other review comments on this PR? I need this PR to be merged in order to proceed with #715. 😄 |
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.
Let's go ahead and merge.
I do want to express my concern with regards to the public API: there are now four or five different load functions and you can pass a .gltf file to all of them I think. It's definitely confusing for users who are exploring the API and figuring out which one to use.
I'm thinking we can do better. I like Almar's earlier suggestion to rename the trimesh based load functions. We can also consider having a single load function with a backend keyword argument to select between trimesh and gltflib.
The main issue is that the current behavior and return values of the Additionally, I think the current |
GLTF file loader for
pygfx
, completely based on the GLTF 2.0 specification.This PR has been separated out from #715 . It is the prerequisite for completing #715 .
It implements the basic parsing logic for the GLTF file data (base on gltflib), and has also completed the loading of Mesh (including Geometry and Material).
I hope that it will ultimately be fully support the GLTF 2.0 specification, and can also be used as a reference for the design of the capability API for the future development of
pygfx
.