Skip to content

Commit

Permalink
init example-unavi-vscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Sep 10, 2024
1 parent 781c249 commit 7f6714a
Show file tree
Hide file tree
Showing 8 changed files with 5,680 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions crates/unavi-scripting/examples/unavi-vscreen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use avian3d::prelude::*;
use bevy::prelude::*;
use unavi_player::PlayerPlugin;
use unavi_scripting::{ScriptBundle, ScriptingPlugin};

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
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::linear_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()
});

commands.spawn((
SpatialBundle {
transform: Transform::from_xyz(0.0, -1.0, 0.0),
..default()
},
Collider::cuboid(20.0, 0.5, 20.0),
RigidBody::Static,
));
}

pub fn load_script(asset_server: Res<AssetServer>, mut commands: Commands) {
commands.spawn((
ScriptBundle::load("example:unavi-vscreen", &asset_server),
SpatialBundle::default(),
));
}
6 changes: 3 additions & 3 deletions wasm/example-unavi-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ impl GuestScript for Script {
}
}

struct Types;
struct GuestImpl;

impl Guest for Types {
impl Guest for GuestImpl {
type Script = Script;
}

bindings::export!(Types with_types_in bindings);
bindings::export!(GuestImpl with_types_in bindings);
31 changes: 31 additions & 0 deletions wasm/example-unavi-vscreen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "example-unavi-vscreen"
publish = false
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true

[lib]
crate-type = ["cdylib"]

[dependencies]
wit-bindgen-rt.workspace = true

[package.metadata.component]
package = "example:unavi-vscreen"

[package.metadata.component.target.dependencies]
"unavi:layout" = { path = "../unavi-layout/wit" }
"unavi:scene" = { path = "../unavi-scene/wit" }
"unavi:shapes" = { path = "../unavi-shapes/wit" }
"unavi:ui" = { path = "../unavi-ui/wit" }
"unavi:vscreen" = { path = "../unavi-vscreen/wit" }
"wired:input" = { path = "../../wired-protocol/spatial/wit/wired-input" }
"wired:log" = { path = "../../wired-protocol/spatial/wit/wired-log" }
"wired:math" = { path = "../../wired-protocol/spatial/wit/wired-math" }
"wired:physics" = { path = "../../wired-protocol/spatial/wit/wired-physics" }
"wired:player" = { path = "../../wired-protocol/spatial/wit/wired-player" }
"wired:prelude" = { path = "../../wired-protocol/spatial/wit/wired-prelude" }
"wired:scene" = { path = "../../wired-protocol/spatial/wit/wired-scene" }
"wired:script" = { path = "../../wired-protocol/spatial/wit/wired-script" }
Loading

0 comments on commit 7f6714a

Please sign in to comment.