Struct bevy_vox_scene::VoxelSceneHookBundle
source · pub struct VoxelSceneHookBundle {
pub scene: Handle<VoxelScene>,
pub hook: VoxelSceneHook,
pub transform: Transform,
pub visibility: Visibility,
}
Expand description
A component bundle for spawning Voxel Scenes, with a VoxelSceneHook
.
The root of the spawned scene will be the entity that has this bundle.
In addition to the standard components bevy uses to organise and render pbr meshes,
spawned entities will also have VoxelLayer
and VoxelModelInstance
components added.
The VoxelSceneHook
allows you to modify entities spawned within the hierarchy.
A typical use-case would be adding additional components based on an entity’s [bevy::core::Name
]
or VoxelLayer
.
VoxelSceneHookBundle {
scene: assets.load("study.vox#tank"),
hook: VoxelSceneHook::new(move |entity, commands| {
let Some(name) = entity.get::<Name>() else { return };
match name.as_str() {
"tank/goldfish" | "tank/tetra" => {
commands.insert(Fish);
}
_ => {},
}
}),
..default()
};
Fields§
§scene: Handle<VoxelScene>
A handle to a VoxelScene
, typically loaded from a “.vox” file via the [bevy::asset::AssetServer
].
This Entity will become the root of the spawned Voxel Scene.
hook: VoxelSceneHook
A VoxelSceneHook
allows you to specify a closure that will be run for each Entity spawned in the scene graph.
transform: Transform
The transform of the scene root. This will override whatever the root transform is in the Magica Voxel scene.
visibility: Visibility
The visibility of the scene root. This will override whatever the root visibility is in the Magical Voxel scene.
Trait Implementations§
source§impl Default for VoxelSceneHookBundle
impl Default for VoxelSceneHookBundle
source§fn default() -> VoxelSceneHookBundle
fn default() -> VoxelSceneHookBundle
impl Bundle for VoxelSceneHookBundle
impl DynamicBundle for VoxelSceneHookBundle
Auto Trait Implementations§
impl !RefUnwindSafe for VoxelSceneHookBundle
impl Send for VoxelSceneHookBundle
impl Sync for VoxelSceneHookBundle
impl Unpin for VoxelSceneHookBundle
impl !UnwindSafe for VoxelSceneHookBundle
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World
].