Merge branch 'dev' into three_importer
This commit is contained in:
commit
c14da66704
@ -298,14 +298,23 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
return rhinoColor.r === 255 && rhinoColor.g === 255 && rhinoColor.b === 255;
|
||||
}
|
||||
|
||||
let material = new OV.Material (OV.MaterialType.Phong);
|
||||
let material = null;
|
||||
if (rhinoMaterial === null) {
|
||||
material = new OV.Material (OV.MaterialType.Phong);
|
||||
material.color.Set (255, 255, 255);
|
||||
} else {
|
||||
let physicallyBased = rhinoMaterial.physicallyBased ();
|
||||
if (physicallyBased.supported) {
|
||||
material = new OV.Material (OV.MaterialType.Physical);
|
||||
material.metalness = physicallyBased.metallic ? 1.0 : 0.0;
|
||||
material.roughness = physicallyBased.roughness;
|
||||
} else {
|
||||
material = new OV.Material (OV.MaterialType.Phong);
|
||||
SetColor (material.ambient, rhinoMaterial.ambientColor);
|
||||
SetColor (material.specular, rhinoMaterial.specularColor);
|
||||
}
|
||||
material.name = rhinoMaterial.name;
|
||||
SetColor (material.ambient, rhinoMaterial.ambientColor);
|
||||
SetColor (material.color, rhinoMaterial.diffuseColor);
|
||||
SetColor (material.specular, rhinoMaterial.specularColor);
|
||||
material.opacity = 1.0 - rhinoMaterial.transparency;
|
||||
OV.UpdateMaterialTransparency (material);
|
||||
// material.shininess = rhinoMaterial.shine / 255.0;
|
||||
@ -318,28 +327,9 @@ OV.Importer3dm = class extends OV.ImporterBase
|
||||
}
|
||||
for (let i = 0; i < model.MaterialCount (); i++) {
|
||||
let current = model.GetMaterial (i);
|
||||
if (current.name !== material.name) {
|
||||
continue;
|
||||
if (OV.MaterialIsEqual (current, material)) {
|
||||
return i;
|
||||
}
|
||||
if (!OV.ColorIsEqual (current.ambient, material.ambient)) {
|
||||
continue;
|
||||
}
|
||||
if (!OV.ColorIsEqual (current.color, material.color)) {
|
||||
continue;
|
||||
}
|
||||
if (!OV.ColorIsEqual (current.specular, material.specular)) {
|
||||
continue;
|
||||
}
|
||||
if (!OV.IsEqual (current.opacity, material.opacity)) {
|
||||
continue;
|
||||
}
|
||||
if (current.transparent !== material.transparent) {
|
||||
continue;
|
||||
}
|
||||
if (!OV.IsEqual (current.shininess, material.shininess)) {
|
||||
continue;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return model.AddMaterial (material);
|
||||
}
|
||||
|
||||
@ -190,14 +190,115 @@ OV.HexStringToColor = function (hexString)
|
||||
return new OV.Color (r, g, b);
|
||||
};
|
||||
|
||||
OV.ArrayToColor = function (arr)
|
||||
{
|
||||
return new OV.Color (arr[0], arr[1], arr[2]);
|
||||
};
|
||||
|
||||
OV.ColorIsEqual = function (a, b)
|
||||
{
|
||||
return a.r === b.r && a.g === b.g && a.b === b.b;
|
||||
};
|
||||
|
||||
OV.ArrayToColor = function (arr)
|
||||
OV.TextureIsEqual = function (a, b)
|
||||
{
|
||||
return new OV.Color (arr[0], arr[1], arr[2]);
|
||||
if (a.name !== b.name) {
|
||||
return false;
|
||||
}
|
||||
if (a.name !== b.name) {
|
||||
return false;
|
||||
}
|
||||
if (a.url !== b.url) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.CoordIsEqual2D (a.offset, b.offset)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.CoordIsEqual2D (a.scale, b.scale)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.rotation, b.rotation)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
OV.MaterialIsEqual = function (a, b)
|
||||
{
|
||||
function TextureIsEqual (aTex, bTex)
|
||||
{
|
||||
if (aTex === null && bTex === null) {
|
||||
return true;
|
||||
} else if (aTex === null || bTex === null) {
|
||||
return false;
|
||||
}
|
||||
return OV.TextureIsEqual (aTex, bTex);
|
||||
}
|
||||
|
||||
if (a.type !== b.type) {
|
||||
return false;
|
||||
}
|
||||
if (a.name !== b.name) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.ColorIsEqual (a.color, b.color)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.ColorIsEqual (a.ambient, b.ambient)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.ColorIsEqual (a.specular, b.specular)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.ColorIsEqual (a.emissive, b.emissive)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.metalness, b.metalness)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.roughness, b.roughness)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.shininess, b.shininess)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.opacity, b.opacity)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.diffuseMap, b.diffuseMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.specularMap, b.specularMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.bumpMap, b.bumpMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.normalMap, b.normalMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.emissiveMap, b.emissiveMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!TextureIsEqual (a.metalnessMap, b.metalnessMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!OV.IsEqual (a.alphaTest, b.alphaTest)) {
|
||||
return false;
|
||||
}
|
||||
if (a.transparent !== b.transparent) {
|
||||
return false;
|
||||
}
|
||||
if (a.multiplyDiffuseMap !== b.multiplyDiffuseMap) {
|
||||
return false;
|
||||
}
|
||||
if (a.multiplyMetallicMap !== b.multiplyMetallicMap) {
|
||||
return false;
|
||||
}
|
||||
if (a.isDefault !== b.isDefault) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
OV.EnumerateMaterialTextureMaps = function (material, enumerator)
|
||||
|
||||
@ -71,6 +71,10 @@ OV.DetailsSidebarPanel = class extends OV.SidebarPanel
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Text, 'Source', material.isDefault ? 'Default' : 'Model'));
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Text, 'Type', typeString));
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Color, 'Color', material.color));
|
||||
if (material.type === OV.MaterialType.Physical) {
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Percent, 'Metalness', material.metalness));
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Percent, 'Roughness', material.roughness));
|
||||
}
|
||||
this.AddProperty (table, new OV.Property (OV.PropertyType.Percent, 'Opacity', material.opacity));
|
||||
AddTextureMap (this, table, 'Diffuse Map', material.diffuseMap);
|
||||
AddTextureMap (this, table, 'Specular Map', material.specularMap);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user