WebGLRenderer.html 10.4 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
		<div>
		canvas — A [page:Canvas] where the renderer draws its output.<br />
		precision — shader precision. Can be *"highp"*, *"mediump"* or *"lowp"*.<br />
26
		alpha — [page:Boolean], default is *false*.<br />
27 28 29 30 31 32
		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 />
		maxLights — [page:Integer], default is *4*.<br />
		</div>
M
Mr.doob 已提交
33

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

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

38 39
		<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 已提交
40

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

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

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

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


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

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


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

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


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

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


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

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

P
PaulJacobs 已提交
69
		<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 已提交
70 71


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

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

76
		<div>TODO</div>
S
sole 已提交
77

78
		<!-- Physically based shading -->
S
sole 已提交
79

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

82
		<div>Default is false. TODO</div>
S
sole 已提交
83 84


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

87
		<div>Default is false. TODO</div>
S
sole 已提交
88 89


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

92
		<div>Default is false. TODO</div>
S
sole 已提交
93 94


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

97
		<div>Default is true. TODO</div>
S
sole 已提交
98 99


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

102 103
		<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 已提交
104 105


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

108
		<div>Default is true. TODO</div>
S
sole 已提交
109 110


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

113
		<div>Default is false. TODO</div>
S
sole 已提交
114 115


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

118
		<div>Default is false. TODO</div>
S
sole 已提交
119 120


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

123
		<div>Default is 8. TODO</div>
S
sole 已提交
124 125


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

128
		<div>Default is 4. TODO</div>
S
sole 已提交
129 130


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

133
		<div>Default is true. TODO</div>
S
sole 已提交
134

M
Mr.doob 已提交
135

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

138 139
		<div>An array with render plugins to be applied before rendering.</div>
		<div>Default is an empty array, or [].</div>
S
sole 已提交
140 141


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

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


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

150 151
		<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 已提交
152
		<ul>
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
			<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 已提交
168
		</ul>
169
		</div>
M
Mr.doob 已提交
170

C
cjshannon 已提交
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
		<h3>.[page:ShadowMapPlugin shadowMapPlugin]</h3>
		<div>
		todo
		</div> 

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

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

186
		<h2>Methods</h2>
M
Mr.doob 已提交
187

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

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


199 200
		<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 已提交
201

202 203
		<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 已提交
204 205


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

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

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

M
Mr.doob 已提交
215
		<code>// Creates a renderer with red background
216 217
		var renderer = new THREE.WebGLRenderer();
		renderer.setSize(200, 100);
M
Mr.doob 已提交
218
		renderer.setClearColor(0xff0000, 1);
219
		</code>
S
sole 已提交
220

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

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

227 228 229
		<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 已提交
230

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

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

237 238 239 240
		<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 已提交
241 242


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


251 252
		<h3>.renderBufferDirect(  camera, lights, fog, material, geometryGroup, object )</h3>
		<div>TODO.</div>
S
sole 已提交
253 254


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


259 260 261
		<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>
262 263
        <div>If forceClear is true the depth, stencil and color buffers will be cleared before rendering even if the renderer's autoClear property is false.</div>
        <div>Even with forceClear set to true you can prevent certain buffers being cleared by setting either the .autoClearColor, .autoClearStencil or .autoClearDepth properties to false.</div>
S
sole 已提交
264

265 266
		<h3>.renderImmediateObject( camera, lights, fog, material, object )</h3>
		<div>TODO.</div>
S
sole 已提交
267 268


269 270
		<h3>.initWebGLObjects( [page:Scene scene] )</h3>
		<div>TODO.</div>
S
sole 已提交
271 272


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


277 278 279 280 281 282 283
		<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 已提交
284 285


286 287
		<h3>.setDepthTest( depthTest )</h3>
		<div>TODO.</div>
S
sole 已提交
288 289


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


294 295
		<h3>.setBlending( blending, blendEquation, blendSrc, blendDst )</h3>
		<div>TODO.</div>
S
sole 已提交
296 297


298 299
		<h3>.setTexture( texture, slot )</h3>
		<div>TODO.</div>
S
sole 已提交
300 301


302 303
		<h3>.setRenderTarget( renderTarget )</h3>
		<div>TODO.</div>
S
sole 已提交
304 305


M
Mr.doob 已提交
306

C
cjshannon 已提交
307 308 309 310 311 312 313 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
		<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>

360
		<h2>Source</h2>
M
Mr.doob 已提交
361

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