SVGRenderer.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SVGRenderer - 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. <h1 translate="no">SVGRenderer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This renderer an be used to render geometric data using SVG. The produced vector
  16. graphics are particular useful in the following use cases:</p>
  17. <ul>
  18. <li>Animated logos or icons.</li>
  19. <li>Interactive 2D/3D diagrams or graphs.</li>
  20. <li>Interactive maps.</li>
  21. <li>Complex or animated user interfaces.</li>
  22. </ul>
  23. <p><code>SVGRenderer</code> has various advantages. It produces crystal-clear and sharp output which
  24. is independent of the actual viewport resolution.SVG elements can be styled via CSS.
  25. And they have good accessibility since it's possible to add metadata like title or description
  26. (useful for search engines or screen readers).</p>
  27. <p>There are, however, some important limitations:</p>
  28. <ul>
  29. <li>No advanced shading.</li>
  30. <li>No texture support.</li>
  31. <li>No shadow support.</li>
  32. </ul></div>
  33. </header>
  34. <article>
  35. <h2 class="subsection-title">Import</h2>
  36. <p><span translate="no">SVGRenderer</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  37. <pre><code class="language-js">import { SVGRenderer } from 'three/addons/renderers/SVGRenderer.js';</code></pre>
  38. <div class="container-overview">
  39. <h2>Constructor</h2>
  40. <h3 class="name name-method" id="SVGRenderer" translate="no">new <a href="#SVGRenderer">SVGRenderer</a><span class="signature">()</span> </h3>
  41. <div class="method">
  42. <div class="description">
  43. <p>Constructs a new SVG renderer.</p>
  44. </div>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <h3 class="name" id="autoClear" translate="no">.<a href="#autoClear">autoClear</a><span class="type-signature"> : boolean</span> </h3>
  50. <div class="description">
  51. <p>Whether to automatically perform a clear before a render call or not.</p>
  52. <p>Default is <code>true</code>.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="domElement" translate="no">.<a href="#domElement">domElement</a><span class="type-signature"> : SVGSVGElement</span> </h3>
  57. <div class="description">
  58. <p>The DOM where the renderer appends its child-elements.</p>
  59. </div>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="info" translate="no">.<a href="#info">info</a><span class="type-signature"> : Object</span> </h3>
  63. <div class="description">
  64. <p>Provides information about the number of
  65. rendered vertices and faces.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="outputColorSpace" translate="no">.<a href="#outputColorSpace">outputColorSpace</a><span class="type-signature"> : <a href="global.html#SRGBColorSpace">SRGBColorSpace</a> | <a href="global.html#LinearSRGBColorSpace">LinearSRGBColorSpace</a></span> </h3>
  70. <div class="description">
  71. <p>The output color space.</p>
  72. <p>Default is <code>SRGBColorSpace</code>.</p>
  73. </div>
  74. </div>
  75. <div class="member">
  76. <h3 class="name" id="overdraw" translate="no">.<a href="#overdraw">overdraw</a><span class="type-signature"> : number</span> </h3>
  77. <div class="description">
  78. <p>Number of fractional pixels to enlarge polygons in order to
  79. prevent anti-aliasing gaps. Range is <code>[0,1]</code>.</p>
  80. <p>Default is <code>0.5</code>.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="sortElements" translate="no">.<a href="#sortElements">sortElements</a><span class="type-signature"> : boolean</span> </h3>
  85. <div class="description">
  86. <p>Whether to sort elements or not.</p>
  87. <p>Default is <code>true</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <h3 class="name" id="sortObjects" translate="no">.<a href="#sortObjects">sortObjects</a><span class="type-signature"> : boolean</span> </h3>
  92. <div class="description">
  93. <p>Whether to sort 3D objects or not.</p>
  94. <p>Default is <code>true</code>.</p>
  95. </div>
  96. </div>
  97. <h2 class="subsection-title">Methods</h2>
  98. <h3 class="name name-method" id="clear" translate="no">.<a href="#clear">clear</a><span class="signature">()</span> </h3>
  99. <div class="method">
  100. <div class="description">
  101. <p>Performs a manual clear with the defined clear color.</p>
  102. </div>
  103. </div>
  104. <h3 class="name name-method" id="getSize" translate="no">.<a href="#getSize">getSize</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
  105. <div class="method">
  106. <div class="description">
  107. <p>Returns an object containing the width and height of the renderer.</p>
  108. </div>
  109. <dl class="details">
  110. <dt class="tag-returns"><strong>Returns:</strong> The size of the renderer.</dt>
  111. </dl>
  112. </div>
  113. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( scene : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span> </h3>
  114. <div class="method">
  115. <div class="description">
  116. <p>Renders the given scene using the given camera.</p>
  117. </div>
  118. <table class="params">
  119. <tbody>
  120. <tr>
  121. <td class="name">
  122. <strong>scene</strong>
  123. </td>
  124. <td class="description last">
  125. <p>A scene or any other type of 3D object.</p>
  126. </td>
  127. </tr>
  128. <tr>
  129. <td class="name">
  130. <strong>camera</strong>
  131. </td>
  132. <td class="description last">
  133. <p>The camera.</p>
  134. </td>
  135. </tr>
  136. </tbody>
  137. </table>
  138. </div>
  139. <h3 class="name name-method" id="setClearColor" translate="no">.<a href="#setClearColor">setClearColor</a><span class="signature">( color : <span class="param-type">number | <a href="Color.html">Color</a> | string</span> )</span> </h3>
  140. <div class="method">
  141. <div class="description">
  142. <p>Sets the clear color.</p>
  143. </div>
  144. <table class="params">
  145. <tbody>
  146. <tr>
  147. <td class="name">
  148. <strong>color</strong>
  149. </td>
  150. <td class="description last">
  151. <p>The clear color to set.</p>
  152. </td>
  153. </tr>
  154. </tbody>
  155. </table>
  156. </div>
  157. <h3 class="name name-method" id="setPrecision" translate="no">.<a href="#setPrecision">setPrecision</a><span class="signature">( precision : <span class="param-type">number</span> )</span> </h3>
  158. <div class="method">
  159. <div class="description">
  160. <p>Sets the precision of the data used to create a paths.</p>
  161. </div>
  162. <table class="params">
  163. <tbody>
  164. <tr>
  165. <td class="name">
  166. <strong>precision</strong>
  167. </td>
  168. <td class="description last">
  169. <p>The precision to set.</p>
  170. </td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. </div>
  175. <h3 class="name name-method" id="setQuality" translate="no">.<a href="#setQuality">setQuality</a><span class="signature">( quality : <span class="param-type">'low' | 'high'</span> )</span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Sets the render quality. Setting to <code>high</code> means This value indicates that the browser
  179. tries to improve the SVG quality over rendering speed and geometric precision.</p>
  180. </div>
  181. <table class="params">
  182. <tbody>
  183. <tr>
  184. <td class="name">
  185. <strong>quality</strong>
  186. </td>
  187. <td class="description last">
  188. <p>The quality.</p>
  189. </td>
  190. </tr>
  191. </tbody>
  192. </table>
  193. </div>
  194. <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> )</span> </h3>
  195. <div class="method">
  196. <div class="description">
  197. <p>Resizes the renderer to the given width and height.</p>
  198. </div>
  199. <table class="params">
  200. <tbody>
  201. <tr>
  202. <td class="name">
  203. <strong>width</strong>
  204. </td>
  205. <td class="description last">
  206. <p>The width of the renderer.</p>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td class="name">
  211. <strong>height</strong>
  212. </td>
  213. <td class="description last">
  214. <p>The height of the renderer.</p>
  215. </td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <h2 class="subsection-title">Source</h2>
  221. <p>
  222. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/SVGRenderer.js" translate="no" target="_blank" rel="noopener">examples/jsm/renderers/SVGRenderer.js</a>
  223. </p>
  224. </article>
  225. </section>
  226. <script src="../scripts/linenumber.js"></script>
  227. <script src="../scripts/page.js"></script>
  228. </body>
  229. </html>
粤ICP备19079148号