Fix crash when material type doesn't match with the preferred shading type.
This commit is contained in:
parent
1a0b473345
commit
7891817b3e
@ -136,27 +136,31 @@ OV.ConvertModelToThreeObject = function (model, params, output, callbacks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
let threeMaterial = null;
|
let threeMaterial = null;
|
||||||
if (shadingType === OV.ShadingType.Phong && material.type === OV.MaterialType.Phong) {
|
if (shadingType === OV.ShadingType.Phong) {
|
||||||
threeMaterial = new THREE.MeshPhongMaterial (materialParams);
|
threeMaterial = new THREE.MeshPhongMaterial (materialParams);
|
||||||
let specularColor = new THREE.Color (material.specular.r / 255.0, material.specular.g / 255.0, material.specular.b / 255.0);
|
if (material.type === OV.MaterialType.Phong) {
|
||||||
if (OV.IsEqual (material.shininess, 0.0)) {
|
let specularColor = new THREE.Color (material.specular.r / 255.0, material.specular.g / 255.0, material.specular.b / 255.0);
|
||||||
specularColor.setRGB (0.0, 0.0, 0.0);
|
if (OV.IsEqual (material.shininess, 0.0)) {
|
||||||
|
specularColor.setRGB (0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
threeMaterial.specular = specularColor;
|
||||||
|
threeMaterial.shininess = material.shininess * 100.0;
|
||||||
|
LoadTexture (stateHandler, threeMaterial, material.specularMap, (threeTexture) => {
|
||||||
|
threeMaterial.specularMap = threeTexture;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
threeMaterial.specular = specularColor;
|
} else if (shadingType === OV.ShadingType.Physical) {
|
||||||
threeMaterial.shininess = material.shininess * 100.0;
|
|
||||||
LoadTexture (stateHandler, threeMaterial, material.specularMap, (threeTexture) => {
|
|
||||||
threeMaterial.specularMap = threeTexture;
|
|
||||||
});
|
|
||||||
} else if (shadingType === OV.ShadingType.Physical && material.type === OV.MaterialType.Physical) {
|
|
||||||
threeMaterial = new THREE.MeshStandardMaterial (materialParams);
|
threeMaterial = new THREE.MeshStandardMaterial (materialParams);
|
||||||
threeMaterial.metalness = material.metalness;
|
if (material.type === OV.MaterialType.Physical) {
|
||||||
threeMaterial.roughness = material.roughness;
|
threeMaterial.metalness = material.metalness;
|
||||||
LoadTexture (stateHandler, threeMaterial, material.metalnessMap, (threeTexture) => {
|
threeMaterial.roughness = material.roughness;
|
||||||
threeMaterial.metalness = 1.0;
|
LoadTexture (stateHandler, threeMaterial, material.metalnessMap, (threeTexture) => {
|
||||||
threeMaterial.roughness = 1.0;
|
threeMaterial.metalness = 1.0;
|
||||||
threeMaterial.metalnessMap = threeTexture;
|
threeMaterial.roughness = 1.0;
|
||||||
threeMaterial.roughnessMap = threeTexture;
|
threeMaterial.metalnessMap = threeTexture;
|
||||||
});
|
threeMaterial.roughnessMap = threeTexture;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let emissiveColor = new THREE.Color (material.emissive.r / 255.0, material.emissive.g / 255.0, material.emissive.b / 255.0);
|
let emissiveColor = new THREE.Color (material.emissive.r / 255.0, material.emissive.g / 255.0, material.emissive.b / 255.0);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user