Просмотр исходного кода

TSL Transpiler: Fix unary negate after arithmetic operator (#31297)

* fix negate

* cleanup

* Update GLSLDecoder.js
sunag 6 месяцев назад
Родитель
Сommit
37c98fa6bc
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      examples/jsm/transpiler/GLSLDecoder.js

+ 3 - 0
examples/jsm/transpiler/GLSLDecoder.js

@@ -327,6 +327,9 @@ class GLSLDecoder {
 
 				if ( ! token.isOperator || i === 0 || i === tokens.length - 1 ) return;
 
+				// important for negate operator after arithmetic operator: a * -1, a * -( b )
+				if ( ( inverse && tokens[ i - 1 ].isOperator ) || ( ! inverse && tokens[ i + 1 ].isOperator ) ) return;
+
 				if ( groupIndex === 0 && token.str === operator ) {
 
 					if ( operator === '?' ) {

粤ICP备19079148号