new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
191 lines
5.0 KiB
JavaScript
191 lines
5.0 KiB
JavaScript
/*!
|
|
* @class bkcore.threejs.Particles
|
|
*
|
|
* Particle system wrapper/helper
|
|
*
|
|
* @author Thibaut 'BKcore' Despoulain <http://bkcore.com>
|
|
*/
|
|
|
|
/*!
|
|
* @package bkcore.threejs
|
|
*/
|
|
var bkcore = bkcore || {};
|
|
bkcore.threejs = bkcore.threejs || {};
|
|
|
|
/**
|
|
* Creates a new particle system using given parameters
|
|
* @param {Object{max, spawnRate, spawn, velocity, randomness, force, spawnRadius, life, friction, color, color2, tint, texture, size, blending, depthTest, transparent, opacity}} opts
|
|
*/
|
|
bkcore.threejs.Particles = function(opts)
|
|
{
|
|
this.black = new THREE.Color(0x000000);
|
|
this.white = new THREE.Color(0xffffff);
|
|
|
|
this.material = new THREE.ParticleBasicMaterial({
|
|
color: opts.tint == undefined ? 0xffffff : opts.tint,
|
|
map: opts.texture == undefined ? null : opts.texture,
|
|
size: opts.size == undefined ? 4 : opts.size,
|
|
blending: opts.blending == undefined ? THREE.AdditiveBlending : opts.blending,
|
|
depthTest: opts.depthTest == undefined ? false : opts.depthTest,
|
|
transparent: opts.transparent == undefined ? true : opts.transparent,
|
|
vertexColors: true,
|
|
opacity: opts.opacity == undefined ? 1.0 : opts.opacity,
|
|
sizeAttenuation: true
|
|
});
|
|
|
|
this.max = opts.max == undefined ? 1000 : opts.max;
|
|
this.spawnRate = opts.spawnRate == undefined ? 0 : opts.spawnRate;
|
|
|
|
this.spawn = opts.spawn == undefined ? new THREE.Vector3() : opts.spawn;
|
|
this.velocity = opts.velocity == undefined ? new THREE.Vector3() : opts.velocity;
|
|
this.randomness = opts.randomness == undefined ? new THREE.Vector3() : opts.randomness;
|
|
this.force = opts.force == undefined ? new THREE.Vector3() : opts.force;
|
|
this.spawnRadius = opts.spawnRadius == undefined ? new THREE.Vector3() : opts.spawnRadius;
|
|
this.life = opts.life == undefined ? 60 : opts.life;
|
|
this.ageing = 1 / this.life;
|
|
this.friction = opts.friction == undefined ? 1.0 : opts.friction;
|
|
this.color = new THREE.Color(opts.color == undefined ? 0xffffff : opts.color);
|
|
this.color2 = opts.color2 == undefined ? null : new THREE.Color(opts.color2);
|
|
|
|
this.position = opts.position == undefined ? new THREE.Vector3() : opts.position;
|
|
this.rotation = opts.rotation == undefined ? new THREE.Vector3() : opts.rotation;
|
|
this.sort = opts.sort == undefined ? false : opts.sort;
|
|
|
|
this.pool = [];
|
|
this.buffer = [];
|
|
this.geometry = null;
|
|
this.system = null;
|
|
|
|
this.build();
|
|
}
|
|
|
|
bkcore.threejs.Particles.prototype.build = function()
|
|
{
|
|
this.geometry = new THREE.Geometry();
|
|
this.geometry.dynamic = true;
|
|
|
|
this.pool = [];
|
|
this.buffer = [];
|
|
|
|
for(var i = 0; i < this.max; ++i)
|
|
{
|
|
var p = new bkcore.threejs.Particle();
|
|
this.pool.push(p);
|
|
this.buffer.push(p);
|
|
this.geometry.vertices.push(p.position);
|
|
this.geometry.colors.push(p.color);
|
|
}
|
|
|
|
this.system = new THREE.ParticleSystem(this.geometry, this.material);
|
|
this.system.position = this.position;
|
|
this.system.rotation = this.rotation;
|
|
this.system.sort = this.sort;
|
|
}
|
|
|
|
/**
|
|
* Emits given number of particles
|
|
* @param int count
|
|
*/
|
|
bkcore.threejs.Particles.prototype.emit = function(count)
|
|
{
|
|
var emitable = Math.min(count, this.pool.length);
|
|
for(var i = 0; i < emitable; ++i)
|
|
{
|
|
var p = this.pool.pop();
|
|
p.available = false;
|
|
p.position.copy(this.spawn)
|
|
.addSelf(
|
|
this.randomVector()
|
|
.multiplySelf(this.spawnRadius)
|
|
);
|
|
p.velocity.copy(this.velocity)
|
|
.addSelf(
|
|
this.randomVector()
|
|
.multiplySelf(this.randomness)
|
|
);
|
|
p.force.copy(this.force);
|
|
p.basecolor.copy(this.color);
|
|
if(this.color2 != undefined) p.basecolor.lerpSelf(this.color2, Math.random());
|
|
p.life = 1.0;
|
|
}
|
|
}
|
|
|
|
bkcore.threejs.Particles.prototype.randomVector = function()
|
|
{
|
|
return new THREE.Vector3(
|
|
Math.random()*2-1,
|
|
Math.random()*2-1,
|
|
Math.random()*2-1
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Updates particles (should be call in a RAF loop)
|
|
* @param float dt time delta ~1.0
|
|
*/
|
|
bkcore.threejs.Particles.prototype.update = function(dt)
|
|
{
|
|
var p, l;
|
|
var df = new THREE.Vector3();
|
|
var dv = new THREE.Vector3();
|
|
for(var i = 0; i < this.buffer.length; ++i)
|
|
{
|
|
|
|
p = this.buffer[i];
|
|
|
|
if(p.available) continue;
|
|
|
|
p.life -= this.ageing;
|
|
|
|
if(p.life <= 0 && !p.available)
|
|
{
|
|
p.reset();
|
|
this.pool.push(p);
|
|
continue;
|
|
}
|
|
|
|
l = p.life > 0.5 ? 1.0 : p.life + 0.5;
|
|
p.color.setRGB(
|
|
l * p.basecolor.r,
|
|
l * p.basecolor.g,
|
|
l * p.basecolor.b
|
|
);
|
|
|
|
if(this.friction != 1.0)
|
|
p.velocity.multiplyScalar(this.friction);
|
|
|
|
df.copy(p.force).multiplyScalar(dt);
|
|
p.velocity.addSelf(df);
|
|
|
|
dv.copy(p.velocity).multiplyScalar(dt);
|
|
p.position.addSelf(dv);
|
|
}
|
|
|
|
if(this.spawnRate > 0)
|
|
this.emit(this.spawnRate);
|
|
|
|
this.geometry.verticesNeedUpdate = true;
|
|
this.geometry.colorsNeedUpdate = true;
|
|
}
|
|
|
|
bkcore.threejs.Particle = function()
|
|
{
|
|
this.position = new THREE.Vector3(-10000,-10000,-10000);
|
|
this.velocity = new THREE.Vector3();
|
|
this.force = new THREE.Vector3();
|
|
this.color = new THREE.Color(0x000000);
|
|
this.basecolor = new THREE.Color(0x000000);
|
|
this.life = 0.0;
|
|
this.available = true;
|
|
}
|
|
|
|
bkcore.threejs.Particle.prototype.reset = function()
|
|
{
|
|
this.position.set(0,-100000,0);
|
|
this.velocity.set(0,0,0);
|
|
this.force.set(0,0,0);
|
|
this.color.setRGB(0,0,0);
|
|
this.basecolor.setRGB(0,0,0);
|
|
this.life = 0.0;
|
|
this.available = true;
|
|
} |