Skip to main content

MeshBuilder

Struct MeshBuilder 

Source
pub struct MeshBuilder { /* private fields */ }
Expand description

Reusable builder for a textured mesh at Earth scale.

Vertex layout is the eight-float stride x, y, z, nx, ny, nz, u, v that Geometry3D::CustomTextured consumes.

Implementations§

Source§

impl MeshBuilder

Source

pub fn new() -> Self

Source

pub fn with_capacity(vertices: usize, triangles: usize) -> Self

Reserves capacity for vertices vertices and triangles triangles.

Source

pub fn set_origin(&mut self, origin: DVec3)

Sets the point subtracted before narrowing to f32.

Source

pub fn clear(&mut self)

Empties the builder while keeping its allocation.

Source

pub fn vertex_capacity(&self) -> usize

Capacity currently held by the vertex buffer, in floats.

Source

pub fn index_capacity(&self) -> usize

Capacity currently held by the index buffer, in indices.

Source

pub fn vertex_count(&self) -> usize

Source

pub fn triangle_count(&self) -> usize

Source

pub fn index_count(&self) -> usize

Number of indices appended so far, for batching index ranges.

Source

pub fn is_empty(&self) -> bool

Source

pub fn push_vertex( &mut self, position: DVec3, normal: [f32; 3], uv: (f32, f32), ) -> u32

Appends a vertex at world scale, relative to the builder origin, and returns its local index.

Source

pub fn push_triangle(&mut self, a: u32, b: u32, c: u32)

Appends a triangle. Degenerate index triplets are dropped.

Source

pub fn push_quad(&mut self, a: u32, b: u32, c: u32, d: u32)

Appends a quad as two triangles.

Source

pub fn push_grid( &mut self, heights: &[DVec3], cols: usize, rows: usize, uv_rect: (f32, f32, f32, f32), )

Appends a terrain patch from a height field.

heights is a (cols x rows) grid of world-space positions in row-major order; uv_rect is the tile’s sub-rectangle of the source image, expressed in the quad’s own 0..1 space and mapped across the patch. The patch is two triangles per grid cell.

Source

pub fn push_grid_with_normals( &mut self, positions: &[DVec3], normals: &[[f32; 3]], cols: usize, rows: usize, uv_rect: (f32, f32, f32, f32), )

Appends a grid patch with explicit per-vertex normals.

Use this for relief, where the surface normal is derived from the height field rather than being the sphere radial.

Source

pub fn push_wall( &mut self, top: &[DVec3], bottom: &[DVec3], uv_rect: (f32, f32, f32, f32), )

Appends a vertical relief wall from a top edge to a bottom edge.

This is the side skirt that hides the gap between a raised terrain tile and the tile behind it. top and bottom are equal-length edge points.

Source

pub fn push_skirt( &mut self, top: &[DVec3], bottom: &[DVec3], uvs: &[(f32, f32)], )

Appends a boundary skirt between a top edge and an extruded bottom edge.

Skirts occlude crack seams between adjacent tiles of differing LOD levels. top and bottom must have equal lengths >= 2, and uvs must match top.len(). The triangles are wound counter-clockwise when viewed from the outside with outward normals.

Source

pub fn push_grid_perimeter_skirts( &mut self, grid_positions: &[DVec3], cols: usize, rows: usize, skirt_depth: f64, uv_rect: (f32, f32, f32, f32), )

Appends vertical skirts along all four perimeter edges of a terrain grid (South, East, North, West).

grid_positions contains cols * rows vertices in row-major order (row 0 is South, col 0 is West). skirt_depth specifies the vertical extrusion distance downward along the -Z axis (or radial inward). uv_rect specifies (u0, v0, u1, v1) texture coordinates.

Source

pub fn push_building( &mut self, base: DVec3, half: (f64, f64), height: f64, facade_uv: (f32, f32, f32, f32), roof_uv: (f32, f32, f32, f32), )

Appends a building prism plus its roof cap.

base is the footprint centre on the ground, half the footprint half extents in the local X and Z axes, and height the extrusion. Walls use the side of facade_uv and the roof uses roof_uv, both sub-rectangles of one atlas.

Source

pub fn finish(&self) -> Option<Geometry3D>

Freezes the builder into a scene geometry, narrowing to f32 after the RTC subtraction. Returns None when nothing was appended.

Source

pub fn push_rte_vertex( &mut self, position: DVec3, normal: [f32; 3], uv: (f32, f32), ) -> (u32, [f32; 3], [f32; 3])

Appends a vertex storing double-single high and low components without RTC origin subtraction. Returns the vertex index along with the split high and low position triples.

Trait Implementations§

Source§

impl Clone for MeshBuilder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MeshBuilder

Source§

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

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

impl Default for MeshBuilder

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoInitialState<T> for T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,