SpotLight.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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>SpotLight - A spotlight &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="Lights" href="index.html" />
  23. <link rel="prev" title="PointLight - A point light" href="PointLight.html" />
  24. </head>
  25. <body>
  26. <div class="related">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="../../genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="PointLight.html" title="PointLight - A point light"
  34. accesskey="P">previous</a> |</li>
  35. <li><a href="../../index.html">three.js v48dev documentation</a> &raquo;</li>
  36. <li><a href="index.html" accesskey="U">Lights</a> &raquo;</li>
  37. </ul>
  38. </div>
  39. <div class="document">
  40. <div class="documentwrapper">
  41. <div class="bodywrapper">
  42. <div class="body">
  43. <div class="section" id="spotlight-a-spotlight">
  44. <h1>SpotLight - A spotlight<a class="headerlink" href="#spotlight-a-spotlight" title="Permalink to this headline">¶</a></h1>
  45. <p class="rubric">Constructor</p>
  46. <dl class="class">
  47. <dt id="SpotLight">
  48. <em class="property">class </em><tt class="descname">SpotLight</tt><big>(</big><em>hex</em>, <em>intensity</em>, <em>distance</em>, <em>castShadow</em><big>)</big><a class="headerlink" href="#SpotLight" title="Permalink to this definition">¶</a></dt>
  49. <dd><p>A point light that can cast shadow in one direction</p>
  50. <p>Part of scene graph</p>
  51. <p>Inherits from <a class="reference internal" href="Light.html#Light" title="Light"><tt class="xref js js-class docutils literal"><span class="pre">Light()</span></tt></a> <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></p>
  52. <p>Affects <tt class="xref js js-class docutils literal"><span class="pre">MeshLambertMaterial()</span></tt> and <tt class="xref js js-class docutils literal"><span class="pre">MeshPhongMaterial()</span></tt></p>
  53. <table class="docutils field-list" frame="void" rules="none">
  54. <col class="field-name" />
  55. <col class="field-body" />
  56. <tbody valign="top">
  57. <tr class="field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
  58. <li><strong>hex</strong> (<em>integer</em>) &#8211; light color</li>
  59. <li><strong>intensity</strong> (<em>float</em>) &#8211; light intensity</li>
  60. <li><strong>distance</strong> (<em>float</em>) &#8211; distance affected by light</li>
  61. <li><strong>castShadow</strong> (<em>bool</em>) &#8211; shadow casting</li>
  62. </ul>
  63. </td>
  64. </tr>
  65. </tbody>
  66. </table>
  67. </dd></dl>
  68. <p class="rubric">Attributes</p>
  69. <dl class="attribute">
  70. <dt id="SpotLight.color">
  71. <tt class="descclassname">SpotLight.</tt><tt class="descname">color</tt><a class="headerlink" href="#SpotLight.color" title="Permalink to this definition">¶</a></dt>
  72. <dd><p>Light <a class="reference internal" href="../core/Color.html#Color" title="Color"><tt class="xref js js-class docutils literal"><span class="pre">Color()</span></tt></a></p>
  73. </dd></dl>
  74. <dl class="attribute">
  75. <dt id="SpotLight.intensity">
  76. <tt class="descclassname">SpotLight.</tt><tt class="descname">intensity</tt><a class="headerlink" href="#SpotLight.intensity" title="Permalink to this definition">¶</a></dt>
  77. <dd><p>Light intensity</p>
  78. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">1.0</span></tt></p>
  79. </dd></dl>
  80. <dl class="attribute">
  81. <dt id="SpotLight.position">
  82. <tt class="descclassname">SpotLight.</tt><tt class="descname">position</tt><a class="headerlink" href="#SpotLight.position" title="Permalink to this definition">¶</a></dt>
  83. <dd><p>Position of the light</p>
  84. </dd></dl>
  85. <dl class="attribute">
  86. <dt id="SpotLight.distance">
  87. <tt class="descclassname">SpotLight.</tt><tt class="descname">distance</tt><a class="headerlink" href="#SpotLight.distance" title="Permalink to this definition">¶</a></dt>
  88. <dd><p>If non-zero, light will attenuate linearly from maximum intensity at light <tt class="docutils literal"><span class="pre">position</span></tt> down to zero at <tt class="docutils literal"><span class="pre">distance</span></tt></p>
  89. </dd></dl>
  90. <p class="rubric">Shadow attributes</p>
  91. <dl class="attribute">
  92. <dt id="SpotLight.castShadow">
  93. <tt class="descclassname">SpotLight.</tt><tt class="descname">castShadow</tt><a class="headerlink" href="#SpotLight.castShadow" title="Permalink to this definition">¶</a></dt>
  94. <dd><p>If set to <cite>true</cite> light will cast dynamic shadows</p>
  95. <p>Warning: this is expensive and requires tweaking to get shadows looking right.</p>
  96. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">false</span></tt></p>
  97. </dd></dl>
  98. <dl class="attribute">
  99. <dt id="SpotLight.onlyShadow">
  100. <tt class="descclassname">SpotLight.</tt><tt class="descname">onlyShadow</tt><a class="headerlink" href="#SpotLight.onlyShadow" title="Permalink to this definition">¶</a></dt>
  101. <dd><p>If set to <cite>true</cite> light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute)</p>
  102. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">false</span></tt></p>
  103. </dd></dl>
  104. <dl class="attribute">
  105. <dt id="SpotLight.target">
  106. <tt class="descclassname">SpotLight.</tt><tt class="descname">target</tt><a class="headerlink" href="#SpotLight.target" title="Permalink to this definition">¶</a></dt>
  107. <dd><p><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> target used for shadow camera orientation</p>
  108. </dd></dl>
  109. <dl class="attribute">
  110. <dt id="SpotLight.shadowCameraNear">
  111. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowCameraNear</tt><a class="headerlink" href="#SpotLight.shadowCameraNear" title="Permalink to this definition">¶</a></dt>
  112. <dd><p>Perspective shadow camera frustum <tt class="docutils literal"><span class="pre">near</span></tt></p>
  113. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">50</span></tt></p>
  114. </dd></dl>
  115. <dl class="attribute">
  116. <dt id="SpotLight.shadowCameraFar">
  117. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowCameraFar</tt><a class="headerlink" href="#SpotLight.shadowCameraFar" title="Permalink to this definition">¶</a></dt>
  118. <dd><p>Perspective shadow camera frustum <tt class="docutils literal"><span class="pre">far</span></tt></p>
  119. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">5000</span></tt></p>
  120. </dd></dl>
  121. <dl class="attribute">
  122. <dt id="SpotLight.shadowCameraFov">
  123. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowCameraFov</tt><a class="headerlink" href="#SpotLight.shadowCameraFov" title="Permalink to this definition">¶</a></dt>
  124. <dd><p>Perspective shadow camera frustum <tt class="docutils literal"><span class="pre">field-of-view</span></tt></p>
  125. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">50</span></tt></p>
  126. </dd></dl>
  127. <dl class="attribute">
  128. <dt id="SpotLight.shadowCameraVisible">
  129. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowCameraVisible</tt><a class="headerlink" href="#SpotLight.shadowCameraVisible" title="Permalink to this definition">¶</a></dt>
  130. <dd><p>Show debug shadow camera frustum</p>
  131. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">false</span></tt></p>
  132. </dd></dl>
  133. <dl class="attribute">
  134. <dt id="SpotLight.shadowBias">
  135. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowBias</tt><a class="headerlink" href="#SpotLight.shadowBias" title="Permalink to this definition">¶</a></dt>
  136. <dd><p>Shadow map bias</p>
  137. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">0</span></tt></p>
  138. </dd></dl>
  139. <dl class="attribute">
  140. <dt id="SpotLight.shadowDarkness">
  141. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowDarkness</tt><a class="headerlink" href="#SpotLight.shadowDarkness" title="Permalink to this definition">¶</a></dt>
  142. <dd><p>Darkness of shadow casted by this light (<tt class="docutils literal"><span class="pre">float</span></tt> from 0 to 1)</p>
  143. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">0.5</span></tt></p>
  144. </dd></dl>
  145. <dl class="attribute">
  146. <dt id="SpotLight.shadowMapWidth">
  147. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowMapWidth</tt><a class="headerlink" href="#SpotLight.shadowMapWidth" title="Permalink to this definition">¶</a></dt>
  148. <dd><p>Shadow map texture width in pixels</p>
  149. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">512</span></tt></p>
  150. </dd></dl>
  151. <dl class="attribute">
  152. <dt id="SpotLight.shadowMapHeight">
  153. <tt class="descclassname">SpotLight.</tt><tt class="descname">shadowMapHeight</tt><a class="headerlink" href="#SpotLight.shadowMapHeight" title="Permalink to this definition">¶</a></dt>
  154. <dd><p>Shadow map texture height in pixels</p>
  155. <p><tt class="docutils literal"><span class="pre">default</span> <span class="pre">512</span></tt></p>
  156. </dd></dl>
  157. <p class="rubric">Example</p>
  158. <div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// white spotlight shining from the side, casting shadow</span>
  159. <span class="kd">var</span> <span class="nx">spotLight</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">THREE</span><span class="p">.</span><span class="nx">SpotLight</span><span class="p">(</span> <span class="mh">0xffffff</span> <span class="p">);</span>
  160. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">position</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">1000</span><span class="p">,</span> <span class="mi">100</span> <span class="p">);</span>
  161. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">castShadow</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
  162. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">shadowMapWidth</span> <span class="o">=</span> <span class="mi">1024</span><span class="p">;</span>
  163. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">shadowMapHeight</span> <span class="o">=</span> <span class="mi">1024</span><span class="p">;</span>
  164. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">shadowCameraNear</span> <span class="o">=</span> <span class="mi">500</span><span class="p">;</span>
  165. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">shadowCameraFar</span> <span class="o">=</span> <span class="mi">4000</span><span class="p">;</span>
  166. <span class="nx">spotLight</span><span class="p">.</span><span class="nx">shadowCameraFov</span> <span class="o">=</span> <span class="mi">30</span><span class="p">;</span>
  167. <span class="nx">scene</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span> <span class="nx">spotLight</span> <span class="p">);</span>
  168. </pre></div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="sphinxsidebar">
  175. <div class="sphinxsidebarwrapper">
  176. <h4>Previous topic</h4>
  177. <p class="topless"><a href="PointLight.html"
  178. title="previous chapter">PointLight - A point light</a></p>
  179. <h3>This Page</h3>
  180. <ul class="this-page-menu">
  181. <li><a href="../../_sources/api/lights/SpotLight.txt"
  182. rel="nofollow">Show Source</a></li>
  183. </ul>
  184. <div id="searchbox" style="display: none">
  185. <h3>Quick search</h3>
  186. <form class="search" action="../../search.html" method="get">
  187. <input type="text" name="q" size="18" />
  188. <input type="submit" value="Go" />
  189. <input type="hidden" name="check_keywords" value="yes" />
  190. <input type="hidden" name="area" value="default" />
  191. </form>
  192. <p class="searchtip" style="font-size: 90%">
  193. Enter search terms or a module, class or function name.
  194. </p>
  195. </div>
  196. <script type="text/javascript">$('#searchbox').show(0);</script>
  197. </div>
  198. </div>
  199. <div class="clearer"></div>
  200. </div>
  201. <div class="related">
  202. <h3>Navigation</h3>
  203. <ul>
  204. <li class="right" style="margin-right: 10px">
  205. <a href="../../genindex.html" title="General Index"
  206. >index</a></li>
  207. <li class="right" >
  208. <a href="PointLight.html" title="PointLight - A point light"
  209. >previous</a> |</li>
  210. <li><a href="../../index.html">three.js v48dev documentation</a> &raquo;</li>
  211. <li><a href="index.html" >Lights</a> &raquo;</li>
  212. </ul>
  213. </div>
  214. <div class="footer">
  215. &copy; Copyright 2010-2012, three.js Authors.
  216. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
  217. </div>
  218. </body>
  219. </html>