refactor(resources): Scene owns pipeline cache, Mesh->Material link

Étape 7 (DRAFT): the PipelineCache moves into the Scene (SceneGpu holds
device + format + cache, wired via Scene::init_gpu in AppRunner::resumed),
so App no longer owns a cache field. Mesh now holds Option<Arc<Material>>
(with material()/set_material()/with_material()); Entity drops material_id
({mesh_id, transform}); iter_entities yields (label, &Mesh, &Transform);
Renderer::render_scene resolves the material from the mesh or the Scene's
lazy default_material(). New declarative Scene helpers: register_shader,
add_material_shader, create_mesh. cube/simple examples migrated; manual
remains low-level and unchanged.
This commit is contained in:
Jérôme Bousquié
2026-09-17 13:15:30 +02:00
parent df546a4ac9
commit 62b5cac11b
7 changed files with 261 additions and 113 deletions
+8 -2
View File
@@ -248,12 +248,18 @@ impl Renderer {
..Default::default()
});
for (label, mesh, material, transform) in scene.iter_entities() {
// Étape 7 (DRAFT 7.3.4) : the Material is resolved from the Mesh itself, falling back
// to the Scene's default material when the mesh carries none.
for (label, mesh, transform) in scene.iter_entities() {
let material = mesh
.material()
.cloned()
.unwrap_or_else(|| scene.default_material());
let object_bind_group = self.object_bind_group_for(label, transform);
draw_entity(
&mut render_pass,
mesh,
material,
&material,
&self.frame_bind_group,
&object_bind_group,
);