WebGLRenderer.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. The WebGL renderer displays your beautifully crafted scenes using
  13. [link:https://en.wikipedia.org/wiki/WebGL WebGL].
  14. </p>
  15. <h2>Constructor</h2>
  16. <h3>[name]( [param:Object parameters] )</h3>
  17. <p>
  18. [page:Object parameters] - (optional) object with properties defining the
  19. renderer's behaviour. The constructor also accepts no parameters at all.
  20. In all cases, it will assume sane defaults when parameters are missing.
  21. The following are valid parameters:<br /><br />
  22. [page:DOMElement canvas] - A
  23. [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas]
  24. where the renderer draws its output. This corresponds to the
  25. [page:WebGLRenderer.domElement domElement] property below. If not passed
  26. in here, a new canvas element will be created.<br />
  27. [page:WebGLRenderingContext context] - This can be used to attach the
  28. renderer to an existing
  29. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext]. Default is null.<br />
  30. [page:String precision] - Shader precision. Can be `"highp"`, `"mediump"`
  31. or `"lowp"`. Defaults to `"highp"` if supported by the device.<br />
  32. [page:Boolean alpha] - controls the default clear alpha value. When set to
  33. `true`, the value is `0`. Otherwise it's `1`. Default is `false`.<br />
  34. [page:Boolean premultipliedAlpha] - whether the renderer will assume that
  35. colors have
  36. [link:https://en.wikipedia.org/wiki/Glossary_of_computer_graphics#Premultiplied_alpha premultiplied alpha].
  37. Default is `true`.<br />
  38. [page:Boolean antialias] - whether to perform antialiasing. Default is
  39. `false`.<br />
  40. [page:Boolean stencil] - whether the drawing buffer has a
  41. [link:https://en.wikipedia.org/wiki/Stencil_buffer stencil buffer] of at
  42. least 8 bits. Default is `true`.<br />
  43. [page:Boolean preserveDrawingBuffer] - whether to preserve the buffers
  44. until manually cleared or overwritten. Default is `false`.<br />
  45. [page:String powerPreference] - Provides a hint to the user agent
  46. indicating what configuration of GPU is suitable for this WebGL context.
  47. Can be `"high-performance"`, `"low-power"` or `"default"`. Default is
  48. `"default"`. See
  49. [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2 WebGL spec] for details.<br />
  50. [page:Boolean failIfMajorPerformanceCaveat] - whether the renderer
  51. creation will fail upon low performance is detected. Default is `false`.
  52. See [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2 WebGL spec] for details.<br />
  53. [page:Boolean depth] - whether the drawing buffer has a
  54. [link:https://en.wikipedia.org/wiki/Z-buffering depth buffer] of at least
  55. 16 bits. Default is `true`.<br />
  56. [page:Boolean logarithmicDepthBuffer] - whether to use a logarithmic depth
  57. buffer. It may be necessary to use this if dealing with huge differences
  58. in scale in a single scene. Note that this setting uses gl_FragDepth if
  59. available which disables the
  60. [link:https://www.khronos.org/opengl/wiki/Early_Fragment_Test Early Fragment Test]
  61. optimization and can cause a decrease in performance.
  62. Default is `false`. See the [example:webgl_camera_logarithmicdepthbuffer camera / logarithmicdepthbuffer] example.
  63. </p>
  64. <h2>Properties</h2>
  65. <h3>[property:Boolean autoClear]</h3>
  66. <p>
  67. Defines whether the renderer should automatically clear its output before
  68. rendering a frame.
  69. </p>
  70. <h3>[property:Boolean autoClearColor]</h3>
  71. <p>
  72. If [page:.autoClear autoClear] is true, defines whether the renderer
  73. should clear the color buffer. Default is `true`.
  74. </p>
  75. <h3>[property:Boolean autoClearDepth]</h3>
  76. <p>
  77. If [page:.autoClear autoClear] is true, defines whether the renderer
  78. should clear the depth buffer. Default is `true`.
  79. </p>
  80. <h3>[property:Boolean autoClearStencil]</h3>
  81. <p>
  82. If [page:.autoClear autoClear] is true, defines whether the renderer
  83. should clear the stencil buffer. Default is `true`.
  84. </p>
  85. <h3>[property:Object debug]</h3>
  86. <p>
  87. - [page:Boolean checkShaderErrors]: If it is true, defines whether
  88. material shader programs are checked for errors during compilation and
  89. linkage process. It may be useful to disable this check in production for
  90. performance gain. It is strongly recommended to keep these checks enabled
  91. during development. If the shader does not compile and link - it will not
  92. work and associated material will not render. Default is `true`.<br />
  93. - [page:Function onShaderError]( gl, program, glVertexShader,
  94. glFragmentShader ): A callback function that can be used for custom error
  95. reporting. The callback receives the WebGL context, an instance of
  96. WebGLProgram as well two instances of WebGLShader representing the vertex
  97. and fragment shader. Assigning a custom function disables the default
  98. error reporting. Default is `null`.
  99. </p>
  100. <h3>[property:Object capabilities]</h3>
  101. <p>
  102. An object containing details about the capabilities of the current
  103. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext RenderingContext].<br />
  104. - [page:Boolean floatFragmentTextures]: whether the context supports the
  105. [link:https://developer.mozilla.org/en-US/docs/Web/API/OES_texture_float OES_texture_float] extension.<br />
  106. - [page:Boolean floatVertexTextures]: `true` if [page:Boolean floatFragmentTextures]
  107. and [page:Boolean vertexTextures] are both true.<br />
  108. - [page:Method getMaxAnisotropy](): Returns the maximum available
  109. anisotropy.<br />
  110. - [page:Method getMaxPrecision](): Returns the maximum available precision
  111. for vertex and fragment shaders. <br />
  112. - [page:Boolean isWebGL2]: `true` if the context in use is a
  113. WebGL2RenderingContext object.<br />
  114. - [page:Boolean logarithmicDepthBuffer]: `true` if the [page:parameter logarithmicDepthBuffer]
  115. was set to true in the constructor and the context
  116. supports the
  117. [link:https://developer.mozilla.org/en-US/docs/Web/API/EXT_frag_depth EXT_frag_depth] extension.<br />
  118. - [page:Integer maxAttributes]: The value of `gl.MAX_VERTEX_ATTRIBS`.<br />
  119. - [page:Integer maxCubemapSize]: The value of
  120. `gl.MAX_CUBE_MAP_TEXTURE_SIZE`. Maximum height * width of cube map
  121. textures that a shader can use.<br />
  122. - [page:Integer maxFragmentUniforms]: The value of
  123. `gl.MAX_FRAGMENT_UNIFORM_VECTORS`. The number of uniforms that can be used
  124. by a fragment shader.<br />
  125. - [page:Integer maxSamples]: The value of `gl.MAX_SAMPLES`. Maximum number
  126. of samples in context of Multisample anti-aliasing (MSAA).<br />
  127. - [page:Integer maxTextureSize]: The value of `gl.MAX_TEXTURE_SIZE`.
  128. Maximum height * width of a texture that a shader use.<br />
  129. - [page:Integer maxTextures]: The value of `gl.MAX_TEXTURE_IMAGE_UNITS`.
  130. The maximum number of textures that can be used by a shader.<br />
  131. - [page:Integer maxVaryings]: The value of `gl.MAX_VARYING_VECTORS`. The
  132. number of varying vectors that can used by shaders.<br />
  133. - [page:Integer maxVertexTextures]: The value of
  134. `gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS`. The number of textures that can be
  135. used in a vertex shader.<br />
  136. - [page:Integer maxVertexUniforms]: The value of
  137. `gl.MAX_VERTEX_UNIFORM_VECTORS`. The maximum number of uniforms that can
  138. be used in a vertex shader.<br />
  139. - [page:String precision]: The shader precision currently being used by
  140. the renderer.<br />
  141. - [page:Boolean vertexTextures]: `true` if [property:Integer maxVertexTextures]
  142. is greater than 0 (i.e. vertex textures can be used).<br />
  143. </p>
  144. <h3>[property:Array clippingPlanes]</h3>
  145. <p>
  146. User-defined clipping planes specified as THREE.Plane objects in world
  147. space. These planes apply globally. Points in space whose dot product with
  148. the plane is negative are cut away. Default is [].
  149. </p>
  150. <h3>[property:DOMElement domElement]</h3>
  151. <p>
  152. A [link:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas canvas]
  153. where the renderer draws its output.<br />
  154. This is automatically created by the renderer in the constructor (if not
  155. provided already); you just need to add it to your page like so:<br />
  156. <code>
  157. document.body.appendChild( renderer.domElement );
  158. </code>
  159. </p>
  160. <h3>[property:Object extensions]</h3>
  161. <p>
  162. - [page:Object get]( [param:String extensionName] ): Used to check whether
  163. various extensions are supported and returns an object with details of the
  164. extension if available. This method can check for the following
  165. extensions:<br />
  166. </p>
  167. <ul>
  168. <li>`WEBGL_depth_texture`</li>
  169. <li>`EXT_texture_filter_anisotropic`</li>
  170. <li>`WEBGL_compressed_texture_s3tc`</li>
  171. <li>`WEBGL_compressed_texture_pvrtc`</li>
  172. <li>`WEBGL_compressed_texture_etc1`</li>
  173. </ul>
  174. <h3>[property:string outputColorSpace]</h3>
  175. <p>
  176. Defines the output color space of the renderer. Default is [page:Textures THREE.SRGBColorSpace].
  177. </p>
  178. <p>
  179. If a render target has been set using [page:WebGLRenderer.setRenderTarget .setRenderTarget]
  180. then renderTarget.texture.colorSpace will be used instead.
  181. </p>
  182. <p>
  183. See the [page:Textures texture constants] page for details of other
  184. formats.
  185. </p>
  186. <h3>[property:Object info]</h3>
  187. <p>
  188. An object with a series of statistical information about the graphics
  189. board memory and the rendering process. Useful for debugging or just for
  190. the sake of curiosity. The object contains the following fields:
  191. </p>
  192. <ul>
  193. <li>
  194. memory:
  195. <ul>
  196. <li>geometries</li>
  197. <li>textures</li>
  198. </ul>
  199. </li>
  200. <li>
  201. render:
  202. <ul>
  203. <li>calls</li>
  204. <li>triangles</li>
  205. <li>points</li>
  206. <li>lines</li>
  207. <li>frame</li>
  208. </ul>
  209. </li>
  210. <li>programs</li>
  211. </ul>
  212. <p>
  213. By default these data are reset at each render call but when having
  214. multiple render passes per frame (e.g. when using post processing) it can
  215. be preferred to reset with a custom pattern. First, set `autoReset` to
  216. `false`.
  217. <code> renderer.info.autoReset = false; </code>
  218. Call `reset()` whenever you have finished to render a single frame.
  219. <code> renderer.info.reset(); </code>
  220. </p>
  221. <h3>[property:Boolean localClippingEnabled]</h3>
  222. <p>
  223. Defines whether the renderer respects object-level clipping planes.
  224. Default is `false`.
  225. </p>
  226. <h3>[property:Boolean useLegacyLights]</h3>
  227. <p>Whether to use the legacy lighting mode or not. Default is `true`.</p>
  228. <h3>[property:Object properties]</h3>
  229. <p>
  230. Used internally by the renderer to keep track of various sub object
  231. properties.
  232. </p>
  233. <h3>[property:WebGLRenderLists renderLists]</h3>
  234. <p>Used internally to handle ordering of scene object rendering.</p>
  235. <h3>[property:WebGLShadowMap shadowMap]</h3>
  236. <p>
  237. This contains the reference to the shadow map, if used.<br />
  238. - [page:Boolean enabled]: If set, use shadow maps in the scene. Default is
  239. `false`.<br />
  240. - [page:Boolean autoUpdate]: Enables automatic updates to the shadows in
  241. the scene. Default is `true`.<br />
  242. If you do not require dynamic lighting / shadows, you may set this to
  243. `false` when the renderer is instantiated.<br />
  244. - [page:Boolean needsUpdate]: When set to `true`, shadow maps in the scene
  245. will be updated in the next `render` call. Default is `false`.<br />
  246. If you have disabled automatic updates to shadow maps
  247. (`shadowMap.autoUpdate = false`), you will need to set this to `true` and
  248. then make a render call to update the shadows in your scene.<br />
  249. - [page:Integer type]: Defines shadow map type (unfiltered, percentage
  250. close filtering, percentage close filtering with bilinear filtering in
  251. shader). Options are:
  252. </p>
  253. <ul>
  254. <li>THREE.BasicShadowMap</li>
  255. <li>THREE.PCFShadowMap (default)</li>
  256. <li>THREE.PCFSoftShadowMap</li>
  257. <li>THREE.VSMShadowMap</li>
  258. </ul>
  259. See [page:Renderer Renderer constants] for details.<br />
  260. <h3>[property:Boolean sortObjects]</h3>
  261. <p>
  262. Defines whether the renderer should sort objects. Default is `true`.<br /><br />
  263. Note: Sorting is used to attempt to properly render objects that have some
  264. degree of transparency. By definition, sorting objects may not work in all
  265. cases. Depending on the needs of application, it may be necessary to turn
  266. off sorting and use other methods to deal with transparency rendering e.g.
  267. manually determining each object's rendering order.
  268. </p>
  269. <h3>[property:Object state]</h3>
  270. <p>
  271. Contains functions for setting various properties of the
  272. [page:WebGLRenderer.context] state.
  273. </p>
  274. <h3>[property:Constant toneMapping]</h3>
  275. <p>
  276. Default is [page:Renderer NoToneMapping]. See the [page:Renderer Renderer constants] for other choices.
  277. </p>
  278. <h3>[property:Number toneMappingExposure]</h3>
  279. <p>Exposure level of tone mapping. Default is `1`.</p>
  280. <h3>[property:WebXRManager xr]</h3>
  281. <p>
  282. Provides access to the WebXR related [page:WebXRManager interface] of the
  283. renderer.
  284. </p>
  285. <h2>Methods</h2>
  286. <h3>
  287. [method:undefined clear]( [param:Boolean color], [param:Boolean depth], [param:Boolean stencil] )
  288. </h3>
  289. <p>
  290. Tells the renderer to clear its color, depth or stencil drawing buffer(s).
  291. This method initializes the color buffer to the current clear color
  292. value.<br />
  293. Arguments default to `true`.
  294. </p>
  295. <h3>[method:undefined clearColor]( )</h3>
  296. <p>
  297. Clear the color buffer. Equivalent to calling [page:WebGLRenderer.clear .clear]( true, false, false ).
  298. </p>
  299. <h3>[method:undefined clearDepth]( )</h3>
  300. <p>
  301. Clear the depth buffer. Equivalent to calling [page:WebGLRenderer.clear .clear]( false, true, false ).
  302. </p>
  303. <h3>[method:undefined clearStencil]( )</h3>
  304. <p>
  305. Clear the stencil buffers. Equivalent to calling [page:WebGLRenderer.clear .clear]( false, false, true ).
  306. </p>
  307. <h3>
  308. [method:undefined compile]( [param:Object3D scene], [param:Camera camera] )
  309. </h3>
  310. <p>
  311. Compiles all materials in the scene with the camera. This is useful to
  312. precompile shaders before the first rendering.
  313. </p>
  314. <h3>
  315. [method:undefined copyFramebufferToTexture]( [param:Vector2 position], [param:FramebufferTexture texture], [param:Number level] )
  316. </h3>
  317. <p>
  318. Copies pixels from the current WebGLFramebuffer into a 2D texture. Enables
  319. access to
  320. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/copyTexImage2D WebGLRenderingContext.copyTexImage2D].
  321. </p>
  322. <h3>
  323. [method:undefined copyTextureToTexture]( [param:Vector2 position], [param:Texture srcTexture], [param:Texture dstTexture], [param:Number level] )
  324. </h3>
  325. <p>
  326. Copies all pixels of a texture to an existing texture starting from the
  327. given position. Enables access to
  328. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texSubImage2D WebGLRenderingContext.texSubImage2D].
  329. </p>
  330. <h3>
  331. [method:undefined copyTextureToTexture3D]( [param:Box3 sourceBox], [param:Vector3 position], [param:Texture srcTexture], [param:Texture dstTexture], [param:Number level] )
  332. </h3>
  333. <p>
  334. Copies the pixels of a texture in the bounds '[page:Box3 sourceBox]' in
  335. the destination texture starting from the given position. Enables access
  336. to
  337. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/texSubImage3D WebGL2RenderingContext.texSubImage3D].
  338. </p>
  339. <h3>[method:undefined dispose]( )</h3>
  340. <p>
  341. Frees the GPU-related resources allocated by this instance. Call this
  342. method whenever this instance is no longer used in your app.
  343. </p>
  344. <h3>[method:undefined forceContextLoss]()</h3>
  345. <p>
  346. Simulate loss of the WebGL context. This requires support for the
  347. [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context WEBGL_lose_context] extensions.
  348. </p>
  349. <h3>[method:undefined forceContextRestore]( )</h3>
  350. <p>
  351. Simulate restore of the WebGL context. This requires support for the
  352. [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context WEBGL_lose_context] extensions.
  353. </p>
  354. <h3>[method:Float getClearAlpha]()</h3>
  355. <p>
  356. Returns a [page:Float float] with the current clear alpha. Ranges from 0
  357. to 1.
  358. </p>
  359. <h3>[method:Color getClearColor]( [param:Color target] )</h3>
  360. <p>
  361. Returns a [page:Color THREE.Color] instance with the current clear color.
  362. </p>
  363. <h3>[method:WebGL2RenderingContext getContext]()</h3>
  364. <p>Return the current WebGL context.</p>
  365. <h3>[method:WebGLContextAttributes getContextAttributes]()</h3>
  366. <p>
  367. Returns an object that describes the attributes set on the WebGL context
  368. when it was created.
  369. </p>
  370. <h3>[method:Integer getActiveCubeFace]()</h3>
  371. <p>Returns the current active cube face.</p>
  372. <h3>[method:Integer getActiveMipmapLevel]()</h3>
  373. <p>Returns the current active mipmap level.</p>
  374. <h3>[method:RenderTarget getRenderTarget]()</h3>
  375. <p>
  376. Returns the current [page:RenderTarget RenderTarget] if there are; returns
  377. `null` otherwise.
  378. </p>
  379. <h3>[method:Vector4 getCurrentViewport]( [param:Vector4 target] )</h3>
  380. <p>
  381. [page:Vector4 target] — the result will be copied into this Vector4.<br /><br />
  382. Returns the current viewport.
  383. </p>
  384. <h3>[method:Vector2 getDrawingBufferSize]( [param:Vector2 target] )</h3>
  385. <p>
  386. [page:Vector2 target] — the result will be copied into this Vector2.<br /><br />
  387. Returns the width and height of the renderer's drawing buffer, in pixels.
  388. </p>
  389. <h3>[method:number getPixelRatio]()</h3>
  390. <p>Returns current device pixel ratio used.</p>
  391. <h3>[method:Vector4 getScissor]( [param:Vector4 target] )</h3>
  392. <p>
  393. [page:Vector4 target] — the result will be copied into this Vector4.<br /><br />
  394. Returns the scissor region.
  395. </p>
  396. <h3>[method:Boolean getScissorTest]()</h3>
  397. <p>Returns `true` if scissor test is enabled; returns `false` otherwise.</p>
  398. <h3>[method:Vector2 getSize]( [param:Vector2 target] )</h3>
  399. <p>
  400. [page:Vector2 target] — the result will be copied into this Vector2.<br /><br />
  401. Returns the width and height of the renderer's output canvas, in pixels.
  402. </p>
  403. <h3>[method:Vector4 getViewport]( [param:Vector4 target] )</h3>
  404. <p>
  405. [page:Vector4 target] — the result will be copied into this Vector4.<br /><br />
  406. Returns the viewport.
  407. </p>
  408. <h3>[method:undefined initTexture]( [param:Texture texture] )</h3>
  409. <p>
  410. Initializes the given texture. Useful for preloading a texture rather than
  411. waiting until first render (which can cause noticeable lags due to decode
  412. and GPU upload overhead).
  413. </p>
  414. <h3>[method:undefined resetGLState]( )</h3>
  415. <p>
  416. Reset the GL state to default. Called internally if the WebGL context is
  417. lost.
  418. </p>
  419. <h3>
  420. [method:undefined readRenderTargetPixels]( [param:WebGLRenderTarget renderTarget], [param:Float x], [param:Float y], [param:Float width], [param:Float height], [param:TypedArray buffer], [param:IntegeractiveCubeFaceIndex] )
  421. </h3>
  422. <p>
  423. buffer - Uint8Array is the only destination type supported in all cases,
  424. other types are renderTarget and platform dependent. See
  425. [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 WebGL spec] for details.
  426. </p>
  427. <p>
  428. Reads the pixel data from the renderTarget into the buffer you pass in.
  429. This is a wrapper around
  430. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels WebGLRenderingContext.readPixels]().
  431. </p>
  432. <p>
  433. See the [example:webgl_interactive_cubes_gpu interactive / cubes / gpu]
  434. example.
  435. </p>
  436. <p>
  437. For reading out a [page:WebGLCubeRenderTarget WebGLCubeRenderTarget] use
  438. the optional parameter activeCubeFaceIndex to determine which face should
  439. be read.
  440. </p>
  441. <h3>
  442. [method:undefined render]( [param:Object3D scene], [param:Camera camera] )
  443. </h3>
  444. <p>
  445. Render a [page:Scene scene] or another type of [page:Object3D object]
  446. using a [page:Camera camera].<br />
  447. The render is done to a previously specified [page:WebGLRenderTarget renderTarget]
  448. set by calling [page:WebGLRenderer.setRenderTarget .setRenderTarget] or to the canvas as usual.<br />
  449. By default render buffers are cleared before rendering but you can prevent
  450. this by setting the property [page:WebGLRenderer.autoClear autoClear] to
  451. false. If you want to prevent only certain buffers being cleared you can
  452. set either the [page:WebGLRenderer.autoClearColor autoClearColor],
  453. [page:WebGLRenderer.autoClearStencil autoClearStencil] or
  454. [page:WebGLRenderer.autoClearDepth autoClearDepth] properties to false. To
  455. forcibly clear one or more buffers call [page:WebGLRenderer.clear .clear].
  456. </p>
  457. <h3>[method:undefined resetState]()</h3>
  458. <p>
  459. Can be used to reset the internal WebGL state. This method is mostly
  460. relevant for applications which share a single WebGL context across
  461. multiple WebGL libraries.
  462. </p>
  463. <h3>[method:undefined setAnimationLoop]( [param:Function callback] )</h3>
  464. <p>
  465. [page:Function callback] — The function will be called every available
  466. frame. If `null` is passed it will stop any already ongoing animation.
  467. </p>
  468. <p>
  469. A built in function that can be used instead of
  470. [link:https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame].
  471. For WebXR projects this function must be used.
  472. </p>
  473. <h3>[method:undefined setClearAlpha]( [param:Float alpha] )</h3>
  474. <p>Sets the clear alpha. Valid input is a float between `0.0` and `1.0`.</p>
  475. <h3>
  476. [method:undefined setClearColor]( [param:Color color], [param:Float alpha] )
  477. </h3>
  478. <p>Sets the clear color and opacity.</p>
  479. <h3>[method:undefined setPixelRatio]( [param:number value] )</h3>
  480. <p>
  481. Sets device pixel ratio. This is usually used for HiDPI device to prevent
  482. blurring output canvas.
  483. </p>
  484. <h3>
  485. [method:undefined setRenderTarget]( [param:WebGLRenderTarget renderTarget],
  486. [param:Integer activeCubeFace], [param:Integer activeMipmapLevel] )
  487. </h3>
  488. <p>
  489. renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be
  490. activated. When `null` is given, the canvas is set as the active render
  491. target instead.<br />
  492. activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3,
  493. PZ 4, NZ 5) of [page:WebGLCubeRenderTarget]. When passing a
  494. [page:WebGLArrayRenderTarget] or [page:WebGL3DRenderTarget] this indicates
  495. the z layer to render in to (optional).<br />
  496. activeMipmapLevel -- Specifies the active mipmap level (optional).<br /><br />
  497. This method sets the active rendertarget.
  498. </p>
  499. <h3>
  500. [method:undefined setScissor]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
  501. [method:undefined setScissor]( [param:Vector4 vector] )
  502. </h3>
  503. <p>
  504. The x, y, width, and height parameters of the scissor region.<br />
  505. Optionally, a 4-component vector specifying the parameters of the
  506. region.<br /><br />
  507. Sets the scissor region from (x, y) to (x + width, y + height).<br />
  508. (x, y) is the lower-left corner of the scissor region.
  509. </p>
  510. <h3>[method:undefined setScissorTest]( [param:Boolean boolean] )</h3>
  511. <p>
  512. Enable or disable the scissor test. When this is enabled, only the pixels
  513. within the defined scissor area will be affected by further renderer
  514. actions.
  515. </p>
  516. <h3>[method:undefined setOpaqueSort]( [param:Function method] )</h3>
  517. <p>
  518. Sets the custom opaque sort function for the WebGLRenderLists. Pass null
  519. to use the default painterSortStable function.
  520. </p>
  521. <h3>[method:undefined setTransparentSort]( [param:Function method] )</h3>
  522. <p>
  523. Sets the custom transparent sort function for the WebGLRenderLists. Pass
  524. null to use the default reversePainterSortStable function.
  525. </p>
  526. <h3>
  527. [method:undefined setSize]( [param:Integer width], [param:Integer height], [param:Boolean updateStyle] )
  528. </h3>
  529. <p>
  530. Resizes the output canvas to (width, height) with device pixel ratio taken
  531. into account, and also sets the viewport to fit that size, starting in (0,
  532. 0). Setting [page:Boolean updateStyle] to false prevents any style changes
  533. to the output canvas.
  534. </p>
  535. <h3>
  536. [method:undefined setViewport]( [param:Integer x], [param:Integer y], [param:Integer width], [param:Integer height] )<br />
  537. [method:undefined setViewport]( [param:Vector4 vector] )
  538. </h3>
  539. <p>
  540. The x, y, width, and height parameters of the viewport.<br />
  541. Optionally, a 4-component vector specifying the parameters of a
  542. viewport.<br /><br />
  543. Sets the viewport to render from (x, y) to (x + width, y + height).<br />
  544. (x, y) is the lower-left corner of the region.
  545. </p>
  546. <h2>Source</h2>
  547. <p>
  548. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  549. </p>
  550. </body>
  551. </html>