parseImages method

dynamic parseImages()

Implementation

parseImages() {
  var images = {};
  var blobs = {};

  if (fbxTree.objects["Video"] != null) {
    var videoNodes = fbxTree.objects["Video"];

    for (var nodeID in videoNodes.keys) {
      var videoNode = videoNodes[nodeID];

      var id = parseInt(nodeID);

      images[id] = videoNode["RelativeFilename"] ?? videoNode["Filename"];

      // raw image data is in videoNode.Content
      if (videoNode["Content"] != null) {
        // var arrayBufferContent = ( videoNode["Content"] is ArrayBuffer ) && ( videoNode["Content"].byteLength > 0 );
        var arrayBufferContent = (videoNode["Content"] is TypedData) && (videoNode["Content"].byteLength > 0);
        var base64Content = (videoNode["Content"] is String) && (videoNode["Content"] != '');

        if (arrayBufferContent || base64Content) {
          var image = parseImage(videoNodes[nodeID]);

          blobs[videoNode.RelativeFilename ?? videoNode.Filename] = image;
        }
      }
    }
  }

  for (var id in images.keys) {
    var filename = images[id];

    if (blobs[filename] != null) {
      images[id] = blobs[filename];
    } else {
      images[id] = images[id].split('\\').removeLast();
    }
  }

  return images;
}