UNPKG

the-world-engine

Version:

three.js based, unity like game engine for browser

131 lines (86 loc) 2.94 kB
export function b2Assert(t, ...e) { if (!t) { throw new Error(...e); } } export function b2Maybe(t, e) { return t !== undefined ? t : e; } export const b2_maxFloat = 1e37; export const b2_epsilon = 1e-5; export const b2_epsilon_sq = b2_epsilon * b2_epsilon; export const b2_pi = 3.14159265359; export const b2_lengthUnitsPerMeter = 1; export const b2_maxPolygonVertices = 8; export const b2_maxManifoldPoints = 2; export const b2_aabbExtension = .1 * b2_lengthUnitsPerMeter; export const b2_aabbMultiplier = 4; export const b2_linearSlop = .005 * b2_lengthUnitsPerMeter; export const b2_angularSlop = 2 / 180 * b2_pi; export const b2_polygonRadius = 2 * b2_linearSlop; export const b2_maxSubSteps = 8; export const b2_maxTOIContacts = 32; export const b2_maxLinearCorrection = .2 * b2_lengthUnitsPerMeter; export const b2_maxAngularCorrection = 8 / 180 * b2_pi; export const b2_maxTranslation = 2 * b2_lengthUnitsPerMeter; export const b2_maxTranslationSquared = b2_maxTranslation * b2_maxTranslation; export const b2_maxRotation = .5 * b2_pi; export const b2_maxRotationSquared = b2_maxRotation * b2_maxRotation; export const b2_baumgarte = .2; export const b2_toiBaumgarte = .75; export const b2_invalidParticleIndex = -1; export const b2_maxParticleIndex = 2147483647; export const b2_particleStride = .75; export const b2_minParticleWeight = 1; export const b2_maxParticlePressure = .25; export const b2_maxParticleForce = .5; export const b2_maxTriadDistance = 2 * b2_lengthUnitsPerMeter; export const b2_maxTriadDistanceSquared = b2_maxTriadDistance * b2_maxTriadDistance; export const b2_minParticleSystemBufferCapacity = 256; export const b2_barrierCollisionTime = 2.5; export const b2_timeToSleep = .5; export const b2_linearSleepTolerance = .01 * b2_lengthUnitsPerMeter; export const b2_angularSleepTolerance = 2 / 180 * b2_pi; export class b2Version { constructor(t = 0, e = 0, r = 0) { this.major = 0; this.minor = 0; this.revision = 0; this.major = t; this.minor = e; this.revision = r; } toString() { return this.major + "." + this.minor + "." + this.revision; } } export const b2_version = new b2Version(2, 4, 1); export const b2_branch = "master"; export const b2_commit = "9ebbbcd960ad424e03e5de6e66a40764c16f51bc"; export function b2ParseInt(t) { return parseInt(t, 10); } export function b2ParseUInt(t) { return Math.abs(parseInt(t, 10)); } export function b2MakeArray(t, e) { const r = new Array(t); for (let o = 0; o < t; ++o) { r[o] = e(o); } return r; } export function b2MakeNullArray(t) { const e = new Array(t); for (let r = 0; r < t; ++r) { e[r] = null; } return e; } export function b2MakeNumberArray(t, e = 0) { const r = new Array(t); for (let o = 0; o < t; ++o) { r[o] = e; } return r; }