gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

what is the proper gpu.addFunction() returnType for function which returns 3 pairs of numbers (vertices of a triangle)?

Open dan-reznik opened this issue 3 years ago • 0 comments

What should the return type for a function which returns 3 vertices of a triangle (pairs of x,y values) be, so it works with GPU.js?

// this works
function transl(p,tr) {
  return [ p[0]+tr[0], p[1]+tr[1] ];
}
gpu.addFunction(transl, { {argumentTypes: { p: 'Array(2)', tr: 'Array(2)' }, returnType: 'Array(2)' });

// I cannot get this function to work
// what should I place on return type on the gpu.addFunction()?
// all I need is a simple array of 3 (x,y) values.
function get_tri(p1,p2,p3, tr) {
  const p1t = transl(p1,tr);
 const p2t = transl(p2,tr);
 const p3t = transl(p3,tr);
 // what should the declared returned type be here?
 return [p1t,p2t,p3t];
}
gpu.addFunction(get_tri,
   { {argumentTypes: { p1: 'Array(2)', p2: 'Array(2)', p3: 'Array(2)' },
      returnType: '???' });

dan-reznik avatar Apr 15 '21 12:04 dan-reznik