@@ -1109,6 +1109,7 @@ class Matrix4 {
11091109 makePerspective ( left , right , top , bottom , near , far , coordinateSystem = WebGLCoordinateSystem , reversedDepth = false ) {
11101110
11111111 const te = this . elements ;
1112+
11121113 const x = 2 * near / ( right - left ) ;
11131114 const y = 2 * near / ( top - bottom ) ;
11141115
@@ -1168,31 +1169,31 @@ class Matrix4 {
11681169 makeOrthographic ( left , right , top , bottom , near , far , coordinateSystem = WebGLCoordinateSystem , reversedDepth = false ) {
11691170
11701171 const te = this . elements ;
1171- const w = 1.0 / ( right - left ) ;
1172- const h = 1.0 / ( top - bottom ) ;
1173- const p = 1.0 / ( far - near ) ;
11741172
1175- const x = ( right + left ) * w ;
1176- const y = ( top + bottom ) * h ;
1173+ const x = 2 / ( right - left ) ;
1174+ const y = 2 / ( top - bottom ) ;
1175+
1176+ const a = - ( right + left ) / ( right - left ) ;
1177+ const b = - ( top + bottom ) / ( top - bottom ) ;
11771178
1178- let z , zInv ;
1179+ let c , d ;
11791180
11801181 if ( reversedDepth ) {
11811182
1182- z = - near * p - 1 ;
1183- zInv = 1 * p ;
1183+ c = 1 / ( far - near ) ;
1184+ d = far / ( far - near ) ;
11841185
11851186 } else {
11861187
11871188 if ( coordinateSystem === WebGLCoordinateSystem ) {
11881189
1189- z = ( far + near ) * p ;
1190- zInv = - 2 * p ;
1190+ c = - 2 / ( far - near ) ;
1191+ d = - ( far + near ) / ( far - near ) ;
11911192
11921193 } else if ( coordinateSystem === WebGPUCoordinateSystem ) {
11931194
1194- z = near * p ;
1195- zInv = - 1 * p ;
1195+ c = - 1 / ( far - near ) ;
1196+ d = - near / ( far - near ) ;
11961197
11971198 } else {
11981199
@@ -1202,9 +1203,9 @@ class Matrix4 {
12021203
12031204 }
12041205
1205- te [ 0 ] = 2 * w ; te [ 4 ] = 0 ; te [ 8 ] = 0 ; te [ 12 ] = - x ;
1206- te [ 1 ] = 0 ; te [ 5 ] = 2 * h ; te [ 9 ] = 0 ; te [ 13 ] = - y ;
1207- te [ 2 ] = 0 ; te [ 6 ] = 0 ; te [ 10 ] = zInv ; te [ 14 ] = - z ;
1206+ te [ 0 ] = x ; te [ 4 ] = 0 ; te [ 8 ] = 0 ; te [ 12 ] = a ;
1207+ te [ 1 ] = 0 ; te [ 5 ] = y ; te [ 9 ] = 0 ; te [ 13 ] = b ;
1208+ te [ 2 ] = 0 ; te [ 6 ] = 0 ; te [ 10 ] = c ; te [ 14 ] = d ;
12081209 te [ 3 ] = 0 ; te [ 7 ] = 0 ; te [ 11 ] = 0 ; te [ 15 ] = 1 ;
12091210
12101211 return this ;
0 commit comments