feat: compose interactive world ui across nested 3d viewports
This commit is contained in:
+30
-17
@@ -128,7 +128,7 @@ impl RenderCache {
|
||||
}
|
||||
store.check_typed_instance_storage(block)?;
|
||||
let (data_ref, raw_data, raw_dependencies) = block::resolve_tracked(store, block)?;
|
||||
let data = block::visual_data(store, raw_data)?;
|
||||
let mut data = block::visual_data(store, raw_data)?;
|
||||
let mut dependencies: Vec<_> = raw_dependencies
|
||||
.into_iter()
|
||||
.map(|object| Dependency {
|
||||
@@ -164,6 +164,33 @@ impl RenderCache {
|
||||
});
|
||||
}
|
||||
}
|
||||
let mut panel_sizes = Vec::new();
|
||||
let view3d = if matches!(data.kind, Kind::Viewport3D { .. }) {
|
||||
let (view, reads, panels) = crate::scene3d_model::snapshot(
|
||||
store,
|
||||
data.scene3d
|
||||
.ok_or(VmError::InvalidArgument("missing Scene3D"))?,
|
||||
data.camera
|
||||
.ok_or(VmError::InvalidArgument("missing 3D camera"))?,
|
||||
)?;
|
||||
dependencies.extend(reads.into_iter().map(|(object, name)| Dependency {
|
||||
object,
|
||||
property: Some(name),
|
||||
}));
|
||||
data.children = panels
|
||||
.into_iter()
|
||||
.map(|panel| {
|
||||
panel_sizes.push(panel.size);
|
||||
crate::block::Child {
|
||||
slot: panel.key,
|
||||
block: panel.content,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Some(view)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if !finish {
|
||||
if !path.insert(data_ref) {
|
||||
return Err(VmError::InvalidArgument("cyclic Block composition"));
|
||||
@@ -175,22 +202,6 @@ impl RenderCache {
|
||||
continue;
|
||||
}
|
||||
path.remove(&data_ref);
|
||||
let view3d = if matches!(data.kind, Kind::Viewport3D { .. }) {
|
||||
let (view, reads) = crate::scene3d_model::snapshot(
|
||||
store,
|
||||
data.scene3d
|
||||
.ok_or(VmError::InvalidArgument("missing Scene3D"))?,
|
||||
data.camera
|
||||
.ok_or(VmError::InvalidArgument("missing 3D camera"))?,
|
||||
)?;
|
||||
dependencies.extend(reads.into_iter().map(|(object, name)| Dependency {
|
||||
object,
|
||||
property: Some(name),
|
||||
}));
|
||||
Some(view)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut protocol_key = String::new();
|
||||
let mut custom_event = false;
|
||||
if let Some(definition) = store.type_of(block)? {
|
||||
@@ -290,6 +301,8 @@ impl RenderCache {
|
||||
height: *height,
|
||||
view: view3d.ok_or(VmError::InvalidArgument("missing 3D view"))?,
|
||||
controls: data.controller.is_some(),
|
||||
panels: panel_sizes,
|
||||
children,
|
||||
},
|
||||
Kind::CanvasViewport { width, height } => UiKind::CanvasViewport {
|
||||
width: *width,
|
||||
|
||||
Reference in New Issue
Block a user