PerspectiveCamera.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. [page:Object3D] → [page:Camera] →
  2. <h1>[name]</h1>
  3. <div class="desc">Camera with perspective projection.</div>
  4. <h2>Example</h2>
  5. <code>var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
  6. scene.add( camera );
  7. </code>
  8. <h2>Constructor</h2>
  9. <h3>[name]( [page:Float fov], [page:Float aspect], [page:Float near], [page:Float far] )</h3>
  10. <div>
  11. fov — Camera frustum vertical field of view.<br />
  12. aspect — Camera frustum aspect ratio.<br />
  13. near — Camera frustum near plane.<br />
  14. far — Camera frustum far plane.
  15. </div>
  16. <h2>Properties</h2>
  17. <h3>.[page:Float fov]</h3>
  18. <div>Camera frustum vertical field of view.</div>
  19. <h3>.[page:Float aspect]</h3>
  20. <div>Camera frustum aspect ratio.</div>
  21. <h3>.[page:Float near]</h3>
  22. <div>Camera frustum near plane.</div>
  23. <h3>.[page:Float far]</h3>
  24. <div>Camera frustum far plane.</div>
  25. <h2>Methods</h2>
  26. <h3>.setLens( [page:Float focalLength], [page:Float frameSize] )</h3>
  27. <div>
  28. focalLength — focal length<br />
  29. frameSize — frame size
  30. </div>
  31. <div>
  32. Uses focal length (in mm) to estimate and set FOV 35mm (fullframe) camera is used if frame size is not specified.<br />
  33. Formula based on [link:http://www.bobatkins.com/photography/technical/field_of_view.html]
  34. </div>
  35. <h3>.setViewOffset( [page:Float fullWidth], [page:Float fullHeight], [page:Float x], [page:Float y], [page:Float width], [page:Float height] )</h3>
  36. <div>
  37. fullWidth — full width of multiview setup<br />
  38. fullHeight — full height of multiview setup<br />
  39. x — horizontal offset of subcamera<br />
  40. y — vertical offset of subcamera<br />
  41. width — width of subcamera<br />
  42. height — height of subcamera
  43. </div>
  44. <div>
  45. Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups.
  46. </div>
  47. <div>
  48. For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:<br />
  49. <pre>+---+---+---+
  50. | A | B | C |
  51. +---+---+---+
  52. | D | E | F |
  53. +---+---+---+
  54. </pre>
  55. then for each monitor you would call it like this:<br />
  56. <code>var w = 1920;
  57. var h = 1080;
  58. var fullWidth = w * 3;
  59. var fullHeight = h * 2;
  60. // A
  61. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
  62. // B
  63. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
  64. // C
  65. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
  66. // D
  67. camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
  68. // E
  69. camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
  70. // F
  71. camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
  72. </code>
  73. Note there is no reason monitors have to be the same size or in a grid.
  74. </div>
  75. <h3>.updateProjectionMatrix()</h3>
  76. <div>
  77. Updates the camera projection matrix. Must be called after change of parameters.
  78. </div>
  79. <h2>Source</h2>
  80. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]