added line in generateTextures that avoids trying to make texture which is not loaded yet. There seems to be a delay between update of imageData in loaderThread and view2d, without the added line I sometimes get key errors within generateTextures