{"id":30524913,"url":"https://github.com/lalabuy948/magicax","last_synced_at":"2025-08-26T21:03:19.718Z","repository":{"id":311761674,"uuid":"1042703948","full_name":"lalabuy948/magicax","owner":"lalabuy948","description":"Elixir toolkit for parsing and generating MagicaVoxel (.vox) files","archived":false,"fork":false,"pushed_at":"2025-08-26T13:06:22.000Z","size":701,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-26T14:50:21.229Z","etag":null,"topics":["elixir","magicavoxel"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lalabuy948.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-08-22T12:46:58.000Z","updated_at":"2025-08-26T13:12:21.000Z","dependencies_parsed_at":"2025-08-26T14:57:14.548Z","dependency_job_id":"ed782008-02a1-46cc-a06f-e18ec10908e4","html_url":"https://github.com/lalabuy948/magicax","commit_stats":null,"previous_names":["lalabuy948/magicax"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lalabuy948/magicax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalabuy948%2Fmagicax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalabuy948%2Fmagicax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalabuy948%2Fmagicax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalabuy948%2Fmagicax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lalabuy948","download_url":"https://codeload.github.com/lalabuy948/magicax/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalabuy948%2Fmagicax/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272243118,"owners_count":24898602,"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-26T02:00:07.904Z","response_time":60,"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":["elixir","magicavoxel"],"created_at":"2025-08-26T21:02:45.740Z","updated_at":"2025-08-26T21:03:19.707Z","avatar_url":"https://github.com/lalabuy948.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MagicaX\n\n[![Hex.pm](https://img.shields.io/hexpm/v/magicax.svg)](https://hex.pm/packages/magicax)\n[![Documentation](https://img.shields.io/badge/docs-hexdocs-purple.svg)](https://hexdocs.pm/magicax/)\n\nA comprehensive Elixir toolkit for parsing and generating MagicaVoxel (.vox) files.\n\n![github](https://github.com/lalabuy948/magicax/blob/master/github/fractal_example.png)\n\n## Features\n\n### 🔍 Parser (`MagicaX.VoxParser`)\n- **Complete VOX parsing** - 100% data coverage with zero skipped bytes\n- **All major chunk types** - SIZE, XYZI, RGBA, MATL, LAYR, rOBJ, rCAM, NOTE, nTRN, nSHP, nGRP, META\n- **3D matrix representation** - Efficient spatial data structure\n- **Comprehensive analysis** - Detailed chunk statistics and validation\n\n### 🎨 Generator (`MagicaX.VoxGenerator`)\n- **Multiple input methods** - JSON, programmatic, and file-based generation\n- **Built-in shapes** - Cube, sphere, teapot generators\n- **Custom palettes** - Full 256-color support\n- **No external dependencies** - Pure Elixir implementation\n\n## Installation\n\nAdd `magicax` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:magicax, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\nThen run `mix deps.get` to fetch the dependency.\n\n## Quick Start\n\n### Library Usage\n\n```elixir\n# Parse a VOX file\n{:ok, data} = MagicaX.parse_file(\"model.vox\")\nIO.inspect(data.size)           # {32, 32, 32}\nIO.inspect(length(data.voxels)) # 1024\n\n# Generate from JSON file\n{:ok, message} = MagicaX.generate_from_json_file(\"model.json\")\n\n# Generate basic shapes\n{:ok, message} = MagicaX.generate_cube(\"cube.vox\", 10)\n{:ok, message} = MagicaX.generate_sphere(\"sphere.vox\", 8)\n\n# Generate programmatically\ndimensions = {10, 10, 10}\nvoxels = [{0, 0, 0, 1}, {1, 1, 1, 2}]\n{:ok, message} = MagicaX.generate_vox_file(\"model.vox\", dimensions, voxels)\n```\n\n### Standalone Scripts (Development)\n\nFor development and testing, you can also run the examples directly using `Mix.install`:\n\n```bash\n# Parse VOX files\nelixir examples/parser_example.exs path/to/model.vox\n\n# Generate VOX files (includes recursive fractal generation)\nelixir examples/generator_example.exs\n\n# Basic usage examples  \nelixir examples/basic_usage.exs\n```\n\nThe examples use `Mix.install([{:magicax, path: \"../\"}])` to automatically compile and load the library.\n\n## JSON Format\n\n### Required Fields\n\n```json\n{\n  \"dimensions\": [x, y, z],           // MANDATORY: 3D dimensions\n  \"voxels\": [                        // MANDATORY: Array of voxel objects\n    {\n      \"x\": 0,                        // MANDATORY: X coordinate (0-255)\n      \"y\": 0,                        // MANDATORY: Y coordinate (0-255)  \n      \"z\": 0,                        // MANDATORY: Z coordinate (0-255)\n      \"color_index\": 1               // MANDATORY: Color index (0-255)\n    }\n  ]\n}\n```\n\n### Optional Fields\n\n```json\n{\n  \"palette\": [                       // OPTIONAL: Custom color palette\n    {\n      \"r\": 255,                      // MANDATORY: Red component (0-255)\n      \"g\": 255,                      // MANDATORY: Green component (0-255)\n      \"b\": 255,                      // MANDATORY: Blue component (0-255)\n      \"a\": 255                       // MANDATORY: Alpha component (0-255)\n    }\n  ],\n  \"metadata\": {                      // OPTIONAL: File metadata\n    \"name\": \"My VOX Model\",\n    \"author\": \"Creator Name\",\n    \"description\": \"Model description\"\n  }\n}\n```\n\n## Examples\n\n### Simple 3x3x3 Cube\n\n```json\n{\n  \"dimensions\": [3, 3, 3],\n  \"voxels\": [\n    {\"x\": 0, \"y\": 0, \"z\": 0, \"color_index\": 1},\n    {\"x\": 1, \"y\": 0, \"z\": 0, \"color_index\": 2},\n    {\"x\": 2, \"y\": 0, \"z\": 0, \"color_index\": 3}\n  ]\n}\n```\n\n### Using the Generator\n\n```elixir\n# Generate from JSON string\njson_data = \"\"\"\n{\n  \"dimensions\": [5, 5, 5],\n  \"voxels\": [\n    {\"x\": 0, \"y\": 0, \"z\": 0, \"color_index\": 1}\n  ]\n}\n\"\"\"\n\nVoxGenerator.generate_from_json(\"output.vox\", json_data)\n\n# Generate from map\nmodel_data = %{\n  \"dimensions\" =\u003e [4, 4, 4],\n  \"voxels\" =\u003e [\n    %{\"x\" =\u003e 0, \"y\" =\u003e 0, \"z\" =\u003e 0, \"color_index\" =\u003e 1}\n  ]\n}\n\nVoxGenerator.generate_from_map(\"output.vox\", model_data)\n\n# Generate from local JSON file (recommended for most use cases)\nVoxGenerator.generate_from_json_file(\"output.vox\", \"my_model.json\")\n```\n\n### Working with Local JSON Files\n\nThe easiest way to create VOX files is using local JSON files:\n\n1. **Create your JSON file** (e.g., `my_model.json`)\n2. **Run the generator**: `elixir -e \"VoxGenerator.generate_from_json_file(\"output.vox\", \"my_model.json\")\"`\n\nThis approach is perfect for:\n- **Batch processing** multiple JSON models\n- **Integration** with other tools that output JSON\n- **Version control** of your 3D models\n- **Sharing** models between team members\n\n## API Reference\n\n### Main Module (`MagicaX`)\n\nThe main module provides convenient access to all functionality:\n\n- `MagicaX.parse_file/1` - Parse a VOX file\n- `MagicaX.generate_vox_file/3` - Generate VOX from dimensions and voxels\n- `MagicaX.generate_from_json/2` - Generate from JSON string\n- `MagicaX.generate_from_json_file/2` - Generate from JSON file\n- `MagicaX.generate_cube/2` - Generate cube shape\n- `MagicaX.generate_sphere/2` - Generate sphere shape\n- `MagicaX.generate_teapot/2` - Generate teapot shape\n\n### Parser Module (`MagicaX.VoxParser`)\n\n- `parse_vox_file/1` - Parse a VOX file and return structured data\n\n### Generator Module (`MagicaX.VoxGenerator`)\n\n- `generate_vox_file/4` - Create custom VOX file\n- `generate_from_json/2` - Generate from JSON string\n- `generate_from_json_file/2` - Generate from JSON file\n- `generate_from_map/2` - Generate from Elixir map\n- `generate_cube/2` - Generate cube VOX file\n- `generate_sphere/2` - Generate sphere VOX file\n- `generate_teapot/2` - Generate teapot VOX file\n\n## Project Structure\n\n```\nmagicax/\n├── lib/\n│   ├── magicax.ex           # Main module and public API\n│   ├── vox_parser.ex        # VOX file parser\n│   └── vox_generator.ex     # VOX file generator\n├── examples/\n│   ├── json/               # Example JSON models\n│   ├── parser_example.exs  # Parser usage examples\n│   ├── generator_example.exs # Generator usage examples\n│   └── basic_usage.exs     # Basic library usage\n├── vox/                    # Sample VOX files\n│   ├── teapot.vox\n│   ├── castle.vox\n│   └── chr_knight.vox\n├── mix.exs                 # Project configuration\n├── CLAUDE.md               # Development instructions\n└── README.md               # This file\n```\n\n## Requirements\n\n- **Elixir 1.18+** - Core language requirement\n- **No external dependencies** - Pure Elixir implementation with custom JSON parser\n\n## Performance\n\n- **Parser**: Efficiently handles large files (tested with 133KB+ models)\n- **Generator**: Optimized voxel generation algorithms\n- **Memory**: Efficient binary handling for complex 3D models\n- **Coverage**: 100% data coverage for VOX format parsing (zero skipped bytes)\n\n## Contributing\n\nFeel free to submit issues, feature requests, or pull requests to improve the toolkit!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalabuy948%2Fmagicax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flalabuy948%2Fmagicax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalabuy948%2Fmagicax/lists"}