Sidebar.Material.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Material = function ( editor ) {
  5. var strings = editor.strings;
  6. var signals = editor.signals;
  7. var currentObject;
  8. var currentMaterialSlot = 0;
  9. var container = new UI.Panel();
  10. container.setBorderTop( '0' );
  11. container.setDisplay( 'none' );
  12. container.setPaddingTop( '20px' );
  13. // New / Copy / Paste
  14. var copiedMaterial;
  15. var managerRow = new UI.Row();
  16. // Current material slot
  17. var materialSlotRow = new UI.Row();
  18. materialSlotRow.add( new UI.Text( 'Slot' ).setWidth( '90px' ) );
  19. var materialSlotSelect = new UI.Select().setWidth( '170px' ).setFontSize( '12px' ).onChange( update );
  20. materialSlotSelect.setOptions( { 0: '' } ).setValue( 0 );
  21. materialSlotRow.add( materialSlotSelect );
  22. container.add( materialSlotRow );
  23. managerRow.add( new UI.Text( '' ).setWidth( '90px' ) );
  24. managerRow.add( new UI.Button( strings.getKey( 'sidebar/material/new' ) ).onClick( function () {
  25. var material = new THREE[ materialClass.getValue() ]();
  26. editor.execute( new SetMaterialCommand( currentObject, material, currentMaterialSlot ), 'New Material: ' + materialClass.getValue() );
  27. update();
  28. } ) );
  29. managerRow.add( new UI.Button( strings.getKey( 'sidebar/material/copy' ) ).setMarginLeft( '4px' ).onClick( function () {
  30. copiedMaterial = currentObject.material;
  31. if ( Array.isArray( copiedMaterial ) ) {
  32. if ( copiedMaterial.length === 0 ) return;
  33. copiedMaterial = copiedMaterial[ currentMaterialSlot ];
  34. }
  35. } ) );
  36. managerRow.add( new UI.Button( strings.getKey( 'sidebar/material/paste' ) ).setMarginLeft( '4px' ).onClick( function () {
  37. if ( copiedMaterial === undefined ) return;
  38. editor.execute( new SetMaterialCommand( currentObject, copiedMaterial, currentMaterialSlot ), 'Pasted Material: ' + materialClass.getValue() );
  39. refreshUI();
  40. update();
  41. } ) );
  42. container.add( managerRow );
  43. // type
  44. var materialClassRow = new UI.Row();
  45. var materialClass = new UI.Select().setOptions( {
  46. 'LineBasicMaterial': 'LineBasicMaterial',
  47. 'LineDashedMaterial': 'LineDashedMaterial',
  48. 'MeshBasicMaterial': 'MeshBasicMaterial',
  49. 'MeshDepthMaterial': 'MeshDepthMaterial',
  50. 'MeshNormalMaterial': 'MeshNormalMaterial',
  51. 'MeshLambertMaterial': 'MeshLambertMaterial',
  52. 'MeshPhongMaterial': 'MeshPhongMaterial',
  53. 'MeshStandardMaterial': 'MeshStandardMaterial',
  54. 'MeshPhysicalMaterial': 'MeshPhysicalMaterial',
  55. 'ShaderMaterial': 'ShaderMaterial',
  56. 'SpriteMaterial': 'SpriteMaterial'
  57. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  58. materialClassRow.add( new UI.Text( strings.getKey( 'sidebar/material/type' ) ).setWidth( '90px' ) );
  59. materialClassRow.add( materialClass );
  60. container.add( materialClassRow );
  61. // uuid
  62. var materialUUIDRow = new UI.Row();
  63. var materialUUID = new UI.Input().setWidth( '102px' ).setFontSize( '12px' ).setDisabled( true );
  64. var materialUUIDRenew = new UI.Button( strings.getKey( 'sidebar/material/new' ) ).setMarginLeft( '7px' ).onClick( function () {
  65. materialUUID.setValue( THREE.Math.generateUUID() );
  66. update();
  67. } );
  68. materialUUIDRow.add( new UI.Text( strings.getKey( 'sidebar/material/uuid' ) ).setWidth( '90px' ) );
  69. materialUUIDRow.add( materialUUID );
  70. materialUUIDRow.add( materialUUIDRenew );
  71. container.add( materialUUIDRow );
  72. // name
  73. var materialNameRow = new UI.Row();
  74. var materialName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
  75. editor.execute( new SetMaterialValueCommand( editor.selected, 'name', materialName.getValue(), currentMaterialSlot ) );
  76. } );
  77. materialNameRow.add( new UI.Text( strings.getKey( 'sidebar/material/name' ) ).setWidth( '90px' ) );
  78. materialNameRow.add( materialName );
  79. container.add( materialNameRow );
  80. // program
  81. var materialProgramRow = new UI.Row();
  82. materialProgramRow.add( new UI.Text( strings.getKey( 'sidebar/material/program' ) ).setWidth( '90px' ) );
  83. var materialProgramInfo = new UI.Button( strings.getKey( 'sidebar/material/info' ) );
  84. materialProgramInfo.setMarginLeft( '4px' );
  85. materialProgramInfo.onClick( function () {
  86. signals.editScript.dispatch( currentObject, 'programInfo' );
  87. } );
  88. materialProgramRow.add( materialProgramInfo );
  89. var materialProgramVertex = new UI.Button( strings.getKey( 'sidebar/material/vertex' ) );
  90. materialProgramVertex.setMarginLeft( '4px' );
  91. materialProgramVertex.onClick( function () {
  92. signals.editScript.dispatch( currentObject, 'vertexShader' );
  93. } );
  94. materialProgramRow.add( materialProgramVertex );
  95. var materialProgramFragment = new UI.Button( strings.getKey( 'sidebar/material/fragment' ) );
  96. materialProgramFragment.setMarginLeft( '4px' );
  97. materialProgramFragment.onClick( function () {
  98. signals.editScript.dispatch( currentObject, 'fragmentShader' );
  99. } );
  100. materialProgramRow.add( materialProgramFragment );
  101. container.add( materialProgramRow );
  102. // color
  103. var materialColorRow = new UI.Row();
  104. var materialColor = new UI.Color().onChange( update );
  105. materialColorRow.add( new UI.Text( strings.getKey( 'sidebar/material/color' ) ).setWidth( '90px' ) );
  106. materialColorRow.add( materialColor );
  107. container.add( materialColorRow );
  108. // roughness
  109. var materialRoughnessRow = new UI.Row();
  110. var materialRoughness = new UI.Number( 0.5 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  111. materialRoughnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/roughness' ) ).setWidth( '90px' ) );
  112. materialRoughnessRow.add( materialRoughness );
  113. container.add( materialRoughnessRow );
  114. // metalness
  115. var materialMetalnessRow = new UI.Row();
  116. var materialMetalness = new UI.Number( 0.5 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  117. materialMetalnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/metalness' ) ).setWidth( '90px' ) );
  118. materialMetalnessRow.add( materialMetalness );
  119. container.add( materialMetalnessRow );
  120. // emissive
  121. var materialEmissiveRow = new UI.Row();
  122. var materialEmissive = new UI.Color().setHexValue( 0x000000 ).onChange( update );
  123. materialEmissiveRow.add( new UI.Text( strings.getKey( 'sidebar/material/emissive' ) ).setWidth( '90px' ) );
  124. materialEmissiveRow.add( materialEmissive );
  125. container.add( materialEmissiveRow );
  126. // specular
  127. var materialSpecularRow = new UI.Row();
  128. var materialSpecular = new UI.Color().setHexValue( 0x111111 ).onChange( update );
  129. materialSpecularRow.add( new UI.Text( strings.getKey( 'sidebar/material/specular' ) ).setWidth( '90px' ) );
  130. materialSpecularRow.add( materialSpecular );
  131. container.add( materialSpecularRow );
  132. // shininess
  133. var materialShininessRow = new UI.Row();
  134. var materialShininess = new UI.Number( 30 ).onChange( update );
  135. materialShininessRow.add( new UI.Text( strings.getKey( 'sidebar/material/shininess' ) ).setWidth( '90px' ) );
  136. materialShininessRow.add( materialShininess );
  137. container.add( materialShininessRow );
  138. // clearCoat
  139. var materialClearCoatRow = new UI.Row();
  140. var materialClearCoat = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  141. materialClearCoatRow.add( new UI.Text( strings.getKey( 'sidebar/material/clearcoat' ) ).setWidth( '90px' ) );
  142. materialClearCoatRow.add( materialClearCoat );
  143. container.add( materialClearCoatRow );
  144. // clearCoatRoughness
  145. var materialClearCoatRoughnessRow = new UI.Row();
  146. var materialClearCoatRoughness = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  147. materialClearCoatRoughnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/clearcoatroughness' ) ).setWidth( '90px' ) );
  148. materialClearCoatRoughnessRow.add( materialClearCoatRoughness );
  149. container.add( materialClearCoatRoughnessRow );
  150. // vertex colors
  151. var materialVertexColorsRow = new UI.Row();
  152. var materialVertexColors = new UI.Select().setOptions( {
  153. 0: strings.getKey( 'sidebar/material/vertexcolors/no' ),
  154. 1: strings.getKey( 'sidebar/material/vertexcolors/face' ),
  155. 2: strings.getKey( 'sidebar/material/vertexcolors/vertex' )
  156. } ).onChange( update );
  157. materialVertexColorsRow.add( new UI.Text( strings.getKey( 'sidebar/material/vertexcolors' ) ).setWidth( '90px' ) );
  158. materialVertexColorsRow.add( materialVertexColors );
  159. container.add( materialVertexColorsRow );
  160. // depth packing
  161. var materialDepthPackingRow = new UI.Row();
  162. var materialDepthPacking = new UI.Select().setOptions( {
  163. [ THREE.BasicDepthPacking ]: 'BasicDepthPacking',
  164. [ THREE.RGBADepthPacking ]: 'RGBADepthPacking'
  165. } );
  166. materialDepthPacking.onChange( update );
  167. materialDepthPackingRow.add( new UI.Text( strings.getKey( 'sidebar/material/depthPacking' ) ).setWidth( '90px' ) );
  168. materialDepthPackingRow.add( materialDepthPacking );
  169. container.add( materialDepthPackingRow );
  170. // skinning
  171. var materialSkinningRow = new UI.Row();
  172. var materialSkinning = new UI.Checkbox( false ).onChange( update );
  173. materialSkinningRow.add( new UI.Text( strings.getKey( 'sidebar/material/skinning' ) ).setWidth( '90px' ) );
  174. materialSkinningRow.add( materialSkinning );
  175. container.add( materialSkinningRow );
  176. // map
  177. var materialMapRow = new UI.Row();
  178. var materialMapEnabled = new UI.Checkbox( false ).onChange( update );
  179. var materialMap = new UI.Texture().onChange( update );
  180. materialMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/map' ) ).setWidth( '90px' ) );
  181. materialMapRow.add( materialMapEnabled );
  182. materialMapRow.add( materialMap );
  183. container.add( materialMapRow );
  184. // alpha map
  185. var materialAlphaMapRow = new UI.Row();
  186. var materialAlphaMapEnabled = new UI.Checkbox( false ).onChange( update );
  187. var materialAlphaMap = new UI.Texture().onChange( update );
  188. materialAlphaMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/alphamap' ) ).setWidth( '90px' ) );
  189. materialAlphaMapRow.add( materialAlphaMapEnabled );
  190. materialAlphaMapRow.add( materialAlphaMap );
  191. container.add( materialAlphaMapRow );
  192. // bump map
  193. var materialBumpMapRow = new UI.Row();
  194. var materialBumpMapEnabled = new UI.Checkbox( false ).onChange( update );
  195. var materialBumpMap = new UI.Texture().onChange( update );
  196. var materialBumpScale = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  197. materialBumpMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/bumpmap' ) ).setWidth( '90px' ) );
  198. materialBumpMapRow.add( materialBumpMapEnabled );
  199. materialBumpMapRow.add( materialBumpMap );
  200. materialBumpMapRow.add( materialBumpScale );
  201. container.add( materialBumpMapRow );
  202. // normal map
  203. var materialNormalMapRow = new UI.Row();
  204. var materialNormalMapEnabled = new UI.Checkbox( false ).onChange( update );
  205. var materialNormalMap = new UI.Texture().onChange( update );
  206. materialNormalMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/normalmap' ) ).setWidth( '90px' ) );
  207. materialNormalMapRow.add( materialNormalMapEnabled );
  208. materialNormalMapRow.add( materialNormalMap );
  209. container.add( materialNormalMapRow );
  210. // displacement map
  211. var materialDisplacementMapRow = new UI.Row();
  212. var materialDisplacementMapEnabled = new UI.Checkbox( false ).onChange( update );
  213. var materialDisplacementMap = new UI.Texture().onChange( update );
  214. var materialDisplacementScale = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  215. materialDisplacementMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/displacemap' ) ).setWidth( '90px' ) );
  216. materialDisplacementMapRow.add( materialDisplacementMapEnabled );
  217. materialDisplacementMapRow.add( materialDisplacementMap );
  218. materialDisplacementMapRow.add( materialDisplacementScale );
  219. container.add( materialDisplacementMapRow );
  220. // roughness map
  221. var materialRoughnessMapRow = new UI.Row();
  222. var materialRoughnessMapEnabled = new UI.Checkbox( false ).onChange( update );
  223. var materialRoughnessMap = new UI.Texture().onChange( update );
  224. materialRoughnessMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/roughmap' ) ).setWidth( '90px' ) );
  225. materialRoughnessMapRow.add( materialRoughnessMapEnabled );
  226. materialRoughnessMapRow.add( materialRoughnessMap );
  227. container.add( materialRoughnessMapRow );
  228. // metalness map
  229. var materialMetalnessMapRow = new UI.Row();
  230. var materialMetalnessMapEnabled = new UI.Checkbox( false ).onChange( update );
  231. var materialMetalnessMap = new UI.Texture().onChange( update );
  232. materialMetalnessMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/metalmap' ) ).setWidth( '90px' ) );
  233. materialMetalnessMapRow.add( materialMetalnessMapEnabled );
  234. materialMetalnessMapRow.add( materialMetalnessMap );
  235. container.add( materialMetalnessMapRow );
  236. // specular map
  237. var materialSpecularMapRow = new UI.Row();
  238. var materialSpecularMapEnabled = new UI.Checkbox( false ).onChange( update );
  239. var materialSpecularMap = new UI.Texture().onChange( update );
  240. materialSpecularMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/specularmap' ) ).setWidth( '90px' ) );
  241. materialSpecularMapRow.add( materialSpecularMapEnabled );
  242. materialSpecularMapRow.add( materialSpecularMap );
  243. container.add( materialSpecularMapRow );
  244. // env map
  245. var materialEnvMapRow = new UI.Row();
  246. var materialEnvMapEnabled = new UI.Checkbox( false ).onChange( update );
  247. var materialEnvMap = new UI.Texture( THREE.SphericalReflectionMapping ).onChange( update );
  248. var materialReflectivity = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  249. materialEnvMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/envmap' ) ).setWidth( '90px' ) );
  250. materialEnvMapRow.add( materialEnvMapEnabled );
  251. materialEnvMapRow.add( materialEnvMap );
  252. materialEnvMapRow.add( materialReflectivity );
  253. container.add( materialEnvMapRow );
  254. // light map
  255. var materialLightMapRow = new UI.Row();
  256. var materialLightMapEnabled = new UI.Checkbox( false ).onChange( update );
  257. var materialLightMap = new UI.Texture().onChange( update );
  258. materialLightMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/lightmap' ) ).setWidth( '90px' ) );
  259. materialLightMapRow.add( materialLightMapEnabled );
  260. materialLightMapRow.add( materialLightMap );
  261. container.add( materialLightMapRow );
  262. // ambient occlusion map
  263. var materialAOMapRow = new UI.Row();
  264. var materialAOMapEnabled = new UI.Checkbox( false ).onChange( update );
  265. var materialAOMap = new UI.Texture().onChange( update );
  266. var materialAOScale = new UI.Number( 1 ).setRange( 0, 1 ).setWidth( '30px' ).onChange( update );
  267. materialAOMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/aomap' ) ).setWidth( '90px' ) );
  268. materialAOMapRow.add( materialAOMapEnabled );
  269. materialAOMapRow.add( materialAOMap );
  270. materialAOMapRow.add( materialAOScale );
  271. container.add( materialAOMapRow );
  272. // emissive map
  273. var materialEmissiveMapRow = new UI.Row();
  274. var materialEmissiveMapEnabled = new UI.Checkbox( false ).onChange( update );
  275. var materialEmissiveMap = new UI.Texture().onChange( update );
  276. materialEmissiveMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/emissivemap' ) ).setWidth( '90px' ) );
  277. materialEmissiveMapRow.add( materialEmissiveMapEnabled );
  278. materialEmissiveMapRow.add( materialEmissiveMap );
  279. container.add( materialEmissiveMapRow );
  280. // side
  281. var materialSideRow = new UI.Row();
  282. var materialSide = new UI.Select().setOptions( {
  283. 0: strings.getKey( 'sidebar/material/side/front' ),
  284. 1: strings.getKey( 'sidebar/material/side/back' ),
  285. 2: strings.getKey( 'sidebar/material/side/double' )
  286. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  287. materialSideRow.add( new UI.Text( strings.getKey( 'sidebar/material/side' ) ).setWidth( '90px' ) );
  288. materialSideRow.add( materialSide );
  289. container.add( materialSideRow );
  290. // shading
  291. var materialShadingRow = new UI.Row();
  292. var materialShading = new UI.Checkbox( false ).setLeft( '100px' ).onChange( update );
  293. materialShadingRow.add( new UI.Text( strings.getKey( 'sidebar/material/flatshaded' ) ).setWidth( '90px' ) );
  294. materialShadingRow.add( materialShading );
  295. container.add( materialShadingRow );
  296. // blending
  297. var materialBlendingRow = new UI.Row();
  298. var materialBlending = new UI.Select().setOptions( {
  299. 0: strings.getKey( 'sidebar/material/blending/no' ),
  300. 1: strings.getKey( 'sidebar/material/blending/normal' ),
  301. 2: strings.getKey( 'sidebar/material/blending/additive' ),
  302. 3: strings.getKey( 'sidebar/material/blending/subtractive' ),
  303. 4: strings.getKey( 'sidebar/material/blending/multiply' ),
  304. 5: strings.getKey( 'sidebar/material/blending/custom' )
  305. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  306. materialBlendingRow.add( new UI.Text( strings.getKey( 'sidebar/material/blending' ) ).setWidth( '90px' ) );
  307. materialBlendingRow.add( materialBlending );
  308. container.add( materialBlendingRow );
  309. // opacity
  310. var materialOpacityRow = new UI.Row();
  311. var materialOpacity = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  312. materialOpacityRow.add( new UI.Text( strings.getKey( 'sidebar/material/opacity' ) ).setWidth( '90px' ) );
  313. materialOpacityRow.add( materialOpacity );
  314. container.add( materialOpacityRow );
  315. // transparent
  316. var materialTransparentRow = new UI.Row();
  317. var materialTransparent = new UI.Checkbox().setLeft( '100px' ).onChange( update );
  318. materialTransparentRow.add( new UI.Text( strings.getKey( 'sidebar/material/transparent' ) ).setWidth( '90px' ) );
  319. materialTransparentRow.add( materialTransparent );
  320. container.add( materialTransparentRow );
  321. // alpha test
  322. var materialAlphaTestRow = new UI.Row();
  323. var materialAlphaTest = new UI.Number().setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  324. materialAlphaTestRow.add( new UI.Text( strings.getKey( 'sidebar/material/alphatest' ) ).setWidth( '90px' ) );
  325. materialAlphaTestRow.add( materialAlphaTest );
  326. container.add( materialAlphaTestRow );
  327. // wireframe
  328. var materialWireframeRow = new UI.Row();
  329. var materialWireframe = new UI.Checkbox( false ).onChange( update );
  330. var materialWireframeLinewidth = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 100 ).onChange( update );
  331. materialWireframeRow.add( new UI.Text( strings.getKey( 'sidebar/material/wireframe' ) ).setWidth( '90px' ) );
  332. materialWireframeRow.add( materialWireframe );
  333. materialWireframeRow.add( materialWireframeLinewidth );
  334. container.add( materialWireframeRow );
  335. //
  336. function update() {
  337. var object = currentObject;
  338. var geometry = object.geometry;
  339. var previousSelectedSlot = currentMaterialSlot;
  340. currentMaterialSlot = parseInt( materialSlotSelect.getValue() );
  341. if ( currentMaterialSlot !== previousSelectedSlot ) refreshUI( true );
  342. var material = editor.getObjectMaterial( currentObject, currentMaterialSlot );
  343. var textureWarning = false;
  344. var objectHasUvs = false;
  345. if ( object.isSprite ) objectHasUvs = true;
  346. if ( geometry.isGeometry && geometry.faceVertexUvs[ 0 ].length > 0 ) objectHasUvs = true;
  347. if ( geometry.isBufferGeometry && geometry.attributes.uv !== undefined ) objectHasUvs = true;
  348. if ( material ) {
  349. if ( material.uuid !== undefined && material.uuid !== materialUUID.getValue() ) {
  350. editor.execute( new SetMaterialValueCommand( currentObject, 'uuid', materialUUID.getValue(), currentMaterialSlot ) );
  351. }
  352. if ( material instanceof THREE[ materialClass.getValue() ] === false ) {
  353. material = new THREE[ materialClass.getValue() ]();
  354. editor.execute( new SetMaterialCommand( currentObject, material, currentMaterialSlot ), 'New Material: ' + materialClass.getValue() );
  355. // TODO Copy other references in the scene graph
  356. // keeping name and UUID then.
  357. // Also there should be means to create a unique
  358. // copy for the current object explicitly and to
  359. // attach the current material to other objects.
  360. }
  361. if ( material.color !== undefined && material.color.getHex() !== materialColor.getHexValue() ) {
  362. editor.execute( new SetMaterialColorCommand( currentObject, 'color', materialColor.getHexValue(), currentMaterialSlot ) );
  363. }
  364. if ( material.roughness !== undefined && Math.abs( material.roughness - materialRoughness.getValue() ) >= 0.01 ) {
  365. editor.execute( new SetMaterialValueCommand( currentObject, 'roughness', materialRoughness.getValue(), currentMaterialSlot ) );
  366. }
  367. if ( material.metalness !== undefined && Math.abs( material.metalness - materialMetalness.getValue() ) >= 0.01 ) {
  368. editor.execute( new SetMaterialValueCommand( currentObject, 'metalness', materialMetalness.getValue(), currentMaterialSlot ) );
  369. }
  370. if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) {
  371. editor.execute( new SetMaterialColorCommand( currentObject, 'emissive', materialEmissive.getHexValue(), currentMaterialSlot ) );
  372. }
  373. if ( material.specular !== undefined && material.specular.getHex() !== materialSpecular.getHexValue() ) {
  374. editor.execute( new SetMaterialColorCommand( currentObject, 'specular', materialSpecular.getHexValue(), currentMaterialSlot ) );
  375. }
  376. if ( material.shininess !== undefined && Math.abs( material.shininess - materialShininess.getValue() ) >= 0.01 ) {
  377. editor.execute( new SetMaterialValueCommand( currentObject, 'shininess', materialShininess.getValue(), currentMaterialSlot ) );
  378. }
  379. if ( material.clearCoat !== undefined && Math.abs( material.clearCoat - materialClearCoat.getValue() ) >= 0.01 ) {
  380. editor.execute( new SetMaterialValueCommand( currentObject, 'clearCoat', materialClearCoat.getValue(), currentMaterialSlot ) );
  381. }
  382. if ( material.clearCoatRoughness !== undefined && Math.abs( material.clearCoatRoughness - materialClearCoatRoughness.getValue() ) >= 0.01 ) {
  383. editor.execute( new SetMaterialValueCommand( currentObject, 'clearCoatRoughness', materialClearCoatRoughness.getValue(), currentMaterialSlot ) );
  384. }
  385. if ( material.vertexColors !== undefined ) {
  386. var vertexColors = parseInt( materialVertexColors.getValue() );
  387. if ( material.vertexColors !== vertexColors ) {
  388. editor.execute( new SetMaterialValueCommand( currentObject, 'vertexColors', vertexColors, currentMaterialSlot ) );
  389. }
  390. }
  391. if ( material.depthPacking !== undefined ) {
  392. var depthPacking = parseInt( materialDepthPacking.getValue() );
  393. if ( material.depthPacking !== depthPacking ) {
  394. editor.execute( new SetMaterialValueCommand( currentObject, 'depthPacking', depthPacking, currentMaterialSlot ) );
  395. }
  396. }
  397. if ( material.skinning !== undefined && material.skinning !== materialSkinning.getValue() ) {
  398. editor.execute( new SetMaterialValueCommand( currentObject, 'skinning', materialSkinning.getValue(), currentMaterialSlot ) );
  399. }
  400. if ( material.map !== undefined ) {
  401. var mapEnabled = materialMapEnabled.getValue() === true;
  402. if ( objectHasUvs ) {
  403. var map = mapEnabled ? materialMap.getValue() : null;
  404. if ( material.map !== map ) {
  405. editor.execute( new SetMaterialMapCommand( currentObject, 'map', map, currentMaterialSlot ) );
  406. }
  407. } else {
  408. if ( mapEnabled ) textureWarning = true;
  409. }
  410. }
  411. if ( material.alphaMap !== undefined ) {
  412. var mapEnabled = materialAlphaMapEnabled.getValue() === true;
  413. if ( objectHasUvs ) {
  414. var alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
  415. if ( material.alphaMap !== alphaMap ) {
  416. editor.execute( new SetMaterialMapCommand( currentObject, 'alphaMap', alphaMap, currentMaterialSlot ) );
  417. }
  418. } else {
  419. if ( mapEnabled ) textureWarning = true;
  420. }
  421. }
  422. if ( material.bumpMap !== undefined ) {
  423. var bumpMapEnabled = materialBumpMapEnabled.getValue() === true;
  424. if ( objectHasUvs ) {
  425. var bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
  426. if ( material.bumpMap !== bumpMap ) {
  427. editor.execute( new SetMaterialMapCommand( currentObject, 'bumpMap', bumpMap, currentMaterialSlot ) );
  428. }
  429. if ( material.bumpScale !== materialBumpScale.getValue() ) {
  430. editor.execute( new SetMaterialValueCommand( currentObject, 'bumpScale', materialBumpScale.getValue(), currentMaterialSlot ) );
  431. }
  432. } else {
  433. if ( bumpMapEnabled ) textureWarning = true;
  434. }
  435. }
  436. if ( material.normalMap !== undefined ) {
  437. var normalMapEnabled = materialNormalMapEnabled.getValue() === true;
  438. if ( objectHasUvs ) {
  439. var normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
  440. if ( material.normalMap !== normalMap ) {
  441. editor.execute( new SetMaterialMapCommand( currentObject, 'normalMap', normalMap, currentMaterialSlot ) );
  442. }
  443. } else {
  444. if ( normalMapEnabled ) textureWarning = true;
  445. }
  446. }
  447. if ( material.displacementMap !== undefined ) {
  448. var displacementMapEnabled = materialDisplacementMapEnabled.getValue() === true;
  449. if ( objectHasUvs ) {
  450. var displacementMap = displacementMapEnabled ? materialDisplacementMap.getValue() : null;
  451. if ( material.displacementMap !== displacementMap ) {
  452. editor.execute( new SetMaterialMapCommand( currentObject, 'displacementMap', displacementMap, currentMaterialSlot ) );
  453. }
  454. if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
  455. editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue(), currentMaterialSlot ) );
  456. }
  457. } else {
  458. if ( displacementMapEnabled ) textureWarning = true;
  459. }
  460. }
  461. if ( material.roughnessMap !== undefined ) {
  462. var roughnessMapEnabled = materialRoughnessMapEnabled.getValue() === true;
  463. if ( objectHasUvs ) {
  464. var roughnessMap = roughnessMapEnabled ? materialRoughnessMap.getValue() : null;
  465. if ( material.roughnessMap !== roughnessMap ) {
  466. editor.execute( new SetMaterialMapCommand( currentObject, 'roughnessMap', roughnessMap, currentMaterialSlot ) );
  467. }
  468. } else {
  469. if ( roughnessMapEnabled ) textureWarning = true;
  470. }
  471. }
  472. if ( material.metalnessMap !== undefined ) {
  473. var metalnessMapEnabled = materialMetalnessMapEnabled.getValue() === true;
  474. if ( objectHasUvs ) {
  475. var metalnessMap = metalnessMapEnabled ? materialMetalnessMap.getValue() : null;
  476. if ( material.metalnessMap !== metalnessMap ) {
  477. editor.execute( new SetMaterialMapCommand( currentObject, 'metalnessMap', metalnessMap, currentMaterialSlot ) );
  478. }
  479. } else {
  480. if ( metalnessMapEnabled ) textureWarning = true;
  481. }
  482. }
  483. if ( material.specularMap !== undefined ) {
  484. var specularMapEnabled = materialSpecularMapEnabled.getValue() === true;
  485. if ( objectHasUvs ) {
  486. var specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
  487. if ( material.specularMap !== specularMap ) {
  488. editor.execute( new SetMaterialMapCommand( currentObject, 'specularMap', specularMap, currentMaterialSlot ) );
  489. }
  490. } else {
  491. if ( specularMapEnabled ) textureWarning = true;
  492. }
  493. }
  494. if ( material.envMap !== undefined ) {
  495. var envMapEnabled = materialEnvMapEnabled.getValue() === true;
  496. var envMap = envMapEnabled ? materialEnvMap.getValue() : null;
  497. if ( material.envMap !== envMap ) {
  498. editor.execute( new SetMaterialMapCommand( currentObject, 'envMap', envMap, currentMaterialSlot ) );
  499. }
  500. }
  501. if ( material.reflectivity !== undefined ) {
  502. var reflectivity = materialReflectivity.getValue();
  503. if ( material.reflectivity !== reflectivity ) {
  504. editor.execute( new SetMaterialValueCommand( currentObject, 'reflectivity', reflectivity, currentMaterialSlot ) );
  505. }
  506. }
  507. if ( material.lightMap !== undefined ) {
  508. var lightMapEnabled = materialLightMapEnabled.getValue() === true;
  509. if ( objectHasUvs ) {
  510. var lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
  511. if ( material.lightMap !== lightMap ) {
  512. editor.execute( new SetMaterialMapCommand( currentObject, 'lightMap', lightMap, currentMaterialSlot ) );
  513. }
  514. } else {
  515. if ( lightMapEnabled ) textureWarning = true;
  516. }
  517. }
  518. if ( material.aoMap !== undefined ) {
  519. var aoMapEnabled = materialAOMapEnabled.getValue() === true;
  520. if ( objectHasUvs ) {
  521. var aoMap = aoMapEnabled ? materialAOMap.getValue() : null;
  522. if ( material.aoMap !== aoMap ) {
  523. editor.execute( new SetMaterialMapCommand( currentObject, 'aoMap', aoMap, currentMaterialSlot ) );
  524. }
  525. if ( material.aoMapIntensity !== materialAOScale.getValue() ) {
  526. editor.execute( new SetMaterialValueCommand( currentObject, 'aoMapIntensity', materialAOScale.getValue(), currentMaterialSlot ) );
  527. }
  528. } else {
  529. if ( aoMapEnabled ) textureWarning = true;
  530. }
  531. }
  532. if ( material.emissiveMap !== undefined ) {
  533. var emissiveMapEnabled = materialEmissiveMapEnabled.getValue() === true;
  534. if ( objectHasUvs ) {
  535. var emissiveMap = emissiveMapEnabled ? materialEmissiveMap.getValue() : null;
  536. if ( material.emissiveMap !== emissiveMap ) {
  537. editor.execute( new SetMaterialMapCommand( currentObject, 'emissiveMap', emissiveMap, currentMaterialSlot ) );
  538. }
  539. } else {
  540. if ( emissiveMapEnabled ) textureWarning = true;
  541. }
  542. }
  543. if ( material.side !== undefined ) {
  544. var side = parseInt( materialSide.getValue() );
  545. if ( material.side !== side ) {
  546. editor.execute( new SetMaterialValueCommand( currentObject, 'side', side, currentMaterialSlot ) );
  547. }
  548. }
  549. if ( material.flatShading !== undefined ) {
  550. var flatShading = materialShading.getValue();
  551. if ( material.flatShading != flatShading ) {
  552. editor.execute( new SetMaterialValueCommand( currentObject, 'flatShading', flatShading, currentMaterialSlot ) );
  553. }
  554. }
  555. if ( material.blending !== undefined ) {
  556. var blending = parseInt( materialBlending.getValue() );
  557. if ( material.blending !== blending ) {
  558. editor.execute( new SetMaterialValueCommand( currentObject, 'blending', blending, currentMaterialSlot ) );
  559. }
  560. }
  561. if ( material.opacity !== undefined && Math.abs( material.opacity - materialOpacity.getValue() ) >= 0.01 ) {
  562. editor.execute( new SetMaterialValueCommand( currentObject, 'opacity', materialOpacity.getValue(), currentMaterialSlot ) );
  563. }
  564. if ( material.transparent !== undefined && material.transparent !== materialTransparent.getValue() ) {
  565. editor.execute( new SetMaterialValueCommand( currentObject, 'transparent', materialTransparent.getValue(), currentMaterialSlot ) );
  566. }
  567. if ( material.alphaTest !== undefined && Math.abs( material.alphaTest - materialAlphaTest.getValue() ) >= 0.01 ) {
  568. editor.execute( new SetMaterialValueCommand( currentObject, 'alphaTest', materialAlphaTest.getValue(), currentMaterialSlot ) );
  569. }
  570. if ( material.wireframe !== undefined && material.wireframe !== materialWireframe.getValue() ) {
  571. editor.execute( new SetMaterialValueCommand( currentObject, 'wireframe', materialWireframe.getValue(), currentMaterialSlot ) );
  572. }
  573. if ( material.wireframeLinewidth !== undefined && Math.abs( material.wireframeLinewidth - materialWireframeLinewidth.getValue() ) >= 0.01 ) {
  574. editor.execute( new SetMaterialValueCommand( currentObject, 'wireframeLinewidth', materialWireframeLinewidth.getValue(), currentMaterialSlot ) );
  575. }
  576. refreshUI();
  577. }
  578. if ( textureWarning ) {
  579. console.warn( "Can't set texture, model doesn't have texture coordinates" );
  580. }
  581. }
  582. //
  583. function setRowVisibility() {
  584. var properties = {
  585. 'name': materialNameRow,
  586. 'color': materialColorRow,
  587. 'roughness': materialRoughnessRow,
  588. 'metalness': materialMetalnessRow,
  589. 'emissive': materialEmissiveRow,
  590. 'specular': materialSpecularRow,
  591. 'shininess': materialShininessRow,
  592. 'clearCoat': materialClearCoatRow,
  593. 'clearCoatRoughness': materialClearCoatRoughnessRow,
  594. 'vertexShader': materialProgramRow,
  595. 'vertexColors': materialVertexColorsRow,
  596. 'depthPacking': materialDepthPackingRow,
  597. 'skinning': materialSkinningRow,
  598. 'map': materialMapRow,
  599. 'alphaMap': materialAlphaMapRow,
  600. 'bumpMap': materialBumpMapRow,
  601. 'normalMap': materialNormalMapRow,
  602. 'displacementMap': materialDisplacementMapRow,
  603. 'roughnessMap': materialRoughnessMapRow,
  604. 'metalnessMap': materialMetalnessMapRow,
  605. 'specularMap': materialSpecularMapRow,
  606. 'envMap': materialEnvMapRow,
  607. 'lightMap': materialLightMapRow,
  608. 'aoMap': materialAOMapRow,
  609. 'emissiveMap': materialEmissiveMapRow,
  610. 'side': materialSideRow,
  611. 'flatShading': materialShadingRow,
  612. 'blending': materialBlendingRow,
  613. 'opacity': materialOpacityRow,
  614. 'transparent': materialTransparentRow,
  615. 'alphaTest': materialAlphaTestRow,
  616. 'wireframe': materialWireframeRow
  617. };
  618. var material = currentObject.material;
  619. if ( Array.isArray( material ) ) {
  620. materialSlotRow.setDisplay( '' );
  621. if ( material.length === 0 ) return;
  622. material = material[ currentMaterialSlot ];
  623. } else {
  624. materialSlotRow.setDisplay( 'none' );
  625. }
  626. for ( var property in properties ) {
  627. properties[ property ].setDisplay( material[ property ] !== undefined ? '' : 'none' );
  628. }
  629. }
  630. function refreshUI( resetTextureSelectors ) {
  631. if ( ! currentObject ) return;
  632. var material = currentObject.material;
  633. if ( Array.isArray( material ) ) {
  634. var slotOptions = {};
  635. currentMaterialSlot = Math.max( 0, Math.min( material.length, currentMaterialSlot ) );
  636. for ( var i = 0; i < material.length; i ++ ) {
  637. slotOptions[ i ] = String( i + 1 ) + ': ' + material[ i ].name;
  638. }
  639. materialSlotSelect.setOptions( slotOptions ).setValue( currentMaterialSlot );
  640. }
  641. material = editor.getObjectMaterial( currentObject, currentMaterialSlot );
  642. if ( material.uuid !== undefined ) {
  643. materialUUID.setValue( material.uuid );
  644. }
  645. if ( material.name !== undefined ) {
  646. materialName.setValue( material.name );
  647. }
  648. materialClass.setValue( material.type );
  649. if ( material.color !== undefined ) {
  650. materialColor.setHexValue( material.color.getHexString() );
  651. }
  652. if ( material.roughness !== undefined ) {
  653. materialRoughness.setValue( material.roughness );
  654. }
  655. if ( material.metalness !== undefined ) {
  656. materialMetalness.setValue( material.metalness );
  657. }
  658. if ( material.emissive !== undefined ) {
  659. materialEmissive.setHexValue( material.emissive.getHexString() );
  660. }
  661. if ( material.specular !== undefined ) {
  662. materialSpecular.setHexValue( material.specular.getHexString() );
  663. }
  664. if ( material.shininess !== undefined ) {
  665. materialShininess.setValue( material.shininess );
  666. }
  667. if ( material.clearCoat !== undefined ) {
  668. materialClearCoat.setValue( material.clearCoat );
  669. }
  670. if ( material.clearCoatRoughness !== undefined ) {
  671. materialClearCoatRoughness.setValue( material.clearCoatRoughness );
  672. }
  673. if ( material.vertexColors !== undefined ) {
  674. materialVertexColors.setValue( material.vertexColors );
  675. }
  676. if ( material.depthPacking !== undefined ) {
  677. materialDepthPacking.setValue( material.depthPacking );
  678. }
  679. if ( material.skinning !== undefined ) {
  680. materialSkinning.setValue( material.skinning );
  681. }
  682. if ( material.map !== undefined ) {
  683. materialMapEnabled.setValue( material.map !== null );
  684. if ( material.map !== null || resetTextureSelectors ) {
  685. materialMap.setValue( material.map );
  686. }
  687. }
  688. if ( material.alphaMap !== undefined ) {
  689. materialAlphaMapEnabled.setValue( material.alphaMap !== null );
  690. if ( material.alphaMap !== null || resetTextureSelectors ) {
  691. materialAlphaMap.setValue( material.alphaMap );
  692. }
  693. }
  694. if ( material.bumpMap !== undefined ) {
  695. materialBumpMapEnabled.setValue( material.bumpMap !== null );
  696. if ( material.bumpMap !== null || resetTextureSelectors ) {
  697. materialBumpMap.setValue( material.bumpMap );
  698. }
  699. materialBumpScale.setValue( material.bumpScale );
  700. }
  701. if ( material.normalMap !== undefined ) {
  702. materialNormalMapEnabled.setValue( material.normalMap !== null );
  703. if ( material.normalMap !== null || resetTextureSelectors ) {
  704. materialNormalMap.setValue( material.normalMap );
  705. }
  706. }
  707. if ( material.displacementMap !== undefined ) {
  708. materialDisplacementMapEnabled.setValue( material.displacementMap !== null );
  709. if ( material.displacementMap !== null || resetTextureSelectors ) {
  710. materialDisplacementMap.setValue( material.displacementMap );
  711. }
  712. materialDisplacementScale.setValue( material.displacementScale );
  713. }
  714. if ( material.roughnessMap !== undefined ) {
  715. materialRoughnessMapEnabled.setValue( material.roughnessMap !== null );
  716. if ( material.roughnessMap !== null || resetTextureSelectors ) {
  717. materialRoughnessMap.setValue( material.roughnessMap );
  718. }
  719. }
  720. if ( material.metalnessMap !== undefined ) {
  721. materialMetalnessMapEnabled.setValue( material.metalnessMap !== null );
  722. if ( material.metalnessMap !== null || resetTextureSelectors ) {
  723. materialMetalnessMap.setValue( material.metalnessMap );
  724. }
  725. }
  726. if ( material.specularMap !== undefined ) {
  727. materialSpecularMapEnabled.setValue( material.specularMap !== null );
  728. if ( material.specularMap !== null || resetTextureSelectors ) {
  729. materialSpecularMap.setValue( material.specularMap );
  730. }
  731. }
  732. if ( material.envMap !== undefined ) {
  733. materialEnvMapEnabled.setValue( material.envMap !== null );
  734. if ( material.envMap !== null || resetTextureSelectors ) {
  735. materialEnvMap.setValue( material.envMap );
  736. }
  737. }
  738. if ( material.reflectivity !== undefined ) {
  739. materialReflectivity.setValue( material.reflectivity );
  740. }
  741. if ( material.lightMap !== undefined ) {
  742. materialLightMapEnabled.setValue( material.lightMap !== null );
  743. if ( material.lightMap !== null || resetTextureSelectors ) {
  744. materialLightMap.setValue( material.lightMap );
  745. }
  746. }
  747. if ( material.aoMap !== undefined ) {
  748. materialAOMapEnabled.setValue( material.aoMap !== null );
  749. if ( material.aoMap !== null || resetTextureSelectors ) {
  750. materialAOMap.setValue( material.aoMap );
  751. }
  752. materialAOScale.setValue( material.aoMapIntensity );
  753. }
  754. if ( material.emissiveMap !== undefined ) {
  755. materialEmissiveMapEnabled.setValue( material.emissiveMap !== null );
  756. if ( material.emissiveMap !== null || resetTextureSelectors ) {
  757. materialEmissiveMap.setValue( material.emissiveMap );
  758. }
  759. }
  760. if ( material.side !== undefined ) {
  761. materialSide.setValue( material.side );
  762. }
  763. if ( material.flatShading !== undefined ) {
  764. materialShading.setValue( material.flatShading );
  765. }
  766. if ( material.blending !== undefined ) {
  767. materialBlending.setValue( material.blending );
  768. }
  769. if ( material.opacity !== undefined ) {
  770. materialOpacity.setValue( material.opacity );
  771. }
  772. if ( material.transparent !== undefined ) {
  773. materialTransparent.setValue( material.transparent );
  774. }
  775. if ( material.alphaTest !== undefined ) {
  776. materialAlphaTest.setValue( material.alphaTest );
  777. }
  778. if ( material.wireframe !== undefined ) {
  779. materialWireframe.setValue( material.wireframe );
  780. }
  781. if ( material.wireframeLinewidth !== undefined ) {
  782. materialWireframeLinewidth.setValue( material.wireframeLinewidth );
  783. }
  784. setRowVisibility();
  785. }
  786. // events
  787. signals.objectSelected.add( function ( object ) {
  788. var hasMaterial = false;
  789. if ( object && object.material ) {
  790. hasMaterial = true;
  791. if ( Array.isArray( object.material ) && object.material.length === 0 ) {
  792. hasMaterial = false;
  793. }
  794. }
  795. if ( hasMaterial ) {
  796. var objectChanged = object !== currentObject;
  797. currentObject = object;
  798. refreshUI( objectChanged );
  799. container.setDisplay( '' );
  800. } else {
  801. currentObject = null;
  802. container.setDisplay( 'none' );
  803. }
  804. } );
  805. signals.materialChanged.add( function () {
  806. refreshUI();
  807. } );
  808. return container;
  809. };