Headless remote assets issues (#94)

Co-authored-by: Danny McGee <dannymcgee@gmail.com>
This commit is contained in:
Lee-Orr
2024-03-20 21:45:09 -04:00
committed by GitHub
parent 0eff115eb5
commit 89487e5889
9 changed files with 42 additions and 6 deletions
+4 -1
View File
@@ -4,6 +4,7 @@ use bevy::{
app::{AppExit, ScheduleRunnerPlugin},
prelude::*,
};
use bevy_web_asset::WebAssetPlugin;
use space_editor::prelude::{EditorEvent, EditorPrefabPath};
use wgpu::Extent3d;
@@ -12,7 +13,7 @@ use crate::{
scene::SceneState,
screenshot::{ScreenCapture, ScreenShotPlugin},
BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera,
MixamoImportEvent, MixamoPlugin, SkyboxId, StudioMode, WorldGridPlugin,
MixamoImportEvent, MixamoPlugin, RemoteAssetPlugin, SkyboxId, StudioMode, WorldGridPlugin,
};
#[derive(Debug, Resource, Clone)]
@@ -42,6 +43,8 @@ pub fn start_headless(
app.add_plugins((
ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / fps as f64)),
WebAssetPlugin,
RemoteAssetPlugin,
DefaultPlugins.set(WindowPlugin {
primary_window: None,
exit_condition: bevy::window::ExitCondition::DontExit,
+3 -2
View File
@@ -1,5 +1,6 @@
use std::{io::ErrorKind, path::Path};
use async_compat::Compat;
use bevy::{
asset::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader},
prelude::*,
@@ -22,7 +23,7 @@ impl AssetReader for RemoteAssetReader {
&'a self,
path: &'a Path,
) -> BoxedFuture<'a, Result<Box<Reader<'a>>, AssetReaderError>> {
Box::pin(async move {
Box::pin(Compat::new(async move {
let token = path
.ext_file_prefix()
.ok_or_else(|| {
@@ -82,7 +83,7 @@ impl AssetReader for RemoteAssetReader {
let reader: Box<Reader> = Box::new(VecReader::new(bytes));
Ok(reader)
})
}))
}
fn read_meta<'a>(
+11 -2
View File
@@ -145,8 +145,19 @@ pub struct LoadingQueue {
fn check_loading(
mut loading_queue: ResMut<LoadingQueue>,
mut st_next: ResMut<NextState<SceneState>>,
r_scene_state: Res<State<SceneState>>,
asset_server: Res<AssetServer>,
) {
// Avoid transitioning from `SceneState::None` directly to `SceneState::Active`.
// We will always be initializing the scene with _something_, so if the
// `LoadingQueue` is empty when we're in `SceneState::None`, it just means
// our startup routine hasn't yet gotten to the point of processing any
// `Handle<T>`s.
if loading_queue.queue.is_empty() && **r_scene_state == SceneState::Loading {
st_next.set(SceneState::Active);
return;
}
if !loading_queue.queue.is_empty() {
//filter queue to only include notloaded assets
@@ -179,8 +190,6 @@ fn check_loading(
} else {
st_next.set(SceneState::Loading);
}
} else {
st_next.set(SceneState::Active);
}
}