Files
avz-site/node_modules/@react-three/drei/core/useAspect.js
T
2026-05-30 19:59:39 -03:00

11 lines
427 B
JavaScript

import { useThree } from '@react-three/fiber';
function useAspect(width, height, factor = 1) {
const v = useThree(state => state.viewport);
const adaptedHeight = height * (v.aspect > width / height ? v.width / width : v.height / height);
const adaptedWidth = width * (v.aspect > width / height ? v.width / width : v.height / height);
return [adaptedWidth * factor, adaptedHeight * factor, 1];
}
export { useAspect };