import math
from pybevy.prelude import *
def setup(
commands: Commands,
asset_server: Res[AssetServer],
meshes: ResMut[Assets[Mesh]],
materials: ResMut[Assets[StandardMaterial]],
) -> None:
texture_handle = asset_server.load_image("bevy/branding/bevy_bird_dark.png")
aspect = 0.25
quad_width = 8.0
quad_handle = meshes.add(Rectangle(quad_width, quad_width * aspect).mesh())
material_handle = materials.add(
StandardMaterial(
base_color_texture=texture_handle,
alpha_mode=AlphaMode.Blend(),
unlit=True,
)
)
red_material_handle = materials.add(
StandardMaterial(
base_color=Color.srgba(1.0, 0.0, 0.0, 0.5),
base_color_texture=texture_handle,
alpha_mode=AlphaMode.Blend(),
unlit=True,
)
)
blue_material_handle = materials.add(
StandardMaterial(
base_color=Color.srgba(0.0, 0.0, 1.0, 0.5),
base_color_texture=texture_handle,
alpha_mode=AlphaMode.Blend(),
unlit=True,
)
)
commands.spawn(
Mesh3d(quad_handle),
MeshMaterial3d(material_handle),
Transform.from_xyz(0.0, 0.0, 1.5).with_rotation(
Quat.from_rotation_x(-math.pi / 5.0)
),
)
commands.spawn(
Mesh3d(quad_handle),
MeshMaterial3d(red_material_handle),
Transform.from_rotation(Quat.from_rotation_x(-math.pi / 5.0)),
)
commands.spawn(
Mesh3d(quad_handle),
MeshMaterial3d(blue_material_handle),
Transform.from_xyz(0.0, 0.0, -1.5).with_rotation(
Quat.from_rotation_x(-math.pi / 5.0)
),
)
commands.spawn(
Camera3d(),
Transform.from_xyz(3.0, 5.0, 8.0).looking_at(Vec3.ZERO, Vec3.Y),
)
@entrypoint
def main(app: App) -> App:
return app.add_plugins(DefaultPlugins).add_systems(Startup, setup)
if __name__ == "__main__":
main().run()