RenderTarget.html 17 KB

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