@@ -3,13 +3,13 @@ title: "Reflective Floor: Stencil‑Masked Planar Reflections"
33document_id : " reflective-room-tutorial-2025-11-17"
44status : " draft"
55created : " 2025-11-17T00:00:00Z"
6- last_updated : " 2026-01-07T00 :00:00Z"
7- version : " 0.4.1 "
6+ last_updated : " 2026-01-16T00 :00:00Z"
7+ version : " 0.4.3 "
88engine_workspace_version : " 2023.1.30"
99wgpu_version : " 28.0.0"
1010shader_backend_default : " naga"
1111winit_version : " 0.29.10"
12- repo_commit : " 183a0499250a2c16e0a09b22107201720016fc48 "
12+ repo_commit : " 87aa423aca541823f271101e5bac390f5ca54c42 "
1313owners : ["lambda-sh"]
1414reviewers : ["engine", "rendering"]
1515tags : ["tutorial", "graphics", "stencil", "depth", "msaa", "mirror", "3d", "immediates", "wgpu", "rust"]
@@ -434,6 +434,56 @@ Support runtime toggles to observe the impact of each setting:
434434
435435Reference: ` crates/lambda-rs/examples/reflective_room.rs:164 ` .
436436
437+ Implement resize and toggles using ` event_mask() ` and ` on_*_event ` handlers.
438+
439+ ``` rust
440+ use lambda :: events :: {EventMask , Key , VirtualKey , WindowEvent };
441+
442+ // Inside `impl Component<ComponentResult, String> for ReflectiveRoomExample`.
443+ fn event_mask (& self ) -> EventMask {
444+ return EventMask :: WINDOW | EventMask :: KEYBOARD ;
445+ }
446+
447+ fn on_window_event (& mut self , event : & WindowEvent ) -> Result <(), String > {
448+ if let WindowEvent :: Resize { width , height } = event {
449+ self . width = * width ;
450+ self . height = * height ;
451+ }
452+ return Ok (());
453+ }
454+
455+ fn on_keyboard_event (& mut self , event : & Key ) -> Result <(), String > {
456+ match event {
457+ Key :: Pressed {
458+ scan_code : _ ,
459+ virtual_key : Some (VirtualKey :: KeyM ),
460+ } => {
461+ self . msaa_samples = if self . msaa_samples > 1 { 1 } else { 4 };
462+ self . needs_rebuild = true ;
463+ }
464+ Key :: Pressed {
465+ scan_code : _ ,
466+ virtual_key : Some (VirtualKey :: KeyS ),
467+ } => {
468+ self . stencil_enabled = ! self . stencil_enabled;
469+ self . needs_rebuild = true ;
470+ }
471+ Key :: Pressed {
472+ scan_code : _ ,
473+ virtual_key : Some (VirtualKey :: KeyD ),
474+ } => {
475+ self . depth_test_enabled = ! self . depth_test_enabled;
476+ self . needs_rebuild = true ;
477+ }
478+ _ => {}
479+ }
480+ return Ok (());
481+ }
482+ ```
483+
484+ When a toggle flips, set ` needs_rebuild = true ` so pipelines and passes are
485+ rebuilt on the next frame with the updated MSAA/depth/stencil settings.
486+
437487## Validation <a name =" validation " ></a >
438488
439489- Build and run: ` cargo run --example reflective_room ` .
@@ -477,6 +527,8 @@ The reflective floor combines a simple stencil mask with an optional depth test
477527
478528## Changelog <a name =" changelog " ></a >
479529
530+ - 2026-01-16, 0.4.3: Normalize event handler terminology.
531+ - 2026-01-16, 0.4.2: Add ` event_mask() ` and ` on_*_event ` handler examples.
480532- 2026-01-07, 0.4.1: Remove stage usage from immediates API examples.
481533- 2026-01-05, 0.4.0: Update for wgpu v28; rename push constants to immediates; update struct references to ` ImmediateData ` .
482534- 2025-12-15, 0.3.0: Update builder API calls to use ` ctx.gpu() ` and add ` surface_format ` /` depth_format ` parameters to ` RenderPassBuilder ` and ` RenderPipelineBuilder ` .
0 commit comments