瀏覽代碼

Merge pull request #15908 from JohannesDeml/feature/fix-material-definition

Precise onBeforeCompile input shader param for Material in documentation and Material definition
Mr.doob 6 年之前
父節點
當前提交
86e76949cc
共有 3 個文件被更改,包括 11 次插入2 次删除
  1. 1 1
      docs/api/en/materials/Material.html
  2. 1 1
      docs/api/zh/materials/Material.html
  3. 9 0
      src/materials/Material.d.ts

+ 1 - 1
docs/api/en/materials/Material.html

@@ -295,7 +295,7 @@
 		These needs to be disposed by [page:Texture Texture].
 		</p>
 
-		<h3>[method:null onBeforeCompile]( [param:Object shader], [param:WebGLRenderer renderer] )</h3>
+		<h3>[method:null onBeforeCompile]( [param:Shader shader], [param:WebGLRenderer renderer] )</h3>
 		<p>
 		An optional callback that is executed immediately before the shader program is compiled.
 		This function is called with the shader source code as a parameter. Useful for the modification of built-in materials.

+ 1 - 1
docs/api/zh/materials/Material.html

@@ -243,7 +243,7 @@
 <p> 处理材质。材质的纹理不会被处理。需要通过[page:Texture Texture]处理。
 </p>
 
-<h3>[method:null onBeforeCompile]( [param:Object shader], [param:WebGLRenderer renderer] )</h3>
+<h3>[method:null onBeforeCompile]( [param:Shader shader], [param:WebGLRenderer renderer] )</h3>
 <p> 在编译shader程序之前立即执行的可选回调。此函数使用shader源码作为参数。用于修改内置材质。
 </p>
 

+ 9 - 0
src/materials/Material.d.ts

@@ -1,5 +1,7 @@
 import { Plane } from './../math/Plane';
+import { Shader } from './../renderers/shaders/ShaderLib'
 import { EventDispatcher } from './../core/EventDispatcher';
+import { WebGLRenderer } from './../renderers/WebGLRenderer';
 import {
   BlendingDstFactor,
   BlendingEquation,
@@ -266,6 +268,13 @@ export class Material extends EventDispatcher {
    */
   dispose(): void;
 
+  /**
+   * An optional callback that is executed immediately before the shader program is compiled. This function is called with the shader source code as a parameter. Useful for the modification of built-in materials. 
+   * @param shader Source code of the shader
+   * @param renderer WebGLRenderer Context that is initializing the material
+   */
+  onBeforeCompile ( shader : Shader, renderer : WebGLRenderer ) : void;
+
   /**
    * Sets the properties based on the values.
    * @param values A container with parameters.