|
@@ -919,7 +919,7 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.isShaderMaterial ) {
|
|
|
+ if ( material.isShaderMaterial && !material.isGLTFSpecularGlossinessMaterial ) {
|
|
|
|
|
|
console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
|
|
|
return null;
|
|
@@ -939,6 +939,12 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
extensionsUsed[ 'KHR_materials_unlit' ] = true;
|
|
|
|
|
|
+ } else if ( material.isGLTFSpecularGlossinessMaterial ) {
|
|
|
+
|
|
|
+ gltfMaterial.extensions = { KHR_materials_pbrSpecularGlossiness: {} };
|
|
|
+
|
|
|
+ extensionsUsed[ 'KHR_materials_pbrSpecularGlossiness' ] = true;
|
|
|
+
|
|
|
} else if ( ! material.isMeshStandardMaterial ) {
|
|
|
|
|
|
console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
|
|
@@ -971,6 +977,23 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ // pbrSpecularGlossiness diffuse, specular and glossiness factor
|
|
|
+ if ( material.isGLTFSpecularGlossinessMaterial ) {
|
|
|
+
|
|
|
+ if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) {
|
|
|
+
|
|
|
+ gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var specularFactor = [ 1, 1, 1 ];
|
|
|
+ material.specular.toArray( specularFactor, 0 );
|
|
|
+ gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor;
|
|
|
+
|
|
|
+ gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// pbrMetallicRoughness.metallicRoughnessTexture
|
|
|
if ( material.metalnessMap || material.roughnessMap ) {
|
|
|
|
|
@@ -988,12 +1011,28 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // pbrMetallicRoughness.baseColorTexture
|
|
|
+ // pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture
|
|
|
if ( material.map ) {
|
|
|
|
|
|
var baseColorMapDef = { index: processTexture( material.map ) };
|
|
|
applyTextureTransform( baseColorMapDef, material.map );
|
|
|
+
|
|
|
+ if ( material.isGLTFSpecularGlossinessMaterial ) {
|
|
|
+
|
|
|
+ gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseTexture = baseColorMapDef;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // pbrSpecularGlossiness specular map
|
|
|
+ if ( material.isGLTFSpecularGlossinessMaterial && material.specularMap ) {
|
|
|
+
|
|
|
+ var specularMapDef = { index: processTexture( material.specularMap ) };
|
|
|
+ applyTextureTransform( specularMapDef, material.specularMap );
|
|
|
+ gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularGlossinessTexture = specularMapDef;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1028,7 +1067,7 @@ GLTFExporter.prototype = {
|
|
|
|
|
|
var normalMapDef = { index: processTexture( material.normalMap ) };
|
|
|
|
|
|
- if ( material.normalScale.x !== - 1 ) {
|
|
|
+ if ( material.normalScale && material.normalScale.x !== - 1 ) {
|
|
|
|
|
|
if ( material.normalScale.x !== material.normalScale.y ) {
|
|
|
|