§ Как куб выглядит

§ Код инициализации
init()
{
this.shader = this.loadShaderTexture();
this.texture = this.loadTexture("/i/icon/math.png", 'nearest');
const vertices = [
-1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
1.0, -1.0, 1.0,
-1.0, -1.0, 1.0,
1.0, 1.0, -1.0,
-1.0, 1.0, -1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
1.0, -1.0, -1.0,
-1.0, -1.0, -1.0,
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, -1.0,
1.0, -1.0, -1.0,
1.0, -1.0, 1.0,
-1.0, 1.0, -1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, 1.0,
-1.0, -1.0, -1.0,
];
const indicies = [
0, 1, 2, 0, 2, 3,
4, 5, 6, 4, 6, 7,
8, 9, 10, 8, 10, 11,
12, 13, 14, 12, 14, 15,
16, 17, 18, 16, 18, 19,
20, 21, 22, 20, 22, 23,
];
const texcoord = [
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1,
0, 0, 1, 0, 1, 1, 0, 1,
];
this.the_cube = this.createNode(this.shader, vertices, indicies, texcoord, [this.texture]);
this._mx = 0; this._my = 0; this._mz = 0;
}
§ Код фрейма
loop()
{
this.cls(0, 0, 0);
this.camera = this.dot
(
this.matRotZ(this._mz),
this.matRotY(this._my),
this.matRotX(this._mx),
this.matTr(0, 0, -3),
);
this.drawNode(this.the_cube);
this._mx -= 0.01; this._my -= 0.02; this._mz -= 0.015;
}