cloneUniforms function

Map<String, dynamic> cloneUniforms(
  1. Map<String, dynamic> src
)

Uniform Utilities

Implementation

Map<String, dynamic> cloneUniforms(Map<String, dynamic> src) {
  var dst = <String, dynamic>{};

  for (var u in src.keys) {
    dst[u] = {};

    for (var p in src[u].keys) {
      var property = src[u][p];

      if (property != null &&
          (property is Color ||
              property is Matrix3 ||
              property is Matrix4 ||
              property is Vector2 ||
              property is Vector3 ||
              property is Vector4 ||
              property is Texture ||
              property is Quaternion)) {
        dst[u][p] = property.clone();
      } else if (property is List) {
        dst[u][p] = property.sublist(0);
      } else {
        dst[u][p] = property;
      }
    }
  }

  return dst;
}