mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 07:35:19 +00:00
Single-canvas juggling (#15)
This PR adds a `CanvasProviderElement` to `@storyteller/studio-web` to manage the complexity of maintaining a single concrete `HTMLCanvasElement` for `@storyteller/studio`, while still being able to treat components like the `ViewerElement` as self-contained "views" that behave as expected with regards to CSS styling, DOM placement, etc. Consuming applications should wrap the new `<sts-canvas-provider />` element around some common ancestor of all views into the `@storyteller/studio` app, similar to a React context provider. The `react-frontend` application has been updated to take advantage of the new `CanvasProviderElement` by demonstrating a more realistic use case for the `ViewerElement`. The new demo presents a grid of "thumbnails," one for each object in our hard-coded "object library." Clicking on one of these thumbnails will render a `ViewerElement` for that object in a modal dialog.
This commit is contained in:
+14
-1
@@ -1,4 +1,5 @@
|
||||
use bevy::{
|
||||
asset::AssetPath,
|
||||
core_pipeline::{
|
||||
bloom::{BloomCompositeMode, BloomPrefilterSettings, BloomSettings},
|
||||
fxaa::Fxaa,
|
||||
@@ -143,12 +144,24 @@ fn initialize(mut cmd: Commands) {
|
||||
fn init_scene_loading(
|
||||
mut cmd: Commands,
|
||||
assets: Res<AssetServer>,
|
||||
r_active_scene: Option<Res<ActiveScene>>,
|
||||
mut er: EventReader<LoadSceneEvent>,
|
||||
mut st_next: ResMut<NextState<SceneState>>,
|
||||
) {
|
||||
if let Some(id) = er.read().last() {
|
||||
let name = &**id;
|
||||
cmd.insert_resource(PendingScene(assets.load(format!("gltf/{name}.gltf"))));
|
||||
let path = format!("gltf/{name}.gltf");
|
||||
|
||||
// Avoid trying to re-load this scene if it's already active
|
||||
if let Some(active_scene_path) =
|
||||
r_active_scene.and_then(|scene| scene.source.path().cloned())
|
||||
{
|
||||
if active_scene_path == AssetPath::parse(&path) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cmd.insert_resource(PendingScene(assets.load(path)));
|
||||
st_next.set(SceneState::Loading);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user