diff --git a/examples/demo/src/main.rs b/examples/demo/src/main.rs index b28cc57..37b5490 100644 --- a/examples/demo/src/main.rs +++ b/examples/demo/src/main.rs @@ -2,9 +2,12 @@ use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, log::info, prelude::{ - App, Commands, IntoSystemConfigs, IntoSystemSetConfigs, PostUpdate, Query, Res, - SpatialBundle, Startup, Update, With, Without, Component, EventReader, Transform, GlobalTransform, + default, shape, App, Assets, Color, Commands, Component, Event, EventReader, EventWriter, + GlobalTransform, IntoSystemConfigs, IntoSystemSetConfigs, Mesh, PbrBundle, PostUpdate, + Query, Res, ResMut, Resource, SpatialBundle, StandardMaterial, Startup, Transform, Update, + With, Without, }, + time::{Time, Timer}, transform::TransformSystem, }; use bevy_openxr::{ @@ -13,8 +16,9 @@ use bevy_openxr::{ xr_input::{ debug_gizmos::OpenXrDebugRenderer, interactions::{ - interactions, update_interactable_states, XRDirectInteractor, XRInteractorState, - XRRayInteractor, draw_interaction_gizmos, draw_socket_gizmos, socket_interactions, InteractionEvent, + draw_interaction_gizmos, draw_socket_gizmos, interactions, socket_interactions, + update_interactable_states, InteractionEvent, Touched, XRDirectInteractor, + XRInteractable, XRInteractableState, XRInteractorState, XRRayInteractor, }, oculus_touch::OculusController, prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig}, @@ -44,7 +48,7 @@ fn main() { .add_plugins(OpenXrDebugRenderer) //rapier goes here .add_plugins(RapierPhysicsPlugin::::default().with_default_system_setup(false)) - .add_plugins(RapierDebugRenderPlugin::default()) + // .add_plugins(RapierDebugRenderPlugin::default()) //lets setup the starting scene .add_systems(Startup, setup_scene) .add_systems(Startup, spawn_controllers_example) //you need to spawn controllers or it crashes TODO:: Fix this @@ -68,6 +72,14 @@ fn main() { draw_interaction_gizmos.after(update_interactable_states), ) .add_systems(Update, draw_socket_gizmos.after(update_interactable_states)) + //add our cube spawning system + .add_event::() + .insert_resource(SpawnCubeTimer(Timer::from_seconds( + 0.25, + bevy::time::TimerMode::Once, + ))) + .add_systems(Update, request_cube_spawn) + .add_systems(Update, cube_spawner.after(request_cube_spawn)) ; //configure rapier sets @@ -121,6 +133,68 @@ fn spawn_controllers_example(mut commands: Commands) { )); } +#[derive(Event, Default)] +pub struct SpawnCubeRequest; + +#[derive(Resource)] +pub struct SpawnCubeTimer(Timer); + +fn request_cube_spawn( + oculus_controller: Res, + frame_state: Res, + xr_input: Res, + instance: Res, + session: Res, + mut writer: EventWriter, + time: Res