-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:NiklasEi/bevy_kira_audio into reexp…
…ort_used_kira_types
- Loading branch information
Showing
16 changed files
with
214 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use bevy::prelude::*; | ||
use bevy_flycam::{FlyCam, NoCameraPlayerPlugin}; | ||
use bevy_kira_audio::prelude::*; | ||
|
||
fn main() { | ||
App::new() | ||
.insert_resource(Msaa { samples: 1 }) | ||
.insert_resource(SpacialAudio { max_distance: 25. }) | ||
.add_plugins(DefaultPlugins) | ||
.add_plugin(AudioPlugin) | ||
.add_plugin(NoCameraPlayerPlugin) | ||
.add_startup_system(setup) | ||
.run() | ||
} | ||
|
||
fn setup( | ||
mut commands: Commands, | ||
asset_server: Res<AssetServer>, | ||
audio: Res<Audio>, | ||
mut meshes: ResMut<Assets<Mesh>>, | ||
mut materials: ResMut<Assets<StandardMaterial>>, | ||
) { | ||
// Emitter Nr. 1 | ||
let cooking = audio | ||
.play(asset_server.load("sounds/cooking.ogg")) | ||
.looped() | ||
.handle(); | ||
commands | ||
.spawn(SceneBundle { | ||
scene: asset_server.load("models/panStew.glb#Scene0"), | ||
transform: Transform::from_xyz(-5.0, 0., 0.), | ||
..default() | ||
}) | ||
.insert(AudioEmitter { | ||
instances: vec![cooking], | ||
}); | ||
// Emitter Nr. 2 | ||
let elevator_music = audio | ||
.play(asset_server.load("sounds/loop.ogg")) | ||
.looped() | ||
.handle(); | ||
commands | ||
.spawn(SceneBundle { | ||
scene: asset_server.load("models/boxOpen.glb#Scene0"), | ||
transform: Transform::from_xyz(10., 0., 0.), | ||
..default() | ||
}) | ||
.insert(AudioEmitter { | ||
instances: vec![elevator_music], | ||
}); | ||
// Our camera will be the receiver | ||
commands | ||
.spawn(Camera3dBundle { | ||
transform: Transform::from_xyz(0.0, 0.5, 10.0), | ||
..default() | ||
}) | ||
.insert(AudioReceiver) | ||
.insert(FlyCam); | ||
|
||
// Other scene setup... | ||
commands.spawn(PointLightBundle { | ||
point_light: PointLight { | ||
intensity: 1500.0, | ||
shadows_enabled: true, | ||
..default() | ||
}, | ||
transform: Transform::from_xyz(4.0, 8.0, 4.0), | ||
..default() | ||
}); | ||
commands.spawn( TextBundle { | ||
text: Text { | ||
sections: vec![TextSection { | ||
value: "WASD to move horizontally\nSPACE to ascend\nLSHIFT to descend\nESC to grab/release cursor.".to_string(), | ||
style: TextStyle { | ||
font: asset_server.load("fonts/monogram.ttf"), | ||
font_size: 40.0, | ||
color: Color::rgb(0.9, 0.9, 0.9), | ||
}, | ||
}], | ||
alignment: Default::default(), | ||
}, | ||
style: Style { | ||
margin: UiRect::all(Val::Px(15.)), | ||
..default() | ||
}, | ||
..default() | ||
}); | ||
commands.spawn(PbrBundle { | ||
mesh: meshes.add(shape::Plane { size: 50. }.into()), | ||
material: materials.add(Color::DARK_GREEN.into()), | ||
..default() | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.