bevy_symbios
Bevy integration for the Symbios L-System ecosystem.
Converts L-System skeletons into Bevy meshes and physics colliders for procedural plant generation, organic structures, and generative art.
Features
- Mesh Generation: Smooth tube meshes from skeleton strands using parallel transport
- Multi-Material Support: Separate meshes per material ID for palette-driven PBR (bark, leaves, etc.)
- Vertex Colors: Per-vertex RGBA colors from skeleton data
- UV Mapping: Arc-length parameterized UVs with aspect-ratio preservation
- Physics Colliders (optional): Compound capsule colliders for Avian3D physics
- Robot Spawning (optional): Spawn articulated rigid-body robots from
symbios-robotblueprints
Installation
Add to your Cargo.toml:
[]
= "0.3"
For physics support with Avian3D:
[]
= { = "0.3", = ["physics"] }
For robot spawning (enables physics automatically):
[]
= { = "0.3", = ["robot"] }
Usage
Basic Mesh Generation
use *;
use ;
Multi-Material Workflow
The material system separates PBR surface properties from local color variation:
- Material ID (
SkeletonPoint::material_id) — Selects a palette entry that defines surface properties like roughness, metallic, and emissive. Each unique ID produces a separate mesh, so different BevyStandardMaterials can be applied per group. - Vertex Colors (
SkeletonPoint::color) — Baked into mesh vertices asATTRIBUTE_COLOR. These provide per-vertex tinting (e.g. darker bark at branch bases, lighter tips on leaves) without needing additional materials or textures.
Set base_color: Color::WHITE on your palette materials so vertex colors pass through
unmodified. Any non-white base color will multiply with the vertex color.
Physics Colliders
Generate a compound capsule collider for physics simulation (requires physics feature):
use *;
use ;
Working with Symbios
This crate works with skeletons from the symbios-turtle-3d interpreter:
use System;
use ;
use LSystemMeshBuilder;
// Parse and derive an L-System
let mut sys = new;
sys.set_axiom.unwrap;
sys.add_rule.unwrap;
sys.derive.unwrap;
// Interpret derived state as a 3D skeleton
let mut interpreter = new;
interpreter.populate_standard_symbols;
let skeleton = interpreter.build_skeleton;
// Now use LSystemMeshBuilder to create meshes
let meshes = new
.with_resolution
.build;
Material Palette System
The materials module provides a palette-first PBR workflow with live editing support:
use *;
use ;
// In your app setup:
app.
.add_systems
.add_systems;
MaterialSettingsMap holds editable settings per material ID (base color, emission, roughness, metallic, texture type, UV scale). The default provides 3 entries but the map accepts any u8 key. sync_material_properties updates the Bevy StandardMaterial handles in MaterialPalette each frame without requiring geometry rebuilds.
Material Palette Editor (requires egui feature)
= { = "0.3", = ["egui"] }
use material_palette_editor;
// Inside an egui panel:
material_palette_editor;
Export
The export module converts meshes to OBJ and GLB (binary glTF) formats:
use ;
// OBJ string from a single mesh (vertex_offset=0 for standalone)
let obj_string = mesh_to_obj;
// Combined OBJ from all material buckets
let obj_combined = meshes_to_obj;
// GLB binary with embedded PBR materials
let glb_bytes = meshes_to_glb;
API Reference
LSystemMeshBuilder
| Method | Description |
|---|---|
new() |
Create builder with default resolution (8) |
with_resolution(n) |
Set vertices per ring (min 3) |
build(&skeleton) |
Convert to HashMap<u8, Mesh> |
ColliderGenerator (requires physics feature)
| Method | Description |
|---|---|
new() |
Create generator with no filtering |
with_min_radius(r) |
Skip segments thinner than r |
build(&skeleton) |
Generate Option<Collider> (single compound collider) |
build_parts(&skeleton) |
Generate Vec<PositionedCollider> (individual segments) |
PositionedCollider
| Field | Type | Description |
|---|---|---|
transform |
Transform |
World-space position and rotation |
collider |
Collider |
Avian3D capsule (or sphere for short segments) |
radius |
f32 |
Average segment radius |
length |
f32 |
Segment length |
Mesh Attributes
Generated meshes include:
| Attribute | Description |
|---|---|
POSITION |
Vertex positions |
NORMAL |
Smooth normals |
COLOR |
RGBA vertex colors for local tinting (SkeletonPoint::color) |
UV_0 |
Texture coordinates (U: around tube, V: along strand, scaled by uv_scale) |
TANGENT |
Tangent vectors (auto-generated for normal mapping) |
Ecosystem
symbios (derivation engine)
└── symbios-turtle-3d (3D interpreter)
└── bevy_symbios (Bevy meshes, materials, export, UI)
└── lsystem-explorer (interactive application)
License
MIT