avian_steam_audio

Crates.ioavian_steam_audio
lib.rsavian_steam_audio
version0.1.1
created_at2025-10-29 23:08:39.391155+00
updated_at2025-11-12 03:51:15.527833+00
descriptionIntegration between bevy_steam_audio and avian3d
homepage
repositoryhttps://github.com/janhohenheim/bevy_steam_audio
max_upload_size
id1907485
size104,485
Corvus (CorvusPrudens)

documentation

README

Bevy Steam Audio

WIP of an integration between Bevy and Steam Audio via audionimbus. See https://github.com/MaxenceMaire/audionimbus-demo for a minimal POC of the approach used in the crate.

Usage

use bevy::{color::palettes::tailwind, prelude::*};
use bevy_seedling::prelude::*;
use bevy_steam_audio::{
    prelude::*,
    scene::mesh_backend::{Mesh3dSteamAudioScenePlugin, SteamAudioMesh},
};

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            SeedlingPlugin::default(),
            // Add the SteamAudioPlugin to the app to enable Steam Audio functionality
            SteamAudioPlugin::default(),
            // Steam Audio still needs some scene backend to know how to build its 3D scene.
            // Mesh3dSteamAudioScenePlugin does this by using all entities that hold both
            // `Mesh3d` and `MeshMaterial3d`.
            Mesh3dSteamAudioScenePlugin::default(),
        ))
        .add_systems(Startup, setup)
        .run();
}

fn setup(
    mut commands: Commands,
    assets: Res<AssetServer>,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    // The camera is our listener using SteamAudioListener
    commands.spawn((Camera3d::default(), SteamAudioListener));

    // The sample player uses Steam Audio through the SteamAudioPool
    // Let's place it to the front left of the listener, making direct sound come from the left
    commands.spawn((
        SamplePlayer::new(assets.load("selfless_courage.ogg")).looping(),
        SteamAudioPool,
        Transform::from_xyz(-1.5, 0.0, -3.0),
        Mesh3d(meshes.add(Sphere::new(0.2))),
        MeshMaterial3d(materials.add(Color::from(tailwind::GREEN_400))),
    ));

    // Some occluding geometry using MeshSteamAudioMaterial
    // Let's place it to the right of the listener, making reflected sound come from the right
    commands.spawn((
        Mesh3d(meshes.add(Cuboid::new(0.1, 1.0, 3.0))),
        MeshMaterial3d(materials.add(Color::from(tailwind::GRAY_600))),
        Transform::from_xyz(1.0, 0.0, 0.0),
        SteamAudioMesh::default(),
    ));

    commands.spawn((
        DirectionalLight::default(),
        Transform::default().looking_to(Vec3::new(0.5, -1.0, -0.3), Vec3::Y),
    ));
}

Compatibility

Bevy bevy_steam_audio Steam Audio
0.17 0.1 4.7
Commit count: 0

cargo fmt