{"id":22802679,"url":"https://github.com/EricFrancis12/bevy_mesh_obj","last_synced_at":"2025-08-10T03:31:22.251Z","repository":{"id":267379274,"uuid":"901068050","full_name":"EricFrancis12/bevy_mesh_obj","owner":"EricFrancis12","description":"Parse Wavefront .obj files into Bevy Meshes","archived":false,"fork":false,"pushed_at":"2025-01-10T17:16:06.000Z","size":294,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T18:07:53.724Z","etag":null,"topics":["bevy","game-development","obj","wavefront"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EricFrancis12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-10T01:32:59.000Z","updated_at":"2025-01-12T04:06:49.000Z","dependencies_parsed_at":"2024-12-10T02:27:00.312Z","dependency_job_id":"a1a6acc8-f849-4de2-879c-ca4a4a14808c","html_url":"https://github.com/EricFrancis12/bevy_mesh_obj","commit_stats":null,"previous_names":["ericfrancis12/bevy-mesh-obj"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EricFrancis12/bevy_mesh_obj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricFrancis12%2Fbevy_mesh_obj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricFrancis12%2Fbevy_mesh_obj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricFrancis12%2Fbevy_mesh_obj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricFrancis12%2Fbevy_mesh_obj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EricFrancis12","download_url":"https://codeload.github.com/EricFrancis12/bevy_mesh_obj/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricFrancis12%2Fbevy_mesh_obj/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269672003,"owners_count":24457110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy","game-development","obj","wavefront"],"created_at":"2024-12-12T09:06:56.524Z","updated_at":"2025-08-10T03:31:22.234Z","avatar_url":"https://github.com/EricFrancis12.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bevy Mesh Obj\n\nThis crate provides utilities to parse Wavefront `.obj` files, handle 3D object data, and generate [bevy](https://github.com/bevyengine/bevy) meshes from them.\n\n## Features\n\n- **Parsing `.obj` files:** Parse `.obj` files into an internal representation of vertices, normals, texture coordinates, faces, and smoothing information.\n- **Handle 3D object data:** The crate includes types for representing vertices (`Vertex`), normals (`Normal`), texture coordinates (`UVTexture`), smoothing groups (`Smoothing`), and faces (`Face`).\n- **Generate meshes:** Create Bevy `Mesh` objects from parsed `.obj` files, which can be used in 3D rendering applications.\n\n\n## Installation\n\nAdd the **bevy_mesh_obj** crate: \n\n```bash\ncargo add bevy_mesh_obj\n```\n\n## Limitations\n\nTo ensure proper functionality, all .obj files must NOT contain any shared vertecies, and all objects must be triangulated (all faces must be triangles). See `assets/wall_with_door_gap.blend` for an example how to achieve this in Blender before exporting to .obj format.\n\n## Usage\n\n### Parsing .obj files\n\nThe crate provides several methods to parse .obj files either from a string or a file. Below are examples of how to use the provided functions.\n\n#### Parse from a file\n```rust\nlet obj: Obj3D = Obj3D::parse_single(\"path/to/file.obj\").unwrap();\n```\n\n#### Parse multiple objects from a file\n\n```rust\nlet objs: Vec\u003cObj3D\u003e = Obj3D::parse(\"path/to/file.obj\").unwrap();\n```\n\n#### Parse the nth object\n\n```rust\nlet obj: Obj3D = Obj3D::parse_n(\"path/to/file.obj\", 2).unwrap();\n```\n\n#### Parse the first object\n\n```rust\nlet obj: Obj3D = Obj3D::parse_first(\"path/to/file.obj\").unwrap();\n```\n\n### Writing to a file\n\nYou can write the Obj3D object back to an .obj file:\n\n```rust\nlet obj: Obj3D = Obj3D::parse_single(\"path/to/file.obj\").unwrap();\nobj.write_to_file(\"path/to/output.obj\").unwrap();\n```\n\n### Generating Bevy Mesh\n\nYou can use the `mesh_from_obj!()` macro to generate a Bevy `Mesh` directly from an .obj file, that you can use in your game or application:\n\n```rust\nuse bevy::prelude::Mesh;\nuse bevy_mesh_obj::mesh_from_obj;\n\nfn new_mesh() -\u003e Mesh {\n    mesh_from_obj!(\"path/to/file.obj\")\n}\n```\n\n## File Format\n\nThis crate handles parsing the following tokens from an .obj file:\n\n- `o`: Object name\n- `v`: Vertex position (x, y, z)\n- `vn`: Vertex normal (x, y, z)\n- `vt`: Texture coordinates (u, v)\n- `s`: Smoothing group\n- `f`: Face definitions, which are made up of indices to vertices, normals, and texture coordinates\n\nHere is an example of a basic .obj file:\n\n```\n# Name\no Cube\n\n# Vertices\nv 1.0 1.0 1.0\nv -1.0 1.0 1.0\nv -1.0 -1.0 1.0\nv 1.0 -1.0 1.0\nv 1.0 1.0 -1.0\nv -1.0 1.0 -1.0\nv -1.0 -1.0 -1.0\nv 1.0 -1.0 -1.0\n\n# Normals\nvn 0.0 0.0 1.0\nvn 0.0 0.0 -1.0\nvn 1.0 0.0 0.0\nvn -1.0 0.0 0.0\nvn 0.0 1.0 0.0\nvn 0.0 -1.0 0.0\n\n# Texture Coordinates\nvt 0.0 0.0\nvt 1.0 0.0\nvt 1.0 1.0\nvt 0.0 1.0\n\n# Faces (using 1-based index notation)\nf 1/1/1 2/2/1 3/3/1 4/4/1  # Front face\nf 5/1/2 6/2/2 7/3/2 8/4/2  # Back face\nf 1/1/3 2/2/3 6/3/5 5/4/5  # Top face\nf 4/1/5 3/2/5 7/3/5 8/4/5  # Bottom face\nf 1/1/4 4/2/4 8/3/4 5/4/4  # Right face\nf 2/1/6 3/2/6 7/3/6 6/4/6  # Left face\n```\n\n- `o` Cube defines the object name.\n- `v` lines define vertices.\n- `vn` lines define vertex normals.\n- `vt` lines define texture coordinates.\n- `f` lines define faces using vertex/texture/normal indices.\n\n## License\n\n[MIT](https://mit-license.org)\n\n\n## Contributing\nI would be more than happy to accept your contribution if you have a valuable addition to this project. Please fork this repository, create a branch, and submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEricFrancis12%2Fbevy_mesh_obj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEricFrancis12%2Fbevy_mesh_obj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEricFrancis12%2Fbevy_mesh_obj/lists"}