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

12 13
		<div class="desc">The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it.</div>
		<div class="desc">This renderer has way better performance than [page:CanvasRenderer].</div>
M
Mr.doob 已提交
14 15


16
		<h2>Constructor</h2>
M
Mr.doob 已提交
17

18
		<h3>[name]( [page:Object parameters] )</h3>
M
Mr.doob 已提交
19

20
		<div>parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing.</div>
S
sole 已提交
21

22 23 24 25 26 27 28 29 30 31 32 33
		<div>
		canvas — A [page:Canvas] where the renderer draws its output.<br />
		precision — shader precision. Can be *"highp"*, *"mediump"* or *"lowp"*.<br />
		alpha — [page:Boolean], default is *true*.<br />
		premultipliedAlpha — [page:Boolean], default is *true*.<br />
		antialias — [page:Boolean], default is *false*.<br />
		stencil — [page:Boolean], default is *true*.<br />
		preserveDrawingBuffer — [page:Boolean], default is *false*.<br />
		clearColor — [page:Integer], default is *0x000000*.<br />
		clearAlpha — [page:Float], default is *0*.<br />
		maxLights — [page:Integer], default is *4*.<br />
		</div>
M
Mr.doob 已提交
34

35
		<h2>Properties</h2>
M
Mr.doob 已提交
36

37
		<h3>.[page:DOMElement domElement]</h3>
S
sole 已提交
38

39 40
		<div>A [page: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.</div>
S
sole 已提交
41

42
		<h3>.context</h3>
S
sole 已提交
43

44
		<div>The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw.</div>
S
sole 已提交
45

46
		<h3>.[page:Boolean autoClear]</h3>
S
sole 已提交
47

48
		<div>Defines whether the renderer should automatically clear its output before rendering.</div>
S
sole 已提交
49 50


51
		<h3>.[page:Boolean autoClearColor]</h3>
S
sole 已提交
52

53
		<div>If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.</div>
S
sole 已提交
54 55


56
		<h3>.[page:Boolean autoClearDepth]</h3>
S
sole 已提交
57

58
		<div>If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true.</div>
S
sole 已提交
59 60


61
		<h3>.[page:Boolean autoClearStencil]</h3>
S
sole 已提交
62

63
		<div>If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true.</div>
S
sole 已提交
64 65


66
		<h3>.[page:Boolean sortObjects]</h3>
S
sole 已提交
67

68
		<div>Defines whether the renderer should sort objects. Default is true.</div>
S
sole 已提交
69

70
		<div>TODO</div>
S
sole 已提交
71 72


73
		<h3>.[page:Boolean autoUpdateObjects]</h3>
S
sole 已提交
74

75
		<div>Defines whether the renderer should auto update objects. Default is true.</div>
S
sole 已提交
76

77
		<div>TODO</div>
S
sole 已提交
78 79


80
		<h3>.[page:Boolean autoUpdateScene]</h3>
S
sole 已提交
81

82
		<div>Defines whether the renderer should auto update the scene. Default is true.</div>
S
sole 已提交
83

84
		<div>TODO</div>
S
sole 已提交
85

86
		<!-- Physically based shading -->
S
sole 已提交
87

88
		<h3>.[page:Boolean gammaInput]</h3>
S
sole 已提交
89

90
		<div>Default is false. TODO</div>
S
sole 已提交
91 92


93
		<h3>.[page:Boolean gammaOutput]</h3>
S
sole 已提交
94

95
		<div>Default is false. TODO</div>
S
sole 已提交
96 97


98
		<h3>.[page:Boolean physicallyBasedShading]</h3>
S
sole 已提交
99

100
		<div>Default is false. TODO</div>
S
sole 已提交
101 102


103
		<h3>.[page:Boolean shadowMapEnabled]</h3>
S
sole 已提交
104

105
		<div>Default is false. TODO</div>
S
sole 已提交
106 107


108
		<h3>.[page:Boolean shadowMapAutoUpdate]</h3>
S
sole 已提交
109

110
		<div>Default is true. TODO</div>
S
sole 已提交
111 112


113
		<h3>.[page:Integer shadowMapType]</h3>
S
sole 已提交
114

115 116
		<div>Defines shadow map type (unfiltered, percentage close filtering, percentage close filtering with bilinear filtering in shader)</div>
		<div>Options are THREE.BasicShadowMap, THREE.PCFShadowMap, THREE.PCFSoftShadowMap. Default is THREE.PCFShadowMap.</div>
S
sole 已提交
117 118


119
		<h3>.[page:Boolean shadowMapCullFrontFaces]</h3>
S
sole 已提交
120

121
		<div>Default is true. TODO</div>
S
sole 已提交
122 123


124
		<h3>.[page:Boolean shadowMapDebug]</h3>
S
sole 已提交
125

126
		<div>Default is false. TODO</div>
S
sole 已提交
127 128


129
		<h3>.[page:Boolean shadowMapCascade]</h3>
S
sole 已提交
130

131
		<div>Default is false. TODO</div>
S
sole 已提交
132 133


134
		<h3>.[page:Integer maxMorphTargets]</h3>
S
sole 已提交
135

136
		<div>Default is 8. TODO</div>
S
sole 已提交
137 138


139
		<h3>.[page:Integer maxMorphNormals]</h3>
S
sole 已提交
140

141
		<div>Default is 4. TODO</div>
S
sole 已提交
142 143


144
		<h3>.[page:Boolean autoScaleCubemaps]</h3>
S
sole 已提交
145

146
		<div>Default is true. TODO</div>
S
sole 已提交
147

M
Mr.doob 已提交
148

149
		<h3>.[page:Boolean renderPluginsPre]</h3>
S
sole 已提交
150

151 152
		<div>An array with render plugins to be applied before rendering.</div>
		<div>Default is an empty array, or [].</div>
S
sole 已提交
153 154


155
		<h3>.[page:Boolean renderPluginsPost]</h3>
S
sole 已提交
156

157 158
		<div>An array with render plugins to be applied after rendering.</div>
		<div>Default is an empty array, or [].</div>
S
sole 已提交
159 160


161
		<h3>.[page:Object info]</h3>
S
sole 已提交
162

163 164
		<div>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:</div>
		<div>
S
sole 已提交
165
		<ul>
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
			<li>memory:
				<ul>
					<li>programs</li>
					<li>geometries</li>
					<li>textures</li>
				</ul>
			</li>
			<li>render:
				<ul>
					<li>calls</li>
					<li>vertices</li>
					<li>faces</li>
					<li>points</li>
				</ul>
			</li>
S
sole 已提交
181
		</ul>
182
		</div>
M
Mr.doob 已提交
183

184
		<h2>Methods</h2>
M
Mr.doob 已提交
185

186 187 188 189
		<h3>.getContext()</h3>
		<div>
		Return the WebGL context.
		</div>
M
Mr.doob 已提交
190

191 192 193 194
		<h3>.supportsVertexTextures()</h3>
		<div>
		Return a [page:Boolean] true if the context supports vertex textures.
		</div>
S
sole 已提交
195 196


197 198
		<h3>.setSize( [page:Integer width], [page:Integer height] )</h3>
		<div>Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0).</div>
S
sole 已提交
199

200 201
		<h3>.setViewport( [page:Integer x], [page:Integer y], [page:Integer width], [page:Integer height] )</h3>
		<div>Sets the viewport to render from (x, y) to (x + width, y + height).</div>
S
sole 已提交
202 203


204 205
		<h3>.setScissor( [page:Integer x], [page:Integer y], [page:Integer width], [page:Integer height] )</h3>
		<div>Sets the scissor area from (x, y) to (x + width, y + height).</div>
S
sole 已提交
206

207 208
		<h3>.enableScissorTest( [page:Boolean enable] )</h3>
		<div>Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.</div>
S
sole 已提交
209 210


211 212
		<h3>.setClearColorHex( [page:Integer hex], [page:Float alpha] )</h3>
		<div>Sets the clear color, using hex for the color and alpha for the opacity.</div>
S
sole 已提交
213

214 215 216 217 218
		<code>// Creates a renderer with black background
		var renderer = new THREE.WebGLRenderer();
		renderer.setSize(200, 100);
		renderer.setClearColorHex(0x000000, 1);
		</code>
S
sole 已提交
219

220 221
		<h3>.setClearColor( [page:Color color], [page:Float alpha] )</h3>
		<div>Sets the clear color, using color for the color and alpha for the opacity.</div>
S
sole 已提交
222

223 224
		<h3>.getClearColor() [page:Color]</h3>
		<div>Returns a [page:Color THREE.Color] instance with the current clear color.</div>
S
sole 已提交
225 226


227 228
		<h3>.getClearAlpha() [page:Float]</h3>
		<div>Returns a [page:Float float] with the current clear alpha. Ranges from 0 to 1.</div>
S
sole 已提交
229

230 231 232
		<h3>.clear( [page:Boolean color], [page:Boolean depth], [page:Boolean stencil] )</h3>
		<div>Tells the renderer to clear its color, depth or stencil drawing buffer(s).</div>
		<div>If no parameters are passed, no buffer will be cleared.</div>
S
sole 已提交
233 234


235 236
		<h3>.addPostPlugin( plugin )</h3>
		<div>Initialises the postprocessing plugin, and adds it to the renderPluginsPost array.</div>
S
sole 已提交
237

238 239
		<h3>.addPrePlugin( plugin )</h3>
		<div>Initialises the preprocessing plugin, and adds it to the renderPluginsPre array.</div>
S
sole 已提交
240

241 242 243 244
		<h3>.updateShadowMap( [page:Scene scene], [page:Camera camera] )</h3>
		<div>scene — an instance of [page:Scene]<br />
		camera — an instance of [page:Camera]</div>
		<div>Tells the shadow map plugin to update using the passed scene and camera parameters.</div>
S
sole 已提交
245 246


247 248 249 250 251 252
		<h3>.renderBufferImmediate( [page:Object3D object], [page:??? program], [page:??? shading] )</h3>
		<div>object — an instance of [page:Object3D]]<br />
		program — an instance of ???<br />
		shading — an instance of ???<br />
		</div>
		<div>TODO.</div>
S
sole 已提交
253 254


255 256
		<h3>.renderBufferDirect(  camera, lights, fog, material, geometryGroup, object )</h3>
		<div>TODO.</div>
S
sole 已提交
257 258


259 260
		<h3>.renderBuffer( camera, lights, fog, material, geometryGroup, object )</h3>
		<div>TODO.</div>
S
sole 已提交
261 262


263 264 265 266
		<h3>.render( [page:Scene scene], [page:Camera camera], [page:WebGLRenderTarget renderTarget], [page:Boolean forceClear] )</h3>
		<div>Render a scene using a camera.</div>
		<div>The render is done to the renderTarget (if specified) or to the canvas as usual.</div>
		<div>If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false.</div>
S
sole 已提交
267 268


269 270
		<h3>.renderImmediateObject( camera, lights, fog, material, object )</h3>
		<div>TODO.</div>
S
sole 已提交
271 272


273 274
		<h3>.initWebGLObjects( [page:Scene scene] )</h3>
		<div>TODO.</div>
S
sole 已提交
275 276


277 278
		<h3>.initMaterial( material, lights, fog, object )</h3>
		<div>TODO.</div>
S
sole 已提交
279 280


281 282 283 284 285 286 287
		<h3>.setFaceCulling( cullFace, frontFace )</h3>
		<div>
		[page:String cullFace] — "back", "front", "front_and_back", or false.<br />
		[page:String frontFace] — "ccw" or "cw<br />
		</div>
		<div>Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering.</div>
		<div>If cullFace is false, culling will be disabled.</div>
S
sole 已提交
288 289


290 291
		<h3>.setObjectFaces( object )</h3>
		<div>TODO.</div>
S
sole 已提交
292 293


294 295
		<h3>.setDepthTest( depthTest )</h3>
		<div>TODO.</div>
S
sole 已提交
296 297


298 299
		<h3>.setDepthWrite( depthWrite )</h3>
		<div>TODO.</div>
S
sole 已提交
300 301


302 303
		<h3>.setBlending( blending, blendEquation, blendSrc, blendDst )</h3>
		<div>TODO.</div>
S
sole 已提交
304 305


306 307
		<h3>.setTexture( texture, slot )</h3>
		<div>TODO.</div>
S
sole 已提交
308 309


310 311
		<h3>.setRenderTarget( renderTarget )</h3>
		<div>TODO.</div>
S
sole 已提交
312 313


M
Mr.doob 已提交
314

315
		<h2>Source</h2>
M
Mr.doob 已提交
316

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