serializeImage function

dynamic serializeImage(
  1. dynamic image
)

Implementation

serializeImage(image) {
  if (image is ImageElement) {
    // default images

    return ImageUtils.getDataURL(image);
  } else {
    if (image.data != null) {
      // images of DataTexture

      return {
        "data": image.data.sublist(0),
        "width": image.width,
        "height": image.height,
        "type": image.data.runtimeType.toString(), // TODO remove runtimeType for web release mode
      };
    } else {
      print('three.Texture: Unable to serialize Texture.');
      return {};
    }
  }
}