remove method

dynamic remove(
  1. List<Mesh> items
)

Implementation

remove(List<Mesh> items) {
  var objects = _objects, indicesByUUID = _indicesByUUID, bindings = _bindings, nBindings = bindings.length;

  var nCachedObjects = nCachedObjects_;

  for (var i = 0, n = items.length; i != n; ++i) {
    var object = items[i], uuid = object.uuid, index = indicesByUUID[uuid];

    if (index != null && index >= nCachedObjects) {
      // move existing object into the CACHED region

      var lastCachedIndex = nCachedObjects++, firstActiveObject = objects[lastCachedIndex];

      indicesByUUID[firstActiveObject.uuid] = index;
      objects[index] = firstActiveObject;

      indicesByUUID[uuid] = lastCachedIndex;
      objects[lastCachedIndex] = object;

      // accounting is done, now do the same for all bindings

      for (var j = 0, m = nBindings; j != m; ++j) {
        var bindingsForPath = bindings[j],
            firstActive = bindingsForPath[lastCachedIndex],
            binding = bindingsForPath[index];

        bindingsForPath[index] = firstActive;
        bindingsForPath[lastCachedIndex] = binding;
      }
    }
  } // for arguments

  nCachedObjects_ = nCachedObjects;
}