Skip to content

Support multiple different AssetLoaders with the same extension #367

@skairunner

Description

@skairunner

Currently, the AssetServer stores its references to handlers as a dictionary of string to box. But the file extension to asset type relationship is not one-to-one -- with GLTF, the file can contain anything from Meshes and Materials to Textures to Skins (aka bones).

In a language with reflection, it would be possible to select handlers depending on the type. While Rust doesn't have true reflection, it does have TypeId which would allow us to match on both AssetLoader type and file extension. This might be a good solution that would also let us preserve the existing API. This could also solve the TODO in the asset server file that mentions that load() needs to be strongly typed.

Another solution that is slightly less ergonomic is to create a load_a method that takes a String specifying the type of the asset we want to load as well as the path.

If we can determine a good path to take, I may be able to implement it, since I am working on something that directly requires this support. (No extra credit for guessing that it's GLTF :D )

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-FeatureA new feature, making something new possible

    Type

    No type

    Projects

    Status

    Wishlist

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions