diff --git a/editor/js/Sidebar.Material.js b/editor/js/Sidebar.Material.js index fa9f47f99eb2ef9596788deebf824ffc37df7b6e..402c5c784e288bc327432b5747d642f2e645454c 100644 --- a/editor/js/Sidebar.Material.js +++ b/editor/js/Sidebar.Material.js @@ -60,9 +60,10 @@ Sidebar.Material = function ( editor ) { 'LineDashedMaterial': 'LineDashedMaterial', 'MeshBasicMaterial': 'MeshBasicMaterial', 'MeshDepthMaterial': 'MeshDepthMaterial', - 'MeshLambertMaterial': 'MeshLambertMaterial', 'MeshNormalMaterial': 'MeshNormalMaterial', + 'MeshLambertMaterial': 'MeshLambertMaterial', 'MeshPhongMaterial': 'MeshPhongMaterial', + 'MeshPhysicalMaterial': 'MeshPhysicalMaterial', 'ShaderMaterial': 'ShaderMaterial', 'SpriteMaterial': 'SpriteMaterial' @@ -117,6 +118,26 @@ Sidebar.Material = function ( editor ) { container.add( materialColorRow ); + // roughness + + var materialRoughnessRow = new UI.Panel(); + var materialRoughness = new UI.Number( 0.5 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update ); + + materialRoughnessRow.add( new UI.Text( 'Roughness' ).setWidth( '90px' ) ); + materialRoughnessRow.add( materialRoughness ); + + container.add( materialRoughnessRow ); + + // metalness + + var materialMetalnessRow = new UI.Panel(); + var materialMetalness = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update ); + + materialMetalnessRow.add( new UI.Text( 'Metalness' ).setWidth( '90px' ) ); + materialMetalnessRow.add( materialMetalness ); + + container.add( materialMetalnessRow ); + // emissive var materialEmissiveRow = new UI.Panel(); @@ -425,6 +446,18 @@ Sidebar.Material = function ( editor ) { } + if ( material.roughness !== undefined && Math.abs( material.roughness - materialRoughness.getValue() ) >= 0.01 ) { + + editor.execute( new SetMaterialValueCommand( currentObject, 'roughness', materialRoughness.getValue() ) ); + + } + + if ( material.metalness !== undefined && Math.abs( material.metalness - materialMetalness.getValue() ) >= 0.01 ) { + + editor.execute( new SetMaterialValueCommand( currentObject, 'metalness', materialMetalness.getValue() ) ); + + } + if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) { editor.execute( new SetMaterialColorCommand( currentObject, 'emissive', materialEmissive.getHexValue() ) ); @@ -752,6 +785,8 @@ Sidebar.Material = function ( editor ) { var properties = { 'name': materialNameRow, 'color': materialColorRow, + 'roughness': materialRoughnessRow, + 'metalness': materialMetalnessRow, 'emissive': materialEmissiveRow, 'specular': materialSpecularRow, 'shininess': materialShininessRow, @@ -813,6 +848,18 @@ Sidebar.Material = function ( editor ) { } + if ( material.roughness !== undefined ) { + + materialRoughness.setValue( material.roughness ); + + } + + if ( material.metalness !== undefined ) { + + materialMetalness.setValue( material.metalness ); + + } + if ( material.emissive !== undefined ) { materialEmissive.setHexValue( material.emissive.getHexString() );