feat: separate 2d scenes viewports and explicit cameras

This commit is contained in:
2026-11-10 22:42:56 +08:00
parent 32d7ada3ab
commit 040b779f5f
29 changed files with 1309 additions and 70 deletions
+29
View File
@@ -154,6 +154,14 @@ impl RenderCache {
});
}
}
if let Some(camera) = data.camera {
for name in ["x", "y", "zoom"] {
dependencies.push(Dependency {
object: camera,
property: Some(name.into()),
});
}
}
if !finish {
if !path.insert(data_ref) {
return Err(VmError::InvalidArgument("cyclic Block composition"));
@@ -259,6 +267,27 @@ impl RenderCache {
children,
},
Kind::Spacer(size) => UiKind::Spacer(*size),
Kind::CanvasViewport { width, height } => UiKind::CanvasViewport {
width: *width,
height: *height,
camera: crate::viewport::camera(
store,
data.camera
.ok_or(VmError::InvalidArgument("missing camera"))?,
)?,
children,
},
Kind::Scene2D => UiKind::Scene2D {
positions: data
.children
.iter()
.map(|child| {
let (_, child) = block::resolve(store, child.block)?;
Ok(block::visual_data(store, child)?.position)
})
.collect::<Result<Vec<_>, VmError>>()?,
children,
},
Kind::Overlay => UiKind::Overlay {
padding: data.padding,
children,