setInstance method

void setInstance(
  1. int index, {
  2. required Vector3 center,
  3. required double width,
  4. required double height,
  5. double rotation = 0.0,
  6. Vector4? color,
  7. double frame = 0.0,
  8. Vector3? velocity,
})

Writes one instance's fields at index into instanceData. A convenience over hand-indexing the flat buffer; call commit when done.

Implementation

void setInstance(
  int index, {
  required vm.Vector3 center,
  required double width,
  required double height,
  double rotation = 0.0,
  vm.Vector4? color,
  double frame = 0.0,
  vm.Vector3? velocity,
}) {
  assert(index >= 0 && index < capacity);
  final o = index * floatsPerInstance;
  final d = _instanceData;
  d[o] = center.x;
  d[o + 1] = center.y;
  d[o + 2] = center.z;
  d[o + 3] = width;
  d[o + 4] = height;
  d[o + 5] = rotation;
  d[o + 6] = color?.x ?? 1.0;
  d[o + 7] = color?.y ?? 1.0;
  d[o + 8] = color?.z ?? 1.0;
  d[o + 9] = color?.w ?? 1.0;
  d[o + 10] = frame;
  d[o + 11] = velocity?.x ?? 0.0;
  d[o + 12] = velocity?.y ?? 0.0;
  d[o + 13] = velocity?.z ?? 0.0;
}