diff --git a/CHANGES.md b/CHANGES.md index c43ff9031..a81a83fb3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Change Log ##### Fixes :wrench: * Upgrade to Draco 1.2.5 [#179](https://github.com/KhronosGroup/COLLADA2GLTF/pull/179) * Fix issue with exporting normal maps [#182](https://github.com/KhronosGroup/COLLADA2GLTF/pull/182) +* Fix issue with COLLADA textures with no backing image [#183](https://github.com/KhronosGroup/COLLADA2GLTF/pull/183) ### v2.1.1 - 2018-04-04 diff --git a/src/COLLADA2GLTFWriter.cpp b/src/COLLADA2GLTFWriter.cpp index 2dc16916b..44ec75392 100755 --- a/src/COLLADA2GLTFWriter.cpp +++ b/src/COLLADA2GLTFWriter.cpp @@ -883,10 +883,15 @@ void packColladaColor(COLLADAFW::Color color, float* packArray) { } GLTF::Texture* COLLADA2GLTF::Writer::fromColladaTexture(const COLLADAFW::EffectCommon* effectCommon, COLLADAFW::SamplerID samplerId) { - GLTF::Texture* texture = new GLTF::Texture(); const COLLADAFW::SamplerPointerArray& samplers = effectCommon->getSamplerPointerArray(); COLLADAFW::Sampler* colladaSampler = (COLLADAFW::Sampler*)samplers[samplerId]; - GLTF::Image* image = _images[colladaSampler->getSourceImage()]; + std::map::iterator findImage = _images.find(colladaSampler->getSourceImage()); + if (findImage == _images.end()) { + return NULL; + } + GLTF::Texture* texture = new GLTF::Texture(); + GLTF::Image* image = findImage->second; + texture->source = image; texture->sampler = _asset->globalSampler; return texture;