├── .envrc ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── examples ├── export.rs ├── map.rs ├── planet.rs └── terrain.rs └── src ├── lib.rs ├── map.rs ├── noise.rs ├── planet.rs ├── terrain.rs ├── tests.rs └── util ├── gltf.rs ├── mod.rs └── save.js /.envrc: -------------------------------------------------------------------------------- 1 | use flake 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | # Run cargo test 14 | test: 15 | name: Test Suite 16 | runs-on: ubuntu-latest 17 | timeout-minutes: 30 18 | steps: 19 | - name: Checkout sources 20 | uses: actions/checkout@v4 21 | - name: Cache 22 | uses: actions/cache@v3 23 | with: 24 | path: | 25 | ~/.cargo/bin/ 26 | ~/.cargo/registry/index/ 27 | ~/.cargo/registry/cache/ 28 | ~/.cargo/git/db/ 29 | target/ 30 | key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} 31 | - name: Install stable toolchain 32 | uses: dtolnay/rust-toolchain@stable 33 | - name: Install Dependencies 34 | run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev librust-atk-dev libgtk-3-dev mesa-vulkan-drivers 35 | - name: Run cargo test 36 | run: cargo test 37 | 38 | # Run cargo clippy -- -D warnings 39 | clippy_check: 40 | name: Clippy 41 | runs-on: ubuntu-latest 42 | timeout-minutes: 30 43 | steps: 44 | - name: Checkout sources 45 | uses: actions/checkout@v4 46 | - name: Cache 47 | uses: actions/cache@v3 48 | with: 49 | path: | 50 | ~/.cargo/bin/ 51 | ~/.cargo/registry/index/ 52 | ~/.cargo/registry/cache/ 53 | ~/.cargo/git/db/ 54 | target/ 55 | key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }} 56 | - name: Install stable toolchain 57 | uses: dtolnay/rust-toolchain@stable 58 | with: 59 | components: clippy 60 | - name: Install Dependencies 61 | run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libgtk-3-dev 62 | - name: Run clippy 63 | run: cargo clippy -- -D warnings 64 | 65 | # Run cargo fmt --all -- --check 66 | format: 67 | name: Format 68 | runs-on: ubuntu-latest 69 | timeout-minutes: 30 70 | steps: 71 | - name: Checkout sources 72 | uses: actions/checkout@v4 73 | - name: Install stable toolchain 74 | uses: dtolnay/rust-toolchain@stable 75 | with: 76 | components: rustfmt 77 | - name: Run cargo fmt 78 | run: cargo fmt --all -- --check 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock 3 | dist/ 4 | .direnv/ 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### [v0.3.1](https://github.com/manankarnik/bevy_generative/compare/v0.3.0...v0.3.1) (2024-08-23) 4 | 5 | ## [v0.3.0](https://github.com/manankarnik/bevy_generative/compare/v0.2.0...v0.3.0) (2024-08-23) 6 | 7 | ## [v0.2.0](https://github.com/manankarnik/bevy_generative/compare/v0.1.0...v0.2.0) (2024-03-08) 8 | 9 | ### Features 10 | 11 | * add image size 12 | ([fbd760b](https://github.com/manankarnik/bevy_generative/commit/fbd760b3e579f6f3b6cff806a3d96c6f27d10b2f)) 13 | * derive serde for components 14 | ([466fd57](https://github.com/manankarnik/bevy_generative/commit/466fd5731b49af0408f42281e45828ab4c45eba5)) 15 | 16 | ### Fixes 17 | 18 | * serde default all structs 19 | ([232b697](https://github.com/manankarnik/bevy_generative/commit/232b69782e5567b3e0bab4c09554c984ccbe88cd)) 20 | * wasm-bindgen called on non-wasm targets 21 | ([3aa437e](https://github.com/manankarnik/bevy_generative/commit/3aa437e72e62a0d42c4c93020a22daed86018f7b)) 22 | 23 | ## v0.1.0 (2024-01-07) 24 | 25 | ### Features 26 | 27 | * **planet:** add elevation and colors 28 | ([6efd336](https://github.com/manankarnik/bevy_generative/commit/6efd336a116aa79916eec57ecec5238dfad511cb)) 29 | * **terrain:** add height exponent and resolution 30 | ([09793f2](https://github.com/manankarnik/bevy_generative/commit/09793f21315cfb7bc8660ee3b7b03862a8783ead)) 31 | * add planet generation 32 | ([6444ac1](https://github.com/manankarnik/bevy_generative/commit/6444ac199c85afc7e09250f8b8144d824e52e57c)) 33 | * add terrain sea level and height exponent 34 | ([0979da0](https://github.com/manankarnik/bevy_generative/commit/0979da0806bea5e2e9b95ddc049c8adb8dd698e6)) 35 | * add export for assets 36 | ([386ea78](https://github.com/manankarnik/bevy_generative/commit/386ea78be2b218f118ae0c4b2665617d789d991e)) 37 | * add trunk and wasm 38 | ([37b294b](https://github.com/manankarnik/bevy_generative/commit/37b294b567d27f8995c6a7a116b5035736287fe2)) 39 | * add wireframe, bloom, export for terrain 40 | ([dc295f0](https://github.com/manankarnik/bevy_generative/commit/dc295f07ca846cd0f94862c073c430c96e4457e9)) 41 | * add wireframe rendering for terrain 42 | ([0c5ed53](https://github.com/manankarnik/bevy_generative/commit/0c5ed531b2f0aed98654326bc6ea8a58f7b26b3e)) 43 | * add terrain generation 44 | ([b732d5f](https://github.com/manankarnik/bevy_generative/commit/b732d5f252b949249084620b4e2eda906ceafad4)) 45 | * add alpha and blending 46 | ([8b1d30d](https://github.com/manankarnik/bevy_generative/commit/8b1d30d4deb671092e6068dc95f704c5071744c5)) 47 | * add color gradients 48 | ([19a6a59](https://github.com/manankarnik/bevy_generative/commit/19a6a59de3004ee0de1df89e62d8f69bd7e2e99a)) 49 | * offset ui 50 | ([2d6d68f](https://github.com/manankarnik/bevy_generative/commit/2d6d68fe3a659babbdbfd2664d3fbc6e7c77ad25)) 51 | * anti-aliasing and method/function selection 52 | ([b251d9f](https://github.com/manankarnik/bevy_generative/commit/b251d9f057ef319f25a6677af4710dcfada0c539)) 53 | * add regions in egui 54 | ([d5ca581](https://github.com/manankarnik/bevy_generative/commit/d5ca581fef557f7767b8ed4ede4c998e7d1ee13e)) 55 | * add threshold region and update scale 56 | ([e5c5a9b](https://github.com/manankarnik/bevy_generative/commit/e5c5a9b54fa1fecea2cc2110621be42910313f7b)) 57 | * add noise functions 58 | ([b9939e8](https://github.com/manankarnik/bevy_generative/commit/b9939e8b80c9f33734445eac78f5c8576e567d58)) 59 | * add regions 60 | ([fc13d1f](https://github.com/manankarnik/bevy_generative/commit/fc13d1fdda04d5aad17381b3ca0cb2e22bae2d05)) 61 | * add noise map bundle 62 | ([41a4afd](https://github.com/manankarnik/bevy_generative/commit/41a4afd570ac8ff18709dced70a3c9c06acae487)) 63 | * add offset to noise map 64 | ([2316311](https://github.com/manankarnik/bevy_generative/commit/2316311dfdbb98417ef568e51048996de13fe0db)) 65 | * add noise map marker component 66 | ([6a93f69](https://github.com/manankarnik/bevy_generative/commit/6a93f6911b4af0a11ec1a6e3c5e2882bf6e049c0)) 67 | * add noise map config 68 | ([e6774f5](https://github.com/manankarnik/bevy_generative/commit/e6774f5eb7b1a8eede32de50301e0a6a5773df60)) 69 | * add noise map generation 70 | ([f723ff8](https://github.com/manankarnik/bevy_generative/commit/f723ff8007ec1df55ed43e8d4eb2d95d64082048)) 71 | 72 | ### Fixes 73 | 74 | * change extras type 75 | ([dbc14fa](https://github.com/manankarnik/bevy_generative/commit/dbc14fa20a0b495ef9b9500058729c7001c94197)) 76 | * add save_buffer import 77 | ([2a096a1](https://github.com/manankarnik/bevy_generative/commit/2a096a1d1e460ab60bb99f68c5a72664f1d7ef8b)) 78 | * **noise:** clamp 3d noise 79 | ([fa0b32c](https://github.com/manankarnik/bevy_generative/commit/fa0b32cc75ad283d3eae82b35eacdd25280443b7)) 80 | * **planet:** tweak noise and height values 81 | ([33ce5c7](https://github.com/manankarnik/bevy_generative/commit/33ce5c7ff64064c4633239d742dc8ba64cb989e3)) 82 | * private field size 83 | ([1ff47e9](https://github.com/manankarnik/bevy_generative/commit/1ff47e94cc138044d6cd434be88ae35e4a1d8532)) 84 | * remove imports 85 | ([7199ce3](https://github.com/manankarnik/bevy_generative/commit/7199ce395d5feb9ae9154e05cda997fc28c36aa1)) 86 | * hard coded size causing panic 87 | ([18702f7](https://github.com/manankarnik/bevy_generative/commit/18702f79662b00574f600fde08c2901f15183d09)) 88 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bevy_generative" 3 | version = "0.3.1" 4 | license = "MIT OR Apache-2.0" 5 | edition = "2021" 6 | description = "Procedural generation in Bevy" 7 | categories = ["game-development", "graphics", "rendering", "visualization"] 8 | keywords = ["bevy", "gamedev", "procedural", "generation", "graphics"] 9 | exclude = [".github/**/*"] 10 | readme = "README.md" 11 | repository = "https://github.com/manankarnik/bevy_generative" 12 | homepage = "https://github.com/manankarnik/bevy_generative" 13 | documentation = "https://docs.rs/bevy_generative" 14 | 15 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 16 | [dependencies] 17 | bevy = { version = "0.14.0", default-features = false, features = [ 18 | "bevy_core_pipeline", 19 | "bevy_pbr", 20 | "bevy_ui", 21 | ] } 22 | colorgrad = "0.6.2" 23 | gltf = "1.3.0" 24 | image = "0.25" 25 | noise = { version = "0.9.0", git = "https://github.com/Razaekel/noise-rs.git" } 26 | rfd = "0.12.1" 27 | serde = "1.0.195" 28 | serde_json = "1.0.111" 29 | wasm-bindgen = "0.2.89" 30 | 31 | [dev-dependencies] 32 | bevy = "0.14.0" 33 | 34 | # Enable max optimizations for dependencies, but not for our code: 35 | [profile.dev.package."*"] 36 | opt-level = 3 37 | 38 | # Enable only a small amount of optimization in debug mode 39 | [profile.dev] 40 | opt-level = 1 41 | 42 | [profile.release] 43 | lto = "thin" 44 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Manan Karnik 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bevy_generative 2 | 3 | ![CodeSize](https://img.shields.io/github/languages/code-size/manankarnik/bevy_generative?style=for-the-badge) 4 | [![License](https://img.shields.io/badge/license-MIT%2FApache-red.svg?style=for-the-badge)](https://github.com/manankarnik/bevy_generative#license) 5 | ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/manankarnik/bevy_generative/ci.yml?style=for-the-badge) 6 | [![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue?style=for-the-badge)](https://bevyengine.org/learn/book/plugin-development/#main-branch-tracking) 7 | [![crates.io](https://img.shields.io/crates/v/bevy_generative?style=for-the-badge)](https://crates.io/crates/bevy_generative) 8 | [![docs.rs](https://img.shields.io/badge/docs-online-brightgreen.svg?style=for-the-badge)](https://docs.rs/bevy_generative) 9 | 10 | `bevy_generative` is a plugin written for the [bevy engine](https://bevyengine.org/) that allows real-time procedural generation of maps, textures, terrain, planets and more! 11 | 12 | ## Features 13 | 14 | - Allows procedural generation of assets which can be directly integrated in your bevy game 15 | - Handles real-time updating of image and mesh data as configuration for the asset changes 16 | - Builds on native as well as wasm targets 17 | - Allows saving generated assets (uses `rfd` for native, javascript blob for wasm) 18 | - Serializes and deserializes components using `serde` 19 | 20 | ## Showcase 21 | 22 | Check out [Procedra](https://procedra.netlify.app) [[Source](https://github.com/manankarnik/procedra)], a procedural generation web application that allows you to experiment with all the parameters and generate assets in real-time! 23 | 24 | ## Installation 25 | 26 | Add `bevy_generative` to your rust project 27 | 28 | ```sh 29 | cargo add bevy_generative 30 | ``` 31 | 32 | ## Examples 33 | 34 | Examples are provided in the [examples](./examples) directory. To run an example, clone this repository and invoke cargo like this: 35 | 36 | ```sh 37 | cargo run --example map 38 | ``` 39 | 40 | ## Bevy Compatibility 41 | 42 | | bevy | bevy_generative | 43 | | ---- | --------------- | 44 | | 0.14 | 0.3, main | 45 | | 0.13 | 0.2 | 46 | | 0.12 | 0.1 | 47 | 48 | ## Contributing 49 | 50 | Contributions are welcome! Issues, pull requests, feature requests and bug reports are appreciated. If you'd like to contribute to this project, please follow these steps: 51 | 52 | 1. Fork the repository. 53 | 2. Create a new branch with a descriptive name. 54 | 3. Make your changes or additions. 55 | 4. Test your changes. 56 | 5. Submit a pull request with a clear description of your work. 57 | 58 | Please ensure your code passes all CI checks and includes relevant tests if applicable. Thank you for helping improve `bevy_generative`! 59 | 60 | Your contribution will be dual-licensed as mentioned in the License section below. 61 | 62 | ## License 63 | 64 | All code in this repository is dual-licensed under either: 65 | 66 | - MIT License ([LICENSE-MIT](LICENSE-MIT) or [http://opensource.org/licenses/MIT](http://opensource.org/licenses/MIT)) 67 | - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) 68 | or [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)) 69 | 70 | at your option. 71 | This means you can select the license you prefer! 72 | This dual-licensing approach is the de-facto standard in the Rust ecosystem and there 73 | are [very good reasons](https://github.com/bevyengine/bevy/issues/2373) to include both. 74 | -------------------------------------------------------------------------------- /examples/export.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | use bevy_generative::terrain::{Terrain, TerrainBundle, TerrainPlugin}; 3 | 4 | fn main() { 5 | App::new() 6 | .add_plugins(DefaultPlugins) 7 | .add_plugins(TerrainPlugin) 8 | .add_systems(Startup, setup) 9 | .add_systems(Update, (button_appearance, export_button)) 10 | .run(); 11 | } 12 | 13 | fn setup(mut commands: Commands) { 14 | commands.spawn(PointLightBundle { 15 | transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), 16 | ..default() 17 | }); 18 | commands.spawn(Camera3dBundle { 19 | transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), 20 | ..default() 21 | }); 22 | commands.spawn(TerrainBundle::default()); 23 | 24 | commands 25 | .spawn(ButtonBundle { 26 | style: Style { 27 | padding: UiRect::all(Val::Px(12.)), 28 | justify_content: JustifyContent::Center, 29 | align_items: AlignItems::Center, 30 | margin: UiRect::all(Val::Px(12.)), 31 | ..default() 32 | }, 33 | border_radius: BorderRadius::all(Val::Px(5.)), 34 | background_color: NORMAL_BUTTON.into(), 35 | ..default() 36 | }) 37 | .with_children(|parent| { 38 | parent.spawn(TextBundle::from_section( 39 | "Export", 40 | TextStyle { 41 | font_size: 30.0, 42 | color: BUTTON_TEXT.into(), 43 | ..default() 44 | }, 45 | )); 46 | }); 47 | } 48 | 49 | fn export_button( 50 | interaction_query: Query<&Interaction, (Changed, With