Issue
https://codesandbox.io/s/r3f-perf-issue-with-gl-0do0bm
const perf = getPerf()
console.log(perf.gl?.info.render.calls) // 0
console.log(perf.gl?.info.render.triangles) // 0
I think this is because of the gl.info.reset() in https://github.com/utsuboco/r3f-perf/blob/main/src/components/PerfHeadless.tsx#L262
Possible fix
Could we save render.calls and render.triangles in the store? In this way we don't break code which relies on that number.
Possible workaround
const info = usePerf((state) => state.gl?.info)
useFrame((state) => {
const { camera, gl, scene } = state
gl.render(scene, camera)
console.log(info.render.frames)
}, 1)
I'm not sure though if this can cause some issue. Do gl.render() gets called twice in this way? Once for useFrame(...,1) and then for useFrame(..., Infinity)?
|
const Renderer = () =>{ |
|
|
|
useFrame(function updateR3FPerf({ gl, scene, camera }) { |
|
camera.updateMatrix() |
|
matriceCount.value -= 1 |
|
camera.matrixWorld.copy(camera.matrix) |
|
camera.matrixWorldInverse.copy(camera.matrixWorld).invert(); |
|
gl.render(scene,camera) |
|
matriceWorldCount.value = 0 |
|
matriceCount.value = 0 |
|
}, Infinity) |
|
|
|
|
|
return null |
|
} |
Issue
https://codesandbox.io/s/r3f-perf-issue-with-gl-0do0bm
I think this is because of the
gl.info.reset()in https://github.com/utsuboco/r3f-perf/blob/main/src/components/PerfHeadless.tsx#L262Possible fix
Could we save
render.callsandrender.trianglesin the store? In this way we don't break code which relies on that number.Possible workaround
I'm not sure though if this can cause some issue. Do
gl.render()gets called twice in this way? Once foruseFrame(...,1)and then foruseFrame(..., Infinity)?r3f-perf/src/components/Graph.tsx
Lines 202 to 216 in 6497ade