RenderTarget.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>RenderTarget - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → </p>
  13. <h1 translate="no">RenderTarget</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A render target is a buffer where the video card draws pixels for a scene
  17. that is being rendered in the background. It is used in different effects,
  18. such as applying postprocessing to a rendered image before displaying it
  19. on the screen.</p></div>
  20. </header>
  21. <article>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="RenderTarget" translate="no">new <a href="#RenderTarget">RenderTarget</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span>, options : <span class="param-type">RenderTarget~Options</span> )</span> </h3>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new render target.</p>
  28. </div>
  29. <table class="params">
  30. <tbody>
  31. <tr>
  32. <td class="name"><code>width</code></td>
  33. <td class="description last"><p>The width of the render target.<br/>Default is <code>1</code>.</p></td>
  34. </tr>
  35. <tr>
  36. <td class="name"><code>height</code></td>
  37. <td class="description last"><p>The height of the render target.<br/>Default is <code>1</code>.</p></td>
  38. </tr>
  39. <tr>
  40. <td class="name"><code>options</code></td>
  41. <td class="description last"><p>The configuration object.</p></td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <h3 class="name" id="depth" translate="no">.<a href="#depth">depth</a><span class="type-signature"> : number</span> </h3>
  50. <div class="description">
  51. <p>The depth of the render target.<br/>Default is <code>1</code>.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="depthBuffer" translate="no">.<a href="#depthBuffer">depthBuffer</a><span class="type-signature"> : boolean</span> </h3>
  56. <div class="description">
  57. <p>Whether to allocate a depth buffer or not.<br/>Default is <code>true</code>.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="depthTexture" translate="no">.<a href="#depthTexture">depthTexture</a><span class="type-signature"> : <a href="DepthTexture.html">DepthTexture</a></span> </h3>
  62. <div class="description">
  63. <p>Instead of saving the depth in a renderbuffer, a texture
  64. can be used instead which is useful for further processing
  65. e.g. in context of post-processing.<br/>Default is <code>null</code>.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="height" translate="no">.<a href="#height">height</a><span class="type-signature"> : number</span> </h3>
  70. <div class="description">
  71. <p>The height of the render target.<br/>Default is <code>1</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="isRenderTarget" translate="no">.<a href="#isRenderTarget">isRenderTarget</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  76. <div class="description">
  77. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="multiview" translate="no">.<a href="#multiview">multiview</a><span class="type-signature"> : boolean</span> </h3>
  82. <div class="description">
  83. <p>Whether to this target is used in multiview rendering.<br/>Default is <code>false</code>.</p>
  84. </div>
  85. </div>
  86. <div class="member">
  87. <h3 class="name" id="resolveDepthBuffer" translate="no">.<a href="#resolveDepthBuffer">resolveDepthBuffer</a><span class="type-signature"> : boolean</span> </h3>
  88. <div class="description">
  89. <p>Whether to resolve the depth buffer or not.<br/>Default is <code>true</code>.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="resolveStencilBuffer" translate="no">.<a href="#resolveStencilBuffer">resolveStencilBuffer</a><span class="type-signature"> : boolean</span> </h3>
  94. <div class="description">
  95. <p>Whether to resolve the stencil buffer or not.<br/>Default is <code>true</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="samples" translate="no">.<a href="#samples">samples</a><span class="type-signature"> : number</span> </h3>
  100. <div class="description">
  101. <p>The number of MSAA samples.</p>
  102. <p>A value of <code>0</code> disables MSAA.<br/>Default is <code>0</code>.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="scissor" translate="no">.<a href="#scissor">scissor</a><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
  107. <div class="description">
  108. <p>A rectangular area inside the render target's viewport. Fragments that are
  109. outside the area will be discarded.<br/>Default is <code>(0,0,width,height)</code>.</p>
  110. </div>
  111. </div>
  112. <div class="member">
  113. <h3 class="name" id="scissorTest" translate="no">.<a href="#scissorTest">scissorTest</a><span class="type-signature"> : boolean</span> </h3>
  114. <div class="description">
  115. <p>Indicates whether the scissor test should be enabled when rendering into
  116. this render target or not.<br/>Default is <code>false</code>.</p>
  117. </div>
  118. </div>
  119. <div class="member">
  120. <h3 class="name" id="stencilBuffer" translate="no">.<a href="#stencilBuffer">stencilBuffer</a><span class="type-signature"> : boolean</span> </h3>
  121. <div class="description">
  122. <p>Whether to allocate a stencil buffer or not.<br/>Default is <code>false</code>.</p>
  123. </div>
  124. </div>
  125. <div class="member">
  126. <h3 class="name" id="texture" translate="no">.<a href="#texture">texture</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  127. <div class="description">
  128. <p>The texture representing the default color attachment.</p>
  129. </div>
  130. </div>
  131. <div class="member">
  132. <h3 class="name" id="textures" translate="no">.<a href="#textures">textures</a><span class="type-signature"> : Array.&lt;<a href="Texture.html">Texture</a>></span> </h3>
  133. <div class="description">
  134. <p>An array of textures. Each color attachment is represented as a separate texture.
  135. Has at least a single entry for the default color attachment.</p>
  136. </div>
  137. </div>
  138. <div class="member">
  139. <h3 class="name" id="viewport" translate="no">.<a href="#viewport">viewport</a><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
  140. <div class="description">
  141. <p>A rectangular area representing the render target's viewport.<br/>Default is <code>(0,0,width,height)</code>.</p>
  142. </div>
  143. </div>
  144. <div class="member">
  145. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  146. <div class="description">
  147. <p>The width of the render target.<br/>Default is <code>1</code>.</p>
  148. </div>
  149. </div>
  150. <h2 class="subsection-title">Methods</h2>
  151. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  152. <div class="method">
  153. <div class="description">
  154. <p>Returns a new render target with copied values from this instance.</p>
  155. </div>
  156. <dl class="details">
  157. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  158. </dl>
  159. </div>
  160. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type">RenderTarget</span> )</span><span class="type-signature"> : <a href="RenderTarget.html">RenderTarget</a></span> </h3>
  161. <div class="method">
  162. <div class="description">
  163. <p>Copies the settings of the given render target. This is a structural copy so
  164. no resources are shared between render targets after the copy. That includes
  165. all MRT textures and the depth texture.</p>
  166. </div>
  167. <table class="params">
  168. <tbody>
  169. <tr>
  170. <td class="name"><code>source</code></td>
  171. <td class="description last"><p>The render target to copy.</p></td>
  172. </tr>
  173. </tbody>
  174. </table>
  175. <dl class="details">
  176. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  177. </dl>
  178. </div>
  179. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  180. <div class="method">
  181. <div class="description">
  182. <p>Frees the GPU-related resources allocated by this instance. Call this
  183. method whenever this instance is no longer used in your app.</p>
  184. </div>
  185. <h5>Fires:</h5>
  186. <ul>
  187. <li>RenderTarget#event:dispose</li>
  188. </ul>
  189. </div>
  190. <h3 class="name name-method" id="setSize" translate="no">.<a href="#setSize">setSize</a><span class="signature">( width : <span class="param-type">number</span>, height : <span class="param-type">number</span>, depth : <span class="param-type">number</span> )</span> </h3>
  191. <div class="method">
  192. <div class="description">
  193. <p>Sets the size of this render target.</p>
  194. </div>
  195. <table class="params">
  196. <tbody>
  197. <tr>
  198. <td class="name"><code>width</code></td>
  199. <td class="description last"><p>The width.</p></td>
  200. </tr>
  201. <tr>
  202. <td class="name"><code>height</code></td>
  203. <td class="description last"><p>The height.</p></td>
  204. </tr>
  205. <tr>
  206. <td class="name"><code>depth</code></td>
  207. <td class="description last"><p>The depth.<br/>Default is <code>1</code>.</p></td>
  208. </tr>
  209. </tbody>
  210. </table>
  211. </div>
  212. <h2 class="subsection-title">Type Definitions</h2>
  213. <div class="member">
  214. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  215. <div class="description">
  216. <p>Render target options.</p>
  217. </div>
  218. <h5 class="subsection-title">Properties:</h5>
  219. <table class="props">
  220. <thead>
  221. <tr>
  222. <th>Name</th>
  223. <th>Type</th>
  224. <th>Attributes</th>
  225. <th>Default</th>
  226. <th class="last">Description</th>
  227. </tr>
  228. </thead>
  229. <tbody>
  230. <tr>
  231. <td class="name"><code>generateMipmaps</code></td>
  232. <td class="type">
  233. <span class="param-type">boolean</span>
  234. </td>
  235. <td class="attributes">
  236. &lt;optional><br>
  237. </td>
  238. <td class="default">
  239. false
  240. </td>
  241. <td class="description last"><p>Whether to generate mipmaps or not.</p></td>
  242. </tr>
  243. <tr>
  244. <td class="name"><code>magFilter</code></td>
  245. <td class="type">
  246. <span class="param-type">number</span>
  247. </td>
  248. <td class="attributes">
  249. &lt;optional><br>
  250. </td>
  251. <td class="default">
  252. LinearFilter
  253. </td>
  254. <td class="description last"><p>The mag filter.</p></td>
  255. </tr>
  256. <tr>
  257. <td class="name"><code>minFilter</code></td>
  258. <td class="type">
  259. <span class="param-type">number</span>
  260. </td>
  261. <td class="attributes">
  262. &lt;optional><br>
  263. </td>
  264. <td class="default">
  265. LinearFilter
  266. </td>
  267. <td class="description last"><p>The min filter.</p></td>
  268. </tr>
  269. <tr>
  270. <td class="name"><code>format</code></td>
  271. <td class="type">
  272. <span class="param-type">number</span>
  273. </td>
  274. <td class="attributes">
  275. &lt;optional><br>
  276. </td>
  277. <td class="default">
  278. RGBAFormat
  279. </td>
  280. <td class="description last"><p>The texture format.</p></td>
  281. </tr>
  282. <tr>
  283. <td class="name"><code>type</code></td>
  284. <td class="type">
  285. <span class="param-type">number</span>
  286. </td>
  287. <td class="attributes">
  288. &lt;optional><br>
  289. </td>
  290. <td class="default">
  291. UnsignedByteType
  292. </td>
  293. <td class="description last"><p>The texture type.</p></td>
  294. </tr>
  295. <tr>
  296. <td class="name"><code>internalFormat</code></td>
  297. <td class="type">
  298. <span class="param-type">string</span>
  299. </td>
  300. <td class="attributes">
  301. &lt;optional><br>
  302. &lt;nullable><br>
  303. </td>
  304. <td class="default">
  305. null
  306. </td>
  307. <td class="description last"><p>The texture's internal format.</p></td>
  308. </tr>
  309. <tr>
  310. <td class="name"><code>wrapS</code></td>
  311. <td class="type">
  312. <span class="param-type">number</span>
  313. </td>
  314. <td class="attributes">
  315. &lt;optional><br>
  316. </td>
  317. <td class="default">
  318. ClampToEdgeWrapping
  319. </td>
  320. <td class="description last"><p>The texture's uv wrapping mode.</p></td>
  321. </tr>
  322. <tr>
  323. <td class="name"><code>wrapT</code></td>
  324. <td class="type">
  325. <span class="param-type">number</span>
  326. </td>
  327. <td class="attributes">
  328. &lt;optional><br>
  329. </td>
  330. <td class="default">
  331. ClampToEdgeWrapping
  332. </td>
  333. <td class="description last"><p>The texture's uv wrapping mode.</p></td>
  334. </tr>
  335. <tr>
  336. <td class="name"><code>anisotropy</code></td>
  337. <td class="type">
  338. <span class="param-type">number</span>
  339. </td>
  340. <td class="attributes">
  341. &lt;optional><br>
  342. </td>
  343. <td class="default">
  344. 1
  345. </td>
  346. <td class="description last"><p>The texture's anisotropy value.</p></td>
  347. </tr>
  348. <tr>
  349. <td class="name"><code>colorSpace</code></td>
  350. <td class="type">
  351. <span class="param-type">string</span>
  352. </td>
  353. <td class="attributes">
  354. &lt;optional><br>
  355. </td>
  356. <td class="default">
  357. NoColorSpace
  358. </td>
  359. <td class="description last"><p>The texture's color space.</p></td>
  360. </tr>
  361. <tr>
  362. <td class="name"><code>depthBuffer</code></td>
  363. <td class="type">
  364. <span class="param-type">boolean</span>
  365. </td>
  366. <td class="attributes">
  367. &lt;optional><br>
  368. </td>
  369. <td class="default">
  370. true
  371. </td>
  372. <td class="description last"><p>Whether to allocate a depth buffer or not.</p></td>
  373. </tr>
  374. <tr>
  375. <td class="name"><code>stencilBuffer</code></td>
  376. <td class="type">
  377. <span class="param-type">boolean</span>
  378. </td>
  379. <td class="attributes">
  380. &lt;optional><br>
  381. </td>
  382. <td class="default">
  383. false
  384. </td>
  385. <td class="description last"><p>Whether to allocate a stencil buffer or not.</p></td>
  386. </tr>
  387. <tr>
  388. <td class="name"><code>resolveDepthBuffer</code></td>
  389. <td class="type">
  390. <span class="param-type">boolean</span>
  391. </td>
  392. <td class="attributes">
  393. &lt;optional><br>
  394. </td>
  395. <td class="default">
  396. true
  397. </td>
  398. <td class="description last"><p>Whether to resolve the depth buffer or not.</p></td>
  399. </tr>
  400. <tr>
  401. <td class="name"><code>resolveStencilBuffer</code></td>
  402. <td class="type">
  403. <span class="param-type">boolean</span>
  404. </td>
  405. <td class="attributes">
  406. &lt;optional><br>
  407. </td>
  408. <td class="default">
  409. true
  410. </td>
  411. <td class="description last"><p>Whether to resolve the stencil buffer or not.</p></td>
  412. </tr>
  413. <tr>
  414. <td class="name"><code>depthTexture</code></td>
  415. <td class="type">
  416. <span class="param-type"><a href="Texture.html">Texture</a></span>
  417. </td>
  418. <td class="attributes">
  419. &lt;optional><br>
  420. &lt;nullable><br>
  421. </td>
  422. <td class="default">
  423. null
  424. </td>
  425. <td class="description last"><p>Reference to a depth texture.</p></td>
  426. </tr>
  427. <tr>
  428. <td class="name"><code>samples</code></td>
  429. <td class="type">
  430. <span class="param-type">number</span>
  431. </td>
  432. <td class="attributes">
  433. &lt;optional><br>
  434. </td>
  435. <td class="default">
  436. 0
  437. </td>
  438. <td class="description last"><p>The MSAA samples count.</p></td>
  439. </tr>
  440. <tr>
  441. <td class="name"><code>count</code></td>
  442. <td class="type">
  443. <span class="param-type">number</span>
  444. </td>
  445. <td class="attributes">
  446. &lt;optional><br>
  447. </td>
  448. <td class="default">
  449. 1
  450. </td>
  451. <td class="description last"><p>Defines the number of color attachments . Must be at least <code>1</code>.</p></td>
  452. </tr>
  453. <tr>
  454. <td class="name"><code>depth</code></td>
  455. <td class="type">
  456. <span class="param-type">number</span>
  457. </td>
  458. <td class="attributes">
  459. &lt;optional><br>
  460. </td>
  461. <td class="default">
  462. 1
  463. </td>
  464. <td class="description last"><p>The texture depth.</p></td>
  465. </tr>
  466. <tr>
  467. <td class="name"><code>multiview</code></td>
  468. <td class="type">
  469. <span class="param-type">boolean</span>
  470. </td>
  471. <td class="attributes">
  472. &lt;optional><br>
  473. </td>
  474. <td class="default">
  475. false
  476. </td>
  477. <td class="description last"><p>Whether this target is used for multiview rendering.</p></td>
  478. </tr>
  479. </tbody>
  480. </table>
  481. </div>
  482. <h2 class="subsection-title">Source</h2>
  483. <p>
  484. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/RenderTarget.js" target="_blank" rel="noopener" translate="no">src/core/RenderTarget.js</a>
  485. </p>
  486. </article>
  487. </section>
  488. <script src="../scripts/linenumber.js"></script>
  489. <script src="../scripts/page.js"></script>
  490. </body>
  491. </html>
粤ICP备19079148号