Skip to content

Lazy Loading with Hooks and Custom Material support#35

Open
g4borg wants to merge 2 commits into
FraserLee:mainfrom
g4borg:main
Open

Lazy Loading with Hooks and Custom Material support#35
g4borg wants to merge 2 commits into
FraserLee:mainfrom
g4borg:main

Conversation

@g4borg
Copy link
Copy Markdown

@g4borg g4borg commented Sep 1, 2025

I was inspired by @vertesians pull request to fork Sprite3d and implement on top of it the same kind of lazy loading with hooks.

Additionally, I wanted to have the support to supply custom materials, or just set the color of a 3d Sprite as well quickly, so I added a more hybrid approach to the material handling: one can either provide a full Material in the bundle to finetune all sorts of settings, or just set Sprite.color.

I also expanded the caching with the color.

Now I am sorry, but before I even realized, I had code formatted the files I touched, and I have yet to come back to it and clean up a few repetititions. If this is really a problem, I can try to manually format it back before rustfmt kicked in.

I am perfectly aware, that his pull request might be a bit big, and not accepted, but as the other one inspired me to do this, maybe it can also inspire yet another take until such features come into the official crate.

I personally just needed these features already :)

Added three features on top of upstream bevy_sprite3d v8.0:

1. Async Asset Loading
   - Sprites no longer panic when assets aren't loaded
   - Uses WaitingSprites resource and IoTaskPool for deferred construction
   - Graceful error handling with warnings instead of panics

2. User-Provided Material Support
   - Detects when user provides MeshMaterial3d before Sprite3d
   - Preserves user material settings, only overrides texture fields
   - New Sprite3dUserMaterial marker component

3. Sprite.color Tinting Support
   - Sprite.color now applies as base_color tint on cached materials
   - Added base_color to MatKey for proper caching

Also adds bevy_log feature for warning messages.
These files document the fork-specific features and can be excluded
from PRs to the upstream repository.
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

Successfully merging this pull request may close these issues.

1 participant