M7.2: 3D viewer — 3D views, camera tools, camera/light wireframes, Camera/Light Settings dialogs
- Viewer renders through the comp's 3D view (RenderOpts.view; FrameKey hashes the view camera), shows the view name, and the bottom-bar 3D View dropdown (automation id viewer.view3d) switches Active Camera/Front/…/Custom View 3. - Orbit / Pan / Dolly tools drag the current view (camera layer in Active Camera, merged into one undo step; view cameras otherwise). - Handles, gizmo and picking go through the view camera; 3D layers move in the view plane at their depth. - Camera frustum + POI and light position/direction wireframes (viewer.camera.<id>, viewer.light.<id>). - Camera Settings / Light Settings dialogs open from New Camera/Light, Camera/Light Settings and Layer Settings; OK runs the engine commands. - Timeline: POI only for two-node cameras/auto-oriented lights; "Z Rotation" label on 3D layers. - Headless egui_kittest tests (UI wiring + opt-in wgpu snapshots); fix the remaining workspace clippy lints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
76ac3f74f7
commit
16a5fa7a83
@@ -1,10 +1,13 @@
|
||||
//! The Composition viewer: pasteboard + comp frame, magnification and resolution, transparency
|
||||
//! grid, guides, layer bounding boxes with handles, anchor points, motion paths and masks, and
|
||||
//! direct manipulation (move, scale, rotate, pan behind, shape/type creation, hand and zoom).
|
||||
//! direct manipulation (move, scale, rotate, pan behind, shape/type creation, hand and zoom),
|
||||
//! 3D views (Active Camera / Front / … / Custom View 3), camera tools (orbit, pan, dolly) and
|
||||
//! camera/light wireframes.
|
||||
|
||||
use effectcraft_engine::geom::{Mat3, vec2 as gv2};
|
||||
use effectcraft_engine::project::{GroupKind, Layer, LayerId};
|
||||
use effectcraft_engine::render::EvalCtx;
|
||||
use effectcraft_engine::render::three_d::{self, CameraState, View3D};
|
||||
use effectcraft_engine::time::Tick;
|
||||
use egui::{Align2, Color32, Pos2, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
|
||||
use serde_json::json;
|
||||
@@ -55,21 +58,71 @@ pub fn last_fit(ctx: &egui::Context) -> f32 {
|
||||
/// What a drag in the viewer is doing.
|
||||
#[derive(Clone, Debug)]
|
||||
enum Gesture {
|
||||
Move { layers: Vec<(LayerId, [f64; 3], Mat3)>, start: [f64; 2] },
|
||||
Scale { layer: LayerId, anchor_screen: Pos2, start_scale: [f64; 3], start_local: [f64; 2], inv: Mat3, uniform: bool },
|
||||
Rotate { layer: LayerId, center: Pos2, start_angle: f64, start_rot: f64 },
|
||||
Anchor { layer: LayerId, start_anchor: [f64; 3], start_pos: [f64; 3], start: [f64; 2], inv: Mat3, l2p: Mat3 },
|
||||
Pan { start_pan: [f32; 2] },
|
||||
Create { tool: Tool, start: [f64; 2] },
|
||||
Marquee { start: Pos2 },
|
||||
/// Per layer: start position and the parent-space change per comp pixel of drag in x and y.
|
||||
Move {
|
||||
layers: Vec<(LayerId, [f64; 3], [f64; 3], [f64; 3])>,
|
||||
start: [f64; 2],
|
||||
},
|
||||
Camera {
|
||||
tool: Tool,
|
||||
},
|
||||
Scale {
|
||||
layer: LayerId,
|
||||
start_scale: [f64; 3],
|
||||
start_local: [f64; 2],
|
||||
inv: Mat3,
|
||||
uniform: bool,
|
||||
},
|
||||
Rotate {
|
||||
layer: LayerId,
|
||||
center: Pos2,
|
||||
start_angle: f64,
|
||||
start_rot: f64,
|
||||
},
|
||||
Anchor {
|
||||
layer: LayerId,
|
||||
start_anchor: [f64; 3],
|
||||
start_pos: [f64; 3],
|
||||
start: [f64; 2],
|
||||
inv: Mat3,
|
||||
l2p: Mat3,
|
||||
},
|
||||
Pan {
|
||||
start_pan: [f32; 2],
|
||||
},
|
||||
Create {
|
||||
tool: Tool,
|
||||
start: [f64; 2],
|
||||
},
|
||||
Marquee {
|
||||
start: Pos2,
|
||||
},
|
||||
}
|
||||
|
||||
const HANDLE: f32 = 7.0;
|
||||
|
||||
thread_local! {
|
||||
/// The 3D view camera of the viewer being drawn (None = the comp's active camera).
|
||||
static VIEW_CAM: std::cell::Cell<Option<CameraState>> = const { std::cell::Cell::new(None) };
|
||||
}
|
||||
|
||||
/// The camera the viewer shows (view camera or the comp's active camera).
|
||||
fn cam_state(ctx: &EvalCtx) -> CameraState {
|
||||
VIEW_CAM.with(|c| c.get()).unwrap_or_else(|| three_d::active_camera(ctx))
|
||||
}
|
||||
|
||||
/// Layer → comp (viewer) matrix through the current 3D view.
|
||||
fn l2c(ctx: &EvalCtx, layer: &Layer) -> (Mat3, f64) {
|
||||
match VIEW_CAM.with(|c| c.get()) {
|
||||
Some(cam) if layer.is_3d() => (three_d::layer_to_view(ctx, layer, &cam), 0.0),
|
||||
_ => ctx.layer_to_comp(layer),
|
||||
}
|
||||
}
|
||||
|
||||
/// Layer → comp matrix and its bounds quad (in comp pixels).
|
||||
fn layer_quad(ctx: &EvalCtx, layer: &Layer) -> Option<(Mat3, [[f64; 2]; 4], [f64; 4])> {
|
||||
let b = effectcraft_engine::render::content_bounds(ctx, layer)?;
|
||||
let (m, _) = ctx.layer_to_comp(layer);
|
||||
let (m, _) = l2c(ctx, layer);
|
||||
let pts = [[b[0], b[1]], [b[2], b[1]], [b[2], b[3]], [b[0], b[3]]].map(|p| {
|
||||
let q = m.apply(gv2(p[0], p[1]));
|
||||
[q.x, q.y]
|
||||
@@ -133,6 +186,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let comp = app.session.project.comp(cid).cloned().unwrap_or_else(|| effectcraft_engine::project::Comp::new(1920, 1080, Default::default(), Tick::ZERO));
|
||||
let comp_name = app.session.project.item(cid).map(|i| i.name.clone()).unwrap_or_default();
|
||||
let p = ui.painter().clone();
|
||||
VIEW_CAM.with(|c| c.set(app.session.view_camera(cid)));
|
||||
|
||||
// Navigator bar (open comps as breadcrumbs).
|
||||
let nav = Rect::from_min_size(rect.min, vec2(rect.width(), 24.0));
|
||||
@@ -279,7 +333,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if app.ui.viewer.show_masks
|
||||
&& let Some(masks) = l.masks()
|
||||
{
|
||||
let (m, _) = ectx.layer_to_comp(l);
|
||||
let (m, _) = l2c(&ectx, l);
|
||||
for g in masks.groups() {
|
||||
let GroupKind::Mask { color, .. } = g.kind else { continue };
|
||||
let Some(path) = g.get("path").map(|pr| ectx.value(l, pr)) else { continue };
|
||||
@@ -338,8 +392,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
// 3D axis gizmo.
|
||||
if l.is_3d() {
|
||||
let w = ectx.world_matrix(l);
|
||||
let (cam, _, _) = ectx.camera();
|
||||
let pc = cam * w;
|
||||
let pc = cam_state(&ectx).projection(cw as f64, ch as f64) * w;
|
||||
let a3 = effectcraft_engine::geom::vec3(a[0], a[1], a[2]);
|
||||
let o = pc.apply(a3);
|
||||
let len = 60.0 / zoom as f64;
|
||||
@@ -356,6 +409,17 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
}
|
||||
|
||||
// Cameras and lights (wireframes) and the 3D view name.
|
||||
if comp.has_3d() {
|
||||
draw_rigs(app, &painter, &map, &ectx, &selected);
|
||||
let view = app.session.state.views3d.get(&cid).map(|v| v.current).unwrap_or_default();
|
||||
let label = match (view, comp.active_camera(time)) {
|
||||
(View3D::ActiveCamera, Some(c)) => format!("Active Camera ({})", c.name),
|
||||
(v, _) => v.label().to_string(),
|
||||
};
|
||||
painter.text(area.left_top() + vec2(12.0, 10.0), Align2::LEFT_TOP, label, Tokens::ui(12.0), t.text_dim);
|
||||
}
|
||||
|
||||
// Interaction.
|
||||
let resp = ui.interact(area, egui::Id::new("viewer-interact"), Sense::click_and_drag());
|
||||
let gid = egui::Id::new("viewer-gesture");
|
||||
@@ -368,6 +432,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
Tool::Hand => egui::CursorIcon::Grab,
|
||||
Tool::Zoom => egui::CursorIcon::ZoomIn,
|
||||
Tool::Type | Tool::TypeVertical => egui::CursorIcon::Text,
|
||||
Tool::Orbit => egui::CursorIcon::Alias,
|
||||
Tool::PanCamera => egui::CursorIcon::Move,
|
||||
Tool::Dolly => egui::CursorIcon::ResizeVertical,
|
||||
t if t.is_shape() || t == Tool::Pen => egui::CursorIcon::Crosshair,
|
||||
_ => {
|
||||
if handle_hits.iter().any(|(_, _, h)| h.distance(hp) < HANDLE) {
|
||||
@@ -415,7 +482,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
Tool::PanBehind => pick(app, &ectx, cpt, false).and_then(|l| {
|
||||
let layer = comp.layer(l)?;
|
||||
let tr = layer.transform()?;
|
||||
let (l2c, _) = ectx.layer_to_comp(layer);
|
||||
let (l2c, _) = l2c(&ectx, layer);
|
||||
let l2p = ectx.local_matrix(layer);
|
||||
let l2p = Mat3([[l2p.0[0][0], l2p.0[0][1], 0.0], [l2p.0[1][0], l2p.0[1][1], 0.0], [0.0, 0.0, 1.0]]);
|
||||
Some(Gesture::Anchor {
|
||||
@@ -428,20 +495,19 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
})
|
||||
}),
|
||||
t if t.is_shape() => Some(Gesture::Create { tool: t, start: cpt }),
|
||||
Tool::Orbit | Tool::PanCamera | Tool::Dolly => Some(Gesture::Camera { tool }),
|
||||
Tool::Selection => {
|
||||
if let Some((lid, hi, _)) = handle_hits.iter().find(|(_, _, h)| h.distance(pos) < HANDLE + 2.0).cloned() {
|
||||
let layer = comp.layer(lid).cloned();
|
||||
layer.and_then(|layer| {
|
||||
let tr = layer.transform()?;
|
||||
let (l2c, _) = ectx.layer_to_comp(&layer);
|
||||
let (l2c, _) = l2c(&ectx, &layer);
|
||||
let inv = l2c.inverse()?;
|
||||
let a = ectx.v3(&layer, tr, "anchor", [0.0; 3]);
|
||||
let ac = l2c.apply(gv2(a[0], a[1]));
|
||||
let lp = inv.apply(gv2(cpt[0], cpt[1]));
|
||||
let _ = hi;
|
||||
Some(Gesture::Scale {
|
||||
layer: lid,
|
||||
anchor_screen: map.to_screen([ac.x, ac.y]),
|
||||
start_scale: ectx.v3(&layer, tr, "scale", [100.0; 3]),
|
||||
start_local: [lp.x - a[0], lp.y - a[1]],
|
||||
inv,
|
||||
@@ -449,14 +515,18 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
})
|
||||
})
|
||||
} else if let Some(l) = pick(app, &ectx, cpt, mods.shift) {
|
||||
let layers: Vec<(LayerId, [f64; 3], Mat3)> = app
|
||||
let layers: Vec<(LayerId, [f64; 3], [f64; 3], [f64; 3])> = app
|
||||
.session
|
||||
.state
|
||||
.selected_layers
|
||||
.iter()
|
||||
.filter_map(|id| comp.layer(*id))
|
||||
.filter(|l| !l.switches.locked)
|
||||
.filter_map(|l| Some((l.id, ectx.v3(l, l.transform()?, "position", [0.0; 3]), parent_inverse(&ectx, l))))
|
||||
.filter_map(|l| {
|
||||
let p0 = ectx.v3(l, l.transform()?, "position", [0.0; 3]);
|
||||
let (ax, ay) = drag_axes(&ectx, l);
|
||||
Some((l.id, p0, ax, ay))
|
||||
})
|
||||
.collect();
|
||||
let _ = l;
|
||||
(!layers.is_empty()).then_some(Gesture::Move { layers, start: cpt })
|
||||
@@ -485,9 +555,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
if mods.shift {
|
||||
if d[0].abs() > d[1].abs() { d[1] = 0.0 } else { d[0] = 0.0 }
|
||||
}
|
||||
for (lid, p0, inv) in layers {
|
||||
let dd = inv.apply_vec(gv2(d[0], d[1]));
|
||||
let v = json!([p0[0] + dd.x, p0[1] + dd.y, p0[2]]);
|
||||
for (lid, p0, ax, ay) in layers {
|
||||
let v = json!([p0[0] + ax[0] * d[0] + ay[0] * d[1], p0[1] + ax[1] * d[0] + ay[1] * d[1], p0[2] + ax[2] * d[0] + ay[2] * d[1]]);
|
||||
let _ = app.session.execute("prop.set", json!({"layer": lid.0, "path": "transform/position", "value": v, "merge": merge}));
|
||||
}
|
||||
}
|
||||
@@ -498,7 +567,8 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let cur = [lp.x - a[0], lp.y - a[1]];
|
||||
let fx = if start_local[0].abs() > 1e-6 { cur[0] / start_local[0] } else { 1.0 };
|
||||
let fy = if start_local[1].abs() > 1e-6 { cur[1] / start_local[1] } else { 1.0 };
|
||||
let (fx, fy) = if mods.shift || uniform && start_local[0].abs() > 1e-6 && start_local[1].abs() > 1e-6 && mods.shift {
|
||||
let _ = uniform;
|
||||
let (fx, fy) = if mods.shift {
|
||||
let f = (fx + fy) / 2.0;
|
||||
(f, f)
|
||||
} else {
|
||||
@@ -528,7 +598,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
time,
|
||||
expr: app.session.expr.as_deref(),
|
||||
};
|
||||
if let Some(m) = e2.layer_to_comp(&l).0.inverse() {
|
||||
if let Some(m) = l2c(&e2, &l).0.inverse() {
|
||||
*i2 = m;
|
||||
}
|
||||
}
|
||||
@@ -555,6 +625,20 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let _ = app.session.execute("prop.set", json!({"layer": layer.0, "path": "transform/anchor", "value": na, "merge": merge}));
|
||||
let _ = app.session.execute("prop.set", json!({"layer": layer.0, "path": "transform/position", "value": np, "merge": merge}));
|
||||
}
|
||||
Gesture::Camera { tool } => {
|
||||
let d = resp.drag_delta();
|
||||
if d != egui::Vec2::ZERO {
|
||||
let (dx, dy) = ((d.x / zoom) as f64, (d.y / zoom) as f64);
|
||||
let (id, params) = match tool {
|
||||
Tool::Orbit => ("camera.orbit", json!({"yaw": -d.x as f64 * 0.4, "pitch": d.y as f64 * 0.4, "merge": merge})),
|
||||
Tool::PanCamera => ("camera.pan", json!({"dx": dx, "dy": dy, "merge": merge})),
|
||||
_ => ("camera.dolly", json!({"amount": -dy * 2.0, "merge": merge})),
|
||||
};
|
||||
if let Err(e) = app.session.execute(id, params) {
|
||||
app.ui.status = e.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
Gesture::Create { start, .. } => {
|
||||
let a = map.to_screen(start);
|
||||
let r = Rect::from_two_pos(a, pos);
|
||||
@@ -650,6 +734,99 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
bottom_bar(app, ui, bar, zoom, fit, time, &comp);
|
||||
}
|
||||
|
||||
/// Parent-space position change per comp pixel of drag (x and y) for a layer: 2D layers map
|
||||
/// through the parent transform; 3D layers move in the view plane at their depth.
|
||||
fn drag_axes(ctx: &EvalCtx, l: &Layer) -> ([f64; 3], [f64; 3]) {
|
||||
if !l.is_3d() {
|
||||
let inv = parent_inverse(ctx, l);
|
||||
let a = inv.apply_vec(gv2(1.0, 0.0));
|
||||
let b = inv.apply_vec(gv2(0.0, 1.0));
|
||||
return ([a.x, a.y, 0.0], [b.x, b.y, 0.0]);
|
||||
}
|
||||
let cam = cam_state(ctx);
|
||||
let anchor = l.transform().map(|tr| ctx.v3(l, tr, "anchor", [0.0; 3])).unwrap_or([0.0; 3]);
|
||||
let wp = ctx.world_matrix(l).apply(anchor.into());
|
||||
let k = if cam.ortho { 1.0 / cam.zoom.max(1e-9) } else { cam.depth(wp).max(1.0) / cam.zoom.max(1e-9) };
|
||||
let pinv = match l.parent.and_then(|p| ctx.comp.layer(p)) {
|
||||
Some(p) => ctx.world_matrix(p).inverse().unwrap_or_default(),
|
||||
None => effectcraft_engine::geom::Mat4::IDENTITY,
|
||||
};
|
||||
let a = pinv.apply_vec(cam.right() * k);
|
||||
let b = pinv.apply_vec(cam.down() * k);
|
||||
([a.x, a.y, a.z], [b.x, b.y, b.z])
|
||||
}
|
||||
|
||||
/// Wireframes of cameras (frustum, point of interest) and lights (position, direction) as seen
|
||||
/// through the current 3D view.
|
||||
fn draw_rigs(app: &mut EffectcraftApp, painter: &egui::Painter, map: &ViewerMap, ectx: &EvalCtx, selected: &[LayerId]) {
|
||||
use effectcraft_engine::geom::Vec3;
|
||||
use effectcraft_engine::project::{LayerSource, LightKind};
|
||||
let cam = cam_state(ectx);
|
||||
let (w, h) = (ectx.comp.width as f64, ectx.comp.height as f64);
|
||||
let active = ectx.comp.active_camera(ectx.time).map(|c| c.id);
|
||||
let through_active = VIEW_CAM.with(|c| c.get()).is_none();
|
||||
let proj = |p: Vec3| cam.project(w, h, p).map(|v| map.to_screen([v.x, v.y]));
|
||||
let seg = |a: Vec3, b: Vec3, stroke: Stroke| {
|
||||
if let (Some(x), Some(y)) = (proj(a), proj(b)) {
|
||||
painter.line_segment([x, y], stroke);
|
||||
}
|
||||
};
|
||||
for l in ectx.comp.layers.iter().filter(|l| (l.is_camera() || l.is_light()) && l.is_active_at(ectx.time)) {
|
||||
let sel = selected.contains(&l.id);
|
||||
let col = Tokens::label(l.label).gamma_multiply(if sel { 1.0 } else { 0.6 });
|
||||
let stroke = Stroke::new(if sel { 1.5 } else { 1.0 }, col);
|
||||
let (eye, fwd, down) = three_d::camera::layer_frame(ectx, l);
|
||||
let poi = |l: &Layer| -> Option<Vec3> {
|
||||
let pr = l.transform()?.get("poi").filter(|_| three_d::camera::is_two_node(l))?;
|
||||
Some(three_d::camera::parent_world(ectx, l).apply(ectx.value(l, pr).as_vec3().into()))
|
||||
};
|
||||
if l.is_camera() {
|
||||
if through_active && Some(l.id) == active {
|
||||
continue;
|
||||
}
|
||||
let zoom = l.props.prop("cameraOptions/zoom").map(|p| ectx.value(l, p).as_f64()).unwrap_or(1000.0);
|
||||
let right = down.cross(fwd);
|
||||
// Frustum to a plane at a quarter of the zoom distance.
|
||||
let k = 0.25;
|
||||
let c = eye + fwd * (zoom * k);
|
||||
let corners = [(-1.0, -1.0), (1.0, -1.0), (1.0, 1.0), (-1.0, 1.0)].map(|(sx, sy)| c + right * (sx * w * 0.5 * k) + down * (sy * h * 0.5 * k));
|
||||
for i in 0..4 {
|
||||
seg(eye, corners[i], stroke);
|
||||
seg(corners[i], corners[(i + 1) % 4], stroke);
|
||||
}
|
||||
if let Some(poi) = poi(l) {
|
||||
seg(eye, poi, Stroke::new(1.0, col.gamma_multiply(0.6)));
|
||||
if let Some(s) = proj(poi) {
|
||||
painter.circle_stroke(s, 4.0, stroke);
|
||||
}
|
||||
}
|
||||
if let Some(s) = proj(eye) {
|
||||
app.auto.add(&format!("viewer.camera.{}", l.id.0), Rect::from_center_size(s, vec2(14.0, 14.0)), &l.name);
|
||||
}
|
||||
} else {
|
||||
let LayerSource::Light { kind } = l.source else { continue };
|
||||
if kind == LightKind::Ambient {
|
||||
continue;
|
||||
}
|
||||
let Some(s) = proj(eye) else { continue };
|
||||
painter.circle_stroke(s, 6.0, stroke);
|
||||
for i in 0..8 {
|
||||
let a = i as f32 * std::f32::consts::FRAC_PI_4;
|
||||
let d = vec2(a.cos(), a.sin());
|
||||
painter.line_segment([s + d * 8.0, s + d * 12.0], stroke);
|
||||
}
|
||||
if matches!(kind, LightKind::Spot | LightKind::Parallel) {
|
||||
let target = poi(l).unwrap_or(eye + fwd * 300.0);
|
||||
seg(eye, target, Stroke::new(1.0, col.gamma_multiply(0.7)));
|
||||
if let Some(q) = proj(target) {
|
||||
painter.circle_stroke(q, 3.0, stroke);
|
||||
}
|
||||
}
|
||||
app.auto.add(&format!("viewer.light.{}", l.id.0), Rect::from_center_size(s, vec2(16.0, 16.0)), &l.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Topmost layer under a comp point (selects it; shift toggles). Returns the hit layer.
|
||||
fn pick(app: &mut EffectcraftApp, ectx: &EvalCtx, cpt: [f64; 2], toggle: bool) -> Option<LayerId> {
|
||||
let hit = ectx
|
||||
@@ -705,7 +882,7 @@ fn create_shape(app: &mut EffectcraftApp, tool: Tool, a: [f64; 2], b: [f64; 2],
|
||||
time: app.session.time(),
|
||||
expr: None,
|
||||
};
|
||||
let inv = ectx.layer_to_comp(&l).0.inverse().unwrap_or(Mat3::IDENTITY);
|
||||
let inv = l2c(&ectx, &l).0.inverse().unwrap_or(Mat3::IDENTITY);
|
||||
let p0 = inv.apply(gv2(cx - w / 2.0, cy - h / 2.0));
|
||||
let p1 = inv.apply(gv2(cx + w / 2.0, cy + h / 2.0));
|
||||
let _ = app.session.execute(
|
||||
@@ -847,7 +1024,7 @@ fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect, zoom: f32,
|
||||
app.ui.viewer.res = Resolution::ALL[i];
|
||||
}
|
||||
x = r.max.x + 6.0;
|
||||
if tog(ui, &mut app.auto, &mut x, Icon::Region, false, "roi", "Region of Interest") {}
|
||||
let _ = tog(ui, &mut app.auto, &mut x, Icon::Region, false, "roi", "Region of Interest");
|
||||
if tog(ui, &mut app.auto, &mut x, Icon::Checker, app.ui.viewer.transparency_grid, "transparency", "Toggle Transparency Grid") {
|
||||
app.ui.viewer.transparency_grid = !app.ui.viewer.transparency_grid;
|
||||
}
|
||||
@@ -858,9 +1035,20 @@ fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect, zoom: f32,
|
||||
if comp.has_3d() {
|
||||
let r = Rect::from_min_size(pos2(x + 2.0, cy - 10.0), vec2(96.0, 20.0));
|
||||
let _ = widgets::dropdown(ui, r, "Classic 3D", &t, egui::Id::new("vw-3d"));
|
||||
app.auto.add("viewer.renderer3d", r, "3D Renderer");
|
||||
x = r.max.x + 4.0;
|
||||
let r = Rect::from_min_size(pos2(x, cy - 10.0), vec2(110.0, 20.0));
|
||||
let _ = widgets::dropdown(ui, r, "Active Camera", &t, egui::Id::new("vw-cam"));
|
||||
let cid = app.session.active_comp_id();
|
||||
let cur = cid.and_then(|c| app.session.state.views3d.get(&c)).map(|v| v.current).unwrap_or_default();
|
||||
let r = Rect::from_min_size(pos2(x, cy - 10.0), vec2(118.0, 20.0));
|
||||
if widgets::dropdown(ui, r, cur.label(), &t, egui::Id::new("vw-cam")).clicked() {
|
||||
widgets::open_popup(ui, egui::Id::new("vw-cam-pop"));
|
||||
}
|
||||
app.auto.add("viewer.view3d", r, "3D View");
|
||||
let opts: Vec<String> = View3D::ALL.iter().map(|v| v.label().to_string()).collect();
|
||||
let at = r.left_top() - vec2(0.0, 22.0 * opts.len() as f32 + 12.0);
|
||||
if let Some(i) = widgets::popup_menu(ui, egui::Id::new("vw-cam-pop"), at, &opts, View3D::ALL.iter().position(|v| *v == cur)) {
|
||||
let _ = app.session.execute("view.set3DView", json!({"view": View3D::ALL[i].id()}));
|
||||
}
|
||||
}
|
||||
// Right: render time.
|
||||
let ms = app.frames.last_ms.lock().map(|v| *v).unwrap_or(0.0);
|
||||
|
||||
Reference in New Issue
Block a user