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

gltf extras component #2153

Closed
wendivoid opened this issue May 12, 2021 · 4 comments
Closed

gltf extras component #2153

wendivoid opened this issue May 12, 2021 · 4 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible

Comments

@wendivoid
Copy link
Contributor

What problem does this solve or what need does it fill?

In my game i would like to store a few variables in the gltf "extras" field in blender and use them to set physics properties on the created entities.

What solution would you like?

Create a struct to store extras data, something like:

pub struct GltfExtras(pub serde_json::Map<String, serde_json::Value>)

and add it when creating entities in the gltf loader. I'm not sure as to what the best type to store the data would be,
according to the gltf spec they should be represented as an object whenever possible, so either a hashmap or something similar.

What alternative(s) have you considered?

I don't think there is another way to do this, but i would like suggestions if there are.

Additional context

@wendivoid wendivoid added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels May 12, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented May 12, 2021

An alternative would be to register extras with the gltf loadet such that every extra results in a typed component specific for such extra. This would be similar to app.register_type::<C>() that allows deserializing .ron scenes to concrete components.

@wendivoid
Copy link
Contributor Author

Yeah that would work.
Now that you mention it all of these types would have to have register_type<T>() called on them already in order
to be used with in a '$scene.ron' file correct?
In that case would it be possible for the gtlf loader and just load each extra against the types
registered with the scene type registry?

I'm very new to bevy so forgive me if that isn't phrased correctly

@mockersf
Copy link
Member

Could you share a GLTF file with those extra set?

@wendivoid
Copy link
Contributor Author

The One i'm working on is very large so i made a simple example file of a cube with 1 'String' property and 1 array property. (As well as one from blenderkit). I have no problem sharing the larger one if that helps it but only has a single property set on one of the mesh objects.

Github wouldn't let me upload a gltf file so here it is as txt.
custom_prop.txt

I'm not sure exactly what schema i would use for now i only want to create simple Colliders with rapier3d

@mockersf mockersf added A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels May 13, 2021
@bors bors bot closed this as completed in 8268e7f Apr 7, 2022
aevyrie pushed a commit to aevyrie/bevy that referenced this issue Jun 7, 2022
fixes bevyengine#2153 

expose the `extras` field value as a string
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
fixes bevyengine#2153 

expose the `extras` field value as a string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants