R3F-Perf
Changelog
Easily monitor the performances of your @react-three/fiber application.
Add the Perf component anywhere in your Canvas. |
|
Installation
yarn add --dev r3f-perf
Options
antialias?: true,
overClock?: false,
deepAnalyze?: false,
showGraph?: true
minimal?: false
customData?: {
value: 0,
name: '',
round: 2,
info: '',
}
matrixUpdate?: false
chart?: {
hz: 60,
length: 120,
}
colorBlind?: false
className?: ''
style?: {}
position?: 'top-right'|'top-left'|'bottom-right'|'bottom-left'
Usage
import { Canvas } from '@react-three/fiber';
import { Perf } from 'r3f-perf';
<Canvas>
<Perf />
</Canvas>;
Usage without interface : PerfHeadless
Codesandbox Example
import { Canvas } from '@react-three/fiber';
import { PerfHeadless, usePerf } from 'r3f-perf';
const PerfHook = () => {
const [gl, log, getReport] = usePerf(s=> s[s.gl, s.log, s.getReport]);
console.log(gl, log, getReport());
return null;
};
export default function App() {
return (
<Canvas>
<PerfHeadless />
<PerfHook />
</Canvas>
);
}
Custom Data
import { setCustomData, getCustomData } from 'r3f-perf';
const UpdateCustomData = () => {
useFrame(() => {
setCustomData(55 + Math.random() * 5)
})
return null
}
SSR
The tool work with any server side rendering framework. You can try with Next and @react-three/fiber using this starter :
https://github.com/pmndrs/react-three-next
Maintainers :