M7.1: Classic 3D renderer, cameras, lights, 3D views and camera-tool commands
- render/three_d: camera eval (one/two-node, DOF), default 50mm comp camera, orthographic Front/Left/Top/Back/Right/Bottom + perspective Custom Views, orbit/pan/dolly rig math; lights (parallel/spot/point/ambient, falloff, cone feather) and material shading; per-pixel depth-sorted compositor for 3D runs (exact intersections, perspective-correct sampling, blend modes, track mattes, motion blur), ray-cast planar shadows with transmission and diffusion, per-layer DOF blur. RenderOpts.view camera override. - project: camera iris/highlight props, aperture per comp width, light orientation/rotations, two-node auto-orient defaults. - engine: layer.newCamera/newLight with presets & settings, layer.cameraSettings/lightSettings (Layer Settings dispatches), view.set3DView + View > Switch 3D View items (F10/F11/F12), last/reset view, camera.orbit/pan/dolly, view.get3D; EditorState.views3d. - demo: "3D Showcase" comp (camera move, key spot + ambient fill, shadows, DOF, intersecting planes, gridded floor). - tests: projection, depth order, intersections, lighting, shadows, DOF, views, rig math; command undo/redo. Fix a few pre-existing 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
dee16181fe
commit
76ac3f74f7
@@ -0,0 +1,36 @@
|
||||
//! Classic 3D: cameras, 3D views, lights, materials and the depth-sorted, lit, shadowed
|
||||
//! compositor for runs of 3D layers.
|
||||
//!
|
||||
//! The 2D compositor (`Renderer::comp_frame`) walks the layer stack bottom-to-top; each run of
|
||||
//! consecutive 3D layers is handed to [`compose::draw_run`] as a group (2D layers break 3D
|
||||
//! groups, as in After Effects).
|
||||
|
||||
pub mod camera;
|
||||
pub(crate) mod compose;
|
||||
pub mod light;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
pub use camera::{CameraState, Dof, Rig, View3D, ViewCam, Views3D, active_camera, default_camera, default_view_cam};
|
||||
pub use light::{LightState, Material, lights_at};
|
||||
|
||||
use effectcraft_geom::Mat3;
|
||||
use effectcraft_project::Layer;
|
||||
|
||||
use crate::EvalCtx;
|
||||
|
||||
/// Layer space → comp pixels through `cam` (2D projective), for viewer overlays and picking in
|
||||
/// any 3D view. 2D layers ignore the camera.
|
||||
pub fn layer_to_view(ctx: &EvalCtx, layer: &Layer, cam: &CameraState) -> Mat3 {
|
||||
if !layer.is_3d() {
|
||||
return ctx.layer_to_comp(layer).0;
|
||||
}
|
||||
let (w, h) = (ctx.comp.width as f64, ctx.comp.height as f64);
|
||||
(cam.projection(w, h) * ctx.world_matrix(layer)).plane_to_mat3()
|
||||
}
|
||||
|
||||
/// Project a world point into comp pixels through `cam` (None behind a perspective camera).
|
||||
pub fn project_point(ctx: &EvalCtx, cam: &CameraState, p: [f64; 3]) -> Option<[f64; 2]> {
|
||||
cam.project(ctx.comp.width as f64, ctx.comp.height as f64, p.into()).map(|v| [v.x, v.y])
|
||||
}
|
||||
Reference in New Issue
Block a user