Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

buildwithflux/r3f-perf

 
 

Repository files navigation

npm npm

Forked to make work woth react v18 RC

R3F-Perf

Easily monitor the performances of your @react-three/fiber application. r3f-perf.js is 6.23 KB.

Add the Perf component anywhere in your Canvas.

Installation

yarn add --dev r3f-perf

Options

headless?: false, // Without UI. See Headless section
showGraph?: true // show the graphs
chart?: {
  hz: 60, // graphs refresh frequency parameter
  length: 120, // number of values shown on the monitor
}
colorBlind?: false // Color blind colors for accessibility
trackGPU?: true // show a graph of the GPU
trackCPU?: false // show a graph of the CPU (Experimental as it should require a server, so might not be relevant)
openByDefault?: false // show more informations by default
className?: false // override CSS class
position?: 'top-right'|'top-left'|'bottom-right'|'bottom-left' // override position, default is top-right

Usage

import { Canvas } from '@react-three/fiber';
import { Perf } from 'r3f-perf';

<Canvas>
  <Perf />
</Canvas>;

Usage without interface : headless mode

import { Canvas } from '@react-three/fiber';
import { Perf, usePerf } from 'r3f-perf';

const PerfHook = () => {
  const { gl, log } = usePerf();
  console.log(gl, log);
  return null;
};

export default function App() {
  return (
    <Canvas>
      <Perf headless />
      <PerfHook />
    </Canvas>
  );
}

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

Feature ideas todo :

  • Convert all DOM text to shader to increase the refresh rate
  • Buffer frame and Forward rendering differenciation in the "calls" section of the UI
  • Postprocess shaders differenciation
  • Deep analytics about the shaders (list the types of material/shader)
  • Lights informations in the scene
  • Show the number of items receiving and casting shadow in the scene
  • Add an audit button to find what consume the most CPU/GPU in the app for every loop

Maintainers :

Packages

No packages published

Languages

  • TypeScript 80.7%
  • JavaScript 18.0%
  • Other 1.3%