WebGLRenderer.html 10.3 KB
Newer Older
1 2 3
<!DOCTYPE html>
<html lang="en">
	<head>
4
		<meta charset="utf-8" />
5 6 7 8 9 10
		<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

C
cjshannon 已提交
18

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

21
		<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 已提交
22

23 24 25 26 27 28 29 30 31 32 33 34
		<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 已提交
35

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

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

40 41
		<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 已提交
42

C
cjshannon 已提交
43
		<h3>.[page:todo context]</h3>
S
sole 已提交
44

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

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

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


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

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


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

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


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

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


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

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

P
PaulJacobs 已提交
71
		<div>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, it may be neccessary to turn off sorting and use other methods to deal with transparency rendering e.g. manually determining the object rendering order.</div>
S
sole 已提交
72 73


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

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

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

80
		<!-- Physically based shading -->
S
sole 已提交
81

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

84
		<div>Default is false. TODO</div>
S
sole 已提交
85 86


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

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


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

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


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

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


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

104
		<div>Default is true. TODO</div>
S
sole 已提交
105 106


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

109 110
		<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 已提交
111 112


C
cjshannon 已提交
113
		<h3>.[page:Boolean shadowMapCullFace]</h3>
S
sole 已提交
114

115
		<div>Default is true. TODO</div>
S
sole 已提交
116 117


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

120
		<div>Default is false. TODO</div>
S
sole 已提交
121 122


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

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


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

130
		<div>Default is 8. TODO</div>
S
sole 已提交
131 132


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

135
		<div>Default is 4. TODO</div>
S
sole 已提交
136 137


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

140
		<div>Default is true. TODO</div>
S
sole 已提交
141

M
Mr.doob 已提交
142

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

145 146
		<div>An array with render plugins to be applied before rendering.</div>
		<div>Default is an empty array, or [].</div>
S
sole 已提交
147 148


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

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


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

157 158
		<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 已提交
159
		<ul>
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
			<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 已提交
175
		</ul>
176
		</div>
M
Mr.doob 已提交
177

C
cjshannon 已提交
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
		<h3>.[page:ShadowMapPlugin shadowMapPlugin]</h3>
		<div>
		todo
		</div> 

		<h3>.[page:number shadowMapCullFace]</h3>
		<div>
		todo
		</div> 

		<h3>.[page:number devicePixelRatio]</h3>
		<div>
		todo
		</div> 

193
		<h2>Methods</h2>
M
Mr.doob 已提交
194

195 196 197 198
		<h3>.getContext()</h3>
		<div>
		Return the WebGL context.
		</div>
M
Mr.doob 已提交
199

200 201 202 203
		<h3>.supportsVertexTextures()</h3>
		<div>
		Return a [page:Boolean] true if the context supports vertex textures.
		</div>
S
sole 已提交
204 205


206 207
		<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 已提交
208

209 210
		<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 已提交
211 212


213 214
		<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 已提交
215

216 217
		<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 已提交
218

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

M
Mr.doob 已提交
222
		<code>// Creates a renderer with red background
223 224
		var renderer = new THREE.WebGLRenderer();
		renderer.setSize(200, 100);
M
Mr.doob 已提交
225
		renderer.setClearColor(0xff0000, 1);
226
		</code>
S
sole 已提交
227

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

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

234 235 236
		<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 已提交
237

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

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

244 245 246 247
		<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 已提交
248 249


250 251 252 253 254 255
		<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 已提交
256 257


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


262 263
		<h3>.renderBuffer( camera, lights, fog, material, geometryGroup, object )</h3>
		<div>TODO.</div>
S
sole 已提交
264 265


266 267 268 269
		<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 已提交
270 271


272 273
		<h3>.renderImmediateObject( camera, lights, fog, material, object )</h3>
		<div>TODO.</div>
S
sole 已提交
274 275


276 277
		<h3>.initWebGLObjects( [page:Scene scene] )</h3>
		<div>TODO.</div>
S
sole 已提交
278 279


280 281
		<h3>.initMaterial( material, lights, fog, object )</h3>
		<div>TODO.</div>
S
sole 已提交
282 283


284 285 286 287 288 289 290
		<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 已提交
291 292


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


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


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


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


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


M
Mr.doob 已提交
313

C
cjshannon 已提交
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
		<h3>.supportsCompressedTextureS3TC() [page:todo]</h3>
		<div>
		todo
		</div>

		<h3>.getMaxAnisotropy() [page:todo]</h3>
		<div>
		todo
		</div>

		<h3>.getPrecision() [page:todo]</h3>
		<div>
		todo
		</div>

		<h3>.setMaterialFaces([page:todo material]) [page:todo]</h3>
		<div>
		material -- todo
		</div>
		<div>
		todo
		</div>

		<h3>.supportsStandardDerivatives() [page:todo]</h3>
		<div>
		todo
		</div>

		<h3>.supportsFloatTextures() [page:todo]</h3>
		<div>
		todo
		</div>

		<h3>.clearTarget([page:todo renderTarget], [page:todo color], [page:todo depth], [page:todo stencil]) [page:todo]</h3>
		<div>
		renderTarget -- todo <br />
		color -- todo <br />
		depth -- todo <br />
		stencil -- todo
		</div>
		<div>
		todo
		</div>

		<h3>.setClearColorHex([page:todo hex], [page:todo alpha]) [page:todo]</h3>
		<div>
		hex -- todo <br />
		alpha -- todo
		</div>
		<div>
		todo
		</div>

367
		<h2>Source</h2>
M
Mr.doob 已提交
368

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