toArray method

dynamic toArray([
  1. dynamic array,
  2. int offset = 0
])

dart array can not expand default so have to set array length enough first.

Implementation

// It's working, but ugly. consider to adds a new function:
// toBufferAttribute(BufferAttribute attribute, int index) ???
toArray([array, int offset = 0]) {
  array ??= List<double>.filled(3, 0.0);

  array[offset] = r;
  array[offset + 1] = g;
  array[offset + 2] = b;

  return array;
}