2014-06-10 3 views
3

사람이 다음과 같은 코드를 좀 도와 주시겠습니까 : 나는 직교 카메라로 큐브를 표시하려고하지만, 내가 볼 모두 검은 색 http://jsfiddle.net/bepa/2QXkp/WebGL을 직교 카메라

gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); 
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 
mat4.ortho(pMatrix, 0, gl.viewportWidth, 0, gl.viewportHeight, 0.1, 100); 
mat4.identity(mvMatrix); 
mat4.lookAt(mvMatrix, [0, 0, -40], [0, 0, 0], [0, 1, 0]); 

전체 소스. 큐브는 (0, 0, 0), 카메라 (0, 0, -40)이어야하며 (0, 0, 0)을보아야합니다.

모든 행렬 변환에 대해 gl-matrix 2.2.0을 사용합니다.

편집 :이 제대로 작동

:

mat4.perspective(pMatrix, 45, gl.viewportWidth/gl.viewportHeight, 0.1, 100.0); 
mat4.identity(mvMatrix); 
mat4.lookAt(mvMatrix, [0, 40, -40], [0, 0, 0], [0, 1, 0]); 
mat4.rotate(mvMatrix, mvMatrix, degToRad(45), [0, 1, 0]); 

이 작동하지 않습니다 :

mat4.ortho(pMatrix, 0, gl.viewportWidth, 0, gl.viewportHeight, 0.1, 100); 
mat4.identity(mvMatrix); 
mat4.lookAt(mvMatrix, [0, 40, -40], [0, 0, 0], [0, 1, 0]); 
mat4.rotate(mvMatrix, mvMatrix, degToRad(45), [0, 1, 0]); 

답변

4
mat4.ortho(pMatrix, -1.0, 1.0, -1.0, 1.0, 0.1, 100); 

검은하지 않은 결과를 제공합니다)

mat4.ortho의 문서() :

정사영을 위해 캔버스의 너비와 높이가 필요하지 않습니다. 하지만 왜 투영 행렬에 익숙하지 않아서 왜 당신에게 깊이있는 설명을 줄지는 못합니다.

+0

대단히 감사합니다. 마침내 약간의 색상을 볼 수 있습니다 :) – coda

+0

이 게시물을 참조하십시오 : http://stackoverflow.com/questions/11088678/webgl-isometric-projection –