Files
discord-decomp/_bundle/Module1684.js
T
2026-11-01 12:12:55 +02:00

30 lines
1.7 KiB
JavaScript

// Metro module 1684 (f1685).
import * as _Module1682 from "./Module1682";
export function rigidDecay(a0, a1, a2) {
const { lastTimestamp, startTimestamp, initialVelocity, current, velocity } = a0;
const r19 = Math.min(Math.max(a1 - lastTimestamp, 0), 64);
const velocity2 = velocity * Math.exp(-(1 - a2.deceleration) * (a1 - startTimestamp) * _Module1682.SLOPE_FACTOR);
a0.current = current + velocity2 * a2.velocityFactor * r19 / 1000;
a0.velocity = velocity2;
a0.lastTimestamp = a1;
if (a2.clamp) {
if (initialVelocity < 0 && a0.current <= a2.clamp[0]) {
a0.current = a2.clamp[0];
return true;
}
if (initialVelocity > 0 && a0.current >= a2.clamp[1]) {
a0.current = a2.clamp[1];
return true;
}
}
return Math.abs(velocity2) < _Module1682.VELOCITY_EPS;
}
rigidDecay.__closure = {
SLOPE_FACTOR: _Module1682.SLOPE_FACTOR,
VELOCITY_EPS: _Module1682.VELOCITY_EPS
};
rigidDecay.__workletHash = 6356485112123;
rigidDecay.__initData = {
code: "function rigidDecay_Pnpm_rigidDecayTs1(animation,now,config){const{SLOPE_FACTOR,VELOCITY_EPS}=this.__closure;const{lastTimestamp:lastTimestamp,startTimestamp:startTimestamp,initialVelocity:initialVelocity,current:current,velocity:velocity}=animation;const deltaTime=Math.min(Math.max(now-lastTimestamp,0),64);const v=velocity*Math.exp(-(1-config.deceleration)*(now-startTimestamp)*SLOPE_FACTOR);animation.current=current+v*config.velocityFactor*deltaTime/1000;animation.velocity=v;animation.lastTimestamp=now;if(config.clamp){if(initialVelocity<0&&animation.current<=config.clamp[0]){animation.current=config.clamp[0];return true;}else if(initialVelocity>0&&animation.current>=config.clamp[1]){animation.current=config.clamp[1];return true;}}return Math.abs(v)<VELOCITY_EPS;}"
};