Repository navigation
feat(id-native-shell): Bevy scene renderer for scene/1 surfaces (#12657 step 2a) - #13214
Conversation
… step 2a) Step 2a of the rich-presentation follow-on: the native shell gains a real 3D renderer for validated scene/1 surfaces, beside the text grid. - scene::SceneModel: pure render model — node shape, position and size carried through from the host-validated contract types; colors derived deterministically (hue family per shape, lightness stepped by the node id's FNV-1a hash); camera framing computed from the scene's bounds. - scene::SceneRenderPlugin: one mesh entity per node with bevy_pbr standard materials, camera reframed per view; a non-scene view (or no view) clears the scene entities. Shells without the plugin keep presenting the scene's text projection — a parity test pins that fallback. - scene::example_scene: the deterministic example world's Harbor scene, exercising all four shapes in the closed set. - bevy gains the bevy_pbr feature on the existing step-2 render wiring (no new system libraries). Verification: cargo nextest run -p id-native-shell — 81/81 pass (8 new scene tests); cargo fmt clean; clippy clean in the new module. The full clippy-native-shell gate is currently red on main for an unrelated id-store reason (filed as #13207).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bbb7f479d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Self { | ||
| title: scene.title.clone(), | ||
| nodes, | ||
| camera_position: centroid + direction * (radius * 2.5), |
There was a problem hiding this comment.
Frame scene bounds using the viewport's aspect ratio
In sufficiently narrow portrait windows, valid scenes with horizontally separated nodes are clipped because the fixed radius * 2.5 camera distance never accounts for the viewport's narrower horizontal field of view. rebuild_scene only updates the camera transform, so resizing the window cannot correct the framing either. Derive the distance from the actual projection and viewport, and update it on resize. The existing camera test merely repeats the distance formula; a projection/frustum containment oracle across viewport ratios would catch this regression.
AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.
| fn spawn_stage(mut commands: Commands<'_, '_>) { | ||
| commands.spawn(( | ||
| SceneCamera, | ||
| bevy::prelude::Camera3d::default(), |
There was a problem hiding this comment.
Enable tonemapping LUTs or select a LUT-free tonemapper
In the shipped binary, Bevy's Core3d plugin automatically adds the default TonyMcMapface tonemapper to this camera, but the crate disables default features and never enables tonemapping_luts. Bevy 0.19.1 substitutes a single magenta texel for the missing LUT, so scene meshes render magenta instead of retaining their derived colors and lighting differences. Enable the feature or explicitly attach a LUT-free tonemapper such as Tonemapping::Reinhard. The headless tests do not exercise this rendering path. See Bevy's camera registration and tonemapping implementation.
Useful? React with 👍 / 👎.
| let sequence = presented.0.as_ref().map(|view| view.sequence); | ||
| if sequence == *last_sequence { | ||
| return; |
There was a problem hiding this comment.
Rebuild scenes when views change without advancing the world sequence
For worlds whose scenes change on host events such as time.tick or presence updates, this guard discards subsequent presentations because those events do not advance the durable world sequence. world/handle.rs:563-564 explicitly documents that behavior, and world_session/mod.rs:1422-1426 schedules fresh views from those notifications using the unchanged sequence. Consequently, animated scenes freeze after their first frame until a durable participant event occurs; a host-driven transition away from a scene also leaves its old entities visible. Track changes to the presented view or preserve and compare the host's view_revision instead of using only sequence.
Useful? React with 👍 / 👎.
Step 2a of #12657 (rich presentation surfaces): the Bevy scene renderer for the native shell. Step 1 of the contract is complete (scene 1a, audio 1b, widget 1c); this is the first of the three step-2 renderers. #12657 stays open on 2b (audio) and 2c (widget).
What lands
scene::SceneModel— the pure render model, mirroringrender::ScreenGrid's separation: a host-validatedSceneSurfacebecomes node models (shape, position, size carried through) plus the renderer's derived visuals, all in one testable place. The contract carries no visual fields beyond shape/position/size, so the derivation is defined here: a fixed hue family per shape, lightness stepped deterministically by the node id's FNV-1a hash, and a camera framing computed from the scene's bounds (centroid target, bounding-sphere standoff along a fixed direction).scene::SceneRenderPlugin— reads the existingPresentedViewresource (world input stays on the same contract frames; no new frame kinds): on each view-sequence change it despawns the old scene's nodes, reframes the camera, and spawns one entity per node —Mesh3d(cuboid / unit sphere scaled to extents / ground plane),MeshMaterial3d<StandardMaterial>in the derived color,Transformat the contract position. A non-scene view, or no view, clears the scene. The binary registers the plugin besideShellRenderPlugin.scene::example_scene— the deterministic example world for this surface: a small Harbor scene (water plane, dock box, buoy sphere, beacon point) exercising the whole closed shape set; the tests present exactly this document through the session-frame seam.bevy_pbrfeature (standard 3D materials) on the existing step-2 render wiring; no new system libraries (the crate compiles and tests in the stock pkgs/id dev shell).Shells without the scene plugin are unchanged:
ScreenGridstill presents a scene surface as its deterministic text projection, and a parity test in the new module pins that fallback.Verification
cargo nextest run -p id-native-shell— 81 passed / 0 failed (8 new scene tests: model determinism, document-order geometry, shape-keyed colors, camera framing, one-entity-per-node spawn, clear-on-non-scene-view, text-projection parity, scene-onlyfrom_view).cargo fmt -p id-native-shell— clean.cargo clippy -p id-native-shell --all-targets --no-deps— no findings in the new module.clippy-native-shellgate (with deps) is red on main for an unrelated reason —id-store/src/admission.rs(from PR feat(id-store): ordered lifecycle hooks around the fixed admission gate (#10192, slice 9110-06) #13156) trips the deniedexpect_usedlint at 9 sites. Filed separately as id-store: admission.rs expect() on Mutex locks breaks the clippy gates on main (PR #13156) #13207; this PR does not touch id-store.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.