addInts method
Adds integer data of componentType (5121 ubyte, 5122 short,
5123 ushort, 5125 uint), optionally normalized.
Implementation
int addInts(
List<int> values,
String type,
int componentType, {
bool normalized = false,
bool indices = false,
}) {
final width = const {'SCALAR': 1, 'VEC2': 2, 'VEC3': 3, 'VEC4': 4}[type]!;
final ByteData data;
switch (componentType) {
case 5121:
data = ByteData(values.length);
for (var i = 0; i < values.length; i++) {
data.setUint8(i, values[i]);
}
case 5122:
data = ByteData(values.length * 2);
for (var i = 0; i < values.length; i++) {
data.setInt16(i * 2, values[i], Endian.little);
}
case 5123:
data = ByteData(values.length * 2);
for (var i = 0; i < values.length; i++) {
data.setUint16(i * 2, values[i], Endian.little);
}
default:
data = ByteData(values.length * 4);
for (var i = 0; i < values.length; i++) {
data.setUint32(i * 4, values[i], Endian.little);
}
}
return _add('accessors', {
'bufferView': _view(
data.buffer.asUint8List(),
target: indices ? 34963 : 34962,
),
'componentType': componentType,
'normalized': ?(normalized ? true : null),
'count': values.length ~/ width,
'type': type,
});
}