CSS3DRenderer.html 6.0 KB

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