11import { Vector3 } from './Vector3.js' ;
2+ import { WebGPU } from '../constants.js' ;
23
34class Matrix4 {
45
@@ -775,14 +776,24 @@ class Matrix4 {
775776
776777 const a = ( right + left ) / ( right - left ) ;
777778 const b = ( top + bottom ) / ( top - bottom ) ;
778- const c = - ( far + near ) / ( far - near ) ;
779- const d = - 2 * far * near / ( far - near ) ;
780779
781780 te [ 0 ] = x ; te [ 4 ] = 0 ; te [ 8 ] = a ; te [ 12 ] = 0 ;
782781 te [ 1 ] = 0 ; te [ 5 ] = y ; te [ 9 ] = b ; te [ 13 ] = 0 ;
783- te [ 2 ] = 0 ; te [ 6 ] = 0 ; te [ 10 ] = c ; te [ 14 ] = d ;
782+ te [ 2 ] = 0 ; te [ 6 ] = 0 ;
784783 te [ 3 ] = 0 ; te [ 7 ] = 0 ; te [ 11 ] = - 1 ; te [ 15 ] = 0 ;
785784
785+ if ( WebGPU . enabled === true ) { // #20276
786+
787+ te [ 10 ] = - far / ( far - near ) ;
788+ te [ 14 ] = - far * near / ( far - near ) ;
789+
790+ } else {
791+
792+ te [ 10 ] = - ( far + near ) / ( far - near ) ;
793+ te [ 14 ] = - 2 * far * near / ( far - near ) ;
794+
795+ }
796+
786797 return this ;
787798
788799 }
@@ -796,13 +807,24 @@ class Matrix4 {
796807
797808 const x = ( right + left ) * w ;
798809 const y = ( top + bottom ) * h ;
799- const z = ( far + near ) * p ;
800810
801811 te [ 0 ] = 2 * w ; te [ 4 ] = 0 ; te [ 8 ] = 0 ; te [ 12 ] = - x ;
802812 te [ 1 ] = 0 ; te [ 5 ] = 2 * h ; te [ 9 ] = 0 ; te [ 13 ] = - y ;
803- te [ 2 ] = 0 ; te [ 6 ] = 0 ; te [ 10 ] = - 2 * p ; te [ 14 ] = - z ;
813+ te [ 2 ] = 0 ; te [ 6 ] = 0 ;
804814 te [ 3 ] = 0 ; te [ 7 ] = 0 ; te [ 11 ] = 0 ; te [ 15 ] = 1 ;
805815
816+ if ( WebGPU . enabled === true ) { // #20276
817+
818+ te [ 10 ] = - 1 * p ;
819+ te [ 14 ] = - near * p ;
820+
821+ } else {
822+
823+ te [ 10 ] = - 2 * p ;
824+ te [ 14 ] = - ( far + near ) * p ;
825+
826+ }
827+
806828 return this ;
807829
808830 }
0 commit comments