Refactor to make MaterialKey enum.#70
Merged
catilac merged 2 commits intoprocessing:mainfrom Feb 12, 2026
Merged
Conversation
catilac
approved these changes
Feb 12, 2026
Contributor
catilac
left a comment
There was a problem hiding this comment.
Looks good! Noting the pattern using TypeErasure.
I left one question
Comment on lines
+58
to
+65
| pub(crate) fn add_standard_materials( | ||
| mut commands: Commands, | ||
| meshes: Query<(Entity, &UntypedMaterial)>, | ||
| ) { | ||
| for (entity, handle) in meshes.iter() { | ||
| let handle = handle.deref().clone(); | ||
| if let Ok(handle) = handle.try_typed::<StandardMaterial>() { | ||
| commands.entity(entity).insert(MeshMaterial3d(handle)); |
Contributor
There was a problem hiding this comment.
When we want to support MeshMaterial2d, how would this look? For now we don't need to worry because we're focused on 3D
Member
Author
There was a problem hiding this comment.
Right now we just implement 2d via 3d, but this would allow us to switch to that later if we wanted, or vector graphics, or whatever.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
MaterialKeyto support batching for things beyondStandardMaterial.We are still implementing theColorMaterialvariant withStandardMaterial, but could choose to do so differently later.Instead of spawning with a hard-coded
MeshMaterial3d, we instead spawn anUntypedHandleand then downcast and attach the concrete material handle to the entity in a later system. This is the pattern we'll also use for custom user materials later. In other words, the core flush system now is type erased over the actual type of material.This is mostly framing for follow up PRs.