`ExtractComponent` creates required components on extract
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
# Problem:
Components that have both #[derive(ExtractComponent)] and #[require] attributes create their required components when extracting into the render world, which is probably not what the user intended and can lead to surprising results.
@robtfm identified the following cases:
- Camera2d - has ExtractComponent and requires Camera (+ other components)
- Camera3d - has ExtractComponent and requires Camera (+ other components)
- ClusteredDecal - has ExtractComponent and requires Transform, Visibility, VisibilityClass
- ScreenSpaceAmbientOcclusion - has ExtractComponent and requires DepthPrepass, NormalPrepass
- FogVolume - has ExtractComponent and requires Transform, Visibility
- AmbientLight has #[require(Camera)] which doesn't make semantic sense (AmbientLight is not IsA Camera)
- MaterialNode is being extracted but probably shouldn't be
# Solution
1. Add compile-time error when a component has both ExtractComponent and #[require] attributes
2. Newtype the affected components for extraction to avoid the require behavior
3. Remove #[require(Camera)] from AmbientLight
4. Remove extraction from MaterialNode if not needed
Contributor guide
Assessment
This issue has not been assessed yet.