fix glTFPbrMetallicRoughness init.

This commit is contained in:
hiroj 2020-05-20 16:33:40 +09:00
parent d864ba6d77
commit 446d5f0d58
2 changed files with 9 additions and 6 deletions

View File

@ -271,7 +271,7 @@ namespace UniGLTF
};
var json = model.ToJson();
Assert.AreEqual(@"{""name"":""a"",""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json);
Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json);
Debug.Log(json);
var c = new JsonSchemaValidationContext("")
@ -279,7 +279,7 @@ namespace UniGLTF
EnableDiagnosisForNotRequiredFields = true,
};
var json2 = JsonSchema.FromType<glTFMaterial>().Serialize(model, c);
Assert.AreEqual(@"{""name"":""a"",""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json2);
Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""doubleSided"":false}", json2);
}
[Test]
@ -297,7 +297,7 @@ namespace UniGLTF
EnableDiagnosisForNotRequiredFields = true,
};
var json = JsonSchema.FromType<glTFMaterial>().Serialize(model, c);
Assert.AreEqual(@"{""name"":""a"",""emissiveFactor"":[0.5,0.5,0.5],""alphaMode"":""MASK"",""alphaCutoff"":0.5,""doubleSided"":false}", json);
Assert.AreEqual(@"{""name"":""a"",""pbrMetallicRoughness"":{""baseColorFactor"":[1,1,1,1],""metallicFactor"":1,""roughnessFactor"":1},""emissiveFactor"":[0.5,0.5,0.5],""alphaMode"":""MASK"",""alphaCutoff"":0.5,""doubleSided"":false}", json);
}
[Test]

View File

@ -147,7 +147,10 @@ namespace UniGLTF
public class glTFMaterial : JsonSerializableBase
{
public string name;
public glTFPbrMetallicRoughness pbrMetallicRoughness;
public glTFPbrMetallicRoughness pbrMetallicRoughness = new glTFPbrMetallicRoughness
{
baseColorFactor = new float[] { 1.0f, 1.0f, 1.0f, 1.0f },
};
public glTFMaterialNormalTextureInfo normalTexture = null;
public glTFMaterialOcclusionTextureInfo occlusionTexture = null;
@ -214,8 +217,8 @@ namespace UniGLTF
{
return new glTFTextureInfo[]
{
pbrMetallicRoughness.baseColorTexture,
pbrMetallicRoughness.metallicRoughnessTexture,
(pbrMetallicRoughness != null)?pbrMetallicRoughness.baseColorTexture:null,
(pbrMetallicRoughness != null)?pbrMetallicRoughness.metallicRoughnessTexture:null,
normalTexture,
occlusionTexture,
emissiveTexture