§ Код
Здесь приведена одна из небольших реализации моего 3Д движка.

class WebGLApp extends WebGLFrameWork
{
init()
{
this.shader = this.loadShaderTexture();
this.texture = this.loadTexture("/i/icon/math.png");
this.the_cube = this.makeCube(this.shader, this.texture, this.matMove(0,0,-3));
}
loop()
{
this.cls();
if (this.keyboard.w) this.cam.z -= 0.05;
if (this.keyboard.a) this.cam.x -= 0.05;
if (this.keyboard.s) this.cam.z += 0.05;
if (this.keyboard.d) this.cam.x += 0.05;
this.updateDefaultCamera();
this.drawNode(this.the_cube);
}
mouseMove(x,y)
{
if (this.mouse.press) {
this.cam.ry -= (x - this.mouse.lastx) / 200; this.mouse.lastx = x;
this.cam.rx -= (y - this.mouse.lasty) / 200; this.mouse.lasty = y;
}
}
keyCode(c, state)
{
if (c === 87) this.keyboard.w = state;
if (c === 83) this.keyboard.s = state;
if (c === 65) this.keyboard.a = state;
if (c === 68) this.keyboard.d = state;
}
}