glB material import not displaying correctly #248

This commit is contained in:
kovacsv 2022-04-19 18:29:28 +02:00
parent df05dd9a51
commit e178e53fbd
2 changed files with 5 additions and 4 deletions

View File

@ -23,7 +23,7 @@ const GltfComponentType =
SHORT : 5122,
UNSIGNED_SHORT : 5123,
UNSIGNED_INT : 5125,
FLOAT : 5126
FLOAT : 5126
};
const GltfDataType =
@ -69,8 +69,10 @@ function GetGltfVertexColor (color, componentType)
function GetColorComponent (component, componentType)
{
let normalized = component;
if (componentType !== GltfComponentType.FLOAT) {
if (componentType === GltfComponentType.UNSIGNED_BYTE) {
normalized /= 255.0;
} else if (componentType === GltfComponentType.UNSIGNED_SHORT) {
normalized /= 65535.0;
}
return ColorComponentFromFloat (LinearToSRGB (normalized));
}

View File

@ -28,8 +28,7 @@ class ModelFinalizer
FinalizeMaterials (model)
{
let hasVertexColors = (model.VertexColorCount () > 0);
if (!hasVertexColors) {
if (model.VertexColorCount () === 0) {
return;
}