WebGLRenderer.html 23.1 KB
Newer Older
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
D
dubejf 已提交
4
		<meta charset="utf-8" />
M
Mr.doob 已提交
5
		<base href="../../../" />
M
Mr.doob 已提交
6 7 8
		<script src="list.js"></script>
		<script src="page.js"></script>
		<link type="text/css" rel="stylesheet" href="page.css" />
9 10 11
	</head>
	<body>
		<h1>[name]</h1>
M
Mr.doob 已提交
12

13
		<p class="desc">
L
Lewy Blue 已提交
14 15
			The WebGL renderer displays your beautifully crafted scenes using
			[link:https://en.wikipedia.org/wiki/WebGL WebGL].
16
		</p>
M
Mr.doob 已提交
17

18
		<h2>Constructor</h2>
M
Mr.doob 已提交
19

20
		<h3>[name]( [param:Object parameters] )</h3>
21
		<p>
L
Lewy Blue 已提交
22
		[page:Object parameters] - (optional) object with properties defining the renderer's behaviour.
23
			The constructor also accepts no parameters at all. In all cases, it will assume sane defaults
L
Lewy Blue 已提交
24 25 26 27 28 29
			when parameters are missing. The following are valid parameters:<br /><br />

		[page:DOMElement canvas] - A [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas]
		where the renderer draws its output.
		This corresponds to the [page:WebGLRenderer.domElement domElement] property below.
		If not passed in here, a new canvas element will be created.<br />
S
sole 已提交
30

31

L
Lewy Blue 已提交
32 33 34
		[page:WebGLRenderingContext context] - This can be used to attach the renderer to an existing
	  [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext].
		Default is null.<br />
35

L
Lewy Blue 已提交
36 37 38
		[page:String precision] - Shader precision. Can be *"highp"*, *"mediump"* or *"lowp"*.
		Defaults to *"highp"* if supported by the device. See the note in "Things to Avoid"
		[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices here].<br />
M
Mr.doob 已提交
39

L
Lewy Blue 已提交
40 41
		[page:Boolean alpha] - whether the canvas contains an alpha (transparency) buffer or not.
	  Default is *false*.<br />
M
Mr.doob 已提交
42

L
Lewy Blue 已提交
43 44 45
		[page:Boolean premultipliedAlpha] - whether the renderer will assume that colors have
		[link:https://en.wikipedia.org/wiki/Glossary_of_computer_graphics#Premultiplied_alpha premultiplied alpha].
		Default is *true*.<br />
S
sole 已提交
46

L
Lewy Blue 已提交
47
		[page:Boolean antialias] - whether to perform antialiasing. Default is *false*.<br />
S
sole 已提交
48

L
Lewy Blue 已提交
49 50 51
		[page:Boolean stencil] - whether the drawing buffer has a
		[link:https://en.wikipedia.org/wiki/Stencil_buffer stencil buffer] of at least 8 bits.
		Default is *true*.<br />
S
sole 已提交
52

L
Lewy Blue 已提交
53
		[page:Boolean preserveDrawingBuffer] - whether to preserve the buffers until manually cleared
54
		or overwritten. Default is *false*.<br />
55

56
		[page:String powerPreference] - Provides a hint to the user agent indicating what configuration
57 58
		of GPU is suitable for this WebGL context. Can be *"high-performance"*, *"low-power"* or *"default"*. Default is *"default"*.
		See the [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2 WebGL spec] for more information.<br />
S
sole 已提交
59

L
Lewy Blue 已提交
60 61 62
		[page:Boolean depth] - whether the drawing buffer has a
		[link:https://en.wikipedia.org/wiki/Z-buffering depth buffer] of at least 16 bits.
		Default is *true*.<br />
63

L
Lewy Blue 已提交
64 65 66
		[page:Boolean logarithmicDepthBuffer] -  whether to use a logarithmic depth buffer. It may
		be neccesary to use this if dealing with huge differences in scale in a single scene.
		Default is *false*. See the [example:webgl_camera_logarithmicdepthbuffer camera / logarithmicdepthbuffer] example.
67
		</p>
68 69

		<h2>Properties</h2>
S
sole 已提交
70

71
		<h3>[property:Boolean autoClear]</h3>
72
		<p>Defines whether the renderer should automatically clear its output before rendering a frame.</p>
S
sole 已提交
73 74


75
		<h3>[property:Boolean autoClearColor]</h3>
76
		<p>
L
Lewy Blue 已提交
77 78
			If [page:.autoClear autoClear] is true, defines whether the renderer should clear the color buffer.
			Default is *true*.
79
		</p>
S
sole 已提交
80 81


82
		<h3>[property:Boolean autoClearDepth]</h3>
83
		<p>
L
Lewy Blue 已提交
84 85
			If [page:.autoClear autoClear] is true, defines whether the renderer should clear the depth buffer.
			Default is *true*.
86
		</p>
S
sole 已提交
87 88


89
		<h3>[property:Boolean autoClearStencil]</h3>
90
		<p>
L
Lewy Blue 已提交
91 92
			If [page:.autoClear autoClear] is true, defines whether the renderer should clear the stencil buffer.
			Default is *true*.
93
		</p>
S
sole 已提交
94

95
		<h3>[property:Object capabilities]</h3>
96
		<p>
97
		An object containing details about the capabilities of the current [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext].<br />
98

99
		- [page:Boolean floatFragmentTextures]: whether the context supports the [link:https://developer.mozilla.org/en-US/docs/Web/API/OES_texture_float OES_texture_float] extension.
100
			According to [link:https://webglstats.com/ WebGLStats], as of February 2016 over 95% of WebGL enabled devices support this.<br />
101 102 103 104
		- [page:Boolean floatVertexTextures]: *true* if [page:Boolean floatFragmentTextures] and [page:Boolean vertexTextures] are both true.<br />
		- [page:Method getMaxAnisotropy](): Returns the maximum available anisotropy.<br />
		- [page:Method getMaxPrecision](): Returns the maximum available precision for vertex and fragment shaders. <br />
		- [page:Boolean logarithmicDepthBuffer]: *true* if the [page:parameter logarithmicDepthBuffer] was set to true in the constructor and
105 106
		the context supports the [link:https://developer.mozilla.org/en-US/docs/Web/API/EXT_frag_depth EXT_frag_depth] extension.
			According to [link:https://webglstats.com/ WebGLStats], as of February 2016 around 66% of WebGL enabled devices support this.<br />
107 108
		- [page:Integer maxAttributes]: The value of *gl.MAX_VERTEX_ATTRIBS*.<br />
		- [page:Integer maxCubemapSize]: The value of *gl.MAX_CUBE_MAP_TEXTURE_SIZE*.
109
		Maximum height * width of cube map textures that a shader can use.<br />
110
		- [page:Integer maxFragmentUniforms]: The value of *gl.MAX_FRAGMENT_UNIFORM_VECTORS*.
111
		  The number of uniforms that can be used by a fragment shader.<br />
112
		- [page:Integer maxTextureSize]: The value of *gl.MAX_TEXTURE_SIZE*.
113
		Maximum height * width of a texture that a shader use.<br />
114
		- [page:Integer maxTextures]: The value of *gl.MAX_TEXTURE_IMAGE_UNITS*.
115
		  The maximum number of textures that can be used by a shader.<br />
116
		- [page:Integer maxVaryings]: The value of *gl.MAX_VARYING_VECTORS*.
117
		  The number of varying vectors that can used by shaders.<br />
118
		- [page:Integer maxVertexTextures]: The value of *gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS*.
119
		   The number of textures that can be used in a vertex shader.<br />
120
		- [page:Integer maxVertexUniforms]: The value of *gl.MAX_VERTEX_UNIFORM_VECTORS*.
121
		   The maximum number of uniforms that can be used in a vertex shader.<br />
122 123
		- [page:String precision]: The shader precision currently being used by the renderer.<br />
		- [page:Boolean vertexTextures]: *true* if [property:Integer maxVertexTextures] is greater than 0 (i.e. vertext textures can be used).<br />
124
		</p>
S
sole 已提交
125

126
		<h3>[property:Array clippingPlanes]</h3>
127
		<p>
128 129 130
		User-defined clipping planes specified as THREE.Plane objects in world space.
			These planes apply globally. Points in space whose dot product with the plane is negative are cut away.
		 Default is [].
131
		</p>
S
sole 已提交
132

133
		<h3>[property:WebGLRenderingContext context]</h3>
134
		<p>
135
		The renderer obtains a [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext] context
M
Magnuz Binder 已提交
136
		  from its [page:WebGLRenderer.domElement domElement] by default, using
J
John Barounis 已提交
137
			[link:https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext HTMLCanvasElement.getContext]().<br /><br />
S
sole 已提交
138

139 140
		You can create this manually, however it must correspond to the
		[page:WebGLRenderer.domElement domElement] in order to render to the screen.
141
		</p>
S
sole 已提交
142

143
		<h3>[property:DOMElement domElement]</h3>
144
		<p>
145 146 147 148 149 150
		A [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas] where the renderer draws its output.<br />
			This is automatically created by the renderer in the constructor (if not provided already);
			you just need to add it to your page like so:<br />
		<code>
			document.body.appendChild( renderer.domElement );
		</code>
151
	  </p>
152 153

		<h3>[property:Object extensions]</h3>
154
		<p>
155 156
		A wrapper for the [page:WebGLRenderer.extensions.get .extensions.get] method, used to check whether
		various WebGL extensions are supported.
157
		</p>
S
sole 已提交
158

W
WestLangley 已提交
159
		<h3>[property:Float gammaFactor]</h3>
160
		<p>Default is *2*. </p>
T
tschw 已提交
161 162


163
		<h3>[property:Boolean gammaInput]</h3>
164
		<p>If set, then it expects that all textures and colors are premultiplied gamma. Default is *false*.</p>
T
tschw 已提交
165 166


167
		<h3>[property:Boolean gammaOutput]</h3>
168
		<p>If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is *false*.</p>
T
tschw 已提交
169

170
		<h3>[property:Object info]</h3>
171 172
		<p>An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields:</p>
		<p>
173 174 175 176 177 178 179 180 181 182
		<ul>
			<li>memory:
				<ul>
					<li>geometries</li>
					<li>textures</li>
				</ul>
			</li>
			<li>render:
				<ul>
					<li>calls</li>
M
Mugen87 已提交
183
					<li>triangles</li>
184
					<li>points</li>
M
Mugen87 已提交
185
					<li>lines</li>
186 187 188 189 190
				</ul>
			</li>
			<li>programs
			</li>
		</ul>
191 192
		</p>
		<p>By default these data are reset at each render calls, but when using the composer or mirrors it can be preferred to reset them with a custom pattern :
A
Atrahasis 已提交
193 194 195 196
		<code>
		renderer.info.autoReset = false;
		renderer.info.reset();
		</code>
197
		</p>
T
tschw 已提交
198

199
		<h3>[property:Boolean localClippingEnabled]</h3>
200
		<p>Defines whether the renderer respects object-level clipping planes. Default is *false*.</p>
S
sole 已提交
201

202
		<h3>[property:Integer maxMorphTargets]</h3>
203
		<p>
204 205
		Default is 8. The maximum number of MorphTargets allowed in a shader.
			Keep in mind that the standard materials only allow 8 MorphTargets.
206
		</p>
S
sole 已提交
207

208
		<h3>[property:Integer maxMorphNormals]</h3>
209
		<p>
210 211
		Default is 4. The maximum number of MorphNormals allowed in a shader.
			Keep in mind that the standard materials only allow 4 MorphNormals.
212
		</p>
S
sole 已提交
213

214
		<h3>[property:Boolean physicallyCorrectLights]</h3>
215
		<p>
216 217
		Whether to use physically correct lighting mode. Default is *false*.
		See the [example:webgl_lights_physical lights / physical] example.
218
		</p>
S
sole 已提交
219

220
		<h3>[property:Object properties]</h3>
221
		<p>
222
		Used internally by the renderer to keep track of various sub object properties.
223
		</p>
S
sole 已提交
224

A
aardgoose 已提交
225
		<h3>[property:WebGLRenderLists renderLists]</h3>
226
		<p>
A
aardgoose 已提交
227
		Used internally to handle ordering of scene object rendering.
228
		</p>
A
aardgoose 已提交
229

230
		<h3>[property:WebGLShadowMap shadowMap]</h3>
231
		<p>
232
		This contains the reference to the shadow map, if used.
233
		</p>
S
sole 已提交
234

235
		<h3>[property:Boolean shadowMap.enabled]</h3>
236
		<p>If set, use shadow maps in the scene. Default is *false*.</p>
S
sole 已提交
237

238
		<h3>[property:Boolean shadowMap.autoUpdate]</h3>
239 240
		<p>Enables automatic updates to the shadows in the scene. Default is *true*.</p>
		<p>If you do not require dynamic lighting / shadows, you may set this to *false* when the renderer is instantiated.</p>
241 242

		<h3>[property:Boolean shadowMap.needsUpdate]</h3>
243 244
		<p>When set to *true*, shadow maps in the scene will be updated in the next *render* call. Default is *false*. </p>
		<p>If you have disabled automatic updates to shadow maps (*shadowMap.autoUpdate = false*), you will need to set this to *true* and then make a render call to update the shadows in your scene.</p>
245

246
		<h3>[property:Integer shadowMap.type]</h3>
247 248
		<p>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</p>
		<p>Options are THREE.BasicShadowMap, THREE.PCFShadowMap (default), THREE.PCFSoftShadowMap. See [page:Renderer Renderer constants] for details.</p>
S
sole 已提交
249

250
		<h3>[property:Boolean sortObjects]</h3>
251
		<p>
252
		Defines whether the renderer should sort objects. Default is *true*.<br /><br />
S
sole 已提交
253

254 255
		Note: Sorting is used to attempt to properly render objects that have some degree of transparency.
		By definition, sorting objects may not work in all cases.  Depending on the needs of application,
256
		it may be necessary to turn off sorting and use other methods to deal with transparency
257
		rendering e.g. manually determining each object's rendering order.
258
		</p>
S
sole 已提交
259

260
		<h3>[property:Object state]</h3>
261
		<p>
262
		Contains functions for setting various properties of the [page:WebGLRenderer.context] state.
263
		</p>
S
sole 已提交
264

265
		<h3>[property:Constant toneMapping]</h3>
266
		<p>
267
		Default is [page:Renderer LinearToneMapping]. See the [page:Renderer Renderer constants] for other choices.
268
		</p>
S
sole 已提交
269

270
		<h3>[property:Number toneMappingExposure]</h3>
271
		<p>
272
		Exposure level of tone mapping. Default is *1*.
273
		</p>
S
sole 已提交
274

275
		<h3>[property:Number toneMappingWhitePoint]</h3>
276
		<p>
277
		Tone mapping white point. Default is *1*.
278
		</p>
M
Mr.doob 已提交
279

280
		<h2>Methods</h2>
M
Mr.doob 已提交
281

282
		<h3>[method:Integer allocTextureUnit]</h3>
283
		<p>
284 285 286
		Attempt to allocate a texture unit for use by a shader. Will warn if trying to allocate
		more texture units than the GPU supports. This is mainly used internally.
		See [page:WebGLRenderer.capabilities capabilities.maxTextures].
287
		</p>
288

289
		<h3>[method:null clear]( [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )</h3>
290
		<p>
291 292 293
		Tells the renderer to clear its color, depth or stencil drawing buffer(s).
			This method initializes the color buffer to the current clear color value.<br />
		Arguments default to *true*.
294
		</p>
M
Mr.doob 已提交
295

296
		<h3>[method:null clearColor]( )</h3>
297
		<p>Clear the color buffer. Equivalent to calling [page:WebGLRenderer.clear .clear]( true, false, false ).</p>
298 299

		<h3>[method:null clearDepth]( )</h3>
300
		<p>Clear the depth buffer. Equivalent to calling [page:WebGLRenderer.clear .clear]( false, true, false ).</p>
301 302

		<h3>[method:null clearStencil]( )</h3>
303
		<p>Clear the stencil buffers. Equivalent to calling [page:WebGLRenderer.clear .clear]( false, false, true ).</p>
304

305
		<h3>[method:null compile]( [param:Scene scene], [param:Camera camera] )</h3>
306
		<p>Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first rendering.</p>
M
Mr.doob 已提交
307

308
		<h3>[method:null copyFramebufferToTexture]( [param:Vector2 position], [param:Texture texture], [param:Number level] )</h3>
309
		<p>Copies pixels from the current WebGLFramebuffer into a 2D texture. Enables access to [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/copyTexImage2D WebGLRenderingContext.copyTexImage2D].</p>
310

311
		<h3>[method:null copyTextureToTexture]( [param:Vector2 position], [param:Texture srcTexture], [param:Texture dstTexture], [param:Number level] )</h3>
312
		<p>Copies all pixels of a texture to an existing texture starting from the given position. Enables access to [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texSubImage2D WebGLRenderingContext.texSubImage2D].</p>
313

314
		<h3>[method:null dispose]( )</h3>
315
		<p>Dispose of the current rendering context.</p>
X
Xiangyun Chi 已提交
316

317
		<h3>[method:Object extensions.get]( [param:String extensionName] )</h3>
318
		<p>
319 320
		Used to check whether various extensions are supported and returns an object with details of the extension if available.
		This method can check for the following extensions:<br /><br />
X
Xiangyun Chi 已提交
321

322 323 324 325 326
		- *WEBGL_depth_texture*<br />
		- *EXT_texture_filter_anisotropic*<br />
		- *WEBGL_compressed_texture_s3tc*<br />
		- *WEBGL_compressed_texture_pvrtc*<br />
		- *WEBGL_compressed_texture_etc1*
327
		</p>
S
sole 已提交
328

329
		<h3>[method:null forceContextLoss]( )</h3>
330
		<p>
331 332 333
		Simulate loss of the WebGL context. This requires support for the
			[link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context WEBGL_lose_context] extensions.
		According to [link:https://webglstats.com/ WebGLStats], as of February 2016 90% of WebGL enabled devices support this.
334
		</p>
S
sole 已提交
335

336
		<h3>[method:Float getClearAlpha]()</h3>
337
		<p>Returns a [page:Float float] with the current clear alpha. Ranges from 0 to 1.</p>
S
sole 已提交
338

339
		<h3>[method:Color getClearColor]()</h3>
340
		<p>Returns a [page:Color THREE.Color] instance with the current clear color.</p>
S
sole 已提交
341

342
		<h3>[method:WebGLRenderingContext getContext]()</h3>
343
		<p>Return the current WebGL context.</p>
344

345
		<h3>[method:WebGLContextAttributes getContextAttributes]()</h3>
346
		<p>Returns an object that describes the attributes set on the WebGL context when it was created.</p>
S
sole 已提交
347

348
		<h3>[method:RenderTarget getRenderTarget]()</h3>
349
		<p>Returns the current RenderTarget, if any.</p>
S
sole 已提交
350

351 352 353 354 355 356
		<h3>[method:Vector4 getCurrentViewport]( [param:Vector4 target] )</h3>
		<p>
		[page:Vector4 target] — the result will be copied into this Vector4.<br /><br />

		Returns the current viewport.
		</p>
M
Mugen87 已提交
357

358 359 360 361 362 363
		<h3>[method:Vector2 getDrawingBufferSize]( [param:Vector2 target] )</h3>
		<p>
		[page:Vector2 target] — the result will be copied into this Vector2.<br /><br />

		Returns the width and height of the renderer's drawing buffer, in pixels.
		</p>
364

365
		<h3>[method:number getPixelRatio]()</h3>
366
		<p>Returns current device pixel ratio used.</p>
S
sole 已提交
367

368 369 370 371 372 373 374 375 376 377
		<h3>[method:Vector4 getScissor]( [param:Vector4 target] )</h3>
		<p>
		[page:Vector4 target] — the result will be copied into this Vector4.<br /><br />

		Returns the scissor region.
		</p>

		<h3>[method:Boolean getScissorTest]()</h3>
		<p>Returns *true* if scissor test is enabled; returns *false* otherwise.</p>

378 379 380 381 382 383
		<h3>[method:Vector2 getSize]( [param:Vector2 target] )</h3>
		<p>
		[page:Vector2 target] — the result will be copied into this Vector2.<br /><br />

		Returns the width and height of the renderer's output canvas, in pixels.
		</p>
S
sole 已提交
384

385 386 387 388 389 390 391
		<h3>[method:Vector4 getViewport]( [param:Vector4 target] )</h3>
		<p>
		[page:Vector4 target] — the result will be copied into this Vector4.<br /><br />

		Returns the viewport.
		</p>

392
		<h3>[method:null resetGLState]( )</h3>
393
		<p>Reset the GL state to default. Called internally if the WebGL context is lost.</p>
S
sole 已提交
394

A
aardgoose 已提交
395 396 397 398
		<h3>[method:null readRenderTargetPixels]( [param:WebGLRenderTarget renderTarget], [param:Float x], [param:Float y], [param:Float width], [param:Float height], [param:TypedArray buffer] )</h3>
		<p>buffer - Uint8Array is the only destination type supported in all cases, other types are renderTarget and platform dependent. See [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 WebGL spec] for details.</p>
		<p>Reads the pixel data from the renderTarget into the buffer you pass in. This is a wrapper around [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels WebGLRenderingContext.readPixels]().</p>
		<p>See the [example:webgl_interactive_cubes_gpu interactive / cubes / gpu] example.
399
		</p>
S
sole 已提交
400

A
aardgoose 已提交
401

402
		<h3>[method:null render]( [param:Scene scene], [param:Camera camera] )</h3>
403
		<p>
404
			Render a [page:Scene scene] using a [page:Camera camera].<br />
S
sole 已提交
405

406
			The render is done to a previously specified [page:WebGLRenderTarget renderTarget] set by calling [page:WebGLRenderer.setRenderTarget .setRenderTarget] or to the canvas as usual.<br />
S
sole 已提交
407

408 409 410
			By default render buffers are cleared before rendering but you can prevent this by setting the property [page:WebGLRenderer.autoClear autoClear] to false.
			If you want to prevent only certain buffers being cleared you can set either the [page:WebGLRenderer.autoClearColor autoClearColor], [page:WebGLRenderer.autoClearStencil autoClearStencil] or
			[page:WebGLRenderer.autoClearDepth autoClearDepth] properties to false. To forcibly clear one ore more buffers call [page:WebGLRenderer.clear .clear].
411
		</p>
S
sole 已提交
412

M
Michael Herzog 已提交
413
		<h3>[method:null renderBufferDirect]( [param:Camera camera], [param:Fog fog], [param:Geometry geometry], [param:Material material], [param:Object3D object], [param:Object group] )</h3>
414
		<p>Render a buffer geometry group using the camera and with the specified material.</p>
S
sole 已提交
415

416
		<h3>[method:null renderBufferImmediate]( [param:Object3D object], [param:shaderprogram program], [param:Material shading] )</h3>
417
		<p>object - an instance of [page:Object3D]<br />
L
Lewy Blue 已提交
418 419
		program - an instance of shaderProgram<br />
		shading - an instance of Material<br /><br />
S
sole 已提交
420

421
		Render an immediate buffer. Gets called by renderImmediateObject.
422
		</p>
423

424 425 426 427
		<h3>[method:null setAnimationLoop]( [param:Function callback] )</h3>
		<p>[page:Function callback] — The function will be called every available frame. If `null` is passed it will stop any already ongoing animation.</p>
		<p>A build in function that can be used instead of [link:https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame]. For WebVR projects this function must be used.</p>

428
		<h3>[method:null setClearAlpha]( [param:Float alpha] )</h3>
429
		<p>Sets the clear alpha. Valid input is a float between *0.0* and *1.0*.</p>
S
sole 已提交
430

431
		<h3>[method:null setClearColor]( [param:Color color], [param:Float alpha] )</h3>
432
		<p>Sets the clear color and opacity.</p>
S
sole 已提交
433

434
		<h3>[method:null setPixelRatio]( [param:number value] )</h3>
435
		<p>Sets device pixel ratio. This is usually used for HiDPI device to prevent bluring output canvas.</p>
436

437
		<h3>[method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipMapLevel] )</h3>
438
		<p>
439 440 441
		renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be activated (optional).<br />
		activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLRenderTargetCube] (optional).<br />
		activeMipMapLevel -- Specifies the active mipmap level (optional).<br /><br />
442
		This method sets the active rendertarget. If the parameter is omitted the canvas is set as the active rendertarget.
443
		</p>
M
Mr.doob 已提交
444

445 446 447
		<h3>[method:null setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
		[method:null setScissor]( [param:Vector4 vector] )</h3>

448
		<p>
449 450 451 452 453
		The x, y, width, and height parameters of the scissor region.<br />
		Optionally, a 4-component vector specifying the parameters of the region.<br /><br />

		Sets the scissor region from (x, y) to (x + width, y + height).<br />
		(x, y) is the lower-left corner of the scissor region.
454
		</p>
C
cjshannon 已提交
455

456
		<h3>[method:null setScissorTest]( [param:Boolean boolean] )</h3>
457
		<p>
M
Mr.doob 已提交
458 459
		Enable or disable the scissor test. When this is enabled, only the pixels within the defined
			scissor area will be affected by further renderer actions.
460
		</p>
C
cjshannon 已提交
461

462
		<h3>[method:null setSize]( [param:Integer width], [param:Integer height], [param:Boolean updateStyle] )</h3>
463
		<p>
464 465
		Resizes the output canvas to (width, height) with device pixel ratio taken into account,
			and also sets the viewport to fit that size, starting in (0, 0).
466
			Setting [page:Boolean updateStyle] to false prevents any style changes to the output canvas.
467
		</p>
C
cjshannon 已提交
468

469
		<h3>[method:null setTexture2D]( [param:Texture texture], [param:number slot] )</h3>
470
		<p>
471 472
		texture -- The [page:Texture texture] that needs to be set.<br />
		slot -- The number indicating which slot should be used by the texture.<br /><br />
C
cjshannon 已提交
473

474 475 476 477
		This method sets the correct texture to the correct slot for the WebGL shader.
		The slot number can be found as a value of the uniform of the sampler.<br /><br />

		Note: This method replaces the older [method:null setTexture] method.
478
		</p>
479

480
		<h3>[method:null setTextureCube]( [param:CubeTexture cubeTexture], [param:Number slot] )</h3>
481
		<p>
482 483 484 485 486
		texture -- The [page:CubeTexture cubeTexture] that needs to be set.<br />
		slot -- The number indicating which slot should be used by the texture.<br /><br />

		This method sets the correct texture to the correct slot for the WebGL shader.
		The slot number can be found as a value of the uniform of the sampler.
487
		</p>
C
cjshannon 已提交
488

489 490 491 492 493 494 495 496 497 498
		<h3>[method:null setViewport]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
		[method:null setViewport]( [param:Vector4 vector] )</h3>

		<p>
		The x, y, width, and height parameters of the viewport.<br />
		Optionally, a 4-component vector specifying the parameters of a viewport.<br /><br />

		Sets the viewport to render from (x, y) to (x + width, y + height).<br />
		(x, y) is the lower-left corner of the region.
		</p>
499

500
		<h2>Source</h2>
M
Mr.doob 已提交
501

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