CSS3DRenderer.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CSS3DRenderer - 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">CSS3DRenderer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This renderer can be used to apply hierarchical 3D transformations to DOM elements
  16. via the CSS3 <a href="https://www.w3schools.com/cssref/css3_pr_transform.asp" target="_blank" rel="noopener">transform</a> property.
  17. <code>CSS3DRenderer</code> is particularly interesting if you want to apply 3D effects to a website without
  18. canvas based rendering. It can also be used in order to combine DOM elements with WebGLcontent.</p>
  19. <p>There are, however, some important limitations:</p>
  20. <ul>
  21. <li>It's not possible to use the material system of <em>three.js</em>.</li>
  22. <li>It's also not possible to use geometries.</li>
  23. <li>The renderer only supports 100% browser and display zoom.</li>
  24. </ul>
  25. <p>So <code>CSS3DRenderer</code> is just focused on ordinary DOM elements. These elements are wrapped into special
  26. 3D objects (<a href="CSS3DObject.html">CSS3DObject</a> or <a href="CSS3DSprite.html">CSS3DSprite</a>) and then added to the scene graph.</p></div>
  27. </header>
  28. <article>
  29. <h2 class="subsection-title">Import</h2>
  30. <p><span translate="no">CSS3DRenderer</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>
  31. <pre><code class="language-js">import { CSS3DRenderer } from 'three/addons/renderers/CSS3DRenderer.js';</code></pre>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="CSS3DRenderer" translate="no">new <a href="#CSS3DRenderer">CSS3DRenderer</a><span class="signature">( parameters : <span class="param-type"><a href="CSS3DRenderer.html#~Parameters">CSS3DRenderer~Parameters</a></span> )</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new CSS3D renderer.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name">
  43. <strong>parameters</strong>
  44. </td>
  45. <td class="description last">
  46. <p>The parameters.</p>
  47. </td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. <h2 class="subsection-title">Properties</h2>
  54. <div class="member">
  55. <h3 class="name" id="domElement" translate="no">.<a href="#domElement">domElement</a><span class="type-signature"> : HTMLElement</span> </h3>
  56. <div class="description">
  57. <p>The DOM where the renderer appends its child-elements.</p>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Methods</h2>
  61. <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>
  62. <div class="method">
  63. <div class="description">
  64. <p>Returns an object containing the width and height of the renderer.</p>
  65. </div>
  66. <dl class="details">
  67. <dt class="tag-returns"><strong>Returns:</strong> The size of the renderer.</dt>
  68. </dl>
  69. </div>
  70. <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>
  71. <div class="method">
  72. <div class="description">
  73. <p>Renders the given scene using the given camera.</p>
  74. </div>
  75. <table class="params">
  76. <tbody>
  77. <tr>
  78. <td class="name">
  79. <strong>scene</strong>
  80. </td>
  81. <td class="description last">
  82. <p>A scene or any other type of 3D object.</p>
  83. </td>
  84. </tr>
  85. <tr>
  86. <td class="name">
  87. <strong>camera</strong>
  88. </td>
  89. <td class="description last">
  90. <p>The camera.</p>
  91. </td>
  92. </tr>
  93. </tbody>
  94. </table>
  95. </div>
  96. <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>
  97. <div class="method">
  98. <div class="description">
  99. <p>Resizes the renderer to the given width and height.</p>
  100. </div>
  101. <table class="params">
  102. <tbody>
  103. <tr>
  104. <td class="name">
  105. <strong>width</strong>
  106. </td>
  107. <td class="description last">
  108. <p>The width of the renderer.</p>
  109. </td>
  110. </tr>
  111. <tr>
  112. <td class="name">
  113. <strong>height</strong>
  114. </td>
  115. <td class="description last">
  116. <p>The height of the renderer.</p>
  117. </td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. </div>
  122. <h2 class="subsection-title">Type Definitions</h2>
  123. <div class="member">
  124. <h3 class="name" id="~Parameters" translate="no">.<a href="#~Parameters">Parameters</a> </h3>
  125. <div class="description">
  126. <p>Constructor parameters of <code>CSS3DRenderer</code>.</p>
  127. </div>
  128. <table class="props">
  129. <tbody>
  130. <tr>
  131. <td class="name">
  132. <strong>element</strong>
  133. <br>
  134. <span class="param-type">HTMLElement</span>
  135. </td>
  136. <td class="description last">
  137. <p>A DOM element where the renderer appends its child-elements.
  138. If not passed in here, a new div element will be created.</p>
  139. </td>
  140. </tr>
  141. </tbody>
  142. </table>
  143. </div>
  144. <h2 class="subsection-title">Source</h2>
  145. <p>
  146. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS3DRenderer.js" translate="no" target="_blank" rel="noopener">examples/jsm/renderers/CSS3DRenderer.js</a>
  147. </p>
  148. </article>
  149. </section>
  150. <script src="../scripts/linenumber.js"></script>
  151. <script src="../scripts/page.js"></script>
  152. </body>
  153. </html>
粤ICP备19079148号