diff --git a/Cargo.lock b/Cargo.lock index bcec9e2be..a617c208b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4098,9 +4098,9 @@ checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wavefront_rs" -version = "2.0.0-alpha.1" +version = "2.0.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad6ae8f49ee35d8afba6b30d1714f9043bfd2d1ef650897cb6405a600609e9a1" +checksum = "c2f237e2271c3f9ccc633ee16918789514fd5a823bf62ddce21f8a730a1d9930" [[package]] name = "wayland-client" diff --git a/crates/fj-export/Cargo.toml b/crates/fj-export/Cargo.toml index 632f7d3c2..f20683586 100644 --- a/crates/fj-export/Cargo.toml +++ b/crates/fj-export/Cargo.toml @@ -17,4 +17,4 @@ fj-math.workspace = true thiserror = "1.0.40" threemf = "0.4.0" stl = "0.2.1" -wavefront_rs = "=2.0.0-alpha.1" +wavefront_rs = "=2.0.0-beta.1" diff --git a/crates/fj-export/src/lib.rs b/crates/fj-export/src/lib.rs index df7bba312..cf0dee687 100644 --- a/crates/fj-export/src/lib.rs +++ b/crates/fj-export/src/lib.rs @@ -14,7 +14,7 @@ #![warn(missing_docs)] -use std::{fs::File, io::Write, path::Path}; +use std::{fs::File, path::Path}; use thiserror::Error; @@ -128,44 +128,44 @@ fn export_obj(mesh: &Mesh>, path: &Path) -> Result<(), Error> { for (cnt, t) in mesh.triangles().enumerate() { // write each point of the triangle for v in t.inner.points() { - wavefront_rs::obj::writer::Writer::write( + wavefront_rs::obj::writer::Writer { auto_newline: true } + .write( + &mut f, + &wavefront_rs::obj::entity::Entity::Vertex { + x: v.x.into_f64(), + y: v.y.into_f64(), + z: v.z.into_f64(), + w: None, + }, + ) + .or(Err(Error::OBJ))?; + } + + // write the triangle + wavefront_rs::obj::writer::Writer { auto_newline: true } + .write( &mut f, - &wavefront_rs::obj::entity::Entity::Vertex { - x: v.x.into_f64(), - y: v.y.into_f64(), - z: v.z.into_f64(), - w: None, + &wavefront_rs::obj::entity::Entity::Face { + vertices: vec![ + wavefront_rs::obj::entity::FaceVertex { + vertex: (cnt * 3 + 1) as i64, + texture: None, + normal: None, + }, + wavefront_rs::obj::entity::FaceVertex { + vertex: (cnt * 3 + 2) as i64, + texture: None, + normal: None, + }, + wavefront_rs::obj::entity::FaceVertex { + vertex: (cnt * 3 + 3) as i64, + texture: None, + normal: None, + }, + ], }, ) .or(Err(Error::OBJ))?; - f.write_all(b"\n")?; - } - - // write the triangle - wavefront_rs::obj::writer::Writer::write( - &mut f, - &wavefront_rs::obj::entity::Entity::Face { - vertices: vec![ - wavefront_rs::obj::entity::FaceVertex { - vertex: (cnt * 3 + 1) as i64, - texture: None, - normal: None, - }, - wavefront_rs::obj::entity::FaceVertex { - vertex: (cnt * 3 + 2) as i64, - texture: None, - normal: None, - }, - wavefront_rs::obj::entity::FaceVertex { - vertex: (cnt * 3 + 3) as i64, - texture: None, - normal: None, - }, - ], - }, - ) - .or(Err(Error::OBJ))?; - f.write_all(b"\n")?; } Ok(())