update method

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

Implementation

void update(attribute, bufferType, {String? name}) {
  if (attribute.type == "GLBufferAttribute") {
    final 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 && attribute != null) {
    buffers.add(
      key: attribute,
      value: createBuffer(attribute, bufferType, name: name)
    );
  }
  else if(data?["version"] != null && data["version"] < attribute.version) {
    updateBuffer(data["buffer"], attribute, bufferType);
    data["version"] = attribute.version;
  }
}