You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
oddfacade opened this issue
Mar 28, 2022
· 1 comment
Labels
A-AssetsLoad files from disk to use for things like images, models, and soundsA-ScenesSerialized ECS data stored on the diskC-FeatureA new feature, making something new possible
What problem does this solve or what need does it fill?
When a scene is loaded from a file, any asset handle components attached to its entities are spawned as weak references. There is no mechanism to trigger asset loads from scene files or otherwise link handles with loaded assets. This inability to define entire scenes complete with meshes, materials, etc. is a significant roadblock to developing scene editors and other such external tooling.
What solution would you like?
I see two potential ways to do this.
The "proxy" approach: Define a new "proxy" handle type which contains an asset path and loads the corresponding asset when the DynamicScene is spawned, attaching the resulting Handle component in its place. This would probably necessitate a special case in DynamicScene::write_to_world that checks if each "component" (which now would not necessarily be a component) has a special "proxy component" data type registration thing.
The "link" approach: Upgrade weak handles to strong handles at scene spawn. In general principle, "change all components that implement a certain trait based on world data" is something that the entity mapping step is already doing, so we could borrow from that feature, either by implementing a parallel feature that works similarly but independently or by unifying the two features behind a more abstract "spawn hook" feature. The scene file format would probably have to be extended to provide a way to declare asset dependencies, since the handles don't provide a full path to load assets with.
What alternative(s) have you considered?
The GLTF loader already produces strong Handles for its meshes, materials, etc., so there are workarounds involving injecting components into the entities that it loads in. I think this is roughly what @nicopap 's bevy scene hook does. This approach could potentially be aided by defining some sort of structured metadata that we look for in the GLTF file's various "extras" fields (see gltf extras component #2153).
@sdfgeoff 's blender bevy toolkit does something sort of like (1) the "proxy" approach above, except the "proxies" are actually components that get loaded as normal, and are queried and resolved/replaced with a handles by special systems. The benefit of this approach is that it doesn't require modifying bevy's internals at all, but since the proxy "resolution" happens after the dynamic scene is spawned, it requires a system to be loaded at runtime for each type of asset.
It's worth mentioning this discussion: #3940 which means it is possible for a single asset to load/reference/link to other assets. However, as you say, the current scene format doesn't seem to support it in any way.
A-AssetsLoad files from disk to use for things like images, models, and soundsA-ScenesSerialized ECS data stored on the diskC-FeatureA new feature, making something new possible
What problem does this solve or what need does it fill?
When a scene is loaded from a file, any asset handle components attached to its entities are spawned as weak references. There is no mechanism to trigger asset loads from scene files or otherwise link handles with loaded assets. This inability to define entire scenes complete with meshes, materials, etc. is a significant roadblock to developing scene editors and other such external tooling.
What solution would you like?
I see two potential ways to do this.
DynamicScene
is spawned, attaching the resultingHandle
component in its place. This would probably necessitate a special case inDynamicScene::write_to_world
that checks if each "component" (which now would not necessarily be a component) has a special "proxy component" data type registration thing.What alternative(s) have you considered?
Handle
s for its meshes, materials, etc., so there are workarounds involving injecting components into the entities that it loads in. I think this is roughly what @nicopap 's bevy scene hook does. This approach could potentially be aided by defining some sort of structured metadata that we look for in the GLTF file's various "extras" fields (see gltf extras component #2153).Additional context
The text was updated successfully, but these errors were encountered: