Single-object viewer POC (#14)

This commit implements a Sketchfab-style single-object viewer as a minimal
proof-of-concept.

### `@storyteller/studio-web`
This is a new package to house web components for interfacing with the
`@storyteller/studio` WASM library. It currently includes a single component,
`<sts-viewer />`, which is exported from `@storyteller/studio-web/viewer`.

### `react-frontend`
This is a new application intended as a proof-of-concept and testbed for React
interop with `@storyteller/studio-web`.

Web components are currently a little bit fiddly to use in a React application.
`react-frontend/src/app/studio-viewer.tsx` demonstrates how a React-idiomatic
component can be written as a thin wrapper around a web component, and
`react-frontend/src/app/app.tsx` demonstrates that wrapper component in use.
This commit is contained in:
Danny McGee
2023-12-07 15:46:32 -05:00
committed by GitHub
parent 155272a5ba
commit cba70a62ae
70 changed files with 71793 additions and 1157 deletions
+26
View File
@@ -22,6 +22,9 @@ impl Plugin for SkyboxPlugin {
.run_if(skybox_assets_loaded),
),
);
#[cfg(feature = "wasm")]
app.add_systems(Update, wasm::set_skybox_from_frontend);
}
}
@@ -112,3 +115,26 @@ impl SkyboxPaths {
}
}
}
#[cfg(feature = "wasm")]
mod wasm {
use bevy::prelude::*;
use wasm_bindgen::prelude::*;
use crate::wasm::{StaticBuffer, WasmMessageBuffer};
use super::SkyboxId;
static SKYBOX_REQUEST: WasmMessageBuffer<String> = WasmMessageBuffer::new();
#[wasm_bindgen(js_name = setSkybox)]
pub fn set_skybox(id: &str) {
SKYBOX_REQUEST.write_message(id.to_string());
}
pub(super) fn set_skybox_from_frontend(mut cmd: Commands) {
if let Some(id) = SKYBOX_REQUEST.take_message() {
cmd.insert_resource(SkyboxId(id));
}
}
}