|
@@ -42,7 +42,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
var materialNameRow = new UI.Panel();
|
|
|
var materialName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
|
|
|
|
|
|
- editor.setMaterialName( editor.selected.material, materialName.getValue() );
|
|
|
+ editor.execute( new SetMaterialValueCommand( editor.selected, 'name', materialName.getValue() ) );
|
|
|
|
|
|
} );
|
|
|
|
|
@@ -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'
|
|
|
|
|
@@ -82,7 +83,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
materialProgramInfo.setMarginLeft( '4px' );
|
|
|
materialProgramInfo.onClick( function () {
|
|
|
|
|
|
- signals.editScript.dispatch( currentObject.material, 'programInfo' );
|
|
|
+ signals.editScript.dispatch( currentObject, 'programInfo' );
|
|
|
|
|
|
} );
|
|
|
materialProgramRow.add( materialProgramInfo );
|
|
@@ -91,7 +92,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
materialProgramVertex.setMarginLeft( '4px' );
|
|
|
materialProgramVertex.onClick( function () {
|
|
|
|
|
|
- signals.editScript.dispatch( currentObject.material, 'vertexShader' );
|
|
|
+ signals.editScript.dispatch( currentObject, 'vertexShader' );
|
|
|
|
|
|
} );
|
|
|
materialProgramRow.add( materialProgramVertex );
|
|
@@ -100,7 +101,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
materialProgramFragment.setMarginLeft( '4px' );
|
|
|
materialProgramFragment.onClick( function () {
|
|
|
|
|
|
- signals.editScript.dispatch( currentObject.material, 'fragmentShader' );
|
|
|
+ signals.editScript.dispatch( currentObject, 'fragmentShader' );
|
|
|
|
|
|
} );
|
|
|
materialProgramRow.add( materialProgramFragment );
|
|
@@ -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();
|
|
@@ -237,6 +258,30 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
container.add( materialDisplacementMapRow );
|
|
|
|
|
|
+ // roughness map
|
|
|
+
|
|
|
+ var materialRoughnessMapRow = new UI.Panel();
|
|
|
+ var materialRoughnessMapEnabled = new UI.Checkbox( false ).onChange( update );
|
|
|
+ var materialRoughnessMap = new UI.Texture().onChange( update );
|
|
|
+
|
|
|
+ materialRoughnessMapRow.add( new UI.Text( 'Rough. Map' ).setWidth( '90px' ) );
|
|
|
+ materialRoughnessMapRow.add( materialRoughnessMapEnabled );
|
|
|
+ materialRoughnessMapRow.add( materialRoughnessMap );
|
|
|
+
|
|
|
+ container.add( materialRoughnessMapRow );
|
|
|
+
|
|
|
+ // metalness map
|
|
|
+
|
|
|
+ var materialMetalnessMapRow = new UI.Panel();
|
|
|
+ var materialMetalnessMapEnabled = new UI.Checkbox( false ).onChange( update );
|
|
|
+ var materialMetalnessMap = new UI.Texture().onChange( update );
|
|
|
+
|
|
|
+ materialMetalnessMapRow.add( new UI.Text( 'Metal. Map' ).setWidth( '90px' ) );
|
|
|
+ materialMetalnessMapRow.add( materialMetalnessMapEnabled );
|
|
|
+ materialMetalnessMapRow.add( materialMetalnessMap );
|
|
|
+
|
|
|
+ container.add( materialMetalnessMapRow );
|
|
|
+
|
|
|
// specular map
|
|
|
|
|
|
var materialSpecularMapRow = new UI.Panel();
|
|
@@ -343,7 +388,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
// opacity
|
|
|
|
|
|
var materialOpacityRow = new UI.Panel();
|
|
|
- var materialOpacity = new UI.Number().setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
|
|
|
+ var materialOpacity = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
|
|
|
|
|
|
materialOpacityRow.add( new UI.Text( 'Opacity' ).setWidth( '90px' ) );
|
|
|
materialOpacityRow.add( materialOpacity );
|
|
@@ -400,9 +445,9 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( material ) {
|
|
|
|
|
|
- if ( material.uuid !== undefined ) {
|
|
|
+ if ( material.uuid !== undefined && material.uuid !== materialUUID.getValue() ) {
|
|
|
|
|
|
- material.uuid = materialUUID.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'uuid', materialUUID.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -410,7 +455,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
material = new THREE[ materialClass.getValue() ]();
|
|
|
|
|
|
- object.material = material;
|
|
|
+ editor.execute( new SetMaterialCommand( currentObject, material ), 'New Material: ' + materialClass.getValue() );
|
|
|
// TODO Copy other references in the scene graph
|
|
|
// keeping name and UUID then.
|
|
|
// Also there should be means to create a unique
|
|
@@ -419,27 +464,39 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.color !== undefined ) {
|
|
|
+ if ( material.color !== undefined && material.color.getHex() !== materialColor.getHexValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialColorCommand( currentObject, 'color', materialColor.getHexValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 ) {
|
|
|
|
|
|
- material.color.setHex( materialColor.getHexValue() );
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'metalness', materialMetalness.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.emissive !== undefined ) {
|
|
|
+ if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) {
|
|
|
|
|
|
- material.emissive.setHex( materialEmissive.getHexValue() );
|
|
|
+ editor.execute( new SetMaterialColorCommand( currentObject, 'emissive', materialEmissive.getHexValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.specular !== undefined ) {
|
|
|
+ if ( material.specular !== undefined && material.specular.getHex() !== materialSpecular.getHexValue() ) {
|
|
|
|
|
|
- material.specular.setHex( materialSpecular.getHexValue() );
|
|
|
+ editor.execute( new SetMaterialColorCommand( currentObject, 'specular', materialSpecular.getHexValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.shininess !== undefined ) {
|
|
|
+ if ( material.shininess !== undefined && Math.abs( material.shininess - materialShininess.getValue() ) >= 0.01 ) {
|
|
|
|
|
|
- material.shininess = materialShininess.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'shininess', materialShininess.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -449,16 +506,15 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( material.vertexColors !== vertexColors ) {
|
|
|
|
|
|
- material.vertexColors = vertexColors;
|
|
|
- material.needsUpdate = true;
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'vertexColors', vertexColors ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.skinning !== undefined ) {
|
|
|
+ if ( material.skinning !== undefined && material.skinning !== materialSkinning.getValue() ) {
|
|
|
|
|
|
- material.skinning = materialSkinning.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'skinning', materialSkinning.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -468,8 +524,12 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.map = mapEnabled ? materialMap.getValue() : null;
|
|
|
- material.needsUpdate = true;
|
|
|
+ var map = mapEnabled ? materialMap.getValue() : null;
|
|
|
+ if ( material.map !== map ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'map', map ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -485,8 +545,12 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
|
|
|
- material.needsUpdate = true;
|
|
|
+ var alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
|
|
|
+ if ( material.alphaMap !== alphaMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'alphaMap', alphaMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -502,9 +566,18 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
|
|
|
- material.bumpScale = materialBumpScale.getValue();
|
|
|
- material.needsUpdate = true;
|
|
|
+ var bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
|
|
|
+ if ( material.bumpMap !== bumpMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'bumpMap', bumpMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.bumpScale !== materialBumpScale.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'bumpScale', materialBumpScale.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -520,8 +593,12 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
|
|
|
- material.needsUpdate = true;
|
|
|
+ var normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
|
|
|
+ if ( material.normalMap !== normalMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'normalMap', normalMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -537,9 +614,18 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.displacementMap = displacementMapEnabled ? materialDisplacementMap.getValue() : null;
|
|
|
- material.displacementScale = materialDisplacementScale.getValue();
|
|
|
- material.needsUpdate = true;
|
|
|
+ var displacementMap = displacementMapEnabled ? materialDisplacementMap.getValue() : null;
|
|
|
+ if ( material.displacementMap !== displacementMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'displacementMap', displacementMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -549,14 +635,72 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( material.roughnessMap !== undefined ) {
|
|
|
+
|
|
|
+ var roughnessMapEnabled = materialRoughnessMapEnabled.getValue() === true;
|
|
|
+
|
|
|
+ if ( objectHasUvs ) {
|
|
|
+
|
|
|
+ var roughnessMap = roughnessMapEnabled ? materialRoughnessMap.getValue() : null;
|
|
|
+ if ( material.roughnessMap !== roughnessMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'roughnessMap', roughnessMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( roughnessMapEnabled ) textureWarning = true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.metalnessMap !== undefined ) {
|
|
|
+
|
|
|
+ var metalnessMapEnabled = materialMetalnessMapEnabled.getValue() === true;
|
|
|
+
|
|
|
+ if ( objectHasUvs ) {
|
|
|
+
|
|
|
+ var metalnessMap = metalnessMapEnabled ? materialMetalnessMap.getValue() : null;
|
|
|
+ if ( material.metalnessMap !== metalnessMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'metalnessMap', metalnessMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if ( metalnessMapEnabled ) textureWarning = true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if ( material.specularMap !== undefined ) {
|
|
|
|
|
|
var specularMapEnabled = materialSpecularMapEnabled.getValue() === true;
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
|
|
|
- material.needsUpdate = true;
|
|
|
+ var specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
|
|
|
+ if ( material.specularMap !== specularMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'specularMap', specularMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -570,12 +714,21 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
var envMapEnabled = materialEnvMapEnabled.getValue() === true;
|
|
|
|
|
|
- material.envMap = envMapEnabled ? materialEnvMap.getValue() : null;
|
|
|
- material.reflectivity = materialReflectivity.getValue();
|
|
|
- material.needsUpdate = true;
|
|
|
+ var envMap = envMapEnabled ? materialEnvMap.getValue() : null;
|
|
|
|
|
|
- }
|
|
|
+ if ( material.envMap !== envMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'envMap', envMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.reflectivity !== materialReflectivity.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'reflectivity', materialReflectivity.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
if ( material.lightMap !== undefined ) {
|
|
|
|
|
@@ -583,8 +736,12 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
|
|
|
- material.needsUpdate = true;
|
|
|
+ var lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
|
|
|
+ if ( material.lightMap !== lightMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'lightMap', lightMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -600,9 +757,18 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( objectHasUvs ) {
|
|
|
|
|
|
- material.aoMap = aoMapEnabled ? materialAOMap.getValue() : null;
|
|
|
- material.aoMapIntensity = materialAOScale.getValue();
|
|
|
- material.needsUpdate = true;
|
|
|
+ var aoMap = aoMapEnabled ? materialAOMap.getValue() : null;
|
|
|
+ if ( material.aoMap !== aoMap ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialMapCommand( currentObject, 'aoMap', aoMap ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.aoMapIntensity !== materialAOScale.getValue() ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'aoMapIntensity', materialAOScale.getValue() ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
|
|
@@ -614,49 +780,65 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
if ( material.side !== undefined ) {
|
|
|
|
|
|
- material.side = parseInt( materialSide.getValue() );
|
|
|
+ var side = parseInt( materialSide.getValue() );
|
|
|
+ if ( material.side !== side ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'side', side ) );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
if ( material.shading !== undefined ) {
|
|
|
|
|
|
- material.shading = parseInt( materialShading.getValue() );
|
|
|
+ var shading = parseInt( materialShading.getValue() );
|
|
|
+ if ( material.shading !== shading ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'shading', shading ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
if ( material.blending !== undefined ) {
|
|
|
|
|
|
- material.blending = parseInt( materialBlending.getValue() );
|
|
|
+ var blending = parseInt( materialBlending.getValue() );
|
|
|
+ if ( material.blending !== blending ) {
|
|
|
+
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'blending', blending ) );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.opacity !== undefined ) {
|
|
|
+ if ( material.opacity !== undefined && Math.abs( material.opacity - materialOpacity.getValue() ) >= 0.01 ) {
|
|
|
|
|
|
- material.opacity = materialOpacity.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'opacity', materialOpacity.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.transparent !== undefined ) {
|
|
|
+ if ( material.transparent !== undefined && material.transparent !== materialTransparent.getValue() ) {
|
|
|
|
|
|
- material.transparent = materialTransparent.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'transparent', materialTransparent.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.alphaTest !== undefined ) {
|
|
|
+ if ( material.alphaTest !== undefined && Math.abs( material.alphaTest - materialAlphaTest.getValue() ) >= 0.01 ) {
|
|
|
|
|
|
- material.alphaTest = materialAlphaTest.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'alphaTest', materialAlphaTest.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.wireframe !== undefined ) {
|
|
|
+ if ( material.wireframe !== undefined && material.wireframe !== materialWireframe.getValue() ) {
|
|
|
|
|
|
- material.wireframe = materialWireframe.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'wireframe', materialWireframe.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( material.wireframeLinewidth !== undefined ) {
|
|
|
+ if ( material.wireframeLinewidth !== undefined && Math.abs( material.wireframeLinewidth - materialWireframeLinewidth.getValue() ) >= 0.01 ) {
|
|
|
|
|
|
- material.wireframeLinewidth = materialWireframeLinewidth.getValue();
|
|
|
+ editor.execute( new SetMaterialValueCommand( currentObject, 'wireframeLinewidth', materialWireframeLinewidth.getValue() ) );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -681,6 +863,8 @@ Sidebar.Material = function ( editor ) {
|
|
|
var properties = {
|
|
|
'name': materialNameRow,
|
|
|
'color': materialColorRow,
|
|
|
+ 'roughness': materialRoughnessRow,
|
|
|
+ 'metalness': materialMetalnessRow,
|
|
|
'emissive': materialEmissiveRow,
|
|
|
'specular': materialSpecularRow,
|
|
|
'shininess': materialShininessRow,
|
|
@@ -692,6 +876,8 @@ Sidebar.Material = function ( editor ) {
|
|
|
'bumpMap': materialBumpMapRow,
|
|
|
'normalMap': materialNormalMapRow,
|
|
|
'displacementMap': materialDisplacementMapRow,
|
|
|
+ 'roughnessMap': materialRoughnessMapRow,
|
|
|
+ 'metalnessMap': materialMetalnessMapRow,
|
|
|
'specularMap': materialSpecularMapRow,
|
|
|
'envMap': materialEnvMapRow,
|
|
|
'lightMap': materialLightMapRow,
|
|
@@ -718,6 +904,8 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
function refreshUi( resetTextureSelectors ) {
|
|
|
|
|
|
+ if ( !currentObject ) return;
|
|
|
+
|
|
|
var material = currentObject.material;
|
|
|
|
|
|
if ( material.uuid !== undefined ) {
|
|
@@ -740,6 +928,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() );
|
|
@@ -834,6 +1034,30 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( material.roughnessMap !== undefined ) {
|
|
|
+
|
|
|
+ materialRoughnessMapEnabled.setValue( material.roughnessMap !== null );
|
|
|
+
|
|
|
+ if ( material.roughnessMap !== null || resetTextureSelectors ) {
|
|
|
+
|
|
|
+ materialRoughnessMap.setValue( material.roughnessMap );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( material.metalnessMap !== undefined ) {
|
|
|
+
|
|
|
+ materialMetalnessMapEnabled.setValue( material.metalnessMap !== null );
|
|
|
+
|
|
|
+ if ( material.metalnessMap !== null || resetTextureSelectors ) {
|
|
|
+
|
|
|
+ materialMetalnessMap.setValue( material.metalnessMap );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if ( material.specularMap !== undefined ) {
|
|
|
|
|
|
materialSpecularMapEnabled.setValue( material.specularMap !== null );
|
|
@@ -959,6 +1183,7 @@ Sidebar.Material = function ( editor ) {
|
|
|
|
|
|
} );
|
|
|
|
|
|
+ signals.materialChanged.add( function () { refreshUi() } );
|
|
|
return container;
|
|
|
|
|
|
}
|