View Full Version : Rotation to form pyramid

10-20-2010, 05:12 AM

I encounter some problems in doing the rotation in webgl.

I want to draw a triangle on the screen. But, I have one more requirement, the triangle will be drawn four times and each time the screen will rotate 90 degree. Therefore, it will form a pyramid.

However, I attempt to implement it with the following coding and it only shows me one triange and it rotates. Is there any mistake in my coding?

for (var j = 0; j < n; j++) {
var newRotationMatrix = createRotationMatrix(1, [0, 1, 0]);
rotationMatrix = newRotationMatrix.x(rotationMatrix);
gl.drawElements(gl.TRIANGLES, pyramidVertexIndexBuffer.numItems, gl.UNSIGNED_SHORT, 0);

Thanks for your help.

10-21-2010, 07:33 AM
Even if I use the "mvRotate(1, [0, 1, 0]);", it still cannot generate four triangles to form a pyramid.

If this method is fine, I can generate five or more triangles to form different pyramid.

Can anyone help me to solve the problem?