Add public IntegerToHexString function.

This commit is contained in:
kovacsv 2021-06-13 07:30:11 +02:00
parent dde3e08687
commit 8fbe59d656
2 changed files with 17 additions and 22 deletions

View File

@ -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 ();

View File

@ -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;
};