@devrals/math 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/math.js +1 -1
- package/dist/math.umd.cjs +1 -1
- package/dist/src/functions.d.ts +1 -1
- package/package.json +2 -1
package/dist/math.js
CHANGED
|
@@ -66,6 +66,6 @@ var e = class e {
|
|
|
66
66
|
this.z
|
|
67
67
|
];
|
|
68
68
|
}
|
|
69
|
-
}, n = (e) => e[Math.floor(Math.random() * e.length)], r = (e, t) => (e % t + t) % t, i = (e, t) => e + Math.random() * t, a = (e, t, n) => Math.max(Math.min(e, n), t), o = (e, t, n) => e * (1 - n) + t * n, s = (e, t, n) => e < t ? Math.min(e + n, t) : Math.max(e - n, t), c = (n, r) => "z" in n && "z" in r ? new t(n.x + r.x, n.y + n.y, n.z + n.z) : new e(n.x + r.x, n.y + n.y), l = (n, r) => "z" in n && "z" in r ? new t(n.x - r.x, n.y - n.y, n.z - n.z) : new e(n.x - r.x, n.y - n.y), u = (n, r) => "z" in n && "z" in r ? new t(n.x * r.x, n.y * n.y, n.z * n.z) : new e(n.x * r.x, n.y * n.y), d = (n, r) => "z" in n && "z" in r ? new t(n.x / r.x, n.y / n.y, n.z / n.z) : new e(n.x / r.x, n.y / n.y);
|
|
69
|
+
}, n = (e) => e[Math.floor(Math.random() * e.length)], r = (e, t) => (e % t + t) % t, i = (e, t) => e + Math.random() * (t - e), a = (e, t, n) => Math.max(Math.min(e, n), t), o = (e, t, n) => e * (1 - n) + t * n, s = (e, t, n) => e < t ? Math.min(e + n, t) : Math.max(e - n, t), c = (n, r) => "z" in n && "z" in r ? new t(n.x + r.x, n.y + n.y, n.z + n.z) : new e(n.x + r.x, n.y + n.y), l = (n, r) => "z" in n && "z" in r ? new t(n.x - r.x, n.y - n.y, n.z - n.z) : new e(n.x - r.x, n.y - n.y), u = (n, r) => "z" in n && "z" in r ? new t(n.x * r.x, n.y * n.y, n.z * n.z) : new e(n.x * r.x, n.y * n.y), d = (n, r) => "z" in n && "z" in r ? new t(n.x / r.x, n.y / n.y, n.z / n.z) : new e(n.x / r.x, n.y / n.y);
|
|
70
70
|
//#endregion
|
|
71
71
|
export { e as Vec2, t as Vec3, c as add, s as approach, n as chooseRand, a as clamp, d as div, o as lerp, r as mod, u as mul, i as randRange, l as sub };
|
package/dist/math.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.index={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class e{constructor(e,t){this.x=e,this.y=t}static initial(t){return new e(t,t)}static empty(){return new e(0,0)}add(e){return typeof e==`number`?this.x+=e:this.x+=e.x,typeof e==`number`?this.y+=e:this.y+=e.y,this}sub(e){return typeof e==`number`?this.x-=e:this.x-=e.x,typeof e==`number`?this.y-=e:this.y-=e.y,this}mul(e){return typeof e==`number`?this.x*=e:this.x*=e.x,typeof e==`number`?this.y*=e:this.y*=e.y,this}div(e){return typeof e==`number`?this.x/=e:this.x/=e.x,typeof e==`number`?this.y/=e:this.y/=e.y,this}map(e){return this.x=e(this.x),this.y=e(this.y),this}toArr(){return[this.x,this.y,0]}},n=class e extends t{constructor(e,t,n){super(e,t),this.z=n}static initial(t){return new e(t,t,t)}static empty(){return new e(0,0,0)}static fromHex(t){return new e(parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16))}add(e){return typeof e==`number`?this.x+=e:this.x+=e.x,typeof e==`number`?this.y+=e:this.y+=e.y,typeof e==`number`?this.z+=e:this.z+=e.z,this}sub(e){return typeof e==`number`?this.x-=e:this.x-=e.x,typeof e==`number`?this.y-=e:this.y-=e.y,typeof e==`number`?this.z-=e:this.z-=e.z,this}mul(e){return this.x*=typeof e==`number`?e:e.x,this.y*=typeof e==`number`?e:e.y,this.z*=typeof e==`number`?e:e.z,this}div(e){return typeof e==`number`?this.x/=e:this.x/=e.x,typeof e==`number`?this.y/=e:this.y/=e.y,typeof e==`number`?this.z/=e:this.z/=e.z,this}map(e){return this.x=e(this.x),this.y=e(this.y),this.z=e(this.z),this}toArr(){return[this.x,this.y,this.z]}};e.Vec2=t,e.Vec3=n,e.add=(e,r)=>`z`in e&&`z`in r?new n(e.x+r.x,e.y+e.y,e.z+e.z):new t(e.x+r.x,e.y+e.y),e.approach=(e,t,n)=>e<t?Math.min(e+n,t):Math.max(e-n,t),e.chooseRand=e=>e[Math.floor(Math.random()*e.length)],e.clamp=(e,t,n)=>Math.max(Math.min(e,n),t),e.div=(e,r)=>`z`in e&&`z`in r?new n(e.x/r.x,e.y/e.y,e.z/e.z):new t(e.x/r.x,e.y/e.y),e.lerp=(e,t,n)=>e*(1-n)+t*n,e.mod=(e,t)=>(e%t+t)%t,e.mul=(e,r)=>`z`in e&&`z`in r?new n(e.x*r.x,e.y*e.y,e.z*e.z):new t(e.x*r.x,e.y*e.y),e.randRange=(e,t)=>e+Math.random()*t,e.sub=(e,r)=>`z`in e&&`z`in r?new n(e.x-r.x,e.y-e.y,e.z-e.z):new t(e.x-r.x,e.y-e.y)});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.index={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=class e{constructor(e,t){this.x=e,this.y=t}static initial(t){return new e(t,t)}static empty(){return new e(0,0)}add(e){return typeof e==`number`?this.x+=e:this.x+=e.x,typeof e==`number`?this.y+=e:this.y+=e.y,this}sub(e){return typeof e==`number`?this.x-=e:this.x-=e.x,typeof e==`number`?this.y-=e:this.y-=e.y,this}mul(e){return typeof e==`number`?this.x*=e:this.x*=e.x,typeof e==`number`?this.y*=e:this.y*=e.y,this}div(e){return typeof e==`number`?this.x/=e:this.x/=e.x,typeof e==`number`?this.y/=e:this.y/=e.y,this}map(e){return this.x=e(this.x),this.y=e(this.y),this}toArr(){return[this.x,this.y,0]}},n=class e extends t{constructor(e,t,n){super(e,t),this.z=n}static initial(t){return new e(t,t,t)}static empty(){return new e(0,0,0)}static fromHex(t){return new e(parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16))}add(e){return typeof e==`number`?this.x+=e:this.x+=e.x,typeof e==`number`?this.y+=e:this.y+=e.y,typeof e==`number`?this.z+=e:this.z+=e.z,this}sub(e){return typeof e==`number`?this.x-=e:this.x-=e.x,typeof e==`number`?this.y-=e:this.y-=e.y,typeof e==`number`?this.z-=e:this.z-=e.z,this}mul(e){return this.x*=typeof e==`number`?e:e.x,this.y*=typeof e==`number`?e:e.y,this.z*=typeof e==`number`?e:e.z,this}div(e){return typeof e==`number`?this.x/=e:this.x/=e.x,typeof e==`number`?this.y/=e:this.y/=e.y,typeof e==`number`?this.z/=e:this.z/=e.z,this}map(e){return this.x=e(this.x),this.y=e(this.y),this.z=e(this.z),this}toArr(){return[this.x,this.y,this.z]}};e.Vec2=t,e.Vec3=n,e.add=(e,r)=>`z`in e&&`z`in r?new n(e.x+r.x,e.y+e.y,e.z+e.z):new t(e.x+r.x,e.y+e.y),e.approach=(e,t,n)=>e<t?Math.min(e+n,t):Math.max(e-n,t),e.chooseRand=e=>e[Math.floor(Math.random()*e.length)],e.clamp=(e,t,n)=>Math.max(Math.min(e,n),t),e.div=(e,r)=>`z`in e&&`z`in r?new n(e.x/r.x,e.y/e.y,e.z/e.z):new t(e.x/r.x,e.y/e.y),e.lerp=(e,t,n)=>e*(1-n)+t*n,e.mod=(e,t)=>(e%t+t)%t,e.mul=(e,r)=>`z`in e&&`z`in r?new n(e.x*r.x,e.y*e.y,e.z*e.z):new t(e.x*r.x,e.y*e.y),e.randRange=(e,t)=>e+Math.random()*(t-e),e.sub=(e,r)=>`z`in e&&`z`in r?new n(e.x-r.x,e.y-e.y,e.z-e.z):new t(e.x-r.x,e.y-e.y)});
|
package/dist/src/functions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vec2, Vec3 } from './vectors.js';
|
|
2
2
|
export declare const chooseRand: <T>(arr: T[]) => T;
|
|
3
3
|
export declare const mod: (x: number, m: number) => number;
|
|
4
|
-
export declare const randRange: (
|
|
4
|
+
export declare const randRange: (min: number, max: number) => number;
|
|
5
5
|
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
6
6
|
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
7
7
|
export declare const approach: (current: number, target: number, dt: number) => number;
|
package/package.json
CHANGED