本文整理汇总了TypeScript中framesync.cancelSync.update方法的典型用法代码示例。如果您正苦于以下问题:TypeScript cancelSync.update方法的具体用法?TypeScript cancelSync.update怎么用?TypeScript cancelSync.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类framesync.cancelSync
的用法示例。
在下文中一共展示了cancelSync.update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: updateTween
process = sync.update(({ delta }) => {
// TODO Maybe try something different to eat the variations in framerate
elapsed += delta * playDirection;
updateTween();
if (isTweenComplete() && complete) {
cancelSync.update(process);
sync.update(complete, false, true);
}
}, true);
示例2: update
const process = sync.update(({ delta: frameDelta }) => {
elapsed += frameDelta;
const delta = -amplitude * Math.exp(-elapsed / timeConstant);
const isMoving = delta > restDelta || delta < -restDelta;
const current = isMoving ? target + delta : target;
update(current);
if (!isMoving) {
cancelSync.update(process);
complete();
}
}, true);
示例3: speedPerSecond
const process = sync.update(({ delta: timeDelta }) => {
t += timeDelta;
const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
const angularFreq = Math.sqrt(stiffness / mass) / 1000;
prevPosition = position;
// Underdamped
if (dampingRatio < 1) {
const envelope = Math.exp(-dampingRatio * angularFreq * t);
const expoDecay =
angularFreq * Math.sqrt(1.0 - dampingRatio * dampingRatio);
position =
to -
envelope *
(((initialVelocity + dampingRatio * angularFreq * delta) /
expoDecay) *
Math.sin(expoDecay * t) +
delta * Math.cos(expoDecay * t));
} else {
const envelope = Math.exp(-angularFreq * t);
position =
to -
envelope * (delta + (initialVelocity + angularFreq * delta) * t);
}
velocity = speedPerSecond(position - prevPosition, timeDelta);
// Check if simulation is complete
// We do this here instead of `isActionComplete` as it allows us
// to clamp to end during update)
const isBelowVelocityThreshold = Math.abs(velocity) <= restSpeed;
const isBelowDisplacementThreshold =
Math.abs(to - position) <= restDelta;
if (isBelowVelocityThreshold && isBelowDisplacementThreshold) {
position = to;
update(position);
cancelSync.update(process);
complete();
} else {
update(position);
}
}, true);
示例4: speedPerFrame
const process = sync.update(({ delta }) => {
// Integration doesn't work well with very low numbers
const elapsed = Math.max(delta, 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) {
cancelSync.update(process);
complete();
}
}, true);
示例5:
stop: () => {
cancelSync.update(updatePoint);
updateOnMove.stop();
}