mirror of
https://github.com/bevyengine/bevy
synced 2024-11-13 00:17:27 +00:00
transition math to nalgebra and add tiny-town.
This commit is contained in:
parent
cd60778d46
commit
e204538ad7
11 changed files with 88 additions and 104 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,7 @@
|
||||||
/target
|
/target
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|
||||||
|
tiny-town/target
|
||||||
|
**/*.rs.bk
|
||||||
|
tiny-town/Cargo.lock
|
||||||
|
|
|
@ -6,11 +6,10 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
legion = { git = "https://github.com/TomGillen/legion.git" }
|
legion = { git = "https://github.com/TomGillen/legion.git" }
|
||||||
nalgebra = "0.18"
|
nalgebra-glm = "0.5.0"
|
||||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "44fa1bc2fa208fa92f80944253e0da56cb7ac1fe"}
|
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "44fa1bc2fa208fa92f80944253e0da56cb7ac1fe"}
|
||||||
winit = "0.20.0-alpha4"
|
winit = "0.20.0-alpha4"
|
||||||
glsl-to-spirv = "0.1"
|
glsl-to-spirv = "0.1"
|
||||||
cgmath = "0.17"
|
|
||||||
zerocopy = "0.2"
|
zerocopy = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
|
@ -13,7 +13,6 @@ fn main() {
|
||||||
// Create a query which finds all `Position` and `Velocity` components
|
// Create a query which finds all `Position` and `Velocity` components
|
||||||
let mut query = Read::<Transform>::query();
|
let mut query = Read::<Transform>::query();
|
||||||
|
|
||||||
|
|
||||||
// // Iterate through all entities that match the query in the world
|
// // Iterate through all entities that match the query in the world
|
||||||
for mut trans in query.iter(&mut world) {
|
for mut trans in query.iter(&mut world) {
|
||||||
// println!("{} hi", trans.global);
|
// println!("{} hi", trans.global);
|
||||||
|
|
|
@ -4,7 +4,8 @@ use winit::{
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
};
|
};
|
||||||
|
|
||||||
use zerocopy::{AsBytes, FromBytes};
|
use zerocopy::AsBytes;
|
||||||
|
use nalgebra_glm as glm;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -12,23 +13,6 @@ use std::mem;
|
||||||
use crate::temp::*;
|
use crate::temp::*;
|
||||||
use crate::vertex::*;
|
use crate::vertex::*;
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
||||||
#[allow(unused)]
|
|
||||||
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
|
|
||||||
1.0, 0.0, 0.0, 0.0,
|
|
||||||
0.0, -1.0, 0.0, 0.0,
|
|
||||||
0.0, 0.0, 0.5, 0.0,
|
|
||||||
0.0, 0.0, 0.5, 1.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn cast_slice<T>(data: &[T]) -> &[u8] {
|
|
||||||
use std::mem::size_of;
|
|
||||||
use std::slice::from_raw_parts;
|
|
||||||
|
|
||||||
unsafe { from_raw_parts(data.as_ptr() as *const u8, data.len() * size_of::<T>()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Application
|
pub struct Application
|
||||||
{
|
{
|
||||||
entities: Vec<Entity>,
|
entities: Vec<Entity>,
|
||||||
|
@ -38,6 +22,8 @@ pub struct Application
|
||||||
forward_pass: Pass,
|
forward_pass: Pass,
|
||||||
forward_depth: wgpu::TextureView,
|
forward_depth: wgpu::TextureView,
|
||||||
light_uniform_buf: wgpu::Buffer,
|
light_uniform_buf: wgpu::Buffer,
|
||||||
|
camera_position: glm::Vec3,
|
||||||
|
camera_fov: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Application {
|
impl Application {
|
||||||
|
@ -88,8 +74,6 @@ impl Application {
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut entities = vec![{
|
let mut entities = vec![{
|
||||||
use cgmath::SquareMatrix;
|
|
||||||
|
|
||||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
layout: &local_bind_group_layout,
|
layout: &local_bind_group_layout,
|
||||||
bindings: &[wgpu::Binding {
|
bindings: &[wgpu::Binding {
|
||||||
|
@ -101,7 +85,7 @@ impl Application {
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
Entity {
|
Entity {
|
||||||
mx_world: cgmath::Matrix4::identity(),
|
mx_world: glm::identity(),
|
||||||
rotation_speed: 0.0,
|
rotation_speed: 0.0,
|
||||||
color: wgpu::Color::WHITE,
|
color: wgpu::Color::WHITE,
|
||||||
vertex_buf: Rc::new(plane_vertex_buf),
|
vertex_buf: Rc::new(plane_vertex_buf),
|
||||||
|
@ -112,53 +96,39 @@ impl Application {
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
let camera_position = glm::vec3(3.0f32, -10.0, 6.0);
|
||||||
|
let camera_fov = glm::quarter_pi();
|
||||||
|
|
||||||
struct CubeDesc {
|
struct CubeDesc {
|
||||||
offset: cgmath::Vector3<f32>,
|
offset: glm::Vec3,
|
||||||
angle: f32,
|
|
||||||
scale: f32,
|
|
||||||
rotation: f32,
|
rotation: f32,
|
||||||
}
|
}
|
||||||
let cube_descs = [
|
let cube_descs = [
|
||||||
CubeDesc {
|
CubeDesc {
|
||||||
offset: cgmath::vec3(-2.0, -2.0, 2.0),
|
offset: glm::vec3(-2.0, -2.0, 2.0),
|
||||||
angle: 10.0,
|
|
||||||
scale: 0.7,
|
|
||||||
rotation: 0.1,
|
rotation: 0.1,
|
||||||
},
|
},
|
||||||
CubeDesc {
|
CubeDesc {
|
||||||
offset: cgmath::vec3(2.0, -2.0, 2.0),
|
offset: glm::vec3(2.0, -2.0, 2.0),
|
||||||
angle: 50.0,
|
|
||||||
scale: 1.3,
|
|
||||||
rotation: 0.2,
|
rotation: 0.2,
|
||||||
},
|
},
|
||||||
CubeDesc {
|
CubeDesc {
|
||||||
offset: cgmath::vec3(-2.0, 2.0, 2.0),
|
offset: glm::vec3(-2.0, 2.0, 2.0),
|
||||||
angle: 140.0,
|
|
||||||
scale: 1.1,
|
|
||||||
rotation: 0.3,
|
rotation: 0.3,
|
||||||
},
|
},
|
||||||
CubeDesc {
|
CubeDesc {
|
||||||
offset: cgmath::vec3(2.0, 2.0, 2.0),
|
offset: glm::vec3(2.0, 2.0, 2.0),
|
||||||
angle: 210.0,
|
|
||||||
scale: 0.9,
|
|
||||||
rotation: 0.4,
|
rotation: 0.4,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for cube in &cube_descs {
|
for cube in &cube_descs {
|
||||||
use cgmath::{Decomposed, Deg, InnerSpace, Quaternion, Rotation3};
|
|
||||||
|
|
||||||
let transform = Decomposed {
|
|
||||||
disp: cube.offset.clone(),
|
|
||||||
rot: Quaternion::from_axis_angle(cube.offset.normalize(), Deg(cube.angle)),
|
|
||||||
scale: cube.scale,
|
|
||||||
};
|
|
||||||
let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
|
let uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
size: entity_uniform_size,
|
size: entity_uniform_size,
|
||||||
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
||||||
});
|
});
|
||||||
entities.push(Entity {
|
entities.push(Entity {
|
||||||
mx_world: cgmath::Matrix4::from(transform),
|
mx_world: glm::translation(&cube.offset),
|
||||||
rotation_speed: cube.rotation,
|
rotation_speed: cube.rotation,
|
||||||
color: wgpu::Color::GREEN,
|
color: wgpu::Color::GREEN,
|
||||||
vertex_buf: Rc::clone(&cube_vertex_buf),
|
vertex_buf: Rc::clone(&cube_vertex_buf),
|
||||||
|
@ -217,26 +187,26 @@ impl Application {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let lights = vec![
|
let lights = vec![
|
||||||
Light {
|
Light {
|
||||||
pos: cgmath::Point3::new(7.0, -5.0, 10.0),
|
pos: glm::vec3(7.0, -5.0, 10.0),
|
||||||
color: wgpu::Color {
|
color: wgpu::Color {
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
g: 1.0,
|
g: 1.0,
|
||||||
b: 0.5,
|
b: 0.5,
|
||||||
a: 1.0,
|
a: 1.0,
|
||||||
},
|
},
|
||||||
fov: 60.0,
|
fov: f32::to_radians(60.0),
|
||||||
depth: 1.0 .. 20.0,
|
depth: 1.0 .. 20.0,
|
||||||
target_view: shadow_target_views[0].take().unwrap(),
|
target_view: shadow_target_views[0].take().unwrap(),
|
||||||
},
|
},
|
||||||
Light {
|
Light {
|
||||||
pos: cgmath::Point3::new(-5.0, 7.0, 10.0),
|
pos: glm::vec3(-5.0, 7.0, 10.0),
|
||||||
color: wgpu::Color {
|
color: wgpu::Color {
|
||||||
r: 1.0,
|
r: 1.0,
|
||||||
g: 0.5,
|
g: 0.5,
|
||||||
b: 0.5,
|
b: 0.5,
|
||||||
a: 1.0,
|
a: 1.0,
|
||||||
},
|
},
|
||||||
fov: 45.0,
|
fov: f32::to_radians(45.0),
|
||||||
depth: 1.0 .. 20.0,
|
depth: 1.0 .. 20.0,
|
||||||
target_view: shadow_target_views[1].take().unwrap(),
|
target_view: shadow_target_views[1].take().unwrap(),
|
||||||
},
|
},
|
||||||
|
@ -383,7 +353,7 @@ impl Application {
|
||||||
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
|
bind_group_layouts: &[&bind_group_layout, &local_bind_group_layout],
|
||||||
});
|
});
|
||||||
|
|
||||||
let mx_total = generate_matrix(sc_desc.width as f32 / sc_desc.height as f32);
|
let mx_total = generate_matrix(&camera_position, camera_fov, sc_desc.width as f32 / sc_desc.height as f32, 1.0, 20.0);
|
||||||
let forward_uniforms = ForwardUniforms {
|
let forward_uniforms = ForwardUniforms {
|
||||||
proj: *mx_total.as_ref(),
|
proj: *mx_total.as_ref(),
|
||||||
num_lights: [lights.len() as u32, 0, 0, 0],
|
num_lights: [lights.len() as u32, 0, 0, 0],
|
||||||
|
@ -501,6 +471,8 @@ impl Application {
|
||||||
forward_pass,
|
forward_pass,
|
||||||
forward_depth: depth_texture.create_default_view(),
|
forward_depth: depth_texture.create_default_view(),
|
||||||
light_uniform_buf,
|
light_uniform_buf,
|
||||||
|
camera_position,
|
||||||
|
camera_fov
|
||||||
};
|
};
|
||||||
(this, None)
|
(this, None)
|
||||||
}
|
}
|
||||||
|
@ -512,8 +484,8 @@ impl Application {
|
||||||
) -> Option<wgpu::CommandBuffer>
|
) -> Option<wgpu::CommandBuffer>
|
||||||
{
|
{
|
||||||
let command_buf = {
|
let command_buf = {
|
||||||
let mx_total = generate_matrix(sc_desc.width as f32 / sc_desc.height as f32);
|
let mx_total = generate_matrix(&self.camera_position, self.camera_fov, sc_desc.width as f32 / sc_desc.height as f32, 1.0, 20.0);
|
||||||
let mx_ref: &[f32; 16] = mx_total.as_ref();
|
let mx_ref: [[f32; 4]; 4] = mx_total.into();
|
||||||
let temp_buf =
|
let temp_buf =
|
||||||
device.create_buffer_with_data(mx_ref.as_bytes(), wgpu::BufferUsage::COPY_SRC);
|
device.create_buffer_with_data(mx_ref.as_bytes(), wgpu::BufferUsage::COPY_SRC);
|
||||||
|
|
||||||
|
@ -541,7 +513,7 @@ impl Application {
|
||||||
Some(command_buf)
|
Some(command_buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, event: WindowEvent)
|
fn update(&mut self, _: WindowEvent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +531,6 @@ impl Application {
|
||||||
let temp_buf_data = device
|
let temp_buf_data = device
|
||||||
.create_buffer_mapped(self.entities.len() * size, wgpu::BufferUsage::COPY_SRC);
|
.create_buffer_mapped(self.entities.len() * size, wgpu::BufferUsage::COPY_SRC);
|
||||||
|
|
||||||
// FIXME: Align and use `LayoutVerified`
|
|
||||||
for (entity, slot) in self
|
for (entity, slot) in self
|
||||||
.entities
|
.entities
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
|
@ -567,7 +538,7 @@ impl Application {
|
||||||
{
|
{
|
||||||
if entity.rotation_speed != 0.0 {
|
if entity.rotation_speed != 0.0 {
|
||||||
let rotation =
|
let rotation =
|
||||||
cgmath::Matrix4::from_angle_x(cgmath::Deg(entity.rotation_speed));
|
glm::rotation(entity.rotation_speed, &glm::vec3(0.0, 1.0, 0.0));
|
||||||
entity.mx_world = entity.mx_world * rotation;
|
entity.mx_world = entity.mx_world * rotation;
|
||||||
}
|
}
|
||||||
slot.copy_from_slice(
|
slot.copy_from_slice(
|
||||||
|
@ -603,7 +574,6 @@ impl Application {
|
||||||
let total_size = size * self.lights.len();
|
let total_size = size * self.lights.len();
|
||||||
let temp_buf_data =
|
let temp_buf_data =
|
||||||
device.create_buffer_mapped(total_size, wgpu::BufferUsage::COPY_SRC);
|
device.create_buffer_mapped(total_size, wgpu::BufferUsage::COPY_SRC);
|
||||||
// FIXME: Align and use `LayoutVerified`
|
|
||||||
for (light, slot) in self
|
for (light, slot) in self
|
||||||
.lights
|
.lights
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -4,4 +4,5 @@ mod vertex;
|
||||||
mod temp;
|
mod temp;
|
||||||
|
|
||||||
pub use transform::Transform;
|
pub use transform::Transform;
|
||||||
pub use application::Application;
|
pub use application::Application;
|
||||||
|
pub use legion;
|
62
src/temp.rs
62
src/temp.rs
|
@ -1,28 +1,18 @@
|
||||||
pub use std::rc::Rc;
|
pub use std::rc::Rc;
|
||||||
pub use std::ops::Range;
|
pub use std::ops::Range;
|
||||||
use zerocopy::{AsBytes, FromBytes};
|
use zerocopy::{AsBytes, FromBytes};
|
||||||
|
use nalgebra_glm as glm;
|
||||||
|
|
||||||
pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = cgmath::Matrix4::new(
|
pub fn opengl_to_wgpu_matrix() -> glm::Mat4 {
|
||||||
1.0,
|
glm::mat4(
|
||||||
0.0,
|
1.0, 0.0, 0.0, 0.0,
|
||||||
0.0,
|
0.0, -1.0, 0.0, 0.0,
|
||||||
0.0,
|
0.0, 0.0, 0.5, 0.0,
|
||||||
0.0,
|
0.0, 0.0, 0.5, 1.0,
|
||||||
-1.0,
|
)
|
||||||
0.0,
|
}
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.5,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.0,
|
|
||||||
0.5,
|
|
||||||
1.0,
|
|
||||||
);
|
|
||||||
|
|
||||||
pub struct Entity {
|
pub struct Entity {
|
||||||
pub mx_world: cgmath::Matrix4<f32>,
|
pub mx_world: glm::Mat4,
|
||||||
pub rotation_speed: f32,
|
pub rotation_speed: f32,
|
||||||
pub color: wgpu::Color,
|
pub color: wgpu::Color,
|
||||||
pub vertex_buf: Rc<wgpu::Buffer>,
|
pub vertex_buf: Rc<wgpu::Buffer>,
|
||||||
|
@ -33,7 +23,7 @@ pub struct Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Light {
|
pub struct Light {
|
||||||
pub pos: cgmath::Point3<f32>,
|
pub pos: glm::Vec3,
|
||||||
pub color: wgpu::Color,
|
pub color: wgpu::Color,
|
||||||
pub fov: f32,
|
pub fov: f32,
|
||||||
pub depth: Range<f32>,
|
pub depth: Range<f32>,
|
||||||
|
@ -50,19 +40,8 @@ pub struct LightRaw {
|
||||||
|
|
||||||
impl Light {
|
impl Light {
|
||||||
pub fn to_raw(&self) -> LightRaw {
|
pub fn to_raw(&self) -> LightRaw {
|
||||||
use cgmath::{Deg, EuclideanSpace, Matrix4, PerspectiveFov, Point3, Vector3};
|
|
||||||
|
|
||||||
let mx_view = Matrix4::look_at(self.pos, Point3::origin(), Vector3::unit_z());
|
|
||||||
let projection = PerspectiveFov {
|
|
||||||
fovy: Deg(self.fov).into(),
|
|
||||||
aspect: 1.0,
|
|
||||||
near: self.depth.start,
|
|
||||||
far: self.depth.end,
|
|
||||||
};
|
|
||||||
let mx_view_proj = OPENGL_TO_WGPU_MATRIX *
|
|
||||||
cgmath::Matrix4::from(projection.to_perspective()) * mx_view;
|
|
||||||
LightRaw {
|
LightRaw {
|
||||||
proj: *mx_view_proj.as_ref(),
|
proj: generate_matrix(&self.pos, self.fov, 1.0, self.depth.start, self.depth.end).into(),
|
||||||
pos: [self.pos.x, self.pos.y, self.pos.z, 1.0],
|
pos: [self.pos.x, self.pos.y, self.pos.z, 1.0],
|
||||||
color: [
|
color: [
|
||||||
self.color.r as f32,
|
self.color.r as f32,
|
||||||
|
@ -99,6 +78,7 @@ pub struct Pass {
|
||||||
pub uniform_buf: wgpu::Buffer,
|
pub uniform_buf: wgpu::Buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum ShaderStage {
|
pub enum ShaderStage {
|
||||||
Vertex,
|
Vertex,
|
||||||
Fragment,
|
Fragment,
|
||||||
|
@ -115,12 +95,14 @@ pub fn load_glsl(code: &str, stage: ShaderStage) -> Vec<u32> {
|
||||||
wgpu::read_spirv(glsl_to_spirv::compile(&code, ty).unwrap()).unwrap()
|
wgpu::read_spirv(glsl_to_spirv::compile(&code, ty).unwrap()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate_matrix(aspect_ratio: f32) -> cgmath::Matrix4<f32> {
|
pub fn generate_matrix(eye: &glm::Vec3, fov: f32, aspect_ratio: f32, near: f32, far: f32) -> glm::Mat4 {
|
||||||
let mx_projection = cgmath::perspective(cgmath::Deg(45f32), aspect_ratio, 1.0, 20.0);
|
let projection = glm::perspective(aspect_ratio, fov, near, far);
|
||||||
let mx_view = cgmath::Matrix4::look_at(
|
|
||||||
cgmath::Point3::new(3.0f32, -10.0, 6.0),
|
let view = glm::look_at_rh::<f32>(
|
||||||
cgmath::Point3::new(0f32, 0.0, 0.0),
|
&eye,
|
||||||
cgmath::Vector3::unit_z(),
|
&glm::vec3(0.0, 0.0, 0.0),
|
||||||
|
&glm::vec3(0.0, 0.0, 1.0),
|
||||||
);
|
);
|
||||||
OPENGL_TO_WGPU_MATRIX * mx_projection * mx_view
|
|
||||||
|
opengl_to_wgpu_matrix() * projection * view
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use nalgebra::Matrix4;
|
use nalgebra_glm as glm;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub struct Transform {
|
pub struct Transform {
|
||||||
pub local: Matrix4<f32>,
|
pub local: glm::Mat4,
|
||||||
pub global: Matrix4<f32>,
|
pub global: glm::Mat4,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Transform {
|
impl Transform {
|
||||||
pub fn new() -> Transform {
|
pub fn new() -> Transform {
|
||||||
Transform {
|
Transform {
|
||||||
local: Matrix4::<f32>::identity(),
|
local: glm::identity(),
|
||||||
global: Matrix4::<f32>::identity(),
|
global: glm::identity(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -73,6 +73,7 @@ pub fn create_plane(size: i8) -> (Vec<Vertex>, Vec<u16>) {
|
||||||
(vertex_data.to_vec(), index_data.to_vec())
|
(vertex_data.to_vec(), index_data.to_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn create_texels(size: usize) -> Vec<u8> {
|
pub fn create_texels(size: usize) -> Vec<u8> {
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
|
|
10
tiny-town/Cargo.toml
Normal file
10
tiny-town/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "tiny-town"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Carter Anderson <mcanders1@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = { path = "../" }
|
6
tiny-town/README.md
Normal file
6
tiny-town/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# run using this command
|
||||||
|
env RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo run --release
|
||||||
|
```
|
12
tiny-town/src/main.rs
Normal file
12
tiny-town/src/main.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
use bevy::*;
|
||||||
|
use bevy::legion::prelude::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let universe = Universe::new();
|
||||||
|
let mut world = universe.create_world();
|
||||||
|
world.insert((), vec![(Transform::new(),)]);
|
||||||
|
|
||||||
|
// Create a query which finds all `Position` and `Velocity` components
|
||||||
|
// let mut query = Read::<Transform>::query();
|
||||||
|
Application::run();
|
||||||
|
}
|
Loading…
Reference in a new issue