PerspectiveCamera.html 3.0 KB

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