Dealing with scene import woes

main
Elijah Voigt 2 years ago
parent 3545aa227c
commit 93d07f1a42

5
.gitattributes vendored

@ -2,3 +2,8 @@
*.blend1 filter=lfs diff=lfs merge=lfs -text
*.gltf filter=lfs diff=lfs merge=lfs -text
*.glb filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.gltf.bak filter=lfs diff=lfs merge=lfs -text
*.glb.bak filter=lfs diff=lfs merge=lfs -text
*.bin.bak filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text

@ -27,6 +27,10 @@ path = "bin/text-inspect.rs"
name = "debug-info"
path = "bin/debug-info.rs"
[[bin]]
name = "audio-inspect"
path = "bin/audio-inspect.rs"
[dependencies]
bevy = "0.11"

@ -1,5 +1,26 @@
# Inspect Model
# Exploration
- [ ] Load previews on startup.
- [ ] Click to "Open" a model.
## Inspectors
### Model Inspector
- [ ] Construct Scene from Nodes/Meshes (not auto-scene builder)
- [ ] Show debug info about selected model
- [ ] Wireframe view
- [ ] Automatic tighter bounding box for selection
### Audio Inspector
- [ ] UI for selecting sound
- [ ] Play/Pause/Volume
- [x] Load sounds
- [ ] Scrolling list of sounds
## WASM
- [ ] Build and run using model/text inspector
- https://github.com/bevyengine/bevy/blob/main/examples/README.md#wasm
## Text Inspector
- [ ] Performance improvements?

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/audio/Ambient/Lake Sound 1.ogg (Stored with Git LFS)

Binary file not shown.

BIN
assets/audio/Ambient/Lake Sound 2.ogg (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/models/FlightHelmet.bin (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/FlightHelmet.gltf (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
assets/models/inspect.blend (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/inspect.blend1 (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/inspect.glb.bak (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/materials.blend (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/materials.blend1 (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/materials.glb.bak (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/sphere.bin (Stored with Git LFS)

Binary file not shown.

BIN
assets/models/sphere.gltf (Stored with Git LFS)

Binary file not shown.

@ -1,6 +1,7 @@
- [x] basic gltf inspector
- [x] with animation previews
- [ ] inspect specific models
- [ ] Use gltf camera
- [x] basic text inspector
- [x] with simple text animation
- [ ] audio inspector

@ -0,0 +1,114 @@
use bevy::prelude::*;
use monologue_trees::debug::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Audio Inspect".into(),
resolution: (640., 480.).into(),
..default()
}),
..default()
}),
DebugInfoPlugin,
))
.add_systems(PreStartup, (load,))
.add_systems(Startup, (init,))
.add_systems(Update, (save, update))
.run()
}
/// Stores audio handles so they don't get dropped
#[derive(Component, Debug)]
struct AudioItem(Handle<AudioSource>);
#[derive(Component)]
struct Container;
///
/// Load audio assets
/// TODO: Does this load new items when they're added to the folder?
fn load(server: Res<AssetServer>) {
// To prevent handles from being dropped,
// they are stored on entities created triggered on AssetEvent<AudioSource>::Created
let _yeet = server.load_folder("audio").expect("Load audios");
}
///
/// Initialize audio inspector UI
fn init(mut commands: Commands) {
commands.spawn(Camera3dBundle { ..default() });
commands
.spawn((
NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::FlexStart,
flex_direction: FlexDirection::Column,
..default()
},
background_color: BackgroundColor(Color::MIDNIGHT_BLUE),
..default()
},
Container,
))
.with_children(|parent| {
// Something might go here...
});
}
///
/// Save loaded audio sources to entities
fn save(
mut audio_load_events: EventReader<AssetEvent<AudioSource>>,
server: Res<AssetServer>,
mut commands: Commands,
container_q: Query<Entity, With<Container>>,
) {
for event in audio_load_events.iter() {
match event {
AssetEvent::Created { handle } => {
let style = TextStyle {
color: Color::BLACK,
font_size: 16.0,
..default()
};
let handle_path = server
.get_handle_path(handle.clone())
.expect("Get handle path");
let path = handle_path.path().to_str().expect("Convert path to str");
let title = path
.split("/")
.last()
.expect("Extracting filename")
.trim_end_matches(".ogg");
commands
.spawn((
ButtonBundle {
style: Style { ..default() },
..default()
},
AudioItem(handle.clone()),
))
.with_children(|parent| {
parent.spawn(TextBundle::from_section(title, style));
})
.set_parent(container_q.single());
}
AssetEvent::Modified { .. } => {
debug_assert!(false, "Audio file was modified, not handled!")
}
AssetEvent::Removed { .. } => {
debug_assert!(false, "Audio file was deleted, not handled!")
}
}
}
}
/// Update loop; play/pause/volume
fn update() {}

@ -273,23 +273,6 @@ fn spawn_models(
Preview(preview_image_handle.clone()),
));
builder.spawn((
DirectionalLightBundle {
directional_light: DirectionalLight {
shadows_enabled: true,
..default()
},
cascade_shadow_config: CascadeShadowConfigBuilder {
num_cascades: 1,
maximum_distance: 1.6,
..default()
}
.into(),
..default()
},
Inspect,
));
builder.spawn((
SceneBundle {
scene: handle.clone(),
@ -503,6 +486,7 @@ fn select(
mut key_evr: EventReader<KeyboardInput>,
mut selected: Local<Option<Entity>>, // Active camera index
parent_search: Query<&Children>,
cameras: Query<&Camera, (Without<SelectionUI>, Without<Inspect>)>,
parents: Query<Entity, (With<Children>, Without<Parent>)>, // TODO: Constrain
mut events: EventWriter<ManageActive>,
) {

Loading…
Cancel
Save