diff --git a/source/import/importero3dv.js b/source/import/importero3dv.js index 46542ea..b7f1538 100644 --- a/source/import/importero3dv.js +++ b/source/import/importero3dv.js @@ -52,7 +52,7 @@ OV.ImporterO3dv = class extends OV.ImporterBase ImportMaterial (materialContent) { - let material = new OV.Material (OV.MaterialType.Phong); + let material = new OV.Material (OV.MaterialType.Physical); material.color.Set (255, 255, 255); if (materialContent.name !== undefined) { material.name = materialContent.name; @@ -60,6 +60,8 @@ OV.ImporterO3dv = class extends OV.ImporterBase if (materialContent.color !== undefined) { material.color = OV.ArrayToColor (materialContent.color); } + material.metalness = OV.ValueOrDefault (materialContent.metalness, 0.0); + material.roughness = OV.ValueOrDefault (materialContent.roughness, 1.0); this.model.AddMaterial (material); } diff --git a/test/testfiles/o3dv/materials.o3dv b/test/testfiles/o3dv/materials.o3dv new file mode 100644 index 0000000..fe03fa2 --- /dev/null +++ b/test/testfiles/o3dv/materials.o3dv @@ -0,0 +1,70 @@ +{ + "materials" : [ + { + "name" : "Material 1", + "color" : [200, 0, 0], + "metalness" : 1.0, + "roughness" : 0.0 + }, + { + "name" : "Material 2", + "color" : [0, 200, 0], + "metalness" : 1.0, + "roughness" : 0.25 + }, + { + "name" : "Material 3", + "color" : [0, 0, 200], + "metalness" : 1.0, + "roughness" : 0.5 + }, + { + "name" : "Material 4", + "color" : [200, 200, 0], + "metalness" : 1.0, + "roughness" : 0.75 + } + ], + "meshes" : [ + { + "type" : "sphere", + "parameters" : { + "radius" : 0.5 + }, + "transformation" : { + "translation" : [0.0, 0.0, 0.0] + }, + "material" : 0 + }, + { + "type" : "sphere", + "parameters" : { + "radius" : 0.5 + }, + "transformation" : { + "translation" : [1.5, 0.0, 0.0] + }, + "material" : 1 + }, + { + "type" : "sphere", + "parameters" : { + "radius" : 0.5 + }, + "transformation" : { + "translation" : [3.0, 0.0, 0.0] + }, + "material" : 2 + }, + { + "type" : "sphere", + "parameters" : { + "radius" : 0.5 + }, + "transformation" : { + "translation" : [4.5, 0.0, 0.0] + }, + "material" : 3 + } + ] +}