提交 8af4653a 编写于 作者: L Ludovic Bailly 提交者: Mr.doob

Created Uniform documentation (#9632)

* Created Uniform documentation and removed Uniform types from ShaderMaterial

* Fixed spaces to tabs
上级 10adc957
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<div class="desc">Uniforms are global [link:https://www.opengl.org/documentation/glsl/ GLSL] variables. They are passed to shader programs.
</div>
<h3>Example</h3>
<p>
When declaring a uniform of a [page:ShaderMaterial], it is declared by value or by object.
</p>
<code>
uniforms: {
time: { value: 1.0 },
resolution: new THREE.Uniform(new THREE.Vector2())
}
</code>
<h3>Uniform types</h3>
<p>
Each uniform must have a *value* property. The type of the value must correspond to the type of the uniform variable in the GLSL code as specified for the primitive GLSL types in the table below. Uniform structures and arrays are also supported. GLSL arrays of primitive type must either be specified as an array of the corresponding THREE objects or as a flat array containing the data of all the objects. In other words; GLSL primitives in arrays must not be represented by arrays. This rule does not apply transitively. An array of *vec2* arrays, each with a length of five vectors, must be an array of arrays, of either five *THREE.Vector2* objects or ten *number*s.
</p>
<table>
<caption><a id="uniform-types">Uniform types</a></caption>
<thead>
<tr>
<th>GLSL type</th>
<th>JavaScript type</th>
</tr>
</thead>
<tbody>
<tr>
<td>int</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>float</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>bool</td>
<td>[page:Boolean]</td>
</tr>
<tr>
<td>bool</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Vector2 THREE.Vector2]</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Vector3 THREE.Vector3]</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Color THREE.Color]</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Vector4 THREE.Vector4]</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Quaternion THREE.Quaternion]</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>mat2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</td>
<tr>
<td>mat2</td>
<td>[page:Array Array] (*)</td>
</td>
<tr>
<td>mat3</td>
<td>[page:Matrix3 THREE.Matrix3]</td>
</tr>
<tr>
<td>mat3</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>mat3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Matrix3 THREE.Matrix4]</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec2, bvec2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>ivec2, bvec2</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec3, bvec3</td>
<td>[page:Int32Array Int32Array] (*)</td>
</tr>
<tr>
<td>ivec3, bvec3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec4, bvec4</td>
<td>[page:Int32Array Int32Array] (*)</td>
</tr>
<tr>
<td>ivec4, bvec4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>sampler2D</td>
<td>[page:Texture THREE.Texture]</td>
</tr>
<tr>
<td>samplerCube</td>
<td>[page:CubeTexture THREE.CubeTexture]</tr>
</tr>
</tbody>
</table>
</p>
<p>
(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.
</p>
<h2>Constructor</h2>
<h3>[name]( [page:Object value] )</h3>
<div>
value -- An object containing the value to set up the uniform. It's type must be one of the Uniform Types described above.
</div>
<h2>Properties</h2>
<h3>[property:Object value]</h3>
<div>
Current value of the uniform.
</div>
<h3>[property:Boolean dynamic]</h3>
<div>
Sets wether this uniform is updated at each render call when used by a renderer.
You must set this attribute by calling [page:.onUpdate].
</div>
<h2>Methods</h2>
<h3>[method:Uniform onUpdate]( [page:Function callback] ) [page:Uniform this]</h3>
<div>
Set the callback function to update this uniform at each render call. The callback has two optional parameters :
<ul>
<li>[page:Object object] : The current object associated to the [page:Material] using this [page:Uniform]</li>
<li>[page:Camera camera] : The current camera used by the current [page:WebGLRenderer]</li>
</ul>
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -120,158 +120,13 @@
</p>
<p>
To declare a custom uniform, use the *uniforms* property:
To declare a custom [page:Uniform], use the *uniforms* property:
<code>
uniforms: {
time: { value: 1.0 },
resolution: { value: new THREE.Vector2() }
}
</code>
Each uniform must have a *value* property. The type of the value must correspond to the type of the uniform variable in the GLSL code as specified for the primitive GLSL types in the table below. Uniform structures and arrays are also supported. GLSL arrays of primitive type must either be specified as an array of the corresponding THREE objects or as a flat array containing the data of all the objects. In other words; GLSL primitives in arrays must not be represented by arrays. This rule does not apply transitively. An array of *vec2* arrays, each with a length of five vectors, must be an array of arrays, of either five *THREE.Vector2* objects or ten *number*s.
<table>
<caption><a id="uniform-types">Uniform types</a></caption>
<thead>
<tr>
<th>GLSL type</th>
<th>JavaScript type</th>
</tr>
</thead>
<tbody>
<tr>
<td>int</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>float</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>bool</td>
<td>[page:Boolean]</td>
</tr>
<tr>
<td>bool</td>
<td>[page:Number]</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Vector2 THREE.Vector2]</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec2</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Vector3 THREE.Vector3]</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Color THREE.Color]</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Vector4 THREE.Vector4]</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Quaternion THREE.Quaternion]</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>vec4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>mat2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</td>
<tr>
<td>mat2</td>
<td>[page:Array Array] (*)</td>
</td>
<tr>
<td>mat3</td>
<td>[page:Matrix3 THREE.Matrix3]</td>
</tr>
<tr>
<td>mat3</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>mat3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Matrix3 THREE.Matrix4]</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>mat4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec2, bvec2</td>
<td>[page:Float32Array Float32Array] (*)</td>
</tr>
<tr>
<td>ivec2, bvec2</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec3, bvec3</td>
<td>[page:Int32Array Int32Array] (*)</td>
</tr>
<tr>
<td>ivec3, bvec3</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>ivec4, bvec4</td>
<td>[page:Int32Array Int32Array] (*)</td>
</tr>
<tr>
<td>ivec4, bvec4</td>
<td>[page:Array Array] (*)</td>
</tr>
<tr>
<td>sampler2D</td>
<td>[page:Texture THREE.Texture]</td>
</tr>
<tr>
<td>samplerCube</td>
<td>[page:CubeTexture THREE.CubeTexture]</tr>
</tr>
</tbody>
</table>
</p>
<p>
(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.
</p>
<h2>Constructor</h2>
......
......@@ -31,7 +31,8 @@ var list = {
[ "Face3", "api/core/Face3" ],
[ "Geometry", "api/core/Geometry" ],
[ "Object3D", "api/core/Object3D" ],
[ "Raycaster", "api/core/Raycaster" ]
[ "Raycaster", "api/core/Raycaster" ],
[ "Uniform", "api/core/Uniform"]
],
"Lights": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册