ferroui_media3d/lib.rs
1//! WPF-style 3D for FerroUI (#608, `docs/porting/media3d.md`).
2//!
3//! The values of `System.Windows.Media.Media3D`, with WPF's names and behaviour and Rust types:
4//! [`Point3D`], [`Vector3D`], [`Size3D`], [`Rect3D`], [`Point4D`], [`Matrix3D`] and
5//! [`Quaternion`], with double-precision components (narrowed to single precision only when a
6//! scene is handed to the GPU). Their operators are the traits of `std::ops`, the members WPF guards
7//! with exceptions return a `Result`, and each value parses and writes WPF's text form in the
8//! invariant culture (`"0,0,5"`, `"Identity"`, `"Empty"`), which is also the form markup writes
9//! them in.
10//!
11//! The scene model of `Viewport3D`, with WPF's classes and properties:
12//!
13//! - the transforms [`Transform3D`], [`TranslateTransform3D`], [`ScaleTransform3D`],
14//! [`RotateTransform3D`], [`MatrixTransform3D`] and [`Transform3DGroup`], and the rotations
15//! [`Rotation3D`], [`AxisAngleRotation3D`] and [`QuaternionRotation3D`];
16//! - the cameras [`Camera`], [`ProjectionCamera`], [`PerspectiveCamera`],
17//! [`OrthographicCamera`] and [`MatrixCamera`];
18//! - the models [`Model3D`], [`GeometryModel3D`] and [`Model3DGroup`], and the lights
19//! [`Light`], [`AmbientLight`], [`DirectionalLight`], [`PointLightBase`], [`PointLight`] and
20//! [`SpotLight`];
21//! - the geometry [`Geometry3D`] and [`MeshGeometry3D`], with the collections
22//! [`Point3DCollection`], [`Vector3DCollection`] and [`Int32Collection`] (and the base library's
23//! `Points` for the texture coordinates);
24//! - the materials [`Material`], [`DiffuseMaterial`], [`SpecularMaterial`],
25//! [`EmissiveMaterial`] and [`MaterialGroup`], painting with the brushes of FerroUI;
26//! - the visuals [`Visual3D`], [`ModelVisual3D`] and [`Viewport3DVisual`], and the control
27//! [`Viewport3D`].
28//!
29//! A `Viewport3DVisual` compiles its scene into an immutable [`Scene3DSnapshot`] (world
30//! matrices, shared meshes, material layers, lights in world space, the camera with its planes
31//! fitted to the scene, and three generations), which `Viewport3D` draws through the
32//! render-data operation `DrawScene3D`; the renderers are in another crate.
33//!
34//! [`register_types`] adds the classes, the markup metadata of the values and collections (their
35//! text converters) and the XML namespace of the framework to the tables of the markup loader.
36#![forbid(unsafe_code)]
37
38mod camera;
39mod change;
40mod collections;
41mod controls;
42mod error;
43mod geometry_3d;
44mod light;
45mod markup_types;
46mod material;
47mod matrix_3d;
48mod model_3d;
49mod point_3d;
50mod point_4d;
51mod quaternion;
52mod rect_3d;
53mod rotation_3d;
54mod scene_compiler;
55mod size_3d;
56mod text;
57mod transform_3d;
58mod vector_3d;
59mod viewport_3d_visual;
60mod visual_3d;
61
62pub use camera::{
63 Camera, CameraImpl, CameraImplExt, CameraVTable, MatrixCamera, OrthographicCamera, PerspectiveCamera,
64 ProjectionCamera,
65};
66pub use change::Scene3DChange;
67pub use collections::{
68 Int32Collection, MaterialCollection, Model3DCollection, Point3DCollection, Transform3DCollection,
69 Vector3DCollection, Visual3DCollection,
70};
71pub use controls::Viewport3D;
72pub use error::{Matrix3DError, QuaternionError, Size3DError};
73pub use geometry_3d::{Geometry3D, Geometry3DImpl, Geometry3DImplExt, Geometry3DVTable, MeshGeometry3D};
74pub use light::{AmbientLight, DirectionalLight, Light, PointLight, PointLightBase, SpotLight};
75pub use markup_types::{register_types, ASSEMBLY};
76pub use material::{DiffuseMaterial, EmissiveMaterial, Material, MaterialGroup, SpecularMaterial};
77pub use matrix_3d::Matrix3D;
78pub use model_3d::{GeometryModel3D, Model3D, Model3DGroup, Model3DImpl, Model3DImplExt, Model3DVTable};
79pub use point_3d::Point3D;
80pub use point_4d::Point4D;
81pub use quaternion::Quaternion;
82pub use rect_3d::Rect3D;
83pub use rotation_3d::{
84 AxisAngleRotation3D, QuaternionRotation3D, Rotation3D, Rotation3DImpl, Rotation3DImplExt, Rotation3DVTable,
85};
86pub use size_3d::Size3D;
87pub use transform_3d::{
88 MatrixTransform3D, RotateTransform3D, ScaleTransform3D, Transform3D, Transform3DGroup, Transform3DImpl,
89 Transform3DImplExt, Transform3DVTable, TranslateTransform3D,
90};
91pub use vector_3d::Vector3D;
92pub use viewport_3d_visual::Viewport3DVisual;
93pub use visual_3d::{ModelVisual3D, Visual3D};
94
95/// The compiled form of a scene, shared with the renderers (defined by the base library, which
96/// the backends depend on).
97pub use ferroui_base::rendering::scene3d::{
98 MeshData, Scene3DBounds, Scene3DCamera, Scene3DCameraKind, Scene3DFrame, Scene3DLight, Scene3DMaterialKind,
99 Scene3DMaterialLayer, Scene3DModel, Scene3DSnapshot,
100};
101
102#[cfg(test)]
103mod scene_tests;
104
105#[cfg(test)]
106mod xaml_tests;