threejs-material-table.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. 'use strict';
  2. const materials = [
  3. {
  4. name: 'MeshBasicMaterial',
  5. shortName: 'Basic',
  6. properties: [
  7. 'alphaMap',
  8. 'aoMap',
  9. 'aoMapIntensity',
  10. 'color',
  11. 'combine',
  12. 'envMap',
  13. 'lightMap',
  14. 'lightMapIntensity',
  15. 'map',
  16. 'reflectivity',
  17. 'refractionRatio',
  18. 'specularMap',
  19. 'wireframe',
  20. ],
  21. },
  22. {
  23. name: 'MeshLambertMaterial',
  24. shortName: 'Lambert',
  25. properties: [
  26. 'alphaMap',
  27. 'aoMap',
  28. 'aoMapIntensity',
  29. 'color',
  30. 'combine',
  31. 'emissive',
  32. 'emissiveMap',
  33. 'emissiveIntensity',
  34. 'envMap',
  35. 'lightMap',
  36. 'lightMapIntensity',
  37. 'map',
  38. 'reflectivity',
  39. 'refractionRatio',
  40. 'specularMap',
  41. 'wireframe',
  42. ],
  43. },
  44. {
  45. name: 'MeshPhongMaterial',
  46. shortName: 'Phong',
  47. properties: [
  48. 'alphaMap',
  49. 'aoMap',
  50. 'aoMapIntensity',
  51. 'bumpMap',
  52. 'bumpScale',
  53. 'color',
  54. 'combine',
  55. 'displacementMap',
  56. 'displacementScale',
  57. 'displacementBias',
  58. 'emissive',
  59. 'emissiveMap',
  60. 'emissiveIntensity',
  61. 'envMap',
  62. 'lightMap',
  63. 'lightMapIntensity',
  64. 'map',
  65. 'normalMap',
  66. 'normalMapType',
  67. 'normalScale',
  68. 'reflectivity',
  69. 'refractionRatio',
  70. 'shininess',
  71. 'specular',
  72. 'specularMap',
  73. 'wireframe',
  74. ],
  75. },
  76. {
  77. name: 'MeshStandardMaterial',
  78. shortName: 'Standard',
  79. properties: [
  80. 'alphaMap',
  81. 'aoMap',
  82. 'aoMapIntensity',
  83. 'bumpMap',
  84. 'bumpScale',
  85. 'color',
  86. 'displacementMap',
  87. 'displacementScale',
  88. 'displacementBias',
  89. 'emissive',
  90. 'emissiveMap',
  91. 'emissiveIntensity',
  92. 'envMap',
  93. 'envMapIntensity',
  94. 'lightMap',
  95. 'lightMapIntensity',
  96. 'map',
  97. 'metalness',
  98. 'metalnessMap',
  99. 'normalMap',
  100. 'normalMapType',
  101. 'normalScale',
  102. 'refractionRatio',
  103. 'roughness',
  104. 'roughnessMap',
  105. 'wireframe',
  106. ],
  107. },
  108. {
  109. name: 'MeshPhysicalMaterial',
  110. shortName: 'Physical',
  111. properties: [
  112. 'alphaMap',
  113. 'aoMap',
  114. 'aoMapIntensity',
  115. 'bumpMap',
  116. 'bumpScale',
  117. 'color',
  118. 'displacementMap',
  119. 'displacementScale',
  120. 'displacementBias',
  121. 'emissive',
  122. 'emissiveMap',
  123. 'emissiveIntensity',
  124. 'envMap',
  125. 'envMapIntensity',
  126. 'lightMap',
  127. 'lightMapIntensity',
  128. 'map',
  129. 'metalness',
  130. 'metalnessMap',
  131. 'normalMap',
  132. 'normalMapType',
  133. 'normalScale',
  134. 'refractionRatio',
  135. 'roughness',
  136. 'roughnessMap',
  137. 'wireframe',
  138. 'clearcoat',
  139. 'clearcoatRoughness',
  140. 'reflectivity',
  141. ],
  142. },
  143. ];
  144. const allProperties = {};
  145. materials.forEach((material) => {
  146. material.properties.forEach((property) => {
  147. allProperties[property] = true;
  148. });
  149. });
  150. function addElem(type, parent, content) {
  151. const elem = document.createElement(type);
  152. if (content) {
  153. elem.textContent = content;
  154. }
  155. if (parent) {
  156. parent.appendChild(elem);
  157. }
  158. return elem;
  159. }
  160. const table = document.createElement('table');
  161. const thead = addElem('thead', table);
  162. {
  163. addElem('td', thead);
  164. materials.forEach((material) => {
  165. const td = addElem('td', thead);
  166. const a = addElem('a', td, material.shortName);
  167. a.href = `https://threejs.org/docs/#api/materials/${material.name}`;
  168. });
  169. }
  170. Object.keys(allProperties).sort().forEach((property) => {
  171. const tr = addElem('tr', table);
  172. addElem('td', tr, property);
  173. materials.forEach((material) => {
  174. const hasProperty = material.properties.indexOf(property) >= 0;
  175. const td = addElem('td', tr);
  176. const a = addElem('a', td, hasProperty ? '•' : '');
  177. a.href = `https://threejs.org/docs/#api/materials/${material.name}.${property}`;
  178. });
  179. });
  180. document.querySelector('#material-table').appendChild(table);