Skip to content

Commit

Permalink
Removal of hardcoded assets.
Browse files Browse the repository at this point in the history
Removal of hardcoded assets such as.
-Models.
-Shaders.
-Textures.
  • Loading branch information
AbdullahAmrSobh committed Sep 23, 2020
1 parent 0e82616 commit aae0cbf
Show file tree
Hide file tree
Showing 21 changed files with 384 additions and 247 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
target
dist
36 changes: 0 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"name": "webgl3drenderer",
"version": "1.0.0",
"description": "3D PBR WIP renderer",
"version": "0.1.0",
"description": "3D Game engine on the web.",
"private": true,

"scripts": {
"dev": "concurrently --kill-others \"webpack watch --dev\" \"tsc --watch\"",
"build": "webpack --config webpack.config.js",
"watchwp": "webpack --watch",
"watchts": "tsc --watch"
"watchts": "tsc --watch",
"serve": "webpack-dev-server",
"watch": "",
"clean": ""
},

"author": "Abdullah Amr",

"license": "ISC",

"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
Expand All @@ -23,6 +30,7 @@
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},

"dependencies": {
"gl-matrix": "^3.1.0"
}
Expand Down
1 change: 1 addition & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//todo.
1 change: 1 addition & 0 deletions scripts/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//todo.
1 change: 1 addition & 0 deletions scripts/watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//todo.
65 changes: 64 additions & 1 deletion src/CameraController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export abstract class Projection {
public abstract update(): void;
}





export namespace Projection {
export class Prespective extends Projection {
constructor (
Expand Down Expand Up @@ -47,6 +51,13 @@ export namespace Projection {
}
}



class KeyStateMap {
constructor(public name: string, public state: boolean) {}
}


export class CameraController implements IUpdatableSystem {


Expand All @@ -63,8 +74,26 @@ export class CameraController implements IUpdatableSystem {
this.oriantation
);

console.log("camera controller init");
window.addEventListener("keydown", event => {
if ( event.key == "w") this.activeKeys[0].state = true;
if ( event.key == "s") this.activeKeys[1].state = true;
if ( event.key == "d") this.activeKeys[2].state = true;
if ( event.key == "a") this.activeKeys[3].state = true;
});

window.addEventListener("keyup", event => {
if ( event.key == "w") this.activeKeys[0].state = false;
if ( event.key == "s") this.activeKeys[1].state = false;
if ( event.key == "d") this.activeKeys[2].state = false;
if ( event.key == "a") this.activeKeys[3].state = false;
});

}




public updateCameraMatrix(timestep: number): void {
this.viewMatrix = mat4.lookAt(
this.viewMatrix,
Expand All @@ -75,8 +104,42 @@ export class CameraController implements IUpdatableSystem {
}

public update(timestep: number): void {


if(this.activeKeys[0].state) this.moveForward();
if(this.activeKeys[1].state) this.moveBackward();
if(this.activeKeys[2].state) this.moveRight();
if(this.activeKeys[3].state) this.moveLeft();

}

private moveForward() : void {
console.log("moving forward");
vec3.add(this.position, this.position, this.forwardVector);
}

private moveBackward() : void {
vec3.add(this.position, this.position, vec3.scale(new vec3(), this.forwardVector, -1));
}

private moveRight() : void {
console.log("moving to the right");
}

private moveLeft() : void {
console.log("moving to the left");
}



private activeKeys: Array<KeyStateMap> = [
new KeyStateMap("w", false),
new KeyStateMap("s", false),
new KeyStateMap("d", false),
new KeyStateMap("a", false),
];

private forwardVector: vec3 = vec3.fromValues(0, 1, 0);
private rightVector: vec3 = vec3.fromValues(0, 0, 1);
}

export namespace CameraController {
Expand Down
4 changes: 1 addition & 3 deletions src/Engine.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { IUpdatableSystem } from "Engine/core/SystemsManager";


export class Engine {
private lastUpdate: number = 0;

private runningSystems: IUpdatableSystem[] = [];
private runningTasks: CallableFunction[] = [];

constructor(renderingContext: WebGLRenderingContext) {

}

public onInit(context: WebGLRenderingContext): void {

}
Expand All @@ -35,7 +34,6 @@ export class Engine {
this.lastUpdate = Date.now();
}


public run(): void {
let that = this;
function loop() {
Expand Down
4 changes: 0 additions & 4 deletions src/assets/image.ts

This file was deleted.

Loading

0 comments on commit aae0cbf

Please sign in to comment.