Crate schematic_mesher

Crate schematic_mesher 

Source
Expand description

§Schematic Mesher

A Rust library for generating 3D meshes from Minecraft schematics.

§Overview

This library takes a Minecraft schematic and resource pack as input, and produces a 3D mesh (GLB/glTF) with a texture atlas as output.

§Quick Start

use schematic_mesher::{load_resource_pack, Mesher, export_glb};

// Load a resource pack
let pack = load_resource_pack("path/to/pack.zip")?;

// Create a mesher
let mesher = Mesher::new(pack);

// Generate mesh from blocks (using BlockSource trait)
let output = mesher.mesh(&my_block_source)?;

// Export to GLB
let glb_bytes = export_glb(&output)?;

§Library Integration

For integrating with existing block storage (like Nucleation), implement the BlockSource trait or use mesh_blocks() with an iterator of blocks:

use schematic_mesher::{Mesher, InputBlock, BlockPosition, BoundingBox};

// Create blocks from your schematic
let blocks: Vec<(BlockPosition, InputBlock)> = /* ... */;
let bounds = BoundingBox::new([0, 0, 0], [16, 16, 16]);

// Mesh with references
let output = mesher.mesh_blocks(
    blocks.iter().map(|(pos, block)| (*pos, block)),
    bounds
)?;

Re-exports§

pub use error::MesherError;
pub use error::Result;
pub use types::Direction;
pub use types::Axis;
pub use types::BlockPosition;
pub use types::BoundingBox;
pub use types::InputBlock;
pub use types::BlockSource;
pub use resource_pack::ResourcePack;
pub use resource_pack::BlockModel;
pub use resource_pack::ModelElement;
pub use resource_pack::BlockstateDefinition;
pub use mesher::Mesher;
pub use mesher::MesherConfig;
pub use mesher::MesherOutput;
pub use mesher::Mesh;
pub use mesher::Vertex;
pub use mesher::TintColors;
pub use mesher::TintProvider;
pub use atlas::TextureAtlas;
pub use export::gltf::export_glb;
pub use export::obj::export_obj;
pub use export::obj::ObjExport;
pub use export::raw::export_raw;
pub use export::raw::RawMeshData;

Modules§

atlas
Texture atlas building.
error
Error types for the schematic mesher.
export
Mesh export formats.
mesher
Mesh generation from block models.
resolver
Block state and model resolution.
resource_pack
Resource pack loading and parsing.
types
Shared types used throughout the library.

Functions§

load_resource_pack
Load a resource pack from a file path (ZIP or directory).
load_resource_pack_from_bytes
Load a resource pack from bytes (for WASM compatibility).