diff --git a/source/export/exporter3dm.js b/source/export/exporter3dm.js index dd608bc..0cd82e6 100644 --- a/source/export/exporter3dm.js +++ b/source/export/exporter3dm.js @@ -76,7 +76,7 @@ OV.Exporter3dm = class extends OV.ExporterBase let rhinoMaterial = new this.rhino.Material (); rhinoMaterial.name = this.GetExportedMaterialName (material.name); rhinoMaterial.ambientColor = ColorToRhinoColor (material.ambient); - rhinoMaterial.diffuseColor = ColorToRhinoColor (material.diffuse); + rhinoMaterial.diffuseColor = ColorToRhinoColor (material.color); rhinoMaterial.specularColor = ColorToRhinoColor (material.specular); rhinoMaterial.transparency = 1.0 - material.opacity; diff --git a/source/export/exportergltf.js b/source/export/exportergltf.js index 5f8432d..1ddc32a 100644 --- a/source/export/exportergltf.js +++ b/source/export/exportergltf.js @@ -403,9 +403,9 @@ OV.ExporterGltf = class extends OV.ExporterBase let jsonMaterial = { name : obj.GetExportedMaterialName (material.name), pbrMetallicRoughness : { - baseColorFactor : ColorToRGBA (material.diffuse, material.opacity), - metallicFactor : 0.0, - roughnessFactor : 1.0 + baseColorFactor : ColorToRGBA (material.color, material.opacity), + metallicFactor : material.metallic, + roughnessFactor : material.roughness }, emissiveFactor : ColorToRGB (material.emissive), doubleSided : true, @@ -424,6 +424,10 @@ OV.ExporterGltf = class extends OV.ExporterBase } jsonMaterial.pbrMetallicRoughness.baseColorTexture = baseColorTexture; } + let metallicTexture = GetTextureParams (mainJson, material.metallicMap, addTexture); + if (metallicTexture !== null) { + jsonMaterial.pbrMetallicRoughness.metallicRoughnessTexture = metallicTexture; + } let normalTexture = GetTextureParams (mainJson, material.normalMap, addTexture); if (normalTexture !== null) { jsonMaterial.normalTexture = normalTexture; diff --git a/source/export/exporterobj.js b/source/export/exporterobj.js index 08dbc50..cb7e6a9 100644 --- a/source/export/exporterobj.js +++ b/source/export/exporterobj.js @@ -42,7 +42,7 @@ OV.ExporterObj = class extends OV.ExporterBase let material = model.GetMaterial (materialIndex); mtlWriter.WriteArrayLine (['newmtl', this.GetExportedMaterialName (material.name)]); mtlWriter.WriteArrayLine (['Ka', material.ambient.r / 255.0, material.ambient.g / 255.0, material.ambient.b / 255.0]); - mtlWriter.WriteArrayLine (['Kd', material.diffuse.r / 255.0, material.diffuse.g / 255.0, material.diffuse.b / 255.0]); + mtlWriter.WriteArrayLine (['Kd', material.color.r / 255.0, material.color.g / 255.0, material.color.b / 255.0]); mtlWriter.WriteArrayLine (['Ks', material.specular.r / 255.0, material.specular.g / 255.0, material.specular.b / 255.0]); mtlWriter.WriteArrayLine (['Ns', material.shininess * 1000.0]); mtlWriter.WriteArrayLine (['d', material.opacity]); diff --git a/source/import/importer.js b/source/import/importer.js index 11854c5..83943ed 100644 --- a/source/import/importer.js +++ b/source/import/importer.js @@ -320,8 +320,8 @@ OV.Importer = class importer.Import (mainFile.file.content, mainFile.file.extension, { getDefaultMaterial : () => { - let material = new OV.Material (); - material.diffuse = settings.defaultColor; + let material = new OV.Material (OV.MaterialType.Phong); + material.color = settings.defaultColor; return material; }, getFileBuffer : (filePath) => { @@ -404,7 +404,7 @@ OV.Importer = class } for (let i = 0; i < this.model.MaterialCount (); i++) { let material = this.model.GetMaterial (i); - material.EnumerateTextureMaps ((texture) => { + OV.EnumerateMaterialTextureMaps (material, (texture) => { if (texture.url !== null) { OV.RevokeObjectUrl (texture.url); } diff --git a/source/import/importer3dm.js b/source/import/importer3dm.js index 5a5f897..b4b8e47 100644 --- a/source/import/importer3dm.js +++ b/source/import/importer3dm.js @@ -293,22 +293,22 @@ OV.Importer3dm = class extends OV.ImporterBase return rhinoColor.r === 255 && rhinoColor.g === 255 && rhinoColor.b === 255; } - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Phong); if (rhinoMaterial === null) { - material.diffuse.Set (255, 255, 255); + material.color.Set (255, 255, 255); } else { material.name = rhinoMaterial.name; SetColor (material.ambient, rhinoMaterial.ambientColor); - SetColor (material.diffuse, rhinoMaterial.diffuseColor); + SetColor (material.color, rhinoMaterial.diffuseColor); SetColor (material.specular, rhinoMaterial.specularColor); material.opacity = 1.0 - rhinoMaterial.transparency; OV.UpdateMaterialTransparency (material); // material.shininess = rhinoMaterial.shine / 255.0; - if (IsBlack (material.diffuse) && !IsWhite (rhinoMaterial.reflectionColor)) { - SetColor (material.diffuse, rhinoMaterial.reflectionColor); + if (IsBlack (material.color) && !IsWhite (rhinoMaterial.reflectionColor)) { + SetColor (material.color, rhinoMaterial.reflectionColor); } - if (IsBlack (material.diffuse) && !IsWhite (rhinoMaterial.transparentColor)) { - SetColor (material.diffuse, rhinoMaterial.transparentColor); + if (IsBlack (material.color) && !IsWhite (rhinoMaterial.transparentColor)) { + SetColor (material.color, rhinoMaterial.transparentColor); } } for (let i = 0; i < model.MaterialCount (); i++) { @@ -319,7 +319,7 @@ OV.Importer3dm = class extends OV.ImporterBase if (!OV.ColorIsEqual (current.ambient, material.ambient)) { continue; } - if (!OV.ColorIsEqual (current.diffuse, material.diffuse)) { + if (!OV.ColorIsEqual (current.color, material.color)) { continue; } if (!OV.ColorIsEqual (current.specular, material.specular)) { diff --git a/source/import/importer3ds.js b/source/import/importer3ds.js index 4a4bfab..c44de06 100644 --- a/source/import/importer3ds.js +++ b/source/import/importer3ds.js @@ -135,7 +135,7 @@ OV.Importer3ds = class extends OV.ImporterBase ReadMaterialChunk (reader, length) { - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Phong); let endByte = this.GetChunkEnd (reader, length); let shininess = null; let shininessStrength = null; @@ -145,7 +145,7 @@ OV.Importer3ds = class extends OV.ImporterBase } else if (chunkId === OV.CHUNK3DS.MAT_AMBIENT) { material.ambient = this.ReadColorChunk (reader, chunkLength); } else if (chunkId === OV.CHUNK3DS.MAT_DIFFUSE) { - material.diffuse = this.ReadColorChunk (reader, chunkLength); + material.color = this.ReadColorChunk (reader, chunkLength); } else if (chunkId === OV.CHUNK3DS.MAT_SPECULAR) { material.specular = this.ReadColorChunk (reader, chunkLength); } else if (chunkId === OV.CHUNK3DS.MAT_SHININESS) { diff --git a/source/import/importergltf.js b/source/import/importergltf.js index d8c053d..4524b04 100644 --- a/source/import/importergltf.js +++ b/source/import/importergltf.js @@ -314,9 +314,10 @@ OV.GltfExtensions = class } let khrSpecularGlossiness = gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness; if (khrSpecularGlossiness !== undefined) { + material.type = OV.MaterialType.Phong; let diffuseColor = khrSpecularGlossiness.diffuseFactor; if (diffuseColor !== undefined) { - material.diffuse = new OV.Color ( + material.color = new OV.Color ( GetMaterialComponent (diffuseColor[0]), GetMaterialComponent (diffuseColor[1]), GetMaterialComponent (diffuseColor[2]) @@ -714,12 +715,12 @@ OV.ImporterGltf = class extends OV.ImporterBase } let gltfMaterial = gltf.materials[materialIndex]; - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Physical); if (gltfMaterial.name !== undefined) { material.name = gltfMaterial.name; } - material.diffuse = new OV.Color ( + material.color = new OV.Color ( GetMaterialComponent (1.0), GetMaterialComponent (1.0), GetMaterialComponent (1.0) @@ -727,13 +728,21 @@ OV.ImporterGltf = class extends OV.ImporterBase if (gltfMaterial.pbrMetallicRoughness !== undefined) { let baseColor = gltfMaterial.pbrMetallicRoughness.baseColorFactor; if (baseColor !== undefined) { - material.diffuse = new OV.Color ( + material.color = new OV.Color ( GetMaterialComponent (baseColor[0]), GetMaterialComponent (baseColor[1]), GetMaterialComponent (baseColor[2]) ); material.opacity = baseColor[3]; } + let metallicFactor = gltfMaterial.pbrMetallicRoughness.metallicFactor; + if (metallicFactor !== undefined) { + material.metallic = metallicFactor; + } + let roughnessFactor = gltfMaterial.pbrMetallicRoughness.roughnessFactor; + if (roughnessFactor !== undefined) { + material.roughness = roughnessFactor; + } let emissiveColor = gltfMaterial.emissiveFactor; if (emissiveColor !== undefined) { material.emissive = new OV.Color ( @@ -744,6 +753,7 @@ OV.ImporterGltf = class extends OV.ImporterBase } material.diffuseMap = this.ImportTexture (gltf, gltfMaterial.pbrMetallicRoughness.baseColorTexture); + material.metallicMap = this.ImportTexture (gltf, gltfMaterial.pbrMetallicRoughness.metallicRoughnessTexture); material.normalMap = this.ImportTexture (gltf, gltfMaterial.normalTexture); material.emissiveMap = this.ImportTexture (gltf, gltfMaterial.emissiveTexture); if (material.diffuseMap !== null) { diff --git a/source/import/importerifc.js b/source/import/importerifc.js index a3397f1..c18602b 100644 --- a/source/import/importerifc.js +++ b/source/import/importerifc.js @@ -206,9 +206,9 @@ OV.ImporterIfc = class extends OV.ImporterBase let materialIndex = this.materialNameToIndex[materialName]; if (materialIndex === undefined) { - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Phong); material.name = materialName; - material.diffuse = color; + material.color = color; material.opacity = ifcColor.w; OV.UpdateMaterialTransparency (material); materialIndex = this.model.AddMaterial (material); diff --git a/source/import/importero3dv.js b/source/import/importero3dv.js index 2643b66..6426cdc 100644 --- a/source/import/importero3dv.js +++ b/source/import/importero3dv.js @@ -52,13 +52,13 @@ OV.ImporterO3dv = class extends OV.ImporterBase ImportMaterial (materialContent) { - let material = new OV.Material (); - material.diffuse.Set (255, 255, 255); + let material = new OV.Material (OV.MaterialType.Phong); + material.color.Set (255, 255, 255); if (materialContent.name !== undefined) { material.name = materialContent.name; } - if (materialContent.diffuse !== undefined) { - material.diffuse = OV.ArrayToColor (materialContent.diffuse); + if (materialContent.color !== undefined) { + material.color = OV.ArrayToColor (materialContent.color); } this.model.AddMaterial (material); } diff --git a/source/import/importerobj.js b/source/import/importerobj.js index 472050b..35607dd 100644 --- a/source/import/importerobj.js +++ b/source/import/importerobj.js @@ -187,7 +187,7 @@ OV.ImporterObj = class extends OV.ImporterBase return true; } - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Phong); let materialName = OV.NameFromLine (line, keyword.length, '#'); let materialIndex = this.model.AddMaterial (material); material.name = materialName; @@ -248,7 +248,7 @@ OV.ImporterObj = class extends OV.ImporterBase if (this.currentMaterial === null || parameters.length < 3) { return true; } - this.currentMaterial.diffuse = CreateColor (parameters); + this.currentMaterial.color = CreateColor (parameters); return true; } else if (keyword === 'ks') { if (this.currentMaterial === null || parameters.length < 3) { diff --git a/source/import/importerply.js b/source/import/importerply.js index e0eb83b..aa6c097 100644 --- a/source/import/importerply.js +++ b/source/import/importerply.js @@ -279,9 +279,9 @@ OV.ImporterPly = class extends OV.ImporterBase OV.IntegerToHexString (color[3]); let materialIndex = colorToMaterial[materialName]; if (materialIndex === undefined) { - let material = new OV.Material (); + let material = new OV.Material (OV.MaterialType.Phong); material.name = materialName; - material.diffuse = new OV.Color (color[0], color[1], color[2]); + material.color = new OV.Color (color[0], color[1], color[2]); material.opacity = color[3] / 255.0; OV.UpdateMaterialTransparency (material); materialIndex = obj.model.AddMaterial (material); diff --git a/source/model/material.js b/source/model/material.js index 344c2a4..82faf32 100644 --- a/source/model/material.js +++ b/source/model/material.js @@ -64,17 +64,27 @@ OV.TextureMap = class } }; +OV.MaterialType = +{ + Phong : 1, + Physical : 2 +}; + OV.Material = class { - constructor () + constructor (type) { + this.type = type; this.name = ''; + this.color = new OV.Color (0, 0, 0); this.ambient = new OV.Color (0, 0, 0); - this.diffuse = new OV.Color (0, 0, 0); this.specular = new OV.Color (0, 0, 0); this.emissive = new OV.Color (0, 0, 0); + this.metallic = 0.0; + this.roughness = 1.0; + this.shininess = 0.0; // 0.0 .. 1.0 this.opacity = 1.0; // 0.0 .. 1.0 @@ -83,6 +93,7 @@ OV.Material = class this.bumpMap = null; this.normalMap = null; this.emissiveMap = null; + this.metallicMap = null; this.alphaTest = 0.0; // 0.0 .. 1.0 this.transparent = false; @@ -91,36 +102,20 @@ OV.Material = class this.isDefault = false; } - EnumerateTextureMaps (enumerator) - { - if (this.diffuseMap !== null) { - enumerator (this.diffuseMap); - } - if (this.specularMap !== null) { - enumerator (this.specularMap); - } - if (this.bumpMap !== null) { - enumerator (this.bumpMap); - } - if (this.normalMap !== null) { - enumerator (this.normalMap); - } - if (this.emissiveMap !== null) { - enumerator (this.emissiveMap); - } - } - Clone () { - let cloned = new OV.Material (); + let cloned = new OV.Material (this.type); cloned.name = this.name; + cloned.color = this.color.Clone (); cloned.ambient = this.ambient.Clone (); - cloned.diffuse = this.diffuse.Clone (); cloned.specular = this.specular.Clone (); cloned.emissive = this.emissive.Clone (); + cloned.metallic = this.metallic; + cloned.roughness = this.roughness; + cloned.shininess = this.shininess; cloned.opacity = this.opacity; @@ -129,6 +124,7 @@ OV.Material = class cloned.bumpMap = this.CloneTextureMap (this.bumpMap); cloned.normalMap = this.CloneTextureMap (this.normalMap); cloned.emissiveMap = this.CloneTextureMap (this.emissiveMap); + cloned.metallicMap = this.CloneTextureMap (this.metallicMap); cloned.alphaTest = this.alphaTest; cloned.transparent = this.transparent; @@ -202,3 +198,25 @@ OV.ArrayToColor = function (arr) { return new OV.Color (arr[0], arr[1], arr[2]); }; + +OV.EnumerateMaterialTextureMaps = function (material, enumerator) +{ + if (material.diffuseMap !== null) { + enumerator (material.diffuseMap); + } + if (material.specularMap !== null) { + enumerator (material.specularMap); + } + if (material.bumpMap !== null) { + enumerator (material.bumpMap); + } + if (material.normalMap !== null) { + enumerator (material.normalMap); + } + if (material.emissiveMap !== null) { + enumerator (material.emissiveMap); + } + if (material.metallicMap !== null) { + enumerator (material.metallicMap); + } +}; diff --git a/source/model/modelutils.js b/source/model/modelutils.js index 1d8f5d1..aca3d06 100644 --- a/source/model/modelutils.js +++ b/source/model/modelutils.js @@ -259,7 +259,7 @@ OV.ReplaceDefaultMaterialColor = function (model, color) for (let i = 0; i < model.MaterialCount (); i++) { let material = model.GetMaterial (i); if (material.isDefault) { - material.diffuse = color; + material.color = color; } } }; diff --git a/source/threejs/threeconverter.js b/source/threejs/threeconverter.js index 0a501a2..858237c 100644 --- a/source/threejs/threeconverter.js +++ b/source/threejs/threeconverter.js @@ -44,28 +44,45 @@ OV.ConvertModelToThreeMeshes = function (model, params, output, callbacks) } let material = model.GetMaterial (materialIndex); - let diffuseColor = new THREE.Color (material.diffuse.r / 255.0, material.diffuse.g / 255.0, material.diffuse.b / 255.0); - let specularColor = new THREE.Color (material.specular.r / 255.0, material.specular.g / 255.0, material.specular.b / 255.0); + let diffuseColor = new THREE.Color (material.color.r / 255.0, material.color.g / 255.0, material.color.b / 255.0); let emissiveColor = new THREE.Color (material.emissive.r / 255.0, material.emissive.g / 255.0, material.emissive.b / 255.0); - if (OV.IsEqual (material.shininess, 0.0)) { - specularColor.setRGB (0.0, 0.0, 0.0); - } let materialParams = { color : diffuseColor, - specular : specularColor, emissive : emissiveColor, - shininess : material.shininess * 100.0, opacity : material.opacity, transparent : material.transparent, alphaTest : material.alphaTest, side : THREE.DoubleSide }; + if (params.forceMediumpForMaterials) { materialParams.precision = 'mediump'; } - let threeMaterial = new THREE.MeshPhongMaterial (materialParams); + let threeMaterial = null; + if (material.type === OV.MaterialType.Phong) { + threeMaterial = new THREE.MeshPhongMaterial (materialParams); + let specularColor = new THREE.Color (material.specular.r / 255.0, material.specular.g / 255.0, material.specular.b / 255.0); + if (OV.IsEqual (material.shininess, 0.0)) { + specularColor.setRGB (0.0, 0.0, 0.0); + } + threeMaterial.specular = specularColor; + threeMaterial.shininess = material.shininess * 100.0, + LoadTexture (threeMaterial, material.specularMap, (threeTexture) => { + threeMaterial.specularMap = threeTexture; + callbacks.onTextureLoaded (); + }); + } else if (material.type === OV.MaterialType.Physical) { + threeMaterial = new THREE.MeshStandardMaterial (materialParams); + threeMaterial.metalness = material.metalness; + threeMaterial.roughness = material.roughness; + LoadTexture (threeMaterial, material.metallicMap, (threeTexture) => { + threeMaterial.metalnessMap = threeTexture; + threeMaterial.roughnessMap = threeTexture; + callbacks.onTextureLoaded (); + }); + } LoadTexture (threeMaterial, material.diffuseMap, (threeTexture) => { if (!material.multiplyDiffuseMap) { threeMaterial.color.setRGB (1.0, 1.0, 1.0); @@ -73,10 +90,6 @@ OV.ConvertModelToThreeMeshes = function (model, params, output, callbacks) threeMaterial.map = threeTexture; callbacks.onTextureLoaded (); }); - LoadTexture (threeMaterial, material.specularMap, (threeTexture) => { - threeMaterial.specularMap = threeTexture; - callbacks.onTextureLoaded (); - }); LoadTexture (threeMaterial, material.bumpMap, (threeTexture) => { threeMaterial.bumpMap = threeTexture; callbacks.onTextureLoaded (); diff --git a/test/testfiles/o3dv/cube_transformation.o3dv b/test/testfiles/o3dv/cube_transformation.o3dv index 0bd08ce..051f477 100644 --- a/test/testfiles/o3dv/cube_transformation.o3dv +++ b/test/testfiles/o3dv/cube_transformation.o3dv @@ -2,19 +2,19 @@ "materials" : [ { "name" : "Material 1", - "diffuse" : [200, 0, 0] + "color" : [200, 0, 0] }, { "name" : "Material 2", - "diffuse" : [0, 200, 0] + "color" : [0, 200, 0] }, { "name" : "Material 3", - "diffuse" : [0, 0, 200] + "color" : [0, 0, 200] }, { "name" : "Material 4", - "diffuse" : [200, 200, 0] + "color" : [200, 200, 0] } ], "meshes" : [ diff --git a/test/testfiles/o3dv/cube_with_material.o3dv b/test/testfiles/o3dv/cube_with_material.o3dv index 2cffbde..86da30d 100644 --- a/test/testfiles/o3dv/cube_with_material.o3dv +++ b/test/testfiles/o3dv/cube_with_material.o3dv @@ -2,7 +2,7 @@ "materials" : [ { "name" : "Material", - "diffuse" : [200, 0, 0] + "color" : [200, 0, 0] } ], "meshes" : [ diff --git a/test/tests/exporter_test.js b/test/tests/exporter_test.js index 96350e7..37288f3 100644 --- a/test/tests/exporter_test.js +++ b/test/tests/exporter_test.js @@ -4,10 +4,10 @@ function CreateTestModel () { let model = new OV.Model (); - let material1 = new OV.Material (); + let material1 = new OV.Material (OV.MaterialType.Phong); material1.name = 'TestMaterial1'; material1.ambient = new OV.Color (0, 0, 0); - material1.diffuse = new OV.Color (255, 0, 0); + material1.color = new OV.Color (255, 0, 0); material1.specular = new OV.Color (51, 51, 51); material1.diffuseMap = new OV.TextureMap (); material1.diffuseMap.name = 'textures/texture1.png'; @@ -23,10 +23,10 @@ function CreateTestModel () material1.bumpMap.buffer = new ArrayBuffer (3); model.AddMaterial (material1); - let material2 = new OV.Material (); + let material2 = new OV.Material (OV.MaterialType.Phong); material2.name = 'TestMaterial2'; material2.ambient = new OV.Color (0, 0, 0); - material2.diffuse = new OV.Color (0, 255, 0); + material2.color = new OV.Color (0, 255, 0); material2.specular = new OV.Color (51, 51, 51); model.AddMaterial (material2); @@ -214,7 +214,7 @@ describe ('Exporter', function () { let importer = new OV.ImporterStl (); importer.Import (contentBuffer, 'stl', { getDefaultMaterial () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }, onSuccess () { let importedModel = importer.GetModel (); @@ -308,7 +308,7 @@ describe ('Exporter', function () { let importer = new OV.ImporterPly (); importer.Import (contentBuffer, 'ply', { getDefaultMaterial () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }, onSuccess () { let importedModel = importer.GetModel (); @@ -338,7 +338,7 @@ describe ('Exporter', function () { let importer = new OV.ImporterGltf (); importer.Import (contentBuffer, 'gltf', { getDefaultMaterial () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }, getFileBuffer (filePath) { if (filePath == 'model.bin') { @@ -376,7 +376,7 @@ describe ('Exporter', function () { let importer = new OV.ImporterGltf (); importer.Import (contentBuffer, 'glb', { getDefaultMaterial () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }, getFileBuffer (filePath) { return null; diff --git a/test/tests/importer_test.js b/test/tests/importer_test.js index 46c6c39..11f8e97 100644 --- a/test/tests/importer_test.js +++ b/test/tests/importer_test.js @@ -260,7 +260,7 @@ describe ('Importer Test', function () { assert.deepStrictEqual (importResult.usedFiles, ['single_triangle.stl']); assert.deepStrictEqual (importResult.missingFiles, []); let material = importResult.model.GetMaterial (0); - assert.deepStrictEqual (material.diffuse, new OV.Color (200, 0, 0)); + assert.deepStrictEqual (material.color, new OV.Color (200, 0, 0)); done (); }, onError : function (importError) { diff --git a/test/tests/meshbuffer_test.js b/test/tests/meshbuffer_test.js index 5491cb0..495ebec 100644 --- a/test/tests/meshbuffer_test.js +++ b/test/tests/meshbuffer_test.js @@ -123,7 +123,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); @@ -163,7 +163,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); @@ -205,7 +205,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); @@ -221,8 +221,8 @@ describe ('Mesh Buffer', function () { it ('Mesh To Buffer Cube Materials', function () { var model = new OV.Model (); - model.AddMaterial (new OV.Material ()); - model.AddMaterial (new OV.Material ()); + model.AddMaterial (new OV.Material (OV.MaterialType.Phong)); + model.AddMaterial (new OV.Material (OV.MaterialType.Phong)); var mesh = new OV.Mesh (); mesh.AddVertex (new OV.Coord3D (0.0, 0.0, 0.0)); @@ -249,7 +249,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); @@ -299,7 +299,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); @@ -342,7 +342,7 @@ describe ('Mesh Buffer', function () { model.AddMesh (mesh); OV.FinalizeModel (model, function () { - return new OV.Material (); + return new OV.Material (OV.MaterialType.Phong); }); assert (OV.CheckModel (model)); diff --git a/test/tests/model_test.js b/test/tests/model_test.js index 1352c42..6cf7bc0 100644 --- a/test/tests/model_test.js +++ b/test/tests/model_test.js @@ -9,7 +9,7 @@ describe ('Model', function() { it ('Add Material', function () { var model = new OV.Model (); - var material = new OV.Material (); + var material = new OV.Material (OV.MaterialType.Phong); material.name = 'example'; var index = model.AddMaterial (material); assert.strictEqual (model.MaterialCount (), 1); @@ -110,7 +110,7 @@ describe ('Model Finalization', function() { var model = new OV.Model (); var meshIndex = model.AddMesh (mesh); assert.strictEqual (model.MaterialCount (), 0); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); assert.strictEqual (model.MaterialCount (), 1); var theMesh = model.GetMesh (meshIndex); assert.strictEqual (theMesh.NormalCount (), 1); @@ -139,7 +139,7 @@ describe ('Model Finalization', function() { var model = new OV.Model () var meshIndex = model.AddMesh (mesh); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); var theMesh = model.GetMesh (meshIndex); assert.strictEqual (theMesh.NormalCount (), 6); @@ -172,7 +172,7 @@ describe ('Model Finalization', function() { var model = new OV.Model () var meshIndex = model.AddMesh (mesh); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); var theMesh = model.GetMesh (meshIndex); assert.strictEqual (theMesh.NormalCount (), 9); diff --git a/test/tests/modelutils_test.js b/test/tests/modelutils_test.js index 536d7ea..24f2b3e 100644 --- a/test/tests/modelutils_test.js +++ b/test/tests/modelutils_test.js @@ -19,7 +19,7 @@ describe ('Model Utils', function () { mesh2.AddTriangle (new OV.Triangle (0, 1, 2)); model.AddMesh (mesh2); - OV.FinalizeModel (model, function () { return new OV.Material (); }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong); }); assert.deepStrictEqual (testUtils.ModelToObject (model), { name : '', materials : [ @@ -103,7 +103,7 @@ describe ('Model Utils', function () { mesh2.AddTriangle (new OV.Triangle (0, 1, 2)); model.AddMesh (mesh2); - OV.FinalizeModel (model, function () { return new OV.Material (); }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong); }); let mesh1Bounds = OV.GetBoundingBox (model.GetMesh (0)); assert (OV.CoordIsEqual3D (mesh1Bounds.min, new OV.Coord3D (0.0, 0.0, 0.0))); diff --git a/test/utils/testfiles.js b/test/utils/testfiles.js index 0470666..7dd2880 100644 --- a/test/utils/testfiles.js +++ b/test/utils/testfiles.js @@ -75,7 +75,7 @@ module.exports = }); importer.Import (content, extension, { getDefaultMaterial : function () { - var material = new OV.Material (); + var material = new OV.Material (OV.MaterialType.Phong); return material; }, getFileBuffer : function (filePath) { diff --git a/test/utils/testutils.js b/test/utils/testutils.js index 4d4dd81..e1f285e 100644 --- a/test/utils/testutils.js +++ b/test/utils/testutils.js @@ -148,7 +148,7 @@ module.exports = let cube2 = OV.GenerateCuboid (new OV.GeneratorParams ().SetTransformationMatrix (matrix), 1.0, 1.0, 1.0); model.AddMesh (cube2); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); return model; }, @@ -163,7 +163,7 @@ module.exports = let cube2 = OV.GenerateCuboid (new OV.GeneratorParams ().SetTransformationMatrix (matrix), 1.0, 1.0, 1.0); model.AddMesh (cube2); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); return model; }, @@ -178,7 +178,7 @@ module.exports = let cube2 = OV.GenerateCuboid (new OV.GeneratorParams ().SetTransformationMatrix (matrix), 1.0, 1.0, 1.0); model.AddMesh (cube2); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); return model; }, @@ -227,7 +227,7 @@ module.exports = { var model = new OV.Model (); model.AddMesh (mesh); - OV.FinalizeModel (model, function () { return new OV.Material () }); + OV.FinalizeModel (model, function () { return new OV.Material (OV.MaterialType.Phong) }); return model; } } diff --git a/website/assets/images/3dviewer_net_start_page.png b/website/assets/images/3dviewer_net_start_page.png index 81adf3f..3fd6b4b 100644 Binary files a/website/assets/images/3dviewer_net_start_page.png and b/website/assets/images/3dviewer_net_start_page.png differ diff --git a/website/o3dv/detailssidebarpanel.js b/website/o3dv/detailssidebarpanel.js index 431adf0..05981d9 100644 --- a/website/o3dv/detailssidebarpanel.js +++ b/website/o3dv/detailssidebarpanel.js @@ -63,13 +63,14 @@ OV.DetailsSidebarPanel = class extends OV.SidebarPanel this.Clear (); let table = $('