toJSON method

Map<String, dynamic> toJSON(
  1. dynamic meta
)

Implementation

Map<String, dynamic> toJSON(meta) {
  bool isRootObject = (meta == null || meta is String);

  if (!isRootObject && meta.textures[uuid] != null) {
    return meta.textures[uuid];
  }

  Map<String, dynamic> output = {
    "metadata": {"version": 4.5, "type": 'Texture', "generator": 'Texture.toJSON'},
    "uuid": uuid,
    "name": name,
    "image": source.toJSON(meta).uuid,
    "mapping": mapping,
    "repeat": [repeat.x, repeat.y],
    "offset": [offset.x, offset.y],
    "center": [center.x, center.y],
    "rotation": rotation,
    "wrap": [wrapS, wrapT],
    "format": format,
    "type": type,
    "encoding": encoding,
    "minFilter": minFilter,
    "magFilter": magFilter,
    "anisotropy": anisotropy,
    "flipY": flipY,
    "premultiplyAlpha": premultiplyAlpha,
    "unpackAlignment": unpackAlignment
  };

  if (userData.isNotEmpty) output["userData"] = userData;

  if (!isRootObject) {
    meta.textures[uuid] = output;
  }

  return output;
}