update method

dynamic update(
  1. dynamic attribute, [
  2. dynamic isIndex = false,
  3. dynamic usage
])

Implementation

update(attribute, [isIndex = false, usage]) {
  if (attribute is InterleavedBufferAttribute) attribute = attribute.data;

  var data = this.buffers.get(attribute);

  if (data == undefined) {
    if (usage == null) {
      usage =
          (isIndex == true) ? GPUBufferUsage.Index : GPUBufferUsage.Vertex;
    }

    data = this._createBuffer(attribute, usage);

    this.buffers.set(attribute, data);
  } else if (usage != null && usage != data.usage) {
    data.buffer.destroy();

    data = this._createBuffer(attribute, usage);

    this.buffers.set(attribute, data);
  } else if (data["version"] < attribute.version) {
    this._writeBuffer(data["buffer"], attribute);

    data["version"] = attribute.version;
  }
}