SmoothDamp
smoothTime というパラメータで比較的直感的にCDSを利用できるのが特徴
code:ts
export class SmoothDamp {
public smoothTime = 1.0;
public velocity = 0.0;
public value = 0.0;
public target = 0.0;
public update( deltaTime: number ): number {
const omega = 2.0 / this.smoothTime;
const x = omega * deltaTime;
const exp = 1.0 / ( 1.0 + x + 0.48 * x * x + 0.235 * x * x * x );
const delta = this.value - this.target;
const temp = ( this.velocity + omega * delta ) * deltaTime;
this.velocity = ( this.velocity - omega * temp ) * exp;
this.value = this.target + ( delta + temp ) * exp;
return this.value;
}
}