libNumericOps = ({
['+']: [{
args: {
a: types.float,
b: types.float,
},
resType: types.float,
js: (a, b) => a + b,
}, {
args: {
a: types.vec2,
b: types.float,
},
resType: types.vec2,
js: ([a0, a1], b) => [a0 + b, a1 + b],
}, {
args: {
a: types.vec3,
b: types.vec3,
},
resType: types.vec3,
js: ([a0, a1, a2], [b0, b1, b2]) => [a0 + b0, a1 + b1, a2 + b2],
}, {
args: {
a: types.vec4,
b: types.vec4,
},
resType: types.vec4,
js: ([a0, a1, a2, a3], [b0, b1, b2, b3]) => [a0 + b0, a1 + b1, a2 + b2, a3 + b3],
}],
['-@']: [{
args: {x: types.float},
resType: types.float,
js: x => -x,
}],
['-']: [{
args: {
a: types.float,
b: types.float,
},
resType: types.float,
js: (a, b) => a - b,
}, {
args: {
a: types.vec2,
b: types.vec2,
},
resType: types.vec2,
js: ([a0, a1], [b0, b1]) => [a0 - b0, a1 - b1],
}, {
args: {
a: types.vec2,
b: types.float,
},
resType: types.vec2,
js: ([a0, a1], b) => [a0 - b, a1 - b],
}, {
args: {
a: types.float,
b: types.vec3,
},
resType: types.vec3,
js: ([a0, a1, a2], b) => [a0 - b, a1 - b, a2 - b],
}, {
args: {
a: types.float,
b: types.vec4,
},
resType: types.vec2,
js: ([a0, a1], b) => [a0 - b, a1 - b],
}],
['*']: [{
args: {
a: types.float,
b: types.float,
},
resType: types.float,
js: (a, b) => a * b,
}, {
args: {
a: types.int,
b: types.int,
},
resType: types.int,
js: (a, b) => a * b,
}, {
args: {
a: types.vec2,
b: types.float,
},
resType: types.vec2,
js: ([a0, a1], b) => [a0 * b, a1 * b],
}, {
args: {
a: types.vec3,
b: types.float,
},
resType: types.vec3,
js: ([a0, a1, a2], b) => [a0 * b, a1 * b, a2 * b],
}, {
args: {
a: types.vec2,
b: types.mat2,
},
resType: types.vec2,
js: ([a0, a1], [b0, b1, b2, b3]) => [a0 * b0 + a1 * b2, a0 * b1 + a1 * b3],
}, {
args: {
a: types.vec3,
b: types.vec3,
},
resType: types.vec3,
js: ([a0, a1, a2], [b0, b1, b2]) => [a0 * b0, a1 * b1, a2 * b2],
}, {
args: {
a: types.float,
b: types.vec4,
},
resType: types.vec4,
js: (a, [b0, b1, b2, b3]) => [a * b0, a * b1, a * b2, a * b3],
}],
['/']: [{
args: {
a: types.float,
b: types.float,
},
resType: types.float,
js: (a, b) => a / b,
}, {
args: {
a: types.vec2,
b: types.float,
},
resType: types.vec2,
js: ([a0, a1], b) => [a0 / b, a1 / b],
}, {
args: {
a: types.vec3,
b: types.float,
},
resType: types.vec3,
js: ([a0, a1, a2], b) => [a0 / b, a1 / b, a2 / b],
}]
})