feat: compose interactive world ui across nested 3d viewports

This commit is contained in:
2026-11-11 00:08:23 +08:00
parent ad2c01bc29
commit 15fc01542c
27 changed files with 1412 additions and 84 deletions
+16 -2
View File
@@ -76,7 +76,12 @@ pub fn project(vm: &mut Vm, table: &MountTable, root: &UiNode, frame: &mut Frame
.mounts
.iter()
.map(|m| {
let inset = layout::insets(nodes[m.block_id.as_str()]);
let node = nodes[m.block_id.as_str()];
let inset = if matches!(node.kind, UiKind::Scroll { .. }) {
layout::insets(node)
} else {
layout::Insets::default()
};
(m.x + m.width - inset.right, m.y + m.height - inset.bottom)
})
.collect();
@@ -84,6 +89,12 @@ pub fn project(vm: &mut Vm, table: &MountTable, root: &UiNode, frame: &mut Frame
let m = &frame.mounts[i];
if let Some(parent) = m.parent {
let parent = indices[&parent];
if matches!(
nodes[frame.mounts[parent].block_id.as_str()].kind,
UiKind::CanvasViewport { .. } | UiKind::Viewport3D { .. }
) {
continue;
}
let e = if scrolling[i] {
(m.x + m.width, m.y + m.height)
} else {
@@ -166,6 +177,9 @@ pub fn project(vm: &mut Vm, table: &MountTable, root: &UiNode, frame: &mut Frame
),
);
}
if matches!(node.kind, UiKind::Viewport3D { .. }) {
child = (0., 0., None);
}
contexts.insert(m.id, child);
for command in layout::paint_commands(
nodes[m.block_id.as_str()],
@@ -259,7 +273,7 @@ pub fn into_view(
};
let mount = cx.store().payload::<Mount>(owner, "Mount")?.clone();
parent = mount.parent;
if mount.geometry.canvas_viewport {
if mount.geometry.canvas_viewport || mount.geometry.scene3d_viewport {
rect = [
mount.geometry.x,
mount.geometry.y,