Is there any way to create a compute function in TSL that can take arguments? For instance, let’s say I create multiple views into different scenes, and I have a compute function that is run in each scene. Ideally, I don’t want to create the function in each scene, but simply create the function once and pass it a storage node.
Hypothetical code:
const initMethod = (currentElements) => {
currentElements.element(instanceIndex).assign(1)
}
const initFunction = Fn( ( [ currentElements ] ) => {
initMethod(currentElements)
})().compute(numElements)
initScene1() {
const currentElementsStorage1 = ...
const runFn1 = Fn( () => {
....
}
renderer.compute(initFunction(currentElementsStorage1))
renderer.compute(runFn1)
}
initScene2() {
const currentElementsStorage = ...
const runFn2 = Fn(() => {
...
}
renderer.compute(initFunction(currentElementsStorage2))
renderer.compute(runFn2)
}