Browse Source

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 years ago
parent
commit
86e76949cc

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

@@ -295,7 +295,7 @@
 		These needs to be disposed by [page:Texture Texture].
 		These needs to be disposed by [page:Texture Texture].
 		</p>
 		</p>
 
 
-		<h3>[method:null onBeforeCompile]( [param:Object shader], [param:WebGLRenderer renderer] )</h3>
+		<h3>[method:null onBeforeCompile]( [param:Shader shader], [param:WebGLRenderer renderer] )</h3>
 		<p>
 		<p>
 		An optional callback that is executed immediately before the shader program is compiled.
 		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.
 		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> 处理材质。材质的纹理不会被处理。需要通过[page:Texture Texture]处理。
 </p>
 </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> 在编译shader程序之前立即执行的可选回调。此函数使用shader源码作为参数。用于修改内置材质。
 </p>
 </p>
 
 

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

@@ -1,5 +1,7 @@
 import { Plane } from './../math/Plane';
 import { Plane } from './../math/Plane';
+import { Shader } from './../renderers/shaders/ShaderLib'
 import { EventDispatcher } from './../core/EventDispatcher';
 import { EventDispatcher } from './../core/EventDispatcher';
+import { WebGLRenderer } from './../renderers/WebGLRenderer';
 import {
 import {
   BlendingDstFactor,
   BlendingDstFactor,
   BlendingEquation,
   BlendingEquation,
@@ -266,6 +268,13 @@ export class Material extends EventDispatcher {
    */
    */
   dispose(): void;
   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.
    * Sets the properties based on the values.
    * @param values A container with parameters.
    * @param values A container with parameters.