pub struct State<T>(/* private fields */);Implementations§
Source§impl<T: StateTrait> State<T>
impl<T: StateTrait> State<T>
Sourcepub fn register_surface<V: Vertices, I: Into<SurfaceIndices>>(
&mut self,
name: impl Into<String>,
vertices: V,
indices: I,
) -> SurfaceMut<'_, T>
pub fn register_surface<V: Vertices, I: Into<SurfaceIndices>>( &mut self, name: impl Into<String>, vertices: V, indices: I, ) -> SurfaceMut<'_, T>
Register a new surface. If an existing one with same number of vertices and same faces exists, previous settings and data are recovered.
See Surface and SurfaceMut for how to add data to the created
shape.
pub fn get_surface_mut(&mut self, name: &str) -> Option<SurfaceMut<'_, T>>
pub fn get_surface(&self, name: &str) -> Option<&Surface<T>>
pub fn remove_surface(&mut self, name: &str)
Sourcepub fn register_point_cloud<V: Vertices>(
&mut self,
name: impl Into<String>,
positions: V,
) -> PointCloudMut<'_, T>
pub fn register_point_cloud<V: Vertices>( &mut self, name: impl Into<String>, positions: V, ) -> PointCloudMut<'_, T>
Register a new point cloud. If an existing one with same number of points exists, previous settings and data are recovered.
See PointCloud and PointCloudMut for how to add data to the created
shape.
pub fn get_point_cloud_mut( &mut self, name: &str, ) -> Option<PointCloudMut<'_, T>>
pub fn get_point_cloud(&self, name: &str) -> Option<&PointCloud<T>>
pub fn remove_point_cloud(&mut self, name: &str)
Sourcepub fn register_segment<V: Vertices>(
&mut self,
name: impl Into<String>,
positions: V,
connections: Vec<[u32; 2]>,
) -> SegmentMut<'_, T>
pub fn register_segment<V: Vertices>( &mut self, name: impl Into<String>, positions: V, connections: Vec<[u32; 2]>, ) -> SegmentMut<'_, T>
Register a list of segments. If an existing one with same number of points and same connextions exists, previous settings and data are recovered.
See Segment and SegmentMut for how to add data to the created
shape.
Arguments :
positions: segments extremitiesconnections: segments denoted by extremities indices
pub fn get_segment_mut(&mut self, name: &str) -> Option<SegmentMut<'_, T>>
pub fn get_segment(&self, name: &str) -> Option<&Segment<T>>
pub fn remove_segment(&mut self, name: &str)
Sourcepub fn load_from_state_file(&mut self, path: impl AsRef<Path>) -> Result<(), ()>
Available on crate feature saves and non-WebAssembly only.
pub fn load_from_state_file(&mut self, path: impl AsRef<Path>) -> Result<(), ()>
saves and non-WebAssembly only.Load app state from given file content.
Sourcepub fn load_from_state_slice(&mut self, data: &[u8]) -> Result<(), ()>
Available on crate feature saves only.
pub fn load_from_state_slice(&mut self, data: &[u8]) -> Result<(), ()>
saves only.Load app state from given buffer.
Sourcepub fn save_state_file(&self, path: impl AsRef<Path>) -> Result<(), ()>
Available on crate feature saves and non-WebAssembly only.
pub fn save_state_file(&self, path: impl AsRef<Path>) -> Result<(), ()>
saves and non-WebAssembly only.Save current state in cbor into chosen file.
Sourcepub fn save_state_vec(&self) -> Result<Vec<u8>, ()>
Available on crate feature saves only.
pub fn save_state_vec(&self) -> Result<Vec<u8>, ()>
saves only.Save current state in cbor into buffer.
pub fn get_settings_mut(&mut self) -> &mut Settings
pub fn get_settings(&self) -> &Settings
pub fn set_camera(&mut self, eye: [f32; 3], target: [f32; 3], up: [f32; 3])
Source§impl State<InnerBareState>
impl State<InnerBareState>
Sourcepub fn run<S: Into<String>>(self, width: u32, height: u32, id: Option<S>)
pub fn run<S: Into<String>>(self, width: u32, height: u32, id: Option<S>)
Show the window and start the app.
In wasm, width and height are ignored and css is used to define the dimensions
(allowing for dimensions in % and vh/vw).
Arguments:
width: requested width of the app (no effect in wasm)height: requested height of the app (no effect in wasm)id: serves as window title, or id shape to attach to. IfNoneuses"State".
use deuxfleurs::load_mesh;
let (spot_v, spot_f) = load_mesh("examples/assets/spot.obj").await.unwrap();
let mut handle = deuxfleurs::init();
handle.register_surface("Spot", spot_v, spot_f);
let mut handle = handle.run(1920, 1080, Some("deuxfleurs"));Sourcepub fn run_headless(self) -> RunningState
Available on non-WebAssembly only.
pub fn run_headless(self) -> RunningState
Run the app without a window. Allows running the app in environment where no display is available and taking screenshots automatically.
Currently only available on non wasm targets, as webGL requires a context.
use deuxfleurs::load_mesh;
let (spot_v, spot_f) = load_mesh("examples/assets/spot.obj").await.unwrap();
let mut handle = deuxfleurs::init();
handle.register_surface("Spot", spot_v, spot_f);
let mut handle = handle.run_headless();
handle.screenshot();Sourcepub fn run_with_callback<S: Into<String>, U: FnMut(&mut Ui, &mut RunningState)>(
self,
width: u32,
height: u32,
id: Option<S>,
callback: U,
)
pub fn run_with_callback<S: Into<String>, U: FnMut(&mut Ui, &mut RunningState)>( self, width: u32, height: u32, id: Option<S>, callback: U, )
Specify a callback that will be called once every frame.
Passes an egui::Ui and a RunningState arguments which can be
used to add UI elements and modify state accordingly.
Source§impl State<InnerGraphicalState>
impl State<InnerGraphicalState>
Sourcepub fn resize_scene(&mut self)
pub fn resize_scene(&mut self)
Fit camera and ground to match the visible shapes
Sourcepub fn screenshot(&mut self)
pub fn screenshot(&mut self)
Take a screenshot of the scene. The screenshot is then
saved on disk under the name screenshot_[nnn].png, with
nnn incrementing each time.
Sourcepub fn screenshot_to_buffer(&mut self) -> Result<Vec<u8>, ()>
pub fn screenshot_to_buffer(&mut self) -> Result<Vec<u8>, ()>
Take a screenshot of the scene. The screenshot is then
returned as a vector oy bytes, each storing r g b
a (in order) values of each pixel.
Should not fail, unless internal buffer storage is messed up.
Sourcepub fn get_picked(&self) -> &Option<(String, Picked)>
pub fn get_picked(&self) -> &Option<(String, Picked)>
Get current selected object: first the name, then index i and type of the selected element
Auto Trait Implementations§
impl<T> Freeze for State<T>where
T: Freeze,
impl<T> RefUnwindSafe for State<T>where
T: RefUnwindSafe,
impl<T> Send for State<T>where
T: Send,
impl<T> Sync for State<T>where
T: Sync,
impl<T> Unpin for State<T>where
T: Unpin,
impl<T> UnsafeUnpin for State<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for State<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.