Skip to content

Commit 2b8e25d

Browse files
committed
Fix multiple multiplication
1 parent 919a75a commit 2b8e25d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/operators.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var opsRE = /\*|\+|\-|\/|\%|\<|\=|\>|\&|\||\!|\^|\~/;
4747
/**
4848
* Check if expression is protected by parentheses
4949
*/
50-
function isProtected (exp) {
50+
function isBraced (exp) {
5151
if (/\s/.test(exp)) {
5252
// a + b
5353
if (exp[0] !== '(') return false;
@@ -306,15 +306,15 @@ function processOperation (left, right, operator) {
306306

307307
// embrace complex operators
308308
if (operator != '+' && operator != '-') {
309-
if (!isProtected(left)) opResult += '(' + left + ')'
309+
if (!isBraced(left)) opResult += '(' + left + ')'
310310
else opResult += left
311311
}
312312
else opResult += left
313313

314314
opResult += ' ' + operator + ' '
315315

316316
if (operator != '+' && operator != '-') {
317-
if (!isProtected(right)) opResult += '(' + right + ')'
317+
if (!isBraced(right)) opResult += '(' + right + ')'
318318
else opResult += right
319319
}
320320
else opResult += right

test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ test('Vec/matrix operators', function () {
927927
var a = [1, 0, 0, 1], b = [1, 0, 0, 1], c = [1, 0, 0, 1];
928928
gl_Position = [(a[0] * b[0] + a[2] * b[1]) * c[0] + (a[0] * b[2] + a[2] * b[3]) * c[1], (a[1] * b[0] + a[3] * b[1]) * c[0] + (a[1] * b[2] + a[3] * b[3]) * c[1], (a[0] * b[0] + a[2] * b[1]) * c[2] + (a[0] * b[2] + a[2] * b[3]) * c[3], (a[1] * b[0] + a[3] * b[1]) * c[2] + (a[1] * b[2] + a[3] * b[3]) * c[3]];
929929
`))
930-
});
930+
})
931931

932932
test(`mat * mat * mat * vec`, function () {
933933
var compile = GLSL({includes: false});
@@ -941,8 +941,8 @@ test('Vec/matrix operators', function () {
941941
var d = [0, 0];
942942
gl_Position = [((a[0] * b[0] + a[2] * b[1]) * c[0] + (a[0] * b[2] + a[2] * b[3]) * c[1]) * d[0] + ((a[0] * b[0] + a[2] * b[1]) * c[2] + (a[0] * b[2] + a[2] * b[3]) * c[3]) * d[1], ((a[1] * b[0] + a[3] * b[1]) * c[0] + (a[1] * b[2] + a[3] * b[3]) * c[1]) * d[0] + ((a[1] * b[0] + a[3] * b[1]) * c[2] + (a[1] * b[2] + a[3] * b[3]) * c[3]) * d[1]];
943943
`))
944-
});
945-
});
944+
})
945+
})
946946

947947

948948
test('Swizzles', function () {

0 commit comments

Comments
 (0)