RenderTarget.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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>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>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>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="viewport" translate="no">.<a href="#viewport">viewport</a><span class="type-signature"> : <a href="Vector4.html">Vector4</a></span> </h3>
  166. <div class="description">
  167. <p>A rectangular area representing the render target's viewport.</p>
  168. <p>Default is <code>(0,0,width,height)</code>.</p>
  169. </div>
  170. </div>
  171. <div class="member">
  172. <h3 class="name" id="width" translate="no">.<a href="#width">width</a><span class="type-signature"> : number</span> </h3>
  173. <div class="description">
  174. <p>The width of the render target.</p>
  175. <p>Default is <code>1</code>.</p>
  176. </div>
  177. </div>
  178. <h2 class="subsection-title">Methods</h2>
  179. <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>
  180. <div class="method">
  181. <div class="description">
  182. <p>Returns a new render target with copied values from this instance.</p>
  183. </div>
  184. <dl class="details">
  185. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  186. </dl>
  187. </div>
  188. <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>
  189. <div class="method">
  190. <div class="description">
  191. <p>Copies the settings of the given render target. This is a structural copy so
  192. no resources are shared between render targets after the copy. That includes
  193. all MRT textures and the depth texture.</p>
  194. </div>
  195. <table class="params">
  196. <tbody>
  197. <tr>
  198. <td class="name">
  199. <strong>source</strong>
  200. </td>
  201. <td class="description last">
  202. <p>The render target to copy.</p>
  203. </td>
  204. </tr>
  205. </tbody>
  206. </table>
  207. <dl class="details">
  208. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  209. </dl>
  210. </div>
  211. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  212. <div class="method">
  213. <div class="description">
  214. <p>Frees the GPU-related resources allocated by this instance. Call this
  215. method whenever this instance is no longer used in your app.</p>
  216. </div>
  217. <h5>Fires:</h5>
  218. <ul>
  219. <li>RenderTarget#event:dispose</li>
  220. </ul>
  221. </div>
  222. <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>
  223. <div class="method">
  224. <div class="description">
  225. <p>Sets the size of this render target.</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name">
  231. <strong>width</strong>
  232. </td>
  233. <td class="description last">
  234. <p>The width.</p>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td class="name">
  239. <strong>height</strong>
  240. </td>
  241. <td class="description last">
  242. <p>The height.</p>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td class="name">
  247. <strong>depth</strong>
  248. </td>
  249. <td class="description last">
  250. <p>The depth.</p>
  251. <p>Default is <code>1</code>.</p>
  252. </td>
  253. </tr>
  254. </tbody>
  255. </table>
  256. </div>
  257. <h2 class="subsection-title">Type Definitions</h2>
  258. <div class="member">
  259. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  260. <div class="description">
  261. <p>Render target options.</p>
  262. </div>
  263. <table class="props">
  264. <tbody>
  265. <tr>
  266. <td class="name">
  267. <strong>generateMipmaps</strong>
  268. <br>
  269. <span class="param-type">boolean</span>
  270. </td>
  271. <td class="description last">
  272. <p>Whether to generate mipmaps or not.</p>
  273. <p>Default is <code>false</code>.</p>
  274. </td>
  275. </tr>
  276. <tr>
  277. <td class="name">
  278. <strong>magFilter</strong>
  279. <br>
  280. <span class="param-type">number</span>
  281. </td>
  282. <td class="description last">
  283. <p>The mag filter.</p>
  284. <p>Default is <code>LinearFilter</code>.</p>
  285. </td>
  286. </tr>
  287. <tr>
  288. <td class="name">
  289. <strong>minFilter</strong>
  290. <br>
  291. <span class="param-type">number</span>
  292. </td>
  293. <td class="description last">
  294. <p>The min filter.</p>
  295. <p>Default is <code>LinearFilter</code>.</p>
  296. </td>
  297. </tr>
  298. <tr>
  299. <td class="name">
  300. <strong>format</strong>
  301. <br>
  302. <span class="param-type">number</span>
  303. </td>
  304. <td class="description last">
  305. <p>The texture format.</p>
  306. <p>Default is <code>RGBAFormat</code>.</p>
  307. </td>
  308. </tr>
  309. <tr>
  310. <td class="name">
  311. <strong>type</strong>
  312. <br>
  313. <span class="param-type">number</span>
  314. </td>
  315. <td class="description last">
  316. <p>The texture type.</p>
  317. <p>Default is <code>UnsignedByteType</code>.</p>
  318. </td>
  319. </tr>
  320. <tr>
  321. <td class="name">
  322. <strong>internalFormat</strong>
  323. <br>
  324. <span class="param-type">string</span>
  325. </td>
  326. <td class="description last">
  327. <p>The texture's internal format.</p>
  328. <p>Default is <code>null</code>.</p>
  329. </td>
  330. </tr>
  331. <tr>
  332. <td class="name">
  333. <strong>wrapS</strong>
  334. <br>
  335. <span class="param-type">number</span>
  336. </td>
  337. <td class="description last">
  338. <p>The texture's uv wrapping mode.</p>
  339. <p>Default is <code>ClampToEdgeWrapping</code>.</p>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td class="name">
  344. <strong>wrapT</strong>
  345. <br>
  346. <span class="param-type">number</span>
  347. </td>
  348. <td class="description last">
  349. <p>The texture's uv wrapping mode.</p>
  350. <p>Default is <code>ClampToEdgeWrapping</code>.</p>
  351. </td>
  352. </tr>
  353. <tr>
  354. <td class="name">
  355. <strong>anisotropy</strong>
  356. <br>
  357. <span class="param-type">number</span>
  358. </td>
  359. <td class="description last">
  360. <p>The texture's anisotropy value.</p>
  361. <p>Default is <code>1</code>.</p>
  362. </td>
  363. </tr>
  364. <tr>
  365. <td class="name">
  366. <strong>colorSpace</strong>
  367. <br>
  368. <span class="param-type">string</span>
  369. </td>
  370. <td class="description last">
  371. <p>The texture's color space.</p>
  372. <p>Default is <code>NoColorSpace</code>.</p>
  373. </td>
  374. </tr>
  375. <tr>
  376. <td class="name">
  377. <strong>depthBuffer</strong>
  378. <br>
  379. <span class="param-type">boolean</span>
  380. </td>
  381. <td class="description last">
  382. <p>Whether to allocate a depth buffer or not.</p>
  383. <p>Default is <code>true</code>.</p>
  384. </td>
  385. </tr>
  386. <tr>
  387. <td class="name">
  388. <strong>stencilBuffer</strong>
  389. <br>
  390. <span class="param-type">boolean</span>
  391. </td>
  392. <td class="description last">
  393. <p>Whether to allocate a stencil buffer or not.</p>
  394. <p>Default is <code>false</code>.</p>
  395. </td>
  396. </tr>
  397. <tr>
  398. <td class="name">
  399. <strong>resolveDepthBuffer</strong>
  400. <br>
  401. <span class="param-type">boolean</span>
  402. </td>
  403. <td class="description last">
  404. <p>Whether to resolve the depth buffer or not.</p>
  405. <p>Default is <code>true</code>.</p>
  406. </td>
  407. </tr>
  408. <tr>
  409. <td class="name">
  410. <strong>resolveStencilBuffer</strong>
  411. <br>
  412. <span class="param-type">boolean</span>
  413. </td>
  414. <td class="description last">
  415. <p>Whether to resolve the stencil buffer or not.</p>
  416. <p>Default is <code>true</code>.</p>
  417. </td>
  418. </tr>
  419. <tr>
  420. <td class="name">
  421. <strong>depthTexture</strong>
  422. <br>
  423. <span class="param-type"><a href="Texture.html">Texture</a></span>
  424. </td>
  425. <td class="description last">
  426. <p>Reference to a depth texture.</p>
  427. <p>Default is <code>null</code>.</p>
  428. </td>
  429. </tr>
  430. <tr>
  431. <td class="name">
  432. <strong>samples</strong>
  433. <br>
  434. <span class="param-type">number</span>
  435. </td>
  436. <td class="description last">
  437. <p>The MSAA samples count.</p>
  438. <p>Default is <code>0</code>.</p>
  439. </td>
  440. </tr>
  441. <tr>
  442. <td class="name">
  443. <strong>count</strong>
  444. <br>
  445. <span class="param-type">number</span>
  446. </td>
  447. <td class="description last">
  448. <p>Defines the number of color attachments . Must be at least <code>1</code>.</p>
  449. <p>Default is <code>1</code>.</p>
  450. </td>
  451. </tr>
  452. <tr>
  453. <td class="name">
  454. <strong>depth</strong>
  455. <br>
  456. <span class="param-type">number</span>
  457. </td>
  458. <td class="description last">
  459. <p>The texture depth.</p>
  460. <p>Default is <code>1</code>.</p>
  461. </td>
  462. </tr>
  463. <tr>
  464. <td class="name">
  465. <strong>multiview</strong>
  466. <br>
  467. <span class="param-type">boolean</span>
  468. </td>
  469. <td class="description last">
  470. <p>Whether this target is used for multiview rendering.</p>
  471. <p>Default is <code>false</code>.</p>
  472. </td>
  473. </tr>
  474. </tbody>
  475. </table>
  476. </div>
  477. <h2 class="subsection-title">Source</h2>
  478. <p>
  479. <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>
  480. </p>
  481. </article>
  482. </section>
  483. <script src="../scripts/linenumber.js"></script>
  484. <script src="../scripts/page.js"></script>
  485. </body>
  486. </html>
粤ICP备19079148号