saveCache method
void
saveCache(
- dynamic object,
- BufferGeometry geometry,
- WebGLProgram program,
- BufferAttribute<
NativeArray< ? index,num> >
Implementation
void saveCache(object, BufferGeometry geometry, WebGLProgram program, BufferAttribute? index) {
final cache = {};
final attributes = geometry.attributes;
int attributesNum = 0;
final programAttributes = program.getAttributes();
for (final name in programAttributes.keys) {
AttributeLocations programAttribute = programAttributes[name]!;
if (programAttribute.location.id >= 0) {
BufferAttribute? attribute = attributes[name];
if (attribute == null) {
if (name == 'instanceMatrix' && object.instanceMatrix != null) attribute = object.instanceMatrix;
if (name == 'instanceColor' && object.instanceColor != null) attribute = object.instanceColor;
}
final data = {};
data["attribute"] = attribute;
if (attribute != null && attribute.data != null) {
data["data"] = attribute.data;
}
cache[name] = data;
attributesNum++;
}
}
currentState["attributes"] = cache;
currentState["attributesNum"] = attributesNum;
currentState["index"] = index;
}