We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
static smoothDamp(current: number, target: number, currentVelocity: number, smoothTime: number, maxSpeed?: number, deltaTime?: number): number[] { deltaTime = deltaTime ? deltaTime : Laya.timer.delta * 0.001; maxSpeed = maxSpeed ? maxSpeed : Number.MAX_VALUE; smoothTime = Math.max(0.0001, smoothTime); let num = 2 / smoothTime; let num2 = num * deltaTime; let num3 = 1 / (1 + num2 + 0.48 * num2 * num2 + 0.235 * num2 * num2 * num2); let num4 = current - target; let num5 = target; let max = maxSpeed * smoothTime; num4 = this.clamp(num4, -max, max); target = current - num4; let num7 = (currentVelocity + (num * num4)) * deltaTime; currentVelocity = (currentVelocity - num * num7) * num3; let num8 = target + (num4 + num7) * num3;
if ((num5 > current) == (num8 > num5)) { num8 = num5; currentVelocity = (num8 - num5) / deltaTime; } return [num8, currentVelocity]; }
return [current, currentVelocity]
It has been tested and perfect!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
static smoothDamp(current: number, target: number, currentVelocity: number, smoothTime: number, maxSpeed?: number, deltaTime?: number): number[] {
deltaTime = deltaTime ? deltaTime : Laya.timer.delta * 0.001;
maxSpeed = maxSpeed ? maxSpeed : Number.MAX_VALUE;
smoothTime = Math.max(0.0001, smoothTime);
let num = 2 / smoothTime;
let num2 = num * deltaTime;
let num3 = 1 / (1 + num2 + 0.48 * num2 * num2 + 0.235 * num2 * num2 * num2);
let num4 = current - target;
let num5 = target;
let max = maxSpeed * smoothTime;
num4 = this.clamp(num4, -max, max);
target = current - num4;
let num7 = (currentVelocity + (num * num4)) * deltaTime;
currentVelocity = (currentVelocity - num * num7) * num3;
let num8 = target + (num4 + num7) * num3;
return [current, currentVelocity]
It has been tested and perfect!
The text was updated successfully, but these errors were encountered: