diff --git a/source/import/importerply.js b/source/import/importerply.js index 5230f08..5c966a0 100644 --- a/source/import/importerply.js +++ b/source/import/importerply.js @@ -269,20 +269,15 @@ OV.ImporterPly = class extends OV.ImporterBase function GetMaterialFromColor (obj, color, colorToMaterial) { - function IntegerToHex (intVal) - { - let result = parseInt (intVal, 10).toString (16); - while (result.length < 2) { - result = '0' + result; - } - return result; - } - if (color === null) { return null; } - let materialName = 'Color ' + IntegerToHex (color[0]) + IntegerToHex (color[1]) + IntegerToHex (color[2]) + IntegerToHex (color[3]); + let materialName = 'Color ' + + OV.IntegerToHexString (color[0]) + + OV.IntegerToHexString (color[1]) + + OV.IntegerToHexString (color[2]) + + OV.IntegerToHexString (color[3]); let materialIndex = colorToMaterial[materialName]; if (materialIndex === undefined) { let material = new OV.Material (); diff --git a/source/model/material.js b/source/model/material.js index cd8fd78..18bc941 100644 --- a/source/model/material.js +++ b/source/model/material.js @@ -162,20 +162,20 @@ OV.LinearToSRGB = function (component) } }; +OV.IntegerToHexString = function (intVal) +{ + let result = parseInt (intVal, 10).toString (16); + while (result.length < 2) { + result = '0' + result; + } + return result; +}; + OV.ColorToHexString = function (color) { - function IntegerToHex (intVal) - { - let result = parseInt (intVal, 10).toString (16); - while (result.length < 2) { - result = '0' + result; - } - return result; - } - - let r = IntegerToHex (color.r); - let g = IntegerToHex (color.g); - let b = IntegerToHex (color.b); + let r = OV.IntegerToHexString (color.r); + let g = OV.IntegerToHexString (color.g); + let b = OV.IntegerToHexString (color.b); return r + g + b; };