PerspectiveCamera.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!DOCTYPE html>
  2. <html lang="en">
  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. Camera that uses [link:https://en.wikipedia.org/wiki/Perspective_(graphical) perspective projection].<br /><br />
  14. This projection mode is designed to mimic the way the human eye sees. It is the most
  15. common projection mode used for rendering a 3D scene.
  16. </p>
  17. <h2>Code Example</h2>
  18. <code>
  19. const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
  20. scene.add( camera );
  21. </code>
  22. <h2>Examples</h2>
  23. <p>
  24. [example:webgl_animation_skinning_blending animation / skinning / blending ]<br />
  25. [example:webgl_animation_skinning_morph animation / skinning / morph ]<br />
  26. [example:webgl_effects_stereo effects / stereo ]<br />
  27. [example:webgl_interactive_cubes interactive / cubes ]<br />
  28. [example:webgl_loader_collada_skinning loader / collada / skinning ]
  29. </p>
  30. <h2>Constructor</h2>
  31. <h3>[name]( [param:Number fov], [param:Number aspect], [param:Number near], [param:Number far] )</h3>
  32. <p>
  33. fov — Camera frustum vertical field of view.<br />
  34. aspect — Camera frustum aspect ratio.<br />
  35. near — Camera frustum near plane.<br />
  36. far — Camera frustum far plane.<br /><br />
  37. Together these define the camera's [link:https://en.wikipedia.org/wiki/Viewing_frustum viewing frustum].
  38. </p>
  39. <h2>Properties</h2>
  40. <p>
  41. See the base [page:Camera] class for common properties.<br>
  42. Note that after making changes to most of these properties you will have to call
  43. [page:PerspectiveCamera.updateProjectionMatrix .updateProjectionMatrix] for the changes to take effect.
  44. </p>
  45. <h3>[property:Float aspect]</h3>
  46. <p>Camera frustum aspect ratio, usually the canvas width / canvas height. Default is *1* (square canvas).</p>
  47. <h3>[property:Float far]</h3>
  48. <p>
  49. Camera frustum far plane. Default is *2000*.<br /><br />
  50. Must be greater than the current value of [page:.near near] plane.
  51. </p>
  52. <h3>[property:Float filmGauge]</h3>
  53. <p>Film size used for the larger axis. Default is 35 (millimeters). This parameter does not influence the projection matrix unless .filmOffset is set to a nonzero value.</p>
  54. <h3>[property:Float filmOffset]</h3>
  55. <p>Horizontal off-center offset in the same unit as .filmGauge. Default is *0*.</p>
  56. <h3>[property:Float focus]</h3>
  57. <p>Object distance used for stereoscopy and depth-of-field effects.
  58. This parameter does not influence the projection matrix unless a [page:StereoCamera] is being used.
  59. Default is *10*.
  60. </p>
  61. <h3>[property:Float fov]</h3>
  62. <p>Camera frustum vertical field of view, from bottom to top of view, in degrees. Default is *50*.</p>
  63. <h3>[property:Float near]</h3>
  64. <p>
  65. Camera frustum near plane. Default is *0.1*.<br /><br />
  66. The valid range is greater than 0 and less than the current value of the [page:.far far] plane.
  67. Note that, unlike for the [page:OrthographicCamera], *0* is <em>not</em> a valid value
  68. for a PerspectiveCamera's near plane.
  69. </p>
  70. <h3>[property:Object view]</h3>
  71. <p>
  72. Frustum window specification or null.
  73. This is set using the [page:PerspectiveCamera.setViewOffset .setViewOffset] method
  74. and cleared using [page:PerspectiveCamera.clearViewOffset .clearViewOffset].
  75. </p>
  76. <h3>[property:number zoom]</h3>
  77. <p>Gets or sets the zoom factor of the camera. Default is *1*.</p>
  78. <h2>Methods</h2>
  79. <p>See the base [page:Camera] class for common methods.</p>
  80. <h3>[method:null clearViewOffset]()</h3>
  81. <p>Removes any offset set by the [page:PerspectiveCamera.setViewOffset .setViewOffset] method.</p>
  82. <h3>[method:Float getEffectiveFOV]()</h3>
  83. <p>Returns the current vertical field of view angle in degrees considering .zoom.</p>
  84. <h3>[method:Float getFilmHeight]()</h3>
  85. <p>
  86. Returns the height of the image on the film. If .aspect is less than or equal to one
  87. (portrait format), the result equals .filmGauge.
  88. </p>
  89. <h3>[method:Float getFilmWidth]()</h3>
  90. <p>
  91. Returns the width of the image on the film. If .aspect is greater than or equal to one
  92. (landscape format), the result equals .filmGauge.
  93. </p>
  94. <h3>[method:Float getFocalLength]()</h3>
  95. <p>Returns the focal length of the current .fov in respect to .filmGauge.</p>
  96. <h3>[method:null setFocalLength]( [param:Float focalLength] )</h3>
  97. <p>
  98. Sets the FOV by focal length in respect to the current [page:PerspectiveCamera.filmGauge .filmGauge].<br /><br />
  99. By default, the focal length is specified for a 35mm (full frame) camera.
  100. </p>
  101. <h3>[method:null setViewOffset]( [param:Float fullWidth], [param:Float fullHeight], [param:Float x], [param:Float y], [param:Float width], [param:Float height] )</h3>
  102. <p>
  103. fullWidth — full width of multiview setup<br />
  104. fullHeight — full height of multiview setup<br />
  105. x — horizontal offset of subcamera<br />
  106. y — vertical offset of subcamera<br />
  107. width — width of subcamera<br />
  108. height — height of subcamera
  109. </p>
  110. <p>
  111. Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups.
  112. </p>
  113. <p>
  114. For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:<br />
  115. <pre>
  116. +---+---+---+
  117. | A | B | C |
  118. +---+---+---+
  119. | D | E | F |
  120. +---+---+---+
  121. </pre>
  122. then for each monitor you would call it like this:<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. Note there is no reason monitors have to be the same size or in a grid.
  141. </p>
  142. <h3>[method:null updateProjectionMatrix]()</h3>
  143. <p>
  144. Updates the camera projection matrix. Must be called after any change of parameters.
  145. </p>
  146. <h3>[method:Object toJSON]([param:Object meta])</h3>
  147. <p>
  148. meta -- object containing metadata such as textures or images in objects' descendants.<br />
  149. Convert the camera to three.js [link:https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 JSON Object/Scene format].
  150. </p>
  151. <h2>Source</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>