use bevy::prelude::*;
use bevy_cef::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, CefPlugin::default()))
.add_systems(Startup, (spawn_scene, spawn_webview))
.run();
}
fn spawn_scene(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0., 0., 4.)).looking_at(Vec3::ZERO, Vec3::Y),
));
commands.spawn((
DirectionalLight::default(),
Transform::from_translation(Vec3::new(1., 1., 1.)).looking_at(Vec3::ZERO, Vec3::Y),
));
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(6.0, 6.0))),
MeshMaterial3d(materials.add(Color::srgb(0.25, 0.25, 0.35))),
Transform::from_translation(Vec3::new(0.0, -1.5, -1.0))
.with_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
}
fn spawn_webview(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<WebviewExtendStandardMaterial>>,
) {
commands.spawn((
WebviewSource::local("resize_demo.html"),
Mesh3d(meshes.add(Plane3d::new(Vec3::Z, Vec2::ONE))),
MeshMaterial3d(materials.add(WebviewExtendStandardMaterial::default())),
Transform::from_translation(Vec3::ZERO),
WebviewResizable::default(),
));
}