UNPKG

@threlte/xr

Version:

Tools to more easily create VR and AR experiences with Threlte

18 lines (17 loc) 558 B
import { useTask } from '@threlte/core'; /** * A fixed useTask, based on https://github.com/threlte/threlte/pull/654 * * @Todo Can be removed if this or a similar feature is merged. */ export const useFixed = (fn, options) => { let fixedStepTimeAccumulator = 0; let fixedStep = options.fixedStep ?? 1 / 60; return useTask((delta) => { fixedStepTimeAccumulator += delta; while (fixedStepTimeAccumulator >= fixedStep) { fixedStepTimeAccumulator -= fixedStep; fn(fixedStep); } }, options); };