-
Notifications
You must be signed in to change notification settings - Fork 251
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
Custom Properties - Deserialize extras property in node.extras #90
Comments
Hi @chrisssssy , Reasonable feature request! The glTF spec says, it recommends Not sure where to place it in the planning timeline though. I see other features (like stable KTX support or animation) more important. |
Hi @atteneder thank you for your quick reply. I managed to implement it for nodes.extras myself. But of course the extras property could be used in every other property as well, like mesh.extras or in the root itself. Also, like you mentioned, in order to deserialize it with JsonUtility, i had to encode my metadata in another json-string and put it in an string variable in the extras property. Later i can take the json and deserialize it to my own classes depending on the type. I'm sure there is a smarter solution, but for know this ist working for my use-case. If you are interested, i can share the code with you. |
Sure, create a PR! |
Hello @atteneder I would like to know if there's already a plan on when and how you are going to work on this feature, because I'm highly interested in implementing this in my project. @chrisssssy Would you mind if you shared your provisional implementation with me? 😄 |
Hi @kt-Andreas i could not figure out how to make a pull request, so i will upload the changes here. And for your information, i did these changes with a much older version of gltfast. I think it was version 2.0 or something, so the files changed quite a bit since then, so i am not shure if it will still work, but here is what i did (all changes are commented with // chrisssssy).
Now you can just create a unity script an listen to the GLTFast.ExtrasFound Event. edit: i added the pull request below |
Hello, First, thank you for developing this library. I expect this package to be officially supported by Unity soon. We are considering to use GLTF in our application. We are using CAD files and our idea is to use gltf as a visualization format. Thanks |
Thanks for reaching out @mespino-cityzenith ! So far I haven't gotten much requests for meta-data, thus it's not planned near-term. I've reviewd @chrisssssy 's work now and I think it needs adjustment. What does your metadata structure look like? Is it a simple string in |
The metadata is just a key/value list. It doesn't have any homogeneous schema because it could have any key-value pair What I'd do is to create a component with a key/value list and add this component to the child corresponding to the node, filled with the key-value list parsed from the gltf node public class Extras: MonoBehaviour
{
public string [] keys;
public string [] values;
} Anyway, if it is not in your roadmap, don't worry. Thank you for your help 👍 |
Thanks for sharing this insight. glTFast currently uses JsonUtility for JSON parsing, which makes it, well, fast. Unfortunately it's not very flexible, especially when it comes to parsing JSON structures unknown at build time (like yours). I totally want to enable uses cases like yours, but this needs a bit more research and refactoring first. This is related to #226 |
Minor update: I've made a proof-of-concept that parses meta data in the https://github.com/atteneder/glTFast/tree/demo-metadata The key is that it used Newtonsoft JSON for parsing instead. |
Hi! Just started to use gltFast plugin for Unity with the help of your example scripts . Importing .glb at runtime. How to import metadata with the file? c# novice. Thank you! |
Ok I figured it out! Found the greyed out code in your examples! 👍🏼 Thank you for this! Will this be implemented in official release any chance? |
I'm investigating all options at the moment and gather early feedback to make sure the best solution wins. |
Hi @atteneder Thanks |
@atteneder It seems that the metadata branch based on the version glTFast 4.8.5 doesn't work or I am doing something wrong? when loading the old one based on 4.8.3 it works again. Any ideas? 4.8.5 is much better for me in regards of materials. When loading the metadata package in unity it says version 5.0.0-exp.1? |
Keep in mind, it's WIP. But what does "does not work" mean? Yes, the |
Hi @atteneder, Can you help me to build the project I have downloaded form the https://github.com/atteneder/glTFast/tree/demo-metadata branch. I have no clue how to include this in mu existing unity project. Thanks |
Hello, the branch 404s for me. I would like to use extras (https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#reference-extras), and I thought this was supported but then I saw only the concept of MeshExtras is in the project. In our case, we need to assign specific unique ids to the nodes, so we are saving it as extras in the nodes |
Any updates on the metadata stuff? |
In version 6.0.0 we've added support for parsing the glTF's JSON part with Newtonsoft JSON as alternative. This allows users to access known extras properties (see example). In the last weeks I've experimented with more sophisticated meta-data import/export and came to the conclusion that a breaking-change refactor is likely required to pull it off. Hence a more improved access to meta data will be delayed. |
Hello @atteneder ,
it would be great to get notified whenever an gltf-file is loaded, which has an extras property in one of its node objects. Maybe fire an event when that happens and pass a reference to the corresponding unity gameobject/node and the extras data as json-string. Another way could be to create a monobehaviour and attach it to the gameobject and pass the json-string in there. After import i could find all gameobjects with the extras-property with GetComponents<>().
My usecase is to add a different monobehaviours to some of the gameobjects depending on the extras-properties. I attached a zip file with an gltf file from blender, where i added 2 custom properties which i'd like to access.
BlenderCube.zip
The text was updated successfully, but these errors were encountered: