mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 00:23:14 +00:00
Load remote BVH from URL param
This commit is contained in:
@@ -35,6 +35,7 @@ web-sys = { version = "0.3.65", optional = true, features = [
|
||||
"Window",
|
||||
] }
|
||||
space_editor = {git = "https://github.com/rewin123/space_editor", rev = "e150ecaf0647de6532d2967928982abf2558bfbc"}
|
||||
bevy_web_asset = "0.7.0"
|
||||
|
||||
[features]
|
||||
wasm = [
|
||||
|
||||
+33
-2
@@ -2,8 +2,9 @@
|
||||
|
||||
use bevy::{app::PluginGroupBuilder, prelude::*};
|
||||
use bevy_mod_picking::DefaultPickingPlugins;
|
||||
|
||||
use bevy_web_asset::WebAssetPlugin;
|
||||
use space_editor::prelude::space_undo::UndoPlugin;
|
||||
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -29,7 +30,7 @@ use crate::{
|
||||
inspector::InspectorPlugin,
|
||||
interaction::InteractionPlugin,
|
||||
math::InterpolationPlugin,
|
||||
scene::{LoadSceneEvent, ScenePlugin},
|
||||
scene::{LoadSceneEvent, ScenePlugin, TestBvh},
|
||||
skybox::{SkyboxId, SkyboxPlugin},
|
||||
ui::UiLayerPlugin,
|
||||
world_grid::WorldGridPlugin,
|
||||
@@ -84,6 +85,35 @@ impl PluginGroup for EditorPlugins {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = startBvhViewer))]
|
||||
pub fn start_bvh_viewer(
|
||||
bvh_path: &str,
|
||||
skybox_id: &str,
|
||||
canvas_selector: &str,
|
||||
canvas_alt: &str,
|
||||
viewport_size: ViewportSize,
|
||||
) {
|
||||
let mut app = start_internal(
|
||||
"Mannequin.gltf",
|
||||
skybox_id,
|
||||
canvas_selector,
|
||||
canvas_alt,
|
||||
viewport_size,
|
||||
StudioMode::Viewer,
|
||||
);
|
||||
|
||||
let bvh_path = bvh_path.to_string();
|
||||
|
||||
app.add_systems(
|
||||
Startup,
|
||||
move |mut cmd: Commands, r_assets: Res<AssetServer>| {
|
||||
cmd.insert_resource(TestBvh(r_assets.load(bvh_path.clone())));
|
||||
},
|
||||
);
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = startViewer))]
|
||||
/// Start the application as a read-only viewer for a single library object.
|
||||
///
|
||||
@@ -175,6 +205,7 @@ pub fn start_internal(
|
||||
app.add_plugins((
|
||||
#[cfg(feature = "wasm")]
|
||||
viewport::wasm::ViewportPlugin,
|
||||
WebAssetPlugin,
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
resolution: viewport_size.into(),
|
||||
|
||||
+2
-5
@@ -44,7 +44,7 @@ impl Plugin for ScenePlugin {
|
||||
.add_systems(
|
||||
Update,
|
||||
(
|
||||
spawn_test_bvh, // TODO
|
||||
spawn_test_bvh.run_if(resource_exists::<TestBvh>()), // TODO
|
||||
init_scene_loading,
|
||||
tick_scene_loading.run_if(in_state(SceneState::Loading)),
|
||||
tick_scene_spawning.run_if(in_state(SceneState::Spawning)),
|
||||
@@ -121,7 +121,7 @@ pub struct SkeletalJoint(pub Color);
|
||||
pub struct SceneRoot;
|
||||
|
||||
#[derive(Resource, Deref, DerefMut)]
|
||||
struct TestBvh(Handle<Bvh>); // TODO
|
||||
pub struct TestBvh(pub Handle<Bvh>); // TODO
|
||||
|
||||
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut)]
|
||||
pub struct BindPoseLocal(pub Transform);
|
||||
@@ -162,9 +162,6 @@ fn initialize(mut cmd: Commands, r_assets: Res<AssetServer>) {
|
||||
},
|
||||
Fxaa::default(),
|
||||
));
|
||||
|
||||
// TODO
|
||||
cmd.insert_resource(TestBvh(r_assets.load("mocap/shuffle.bvh")));
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user