Skip to content
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

Get the json from the gltf #743

Open
MarcusGT076 opened this issue Jun 24, 2024 · 7 comments
Open

Get the json from the gltf #743

MarcusGT076 opened this issue Jun 24, 2024 · 7 comments
Assignees

Comments

@MarcusGT076
Copy link

Hello there,

i want to access the complete json from the gltf file. I tried to get the root, but he is not displaying the whole json from the gltf file ?
This is what i see when i access the root of the GLTFSsceneImporter.

{
"ExtensionsUsed": [
"KHR_draco_mesh_compression",
"KHR_materials_emissive_strength"
],
"ExtensionsRequired": [
"KHR_draco_mesh_compression"
],
"IsGLB": false
}

I want to send the whole structure of the gltf to javascript as a json with all inside.
How is this possible to get those data that i need ?

Cheers :)

@hybridherbst hybridherbst self-assigned this Jul 2, 2024
@pfcDorn
Copy link
Contributor

pfcDorn commented Jul 10, 2024

hey, when the file is a gltf (not glb), then you can just send the whole gltf file. It's all json. Or do i miss here something?

@MarcusGT076
Copy link
Author

hey, but in the loading process from youre plugin you dispose the complete result from the json ?
I have a workaround to load the json file second time and send it to javascript. But than i have to load it twice. First to send the json to javascript and second time with youre plugin. So it would be cool maybe that you have a flag that you can set that a copy from the json will be kept ?

@pfcDorn
Copy link
Contributor

pfcDorn commented Jul 11, 2024

Are you downloading the glb?

@MarcusGT076
Copy link
Author

Nope i load it with a gltf. I mean i can access the root from the plugin but all i get in return its from the first article. I did not get back the whole gltf json.
So i mean the workaround its functioning but i have to load the GLTF Json twice. First for myself to send it to Javascript and than over your plugin with LoadScene.

@pfcDorn
Copy link
Contributor

pfcDorn commented Jul 12, 2024

I don't think it would make sense to expose the loaded json string. When you need them, just load the json string with File.ReadAllText(gtlfFilePath). To read the file twice should not be a problem in any case. You just read the string without any deserialisation and send it to the javascript.

@hybridherbst
Copy link
Collaborator

@MarcusGT076 can you say a bit more what your goal is? Do you just want to display the JSON data somewhere else, both for files loaded as glTF and as glb?

You get the parsed JSON object (gltfroot) in an importer plugin and can do with it what you want. This is a JObject that is serializable back to readable JSON if that’s your goal.

@MarcusGT076
Copy link
Author

MarcusGT076 commented Jul 12, 2024

Yes in this case its not a problem to load it twice i already did that. My goal is : i create a hierarchy list in javascript on an html site that take the data with all its children and submeshes. So it was only a thought when the loader get the file to access it and send it to javascript that i dont have to load it second time, because its already there in youre loader. I mean in gltfast i could access the root after loading and it showed the gltf file in its original form. With your loader i can access also the root but it has not all the data as the original gltf. I am sending the gltf as a string through unity to javascript and parse it there back to an json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants