PerspectiveCamera.html 6.9 KB

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