needsUpdate method
bool
needsUpdate(
- Object3D object,
- BufferGeometry geometry,
- WebGLProgram program,
- BufferAttribute<
NativeArray< ? index,num> >
Implementation
bool needsUpdate(Object3D object, BufferGeometry geometry, WebGLProgram program, BufferAttribute? index) {
final cachedAttributes = currentState["attributes"];
final geometryAttributes = geometry.attributes;
int attributesNum = 0;
final programAttributes = program.getAttributes();
for (final name in programAttributes.keys) {
AttributeLocations programAttribute = programAttributes[name]!;
if (programAttribute.location.id >= 0) {
final cachedAttribute = cachedAttributes[name];
BufferAttribute? geometryAttribute = geometryAttributes[name];
if (geometryAttribute == null) {
if (name == 'instanceMatrix' && object.instanceMatrix != null) geometryAttribute = object.instanceMatrix;
if (name == 'instanceColor' && object.instanceColor != null) geometryAttribute = object.instanceColor;
}
if (cachedAttribute == null) 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;
}