SpotLight.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. 如果非零,那么光强度将会从最大值当前灯光位置处按照距离线性衰减到0。
  66. 缺省值为 *0.0*。
  67. </p>
  68. <h3>[property:Boolean isSpotLight]</h3>
  69. <p>
  70. Read-only flag to check if a given object is of type [name].
  71. </p>
  72. <h3>[property:Float penumbra]</h3>
  73. <p>
  74. 聚光锥的半影衰减百分比。在0和1之间的值。
  75. 默认值 — 0.0。
  76. </p>
  77. <h3>[property:Vector3 position]</h3>
  78. <p>
  79. 假如这个值设置等于 [page:Object3D.DefaultUp] (0, 1, 0),那么光线将会从上往下照射。
  80. </p>
  81. <h3>[property:Float power]</h3>
  82. <p>
  83. 光功率<br />
  84. 在 [page:WebGLRenderer.physicallyCorrectLights physically correct] 模式中,
  85. 表示以"流明(光通量单位)"为单位的光功率。 缺省值 - *4Math.PI*。 <br /><br />
  86. 该值与 [page:.intensity intensity] 直接关联
  87. <code>
  88. power = intensity * 4&pi;
  89. </code>
  90. 修改该值也会导致光强度的改变。
  91. </p>
  92. <h3>[property:SpotLightShadow shadow]</h3>
  93. <p>
  94. [page:SpotLightShadow]用与计算此光照的阴影。
  95. </p>
  96. <h3>[property:Object3D target]</h3>
  97. <p>
  98. 聚光灯的方向是从它的位置到目标位置.默认的目标位置为原点 *(0,0,0)*。<br />
  99. 注意: 对于目标的位置,要将其更改为除缺省值之外的任何位置,它必须被添加到 [page:Scene scene]
  100. 场景中去。
  101. <code>
  102. scene.add( light.target );
  103. </code>
  104. 这使得属性target中的 [page:Object3D.matrixWorld matrixWorld] 会每帧自动更新。<br /><br />
  105. 它也可以设置target为场景中的其他对象(任意拥有 [page:Object3D.position position] 属性的对象), 示例如下:
  106. <code>
  107. const targetObject = new THREE.Object3D();
  108. scene.add(targetObject);
  109. light.target = targetObject;
  110. </code>
  111. 完成上述操作后,聚光灯现在就可以追踪到目标对像了。
  112. </p>
  113. <h3>[property:Texture map]</h3>
  114. <p>
  115. A [page:Texture] used to modulate the color of the light. The spot light color is mixed
  116. with the RGB value of this texture, with a ratio corresponding to its
  117. alpha value. The cookie-like masking effect is reproduced using pixel values (0, 0, 0, 1-cookie_value).
  118. *Warning*: [param:SpotLight map] is disabled if [param:SpotLight castShadow] is *false*.
  119. </p>
  120. <h2>方法(Methods)</h2>
  121. <p>公共方法请查看基类 [page:Light Light]。</p>
  122. <h3>[method:this copy]( [param:SpotLight source] )</h3>
  123. <p>
  124. 将所有属性的值从源 [page:SpotLight source] 复制到此聚光灯光源对象。
  125. </p>
  126. <p>
  127. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  128. </p>
  129. </body>
  130. </html>