From cf65d1f204e9527f9e9fb0c0f38d7ec641119121 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sat, 17 Apr 2021 12:16:01 +0200 Subject: [PATCH] Override diffuse color only it it is completely black. --- source/external/rhino.importer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/external/rhino.importer.js b/source/external/rhino.importer.js index d142459..d4c5264 100644 --- a/source/external/rhino.importer.js +++ b/source/external/rhino.importer.js @@ -251,6 +251,11 @@ OV.Importer3dm = class extends OV.ImporterBase color.Set (rhinoColor.r, rhinoColor.g, rhinoColor.b); } + function IsBlack (rhinoColor) + { + return rhinoColor.r === 0 && rhinoColor.g === 0 && rhinoColor.b === 0; + } + function IsWhite (rhinoColor) { return rhinoColor.r === 255 && rhinoColor.g === 255 && rhinoColor.b === 255; @@ -266,9 +271,11 @@ OV.Importer3dm = class extends OV.ImporterBase SetColor (material.specular, rhinoMaterial.specularColor); material.opacity = 1.0 - rhinoMaterial.transparency; material.transparent = OV.IsLower (material.opacity, 1.0); - if (!IsWhite (rhinoMaterial.reflectionColor)) { + // material.shininess = rhinoMaterial.shine / 255.0; + if (IsBlack (material.diffuse) && !IsWhite (rhinoMaterial.reflectionColor)) { SetColor (material.diffuse, rhinoMaterial.reflectionColor); - } else if (!IsWhite (rhinoMaterial.transparentColor)) { + } + if (IsBlack (material.diffuse) && !IsWhite (rhinoMaterial.transparentColor)) { SetColor (material.diffuse, rhinoMaterial.transparentColor); } } @@ -292,6 +299,9 @@ OV.Importer3dm = class extends OV.ImporterBase if (current.transparent !== material.transparent) { continue; } + if (!OV.IsEqual (current.shininess, material.shininess)) { + continue; + } return i; } return model.AddMaterial (material);