轻松监控您的 ThreeJS 性能。
变更记录 轻松监控您的 @React-three/光纤应用程序的性能。 在 Canvas 中的任何位置添加 Perf 组件。
yarn add --dev r3f-perf…import { Canvas } from '@react-three/fiber'
import { Perf } from 'r3f-perf'
function App() {
return (
)
}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 (
)
}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
}该工具可与任何服务器端渲染框架一起使用。您可以尝试使用此入门工具与 Next 和 @React-three/fiber 进行搭配: https://github.com/pmndrs/react-three-next
暂无开放 Issues,或尚未同步最近议题。