### Installing R3F-Perf Development Dependency (Bash) Source: https://github.com/utsuboco/r3f-perf/blob/main/README.md This command installs the `r3f-perf` library as a development dependency using Yarn. It is required to integrate the performance monitoring tool into a React Three Fiber project. ```bash yarn add --dev r3f-perf ``` -------------------------------- ### Using PerfHeadless and usePerf Hook for Programmatic Access (JSX) Source: https://github.com/utsuboco/r3f-perf/blob/main/README.md This snippet illustrates how to use `PerfHeadless` for performance monitoring without a visible UI, combined with the `usePerf` hook to programmatically access performance data. The hook provides reactive access to WebGL context, log data, and a function to get a full report, enabling custom logging or integration with other systems. ```jsx import { Canvas } from '@react-three/fiber' import { PerfHeadless, usePerf } from 'r3f-perf' const PerfHook = () => { // getPerf() is also available for non-reactive way const [gl, log, getReport] = usePerf((s) => s[(s.gl, s.log, s.getReport)]) console.log(gl, log, getReport()) return } function App() { return ( ) } ``` -------------------------------- ### Integrating Perf Component into React Three Fiber Canvas (JSX) Source: https://github.com/utsuboco/r3f-perf/blob/main/README.md This example demonstrates the basic integration of the `Perf` component into a `@react-three/fiber` application. By simply adding `` inside the `` component, the performance monitor is activated and displayed within the 3D scene. ```jsx import { Canvas } from '@react-three/fiber' import { Perf } from 'r3f-perf' function App() { return ( ) } ``` -------------------------------- ### Updating Custom Performance Data in R3F-Perf (JSX) Source: https://github.com/utsuboco/r3f-perf/blob/main/README.md This example shows how to dynamically update custom data displayed by `r3f-perf` using the `setCustomData` function within a `useFrame` hook. This allows developers to monitor application-specific metrics alongside standard performance indicators, enhancing the utility of the performance panel. ```jsx 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 } ``` -------------------------------- ### Configuring R3F-Perf Component Options (JSX) Source: https://github.com/utsuboco/r3f-perf/blob/main/README.md This snippet outlines the various configuration options available for the `Perf` component. These options control aspects like log refresh rate, antialiasing, deep analysis, graph visibility, custom data display, and component positioning, allowing users to customize the performance monitor's behavior and appearance. ```jsx logsPerSecond?: 10, // Refresh rate of the logs 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 ``` -------------------------------- ### Applying Eric Meyer's CSS Reset 2.0 Source: https://github.com/utsuboco/r3f-perf/blob/main/demo/index.html This snippet implements Eric Meyer's 'Reset CSS 2.0', a widely used stylesheet that resets the default styling of most HTML elements. It aims to reduce browser inconsistencies in rendering by setting common properties like margin, padding, and border to zero, and normalizing font and display behaviors. This provides a consistent foundation for developers to build their custom styles upon. ```css /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } table { border-collapse: collapse; border-spacing: 0; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.