needsUpdate method

bool needsUpdate(
  1. Object3D object,
  2. BufferGeometry geometry,
  3. WebGLProgram program,
  4. BufferAttribute<NativeArray<num>>? index,
)

Implementation

bool needsUpdate(Object3D object, BufferGeometry geometry, WebGLProgram program, BufferAttribute? index) {
  var cachedAttributes = currentState["attributes"];
  var geometryAttributes = geometry.attributes;
  var attributesNum = 0;
  var programAttributes = program.getAttributes();

  for (final name in programAttributes.keys) {
    Map programAttribute = programAttributes[name];

    if (programAttribute["location"] >= 0) {
      var cachedAttribute = cachedAttributes[name];
      var geometryAttribute = geometryAttributes[name];

      if (geometryAttribute == undefined) {
        if (name == 'instanceMatrix' && object.instanceMatrix != null) geometryAttribute = object.instanceMatrix;
        if (name == 'instanceColor' && object.instanceColor != null) geometryAttribute = object.instanceColor;
      }

      if (cachedAttribute == undefined) return true;

      if (cachedAttribute["attribute"] != geometryAttribute) return true;

      if (geometryAttribute != null && cachedAttribute["data"] != geometryAttribute.data) return true;

      attributesNum++;
    }
  }

  if (currentState["attributesNum"] != attributesNum) return true;
  if (currentState["index"] != index) return true;
  return false;
}