Sidebar.Material.js 39 KB

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