diff --git a/lib/GLTFExporter.js b/lib/GLTFExporter.js index fe85ab77..bbbc4e34 100644 --- a/lib/GLTFExporter.js +++ b/lib/GLTFExporter.js @@ -165,6 +165,8 @@ GLTFExporter.prototype = { var uids = new Map(); var uid = 0; + var cachedMaterials = {}; + /** * Assign and return a temporal unique id for an object * especially which doesn't have .uuid @@ -919,6 +921,22 @@ GLTFExporter.prototype = { } + function getLamberMaterial(original) { + if (cachedMaterials[original.uuid]) { + return cachedMaterials[original.uuid]; + } else { + let material = new THREE.MeshLambertMaterial({ + color: 0xffffff, + map: original.map, + transparent: true, + side: Canvas.getRenderSide(), + alphaTest: 0.05 + }); + cachedMaterials[original.uuid] = material; + return material; + } + } + /** * Process material * @param {THREE.Material} material Material to process @@ -945,8 +963,7 @@ GLTFExporter.prototype = { if ( material.isShaderMaterial && ! material.isGLTFSpecularGlossinessMaterial ) { - console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' ); - return null; + material = getLamberMaterial(material); }