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

what is the parameter "arrayName" of createBufferFromArray for? could it be optional?

Open mizok opened this issue 2 years ago • 2 comments

In the document the third parameter arrayName of createBufferFromArray is said to be string type, but is not mentioned why we are giving this parameter.

So I checked attribute.js and found that this parameter is used to definite another boolean isIndice.

function createBufferFromArray(gl, array, arrayName) {
  const type = arrayName === "indices" ? ELEMENT_ARRAY_BUFFER : ARRAY_BUFFER;
  const typedArray = makeTypedArray(array, arrayName);
  return createBufferFromTypedArray(gl, typedArray, type);
}

I am just wondering if this parameter will be better if we change it to boolean type and make it optional (to me it's easier to understand)?

mizok avatar Apr 20 '22 02:04 mizok

I think it was probably my mistake to make that function public but if you want to make arrayName optional, or give it a default of "" that's fine with me.

greggman avatar Apr 21 '22 01:04 greggman

@greggman sure, I will make a pull request for that soon.

mizok avatar Apr 22 '22 03:04 mizok