still trying to get this thing to render. it, for a split second rendered correctly. But now no dice..

This commit is contained in:
2021-02-04 00:31:30 -08:00
parent 8d7a62da7f
commit 3d87d11485
2 changed files with 148 additions and 140 deletions

View File

@@ -7,7 +7,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use bytemuck::__core::ops::Range;
use cgmath::{Matrix4, Point3};
use cgmath::{Matrix4, Point3, Decomposed, Quaternion, Rotation3, Deg, InnerSpace, SquareMatrix};
use futures::task::LocalSpawn;
use legion::*;
use wgpu::{BindGroup, Buffer, TextureView};
@@ -138,6 +138,9 @@ pub struct Mesh {
fn main() {
// #[cfg(not(target_arch = "wasm32"))]
// {
// let chrome_tracing_dir = std::env::var("WGPU_CHROME_TRACE");
@@ -215,9 +218,18 @@ fn main() {
let mut renderer = render::Renderer::init(window);
let untitled_mesh =
renderer.load_mesh_to_buffer("./resources/untitled.obj");
renderer.load_mesh_to_buffer("./resources/monkey.obj");
// This could be used for relationships between entities...???
let light_entity: Entity = world.push((
cgmath::Point3 {
x: 7.0 as f32,
y: -5.0 as f32,
z: 10.0 as f32,
},
renderer.create_light(),
));
let light_entity: Entity = world.push((
cgmath::Point3 {
x: -5.0 as f32,
@@ -227,12 +239,19 @@ fn main() {
renderer.create_light(),
));
let offset = cgmath::vec3(2.0, 2.0, 2.0);
let transform = Decomposed {
disp: offset.clone(),
rot: Quaternion::from_axis_angle(offset.normalize(), Deg(50.0)),
scale: 1.0,
};
let mesh_entity: Entity = world.push((
Position {
x: -5.0,
y: 7.0,
x: 17.0,
y: 15.0,
z: 10.0,
mx: OPENGL_TO_WGPU_MATRIX,
mx: cgmath::Matrix4::from(transform),
},
untitled_mesh,
Color {
@@ -243,47 +262,25 @@ fn main() {
},
));
let entities: &[Entity] = world.extend(vec![
(
Position {
x: 0.0,
y: 0.0,
z: 0.0,
mx: OPENGL_TO_WGPU_MATRIX,
},
Velocity {
dx: 0.0,
dy: 0.0,
rs: 0.0,
},
),
(
Position {
x: 1.0,
y: 1.0,
z: 0.0,
mx: OPENGL_TO_WGPU_MATRIX,
},
Velocity {
dx: 0.0,
dy: 0.0,
rs: 0.0,
},
),
(
Position {
x: 2.0,
y: 2.0,
z: 0.0,
mx: OPENGL_TO_WGPU_MATRIX,
},
Velocity {
dx: 0.0,
dy: 0.0,
rs: 0.0,
},
),
]);
let plane_mesh =
renderer.create_plane(7.0);
// let plane_entity: Entity = world.push((
// Position {
// x: 0.0,
// y: 0.0,
// z: 0.0,
// mx: cgmath::Matrix4::identity(),
// },
// plane_mesh,
// Color {
// r: 1.0,
// g: 0.5,
// b: 0.5,
// a: 1.0,
// },
// ));
// Init, this wants the references to the buffers...
let mut runtime = runtime::Runtime::init();