-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0d6458
commit 23a4bc1
Showing
26 changed files
with
1,538 additions
and
2,253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/.vscode | ||
node_modules | ||
predist | ||
predist/** | ||
dist/bundle.js | ||
dist | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### WebGL basic game engine. | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ISObject } from "Engine/Core/SObject" | ||
import { IUpdatableSystem } from "Engine/core/SystemsManager"; | ||
import { Components } from "Engine/Core/CoreComponents/Components"; | ||
import { vec3, mat4 } from "gl-matrix"; | ||
|
||
const zeroVector: vec3 = vec3.fromValues(0, 0, 0); | ||
const unitVector: vec3 = vec3.fromValues(0, 0, 0); | ||
|
||
export abstract class Actor implements ISObject { | ||
public modelMatrix: mat4 = mat4.create(); | ||
|
||
constructor( | ||
public name: string, | ||
public transfrom: Components.Transfrom = new Components.Transfrom(zeroVector, zeroVector, unitVector) | ||
) { | ||
} | ||
|
||
public staticMesh!: Components.StaticMesh; | ||
public attachStaticMesh(mesh: Components.StaticMesh): void { | ||
this.staticMesh = mesh | ||
} | ||
|
||
abstract onUpdate(timestep: number): void; | ||
} | ||
|
||
export class ActorManager implements IUpdatableSystem { | ||
private actors: Actor[] = []; | ||
public update(timestep: number): void { | ||
for (const actor of this.actors) { | ||
actor.onUpdate(timestep); | ||
} | ||
} | ||
public registerActor(actor: Actor): void { | ||
this.actors.push(actor); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface IComponent { | ||
parant: number; | ||
child: number[]; | ||
} | ||
export interface ISObject { | ||
|
||
} | ||
|
||
export namespace SObject { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IUpdatableSystem | ||
{ | ||
update(timestep: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { mat4 } from "gl-matrix"; | ||
|
||
export class SceneGraph | ||
{ | ||
public nodes: SceneGraphNode[] = []; | ||
|
||
constructor(subGraph: SceneGraph | null) | ||
{ | ||
if(typeof subGraph === null) | ||
{ | ||
|
||
} | ||
else | ||
{ | ||
|
||
} | ||
} | ||
} | ||
|
||
class SceneGraphNode | ||
{ | ||
public parant: number = 0; | ||
public children: number[] = []; | ||
public transform: mat4 = mat4.create(); | ||
|
||
private static getParant(node: SceneGraphNode, graph: SceneGraphNode[]): SceneGraphNode | boolean { | ||
return node.parant != 0? graph[node.parant] : false; | ||
} | ||
|
||
public getRelativeTransform(graph: SceneGraphNode[]): mat4 { | ||
let transform = this.transform; | ||
let currentNode = SceneGraphNode.getParant(this, graph); | ||
if(currentNode !== false) | ||
{ | ||
mat4.multiply(transform, transform, (<SceneGraphNode>currentNode).transform); | ||
currentNode = SceneGraphNode.getParant(<SceneGraphNode>currentNode, graph); | ||
} | ||
return transform; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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 { | ||
|
||
} | ||
|
||
public registerNewSystem(system: IUpdatableSystem): void { | ||
this.runningSystems.push(system); | ||
} | ||
|
||
public registerNewTask(update: CallableFunction): void { | ||
this.runningTasks.push(update); | ||
} | ||
|
||
|
||
update(time: number) { | ||
for (const task of this.runningTasks) { | ||
task(time); | ||
} | ||
|
||
for (const system of this.runningSystems) { | ||
system.update(time); | ||
} | ||
|
||
this.lastUpdate = Date.now(); | ||
} | ||
|
||
|
||
public run(): void { | ||
let that = this; | ||
function loop() { | ||
var time: number = Date.now() - that.lastUpdate; | ||
that.update(time); | ||
requestAnimationFrame(loop); | ||
} | ||
requestAnimationFrame(loop) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.