PerspectiveCamera.rst 3.9 KB

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