PerspectiveCamera.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. <div class="desc">Camera with perspective projection.</div>
  14. <h2>Example</h2>
  15. <div>[example:canvas_geometry_birds geometry / birds ]</div>
  16. <div>[example:canvas_geometry_cube geometry / cube ]</div>
  17. <div>[example:webgl_animation_skinning_blending animation / skinning / blending ]</div>
  18. <div>[example:webgl_animation_skinning_morph animation / skinning / blending ]</div>
  19. <div>[example:webgl_effects_stereo effects / stereo ]</div>
  20. <div>[example:webgl_interactive_cubes interactive / cubes ]</div>
  21. <div>[example:webgl_loader_collada_skinning loader / collada / skinning ]</div>
  22. <code>var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
  23. scene.add( camera );</code>
  24. <h2>Constructor</h2>
  25. <h3>[name]( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] )</h3>
  26. <div>
  27. fov — Camera frustum vertical field of view.<br />
  28. aspect — Camera frustum aspect ratio.<br />
  29. near — Camera frustum near plane.<br />
  30. far — Camera frustum far plane.
  31. </div>
  32. <h2>Properties</h2>
  33. <h3>[property:Float fov]</h3>
  34. <div>Camera frustum vertical field of view, from bottom to top of view, in degrees. Default is *50*.</div>
  35. <h3>[property:number zoom]</h3>
  36. <div>Gets or sets the zoom factor of the camera. Default is *1*.</div>
  37. <h3>[property:Float near]</h3>
  38. <div>Camera frustum near plane. Default is *0.1*.</div>
  39. <h3>[property:Float far]</h3>
  40. <div>Camera frustum far plane. Default is *2000*.</div>
  41. <h3>[property:Float focus]</h3>
  42. <div>Object distance used for stereoscopy and depth-of-field effects.
  43. This parameter does not influence the projection matrix unless a StereoCamera is being used.
  44. Default is *10*.
  45. </div>
  46. <h3>[property:Float aspect]</h3>
  47. <div>Camera frustum aspect ratio, usually the canvas width / canvas height. Default is *1* (square canvas).</div>
  48. <h3>[property:Object view]</h3>
  49. <div>
  50. Frustum window specification or null.
  51. This is set using the [page:PerspectiveCamera.setViewOffset .setViewOffset] method
  52. and cleared using [page:PerspectiveCamera.clearViewOffset .clearViewOffset].
  53. </div>
  54. <h3>[property:Float filmGauge]</h3>
  55. <div>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.</div>
  56. <h3>[property:Float filmOffset]</h3>
  57. <div>Horizontal off-center offset in the same unit as .filmGauge. Default is *0*.</div>
  58. <h2>Methods</h2>
  59. <h3>[method:Float getEffectiveFOV]()</h3>
  60. <div>
  61. Returns the current vertical field of view angle in degrees considering .zoom.
  62. </div>
  63. <h3>[method:Float getFocalLength]()</h3>
  64. <div>
  65. Returns the focal length of the current .fov in respect to .filmGauge.
  66. </div>
  67. <h3>[method:Float getFilmWidth]()</h3>
  68. <div>
  69. Returns the width of the image on the film. If .aspect is greater than or equal to one (landscape format), the result equals .filmGauge.
  70. </div>
  71. <h3>[method:Float getFilmHeight]()</h3>
  72. <div>
  73. Returns the height of the image on the film. If .aspect is less than or equal to one (portrait format), the result equals .filmGauge.
  74. </div>
  75. <h3>[method:null setFocalLength]( [page:Float focalLength] )</h3>
  76. <div>
  77. Sets the FOV by focal length in respect to the current .filmGauge.
  78. </div>
  79. <div>
  80. By default, the focal length is specified for a 35mm (full frame) camera.
  81. </div>
  82. <h3>[method:null setLens]( [page:Float focalLength], [page:Float filmGauge] )</h3>
  83. <div>
  84. focalLength — focal length<br />
  85. frameGauge — film gauge
  86. </div>
  87. <div>
  88. Sets .fov by focal length. Optionally also sets .filmGauge.
  89. This method is deprecated, please use .setFocalLength instead.
  90. </div>
  91. <h3>[method:null setViewOffset]( [page:Float fullWidth], [page:Float fullHeight], [page:Float x], [page:Float y], [page:Float width], [page:Float height] )</h3>
  92. <div>
  93. fullWidth — full width of multiview setup<br />
  94. fullHeight — full height of multiview setup<br />
  95. x — horizontal offset of subcamera<br />
  96. y — vertical offset of subcamera<br />
  97. width — width of subcamera<br />
  98. height — height of subcamera
  99. </div>
  100. <div>
  101. Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups.
  102. </div>
  103. <div>
  104. For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:<br />
  105. <pre>+---+---+---+
  106. | A | B | C |
  107. +---+---+---+
  108. | D | E | F |
  109. +---+---+---+</pre>
  110. then for each monitor you would call it like this:<br />
  111. <code>var w = 1920;
  112. var h = 1080;
  113. var fullWidth = w * 3;
  114. var fullHeight = h * 2;
  115. // A
  116. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
  117. // B
  118. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
  119. // C
  120. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
  121. // D
  122. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
  123. // E
  124. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
  125. // F
  126. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
  127. </code>
  128. Note there is no reason monitors have to be the same size or in a grid.
  129. </div>
  130. <h3>[method:null clearViewOffset]()</h3>
  131. <div>
  132. Removes any offset set by the .setViewOffset method.
  133. </div>
  134. <h3>[method:null updateProjectionMatrix]()</h3>
  135. <div>
  136. Updates the camera projection matrix. Must be called after change of parameters.
  137. </div>
  138. <h3>[method:PerspectiveCamera clone]()</h3>
  139. <div>
  140. <br />
  141. It returns a clone of PerspectiveCamera.
  142. </div>
  143. <h3>[method:JSON toJSON]()</h3>
  144. <div>
  145. Return camera data in JSON format.
  146. </div>
  147. <h2>Source</h2>
  148. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  149. </body>
  150. </html>