本文整理匯總了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();
}