-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
3,197 additions
and
485 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use bevy::prelude::*; | ||
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin}; | ||
use unavi_scripting::{ScriptBundle, ScriptingPlugin}; | ||
|
||
fn main() { | ||
App::new() | ||
.add_plugins(( | ||
DefaultPlugins.set(AssetPlugin { | ||
file_path: "../unavi-app/assets".to_string(), | ||
..Default::default() | ||
}), | ||
PanOrbitCameraPlugin, | ||
ScriptingPlugin, | ||
)) | ||
.add_systems(Startup, (setup_scene, load_script)) | ||
.run(); | ||
} | ||
|
||
fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) { | ||
ambient.brightness = 100.0; | ||
ambient.color = Color::rgb(0.95, 0.95, 1.0); | ||
|
||
commands.spawn(DirectionalLightBundle { | ||
transform: Transform::from_xyz(4.5, 10.0, -7.0).looking_at(Vec3::ZERO, Vec3::Y), | ||
..Default::default() | ||
}); | ||
|
||
let mut transform = Transform::from_xyz(0.0, 3.0, -10.0); | ||
transform.look_at(Vec3::new(0.0, 0.5, 0.0), Vec3::new(0.0, 1.0, 0.0)); | ||
|
||
commands.spawn(( | ||
Camera3dBundle { | ||
transform, | ||
..Default::default() | ||
}, | ||
PanOrbitCamera::default(), | ||
)); | ||
} | ||
|
||
pub fn load_script(asset_server: Res<AssetServer>, mut commands: Commands) { | ||
commands.spawn(( | ||
ScriptBundle::load("example:wired-input", &asset_server), | ||
SpatialBundle::default(), | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use wasm_bridge::component::Resource; | ||
|
||
use crate::state::StoreState; | ||
|
||
use super::wired::input::{ | ||
handler::{HostSpatialHandler, Node}, | ||
types::InputEvent, | ||
}; | ||
|
||
pub struct SpatialHandler; | ||
|
||
impl HostSpatialHandler for StoreState { | ||
fn new(&mut self, node: Resource<Node>) -> wasm_bridge::Result<Resource<SpatialHandler>> { | ||
let handler = SpatialHandler; | ||
let res = self.table.push_child(handler, &node)?; | ||
let rep = res.rep(); | ||
|
||
let node = self.table.get_mut(&node)?; | ||
node.handlers.push(res); | ||
|
||
Ok(Resource::new_own(rep)) | ||
} | ||
|
||
fn handle_input( | ||
&mut self, | ||
_self_: Resource<SpatialHandler>, | ||
) -> wasm_bridge::Result<Option<InputEvent>> { | ||
Ok(None) | ||
} | ||
|
||
fn drop(&mut self, _rep: Resource<SpatialHandler>) -> wasm_bridge::Result<()> { | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use anyhow::Result; | ||
use wasm_bridge::component::Linker; | ||
use wired::input::handler::Host; | ||
|
||
use crate::state::StoreState; | ||
|
||
pub mod handler; | ||
|
||
wasm_bridge::component::bindgen!({ | ||
path: "../../wired-protocol/spatial/wit/wired-input", | ||
world: "host", | ||
with: { | ||
"wired:gltf/material/material": super::wired_gltf::bindgen::Material, | ||
"wired:gltf/mesh/mesh": super::wired_gltf::bindgen::Mesh, | ||
"wired:gltf/mesh/primitive": super::wired_gltf::bindgen::Primitive, | ||
"wired:gltf/node/node": super::wired_gltf::bindgen::Node, | ||
"wired:input/handler/spatial-handler": handler::SpatialHandler, | ||
} | ||
}); | ||
|
||
impl Host for StoreState {} | ||
|
||
pub fn add_to_host(linker: &mut Linker<StoreState>) -> Result<()> { | ||
wired::input::handler::add_to_linker(linker, |s| s)?; | ||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.