15 lines
376 B
JavaScript
15 lines
376 B
JavaScript
import {useCallback, useState} from 'react';
|
|
|
|
import useAnimationFrame from '@/react/hooks/use-animation-frame.js';
|
|
import {TAU} from '@/util/math.js';
|
|
|
|
export function useRadians() {
|
|
const [radians, setRadians] = useState(0);
|
|
useAnimationFrame(
|
|
useCallback((elapsed) => {
|
|
setRadians((radians) => radians + (elapsed * TAU));
|
|
}, []),
|
|
);
|
|
return radians;
|
|
}
|