1+ import { WebGLCoordinateSystem } from '../../constants.js' ;
12import TempNode from '../core/TempNode.js' ;
23import { addMethodChaining , nodeProxy } from '../tsl/TSLCore.js' ;
34
@@ -117,6 +118,7 @@ class OperatorNode extends TempNode {
117118 } else {
118119
119120 // Handle matrix operations
121+
120122 if ( builder . isMatrix ( typeA ) ) {
121123
122124 if ( typeB === 'float' ) {
@@ -148,6 +150,7 @@ class OperatorNode extends TempNode {
148150 }
149151
150152 // Handle non-matrix cases
153+
151154 if ( builder . getTypeLength ( typeB ) > builder . getTypeLength ( typeA ) ) {
152155
153156 // anytype x anytype: use the greater length vector
@@ -201,6 +204,7 @@ class OperatorNode extends TempNode {
201204 if ( typeB === 'float' ) {
202205
203206 // Keep matrix type for typeA, but ensure typeB stays float
207+
204208 typeB = 'float' ;
205209
206210 } else if ( builder . isVector ( typeB ) ) {
@@ -209,7 +213,9 @@ class OperatorNode extends TempNode {
209213 typeB = builder . getVectorFromMatrix ( typeA ) ;
210214
211215 } else if ( builder . isMatrix ( typeB ) ) {
216+
212217 // matrix x matrix - keep both types
218+
213219 } else {
214220
215221 typeA = typeB = type ;
@@ -221,11 +227,13 @@ class OperatorNode extends TempNode {
221227 if ( typeA === 'float' ) {
222228
223229 // Keep matrix type for typeB, but ensure typeA stays float
230+
224231 typeA = 'float' ;
225232
226233 } else if ( builder . isVector ( typeA ) ) {
227234
228235 // vector x matrix
236+
229237 typeA = builder . getVectorFromMatrix ( typeB ) ;
230238
231239 } else {
@@ -256,50 +264,90 @@ class OperatorNode extends TempNode {
256264
257265 if ( output !== 'void' ) {
258266
259- if ( op === '<' && outputLength > 1 ) {
267+ const isGLSL = builder . renderer . coordinateSystem === WebGLCoordinateSystem ;
268+
269+ if ( op === '==' ) {
270+
271+ if ( isGLSL ) {
272+
273+ if ( outputLength > 1 ) {
274+
275+ return builder . format ( `${ builder . getMethod ( 'equal' , output ) } ( ${ a } , ${ b } )` , type , output ) ;
276+
277+ } else {
278+
279+ return builder . format ( `( ${ a } ${ op } ${ b } )` , type , output ) ;
280+
281+ }
282+
283+ } else {
284+
285+ // WGSL
286+
287+ if ( outputLength > 1 || ! builder . isVector ( typeA ) ) {
288+
289+ return builder . format ( `( ${ a } == ${ b } )` , type , output ) ;
260290
261- if ( builder . useComparisonMethod ) {
291+ } else {
292+
293+ return builder . format ( `all( ${ a } == ${ b } )` , type , output ) ;
294+
295+ }
296+
297+ }
298+
299+ } else if ( op === '<' && outputLength > 1 ) {
300+
301+ if ( isGLSL ) {
262302
263303 return builder . format ( `${ builder . getMethod ( 'lessThan' , output ) } ( ${ a } , ${ b } )` , type , output ) ;
264304
265305 } else {
266306
307+ // WGSL
308+
267309 return builder . format ( `( ${ a } < ${ b } )` , type , output ) ;
268310
269311 }
270312
271313 } else if ( op === '<=' && outputLength > 1 ) {
272314
273- if ( builder . useComparisonMethod ) {
315+ if ( isGLSL ) {
274316
275317 return builder . format ( `${ builder . getMethod ( 'lessThanEqual' , output ) } ( ${ a } , ${ b } )` , type , output ) ;
276318
277319 } else {
278320
321+ // WGSL
322+
279323 return builder . format ( `( ${ a } <= ${ b } )` , type , output ) ;
280324
281325 }
282326
283327 } else if ( op === '>' && outputLength > 1 ) {
284328
285- if ( builder . useComparisonMethod ) {
329+ if ( isGLSL ) {
286330
287331 return builder . format ( `${ builder . getMethod ( 'greaterThan' , output ) } ( ${ a } , ${ b } )` , type , output ) ;
288332
289333 } else {
290334
335+ // WGSL
336+
291337 return builder . format ( `( ${ a } > ${ b } )` , type , output ) ;
292338
293339 }
294340
295341 } else if ( op === '>=' && outputLength > 1 ) {
296342
297- if ( builder . useComparisonMethod ) {
343+ if ( isGLSL ) {
298344
299345 return builder . format ( `${ builder . getMethod ( 'greaterThanEqual' , output ) } ( ${ a } , ${ b } )` , type , output ) ;
300346
301347 } else {
302348
349+ // WGSL
350+
303351 return builder . format ( `( ${ a } >= ${ b } )` , type , output ) ;
304352
305353 }
@@ -315,6 +363,7 @@ class OperatorNode extends TempNode {
315363 } else {
316364
317365 // Handle matrix operations
366+
318367 if ( builder . isMatrix ( typeA ) && typeB === 'float' ) {
319368
320369 return builder . format ( `( ${ b } ${ op } ${ a } )` , type , output ) ;
0 commit comments