feat: compose interactive world ui across nested 3d viewports
This commit is contained in:
+15
-2
@@ -259,7 +259,12 @@ pub fn occurrence_constraints(
|
||||
child: &UiNode,
|
||||
mut base: [f32; 4],
|
||||
offer: Size,
|
||||
child_index: usize,
|
||||
) -> [f32; 4] {
|
||||
if let UiKind::Viewport3D { panels, .. } = &parent.kind {
|
||||
let size = panels[child_index];
|
||||
return [size.width, size.height, size.width, size.height];
|
||||
}
|
||||
let inset = insets(parent);
|
||||
for (axis, dimension, available, padding) in [
|
||||
(0, child.sizing.width, offer.width, inset.horizontal()),
|
||||
@@ -280,6 +285,7 @@ pub fn initial_child_constraints(
|
||||
parent: &UiNode,
|
||||
child: &UiNode,
|
||||
constraints: [f32; 4],
|
||||
child_index: usize,
|
||||
) -> [f32; 4] {
|
||||
let offer = parent.sizing.available(constraints);
|
||||
occurrence_constraints(
|
||||
@@ -290,6 +296,7 @@ pub fn initial_child_constraints(
|
||||
width: offer[2],
|
||||
height: offer[3],
|
||||
},
|
||||
child_index,
|
||||
)
|
||||
}
|
||||
/// Scroll cross-axis constraints come from this occurrence's actual viewport,
|
||||
@@ -752,6 +759,9 @@ pub fn arrange_native(
|
||||
bounds: Size,
|
||||
children: &[Size],
|
||||
) -> Result<Vec<(f32, f32)>> {
|
||||
if matches!(node.kind, UiKind::Viewport3D { .. }) {
|
||||
return Ok(node.children().iter().map(|_| (0., 0.)).collect());
|
||||
}
|
||||
if let UiKind::Overlay { .. } = node.kind {
|
||||
let padding = insets(node);
|
||||
let horizontal = match node.main_align {
|
||||
@@ -977,12 +987,14 @@ impl LayoutRuntime {
|
||||
id,
|
||||
constraints,
|
||||
});
|
||||
for (child, slot) in node.children().iter().zip(&node.slots).rev() {
|
||||
for (child_index, (child, slot)) in
|
||||
node.children().iter().zip(&node.slots).enumerate().rev()
|
||||
{
|
||||
work.push((
|
||||
child.as_ref(),
|
||||
Some(index),
|
||||
*slot,
|
||||
initial_child_constraints(node, child, constraints),
|
||||
initial_child_constraints(node, child, constraints, child_index),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1017,6 +1029,7 @@ impl LayoutRuntime {
|
||||
coordinate(x + size.width)?;
|
||||
coordinate(y + size.height)?;
|
||||
mounts.push(MountGeometry {
|
||||
panel: None,
|
||||
canvas_viewport: matches!(item.node.kind, UiKind::CanvasViewport { .. }),
|
||||
scene3d_viewport: matches!(item.node.kind, UiKind::Viewport3D { .. }),
|
||||
camera_controls: matches!(
|
||||
|
||||
Reference in New Issue
Block a user