addSparse method

int addSparse(
  1. int count,
  2. String type,
  3. List<int> indices,
  4. List<double> values,
)

Adds an accessor of count zeros whose indices are replaced by values (a sparse accessor with no bufferView).

Implementation

int addSparse(
  int count,
  String type,
  List<int> indices,
  List<double> values,
) {
  final idx = Uint32List.fromList(indices);
  final val = Float32List.fromList(values);
  return _add('accessors', {
    'componentType': 5126,
    'count': count,
    'type': type,
    'sparse': {
      'count': indices.length,
      'indices': {
        'bufferView': _view(idx.buffer.asUint8List()),
        'componentType': 5125,
      },
      'values': {'bufferView': _view(val.buffer.asUint8List())},
    },
  });
}