Skip to main content

VectorMeshData

Struct VectorMeshData 

Source
pub struct VectorMeshData {
Show 20 fields pub positions: Vec<[f64; 3]>, pub colors: Vec<[f32; 4]>, pub normals: Vec<[f32; 3]>, pub indices: Vec<u32>, pub render_mode: VectorRenderMode, pub line_distances: Vec<f32>, pub line_normals: Vec<[f32; 2]>, pub line_cap_joins: Vec<f32>, pub line_params: [f32; 4], pub circle_instances: Vec<CircleInstanceData>, pub heatmap_points: Vec<[f64; 4]>, pub heatmap_intensity: f32, pub fill_translate: [f32; 2], pub fill_opacity: f32, pub fill_antialias: bool, pub fill_outline_color: [f32; 4], pub fill_pattern: Option<Arc<PatternImage>>, pub fill_pattern_uvs: Vec<[f32; 2]>, pub line_pattern: Option<Arc<PatternImage>>, pub line_pattern_uvs: Vec<[f32; 2]>,
}
Expand description

CPU-side mesh data for vector rendering, ready for GPU upload.

Produced by VectorLayer::tessellate and consumed by renderers. One instance per visible vector layer per frame.

All positions are in Web Mercator world space (f64 for precision). The renderer converts them to camera-relative f32 before uploading.

Fields§

§positions: Vec<[f64; 3]>

Vertex positions in world space [x, y, z] (f64 for precision).

§colors: Vec<[f32; 4]>

Per-vertex colour [r, g, b, a] (0–1 range, linear).

§normals: Vec<[f32; 3]>

Per-vertex surface normals [nx, ny, nz].

Empty for flat geometry (fills, lines, circles). Populated for 3-D geometry such as fill-extrusions where per-face normals are needed for proper lighting. When non-empty, the length must equal positions.len().

§indices: Vec<u32>

Triangle indices into positions / colors / normals.

§render_mode: VectorRenderMode

High-level render family that produced this mesh.

Renderers use this to select the appropriate GPU pipeline (e.g. lit fill-extrusion vs. flat fill).

§line_distances: Vec<f32>

Per-vertex distance along the polyline centreline (meters in world space). Non-empty only for VectorRenderMode::Line. The GPU line shader uses this for dash-pattern evaluation.

§line_normals: Vec<[f32; 2]>

Per-vertex extrusion normal [nx, ny] (unit-length direction perpendicular to the line centreline). Non-empty only for VectorRenderMode::Line.

§line_cap_joins: Vec<f32>

Per-vertex cap/join flag. 1.0 for round cap/join fan vertices, 0.0 for ribbon body and non-round cap/join vertices. The GPU line shader uses this to switch between linear edge AA and SDF circle-based AA. Non-empty only for VectorRenderMode::Line.

§line_params: [f32; 4]

Line style parameters [dash_length, gap_length, half_width, cap_round]. Uniform across all vertices in a single mesh. cap_round is 1.0 for round caps and 0.0 for butt caps.

§circle_instances: Vec<CircleInstanceData>

Per-instance circle data: [center_x, center_y, center_z, radius] in world space (f64 centre, f32 radius).

§heatmap_points: Vec<[f64; 4]>

Per-point heatmap data: [x, y, weight, radius] in world space.

§heatmap_intensity: f32

Heatmap intensity multiplier.

§fill_translate: [f32; 2]

Fill-layer pixel translate offset [tx, ty].

§fill_opacity: f32

Fill-layer opacity (separate from vertex alpha).

§fill_antialias: bool

Whether fill edges should be antialiased.

§fill_outline_color: [f32; 4]

Outline colour override for fill outlines. When [0,0,0,0], the outline uses the fill colour.

§fill_pattern: Option<Arc<PatternImage>>

Optional pattern image for fill-pattern rendering.

When present, the renderer creates a repeating texture and uses fill_pattern_uvs to sample it. Non-empty only for VectorRenderMode::Fill with a pattern set.

§fill_pattern_uvs: Vec<[f32; 2]>

Per-vertex pattern UV coordinates [u, v].

Populated only when fill_pattern is Some. The coordinates are in pattern-tile units: (0,0) is the pattern origin, (1,1) is one full pattern repetition. Values outside [0,1] repeat via the GPU’s Repeat address mode.

§line_pattern: Option<Arc<PatternImage>>

Optional pattern image for line-pattern rendering.

When present, the renderer creates a repeating texture and uses line_pattern_uvs to sample it. Non-empty only for VectorRenderMode::Line with a pattern set.

§line_pattern_uvs: Vec<[f32; 2]>

Per-vertex pattern UV coordinates [u, v] for line-pattern rendering.

U maps along the line centreline (distance / pattern_width), V maps across the line width (0.0 = left edge, 1.0 = right edge). Values outside [0,1] on the U axis repeat via the GPU’s Repeat address mode.

Implementations§

Source§

impl VectorMeshData

Source

pub fn is_empty(&self) -> bool

Whether the mesh contains no geometry.

Source

pub fn vertex_count(&self) -> usize

Number of vertices.

Source

pub fn index_count(&self) -> usize

Number of triangle indices (always a multiple of 3 in valid meshes).

Source

pub fn triangle_count(&self) -> usize

Number of triangles.

Source

pub fn has_normals(&self) -> bool

Whether this mesh carries per-vertex normals for lighting.

Source

pub fn merge(&mut self, other: &VectorMeshData)

Append another mesh into this one, adjusting indices.

Source

pub fn clear(&mut self)

Remove all vertices and indices.

Trait Implementations§

Source§

impl Clone for VectorMeshData

Source§

fn clone(&self) -> VectorMeshData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VectorMeshData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VectorMeshData

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.