PerspectiveCamera.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>PerspectiveCamera - Camera with perspective projection &mdash; three.js v48dev documentation</title>
  7. <link rel="stylesheet" href="../../_static/nature.css" type="text/css" />
  8. <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../../',
  12. VERSION: '48dev',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../../_static/jquery.js"></script>
  19. <script type="text/javascript" src="../../_static/underscore.js"></script>
  20. <script type="text/javascript" src="../../_static/doctools.js"></script>
  21. <link rel="top" title="three.js v48dev documentation" href="../../index.html" />
  22. <link rel="up" title="Cameras" href="index.html" />
  23. <link rel="next" title="Core" href="../core/index.html" />
  24. <link rel="prev" title="OrthographicCamera - Camera with orthographic projection" href="OrthographicCamera.html" />
  25. </head>
  26. <body>
  27. <div class="related">
  28. <h3>Navigation</h3>
  29. <ul>
  30. <li class="right" style="margin-right: 10px">
  31. <a href="../../genindex.html" title="General Index"
  32. accesskey="I">index</a></li>
  33. <li class="right" >
  34. <a href="../core/index.html" title="Core"
  35. accesskey="N">next</a> |</li>
  36. <li class="right" >
  37. <a href="OrthographicCamera.html" title="OrthographicCamera - Camera with orthographic projection"
  38. accesskey="P">previous</a> |</li>
  39. <li><a href="../../index.html">three.js v48dev documentation</a> &raquo;</li>
  40. <li><a href="index.html" accesskey="U">Cameras</a> &raquo;</li>
  41. </ul>
  42. </div>
  43. <div class="document">
  44. <div class="documentwrapper">
  45. <div class="bodywrapper">
  46. <div class="body">
  47. <div class="section" id="perspectivecamera-camera-with-perspective-projection">
  48. <h1>PerspectiveCamera - Camera with perspective projection<a class="headerlink" href="#perspectivecamera-camera-with-perspective-projection" title="Permalink to this headline">¶</a></h1>
  49. <p class="rubric">Constructor</p>
  50. <dl class="class">
  51. <dt id="PerspectiveCamera">
  52. <em class="property">class </em><tt class="descname">PerspectiveCamera</tt><big>(</big><em>fov</em>, <em>aspect</em>, <em>near</em>, <em>far</em><big>)</big><a class="headerlink" href="#PerspectiveCamera" title="Permalink to this definition">¶</a></dt>
  53. <dd><p>Camera with perspective projection</p>
  54. <p>Part of scene graph</p>
  55. <p>Inherits from <a class="reference internal" href="../core/Object3D.html#Object3D" title="Object3D"><tt class="xref js js-class docutils literal"><span class="pre">Object3D()</span></tt></a> <a class="reference internal" href="Camera.html#Camera" title="Camera"><tt class="xref js js-class docutils literal"><span class="pre">Camera()</span></tt></a></p>
  56. <table class="docutils field-list" frame="void" rules="none">
  57. <col class="field-name" />
  58. <col class="field-body" />
  59. <tbody valign="top">
  60. <tr class="field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
  61. <li><strong>fov</strong> (<em>float</em>) &#8211; field of view</li>
  62. <li><strong>aspect</strong> (<em>float</em>) &#8211; aspect ratio</li>
  63. <li><strong>near</strong> (<em>float</em>) &#8211; near</li>
  64. <li><strong>far</strong> (<em>float</em>) &#8211; far</li>
  65. </ul>
  66. </td>
  67. </tr>
  68. </tbody>
  69. </table>
  70. </dd></dl>
  71. <p class="rubric">Attributes</p>
  72. <dl class="attribute">
  73. <dt id="PerspectiveCamera.fov">
  74. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">fov</tt><a class="headerlink" href="#PerspectiveCamera.fov" title="Permalink to this definition">¶</a></dt>
  75. <dd><p>Camera frustum vertical field of view</p>
  76. </dd></dl>
  77. <dl class="attribute">
  78. <dt id="PerspectiveCamera.aspect">
  79. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">aspect</tt><a class="headerlink" href="#PerspectiveCamera.aspect" title="Permalink to this definition">¶</a></dt>
  80. <dd><p>Camera frustum aspect ratio</p>
  81. </dd></dl>
  82. <dl class="attribute">
  83. <dt id="PerspectiveCamera.near">
  84. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">near</tt><a class="headerlink" href="#PerspectiveCamera.near" title="Permalink to this definition">¶</a></dt>
  85. <dd><p>Camera frustum near plane</p>
  86. </dd></dl>
  87. <dl class="attribute">
  88. <dt id="PerspectiveCamera.far">
  89. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">far</tt><a class="headerlink" href="#PerspectiveCamera.far" title="Permalink to this definition">¶</a></dt>
  90. <dd><p>Camera frustum far plane</p>
  91. </dd></dl>
  92. <p class="rubric">Multi-view attributes</p>
  93. <dl class="attribute">
  94. <dt id="PerspectiveCamera.fullWidth">
  95. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">fullWidth</tt><a class="headerlink" href="#PerspectiveCamera.fullWidth" title="Permalink to this definition">¶</a></dt>
  96. <dd></dd></dl>
  97. <dl class="attribute">
  98. <dt id="PerspectiveCamera.fullHeight">
  99. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">fullHeight</tt><a class="headerlink" href="#PerspectiveCamera.fullHeight" title="Permalink to this definition">¶</a></dt>
  100. <dd></dd></dl>
  101. <dl class="attribute">
  102. <dt id="PerspectiveCamera.x">
  103. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">x</tt><a class="headerlink" href="#PerspectiveCamera.x" title="Permalink to this definition">¶</a></dt>
  104. <dd></dd></dl>
  105. <dl class="attribute">
  106. <dt id="PerspectiveCamera.y">
  107. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">y</tt><a class="headerlink" href="#PerspectiveCamera.y" title="Permalink to this definition">¶</a></dt>
  108. <dd></dd></dl>
  109. <dl class="attribute">
  110. <dt id="PerspectiveCamera.width">
  111. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">width</tt><a class="headerlink" href="#PerspectiveCamera.width" title="Permalink to this definition">¶</a></dt>
  112. <dd></dd></dl>
  113. <dl class="attribute">
  114. <dt id="PerspectiveCamera.height">
  115. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">height</tt><a class="headerlink" href="#PerspectiveCamera.height" title="Permalink to this definition">¶</a></dt>
  116. <dd></dd></dl>
  117. <p class="rubric">Methods</p>
  118. <dl class="function">
  119. <dt id="PerspectiveCamera.updateProjectionMatrix">
  120. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">updateProjectionMatrix</tt><big>(</big><big>)</big><a class="headerlink" href="#PerspectiveCamera.updateProjectionMatrix" title="Permalink to this definition">¶</a></dt>
  121. <dd><p>Updates camera&#8217;s projection matrix. Must be called after change of parameters.</p>
  122. </dd></dl>
  123. <dl class="function">
  124. <dt id="PerspectiveCamera.setLens ">
  125. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">setLens </tt><big>(</big><em>focalLength</em>, <em>frameSize</em><big>)</big><a class="headerlink" href="#PerspectiveCamera.setLens " title="Permalink to this definition">¶</a></dt>
  126. <dd><p>Uses focal length (in mm) to estimate and set FOV
  127. 35mm (fullframe) camera is used if frame size is not specified.</p>
  128. <p>Formula based on <a class="reference external" href="http://www.bobatkins.com/photography/technical/field_of_view.html">http://www.bobatkins.com/photography/technical/field_of_view.html</a></p>
  129. <table class="docutils field-list" frame="void" rules="none">
  130. <col class="field-name" />
  131. <col class="field-body" />
  132. <tbody valign="top">
  133. <tr class="field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
  134. <li><strong>focalLength</strong> (<em>float</em>) &#8211; focal length</li>
  135. <li><strong>frameSize</strong> (<em>float</em>) &#8211; frame size</li>
  136. </ul>
  137. </td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. </dd></dl>
  142. <dl class="function">
  143. <dt id="PerspectiveCamera.setViewOffset ">
  144. <tt class="descclassname">PerspectiveCamera.</tt><tt class="descname">setViewOffset </tt><big>(</big><em>fullWidth</em>, <em>fullHeight</em>, <em>x</em>, <em>y</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#PerspectiveCamera.setViewOffset " title="Permalink to this definition">¶</a></dt>
  145. <dd><p>Sets an offset in a larger frustum. This is useful for multi-window or
  146. multi-monitor/multi-machine setups.</p>
  147. <p>For example, if you have 3x2 monitors and each monitor is 1920x1080 and
  148. the monitors are in grid like this:</p>
  149. <table border="1" class="docutils">
  150. <colgroup>
  151. <col width="33%" />
  152. <col width="33%" />
  153. <col width="33%" />
  154. </colgroup>
  155. <tbody valign="top">
  156. <tr><td>A</td>
  157. <td>B</td>
  158. <td>C</td>
  159. </tr>
  160. <tr><td>D</td>
  161. <td>E</td>
  162. <td>F</td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <p>then for each monitor you would call it like this:</p>
  167. <div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="mi">1920</span><span class="p">;</span>
  168. <span class="kd">var</span> <span class="nx">h</span> <span class="o">=</span> <span class="mi">1080</span><span class="p">;</span>
  169. <span class="kd">var</span> <span class="nx">fullWidth</span> <span class="o">=</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">3</span><span class="p">;</span>
  170. <span class="kd">var</span> <span class="nx">fullHeight</span> <span class="o">=</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">2</span><span class="p">;</span>
  171. <span class="c1">// --A--</span>
  172. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  173. <span class="c1">//--B--</span>
  174. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  175. <span class="c1">//--C--</span>
  176. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  177. <span class="c1">//--D--</span>
  178. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  179. <span class="c1">//--E--</span>
  180. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  181. <span class="c1">//--F--</span>
  182. <span class="nx">camera</span><span class="p">.</span><span class="nx">setOffset</span><span class="p">(</span> <span class="nx">fullWidth</span><span class="p">,</span> <span class="nx">fullHeight</span><span class="p">,</span> <span class="nx">w</span> <span class="o">*</span> <span class="mi">2</span><span class="p">,</span> <span class="nx">h</span> <span class="o">*</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">w</span><span class="p">,</span> <span class="nx">h</span> <span class="p">);</span>
  183. </pre></div>
  184. </div>
  185. <p>Note there is no reason monitors have to be the same size or in a grid.</p>
  186. <table class="docutils field-list" frame="void" rules="none">
  187. <col class="field-name" />
  188. <col class="field-body" />
  189. <tbody valign="top">
  190. <tr class="field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
  191. <li><strong>fullWidth</strong> (<em>float</em>) &#8211; full width of multi-view setup</li>
  192. <li><strong>fullHeight</strong> (<em>float</em>) &#8211; full height of multi-view setup</li>
  193. <li><strong>x</strong> (<em>float</em>) &#8211; x-offset of subcamera</li>
  194. <li><strong>y</strong> (<em>float</em>) &#8211; y-offset of subcamera</li>
  195. <li><strong>width</strong> (<em>float</em>) &#8211; width of subcamera</li>
  196. <li><strong>height</strong> (<em>float</em>) &#8211; height of subcamera</li>
  197. </ul>
  198. </td>
  199. </tr>
  200. </tbody>
  201. </table>
  202. </dd></dl>
  203. <p class="rubric">Example</p>
  204. <div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">camera</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">THREE</span><span class="p">.</span><span class="nx">PerspectiveCamera</span><span class="p">(</span> <span class="mi">45</span><span class="p">,</span> <span class="nb">window</span><span class="p">.</span><span class="nx">innerWidth</span> <span class="o">/</span> <span class="nb">window</span><span class="p">.</span><span class="nx">innerHeight</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1000</span> <span class="p">);</span>
  205. <span class="nx">scene</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span> <span class="nx">camera</span> <span class="p">);</span>
  206. </pre></div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <div class="sphinxsidebar">
  213. <div class="sphinxsidebarwrapper">
  214. <h4>Previous topic</h4>
  215. <p class="topless"><a href="OrthographicCamera.html"
  216. title="previous chapter">OrthographicCamera - Camera with orthographic projection</a></p>
  217. <h4>Next topic</h4>
  218. <p class="topless"><a href="../core/index.html"
  219. title="next chapter">Core</a></p>
  220. <h3>This Page</h3>
  221. <ul class="this-page-menu">
  222. <li><a href="../../_sources/api/cameras/PerspectiveCamera.txt"
  223. rel="nofollow">Show Source</a></li>
  224. </ul>
  225. <div id="searchbox" style="display: none">
  226. <h3>Quick search</h3>
  227. <form class="search" action="../../search.html" method="get">
  228. <input type="text" name="q" size="18" />
  229. <input type="submit" value="Go" />
  230. <input type="hidden" name="check_keywords" value="yes" />
  231. <input type="hidden" name="area" value="default" />
  232. </form>
  233. <p class="searchtip" style="font-size: 90%">
  234. Enter search terms or a module, class or function name.
  235. </p>
  236. </div>
  237. <script type="text/javascript">$('#searchbox').show(0);</script>
  238. </div>
  239. </div>
  240. <div class="clearer"></div>
  241. </div>
  242. <div class="related">
  243. <h3>Navigation</h3>
  244. <ul>
  245. <li class="right" style="margin-right: 10px">
  246. <a href="../../genindex.html" title="General Index"
  247. >index</a></li>
  248. <li class="right" >
  249. <a href="../core/index.html" title="Core"
  250. >next</a> |</li>
  251. <li class="right" >
  252. <a href="OrthographicCamera.html" title="OrthographicCamera - Camera with orthographic projection"
  253. >previous</a> |</li>
  254. <li><a href="../../index.html">three.js v48dev documentation</a> &raquo;</li>
  255. <li><a href="index.html" >Cameras</a> &raquo;</li>
  256. </ul>
  257. </div>
  258. <div class="footer">
  259. &copy; Copyright 2010-2012, three.js Authors.
  260. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
  261. </div>
  262. </body>
  263. </html>
粤ICP备19079148号