LensFlare.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Object3D] &rarr;
  12. <h1>[name]</h1>
  13. <div class="desc">
  14. Creates a simulated lens flare that tracks a light.<br /><br />
  15. Note: [page:WebGLRenderer.alpha] must be set to *true* for LensFlare to work.
  16. </div>
  17. <h2>Example</h2>
  18. <div>
  19. [example:webgl_lensflares lensflares]
  20. <code>
  21. var light = new THREE.PointLight( 0xffffff, 1.5, 2000 );
  22. var textureLoader = new THREE.TextureLoader();
  23. var textureFlare = textureLoader.load( "textures/lensflare/lensflare.png" );
  24. var flareColor = new THREE.Color( 0xffffff );
  25. flareColor.setHSL( h, s, l + 0.5 );
  26. var lensFlare = new THREE.LensFlare( textureFlare, 700, 0.0, THREE.AdditiveBlending, flareColor );
  27. lensFlare.position.copy( light.position );
  28. scene.add( lensFlare );
  29. </code>
  30. </div>
  31. <h2>Constructor</h2>
  32. <h3>[name]( [page:Texture texture], [page:Float size], [page:Float distance], [page:Materials blending], [page:Color color] )</h3>
  33. <div>
  34. [page:Texture texture] - (optional) THREE.Texture to use for the flare. <br />
  35. [page:Float size] - (optional) size in pixels (-1 = use texture.width) <br />
  36. [page:Float distance] - (optional) (0-1) from light source (0 = at light source) <br />
  37. [page:Materials blending] - (optional) [page:Materials Blending Mode] - Defaults to THREE.NormalBlending <br />
  38. [page:Color color] - (optional) the [page:Color] of the lens flare<br /><br />
  39. Automatically adds a lens flare to the lensFlares array if a [page:Texture texture] is set.
  40. If [page:Texture texture] not passed here, [page:.add add] must be called later.
  41. </div>
  42. <h2>Properties</h2>
  43. <div>See the base [page:Object3D] class for common properties.</div>
  44. <h3>[property:Boolean isLensFlare]</h3>
  45. <div>
  46. Used to check whether this or derived classes are lens flares. Default is *true*.<br /><br />
  47. You should not change this, as it used internally for optimisation.
  48. </div>
  49. <h3>[property:array lensFlares]</h3>
  50. <div>
  51. The array of flares as set by [page:LensFlare.add] or passed in the constructor.
  52. Each flare is an object with the following defaults:
  53. <code>
  54. {
  55. texture: texture, // texture passed in the constructor or [page:.add add] method
  56. size: size, // if not passed in, default is -1
  57. distance: distance, // if not passed in, default is 0
  58. x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is in front z = 1 is back
  59. scale: 1,
  60. rotation: 0,
  61. opacity: opacity, // if not passed in, default is 1
  62. color: color, // if not passed in, default is new Color( 0xffffff ) (white)
  63. blending: blending // if not passed in, default is NormalBlending
  64. }
  65. </code>
  66. </div>
  67. <h3>[property:Vector3 positionScreen]</h3>
  68. <div>The position of the lens flare on the screen.</div>
  69. <h3>[property:Function customUpdateCallback]</h3>
  70. <div>
  71. A custom update callback. Default is undefined, set this to override [page:.updateLensFlares updateLensFlares]().
  72. </div>
  73. <h2>Methods</h2>
  74. <div>See the base [page:Object3D] class for common methods.</div>
  75. <h3>[method:null add]( [page:Texture texture], [page:Float size], [page:Float distance], [page:Materials blending], [page:Color color] )</h3>
  76. <div>
  77. Adds a lens flare. Takes the same parameters as the constructor.
  78. </div>
  79. <h3>[method:LensFlare clone]()</h3>
  80. <div>
  81. Return a new LensFlare with the same parameters as this one.
  82. </div>
  83. <h3>[method:LensFlare copy]( [page:LensFlare source] )</h3>
  84. <div>
  85. Copy the parameters from the [page:LensFlare source] LensFlare into this one.
  86. </div>
  87. <h3>[method:null updateLensFlares]()</h3>
  88. <div>
  89. Updates [page:.lensFlares lensFlares] based on the [page:LensFlare.positionScreen positionScreen]
  90. property.<br /><br />
  91. Can be overridden by setting the [page:.customUpdateCallback customUpdateCallback] function.
  92. </div>
  93. <h2>Source</h2>
  94. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  95. </body>
  96. </html>