Add public IntegerToHexString function.
This commit is contained in:
parent
dde3e08687
commit
8fbe59d656
@ -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 ();
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user