update method

dynamic update(
  1. dynamic attribute,
  2. dynamic bufferType, {
  3. String? name,
})

Implementation

update(attribute, bufferType, {String? name}) {
  if (attribute.type == "GLBufferAttribute") {
    var cached = buffers.get(attribute);

    if (cached == null || cached["version"] < attribute.version) {
      buffers.add(key: attribute, value: createBuffer(attribute, bufferType, name: name));
    }

    return;
  }

  if (attribute.type == "InterleavedBufferAttribute") {
    attribute = attribute.data;
  }

  final data = buffers.get(attribute);

  if (data == null) {
    buffers.add(key: attribute, value: createBuffer(attribute, bufferType, name: name));
  } else if (data["version"] < attribute.version) {
    updateBuffer(data["buffer"], attribute, bufferType);
    data["version"] = attribute.version;
  }
}