File: Uniform.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (215 lines) | stat: -rw-r--r-- 5,131 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!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>

		<p class="desc">Uniforms are global [link:https://www.opengl.org/documentation/glsl/ GLSL] variables. They are passed to shader programs.
		</p>

		<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 [page: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>
				</tr>
				<tr>
					<td>mat2</td>
					<td>[page:Array Array] (*)</td>
				</tr>
				<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]</td>
				</tr>

			</tbody>
		</table>

		<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]( [param:Object value] )</h3>
		<p>
		value -- An object containing the value to set up the uniform. It's type must be one of the Uniform Types described above.
		</p>

		<h2>Properties</h2>

		<h3>[property:Object value]</h3>
		<p>
		Current value of the uniform.
		</p>

		<h2>Methods</h2>

		<h3>[method:Uniform clone]()</h3>
		<p>
		Returns a clone of this uniform.<br />
		If the uniform's value property is an [page:Object] with a clone() method, this is used, otherwise the value is copied by assignment.
		Array values are shared between cloned [page:Uniform]s.<br /><br />
		See [example:webgldeferred_animation WebGL deferred animation] for an example of this method in use.
		</p>

		<h2>Source</h2>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
		</p>
	</body>
</html>