PerspectiveCamera.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Object3D] &rarr; [page:Camera] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. 使用[link:https://en.wikipedia.org/wiki/Perspective_(graphical) perspective projection]的摄像机。<br /><br />
  15. 这种投影模式旨在模仿人眼看到的方式。它是用于渲染3D场景的最常见投影模式。
  16. </p>
  17. <h2>例子</h2>
  18. <p>[example:canvas_geometry_birds geometry / birds ]</p>
  19. <p>[example:canvas_geometry_cube geometry / cube ]</p>
  20. <p>[example:webgl_animation_skinning_blending animation / skinning / blending ]</p>
  21. <p>[example:webgl_animation_skinning_morph animation / skinning / blending ]</p>
  22. <p>[example:webgl_effects_stereo effects / stereo ]</p>
  23. <p>[example:webgl_interactive_cubes interactive / cubes ]</p>
  24. <p>[example:webgl_loader_collada_skinning loader / collada / skinning ]</p>
  25. <code>var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
  26. scene.add( camera );</code>
  27. <h2>构造函数</h2>
  28. <h3>[name]( [param:Number fov], [param:Number aspect], [param:Number near], [param:Number far] )</h3>
  29. <p>
  30. fov — 摄像机视锥体垂直视野。<br />
  31. aspect — 摄像机视锥体宽高比。<br />
  32. near — 摄像机视锥体近平面。<br />
  33. far — 摄像机视锥体远平面。<br /><br />
  34. 这些一起定义了摄像机的[link:https://en.wikipedia.org/wiki/Viewing_frustum viewing frustum]。
  35. </p>
  36. <h2>属性</h2>
  37. <p>
  38. 参阅基类[page:Camera]的公共属性。<br>
  39. 请注意,在对大多数这些属性进行更改后,必须调用[page:PerspectiveCamera.updateProjectionMatrix .updateProjectionMatrix]才能使更改生效。.
  40. </p>
  41. <h3>[property:Float aspect]</h3>
  42. <p>摄像机视锥体宽高比。默认是画布宽度/画布高度。默认值为*1*(方形画布)。</p>
  43. <h3>[property:Float far]</h3>
  44. <p>
  45. 摄像机视锥体远平面。 默认值为*2000*。<br /><br />
  46. 有效范围介于[page:.near]平面的当前值和无穷远之间。
  47. </p>
  48. <h3>[property:Float filmGauge]</h3>
  49. <p>用于较大轴的胶片尺寸。默认值为35 (毫米)。 除非.filmOffset设置为非零值,否则此参数不会影响投影矩阵。</p>
  50. <h3>[property:Float filmOffset]</h3>
  51. <p>与.filmGauge相同单位的水平偏中心偏移。默认值为0。</p>
  52. <h3>[property:Float focus]</h3>
  53. <p>用于立体视觉和景深效果的物距。
  54. 除非使用[page:StereoCamera],否则此参数不会影响投影矩阵。默认值为*10*。
  55. </p>
  56. <h3>[property:Float fov]</h3>
  57. <p>摄像机视锥体垂直视野,从底部到顶部,以度为单位。默认值为*50*。</p>
  58. <h3>[property:Boolean isPerspectiveCamera]</h3>
  59. <p>
  60. 用于测试此类或派生类是否为透视摄像机。默认为*true*。<br /><br />
  61. 这不应该更改,因为渲染器在内部使用它进行优化。
  62. </p>
  63. <h3>[property:Float near]</h3>
  64. <p>
  65. 摄像机视锥体的近平面,默认值为*0.1*。<br /><br />
  66. 有效范围大于0且小于远平面的当前值。需要注意的是,与正交摄像机不同,对于透视摄像机的近平面,0不是一个有效值。
  67. </p>
  68. <h3>[property:Object view]</h3>
  69. <p>
  70. 视锥体窗口规范或null。这是使用[page:PerspectiveCamera.setViewOffset .setViewOffset]方法设置,
  71. 并使用[page:PerspectiveCamera.clearViewOffset .clearViewOffset]清除。
  72. </p>
  73. <h3>[property:number zoom]</h3>
  74. <p>获取或设置摄像机的缩放系数。默认值为*1*。</p>
  75. <h2>方法</h2>
  76. <p>参阅基类[page:Camera]的公共方法。</p>
  77. <h3>[method:null clearViewOffset]()</h3>
  78. <p>删除[page:PerspectiveCamera.setViewOffset .setViewOffset]方法设置的任何偏移量。</p>
  79. <h3>[method:Float getEffectiveFOV]()</h3>
  80. <p>考虑.zoom,返回当前垂直视角范围(以度为单位)。</p>
  81. <h3>[method:Float getFilmHeight]()</h3>
  82. <p>
  83. 返回胶片上图像的高度。如果.aspect小于或等于1(纵向格式),则结果等于.filmGauge。
  84. </p>
  85. <h3>[method:Float getFilmWidth]()</h3>
  86. <p>
  87. 返回胶片上图像的宽度。如果.aspect大于或等于1(横向格式),则结果等于.filmGauge。
  88. </p>
  89. <h3>[method:Float getFocalLength]()</h3>
  90. <p>返回.filmGauge当前.fov的焦距。</p>
  91. <h3>[method:null setFocalLength]( [param:Float focalLength] )</h3>
  92. <p>
  93. 根据当前[page:PerspectiveCamera.filmGauge .filmGauge]的焦距设置FOV。<br /><br />
  94. 默认情况下,焦距是为35mm(全画幅)摄像机指定的。
  95. </p>
  96. <h3>[method:null setViewOffset]( [param:Float fullWidth], [param:Float fullHeight], [param:Float x], [param:Float y], [param:Float width], [param:Float height] )</h3>
  97. <p>
  98. fullWidth — 多视图设置的全宽度<br />
  99. fullHeight — 多视图设置的全高度<br />
  100. x — 子摄像机的水平偏移<br />
  101. y — 子摄像机的竖直偏移<br />
  102. width — 子摄像机宽度<br />
  103. height — 子摄像机高度
  104. </p>
  105. <p>
  106. 在较大的视锥体中设置偏移。
  107. 这对于多窗口或多显示器/多机器设置很有用。
  108. </p>
  109. <p>
  110. 例如,如果你有3x2显示器,每个显示器是1920x1080,显示器是这样的网格:<br />
  111. <pre>
  112. +---+---+---+
  113. | A | B | C |
  114. +---+---+---+
  115. | D | E | F |
  116. +---+---+---+
  117. </pre>
  118. 然后对于每个监视器,你会这样调用它: <br />
  119. <code>var w = 1920;
  120. var h = 1080;
  121. var fullWidth = w * 3;
  122. var fullHeight = h * 2;
  123. // A
  124. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
  125. // B
  126. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
  127. // C
  128. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
  129. // D
  130. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
  131. // E
  132. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
  133. // F
  134. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
  135. </code>
  136. 注意监视器没有理由必须是相同的大小或在一个网格中。
  137. </p>
  138. <h3>[method:null updateProjectionMatrix]()</h3>
  139. <p>
  140. 更新摄像机的投影矩阵。必须在更改参数后调用。
  141. </p>
  142. <h3>[method:JSON toJSON]()</h3>
  143. <p>
  144. 以JSON格式返回摄像机的数据。
  145. </p>
  146. <h2>源代码</h2>
  147. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  148. </body>
  149. </html>