PerspectiveCamera.html 5.6 KB

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