CubeCamera.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CubeCamera - 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. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → </p>
  13. <h1 translate="no">CubeCamera</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A special type of camera that is positioned in 3D space to render its surroundings into a
  17. cube render target. The render target can then be used as an environment map for rendering
  18. realtime reflections in your scene.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">// Create cube render target
  21. const cubeRenderTarget = new THREE.WebGLCubeRenderTarget( 256, { generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter } );
  22. // Create cube camera
  23. const cubeCamera = new THREE.CubeCamera( 1, 100000, cubeRenderTarget );
  24. scene.add( cubeCamera );
  25. // Create car
  26. const chromeMaterial = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: cubeRenderTarget.texture } );
  27. const car = new THREE.Mesh( carGeometry, chromeMaterial );
  28. scene.add( car );
  29. // Update the render target cube
  30. car.visible = false;
  31. cubeCamera.position.copy( car.position );
  32. cubeCamera.update( renderer, scene );
  33. // Render the scene
  34. car.visible = true;
  35. renderer.render( scene, camera );
  36. </code></pre></div>
  37. </header>
  38. <article>
  39. <div class="container-overview">
  40. <h2>Constructor</h2>
  41. <h3 class="name name-method" id="CubeCamera" translate="no">new <a href="#CubeCamera">CubeCamera</a><span class="signature">( near : <span class="param-type">number</span>, far : <span class="param-type">number</span>, renderTarget : <span class="param-type">WebGLCubeRenderTarget</span> )</span> </h3>
  42. <div class="method">
  43. <div class="description">
  44. <p>Constructs a new cube camera.</p>
  45. </div>
  46. <table class="params">
  47. <tbody>
  48. <tr>
  49. <td class="name"><code>near</code></td>
  50. <td class="description last"><p>The camera's near plane.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>far</code></td>
  54. <td class="description last"><p>The camera's far plane.</p></td>
  55. </tr>
  56. <tr>
  57. <td class="name"><code>renderTarget</code></td>
  58. <td class="description last"><p>The cube render target.</p></td>
  59. </tr>
  60. </tbody>
  61. </table>
  62. </div>
  63. </div>
  64. <h2 class="subsection-title">Properties</h2>
  65. <div class="member">
  66. <h3 class="name" id="activeMipmapLevel" translate="no">.<a href="#activeMipmapLevel">activeMipmapLevel</a><span class="type-signature"> : number</span> </h3>
  67. <div class="description">
  68. <p>The current active mipmap level<br/>Default is <code>0</code>.</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="coordinateSystem" translate="no">.<a href="#coordinateSystem">coordinateSystem</a><span class="type-signature"> : <a href="global.html#WebGLCoordinateSystem">WebGLCoordinateSystem</a> | <a href="global.html#WebGPUCoordinateSystem">WebGPUCoordinateSystem</a></span> </h3>
  73. <div class="description">
  74. <p>The current active coordinate system.<br/>Default is <code>null</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="renderTarget" translate="no">.<a href="#renderTarget">renderTarget</a><span class="type-signature"> : <a href="WebGLCubeRenderTarget.html">WebGLCubeRenderTarget</a></span> </h3>
  79. <div class="description">
  80. <p>A reference to the cube render target.</p>
  81. </div>
  82. </div>
  83. <h2 class="subsection-title">Methods</h2>
  84. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( renderer : <span class="param-type">Renderer | WebGLRenderer</span>, scene : <span class="param-type">Scene</span> )</span> </h3>
  85. <div class="method">
  86. <div class="description">
  87. <p>Calling this method will render the given scene with the given renderer
  88. into the cube render target of the camera.</p>
  89. </div>
  90. <table class="params">
  91. <tbody>
  92. <tr>
  93. <td class="name"><code>renderer</code></td>
  94. <td class="description last"><p>The renderer.</p></td>
  95. </tr>
  96. <tr>
  97. <td class="name"><code>scene</code></td>
  98. <td class="description last"><p>The scene to render.</p></td>
  99. </tr>
  100. </tbody>
  101. </table>
  102. </div>
  103. <h3 class="name name-method" id="updateCoordinateSystem" translate="no">.<a href="#updateCoordinateSystem">updateCoordinateSystem</a><span class="signature">()</span> </h3>
  104. <div class="method">
  105. <div class="description">
  106. <p>Must be called when the coordinate system of the cube camera is changed.</p>
  107. </div>
  108. </div>
  109. <h2 class="subsection-title">Source</h2>
  110. <p>
  111. <a href="https://github.com/mrdoob/three.js/blob/master/src/cameras/CubeCamera.js" target="_blank" rel="noopener" translate="no">src/cameras/CubeCamera.js</a>
  112. </p>
  113. </article>
  114. </section>
  115. <script src="../scripts/linenumber.js"></script>
  116. <script src="../scripts/page.js"></script>
  117. </body>
  118. </html>
粤ICP备19079148号