5180 fichiers 38.5 Mo 0 téléchargements 272 vues mis à jour il y a 6 heures ui
nitro-v36-with-renderer-v36 / src / api / octane / room / AddAnimationTickerCallback.ts
AddAnimationTickerCallback.ts 959 o Télécharger le fichier
import { GetTicker, OctaneTicker } from '@octane/renderer';
import { GetConfigurationValue } from '../GetConfigurationValue';

// Milliseconds between frames of the room's animation clock (system.fps.animation, 24 Hz).
export const GetAnimationFrameInterval = (): number => 1000 / (GetConfigurationValue<number>('system.fps.animation', 24) || 24);

// Runs the callback on the room's animation clock instead of every render
// frame; returns the unsubscriber.
export const AddAnimationTickerCallback = (callback: () => void): (() => void) => {
    const interval = GetAnimationFrameInterval();
    let elapsed = interval;

    const update = (ticker: OctaneTicker) => {
        elapsed += ticker.deltaMS;

        if (elapsed < interval) return;

        // Keep the remainder so the cadence averages out to the clock rate.
        elapsed %= interval;
        callback();
    };

    GetTicker().add(update);

    return () => GetTicker().remove(update);
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser