mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-09 00:09:55 +00:00
Headless remote assets issues (#94)
Co-authored-by: Danny McGee <dannymcgee@gmail.com>
This commit is contained in:
Generated
+14
@@ -305,6 +305,19 @@ dependencies = [
|
|||||||
"futures-core",
|
"futures-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-compat"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f68a707c1feb095d8c07f8a65b9f506b117d30af431cab89374357de7c11461b"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
|
"once_cell",
|
||||||
|
"pin-project-lite",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-executor"
|
name = "async-executor"
|
||||||
version = "1.8.0"
|
version = "1.8.0"
|
||||||
@@ -4851,6 +4864,7 @@ name = "studio"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"async-compat",
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy-inspector-egui",
|
"bevy-inspector-egui",
|
||||||
"bevy_mod_outline",
|
"bevy_mod_outline",
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
background: #242433;
|
background: #242433;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sts-scene-data-provider {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
// Layout utilities
|
// Layout utilities
|
||||||
.v-start, .v-end, .h-start, .h-end, .h-center {
|
.v-start, .v-end, .h-start, .h-end, .h-center {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { ImageInfo, LcmClient } from "./lcm-client";
|
|||||||
|
|
||||||
import "@storyteller/studio-web/canvas-provider";
|
import "@storyteller/studio-web/canvas-provider";
|
||||||
import "@storyteller/studio-web/loading";
|
import "@storyteller/studio-web/loading";
|
||||||
|
import "@storyteller/studio-web/scene-data-provider";
|
||||||
import "@storyteller/studio-web/scene-hierarchy";
|
import "@storyteller/studio-web/scene-hierarchy";
|
||||||
import "@storyteller/studio-web/studio";
|
import "@storyteller/studio-web/studio";
|
||||||
import "@storyteller/studio-web/transform-toolbar";
|
import "@storyteller/studio-web/transform-toolbar";
|
||||||
@@ -173,6 +174,7 @@ export class AppElement extends LitElement {
|
|||||||
|
|
||||||
protected override render = () => html`
|
protected override render = () => html`
|
||||||
<sts-canvas-provider class="app-root">
|
<sts-canvas-provider class="app-root">
|
||||||
|
<sts-scene-data-provider>
|
||||||
<div
|
<div
|
||||||
class="hierarchy-wrapper"
|
class="hierarchy-wrapper"
|
||||||
style=${styleMap({ width: `${this.hierarchyWidth}px` })}
|
style=${styleMap({ width: `${this.hierarchyWidth}px` })}
|
||||||
@@ -297,6 +299,7 @@ export class AppElement extends LitElement {
|
|||||||
${this.loading ? html`
|
${this.loading ? html`
|
||||||
<sts-loading></sts-loading>
|
<sts-loading></sts-loading>
|
||||||
` : nothing}
|
` : nothing}
|
||||||
|
</sts-scene-data-provider>
|
||||||
</sts-canvas-provider>
|
</sts-canvas-provider>
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ space_editor = {git = "https://github.com/rewin123/space_editor", rev = "ce83f86
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
serde_repr = "0.1.18"
|
serde_repr = "0.1.18"
|
||||||
bevy_tweening = "0.9"
|
bevy_tweening = "0.9"
|
||||||
|
async-compat = "0.2"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.11.24"
|
version = "0.11.24"
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@
|
|||||||
"headless": {
|
"headless": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
"command": "cargo run -p studio --bin studio-headless -- {args}"
|
"command": "cargo run -p studio --bin studio-headless --"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use bevy::{
|
|||||||
app::{AppExit, ScheduleRunnerPlugin},
|
app::{AppExit, ScheduleRunnerPlugin},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
use bevy_web_asset::WebAssetPlugin;
|
||||||
use space_editor::prelude::{EditorEvent, EditorPrefabPath};
|
use space_editor::prelude::{EditorEvent, EditorPrefabPath};
|
||||||
use wgpu::Extent3d;
|
use wgpu::Extent3d;
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ use crate::{
|
|||||||
scene::SceneState,
|
scene::SceneState,
|
||||||
screenshot::{ScreenCapture, ScreenShotPlugin},
|
screenshot::{ScreenCapture, ScreenShotPlugin},
|
||||||
BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera,
|
BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera,
|
||||||
MixamoImportEvent, MixamoPlugin, SkyboxId, StudioMode, WorldGridPlugin,
|
MixamoImportEvent, MixamoPlugin, RemoteAssetPlugin, SkyboxId, StudioMode, WorldGridPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Resource, Clone)]
|
#[derive(Debug, Resource, Clone)]
|
||||||
@@ -42,6 +43,8 @@ pub fn start_headless(
|
|||||||
|
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / fps as f64)),
|
ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / fps as f64)),
|
||||||
|
WebAssetPlugin,
|
||||||
|
RemoteAssetPlugin,
|
||||||
DefaultPlugins.set(WindowPlugin {
|
DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: None,
|
primary_window: None,
|
||||||
exit_condition: bevy::window::ExitCondition::DontExit,
|
exit_condition: bevy::window::ExitCondition::DontExit,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::{io::ErrorKind, path::Path};
|
use std::{io::ErrorKind, path::Path};
|
||||||
|
|
||||||
|
use async_compat::Compat;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader},
|
asset::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@@ -22,7 +23,7 @@ impl AssetReader for RemoteAssetReader {
|
|||||||
&'a self,
|
&'a self,
|
||||||
path: &'a Path,
|
path: &'a Path,
|
||||||
) -> BoxedFuture<'a, Result<Box<Reader<'a>>, AssetReaderError>> {
|
) -> BoxedFuture<'a, Result<Box<Reader<'a>>, AssetReaderError>> {
|
||||||
Box::pin(async move {
|
Box::pin(Compat::new(async move {
|
||||||
let token = path
|
let token = path
|
||||||
.ext_file_prefix()
|
.ext_file_prefix()
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
@@ -82,7 +83,7 @@ impl AssetReader for RemoteAssetReader {
|
|||||||
|
|
||||||
let reader: Box<Reader> = Box::new(VecReader::new(bytes));
|
let reader: Box<Reader> = Box::new(VecReader::new(bytes));
|
||||||
Ok(reader)
|
Ok(reader)
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_meta<'a>(
|
fn read_meta<'a>(
|
||||||
|
|||||||
+11
-2
@@ -145,8 +145,19 @@ pub struct LoadingQueue {
|
|||||||
fn check_loading(
|
fn check_loading(
|
||||||
mut loading_queue: ResMut<LoadingQueue>,
|
mut loading_queue: ResMut<LoadingQueue>,
|
||||||
mut st_next: ResMut<NextState<SceneState>>,
|
mut st_next: ResMut<NextState<SceneState>>,
|
||||||
|
r_scene_state: Res<State<SceneState>>,
|
||||||
asset_server: Res<AssetServer>,
|
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() {
|
if !loading_queue.queue.is_empty() {
|
||||||
//filter queue to only include notloaded assets
|
//filter queue to only include notloaded assets
|
||||||
|
|
||||||
@@ -179,8 +190,6 @@ fn check_loading(
|
|||||||
} else {
|
} else {
|
||||||
st_next.set(SceneState::Loading);
|
st_next.set(SceneState::Loading);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
st_next.set(SceneState::Active);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const mimeTypes = {
|
|||||||
".otf": "font/otf",
|
".otf": "font/otf",
|
||||||
".png": "image/png",
|
".png": "image/png",
|
||||||
".rar": "application/x-rar-compressed",
|
".rar": "application/x-rar-compressed",
|
||||||
|
".ron": "text/ron",
|
||||||
".svg": "image/svg+xml",
|
".svg": "image/svg+xml",
|
||||||
".tiff": "image/tiff",
|
".tiff": "image/tiff",
|
||||||
".ttf": "font/ttf",
|
".ttf": "font/ttf",
|
||||||
|
|||||||
Reference in New Issue
Block a user