updateWireframeAttribute method
Implementation
void updateWireframeAttribute(BufferGeometry geometry) {
List<int> indices = [];
final geometryIndex = geometry.index;
final geometryPosition = geometry.attributes["position"];
int version = 0;
if (geometryIndex != null) {
final array = geometryIndex.array;
version = geometryIndex.version;
for (int i = 0, l = array.length; i < l; i += 3) {
final a = array[i + 0].toInt();
final b = array[i + 1].toInt();
final c = array[i + 2].toInt();
indices.addAll([a, b, b, c, c, a]);
}
}
else {
final array = geometryPosition.array;
version = geometryPosition.version;
for (int i = 0, l = (array.length ~/ 3) - 1; i < l; i += 3) {
final a = i + 0;
final b = i + 1;
final c = i + 2;
indices.addAll([a, b, b, c, c, a]);
}
}
BufferAttribute attribute;
final max = indices.getMaxValue();
if (max != null && max > 65535) {
attribute = Uint32BufferAttribute.fromList(indices, 1, false);
}
else {
attribute = Uint16BufferAttribute.fromList(indices, 1, false);
}
attribute.version = version;
// Updating index buffer in VAO now. See WebGLBindingStates
final previousAttribute = wireframeAttributes.get(geometry);
if (previousAttribute != null) attributes.remove(previousAttribute);
wireframeAttributes.add(key: geometry, value: attribute);
}