#[repr(C)]pub struct Scene {
pub world: World,
pub command_buffer: CommandBuffer,
/* private fields */
}
Expand description
Scene contains the ECS world and various functionality to interact with it.
Fields§
§world: World
§command_buffer: CommandBuffer
Implementations§
Source§impl Scene
impl Scene
pub fn new() -> Self
Sourcepub fn get_entity_resource(&self) -> Entity
pub fn get_entity_resource(&self) -> Entity
Gets the entity that contains all the resources
Sourcepub fn get_unused_name(&self) -> String
pub fn get_unused_name(&self) -> String
Creates a name that is guaranteed to be unused
Creates a entity with a name or gets the one that already exists with that concrete name You can keep adding components to this entity with .insert()
Sourcepub fn get_or_create_entity(&mut self, name: &str) -> EntityMut<'_>
pub fn get_or_create_entity(&mut self, name: &str) -> EntityMut<'_>
Creates a entity with a name or gets the one that already exists with that concrete name You can keep adding components to this entity with .insert() Also inserts a renderable component
Sourcepub fn despawn_with_name(&mut self, name: &str)
pub fn despawn_with_name(&mut self, name: &str)
Despawns entity with a certain name and all it’s components
pub fn despawn(&mut self, entity: Entity)
Sourcepub fn get_entity_with_name(&self, name: &str) -> Option<Entity>
pub fn get_entity_with_name(&self, name: &str) -> Option<Entity>
§Panics
Will panic if no entity has that name
Sourcepub fn get_entity_mut_with_name(&mut self, name: &str) -> Option<EntityMut<'_>>
pub fn get_entity_mut_with_name(&mut self, name: &str) -> Option<EntityMut<'_>>
§Panics
Will panic if no entity has that name
Sourcepub fn find_entity_with_id(&mut self, id: u8) -> Option<EntityRef<'_>>
pub fn find_entity_with_id(&mut self, id: u8) -> Option<EntityRef<'_>>
§Panics
Will return None if no entity with id found
Sourcepub fn get_current_cam(&self) -> Option<Camera>
pub fn get_current_cam(&self) -> Option<Camera>
§Panics
Will panic if there is no camera added yet
Sourcepub fn add_resource<T: Component>(&mut self, component: T)
pub fn add_resource<T: Component>(&mut self, component: T)
Use to create a unique component, similar to resources in Bevy
§Panics
Will panic if the entity that contains all the resources has not been created
Sourcepub fn remove_resource<T: Component>(&mut self) -> Result<T, ComponentError>
pub fn remove_resource<T: Component>(&mut self) -> Result<T, ComponentError>
Sourcepub fn has_resource<T: Component>(&self) -> bool
pub fn has_resource<T: Component>(&self) -> bool
§Panics
Will panic if the entity that contains all the resources has not been created
Sourcepub fn get_resource<'a, T: ComponentRef<'a>>(
&'a self,
) -> Result<<T as ComponentRef<'a>>::Ref, ComponentError>
pub fn get_resource<'a, T: ComponentRef<'a>>( &'a self, ) -> Result<<T as ComponentRef<'a>>::Ref, ComponentError>
Gets a resource which is a component shared between all entities Use with: scene.get_resource::<&mut Component>();
§Errors
Will error if the entity that contains all the resources has not been created
Sourcepub fn insert_if_doesnt_exist<T: Component + Default>(&mut self, entity: Entity)
pub fn insert_if_doesnt_exist<T: Component + Default>(&mut self, entity: Entity)
§Panics
Will panic if the entity has not been created
Sourcepub fn get_comp<'a, T: ComponentRef<'a>>(
&'a self,
entity: &Entity,
) -> Result<<T as ComponentRef<'a>>::Ref, ComponentError>
pub fn get_comp<'a, T: ComponentRef<'a>>( &'a self, entity: &Entity, ) -> Result<<T as ComponentRef<'a>>::Ref, ComponentError>
Generic function to get a component for a certain entity. Merely syntactic sugar. Use with: scene.get_comp::<&mut Component>(&entity);
§Errors
Will error if the component or the entity does not exist
Sourcepub fn get_lights(&self, sorted_by_name: bool) -> Vec<Entity>
pub fn get_lights(&self, sorted_by_name: bool) -> Vec<Entity>
§Panics
Will panic if the entity does not have a name assigned
pub fn get_all_entities(&self, sorted_by_name: bool) -> Vec<Entity>
pub fn get_renderables(&self, sorted_by_name: bool) -> Vec<Entity>
pub fn get_renderable_names(&self) -> Vec<String>
pub fn nr_renderables(&self) -> u32
Sourcepub fn get_bounding_points(&self) -> (Point3<f32>, Point3<f32>)
pub fn get_bounding_points(&self) -> (Point3<f32>, Point3<f32>)
get two points that define the minimal point of the scene in all dimensions and the maximum point of the scene in all directions. These two points would form a rectangle containing the whole scene without the floor
pub fn get_min_y(&self) -> f32
Sourcepub fn get_scale(&self) -> f32
pub fn get_scale(&self) -> f32
get the scale of the scene. useful for adding camera or lights automtically
pub fn get_centroid(&self) -> Point3<f32>
pub fn init_3_point_light( &self, light_config: &mut LightConfig, idx: usize, scale: f32, centroid: &Point3<f32>, )
pub fn make_concrete_config(&self, config: &mut Config)
Sourcepub fn from_config(&mut self, config: &mut Config, width: u32, height: u32)
pub fn from_config(&mut self, config: &mut Config, width: u32, height: u32)
§Panics
Will panic if the camera entity has not yet been created
pub fn create_floor(&mut self, config: &Config)
pub fn get_floor(&self) -> Option<Actor>
pub fn has_floor(&self) -> bool
pub fn remove_all_gpu_components(&mut self)
Trait Implementations§
Source§impl GetStaticEquivalent_ for Scene
impl GetStaticEquivalent_ for Scene
Source§type StaticEquivalent = _static_Scene
type StaticEquivalent = _static_Scene
'static
equivalent of Self
Auto Trait Implementations§
impl !Freeze for Scene
impl RefUnwindSafe for Scene
impl Send for Scene
impl Sync for Scene
impl Unpin for Scene
impl UnwindSafe for Scene
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo*
type which aligns Self
to ALIGNMENT
.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
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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset
. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset
. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset
. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset
. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset
) with value
,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read moreSource§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.