pub struct SurfaceMesh { /* private fields */ }Expand description
A surface mesh structure (triangular or polygonal).
Implementations§
Source§impl SurfaceMesh
impl SurfaceMesh
Source§impl SurfaceMesh
impl SurfaceMesh
Sourcepub fn add_vertex_scalar_quantity(
&mut self,
name: impl Into<String>,
values: Vec<f32>,
) -> &mut Self
pub fn add_vertex_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self
Adds a vertex scalar quantity to this mesh.
Sourcepub fn add_face_scalar_quantity(
&mut self,
name: impl Into<String>,
values: Vec<f32>,
) -> &mut Self
pub fn add_face_scalar_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, ) -> &mut Self
Adds a face scalar quantity to this mesh.
Sourcepub fn add_vertex_color_quantity(
&mut self,
name: impl Into<String>,
colors: Vec<Vec3>,
) -> &mut Self
pub fn add_vertex_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self
Adds a vertex color quantity to this mesh (RGB, alpha defaults to 1.0).
Sourcepub fn add_vertex_color_quantity_with_alpha(
&mut self,
name: impl Into<String>,
colors: Vec<Vec4>,
) -> &mut Self
pub fn add_vertex_color_quantity_with_alpha( &mut self, name: impl Into<String>, colors: Vec<Vec4>, ) -> &mut Self
Adds a vertex color quantity with explicit per-vertex RGBA alpha values.
Sourcepub fn add_face_color_quantity(
&mut self,
name: impl Into<String>,
colors: Vec<Vec3>,
) -> &mut Self
pub fn add_face_color_quantity( &mut self, name: impl Into<String>, colors: Vec<Vec3>, ) -> &mut Self
Adds a face color quantity to this mesh (RGB, alpha defaults to 1.0).
Sourcepub fn add_face_color_quantity_with_alpha(
&mut self,
name: impl Into<String>,
colors: Vec<Vec4>,
) -> &mut Self
pub fn add_face_color_quantity_with_alpha( &mut self, name: impl Into<String>, colors: Vec<Vec4>, ) -> &mut Self
Adds a face color quantity with explicit per-face RGBA alpha values.
Sourcepub fn add_vertex_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec3>,
) -> &mut Self
pub fn add_vertex_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self
Adds a vertex vector quantity to this mesh.
Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.
Sourcepub fn add_face_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec3>,
) -> &mut Self
pub fn add_face_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec3>, ) -> &mut Self
Adds a face vector quantity to this mesh.
Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.
Sourcepub fn add_vertex_parameterization_quantity(
&mut self,
name: impl Into<String>,
coords: Vec<Vec2>,
) -> &mut Self
pub fn add_vertex_parameterization_quantity( &mut self, name: impl Into<String>, coords: Vec<Vec2>, ) -> &mut Self
Adds a vertex parameterization (UV) quantity to this mesh.
Sourcepub fn add_corner_parameterization_quantity(
&mut self,
name: impl Into<String>,
coords: Vec<Vec2>,
) -> &mut Self
pub fn add_corner_parameterization_quantity( &mut self, name: impl Into<String>, coords: Vec<Vec2>, ) -> &mut Self
Adds a corner parameterization (UV) quantity to this mesh.
Sourcepub fn add_vertex_intrinsic_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec2>,
basis_x: Vec<Vec3>,
basis_y: Vec<Vec3>,
) -> &mut Self
pub fn add_vertex_intrinsic_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, basis_x: Vec<Vec3>, basis_y: Vec<Vec3>, ) -> &mut Self
Adds a vertex intrinsic vector quantity with explicit tangent basis.
Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.
Sourcepub fn add_vertex_intrinsic_vector_quantity_auto(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec2>,
) -> &mut Self
pub fn add_vertex_intrinsic_vector_quantity_auto( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, ) -> &mut Self
Adds a vertex intrinsic vector quantity with auto-computed tangent basis.
Sourcepub fn add_face_intrinsic_vector_quantity(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec2>,
basis_x: Vec<Vec3>,
basis_y: Vec<Vec3>,
) -> &mut Self
pub fn add_face_intrinsic_vector_quantity( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, basis_x: Vec<Vec3>, basis_y: Vec<Vec3>, ) -> &mut Self
Adds a face intrinsic vector quantity with explicit tangent basis.
Arrow length and radius are auto-scaled based on mesh extent and vector magnitudes.
Sourcepub fn add_face_intrinsic_vector_quantity_auto(
&mut self,
name: impl Into<String>,
vectors: Vec<Vec2>,
) -> &mut Self
pub fn add_face_intrinsic_vector_quantity_auto( &mut self, name: impl Into<String>, vectors: Vec<Vec2>, ) -> &mut Self
Adds a face intrinsic vector quantity with auto-computed tangent basis.
Sourcepub fn add_one_form_quantity(
&mut self,
name: impl Into<String>,
values: Vec<f32>,
orientations: Vec<bool>,
) -> &mut Self
pub fn add_one_form_quantity( &mut self, name: impl Into<String>, values: Vec<f32>, orientations: Vec<bool>, ) -> &mut Self
Adds a one-form quantity to this mesh.
A one-form assigns a scalar value to each edge, rendered as arrows
at edge midpoints. The orientations array specifies the sign convention
for each edge (true = canonical low→high vertex direction).
Arrow length and radius are auto-scaled based on mesh extent and edge flow magnitudes.
Sourcepub fn active_vertex_scalar_quantity(&self) -> Option<&MeshVertexScalarQuantity>
pub fn active_vertex_scalar_quantity(&self) -> Option<&MeshVertexScalarQuantity>
Returns the currently active vertex scalar quantity, if any.
Sourcepub fn active_face_scalar_quantity(&self) -> Option<&MeshFaceScalarQuantity>
pub fn active_face_scalar_quantity(&self) -> Option<&MeshFaceScalarQuantity>
Returns the currently active face scalar quantity, if any.
Sourcepub fn active_vertex_color_quantity(&self) -> Option<&MeshVertexColorQuantity>
pub fn active_vertex_color_quantity(&self) -> Option<&MeshVertexColorQuantity>
Returns the currently active vertex color quantity, if any.
Sourcepub fn active_face_color_quantity(&self) -> Option<&MeshFaceColorQuantity>
pub fn active_face_color_quantity(&self) -> Option<&MeshFaceColorQuantity>
Returns the currently active face color quantity, if any.
Sourcepub fn active_vertex_vector_quantity(&self) -> Option<&MeshVertexVectorQuantity>
pub fn active_vertex_vector_quantity(&self) -> Option<&MeshVertexVectorQuantity>
Returns the currently active vertex vector quantity (immutable), if any.
Sourcepub fn active_vertex_vector_quantity_mut(
&mut self,
) -> Option<&mut MeshVertexVectorQuantity>
pub fn active_vertex_vector_quantity_mut( &mut self, ) -> Option<&mut MeshVertexVectorQuantity>
Returns the currently active vertex vector quantity (mutable), if any.
Sourcepub fn active_face_vector_quantity(&self) -> Option<&MeshFaceVectorQuantity>
pub fn active_face_vector_quantity(&self) -> Option<&MeshFaceVectorQuantity>
Returns the currently active face vector quantity (immutable), if any.
Sourcepub fn active_face_vector_quantity_mut(
&mut self,
) -> Option<&mut MeshFaceVectorQuantity>
pub fn active_face_vector_quantity_mut( &mut self, ) -> Option<&mut MeshFaceVectorQuantity>
Returns the currently active face vector quantity (mutable), if any.
Sourcepub fn face_centroids(&self) -> Vec<Vec3>
pub fn face_centroids(&self) -> Vec<Vec3>
Computes face centroids (average of face vertices).
Sourcepub fn active_vertex_parameterization_quantity(
&self,
) -> Option<&MeshVertexParameterizationQuantity>
pub fn active_vertex_parameterization_quantity( &self, ) -> Option<&MeshVertexParameterizationQuantity>
Returns the currently active vertex parameterization quantity, if any.
Sourcepub fn active_corner_parameterization_quantity(
&self,
) -> Option<&MeshCornerParameterizationQuantity>
pub fn active_corner_parameterization_quantity( &self, ) -> Option<&MeshCornerParameterizationQuantity>
Returns the currently active corner parameterization quantity, if any.
Sourcepub fn active_vertex_intrinsic_vector_quantity(
&self,
) -> Option<&MeshVertexIntrinsicVectorQuantity>
pub fn active_vertex_intrinsic_vector_quantity( &self, ) -> Option<&MeshVertexIntrinsicVectorQuantity>
Returns the currently active vertex intrinsic vector quantity (immutable), if any.
Sourcepub fn active_vertex_intrinsic_vector_quantity_mut(
&mut self,
) -> Option<&mut MeshVertexIntrinsicVectorQuantity>
pub fn active_vertex_intrinsic_vector_quantity_mut( &mut self, ) -> Option<&mut MeshVertexIntrinsicVectorQuantity>
Returns the currently active vertex intrinsic vector quantity (mutable), if any.
Sourcepub fn active_face_intrinsic_vector_quantity(
&self,
) -> Option<&MeshFaceIntrinsicVectorQuantity>
pub fn active_face_intrinsic_vector_quantity( &self, ) -> Option<&MeshFaceIntrinsicVectorQuantity>
Returns the currently active face intrinsic vector quantity (immutable), if any.
Sourcepub fn active_face_intrinsic_vector_quantity_mut(
&mut self,
) -> Option<&mut MeshFaceIntrinsicVectorQuantity>
pub fn active_face_intrinsic_vector_quantity_mut( &mut self, ) -> Option<&mut MeshFaceIntrinsicVectorQuantity>
Returns the currently active face intrinsic vector quantity (mutable), if any.
Sourcepub fn active_one_form_quantity(&self) -> Option<&MeshOneFormQuantity>
pub fn active_one_form_quantity(&self) -> Option<&MeshOneFormQuantity>
Returns the currently active one-form quantity (immutable), if any.
Sourcepub fn active_one_form_quantity_mut(
&mut self,
) -> Option<&mut MeshOneFormQuantity>
pub fn active_one_form_quantity_mut( &mut self, ) -> Option<&mut MeshOneFormQuantity>
Returns the currently active one-form quantity (mutable), if any.
Source§impl SurfaceMesh
impl SurfaceMesh
Sourcepub fn new(
name: impl Into<String>,
vertices: Vec<Vec3>,
faces: Vec<Vec<u32>>,
) -> Self
pub fn new( name: impl Into<String>, vertices: Vec<Vec3>, faces: Vec<Vec<u32>>, ) -> Self
Creates a new surface mesh from vertices and polygon faces.
Each face is a variable-length list of vertex indices forming a polygon. Triangles have 3 indices, quads have 4, etc.
Sourcepub fn from_triangles(
name: impl Into<String>,
vertices: Vec<Vec3>,
triangles: Vec<[u32; 3]>,
) -> Self
pub fn from_triangles( name: impl Into<String>, vertices: Vec<Vec3>, triangles: Vec<[u32; 3]>, ) -> Self
Creates a new surface mesh from triangles (convenience method).
This is a convenience method for creating a mesh from triangle data.
Sourcepub fn num_vertices(&self) -> usize
pub fn num_vertices(&self) -> usize
Returns the number of vertices.
Sourcepub fn num_triangles(&self) -> usize
pub fn num_triangles(&self) -> usize
Returns the number of triangles in the triangulation.
Sourcepub fn triangulation(&self) -> &[[u32; 3]]
pub fn triangulation(&self) -> &[[u32; 3]]
Returns the triangulation.
Sourcepub fn face_to_tri_range(&self) -> &[Range<usize>]
pub fn face_to_tri_range(&self) -> &[Range<usize>]
Returns the mapping from face index to triangle range.
Sourcepub fn vertex_normals(&self) -> &[Vec3]
pub fn vertex_normals(&self) -> &[Vec3]
Returns the vertex normals.
Sourcepub fn face_normals(&self) -> &[Vec3]
pub fn face_normals(&self) -> &[Vec3]
Returns the face normals.
Sourcepub fn corner_normals(&self) -> &[Vec3]
pub fn corner_normals(&self) -> &[Vec3]
Returns the corner normals (per triangle vertex).
Sourcepub fn edge_is_real(&self) -> &[Vec3]
pub fn edge_is_real(&self) -> &[Vec3]
Returns the edge_is_real flags for each triangle corner.
For each triangle vertex, this is a Vec3 where:
- x = 1.0 if edge from this vertex to next is real, 0.0 if internal
- y = 1.0 if edge from next to prev is real (always real for middle edge)
- z = 1.0 if edge from prev to this is real, 0.0 if internal
Sourcepub fn update_vertices(&mut self, vertices: Vec<Vec3>)
pub fn update_vertices(&mut self, vertices: Vec<Vec3>)
Updates the vertex positions.
Sourcepub fn update_faces(&mut self, faces: Vec<Vec<u32>>)
pub fn update_faces(&mut self, faces: Vec<Vec<u32>>)
Updates the faces.
Sourcepub fn shade_style(&self) -> ShadeStyle
pub fn shade_style(&self) -> ShadeStyle
Gets the shade style.
Sourcepub fn set_shade_style(&mut self, style: ShadeStyle)
pub fn set_shade_style(&mut self, style: ShadeStyle)
Sets the shade style.
Sourcepub fn edge_width(&self) -> f32
pub fn edge_width(&self) -> f32
Gets the edge width.
Sourcepub fn set_edge_width(&mut self, width: f32)
pub fn set_edge_width(&mut self, width: f32)
Sets the edge width.
Sourcepub fn edge_color(&self) -> Vec4
pub fn edge_color(&self) -> Vec4
Gets the edge color.
Sourcepub fn set_edge_color(&mut self, color: Vec3)
pub fn set_edge_color(&mut self, color: Vec3)
Sets the edge color.
Sourcepub fn show_edges(&self) -> bool
pub fn show_edges(&self) -> bool
Gets whether edges are shown.
Sourcepub fn set_show_edges(&mut self, show: bool)
pub fn set_show_edges(&mut self, show: bool)
Sets whether edges are shown.
Sourcepub fn backface_policy(&self) -> BackfacePolicy
pub fn backface_policy(&self) -> BackfacePolicy
Gets the backface policy.
Sourcepub fn set_backface_policy(&mut self, policy: BackfacePolicy)
pub fn set_backface_policy(&mut self, policy: BackfacePolicy)
Sets the backface policy.
Sourcepub fn backface_color(&self) -> Vec4
pub fn backface_color(&self) -> Vec4
Gets the backface color.
Sourcepub fn set_backface_color(&mut self, color: Vec3)
pub fn set_backface_color(&mut self, color: Vec3)
Sets the backface color.
Sourcepub fn surface_color(&self) -> Vec4
pub fn surface_color(&self) -> Vec4
Gets the surface color.
Sourcepub fn set_surface_color(&mut self, color: Vec3)
pub fn set_surface_color(&mut self, color: Vec3)
Sets the surface color.
Sourcepub fn transparency(&self) -> f32
pub fn transparency(&self) -> f32
Gets the transparency (0.0 = opaque, 1.0 = fully transparent).
Sourcepub fn set_transparency(&mut self, transparency: f32)
pub fn set_transparency(&mut self, transparency: f32)
Sets the transparency.
Sourcepub fn build_egui_ui(&mut self, ui: &mut Ui, available_materials: &[&str])
pub fn build_egui_ui(&mut self, ui: &mut Ui, available_materials: &[&str])
Builds the egui UI for this surface mesh.
Sourcepub fn init_gpu_resources(
&mut self,
device: &Device,
bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
)
pub fn init_gpu_resources( &mut self, device: &Device, bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, )
Initializes GPU resources for rendering.
Sourcepub fn render_data(&self) -> Option<&SurfaceMeshRenderData>
pub fn render_data(&self) -> Option<&SurfaceMeshRenderData>
Returns the render data if initialized.
Sourcepub fn init_shadow_resources(
&mut self,
device: &Device,
shadow_bind_group_layout: &BindGroupLayout,
light_buffer: &Buffer,
)
pub fn init_shadow_resources( &mut self, device: &Device, shadow_bind_group_layout: &BindGroupLayout, light_buffer: &Buffer, )
Initializes shadow rendering resources.
Creates the bind group needed to render this mesh in the shadow pass.
Sourcepub fn shadow_bind_group(&self) -> Option<&BindGroup>
pub fn shadow_bind_group(&self) -> Option<&BindGroup>
Returns the shadow bind group if initialized.
Sourcepub fn has_shadow_resources(&self) -> bool
pub fn has_shadow_resources(&self) -> bool
Returns whether shadow resources are initialized.
Sourcepub fn init_pick_resources(
&mut self,
device: &Device,
mesh_pick_bind_group_layout: &BindGroupLayout,
camera_buffer: &Buffer,
global_start: u32,
)
pub fn init_pick_resources( &mut self, device: &Device, mesh_pick_bind_group_layout: &BindGroupLayout, camera_buffer: &Buffer, global_start: u32, )
Initializes GPU resources for pick rendering.
Creates the pick uniform buffer, face index mapping buffer, and bind group. The face index buffer maps each GPU triangle to its original polygon face index.
Sourcepub fn pick_bind_group(&self) -> Option<&BindGroup>
pub fn pick_bind_group(&self) -> Option<&BindGroup>
Returns the pick bind group if initialized.
Sourcepub fn update_pick_uniforms(&self, queue: &Queue)
pub fn update_pick_uniforms(&self, queue: &Queue)
Updates pick uniforms (model transform) when the structure is moved.
Sourcepub fn num_triangulation_vertices(&self) -> u32
pub fn num_triangulation_vertices(&self) -> u32
Returns the total number of vertices in the triangulation (for draw calls).
Sourcepub fn update_gpu_buffers(&self, queue: &Queue, color_maps: &ColorMapRegistry)
pub fn update_gpu_buffers(&self, queue: &Queue, color_maps: &ColorMapRegistry)
Updates GPU buffers with current mesh settings.
Trait Implementations§
Source§impl HasQuantities for SurfaceMesh
impl HasQuantities for SurfaceMesh
Source§fn add_quantity(&mut self, quantity: Box<dyn Quantity>)
fn add_quantity(&mut self, quantity: Box<dyn Quantity>)
Source§fn get_quantity_mut(&mut self, name: &str) -> Option<&mut Box<dyn Quantity>>
fn get_quantity_mut(&mut self, name: &str) -> Option<&mut Box<dyn Quantity>>
Source§fn remove_quantity(&mut self, name: &str) -> Option<Box<dyn Quantity>>
fn remove_quantity(&mut self, name: &str) -> Option<Box<dyn Quantity>>
Source§fn quantities(&self) -> &[Box<dyn Quantity>]
fn quantities(&self) -> &[Box<dyn Quantity>]
Source§fn num_quantities(&self) -> usize
fn num_quantities(&self) -> usize
Source§impl Structure for SurfaceMesh
impl Structure for SurfaceMesh
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Any for downcasting.Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
PointCloud”, “SurfaceMesh”).Source§fn bounding_box(&self) -> Option<(Vec3, Vec3)>
fn bounding_box(&self) -> Option<(Vec3, Vec3)>
Source§fn length_scale(&self) -> f32
fn length_scale(&self) -> f32
Source§fn set_transform(&mut self, transform: Mat4)
fn set_transform(&mut self, transform: Mat4)
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Source§fn set_enabled(&mut self, enabled: bool)
fn set_enabled(&mut self, enabled: bool)
Source§fn material(&self) -> &str
fn material(&self) -> &str
Source§fn set_material(&mut self, material: &str)
fn set_material(&mut self, material: &str)
Source§fn draw(&self, _ctx: &mut dyn RenderContext)
fn draw(&self, _ctx: &mut dyn RenderContext)
Source§fn draw_pick(&self, _ctx: &mut dyn RenderContext)
fn draw_pick(&self, _ctx: &mut dyn RenderContext)
Source§fn build_pick_ui(&self, _ui: &dyn Any, _pick: &PickResult)
fn build_pick_ui(&self, _ui: &dyn Any, _pick: &PickResult)
ImGui UI for a picked element.Source§fn clear_gpu_resources(&mut self)
fn clear_gpu_resources(&mut self)
Source§fn center_bounding_box(&mut self)
fn center_bounding_box(&mut self)
Source§fn reset_transform(&mut self)
fn reset_transform(&mut self)
Auto Trait Implementations§
impl Freeze for SurfaceMesh
impl !RefUnwindSafe for SurfaceMesh
impl Send for SurfaceMesh
impl Sync for SurfaceMesh
impl Unpin for SurfaceMesh
impl !UnwindSafe for SurfaceMesh
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> 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>
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