pub struct InstancedMesh { /* private fields */ }Expand description
Similar to Mesh, except it is possible to render many instances of the same mesh efficiently.
Implementations
sourceimpl InstancedMesh
impl InstancedMesh
sourcepub fn new(
context: &Context,
instances: &[Instance],
cpu_mesh: &CpuMesh
) -> ThreeDResult<Self>
pub fn new(
context: &Context,
instances: &[Instance],
cpu_mesh: &CpuMesh
) -> ThreeDResult<Self>
Creates a new 3D mesh from the given CpuMesh. All data in the CpuMesh is transfered to the GPU, so make sure to remove all unnecessary data from the CpuMesh before calling this method. The mesh is rendered in as many instances as there are Instance structs given as input. The transformation and texture transform in Instance are applied to each instance before they are rendered.
sourcepub fn transformation(&self) -> Mat4
pub fn transformation(&self) -> Mat4
Returns the local to world transformation applied to all instances.
sourcepub fn set_transformation(&mut self, transformation: Mat4)
pub fn set_transformation(&mut self, transformation: Mat4)
Set the local to world transformation applied to all instances.
sourcepub fn texture_transform(&mut self) -> &Mat3
pub fn texture_transform(&mut self) -> &Mat3
Get the texture transform applied to the uv coordinates of all of the instances.
sourcepub fn set_texture_transform(&mut self, texture_transform: Mat3)
pub fn set_texture_transform(&mut self, texture_transform: Mat3)
Set the texture transform applied to the uv coordinates of all of the model instances. This is multiplied to the texture transform for each instance.
sourcepub fn instance_count(&mut self) -> u32
pub fn instance_count(&mut self) -> u32
Returns the number of instances that is rendered.
sourcepub fn set_instance_count(&mut self, instance_count: u32)
pub fn set_instance_count(&mut self, instance_count: u32)
Use this if you only want to render instance 0 through to instance instance_count.
This is the same as changing the instances using set_instances, except that it is faster since it doesn’t update any buffers.
instance_count will be set to the number of instances when they are defined by set_instances, so all instanced are rendered by default.
sourcepub fn set_instances(&mut self, instances: &[Instance]) -> ThreeDResult<()>
pub fn set_instances(&mut self, instances: &[Instance]) -> ThreeDResult<()>
Create an instance for each element with the given mesh and texture transforms.
Trait Implementations
sourceimpl Geometry for InstancedMesh
impl Geometry for InstancedMesh
sourcefn aabb(&self) -> AxisAlignedBoundingBox
fn aabb(&self) -> AxisAlignedBoundingBox
Returns the AxisAlignedBoundingBox for this geometry in the global coordinate system. Read more
sourcefn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> ThreeDResult<()>
fn render_with_material(
&self,
material: &dyn Material,
camera: &Camera,
lights: &[&dyn Light]
) -> ThreeDResult<()>
Render the geometry with the given material.
Must be called in a render target render function,
for example in the callback function of Screen::write.
You can use an empty array for the lights argument, if you know the object does not require lights to be rendered. Read more
Auto Trait Implementations
impl !RefUnwindSafe for InstancedMesh
impl !Send for InstancedMesh
impl !Sync for InstancedMesh
impl Unpin for InstancedMesh
impl !UnwindSafe for InstancedMesh
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more