UNPKG

the-world-engine

Version:

three.js based, unity like game engine for browser

59 lines (52 loc) 2.19 kB
import { b2_invalidParticleIndex } from "../common/b2_settings.js"; import { b2Clamp, b2Vec2 } from "../common/b2_math.js"; import { b2Color } from "../common/b2_draw.js"; export var b2ParticleFlag; (function(t) { t[t["b2_waterParticle"] = 0] = "b2_waterParticle"; t[t["b2_zombieParticle"] = 2] = "b2_zombieParticle"; t[t["b2_wallParticle"] = 4] = "b2_wallParticle"; t[t["b2_springParticle"] = 8] = "b2_springParticle"; t[t["b2_elasticParticle"] = 16] = "b2_elasticParticle"; t[t["b2_viscousParticle"] = 32] = "b2_viscousParticle"; t[t["b2_powderParticle"] = 64] = "b2_powderParticle"; t[t["b2_tensileParticle"] = 128] = "b2_tensileParticle"; t[t["b2_colorMixingParticle"] = 256] = "b2_colorMixingParticle"; t[t["b2_destructionListenerParticle"] = 512] = "b2_destructionListenerParticle"; t[t["b2_barrierParticle"] = 1024] = "b2_barrierParticle"; t[t["b2_staticPressureParticle"] = 2048] = "b2_staticPressureParticle"; t[t["b2_reactiveParticle"] = 4096] = "b2_reactiveParticle"; t[t["b2_repulsiveParticle"] = 8192] = "b2_repulsiveParticle"; t[t["b2_fixtureContactListenerParticle"] = 16384] = "b2_fixtureContactListenerParticle"; t[t["b2_particleContactListenerParticle"] = 32768] = "b2_particleContactListenerParticle"; t[t["b2_fixtureContactFilterParticle"] = 65536] = "b2_fixtureContactFilterParticle"; t[t["b2_particleContactFilterParticle"] = 131072] = "b2_particleContactFilterParticle"; })(b2ParticleFlag || (b2ParticleFlag = {})); export class b2ParticleDef { constructor() { this.flags = 0; this.position = new b2Vec2; this.velocity = new b2Vec2; this.color = new b2Color(0, 0, 0, 0); this.lifetime = 0; this.userData = null; this.group = null; } } export function b2CalculateParticleIterations(t, e, r) { const i = 8; const a = .01; const c = Math.ceil(Math.sqrt(t / (a * e)) * r); return b2Clamp(c, 1, i); } export class b2ParticleHandle { constructor() { this.m_index = b2_invalidParticleIndex; } GetIndex() { return this.m_index; } SetIndex(t) { this.m_index = t; } }