mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Fix #941 glTF does not export materials
This commit is contained in:
parent
5ed2019e74
commit
a272561c6e
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user