2
0

PerspectiveCamera.html 3.2 KB

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