Rzut izometryczny WebGL

W porządku. Robię trochę WebGL i próbuję stworzyć kostkę izometryczną. Nie chcę używać Three.js. Chcę najpierw zrozumieć, co jest nie tak w moim kodzie. Badałem i jedyne tutoriale, które mogę znaleźć, wydają się dotyczyć OpenGL

W każdym razie - oto moja funkcja drawScene:

function drawScene() {

this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
mat4.perspective(45, this.gl.viewportWidth / this.gl.viewportHeight, 0.1, 100.0, pMatrix);
mvMatrix = mat4.lookAt([0,0,40], [0, 0, 0], [0, 1, 0]);

_globalNext = this._first;

    while(_globalNext) {
    _globalNext.render();
    }

}

a funkcja renderowania jest

function render() {

mvPushMatrix();

//transform. order matters.
mat4.translate(mvMatrix, [this._x, this._y, this._z]);
mat4.rotate(mvMatrix, 0.01745*this._rot, [this._axisX, this._axisY, this._axisZ]);
mat4.scale(mvMatrix,  [this._scaleX,this._scaleY,this._scaleZ]);

//bind the buffers.
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._positionBuff);
this.gl.vertexAttribPointer(this._shader.vertexPositionAttribute, this._positionBuff.itemSize,   this.gl.FLOAT, false, 0, 0);

this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this._colorBuff);
this.gl.vertexAttribPointer(this._shader.vertexColorAttribute, this._colorBuff.itemSize, this.gl.FLOAT, false, 0, 0);

this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this._indexBuff);
this.setMatrixUniforms(this.gl);
this.gl.drawElements(this.gl.TRIANGLES, this._indexBuff.numItems, this.gl.UNSIGNED_SHORT, 0);

    if(this._usePopper == false) {
    mvPopMatrix();
    } 

_globalNext = this._nextSib;
}

Dość pieszy. Używam go do rysowania kostek. W każdym razie w przykładach OpenGL zdają się one rezygnować z funkcji perspektywy, ale tutaj, jeśli to zostawię, moja scena jest pusta. Wiem, że funkcja lookAt działa poprawnie i muszę to zrobićcoś z matrycą perspektywiczną. Mała pomoc byłaby doceniana. Dziękuję Ci!

questionAnswers(1)

yourAnswerToTheQuestion