CSS2DRenderer.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CSS2DRenderer - 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">CSS2DRenderer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This renderer is a simplified version of <a href="CSS3DRenderer.html">CSS3DRenderer</a>. The only transformation that is
  16. supported is translation.</p>
  17. <p>The renderer is very useful if you want to combine HTML based labels with 3D objects. Here too,
  18. the respective DOM elements are wrapped into an instance of <a href="CSS2DObject.html">CSS2DObject</a> and added to the
  19. scene graph. All other types of renderable 3D objects (like meshes or point clouds) are ignored.</p>
  20. <p><code>CSS2DRenderer</code> only supports 100% browser and display zoom.</p></div>
  21. </header>
  22. <article>
  23. <h2 class="subsection-title">Import</h2>
  24. <p><span translate="no">CSS2DRenderer</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>
  25. <pre><code class="language-js">import { CSS2DRenderer } from 'three/addons/renderers/CSS2DRenderer.js';</code></pre>
  26. <div class="container-overview">
  27. <h2>Constructor</h2>
  28. <h3 class="name name-method" id="CSS2DRenderer" translate="no">new <a href="#CSS2DRenderer">CSS2DRenderer</a><span class="signature">( parameters : <span class="param-type"><a href="CSS2DRenderer.html#~Parameters">CSS2DRenderer~Parameters</a></span> )</span> </h3>
  29. <div class="method">
  30. <div class="description">
  31. <p>Constructs a new CSS2D renderer.</p>
  32. </div>
  33. <table class="params">
  34. <tbody>
  35. <tr>
  36. <td class="name">
  37. <strong>parameters</strong>
  38. </td>
  39. <td class="description last">
  40. <p>The parameters.</p>
  41. </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="domElement" translate="no">.<a href="#domElement">domElement</a><span class="type-signature"> : HTMLElement</span> </h3>
  50. <div class="description">
  51. <p>The DOM where the renderer appends its child-elements.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="sortObjects" translate="no">.<a href="#sortObjects">sortObjects</a><span class="type-signature"> : boolean</span> </h3>
  56. <div class="description">
  57. <p>Controls whether the renderer assigns <code>z-index</code> values to CSS2DObject DOM elements.
  58. If set to <code>true</code>, z-index values are assigned first based on the <code>renderOrder</code>
  59. and secondly - the distance to the camera. If set to <code>false</code>, no z-index values are assigned.</p>
  60. <p>Default is <code>true</code>.</p>
  61. </div>
  62. </div>
  63. <h2 class="subsection-title">Methods</h2>
  64. <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>
  65. <div class="method">
  66. <div class="description">
  67. <p>Returns an object containing the width and height of the renderer.</p>
  68. </div>
  69. <dl class="details">
  70. <dt class="tag-returns"><strong>Returns:</strong> The size of the renderer.</dt>
  71. </dl>
  72. </div>
  73. <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>
  74. <div class="method">
  75. <div class="description">
  76. <p>Renders the given scene using the given camera.</p>
  77. </div>
  78. <table class="params">
  79. <tbody>
  80. <tr>
  81. <td class="name">
  82. <strong>scene</strong>
  83. </td>
  84. <td class="description last">
  85. <p>A scene or any other type of 3D object.</p>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td class="name">
  90. <strong>camera</strong>
  91. </td>
  92. <td class="description last">
  93. <p>The camera.</p>
  94. </td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </div>
  99. <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>
  100. <div class="method">
  101. <div class="description">
  102. <p>Resizes the renderer to the given width and height.</p>
  103. </div>
  104. <table class="params">
  105. <tbody>
  106. <tr>
  107. <td class="name">
  108. <strong>width</strong>
  109. </td>
  110. <td class="description last">
  111. <p>The width of the renderer.</p>
  112. </td>
  113. </tr>
  114. <tr>
  115. <td class="name">
  116. <strong>height</strong>
  117. </td>
  118. <td class="description last">
  119. <p>The height of the renderer.</p>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. </div>
  125. <h2 class="subsection-title">Type Definitions</h2>
  126. <div class="member">
  127. <h3 class="name" id="~Parameters" translate="no">.<a href="#~Parameters">Parameters</a> </h3>
  128. <div class="description">
  129. <p>Constructor parameters of <code>CSS2DRenderer</code>.</p>
  130. </div>
  131. <table class="props">
  132. <tbody>
  133. <tr>
  134. <td class="name">
  135. <strong>element</strong>
  136. <br>
  137. <span class="param-type">HTMLElement</span>
  138. </td>
  139. <td class="description last">
  140. <p>A DOM element where the renderer appends its child-elements.
  141. If not passed in here, a new div element will be created.</p>
  142. </td>
  143. </tr>
  144. </tbody>
  145. </table>
  146. </div>
  147. <h2 class="subsection-title">Source</h2>
  148. <p>
  149. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS2DRenderer.js" translate="no" target="_blank" rel="noopener">examples/jsm/renderers/CSS2DRenderer.js</a>
  150. </p>
  151. </article>
  152. </section>
  153. <script src="../scripts/linenumber.js"></script>
  154. <script src="../scripts/page.js"></script>
  155. </body>
  156. </html>
粤ICP备19079148号