topical media & game development
mobile-query-three-plugins-lensflare-tquery.lensflare.js / js
Create a lens flare
tQuery.registerStatic('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 );
color.offsetHSL( 0, -0.5, 0.5 );
// init the textures
var baseUrl = tQuery.createLensFlare.baseUrl;
var texture0 = THREE.ImageUtils.loadTexture( baseUrl+'images/lensflare0.png' );
var texture2 = THREE.ImageUtils.loadTexture( baseUrl+'images/lensflare2.png' );
var texture3 = THREE.ImageUtils.loadTexture( baseUrl+'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, 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;
}
});
tQuery.createLensFlare.baseUrl = "../../../plugins/lensflare/";
(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.