[vtk] GLTF loader doesn't error on extentionsUsed images

When images are only referenced by extensionsUsed that we're skipping
over anyway, we should not report false positive error messages. The
warning about the skipped extensionsUsed is sufficient on its own.

Also be sure to forward warnings and errors from the loader that's
nested inside the importer back to the importer proper.

This patch should be upstreamed.

--- IO/Geometry/vtkGLTFDocumentLoader.cxx
+++ IO/Geometry/vtkGLTFDocumentLoader.cxx
@@ -819,6 +819,15 @@ bool vtkGLTFDocumentLoader::LoadImageData()
     {
       reader = vtkSmartPointer<vtkPNGReader>::New();
     }
+    else
+    {
+      // We must not report any error here; extensions allow other image types.
+      // It is perfectly valid to declare other, extension-supported image types,
+      // so long as they are never required by the scene. Therefore, the possible
+      // error is deferred til later.
+      image.ImageData = nullptr;
+      continue;
+    }
 
     // If image is defined via bufferview index
     if (image.BufferView >= 0 &&

--- IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx
+++ IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx
@@ -616,13 +616,7 @@ bool vtkGLTFDocumentLoaderInternals::LoadImage(
   {
     image.MimeType.clear();
   }
-  else if (image.MimeType != "image/jpeg" && image.MimeType != "image/png")
-  {
-    vtkErrorWithObjectMacro(this->Self,
-      "Invalid image.mimeType value. Must be either image/jpeg or image/png for image "
-        << image.Name);
-    return false;
-  }
+
   // Read the bufferView index value, if it exists.
   image.BufferView = -1;
   if (vtkGLTFUtils::GetIntValue(root, "bufferView", image.BufferView))

--- IO/Import/vtkGLTFImporter.cxx
+++ IO/Import/vtkGLTFImporter.cxx
@@ -81,11 +81,15 @@ vtkSmartPointer<vtkTexture> CreateVTKTextureFromGLTFTexture(
   const vtkGLTFDocumentLoader::Texture& glTFTex = model->Textures[textureIndex];
   if (glTFTex.Source < 0 || glTFTex.Source >= static_cast<int>(model->Images.size()))
   {
-    vtkErrorWithObjectMacro(nullptr, "Image not found");
+    vtkErrorWithObjectMacro(parent, "Image not found");
     return nullptr;
   }
 
   const vtkGLTFDocumentLoader::Image& image = model->Images[glTFTex.Source];
+  if (image.ImageData == nullptr) {
+    vtkErrorWithObjectMacro(parent, "Image mimeType not supported");
+    return nullptr;
+  }
 
   vtkNew<vtkTexture> texture;
   texture->SetColorModeToDirectScalars();
@@ -381,6 +381,8 @@ int vtkGLTFImporter::ImportBegin()
   vtkNew<vtkEventForwarderCommand> forwarder;
   forwarder->SetTarget(this);
   this->Loader->AddObserver(vtkCommand::ProgressEvent, forwarder);
+  this->Loader->AddObserver(vtkCommand::WarningEvent, forwarder);
+  this->Loader->AddObserver(vtkCommand::ErrorEvent, forwarder);
 
   // Check extension
   std::vector<char> glbBuffer;
