Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

75
vendor/bevy/examples/remote/client.rs vendored Normal file
View File

@@ -0,0 +1,75 @@
//! A simple command line client that allows issuing queries to a remote Bevy
//! app via the BRP.
use anyhow::Result as AnyhowResult;
use argh::FromArgs;
use bevy::remote::{
builtin_methods::{BrpQuery, BrpQueryFilter, BrpQueryParams, BRP_QUERY_METHOD},
http::DEFAULT_ADDR,
http::DEFAULT_PORT,
BrpRequest,
};
/// Struct containing the command-line arguments that can be passed to this example.
///
/// The components are passed by their full type names positionally, while `host`
/// and `port` are optional arguments which should correspond to those used on
/// the server.
///
/// When running this example in conjunction with the `server` example, the `host`
/// and `port` can be left as their defaults.
///
/// For example, to connect to port 1337 on the default IP address and query for entities
/// with `Transform` components:
/// ```text
/// cargo run --example client -- --port 1337 bevy_transform::components::transform::Transform
/// ```
#[derive(FromArgs)]
struct Args {
/// the host IP address to connect to
#[argh(option, default = "DEFAULT_ADDR.to_string()")]
host: String,
/// the port to connect to
#[argh(option, default = "DEFAULT_PORT")]
port: u16,
/// the full type names of the components to query for
#[argh(positional, greedy)]
components: Vec<String>,
}
/// The application entry point.
fn main() -> AnyhowResult<()> {
// Parse the arguments.
let args: Args = argh::from_env();
// Create the URL. We're going to need it to issue the HTTP request.
let host_part = format!("{}:{}", args.host, args.port);
let url = format!("http://{}/", host_part);
let req = BrpRequest {
jsonrpc: String::from("2.0"),
method: String::from(BRP_QUERY_METHOD),
id: Some(serde_json::to_value(1)?),
params: Some(
serde_json::to_value(BrpQueryParams {
data: BrpQuery {
components: args.components,
option: Vec::default(),
has: Vec::default(),
},
strict: false,
filter: BrpQueryFilter::default(),
})
.expect("Unable to convert query parameters to a valid JSON value"),
),
};
let res = ureq::post(&url)
.send_json(req)?
.body_mut()
.read_json::<serde_json::Value>()?;
println!("{:#}", res);
Ok(())
}

90
vendor/bevy/examples/remote/server.rs vendored Normal file
View File

@@ -0,0 +1,90 @@
//! A Bevy app that you can connect to with the BRP and edit.
use bevy::math::ops::cos;
use bevy::{
input::common_conditions::input_just_pressed,
prelude::*,
remote::{http::RemoteHttpPlugin, RemotePlugin},
};
use serde::{Deserialize, Serialize};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RemotePlugin::default())
.add_plugins(RemoteHttpPlugin::default())
.add_systems(Startup, setup)
.add_systems(Update, remove.run_if(input_just_pressed(KeyCode::Space)))
.add_systems(Update, move_cube)
// New types must be registered in order to be usable with reflection.
.register_type::<Cube>()
.register_type::<TestResource>()
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// circular base
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// cube
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
Cube(1.0),
));
// test resource
commands.insert_resource(TestResource {
foo: Vec2::new(1.0, -1.0),
bar: false,
});
// light
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
Transform::from_xyz(4.0, 8.0, 4.0),
));
// camera
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
/// An arbitrary resource that can be inspected and manipulated with remote methods.
#[derive(Resource, Reflect, Serialize, Deserialize)]
#[reflect(Resource, Serialize, Deserialize)]
pub struct TestResource {
/// An arbitrary field of the test resource.
pub foo: Vec2,
/// Another arbitrary field.
pub bar: bool,
}
fn move_cube(mut query: Query<&mut Transform, With<Cube>>, time: Res<Time>) {
for mut transform in &mut query {
transform.translation.y = -cos(time.elapsed_secs()) + 1.5;
}
}
fn remove(mut commands: Commands, cube_entity: Single<Entity, With<Cube>>) {
commands.entity(*cube_entity).remove::<Cube>();
}
#[derive(Component, Reflect, Serialize, Deserialize)]
#[reflect(Component, Serialize, Deserialize)]
struct Cube(f32);