Sidebar.Material.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422
  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. 'ShaderMaterial': 'ShaderMaterial',
  57. 'SpriteMaterial': 'SpriteMaterial'
  58. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  59. materialClassRow.add( new UI.Text( strings.getKey( 'sidebar/material/type' ) ).setWidth( '90px' ) );
  60. materialClassRow.add( materialClass );
  61. container.add( materialClassRow );
  62. // uuid
  63. var materialUUIDRow = new UI.Row();
  64. var materialUUID = new UI.Input().setWidth( '102px' ).setFontSize( '12px' ).setDisabled( true );
  65. var materialUUIDRenew = new UI.Button( strings.getKey( 'sidebar/material/new' ) ).setMarginLeft( '7px' ).onClick( function () {
  66. materialUUID.setValue( THREE.Math.generateUUID() );
  67. update();
  68. } );
  69. materialUUIDRow.add( new UI.Text( strings.getKey( 'sidebar/material/uuid' ) ).setWidth( '90px' ) );
  70. materialUUIDRow.add( materialUUID );
  71. materialUUIDRow.add( materialUUIDRenew );
  72. container.add( materialUUIDRow );
  73. // name
  74. var materialNameRow = new UI.Row();
  75. var materialName = new UI.Input().setWidth( '150px' ).setFontSize( '12px' ).onChange( function () {
  76. editor.execute( new SetMaterialValueCommand( editor.selected, 'name', materialName.getValue(), currentMaterialSlot ) );
  77. } );
  78. materialNameRow.add( new UI.Text( strings.getKey( 'sidebar/material/name' ) ).setWidth( '90px' ) );
  79. materialNameRow.add( materialName );
  80. container.add( materialNameRow );
  81. // program
  82. var materialProgramRow = new UI.Row();
  83. materialProgramRow.add( new UI.Text( strings.getKey( 'sidebar/material/program' ) ).setWidth( '90px' ) );
  84. var materialProgramInfo = new UI.Button( strings.getKey( 'sidebar/material/info' ) );
  85. materialProgramInfo.setMarginLeft( '4px' );
  86. materialProgramInfo.onClick( function () {
  87. signals.editScript.dispatch( currentObject, 'programInfo' );
  88. } );
  89. materialProgramRow.add( materialProgramInfo );
  90. var materialProgramVertex = new UI.Button( strings.getKey( 'sidebar/material/vertex' ) );
  91. materialProgramVertex.setMarginLeft( '4px' );
  92. materialProgramVertex.onClick( function () {
  93. signals.editScript.dispatch( currentObject, 'vertexShader' );
  94. } );
  95. materialProgramRow.add( materialProgramVertex );
  96. var materialProgramFragment = new UI.Button( strings.getKey( 'sidebar/material/fragment' ) );
  97. materialProgramFragment.setMarginLeft( '4px' );
  98. materialProgramFragment.onClick( function () {
  99. signals.editScript.dispatch( currentObject, 'fragmentShader' );
  100. } );
  101. materialProgramRow.add( materialProgramFragment );
  102. container.add( materialProgramRow );
  103. // color
  104. var materialColorRow = new UI.Row();
  105. var materialColor = new UI.Color().onChange( update );
  106. materialColorRow.add( new UI.Text( strings.getKey( 'sidebar/material/color' ) ).setWidth( '90px' ) );
  107. materialColorRow.add( materialColor );
  108. container.add( materialColorRow );
  109. // roughness
  110. var materialRoughnessRow = new UI.Row();
  111. var materialRoughness = new UI.Number( 0.5 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  112. materialRoughnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/roughness' ) ).setWidth( '90px' ) );
  113. materialRoughnessRow.add( materialRoughness );
  114. container.add( materialRoughnessRow );
  115. // metalness
  116. var materialMetalnessRow = new UI.Row();
  117. var materialMetalness = new UI.Number( 0.5 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  118. materialMetalnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/metalness' ) ).setWidth( '90px' ) );
  119. materialMetalnessRow.add( materialMetalness );
  120. container.add( materialMetalnessRow );
  121. // emissive
  122. var materialEmissiveRow = new UI.Row();
  123. var materialEmissive = new UI.Color().setHexValue( 0x000000 ).onChange( update );
  124. materialEmissiveRow.add( new UI.Text( strings.getKey( 'sidebar/material/emissive' ) ).setWidth( '90px' ) );
  125. materialEmissiveRow.add( materialEmissive );
  126. container.add( materialEmissiveRow );
  127. // specular
  128. var materialSpecularRow = new UI.Row();
  129. var materialSpecular = new UI.Color().setHexValue( 0x111111 ).onChange( update );
  130. materialSpecularRow.add( new UI.Text( strings.getKey( 'sidebar/material/specular' ) ).setWidth( '90px' ) );
  131. materialSpecularRow.add( materialSpecular );
  132. container.add( materialSpecularRow );
  133. // shininess
  134. var materialShininessRow = new UI.Row();
  135. var materialShininess = new UI.Number( 30 ).onChange( update );
  136. materialShininessRow.add( new UI.Text( strings.getKey( 'sidebar/material/shininess' ) ).setWidth( '90px' ) );
  137. materialShininessRow.add( materialShininess );
  138. container.add( materialShininessRow );
  139. // clearCoat
  140. var materialClearCoatRow = new UI.Row();
  141. var materialClearCoat = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  142. materialClearCoatRow.add( new UI.Text( strings.getKey( 'sidebar/material/clearcoat' ) ).setWidth( '90px' ) );
  143. materialClearCoatRow.add( materialClearCoat );
  144. container.add( materialClearCoatRow );
  145. // clearCoatRoughness
  146. var materialClearCoatRoughnessRow = new UI.Row();
  147. var materialClearCoatRoughness = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  148. materialClearCoatRoughnessRow.add( new UI.Text( strings.getKey( 'sidebar/material/clearcoatroughness' ) ).setWidth( '90px' ) );
  149. materialClearCoatRoughnessRow.add( materialClearCoatRoughness );
  150. container.add( materialClearCoatRoughnessRow );
  151. // vertex colors
  152. var materialVertexColorsRow = new UI.Row();
  153. var materialVertexColors = new UI.Select().setOptions( {
  154. 0: strings.getKey( 'sidebar/material/vertexcolors/no' ),
  155. 1: strings.getKey( 'sidebar/material/vertexcolors/face' ),
  156. 2: strings.getKey( 'sidebar/material/vertexcolors/vertex' )
  157. } ).onChange( update );
  158. materialVertexColorsRow.add( new UI.Text( strings.getKey( 'sidebar/material/vertexcolors' ) ).setWidth( '90px' ) );
  159. materialVertexColorsRow.add( materialVertexColors );
  160. container.add( materialVertexColorsRow );
  161. // skinning
  162. var materialSkinningRow = new UI.Row();
  163. var materialSkinning = new UI.Checkbox( false ).onChange( update );
  164. materialSkinningRow.add( new UI.Text( strings.getKey( 'sidebar/material/skinning' ) ).setWidth( '90px' ) );
  165. materialSkinningRow.add( materialSkinning );
  166. container.add( materialSkinningRow );
  167. // map
  168. var materialMapRow = new UI.Row();
  169. var materialMapEnabled = new UI.Checkbox( false ).onChange( update );
  170. var materialMap = new UI.Texture().onChange( update );
  171. materialMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/map' ) ).setWidth( '90px' ) );
  172. materialMapRow.add( materialMapEnabled );
  173. materialMapRow.add( materialMap );
  174. container.add( materialMapRow );
  175. // alpha map
  176. var materialAlphaMapRow = new UI.Row();
  177. var materialAlphaMapEnabled = new UI.Checkbox( false ).onChange( update );
  178. var materialAlphaMap = new UI.Texture().onChange( update );
  179. materialAlphaMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/alphamap' ) ).setWidth( '90px' ) );
  180. materialAlphaMapRow.add( materialAlphaMapEnabled );
  181. materialAlphaMapRow.add( materialAlphaMap );
  182. container.add( materialAlphaMapRow );
  183. // bump map
  184. var materialBumpMapRow = new UI.Row();
  185. var materialBumpMapEnabled = new UI.Checkbox( false ).onChange( update );
  186. var materialBumpMap = new UI.Texture().onChange( update );
  187. var materialBumpScale = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  188. materialBumpMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/bumpmap' ) ).setWidth( '90px' ) );
  189. materialBumpMapRow.add( materialBumpMapEnabled );
  190. materialBumpMapRow.add( materialBumpMap );
  191. materialBumpMapRow.add( materialBumpScale );
  192. container.add( materialBumpMapRow );
  193. // normal map
  194. var materialNormalMapRow = new UI.Row();
  195. var materialNormalMapEnabled = new UI.Checkbox( false ).onChange( update );
  196. var materialNormalMap = new UI.Texture().onChange( update );
  197. materialNormalMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/normalmap' ) ).setWidth( '90px' ) );
  198. materialNormalMapRow.add( materialNormalMapEnabled );
  199. materialNormalMapRow.add( materialNormalMap );
  200. container.add( materialNormalMapRow );
  201. // displacement map
  202. var materialDisplacementMapRow = new UI.Row();
  203. var materialDisplacementMapEnabled = new UI.Checkbox( false ).onChange( update );
  204. var materialDisplacementMap = new UI.Texture().onChange( update );
  205. var materialDisplacementScale = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  206. materialDisplacementMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/displacemap' ) ).setWidth( '90px' ) );
  207. materialDisplacementMapRow.add( materialDisplacementMapEnabled );
  208. materialDisplacementMapRow.add( materialDisplacementMap );
  209. materialDisplacementMapRow.add( materialDisplacementScale );
  210. container.add( materialDisplacementMapRow );
  211. // roughness map
  212. var materialRoughnessMapRow = new UI.Row();
  213. var materialRoughnessMapEnabled = new UI.Checkbox( false ).onChange( update );
  214. var materialRoughnessMap = new UI.Texture().onChange( update );
  215. materialRoughnessMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/roughmap' ) ).setWidth( '90px' ) );
  216. materialRoughnessMapRow.add( materialRoughnessMapEnabled );
  217. materialRoughnessMapRow.add( materialRoughnessMap );
  218. container.add( materialRoughnessMapRow );
  219. // metalness map
  220. var materialMetalnessMapRow = new UI.Row();
  221. var materialMetalnessMapEnabled = new UI.Checkbox( false ).onChange( update );
  222. var materialMetalnessMap = new UI.Texture().onChange( update );
  223. materialMetalnessMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/metalmap' ) ).setWidth( '90px' ) );
  224. materialMetalnessMapRow.add( materialMetalnessMapEnabled );
  225. materialMetalnessMapRow.add( materialMetalnessMap );
  226. container.add( materialMetalnessMapRow );
  227. // specular map
  228. var materialSpecularMapRow = new UI.Row();
  229. var materialSpecularMapEnabled = new UI.Checkbox( false ).onChange( update );
  230. var materialSpecularMap = new UI.Texture().onChange( update );
  231. materialSpecularMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/specularmap' ) ).setWidth( '90px' ) );
  232. materialSpecularMapRow.add( materialSpecularMapEnabled );
  233. materialSpecularMapRow.add( materialSpecularMap );
  234. container.add( materialSpecularMapRow );
  235. // env map
  236. var materialEnvMapRow = new UI.Row();
  237. var materialEnvMapEnabled = new UI.Checkbox( false ).onChange( update );
  238. var materialEnvMap = new UI.Texture( THREE.SphericalReflectionMapping ).onChange( update );
  239. var materialReflectivity = new UI.Number( 1 ).setWidth( '30px' ).onChange( update );
  240. materialEnvMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/envmap' ) ).setWidth( '90px' ) );
  241. materialEnvMapRow.add( materialEnvMapEnabled );
  242. materialEnvMapRow.add( materialEnvMap );
  243. materialEnvMapRow.add( materialReflectivity );
  244. container.add( materialEnvMapRow );
  245. // light map
  246. var materialLightMapRow = new UI.Row();
  247. var materialLightMapEnabled = new UI.Checkbox( false ).onChange( update );
  248. var materialLightMap = new UI.Texture().onChange( update );
  249. materialLightMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/lightmap' ) ).setWidth( '90px' ) );
  250. materialLightMapRow.add( materialLightMapEnabled );
  251. materialLightMapRow.add( materialLightMap );
  252. container.add( materialLightMapRow );
  253. // ambient occlusion map
  254. var materialAOMapRow = new UI.Row();
  255. var materialAOMapEnabled = new UI.Checkbox( false ).onChange( update );
  256. var materialAOMap = new UI.Texture().onChange( update );
  257. var materialAOScale = new UI.Number( 1 ).setRange( 0, 1 ).setWidth( '30px' ).onChange( update );
  258. materialAOMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/aomap' ) ).setWidth( '90px' ) );
  259. materialAOMapRow.add( materialAOMapEnabled );
  260. materialAOMapRow.add( materialAOMap );
  261. materialAOMapRow.add( materialAOScale );
  262. container.add( materialAOMapRow );
  263. // emissive map
  264. var materialEmissiveMapRow = new UI.Row();
  265. var materialEmissiveMapEnabled = new UI.Checkbox( false ).onChange( update );
  266. var materialEmissiveMap = new UI.Texture().onChange( update );
  267. materialEmissiveMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/emissivemap' ) ).setWidth( '90px' ) );
  268. materialEmissiveMapRow.add( materialEmissiveMapEnabled );
  269. materialEmissiveMapRow.add( materialEmissiveMap );
  270. container.add( materialEmissiveMapRow );
  271. // gradient map
  272. var materialGradientMapRow = new UI.Row();
  273. var materialGradientMapEnabled = new UI.Checkbox( false ).onChange( update );
  274. var materialGradientMap = new UI.Texture().onChange( update );
  275. materialGradientMapRow.add( new UI.Text( strings.getKey( 'sidebar/material/gradientmap' ) ).setWidth( '90px' ) );
  276. materialGradientMapRow.add( materialGradientMapEnabled );
  277. materialGradientMapRow.add( materialGradientMap );
  278. container.add( materialGradientMapRow );
  279. // side
  280. var materialSideRow = new UI.Row();
  281. var materialSide = new UI.Select().setOptions( {
  282. 0: strings.getKey( 'sidebar/material/side/front' ),
  283. 1: strings.getKey( 'sidebar/material/side/back' ),
  284. 2: strings.getKey( 'sidebar/material/side/double' )
  285. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  286. materialSideRow.add( new UI.Text( strings.getKey( 'sidebar/material/side' ) ).setWidth( '90px' ) );
  287. materialSideRow.add( materialSide );
  288. container.add( materialSideRow );
  289. // shading
  290. var materialShadingRow = new UI.Row();
  291. var materialShading = new UI.Checkbox( false ).setLeft( '100px' ).onChange( update );
  292. materialShadingRow.add( new UI.Text( strings.getKey( 'sidebar/material/flatshaded' ) ).setWidth( '90px' ) );
  293. materialShadingRow.add( materialShading );
  294. container.add( materialShadingRow );
  295. // blending
  296. var materialBlendingRow = new UI.Row();
  297. var materialBlending = new UI.Select().setOptions( {
  298. 0: strings.getKey( 'sidebar/material/blending/no' ),
  299. 1: strings.getKey( 'sidebar/material/blending/normal' ),
  300. 2: strings.getKey( 'sidebar/material/blending/additive' ),
  301. 3: strings.getKey( 'sidebar/material/blending/subtractive' ),
  302. 4: strings.getKey( 'sidebar/material/blending/multiply' ),
  303. 5: strings.getKey( 'sidebar/material/blending/custom' )
  304. } ).setWidth( '150px' ).setFontSize( '12px' ).onChange( update );
  305. materialBlendingRow.add( new UI.Text( strings.getKey( 'sidebar/material/blending' ) ).setWidth( '90px' ) );
  306. materialBlendingRow.add( materialBlending );
  307. container.add( materialBlendingRow );
  308. // opacity
  309. var materialOpacityRow = new UI.Row();
  310. var materialOpacity = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  311. materialOpacityRow.add( new UI.Text( strings.getKey( 'sidebar/material/opacity' ) ).setWidth( '90px' ) );
  312. materialOpacityRow.add( materialOpacity );
  313. container.add( materialOpacityRow );
  314. // transparent
  315. var materialTransparentRow = new UI.Row();
  316. var materialTransparent = new UI.Checkbox().setLeft( '100px' ).onChange( update );
  317. materialTransparentRow.add( new UI.Text( strings.getKey( 'sidebar/material/transparent' ) ).setWidth( '90px' ) );
  318. materialTransparentRow.add( materialTransparent );
  319. container.add( materialTransparentRow );
  320. // alpha test
  321. var materialAlphaTestRow = new UI.Row();
  322. var materialAlphaTest = new UI.Number().setWidth( '60px' ).setRange( 0, 1 ).onChange( update );
  323. materialAlphaTestRow.add( new UI.Text( strings.getKey( 'sidebar/material/alphatest' ) ).setWidth( '90px' ) );
  324. materialAlphaTestRow.add( materialAlphaTest );
  325. container.add( materialAlphaTestRow );
  326. // wireframe
  327. var materialWireframeRow = new UI.Row();
  328. var materialWireframe = new UI.Checkbox( false ).onChange( update );
  329. var materialWireframeLinewidth = new UI.Number( 1 ).setWidth( '60px' ).setRange( 0, 100 ).onChange( update );
  330. materialWireframeRow.add( new UI.Text( strings.getKey( 'sidebar/material/wireframe' ) ).setWidth( '90px' ) );
  331. materialWireframeRow.add( materialWireframe );
  332. materialWireframeRow.add( materialWireframeLinewidth );
  333. container.add( materialWireframeRow );
  334. //
  335. function update() {
  336. var object = currentObject;
  337. var geometry = object.geometry;
  338. var previousSelectedSlot = currentMaterialSlot;
  339. currentMaterialSlot = parseInt( materialSlotSelect.getValue() );
  340. if ( currentMaterialSlot !== previousSelectedSlot ) refreshUI( true );
  341. var material = editor.getObjectMaterial( currentObject, currentMaterialSlot );
  342. var textureWarning = false;
  343. var objectHasUvs = false;
  344. if ( object.isSprite ) objectHasUvs = true;
  345. if ( geometry.isGeometry && geometry.faceVertexUvs[ 0 ].length > 0 ) objectHasUvs = true;
  346. if ( geometry.isBufferGeometry && geometry.attributes.uv !== undefined ) objectHasUvs = true;
  347. if ( material ) {
  348. if ( material.uuid !== undefined && material.uuid !== materialUUID.getValue() ) {
  349. editor.execute( new SetMaterialValueCommand( currentObject, 'uuid', materialUUID.getValue(), currentMaterialSlot ) );
  350. }
  351. if ( material.type !== materialClass.getValue() ) {
  352. material = new THREE[ materialClass.getValue() ]();
  353. editor.execute( new SetMaterialCommand( currentObject, material, currentMaterialSlot ), 'New Material: ' + materialClass.getValue() );
  354. // TODO Copy other references in the scene graph
  355. // keeping name and UUID then.
  356. // Also there should be means to create a unique
  357. // copy for the current object explicitly and to
  358. // attach the current material to other objects.
  359. }
  360. if ( material.color !== undefined && material.color.getHex() !== materialColor.getHexValue() ) {
  361. editor.execute( new SetMaterialColorCommand( currentObject, 'color', materialColor.getHexValue(), currentMaterialSlot ) );
  362. }
  363. if ( material.roughness !== undefined && Math.abs( material.roughness - materialRoughness.getValue() ) >= 0.01 ) {
  364. editor.execute( new SetMaterialValueCommand( currentObject, 'roughness', materialRoughness.getValue(), currentMaterialSlot ) );
  365. }
  366. if ( material.metalness !== undefined && Math.abs( material.metalness - materialMetalness.getValue() ) >= 0.01 ) {
  367. editor.execute( new SetMaterialValueCommand( currentObject, 'metalness', materialMetalness.getValue(), currentMaterialSlot ) );
  368. }
  369. if ( material.emissive !== undefined && material.emissive.getHex() !== materialEmissive.getHexValue() ) {
  370. editor.execute( new SetMaterialColorCommand( currentObject, 'emissive', materialEmissive.getHexValue(), currentMaterialSlot ) );
  371. }
  372. if ( material.specular !== undefined && material.specular.getHex() !== materialSpecular.getHexValue() ) {
  373. editor.execute( new SetMaterialColorCommand( currentObject, 'specular', materialSpecular.getHexValue(), currentMaterialSlot ) );
  374. }
  375. if ( material.shininess !== undefined && Math.abs( material.shininess - materialShininess.getValue() ) >= 0.01 ) {
  376. editor.execute( new SetMaterialValueCommand( currentObject, 'shininess', materialShininess.getValue(), currentMaterialSlot ) );
  377. }
  378. if ( material.clearCoat !== undefined && Math.abs( material.clearCoat - materialClearCoat.getValue() ) >= 0.01 ) {
  379. editor.execute( new SetMaterialValueCommand( currentObject, 'clearCoat', materialClearCoat.getValue(), currentMaterialSlot ) );
  380. }
  381. if ( material.clearCoatRoughness !== undefined && Math.abs( material.clearCoatRoughness - materialClearCoatRoughness.getValue() ) >= 0.01 ) {
  382. editor.execute( new SetMaterialValueCommand( currentObject, 'clearCoatRoughness', materialClearCoatRoughness.getValue(), currentMaterialSlot ) );
  383. }
  384. if ( material.vertexColors !== undefined ) {
  385. var vertexColors = parseInt( materialVertexColors.getValue() );
  386. if ( material.vertexColors !== vertexColors ) {
  387. editor.execute( new SetMaterialValueCommand( currentObject, 'vertexColors', vertexColors, currentMaterialSlot ) );
  388. }
  389. }
  390. if ( material.skinning !== undefined && material.skinning !== materialSkinning.getValue() ) {
  391. editor.execute( new SetMaterialValueCommand( currentObject, 'skinning', materialSkinning.getValue(), currentMaterialSlot ) );
  392. }
  393. if ( material.map !== undefined ) {
  394. var mapEnabled = materialMapEnabled.getValue() === true;
  395. if ( objectHasUvs ) {
  396. var map = mapEnabled ? materialMap.getValue() : null;
  397. if ( material.map !== map ) {
  398. editor.execute( new SetMaterialMapCommand( currentObject, 'map', map, currentMaterialSlot ) );
  399. }
  400. } else {
  401. if ( mapEnabled ) textureWarning = true;
  402. }
  403. }
  404. if ( material.alphaMap !== undefined ) {
  405. var mapEnabled = materialAlphaMapEnabled.getValue() === true;
  406. if ( objectHasUvs ) {
  407. var alphaMap = mapEnabled ? materialAlphaMap.getValue() : null;
  408. if ( material.alphaMap !== alphaMap ) {
  409. editor.execute( new SetMaterialMapCommand( currentObject, 'alphaMap', alphaMap, currentMaterialSlot ) );
  410. }
  411. } else {
  412. if ( mapEnabled ) textureWarning = true;
  413. }
  414. }
  415. if ( material.bumpMap !== undefined ) {
  416. var bumpMapEnabled = materialBumpMapEnabled.getValue() === true;
  417. if ( objectHasUvs ) {
  418. var bumpMap = bumpMapEnabled ? materialBumpMap.getValue() : null;
  419. if ( material.bumpMap !== bumpMap ) {
  420. editor.execute( new SetMaterialMapCommand( currentObject, 'bumpMap', bumpMap, currentMaterialSlot ) );
  421. }
  422. if ( material.bumpScale !== materialBumpScale.getValue() ) {
  423. editor.execute( new SetMaterialValueCommand( currentObject, 'bumpScale', materialBumpScale.getValue(), currentMaterialSlot ) );
  424. }
  425. } else {
  426. if ( bumpMapEnabled ) textureWarning = true;
  427. }
  428. }
  429. if ( material.normalMap !== undefined ) {
  430. var normalMapEnabled = materialNormalMapEnabled.getValue() === true;
  431. if ( objectHasUvs ) {
  432. var normalMap = normalMapEnabled ? materialNormalMap.getValue() : null;
  433. if ( material.normalMap !== normalMap ) {
  434. editor.execute( new SetMaterialMapCommand( currentObject, 'normalMap', normalMap, currentMaterialSlot ) );
  435. }
  436. } else {
  437. if ( normalMapEnabled ) textureWarning = true;
  438. }
  439. }
  440. if ( material.displacementMap !== undefined ) {
  441. var displacementMapEnabled = materialDisplacementMapEnabled.getValue() === true;
  442. if ( objectHasUvs ) {
  443. var displacementMap = displacementMapEnabled ? materialDisplacementMap.getValue() : null;
  444. if ( material.displacementMap !== displacementMap ) {
  445. editor.execute( new SetMaterialMapCommand( currentObject, 'displacementMap', displacementMap, currentMaterialSlot ) );
  446. }
  447. if ( material.displacementScale !== materialDisplacementScale.getValue() ) {
  448. editor.execute( new SetMaterialValueCommand( currentObject, 'displacementScale', materialDisplacementScale.getValue(), currentMaterialSlot ) );
  449. }
  450. } else {
  451. if ( displacementMapEnabled ) textureWarning = true;
  452. }
  453. }
  454. if ( material.roughnessMap !== undefined ) {
  455. var roughnessMapEnabled = materialRoughnessMapEnabled.getValue() === true;
  456. if ( objectHasUvs ) {
  457. var roughnessMap = roughnessMapEnabled ? materialRoughnessMap.getValue() : null;
  458. if ( material.roughnessMap !== roughnessMap ) {
  459. editor.execute( new SetMaterialMapCommand( currentObject, 'roughnessMap', roughnessMap, currentMaterialSlot ) );
  460. }
  461. } else {
  462. if ( roughnessMapEnabled ) textureWarning = true;
  463. }
  464. }
  465. if ( material.metalnessMap !== undefined ) {
  466. var metalnessMapEnabled = materialMetalnessMapEnabled.getValue() === true;
  467. if ( objectHasUvs ) {
  468. var metalnessMap = metalnessMapEnabled ? materialMetalnessMap.getValue() : null;
  469. if ( material.metalnessMap !== metalnessMap ) {
  470. editor.execute( new SetMaterialMapCommand( currentObject, 'metalnessMap', metalnessMap, currentMaterialSlot ) );
  471. }
  472. } else {
  473. if ( metalnessMapEnabled ) textureWarning = true;
  474. }
  475. }
  476. if ( material.specularMap !== undefined ) {
  477. var specularMapEnabled = materialSpecularMapEnabled.getValue() === true;
  478. if ( objectHasUvs ) {
  479. var specularMap = specularMapEnabled ? materialSpecularMap.getValue() : null;
  480. if ( material.specularMap !== specularMap ) {
  481. editor.execute( new SetMaterialMapCommand( currentObject, 'specularMap', specularMap, currentMaterialSlot ) );
  482. }
  483. } else {
  484. if ( specularMapEnabled ) textureWarning = true;
  485. }
  486. }
  487. if ( material.envMap !== undefined ) {
  488. var envMapEnabled = materialEnvMapEnabled.getValue() === true;
  489. var envMap = envMapEnabled ? materialEnvMap.getValue() : null;
  490. if ( material.envMap !== envMap ) {
  491. editor.execute( new SetMaterialMapCommand( currentObject, 'envMap', envMap, currentMaterialSlot ) );
  492. }
  493. }
  494. if ( material.reflectivity !== undefined ) {
  495. var reflectivity = materialReflectivity.getValue();
  496. if ( material.reflectivity !== reflectivity ) {
  497. editor.execute( new SetMaterialValueCommand( currentObject, 'reflectivity', reflectivity, currentMaterialSlot ) );
  498. }
  499. }
  500. if ( material.lightMap !== undefined ) {
  501. var lightMapEnabled = materialLightMapEnabled.getValue() === true;
  502. if ( objectHasUvs ) {
  503. var lightMap = lightMapEnabled ? materialLightMap.getValue() : null;
  504. if ( material.lightMap !== lightMap ) {
  505. editor.execute( new SetMaterialMapCommand( currentObject, 'lightMap', lightMap, currentMaterialSlot ) );
  506. }
  507. } else {
  508. if ( lightMapEnabled ) textureWarning = true;
  509. }
  510. }
  511. if ( material.aoMap !== undefined ) {
  512. var aoMapEnabled = materialAOMapEnabled.getValue() === true;
  513. if ( objectHasUvs ) {
  514. var aoMap = aoMapEnabled ? materialAOMap.getValue() : null;
  515. if ( material.aoMap !== aoMap ) {
  516. editor.execute( new SetMaterialMapCommand( currentObject, 'aoMap', aoMap, currentMaterialSlot ) );
  517. }
  518. if ( material.aoMapIntensity !== materialAOScale.getValue() ) {
  519. editor.execute( new SetMaterialValueCommand( currentObject, 'aoMapIntensity', materialAOScale.getValue(), currentMaterialSlot ) );
  520. }
  521. } else {
  522. if ( aoMapEnabled ) textureWarning = true;
  523. }
  524. }
  525. if ( material.emissiveMap !== undefined ) {
  526. var emissiveMapEnabled = materialEmissiveMapEnabled.getValue() === true;
  527. if ( objectHasUvs ) {
  528. var emissiveMap = emissiveMapEnabled ? materialEmissiveMap.getValue() : null;
  529. if ( material.emissiveMap !== emissiveMap ) {
  530. editor.execute( new SetMaterialMapCommand( currentObject, 'emissiveMap', emissiveMap, currentMaterialSlot ) );
  531. }
  532. } else {
  533. if ( emissiveMapEnabled ) textureWarning = true;
  534. }
  535. }
  536. if ( material.gradientMap !== undefined ) {
  537. var gradientMapEnabled = materialGradientMapEnabled.getValue() === true;
  538. var gradientMap = gradientMapEnabled ? materialGradientMap.getValue() : null;
  539. if ( material.gradientMap !== gradientMap ) {
  540. editor.execute( new SetMaterialMapCommand( currentObject, 'gradientMap', gradientMap, currentMaterialSlot ) );
  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. 'skinning': materialSkinningRow,
  597. 'map': materialMapRow,
  598. 'alphaMap': materialAlphaMapRow,
  599. 'bumpMap': materialBumpMapRow,
  600. 'normalMap': materialNormalMapRow,
  601. 'displacementMap': materialDisplacementMapRow,
  602. 'roughnessMap': materialRoughnessMapRow,
  603. 'metalnessMap': materialMetalnessMapRow,
  604. 'specularMap': materialSpecularMapRow,
  605. 'envMap': materialEnvMapRow,
  606. 'lightMap': materialLightMapRow,
  607. 'aoMap': materialAOMapRow,
  608. 'emissiveMap': materialEmissiveMapRow,
  609. 'gradientMap': materialGradientMapRow,
  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.skinning !== undefined ) {
  677. materialSkinning.setValue( material.skinning );
  678. }
  679. if ( material.map !== undefined ) {
  680. materialMapEnabled.setValue( material.map !== null );
  681. if ( material.map !== null || resetTextureSelectors ) {
  682. materialMap.setValue( material.map );
  683. }
  684. }
  685. if ( material.alphaMap !== undefined ) {
  686. materialAlphaMapEnabled.setValue( material.alphaMap !== null );
  687. if ( material.alphaMap !== null || resetTextureSelectors ) {
  688. materialAlphaMap.setValue( material.alphaMap );
  689. }
  690. }
  691. if ( material.bumpMap !== undefined ) {
  692. materialBumpMapEnabled.setValue( material.bumpMap !== null );
  693. if ( material.bumpMap !== null || resetTextureSelectors ) {
  694. materialBumpMap.setValue( material.bumpMap );
  695. }
  696. materialBumpScale.setValue( material.bumpScale );
  697. }
  698. if ( material.normalMap !== undefined ) {
  699. materialNormalMapEnabled.setValue( material.normalMap !== null );
  700. if ( material.normalMap !== null || resetTextureSelectors ) {
  701. materialNormalMap.setValue( material.normalMap );
  702. }
  703. }
  704. if ( material.displacementMap !== undefined ) {
  705. materialDisplacementMapEnabled.setValue( material.displacementMap !== null );
  706. if ( material.displacementMap !== null || resetTextureSelectors ) {
  707. materialDisplacementMap.setValue( material.displacementMap );
  708. }
  709. materialDisplacementScale.setValue( material.displacementScale );
  710. }
  711. if ( material.roughnessMap !== undefined ) {
  712. materialRoughnessMapEnabled.setValue( material.roughnessMap !== null );
  713. if ( material.roughnessMap !== null || resetTextureSelectors ) {
  714. materialRoughnessMap.setValue( material.roughnessMap );
  715. }
  716. }
  717. if ( material.metalnessMap !== undefined ) {
  718. materialMetalnessMapEnabled.setValue( material.metalnessMap !== null );
  719. if ( material.metalnessMap !== null || resetTextureSelectors ) {
  720. materialMetalnessMap.setValue( material.metalnessMap );
  721. }
  722. }
  723. if ( material.specularMap !== undefined ) {
  724. materialSpecularMapEnabled.setValue( material.specularMap !== null );
  725. if ( material.specularMap !== null || resetTextureSelectors ) {
  726. materialSpecularMap.setValue( material.specularMap );
  727. }
  728. }
  729. if ( material.envMap !== undefined ) {
  730. materialEnvMapEnabled.setValue( material.envMap !== null );
  731. if ( material.envMap !== null || resetTextureSelectors ) {
  732. materialEnvMap.setValue( material.envMap );
  733. }
  734. }
  735. if ( material.gradientMap !== undefined ) {
  736. materialGradientMapEnabled.setValue( material.gradientMap !== null );
  737. if ( material.gradientMap !== null || resetTextureSelectors ) {
  738. materialGradientMap.setValue( material.gradientMap );
  739. }
  740. }
  741. if ( material.reflectivity !== undefined ) {
  742. materialReflectivity.setValue( material.reflectivity );
  743. }
  744. if ( material.lightMap !== undefined ) {
  745. materialLightMapEnabled.setValue( material.lightMap !== null );
  746. if ( material.lightMap !== null || resetTextureSelectors ) {
  747. materialLightMap.setValue( material.lightMap );
  748. }
  749. }
  750. if ( material.aoMap !== undefined ) {
  751. materialAOMapEnabled.setValue( material.aoMap !== null );
  752. if ( material.aoMap !== null || resetTextureSelectors ) {
  753. materialAOMap.setValue( material.aoMap );
  754. }
  755. materialAOScale.setValue( material.aoMapIntensity );
  756. }
  757. if ( material.emissiveMap !== undefined ) {
  758. materialEmissiveMapEnabled.setValue( material.emissiveMap !== null );
  759. if ( material.emissiveMap !== null || resetTextureSelectors ) {
  760. materialEmissiveMap.setValue( material.emissiveMap );
  761. }
  762. }
  763. if ( material.side !== undefined ) {
  764. materialSide.setValue( material.side );
  765. }
  766. if ( material.flatShading !== undefined ) {
  767. materialShading.setValue( material.flatShading );
  768. }
  769. if ( material.blending !== undefined ) {
  770. materialBlending.setValue( material.blending );
  771. }
  772. if ( material.opacity !== undefined ) {
  773. materialOpacity.setValue( material.opacity );
  774. }
  775. if ( material.transparent !== undefined ) {
  776. materialTransparent.setValue( material.transparent );
  777. }
  778. if ( material.alphaTest !== undefined ) {
  779. materialAlphaTest.setValue( material.alphaTest );
  780. }
  781. if ( material.wireframe !== undefined ) {
  782. materialWireframe.setValue( material.wireframe );
  783. }
  784. if ( material.wireframeLinewidth !== undefined ) {
  785. materialWireframeLinewidth.setValue( material.wireframeLinewidth );
  786. }
  787. setRowVisibility();
  788. }
  789. // events
  790. signals.objectSelected.add( function ( object ) {
  791. var hasMaterial = false;
  792. if ( object && object.material ) {
  793. hasMaterial = true;
  794. if ( Array.isArray( object.material ) && object.material.length === 0 ) {
  795. hasMaterial = false;
  796. }
  797. }
  798. if ( hasMaterial ) {
  799. var objectChanged = object !== currentObject;
  800. currentObject = object;
  801. refreshUI( objectChanged );
  802. container.setDisplay( '' );
  803. } else {
  804. currentObject = null;
  805. container.setDisplay( 'none' );
  806. }
  807. } );
  808. signals.materialChanged.add( function () {
  809. refreshUI();
  810. } );
  811. return container;
  812. };
粤ICP备19079148号