mesh3d

Mesh / vertex-format primitives for 3D rendering (extracted from kagura)

moon add mizchi/mesh3d@0.2.0
Download zip
Author
Version
0.2.0
License
Apache-2.0
Last updated
2 months ago
Downloads
190
README

#
Mesh3D

pub struct Mesh3D {
vertex_data : Array[Double]
indices : Array[Int]
bounds : MeshBounds3D
format : VertexFormat
} derive(
Debug
)

impl Show for Mesh3D

#
Mesh3D::bounds

fn Mesh3D::bounds(self : Mesh3D) -> MeshBounds3D

#
Mesh3D::box

fn Mesh3D::box(width : Double, height : Double, depth : Double) -> Mesh3D

Box mesh with given width (X), height (Y), depth (Z), bottom at y=0. 5 faces (no bottom face): front, back, right, left, top.

#
Mesh3D::cube

fn Mesh3D::cube(size : Double) -> Mesh3D

Unit cube centered at origin with side length size.

#
Mesh3D::from_obj

fn Mesh3D::from_obj(source : String) -> Mesh3D

Parse a Wavefront OBJ string into a Mesh3D. Supports v, vn, vt, f directives. Handles scientific notation, N-gon triangulation, negative indices, and flat normal generation.

#
Mesh3D::new

fn Mesh3D::new(vertex_data : Array[Double], indices : Array[Int]) -> Mesh3D

Create a Mesh3D with standard_3d format (stride 8).

#
Mesh3D::new_with_format

fn Mesh3D::new_with_format(vertex_data : Array[Double], indices : Array[Int], format : VertexFormat) -> Mesh3D

Create a Mesh3D with an explicit vertex format.

#
Mesh3D::plane

fn Mesh3D::plane(width : Double, depth : Double, subdivisions? : Int) -> Mesh3D

XZ plane centered at origin with given width and depth.

#
Mesh3D::sphere

fn Mesh3D::sphere(radius : Double, segments : Int, rings : Int) -> Mesh3D

UV sphere with given radius, number of horizontal segments, and vertical rings.

#
Mesh3D::triangle_count

fn Mesh3D::triangle_count(self : Mesh3D) -> Int

#
Mesh3D::vertex_count

fn Mesh3D::vertex_count(self : Mesh3D) -> Int

#
MeshBounds3D

pub struct MeshBounds3D {
min_x : Double
min_y : Double
min_z : Double
max_x : Double
max_y : Double
max_z : Double
} derive(
Debug
)

#
VertexAttribute

pub enum VertexAttribute {
Position3
Normal3
TexCoord2
Joints4
Weights4
Tangent4
Color4
} derive(Eq,
Debug
)

Vertex attribute types for 3D mesh data.

#
VertexAttribute::size

fn VertexAttribute::size(self : VertexAttribute) -> Int

Number of float components for a vertex attribute.

#
VertexFormat

pub struct VertexFormat {
attributes : Array[VertexAttribute]
} derive(
Debug
)

Describes the layout of vertex data as an ordered list of attributes.

#
VertexFormat::has

fn VertexFormat::has(self : VertexFormat, target : VertexAttribute) -> Bool

Whether this format contains the given attribute.

#
VertexFormat::offset_of

fn VertexFormat::offset_of(self : VertexFormat, target : VertexAttribute) -> Int

Byte offset of an attribute in the vertex layout. Returns -1 if the attribute is not present.

#
VertexFormat::skinned_3d

fn VertexFormat::skinned_3d() -> VertexFormat

Skinned 3D format: position(3) + normal(3) + uv(2) + joints(4) + weights(4) = stride 16.

#
VertexFormat::standard_3d

fn VertexFormat::standard_3d() -> VertexFormat

Standard 3D format: position(3) + normal(3) + uv(2) = stride 8.

#
VertexFormat::stride

fn VertexFormat::stride(self : VertexFormat) -> Int

Total number of floats per vertex.

#
push_quad

fn push_quad(indices : Array[Int], base : Int) -> Unit

Push two triangles (a quad) from 4 consecutive vertices starting at base. Winding: base, base+1, base+2, base+2, base+3, base.

#
push_vertex

fn push_vertex(data : Array[Double], px : Double, py : Double, pz : Double, nx : Double, ny : Double, nz : Double, u : Double, v : Double) -> Unit

#
vertex3d_stride

let vertex3d_stride : Int

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io