1
0

WebGLRenderer.html 26 KB

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