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

Can GLTF model structure be customized with additional properties? #2334

Closed
nRammm opened this issue Oct 10, 2023 · 3 comments
Closed

Can GLTF model structure be customized with additional properties? #2334

nRammm opened this issue Oct 10, 2023 · 3 comments

Comments

@nRammm
Copy link

nRammm commented Oct 10, 2023

Hi ,I'm a beginner for GLTF.
I'm basically trying to use GLTF models as input for Azure Remote Rendering.

I have a custom formatted model which has certain model properties associated with it. For example let the custom model be a building and it has various properties like Length/Area/Volume/Mass/Angle of a pillar or any other objects in the model. Is there a way to include these properties in GLTF json structure? If yes , will that be a valid GLTF file?
Also does GLTF maintains any unique id for each objects in the model? If no , can that be customized as well?

@javagl
Copy link
Contributor

javagl commented Oct 10, 2023

It is technically possible to just add anything to a glTF JSON file, and it will not affect the validity (as long as it does not interfere with the existing properties, of course). But this is

not recommended!!!

No application will know how to produce or consume these properties, and any application that reads and then writes the glTF asset will likely throw away this data.


A slightly more portable way is to use the extras property that is basically defined for every glTF property. So you could have something like

  "nodes" : [
    {
      "mesh" : 0,
      "extras": {
          "myCustomData": { 
              "mySpecificValue": 12345
          }
      }
    }
  ],

to store your myCustomData object with its mySpecificValue. But this is still only application-specific. You'd still have to expect third-party applications to ignore or remove this data.


The most portable way is to use an extension to store this data. There are different extensions to store various forms of metadata, for example, KHR_xmp_json_ld, but the details will heavily depend on the application case.


Also does GLTF maintains any unique id for each objects in the model? If no , can that be customized as well?

glTF does not maintain unique IDs. There recently has been a discussion about that, at #1051 (comment) .

@javagl
Copy link
Contributor

javagl commented Oct 11, 2023

The forum is probably a better place to discuss this.

@javagl javagl closed this as completed Oct 11, 2023
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