CSS2DRenderer.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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">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">CSS2DRenderer~Parameters</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"><code>parameters</code></td>
  37. <td class="description last"><p>The parameters.</p></td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </div>
  42. </div>
  43. <h2 class="subsection-title">Properties</h2>
  44. <div class="member">
  45. <h3 class="name" id="domElement" translate="no">.<a href="#domElement">domElement</a><span class="type-signature"> : HTMLElement</span> </h3>
  46. <div class="description">
  47. <p>The DOM where the renderer appends its child-elements.</p>
  48. </div>
  49. </div>
  50. <div class="member">
  51. <h3 class="name" id="sortObjects" translate="no">.<a href="#sortObjects">sortObjects</a><span class="type-signature"> : boolean</span> </h3>
  52. <div class="description">
  53. <p>Controls whether the renderer assigns <code>z-index</code> values to CSS2DObject DOM elements.
  54. If set to <code>true</code>, z-index values are assigned first based on the <code>renderOrder</code>
  55. and secondly - the distance to the camera. If set to <code>false</code>, no z-index values are assigned.<br/>Default is <code>true</code>.</p>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Methods</h2>
  59. <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>
  60. <div class="method">
  61. <div class="description">
  62. <p>Returns an object containing the width and height of the renderer.</p>
  63. </div>
  64. <dl class="details">
  65. <dt class="tag-returns"><strong>Returns:</strong> The size of the renderer.</dt>
  66. </dl>
  67. </div>
  68. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( scene : <span class="param-type">Object3D</span>, camera : <span class="param-type">Camera</span> )</span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>Renders the given scene using the given camera.</p>
  72. </div>
  73. <table class="params">
  74. <tbody>
  75. <tr>
  76. <td class="name"><code>scene</code></td>
  77. <td class="description last"><p>A scene or any other type of 3D object.</p></td>
  78. </tr>
  79. <tr>
  80. <td class="name"><code>camera</code></td>
  81. <td class="description last"><p>The camera.</p></td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. </div>
  86. <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>
  87. <div class="method">
  88. <div class="description">
  89. <p>Resizes the renderer to the given width and height.</p>
  90. </div>
  91. <table class="params">
  92. <tbody>
  93. <tr>
  94. <td class="name"><code>width</code></td>
  95. <td class="description last"><p>The width of the renderer.</p></td>
  96. </tr>
  97. <tr>
  98. <td class="name"><code>height</code></td>
  99. <td class="description last"><p>The height of the renderer.</p></td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. </div>
  104. <h2 class="subsection-title">Type Definitions</h2>
  105. <div class="member">
  106. <h3 class="name" id="~Parameters" translate="no">.<a href="#~Parameters">Parameters</a> </h3>
  107. <div class="description">
  108. <p>Constructor parameters of <code>CSS2DRenderer</code>.</p>
  109. </div>
  110. <h5 class="subsection-title">Properties:</h5>
  111. <table class="props">
  112. <thead>
  113. <tr>
  114. <th>Name</th>
  115. <th>Type</th>
  116. <th>Attributes</th>
  117. <th class="last">Description</th>
  118. </tr>
  119. </thead>
  120. <tbody>
  121. <tr>
  122. <td class="name"><code>element</code></td>
  123. <td class="type">
  124. <span class="param-type">HTMLElement</span>
  125. </td>
  126. <td class="attributes">
  127. &lt;optional><br>
  128. </td>
  129. <td class="description last"><p>A DOM element where the renderer appends its child-elements.
  130. If not passed in here, a new div element will be created.</p></td>
  131. </tr>
  132. </tbody>
  133. </table>
  134. </div>
  135. <h2 class="subsection-title">Source</h2>
  136. <p>
  137. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS2DRenderer.js" target="_blank" rel="noopener" translate="no">examples/jsm/renderers/CSS2DRenderer.js</a>
  138. </p>
  139. </article>
  140. </section>
  141. <script src="../scripts/linenumber.js"></script>
  142. <script src="../scripts/page.js"></script>
  143. </body>
  144. </html>
粤ICP备19079148号