Skip to content
/ weldr Public

A Rust library and command-line tool to manage LDraw files (.ldr)

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE2
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

djeedai/weldr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👨‍🏭 weldr, the link between your favorite building blocks and Rust 🧱

License: MIT or Apache 2.0 CI Coverage Status Minimum rustc version

weldr is a Rust library and command-line tool to manipulate LDraw files (format specification), which are files describing 3D models of LEGO®* pieces.

This repository is a Cargo workspace composed of the following packages:

Package Version Description Path
📦 weldr Crates.io Version The weldr Rust library lib/
📦 weldr-bin Crates.io Version The ⚙ weldr command-line tool bin/weldr/

Library

The weldr library allows building command-line tools and applications leveraging the fantastic database of pieces contributed by the LDraw community.

Parse the content of a single LDraw file containing 2 commands:

use weldr::*;

#[test]
fn test_weldr() {
  let cmd0 = CommandType::Comment(
    CommentCmd{ text: "this is a comment".to_string() }
  );
  let cmd1 = CommandType::Line(LineCmd{
    color: 16,
    vertices: [
      Vec3{ x: 0.0, y: 0.0, z: 0.0 },
      Vec3{ x: 1.0, y: 1.0, z: 1.0 }
    ]
  });
  assert_eq!(
    parse_raw(b"0 this is a comment\n2 16 0 0 0 1 1 1"),
    vec![cmd0, cmd1]
  );
}

Command-line tool

The ⚙ weldr command-line tool is an executable to manipulate LDraw files and convert them to other formats (currently: glTF 2.0 only).

Convert an LDraw file to a glTF 2.0 file:

weldr convert gltf 5-8cyli.dat --output 5-8cyli.gltf

The format is:

weldr <COMMAND> <INPUT>

You can get the list of commands with weldr --help. Currently only the convert command is implemented for the gltf (glTF 2.0) format.

weldr convert [OPTIONS] gltf <INPUT>

The official LDraw catalog of parts is available at https://library.ldraw.org/library/updates/complete.zip. When using it, use the --catalog-path to specify the location where it was downloaded, to allow ⚙ weldr to resolve files and all their sub-file references. By default the current working directory is used.

Copyrights

LDraw™ is a trademark owned and licensed by the Estate of James Jessiman, which does not sponsor, endorse, or authorize this project.

*LEGO® is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this project.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.