basic setup

This commit is contained in:
nicwands
2026-05-18 15:13:23 -04:00
parent c4113658f7
commit a54e63323f
33 changed files with 2563 additions and 43 deletions

22
libs/math.js Normal file
View File

@@ -0,0 +1,22 @@
export function clamp(min, input, max) {
return Math.max(min, Math.min(input, max))
}
export function mapRange(in_min, in_max, input, out_min, out_max) {
return (
((input - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min
)
}
export function lerp(start, end, amt) {
return (1 - amt) * start + amt * end
}
export function truncate(value, decimals) {
return parseFloat(value.toFixed(decimals))
}
export function wrapValue(value, lowBound, highBound) {
const range = highBound - lowBound
return ((((value - lowBound) % range) + range) % range) + lowBound
}