parseImage method

dynamic parseImage(
  1. dynamic videoNode
)

Implementation

parseImage( videoNode ) {

	var content = videoNode.Content;
	String fileName = videoNode.RelativeFilename ?? videoNode.Filename;
	var extension = fileName.substring( fileName.lastIndexOf( '.' ) + 1 ).toLowerCase();

	var type;

	switch ( extension ) {

		case 'bmp':

			type = 'image/bmp';
			break;

		case 'jpg':
		case 'jpeg':

			type = 'image/jpeg';
			break;

		case 'png':

			type = 'image/png';
			break;

		case 'tif':

			type = 'image/tiff';
			break;

		case 'tga':

			if ( this.manager.getHandler( '.tga' ) == null ) {

				print( 'FBXLoader: TGA loader not found, skipping ${fileName}' );

			}

			type = 'image/tga';
			break;

		default:

			print( 'FBXLoader: Image type "${extension}" is not supported.' );
			return;

	}

	if ( content is String ) { // ASCII format

		return 'data:' + type + ';base64,' + content;

	} else { // Binary Format

		var array = new Uint8Array( content );
		return createObjectURL( new Blob( [ array ], { type: type } ) );

	}

}