topical media & game development

talk show tell print

mobile-query-three-plugins-flamethrower-tmp-vendor-tquery-tquery.lensflare.js / js



  
Create a lens flare

  
  tQuery.register('createLensFlare', function(opts){
          // handle polymorphism
          opts                = opts        || defaultOpts();
          // create the object
          var lensFlare        = new THREE.LensFlare();
          // add each flare in the lens flare
          opts.flareParams.forEach(function(flareParam){
                  lensFlare.add.apply(lensFlare, flareParam)
          });
          // return the tQuery.Object3D
          return tQuery(lensFlare);
          
          
the default options if no options are given

  
          function defaultOpts(){
                  var opts        = {
                          flareParams        : []
                  };
                  var color        = new THREE.Color( 0xffffff );
                  THREE.ColorUtils.adjustHSV( color, 0, -0.5, 0.5 );
                  
                  // init the textures
                  var texture0        = THREE.ImageUtils.loadTexture( "images/lensflare0.png" );
                  var texture2        = THREE.ImageUtils.loadTexture( "images/lensflare2.png" );
                  var texture3        = THREE.ImageUtils.loadTexture( "images/lensflare3.png" );
  
                  opts.flareParams.push([ texture0, 700, 0.0, THREE.AdditiveBlending, color ]);
  
                  opts.flareParams.push([ texture2, 512, 0.0, THREE.AdditiveBlending ]);
  
                  opts.flareParams.push([ texture3, 500, 0.4, THREE.AdditiveBlending ]);
                  opts.flareParams.push([ texture3,  60, 0.6, THREE.AdditiveBlending ]);
                  opts.flareParams.push([ texture3,  70, 0.7, THREE.AdditiveBlending ]);
                  opts.flareParams.push([ texture3, 120, 0.9, THREE.AdditiveBlending ]);
                  opts.flareParams.push([ texture3,  70, 1.0, THREE.AdditiveBlending ]);
                  return opts;
          }
  })


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.