voxel-framework 0.12.4

A reusable voxel engine framework built on Bevy
Documentation
# Collectible drops

Available in `voxel-framework = "=0.10.3"`. Enable the `items` feature (included by default). Gameplay and presentation are
separate explicit plugins:

```rust,no_run
use bevy::prelude::*;
use voxel_framework::prelude::*;

App::new()
    .add_plugins(DefaultPlugins)
    .add_plugins((
        MiningPlugin,
        DropsPlugin::<DefaultItem>::new(),
        DropVisualPlugin::<DefaultItem>::new(),
    ))
    .add_systems(Startup, setup);

fn setup(mut commands: Commands, mut table: ResMut<DropTable<DefaultItem>>) {
    table.register(1, DefaultItem::RockFragment, 1, 3);
    // In a game, attach these components to the actual moving player instead.
    commands.spawn((
        Transform::default(),
        ItemCollector,
        PrimaryContainer,
        ContainerComponent::<DefaultItem>::new(9),
    ));
}
```

Mining emits `VoxelBroken`; register the message through `MiningPlugin` or a
bundle that contains it. Populate the drop table before mining begins. Your game
still owns the camera, mining input, player movement, and UI. Drop and collector
transforms must represent world positions (use unparented entities). The current
pickup model expects exactly one collector and one primary container; they need
not be the same entity. Ambiguous collectors disable spatial pickup, not expiry.

`DropsPlugin<I>` spawns at the broken voxel center, attracts nearby drops,
advances velocity while a unique collector exists, and inserts accepted items
into the primary container. Full inventories leave the drop intact. Partial
pickups subtract only accepted items; `ItemPickedUp<I>` reports only that amount.
Remaining lifetime continues to decrease, including when no collector exists or
a drop has no transform. Expired drops disappear without pickup messages.

`DropVisualPlugin<I>` draws a 0.25-unit cube per positioned drop, using
`ItemType::color()` and an unlit material, so no lights or texture assets are
required. It runs in PostUpdate before transform/visibility propagation and
bounds calculation. It handles existing drops and late-added transforms as well
as newly spawned drops. Mesh/material components live on the drop entity:
partial pickup preserves the visual; full pickup and expiry remove it. Changes
to the drop Transform (from attraction or game systems) propagate to the visible
geometry in the same frame. You can also replace its mesh and material after
the default has been attached; subsequent frames preserve that replacement.

### Idle motion

Insert a `DropVisualConfig` to make waiting drops spin and bob:

```rust
app.insert_resource(DropVisualConfig {
    spin_rad_per_sec: 1.5, // around the drop's local Y axis
    bob_amplitude: 0.05,   // world units
    bob_period: 2.0,       // seconds per up-and-down cycle
});
```

The default is all zeros: no motion, and the visual stays on the drop entity as
described above. With any motion enabled, the cube is spawned as a child entity
marked `DropVisual`, and only that child's local transform is animated. The
drop's own `Transform` is never written, so attraction, pickup distance and any
game system that reads the drop's position behave the same. The child is
despawned with its drop. Each drop gets its own phase, so they do not move in
unison.

The values are read every frame and can be changed while drops exist; setting
them back to zero returns the children to rest. Whether a drop uses a child is
decided when its visual is first attached, so drops that already had a static
visual stay static. A drop with its own `Mesh3d` or material is left alone.

Assets are shared: one mesh and one material per encountered item variant, kept
for reuse until the app ends. Colors are sampled on first use. This default does
not track changes to an already rendered drop's item identity. For custom art,
omit the plugin or attach your own Mesh3d/material before PostUpdate; existing
Mesh3d or MeshMaterial3d<StandardMaterial> components are never overwritten.
DefaultPlugins supplies the required asset stores; headless ECS tests may supply
Assets<Mesh> and Assets<StandardMaterial> explicitly.

The visual plugin never integrates motion, changes quantities, or installs
DropsPlugin. It does not implement gravity, terrain collision, or bouncing;
the initial upward velocity is not a complete ballistic simulation. Game-owned
physics may update velocity, but must not integrate the same movement twice.

Run `cargo run --example drops --no-default-features --features items` with a
graphical display. Colored drops are initially stationary with no collector.
Press Space to enable a collector at the center; nearby drops move toward it
and disappear on pickup. Press R to spawn another batch. Leave collection off
for 10 seconds to observe expiration. The example logs accepted quantities.