bevy_clay_tiles

Crates.iobevy_clay_tiles
lib.rsbevy_clay_tiles
version
sourcesrc
created_at2024-08-19 13:48:55.70307
updated_at2024-12-09 17:47:16.32813
descriptionA procedural-mesh building system for bevy
homepage
repositoryhttps://github.com/ethereumdegen/bevy_clay_tiles
max_upload_size
id1343888
Cargo.toml error:TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Ethereumdegen (ethereumdegen)

documentation

README

Bevy Clay Tiles

Paint tiles and walls within a constrained+layered 2D grid system and they are extruded to 3D meshes for 3D games. This is meant to be useful for blocking out levels.

(Inspired by DreamerTalin)

Installing

cargo add bevy_clay_tiles

clay_tiles

image

Run example

cargo run --example basic

Config

In the tile_types config, for each 'tile type' you can set:

  1. the texture index used for diffuse texture

  2. texture UV expansion factor (stretch material)

  3. color tint of the diffuse texture

Editing

When creating the clay tiles, you can use either a Rectangle paint mode or a Polygon paint mode, similar to the Rectangle or Polygon select tools in typical photo editor softwares.

The edit mode allows you to control:

  1. the Y height offset of created tiles

  2. the height scale that new tiles will be extruded up to

  3. the tile type index (see the Config section and tile_types.ron)

  4. the default parent entity for the tile meshes when created

Tile Materials

When clay tiles blocks spawn, they will not have a material on them, only a component ClayTileMaterial { material_name: String }. Therefore it is your responsibility to replace the component with your own material handle. The example use the BevyMaterialTool to help with this but you can just insert a Handle if you wish.


fn add_material_handles(
  mut commands:Commands, 
  block_query: Query<(Entity, &ClayTileMaterial), Added<ClayTileMaterial>>
){

  for (tile_entity, tile_material_comp) in block_query.iter(){

      let material_name = &tile_material_comp.material_name;  

      commands.get_entity(tile_entity).map( |mut cmd| { 


          cmd.remove::<ClayTileMaterial>( ); 

          cmd.insert( MaterialOverrideComponent {
              material_override:  material_name.clone()
          }  ); 


      } );

  }

}

Do you like this crate? Support the creator on Patreon

https://www.patreon.com/infernaltoast

creatinggames-preview

Commit count: 90

cargo fmt