本文整理汇总了TypeScript中framesync.timeSinceLastFrame函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timeSinceLastFrame函数的具体用法?TypeScript timeSinceLastFrame怎么用?TypeScript timeSinceLastFrame使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeSinceLastFrame函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: onFrame
tweenTimer = onFrame().start(() => {
elapsed += timeSinceLastFrame() * playDirection;
updateTween();
if (isTweenComplete() && complete) {
tweenTimer.stop();
onFrameUpdate(complete, true);
}
});
示例2: onFrame
const timer = onFrame().start(() => {
// Integration doesn't work well with very low numbers
const elapsed = Math.max(timeSinceLastFrame(), 16);
if (acceleration) velocity += speedPerFrame(acceleration, elapsed);
if (friction) velocity *= (1 - friction) ** (elapsed / 100);
if (springStrength !== undefined && to !== undefined) {
const distanceToTarget = to - current;
velocity += distanceToTarget * speedPerFrame(springStrength, elapsed);
}
current += speedPerFrame(velocity, elapsed);
update(current);
const isComplete = (restSpeed !== false && (!velocity || Math.abs(velocity) <= restSpeed));
if (isComplete) {
timer.stop();
complete();
}
});
示例3: update
// TODO: Schedule a velocity check on the next frame
update(v: Value) {
super.update(v);
this.prev = this.current;
this.updateCurrent(v);
this.timeDelta = timeSinceLastFrame();
}