Skip to content

Commit

Permalink
Support Rhino PBR materials #107
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Aug 7, 2021
1 parent 6a2315f commit ad7a1f9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions source/import/importer3dm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ad7a1f9

Please sign in to comment.