當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript cancelSync.update方法代碼示例

本文整理匯總了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);
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:9,代碼來源:index.ts

示例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);
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:13,代碼來源:index.ts

示例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);
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:46,代碼來源:index.ts

示例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);
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:24,代碼來源:index.ts

示例5:

 stop: () => {
   cancelSync.update(updatePoint);
   updateOnMove.stop();
 }
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:4,代碼來源:index.ts

示例6:

 stop: () => cancelSync.update(process)
開發者ID:Popmotion,項目名稱:popmotion,代碼行數:1,代碼來源:index.ts


注:本文中的framesync.cancelSync.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。