SpotLight.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  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:Light] &rarr;
  11. <h1>聚光灯([name])</h1>
  12. <p class="desc">
  13. 光线从一个点沿一个方向射出,随着光线照射的变远,光线圆锥体的尺寸也逐渐增大。<br /><br />
  14. 该光源可以投射阴影 - 跳转至 [page:SpotLightShadow] 查看更多细节。
  15. </p>
  16. <h2>代码示例</h2>
  17. <code>
  18. // white spotlight shining from the side, modulated by a texture, casting a shadow
  19. const spotLight = new THREE.SpotLight( 0xffffff );
  20. spotLight.position.set( 100, 1000, 100 );
  21. spotLight.map = new THREE.TextureLoader().load( url );
  22. spotLight.castShadow = true;
  23. spotLight.shadow.mapSize.width = 1024;
  24. spotLight.shadow.mapSize.height = 1024;
  25. spotLight.shadow.camera.near = 500;
  26. spotLight.shadow.camera.far = 4000;
  27. spotLight.shadow.camera.fov = 30;
  28. scene.add( spotLight );
  29. </code>
  30. <h2>例子</h2>
  31. <p>
  32. [example:webgl_lights_spotlight lights / spotlight ]<br />
  33. [example:webgl_lights_spotlights lights / spotlights ]
  34. </p>
  35. <h2>构造器(Constructor)</h2>
  36. <h3>[name]( [param:Integer color], [param:Float intensity], [param:Float distance], [param:Radians angle], [param:Float penumbra], [param:Float decay] )</h3>
  37. <p>
  38. [page:Integer color] - (可选参数) 十六进制光照颜色。 缺省值 0xffffff (白色)。<br />
  39. [page:Float intensity] - (可选参数) 光照强度。 缺省值 1。<br />
  40. [page:Float distance] - 从光源发出光的最大距离,其强度根据光源的距离线性衰减。 <br />
  41. [page:Radians angle] - 光线散射角度,最大为Math.PI/2。<br />
  42. [page:Float penumbra] - 聚光锥的半影衰减百分比。在0和1之间的值。默认为0。<br />
  43. [page:Float decay] - 沿着光照距离的衰减量。<br /><br />
  44. 创建一个新的聚光灯。
  45. </p>
  46. <h2>属性(Properties)</h2>
  47. <p>公共属性请查看基类[page:Light Light]。</p>
  48. <h3>[property:Float angle]</h3>
  49. <p>
  50. 从聚光灯的位置以弧度表示聚光灯的最大范围。应该不超过 *Math.PI/2*。默认值为 *Math.PI/3*。
  51. </p>
  52. <h3>[property:Boolean castShadow]</h3>
  53. <p>
  54. 此属性设置为 *true* 聚光灯将投射阴影。警告: 这样做的代价比较高而且需要一直调整到阴影看起来正确。
  55. 查看 [page:SpotLightShadow] 了解详细信息。
  56. 默认值为 *false*
  57. </p>
  58. <h3>[property:Float decay]</h3>
  59. <p>
  60. The amount the light dims along the distance of the light. Default is `2`.<br />
  61. In context of physically-correct rendering the default value should not be changed.
  62. </p>
  63. <h3>[property:Float distance]</h3>
  64. <p>
  65. `Default mode` — When distance is zero, light does not attenuate. When
  66. distance is non-zero, light will attenuate linearly from maximum intensity
  67. at the light's position down to zero at this distance from the light.
  68. </p>
  69. <p>
  70. When [page:WebGLRenderer.useLegacyLights legacy lighting mode] is disabled —
  71. When distance is zero, light will attenuate according to inverse-square
  72. law to infinite distance. When distance is non-zero, light will attenuate
  73. according to inverse-square law until near the distance cutoff, where it
  74. will then attenuate quickly and smoothly to `0`. Inherently, cutoffs are
  75. not physically correct.
  76. </p>
  77. <p>Default is `0.0`.</p>
  78. <h3>[property:Float intensity]</h3>
  79. <p>
  80. The light's intensity. Default is `1`.<br />
  81. When [page:WebGLRenderer.useLegacyLights legacy lighting mode] is disabled,
  82. intensity is the luminous intensity of the light measured in candela
  83. (cd).<br /><br />
  84. Changing the intensity will also change the light's power.
  85. </p>
  86. <h3>[property:Boolean isSpotLight]</h3>
  87. <p>
  88. Read-only flag to check if a given object is of type [name].
  89. </p>
  90. <h3>[property:Float penumbra]</h3>
  91. <p>
  92. 聚光锥的半影衰减百分比。在0和1之间的值。
  93. 默认值 — 0.0。
  94. </p>
  95. <h3>[property:Vector3 position]</h3>
  96. <p>
  97. 假如这个值设置等于 [page:Object3D.DEFAULT_UP] (0, 1, 0),那么光线将会从上往下照射。
  98. </p>
  99. <h3>[property:Float power]</h3>
  100. <p>
  101. The light's power.<br />
  102. When [page:WebGLRenderer.useLegacyLights legacy lighting mode] is disabled,
  103. power is the luminous power of the light measured in lumens (lm).
  104. <br /><br />
  105. Changing the power will also change the light's intensity.
  106. </p>
  107. <h3>[property:SpotLightShadow shadow]</h3>
  108. <p>
  109. [page:SpotLightShadow]用与计算此光照的阴影。
  110. </p>
  111. <h3>[property:Object3D target]</h3>
  112. <p>
  113. 聚光灯的方向是从它的位置到目标位置.默认的目标位置为原点 *(0,0,0)*。<br />
  114. 注意: 对于目标的位置,要将其更改为除缺省值之外的任何位置,它必须被添加到 [page:Scene scene]
  115. 场景中去。
  116. <code>
  117. scene.add( light.target );
  118. </code>
  119. 这使得属性target中的 [page:Object3D.matrixWorld matrixWorld] 会每帧自动更新。<br /><br />
  120. 它也可以设置target为场景中的其他对象(任意拥有 [page:Object3D.position position] 属性的对象), 示例如下:
  121. <code>
  122. const targetObject = new THREE.Object3D();
  123. scene.add(targetObject);
  124. light.target = targetObject;
  125. </code>
  126. 完成上述操作后,聚光灯现在就可以追踪到目标对像了。
  127. </p>
  128. <h3>[property:Texture map]</h3>
  129. <p>
  130. A [page:Texture] used to modulate the color of the light. The spot light color is mixed
  131. with the RGB value of this texture, with a ratio corresponding to its
  132. alpha value. The cookie-like masking effect is reproduced using pixel values (0, 0, 0, 1-cookie_value).
  133. *Warning*: [param:SpotLight map] is disabled if [param:SpotLight castShadow] is *false*.
  134. </p>
  135. <h2>方法(Methods)</h2>
  136. <p>公共方法请查看基类 [page:Light Light]。</p>
  137. <h3>[method:this copy]( [param:SpotLight source] )</h3>
  138. <p>
  139. 将所有属性的值从源 [page:SpotLight source] 复制到此聚光灯光源对象。
  140. </p>
  141. <p>
  142. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  143. </p>
  144. </body>
  145. </html>