Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

r3f-perf

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

r3f-perf

Easily monitor your ThreeJS performances.

  • 7.0.0-beta.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm npm

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, // Take a bit more performances but render the text with antialiasing
overClock?: false, // Disable the limitation of the monitor refresh rate for the fps
deepAnalyze?: false, // More detailed informations about gl programs
showGraph?: true // show the graphs
minimal?: false // condensed version with the most important informations (gpu/memory/fps/custom data)
customData?: {
  value: 0, // initial value,
  name: '', // name to show
  round: 2, // precision of the float
  info: '', // additional information about the data (fps/ms for instance)
}
matrixUpdate?: false // count the number of time matrixWorldUpdate is called per frame
chart?: {
  hz: 60, // graphs refresh frequency parameter
  length: 120, // number of values shown on the monitor
}
colorBlind?: false // Color blind colors for accessibility
className?: '' // override CSS class
style?: {} // override style
position?: 'top-right'|'top-left'|'bottom-right'|'bottom-left' // quickly set the position, default is top-right

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 = () => {
  // getPerf() is also available for non-reactive way or to access values outside react
  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 = () => {
  // recommended to throttle to 1sec for readability
  useFrame(() => {
    setCustomData(55 + Math.random() * 5) // will update the panel with the current information
  })
  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 :

Keywords

FAQs

Package last updated on 30 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc