pub struct Mesh3D {
pub vertex_positions: Vec<Position3D>,
pub triangle_indices: Option<Vec<TriangleIndices>>,
pub vertex_normals: Option<Vec<Vector3D>>,
pub vertex_colors: Option<Vec<Color>>,
pub vertex_texcoords: Option<Vec<Texcoord2D>>,
pub mesh_material: Option<Material>,
pub albedo_texture: Option<TensorData>,
pub class_ids: Option<Vec<ClassId>>,
}
Expand description
Archetype: A 3D triangle mesh as specified by its per-mesh and per-vertex properties.
See also Asset3D
.
§Example
§Simple indexed 3D mesh
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_mesh3d_indexed").spawn()?;
rec.log(
"triangle",
&rerun::Mesh3D::new([[0.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
.with_vertex_normals([[0.0, 0.0, 1.0]])
.with_vertex_colors([0x0000FFFF, 0x00FF00FF, 0xFF0000FF])
.with_triangle_indices([[2, 1, 0]]),
)?;
Ok(())
}
Fields§
§vertex_positions: Vec<Position3D>
The positions of each vertex.
If no triangle_indices
are specified, then each triplet of positions is interpreted as a triangle.
triangle_indices: Option<Vec<TriangleIndices>>
Optional indices for the triangles that make up the mesh.
vertex_normals: Option<Vec<Vector3D>>
An optional normal for each vertex.
vertex_colors: Option<Vec<Color>>
An optional color for each vertex.
vertex_texcoords: Option<Vec<Texcoord2D>>
An optional uv texture coordinate for each vertex.
mesh_material: Option<Material>
Optional material properties for the mesh as a whole.
albedo_texture: Option<TensorData>
Optional albedo texture.
Used with vertex_texcoords
on Mesh3D
.
Currently supports only sRGB(A) textures, ignoring alpha.
(meaning that the tensor must have 3 or 4 channels and use the u8
format)
class_ids: Option<Vec<ClassId>>
Optional class Ids for the vertices.
The class ID provides colors and labels if not specified explicitly.
Implementations§
source§impl Mesh3D
impl Mesh3D
sourcepub const NUM_COMPONENTS: usize = 9usize
pub const NUM_COMPONENTS: usize = 9usize
The total number of components in the archetype: 1 required, 3 recommended, 5 optional
source§impl Mesh3D
impl Mesh3D
sourcepub fn new(
vertex_positions: impl IntoIterator<Item = impl Into<Position3D>>
) -> Mesh3D
pub fn new( vertex_positions: impl IntoIterator<Item = impl Into<Position3D>> ) -> Mesh3D
Create a new Mesh3D
.
sourcepub fn with_triangle_indices(
self,
triangle_indices: impl IntoIterator<Item = impl Into<TriangleIndices>>
) -> Mesh3D
pub fn with_triangle_indices( self, triangle_indices: impl IntoIterator<Item = impl Into<TriangleIndices>> ) -> Mesh3D
Optional indices for the triangles that make up the mesh.
sourcepub fn with_vertex_normals(
self,
vertex_normals: impl IntoIterator<Item = impl Into<Vector3D>>
) -> Mesh3D
pub fn with_vertex_normals( self, vertex_normals: impl IntoIterator<Item = impl Into<Vector3D>> ) -> Mesh3D
An optional normal for each vertex.
sourcepub fn with_vertex_colors(
self,
vertex_colors: impl IntoIterator<Item = impl Into<Color>>
) -> Mesh3D
pub fn with_vertex_colors( self, vertex_colors: impl IntoIterator<Item = impl Into<Color>> ) -> Mesh3D
An optional color for each vertex.
sourcepub fn with_vertex_texcoords(
self,
vertex_texcoords: impl IntoIterator<Item = impl Into<Texcoord2D>>
) -> Mesh3D
pub fn with_vertex_texcoords( self, vertex_texcoords: impl IntoIterator<Item = impl Into<Texcoord2D>> ) -> Mesh3D
An optional uv texture coordinate for each vertex.
sourcepub fn with_mesh_material(self, mesh_material: impl Into<Material>) -> Mesh3D
pub fn with_mesh_material(self, mesh_material: impl Into<Material>) -> Mesh3D
Optional material properties for the mesh as a whole.
sourcepub fn with_albedo_texture(
self,
albedo_texture: impl Into<TensorData>
) -> Mesh3D
pub fn with_albedo_texture( self, albedo_texture: impl Into<TensorData> ) -> Mesh3D
Optional albedo texture.
Used with vertex_texcoords
on Mesh3D
.
Currently supports only sRGB(A) textures, ignoring alpha.
(meaning that the tensor must have 3 or 4 channels and use the u8
format)
sourcepub fn with_class_ids(
self,
class_ids: impl IntoIterator<Item = impl Into<ClassId>>
) -> Mesh3D
pub fn with_class_ids( self, class_ids: impl IntoIterator<Item = impl Into<ClassId>> ) -> Mesh3D
Optional class Ids for the vertices.
The class ID provides colors and labels if not specified explicitly.
source§impl Mesh3D
impl Mesh3D
sourcepub fn sanity_check(&self) -> Result<(), Mesh3DError>
pub fn sanity_check(&self) -> Result<(), Mesh3DError>
Check that this is a valid mesh, e.g. that the vertex indices are within bounds and that we have the same number of positions and normals (if any).
sourcepub fn num_vertices(&self) -> usize
pub fn num_vertices(&self) -> usize
The total number of vertices.
sourcepub fn num_triangles(&self) -> usize
pub fn num_triangles(&self) -> usize
The total number of triangles.
Trait Implementations§
source§impl Archetype for Mesh3D
impl Archetype for Mesh3D
§type Indicator = GenericIndicatorComponent<Mesh3D>
type Indicator = GenericIndicatorComponent<Mesh3D>
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
rerun.archetypes.Points2D
.source§fn indicator() -> MaybeOwnedComponentBatch<'static>
fn indicator() -> MaybeOwnedComponentBatch<'static>
source§fn required_components() -> Cow<'static, [ComponentName]>
fn required_components() -> Cow<'static, [ComponentName]>
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
source§fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)>
) -> Result<Mesh3D, DeserializationError>
fn from_arrow_components( arrow_data: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> Result<Mesh3D, DeserializationError>
ComponentNames
, deserializes them
into this archetype. Read moresource§fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
fn from_arrow(
data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> Result<Self, DeserializationError>where
Self: Sized,
source§impl AsComponents for Mesh3D
impl AsComponents for Mesh3D
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
ComponentBatch
s. Read moresource§impl PartialEq for Mesh3D
impl PartialEq for Mesh3D
source§impl SizeBytes for Mesh3D
impl SizeBytes for Mesh3D
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
self
on the heap, in bytes.source§fn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
self
in bytes, accounting for both stack and heap space.source§fn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
self
on the stack, in bytes. Read moresource§impl ToArchetype<Mesh3D> for LatestAtResults
impl ToArchetype<Mesh3D> for LatestAtResults
source§fn to_archetype(
&self,
resolver: &PromiseResolver
) -> PromiseResult<Result<Mesh3D, QueryError>>
fn to_archetype( &self, resolver: &PromiseResolver ) -> PromiseResult<Result<Mesh3D, QueryError>>
re_types_core::Archetype
. Read moreimpl StructuralPartialEq for Mesh3D
Auto Trait Implementations§
impl Freeze for Mesh3D
impl RefUnwindSafe for Mesh3D
impl Send for Mesh3D
impl Sync for Mesh3D
impl Unpin for Mesh3D
impl UnwindSafe for Mesh3D
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
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 more