Material.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <base href="../../../"/>
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css"/>
  9. </head>
  10. <body>
  11. <h1>材质([name])</h1>
  12. <p class="desc">材质的抽象基类。<br/><br/>
  13. 材质描述了对象[page:Object objects]的外观。它们的定义方式与渲染器无关,
  14. 因此,如果您决定使用不同的渲染器,不必重写材质。<br/><br/>
  15. 所有其他材质类型都继承了以下属性和方法(尽管它们可能具有不同的默认值)。
  16. </p>
  17. <h2>构造函数(Constructor)</h2>
  18. <h3>[name]()</h3>
  19. <p>该方法创建一个通用材质。</p>
  20. <h2>属性(Properties)</h2>
  21. <h3>[property:Float alphaTest]</h3>
  22. <p>设置运行alphaTest时要使用的alpha值。如果不透明度低于此值,则不会渲染材质。默认值为*0*。
  23. </p>
  24. <h3>[property:Integer blendDst]</h3>
  25. <p> 混合目标。默认值为[page:CustomBlendingEquation OneMinusSrcAlphaFactor]。
  26. 目标因子所有可能的取值请参阅[page:CustomBlendingEquation constants]。
  27. 必须将材质的[page:Constant blending]设置为[page:Materials CustomBlending]才能生效。<br/>
  28. </p>
  29. <h3>[property:Integer blendDstAlpha]</h3>
  30. <p> [page:.blendDst]的透明度。 默认值为 *null*.</p>
  31. <h3>[property:Integer blendEquation]</h3>
  32. <p> 使用混合时所采用的混合方程式。默认值为[page:CustomBlendingEquation AddEquation]。
  33. 混合方程式所有可能的取值请参阅[page:CustomBlendingEquation constants]。
  34. 必须将材质的[page:Constant blending]设置为[page:Materials CustomBlending]才能生效。<br/>
  35. </p>
  36. <h3>[property:Integer blendEquationAlpha]</h3>
  37. <p>[page:.blendEquation] 的透明度. 默认值为 *null*.</p>
  38. <h3>[property:Blending blending]</h3>
  39. <p> 在使用此材质显示对象时要使用何种混合。<br/>
  40. 必须将其设置为[page:Materials CustomBlending]才能使用自定义[page:Constant blendSrc], [page:Constant blendDst] 或者 [page:Constant
  41. blendEquation]。
  42. 混合模式所有可能的取值请参阅[page:Materials constants]。默认值为[page:Materials NormalBlending]。
  43. </p>
  44. <h3>[property:Integer blendSrc]</h3>
  45. <p> 混合源。默认值为[page:CustomBlendingEquation SrcAlphaFactor]。
  46. 源因子所有可能的取值请参阅[page:CustomBlendingEquation constants]。<br/>
  47. 必须将材质的[page:Constant blending]设置为[page:Materials CustomBlending]才能生效。
  48. </p>
  49. <h3>[property:Integer blendSrcAlpha]</h3>
  50. <p> [page:.blendSrc]的透明度。 默认值为 *null*.</p>
  51. <h3>[property:Boolean clipIntersection]</h3>
  52. <p>更改剪裁平面的行为,以便仅剪切其交叉点,而不是它们的并集。默认值为 *false*。
  53. </p>
  54. <h3>[property:Array clippingPlanes]</h3>
  55. <p>
  56. 用户定义的剪裁平面,在世界空间中指定为THREE.Plane对象。这些平面适用于所有使用此材质的对象。空间中与平面的有符号距离为负的点被剪裁(未渲染)。
  57. 这需要[page:WebGLRenderer.localClippingEnabled]为*true*。
  58. 示例请参阅[example:webgl_clipping_intersection WebGL / clipping /intersection]。默认值为 *null*。
  59. </p>
  60. <h3>[property:Boolean clipShadows]</h3>
  61. <p>定义是否根据此材质上指定的剪裁平面剪切阴影。默认值为 *false*。
  62. </p>
  63. <h3>[property:Boolean colorWrite]</h3>
  64. <p> 是否渲染材质的颜色。
  65. 这可以与网格的[page:Integer renderOrder]属性结合使用,以创建遮挡其他对象的不可见对象。默认值为*true*。
  66. </p>
  67. <h3>[property:Object defines]</h3>
  68. <p> 注入shader的自定义对象。 以键值对形式的对象传递,{ MY_CUSTOM_DEFINE: '' , PI2: Math.PI * 2 }。
  69. 这些键值对在顶点和片元着色器中定义。默认值为*undefined*。
  70. </p>
  71. <h3>[property:Integer depthFunc]</h3>
  72. <p> 使用何种深度函数。默认为[page:Materials LessEqualDepth]。
  73. 深度模式所有可能的取值请查阅[page:Materials constants]。
  74. </p>
  75. <h3>[property:Boolean depthTest]</h3>
  76. <p>是否在渲染此材质时启用深度测试。默认为 *true*。
  77. </p>
  78. <h3>[property:Boolean depthWrite]</h3>
  79. <p>渲染此材质是否对深度缓冲区有任何影响。默认为*true*。<br/><br/>
  80. 在绘制2D叠加时,将多个事物分层在一起而不创建z-index时,禁用深度写入会很有用。
  81. </p>
  82. <h3>[property:Boolean stencilWrite]</h3>
  83. <p>
  84. Whether rendering this material has any effect on the stencil buffer. Default is *false*.
  85. </p>
  86. <h3>[property:Integer stencilWriteMask]</h3>
  87. <p>
  88. The bit mask to use when writing to the stencil buffer. Default is *0xFF*.
  89. </p>
  90. <h3>[property:Integer stencilFunc]</h3>
  91. <p>
  92. The stencil comparison function to use. Default is [page:Materials AlwaysStencilFunc]. See stencil function [page:Materials constants] for all possible values.
  93. </p>
  94. <h3>[property:Integer stencilRef]</h3>
  95. <p>
  96. The value to use when performing stencil comparisons or stencil operations. Default is *0*.
  97. </p>
  98. <h3>[property:Integer stencilFuncMask]</h3>
  99. <p>
  100. The bit mask to use when comparing against the stencil buffer. Default is *0xFF*.
  101. </p>
  102. <h3>[property:Integer stencilFail]</h3>
  103. <p>
  104. Which stencil operation to perform when the comparison function returns false. Default is [page:Materials KeepStencilOp]. See the stencil operations [page:Materials constants] for all possible values.
  105. </p>
  106. <h3>[property:Integer stencilZFail]</h3>
  107. <p>
  108. Which stencil operation to perform when the comparison function returns true but the depth test fails. Default is [page:Materials KeepStencilOp]. See the stencil operations [page:Materials constants] for all possible values.
  109. </p>
  110. <h3>[property:Integer stencilZPass]</h3>
  111. <p>
  112. Which stencil operation to perform when the comparison function returns true and the depth test passes. Default is [page:Materials KeepStencilOp]. See the stencil operations [page:Materials constants] for all possible values.
  113. </p>
  114. <h3>[property:Boolean flatShading]</h3>
  115. <p> 定义材质是否使用平面着色进行渲染。默认值为false。
  116. </p>
  117. <h3>[property:Boolean fog]</h3>
  118. <p>材质是否受雾影响。默认为*true*。</p>
  119. <h3>[property:Integer id]</h3>
  120. <p>此材质实例的唯一编号。</p>
  121. <h3>[property:String name]</h3>
  122. <p>对象的可选名称(不必是唯一的)。默认值为空字符串。</p>
  123. <h3>[property:Boolean needsUpdate]</h3>
  124. <p>指定需要重新编译材质。
  125. </p>
  126. <h3>[property:Float opacity]</h3>
  127. <p> 在0.0 - 1.0的范围内的浮点数,表明材质的透明度。值*0.0*表示完全透明,*1.0*表示完全不透明。<br/>
  128. 如果材质的[page:Boolean transparent]属性未设置为*true*,则材质将保持完全不透明,此值仅影响其颜色。
  129. 默认值为*1.0*。 <br/>
  130. </p>
  131. <h3>[property:Boolean polygonOffset]</h3>
  132. <p> 是否使用多边形偏移。默认值为*false*。这对应于WebGL的*GL_POLYGON_OFFSET_FILL*功能。
  133. </p>
  134. <h3>[property:Integer polygonOffsetFactor]</h3>
  135. <p>设置多边形偏移系数。默认值为*0*。</p>
  136. <h3>[property:Integer polygonOffsetUnits]</h3>
  137. <p>设置多边形偏移单位。默认值为*0*。</p>
  138. <h3>[property:String precision]</h3>
  139. <p> 重写此材质渲染器的默认精度。可以是"*highp*", "*mediump*" 或 "*lowp*"。默认值为*null*。
  140. </p>
  141. <h3>[property:Boolean premultipliedAlpha]</h3>
  142. <p> 是否预乘alpha(透明度)值。有关差异的示例,请参阅[Example:webgl_materials_transparency WebGL / Materials / Transparency]。
  143. 默认值为*false*。
  144. </p>
  145. <h3>[property:Boolean dithering]</h3>
  146. <p> 是否对颜色应用抖动以消除条带的外观。默认值为 *false*。
  147. </p>
  148. <h3>[property:Integer shadowSide]</h3>
  149. <p> 定义投影的面。设置时,可以是[page:Materials THREE.FrontSide], [page:Materials THREE.BackSide], 或[page:Materials]。默认值为 *null*。
  150. <br/>
  151. 如果为*null*, 则面投射阴影确定如下: <br/>
  152. <table>
  153. <thead>
  154. <tr>
  155. <th>[page:Material.side]</th>
  156. <th>Side casting shadows</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <tr>
  161. <td>THREE.FrontSide</td>
  162. <td>背面</td>
  163. </tr>
  164. <tr>
  165. <td>THREE.BackSide</td>
  166. <td>前面</td>
  167. </tr>
  168. <tr>
  169. <td>THREE.DoubleSide</td>
  170. <td>双面</td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. </p>
  175. <h3>[property:Integer side]</h3>
  176. <p> 定义将要渲染哪一面 - 正面,背面或两者。
  177. 默认为[page:Materials THREE.FrontSide]。其他选项有[page:Materials THREE.BackSide]和[page:Materials THREE.DoubleSide]。
  178. </p>
  179. <h3>[property:Boolean toneMapped]</h3>
  180. <p>
  181. Defines whether this material is tone mapped according to the renderer's [page:WebGLRenderer.toneMapping toneMapping] setting. Default is *true*.
  182. </p>
  183. <h3>[property:Boolean transparent]</h3>
  184. <p>
  185. 定义此材质是否透明。这对渲染有影响,因为透明对象需要特殊处理,并在非透明对象之后渲染。
  186. <br/>
  187. 设置为true时,通过设置材质的[page:Float opacity]属性来控制材质透明的程度。<br/>
  188. 默认值为*false*。
  189. </p>
  190. <h3>[property:String type]</h3>
  191. <p> 值是字符串'Material'。不应该被更改,并且可以用于在场景中查找此类型的所有对象。
  192. </p>
  193. <h3>[property:String uuid]</h3>
  194. <p> 此材质实例的[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID],会自动分配,不应该被更改。
  195. </p>
  196. <h3>[property:Integer version]</h3>
  197. <p>
  198. This starts at *0* and counts how many times [property:Boolean needsUpdate] is set to *true*.
  199. </p>
  200. <h3>[property:Boolean vertexColors]</h3>
  201. <p>
  202. Defines whether vertex coloring is used. Default is *false*.
  203. </p>
  204. <h3>[property:Boolean visible]</h3>
  205. <p> 此材质是否可见。默认为*true*。
  206. </p>
  207. <h3>[property:object userData]</h3>
  208. <p> 一个对象,可用于存储有关Material的自定义数据。它不应该包含对函数的引用,因为这些函数不会被克隆。
  209. </p>
  210. <h2>方法(Methods)</h2>
  211. <h3>[page:EventDispatcher EventDispatcher] 方法在此类中可用。</h3>
  212. <h3>[method:Material clone]( )</h3>
  213. <p> 返回与此材质具有相同参数的新材质。</p>
  214. <h3>[method:Material copy]( [param:material material] )</h3>
  215. <p> 将被传入材质中的参数复制到此材质中。</p>
  216. <h3>[method:null dispose]()</h3>
  217. <p> 处理材质。材质的纹理不会被处理。需要通过[page:Texture Texture]处理。
  218. </p>
  219. <h3>[method:null onBeforeCompile]( [param:Shader shader], [param:WebGLRenderer renderer] )</h3>
  220. <p> 在编译shader程序之前立即执行的可选回调。此函数使用shader源码作为参数。用于修改内置材质。
  221. </p>
  222. <p>
  223. Unlike properties, the callback is not supported by [page:Material.clone .clone](), [page:Material.copy .copy]() and [page:Material.toJSON .toJSON]().
  224. </p>
  225. <h3>[method:null setValues]( [param:object values] )</h3>
  226. <p> values -- 具有参数的容器。
  227. 根据*values*设置属性。<br/>
  228. </p>
  229. <h3>[method:Object toJSON]( [param:object meta] )</h3>
  230. <p>
  231. meta -- 包含有元数据的对象,例如该对象的纹理或图片。
  232. 将material对象转换为 three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format](three.js JSON 物体/场景格式)。
  233. </p>
  234. <h2>源码(Source)</h2>
  235. <p>
  236. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  237. </p>
  238. </body>
  239. </html>